aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/bfa')
-rw-r--r--drivers/scsi/bfa/Makefile17
-rw-r--r--drivers/scsi/bfa/bfa.h408
-rw-r--r--drivers/scsi/bfa/bfa_callback_priv.h57
-rw-r--r--drivers/scsi/bfa/bfa_cb_ioim_macros.h181
-rw-r--r--drivers/scsi/bfa/bfa_cee.c492
-rw-r--r--drivers/scsi/bfa/bfa_core.c1256
-rw-r--r--drivers/scsi/bfa/bfa_cs.h366
-rw-r--r--drivers/scsi/bfa/bfa_csdebug.c58
-rw-r--r--drivers/scsi/bfa/bfa_defs.h466
-rw-r--r--drivers/scsi/bfa/bfa_defs_fcs.h457
-rw-r--r--drivers/scsi/bfa/bfa_defs_svc.h1081
-rw-r--r--drivers/scsi/bfa/bfa_fc.h (renamed from drivers/scsi/bfa/include/protocol/fc.h)1024
-rw-r--r--drivers/scsi/bfa/bfa_fcbuild.c (renamed from drivers/scsi/bfa/fcbuild.c)512
-rw-r--r--drivers/scsi/bfa/bfa_fcbuild.h316
-rw-r--r--drivers/scsi/bfa/bfa_fcpim.c3129
-rw-r--r--drivers/scsi/bfa/bfa_fcpim.h355
-rw-r--r--drivers/scsi/bfa/bfa_fcpim_priv.h192
-rw-r--r--drivers/scsi/bfa/bfa_fcport.c1962
-rw-r--r--drivers/scsi/bfa/bfa_fcs.c1334
-rw-r--r--drivers/scsi/bfa/bfa_fcs.h804
-rw-r--r--drivers/scsi/bfa/bfa_fcs_fcpim.c (renamed from drivers/scsi/bfa/fcpim.c)301
-rw-r--r--drivers/scsi/bfa/bfa_fcs_lport.c5475
-rw-r--r--drivers/scsi/bfa/bfa_fcs_port.c61
-rw-r--r--drivers/scsi/bfa/bfa_fcs_rport.c (renamed from drivers/scsi/bfa/rport.c)1748
-rw-r--r--drivers/scsi/bfa/bfa_fcs_uf.c99
-rw-r--r--drivers/scsi/bfa/bfa_fcxp.c774
-rw-r--r--drivers/scsi/bfa/bfa_fcxp_priv.h138
-rw-r--r--drivers/scsi/bfa/bfa_fwimg_priv.h44
-rw-r--r--drivers/scsi/bfa/bfa_hw_cb.c27
-rw-r--r--drivers/scsi/bfa/bfa_hw_ct.c38
-rw-r--r--drivers/scsi/bfa/bfa_intr.c270
-rw-r--r--drivers/scsi/bfa/bfa_intr_priv.h117
-rw-r--r--drivers/scsi/bfa/bfa_ioc.c2330
-rw-r--r--drivers/scsi/bfa/bfa_ioc.h355
-rw-r--r--drivers/scsi/bfa/bfa_ioc_cb.c264
-rw-r--r--drivers/scsi/bfa/bfa_ioc_ct.c408
-rw-r--r--drivers/scsi/bfa/bfa_iocfc.c927
-rw-r--r--drivers/scsi/bfa/bfa_iocfc.h184
-rw-r--r--drivers/scsi/bfa/bfa_iocfc_q.c44
-rw-r--r--drivers/scsi/bfa/bfa_ioim.c1364
-rw-r--r--drivers/scsi/bfa/bfa_itnim.c1088
-rw-r--r--drivers/scsi/bfa/bfa_log.c346
-rw-r--r--drivers/scsi/bfa/bfa_log_module.c537
-rw-r--r--drivers/scsi/bfa/bfa_lps.c892
-rw-r--r--drivers/scsi/bfa/bfa_lps_priv.h38
-rw-r--r--drivers/scsi/bfa/bfa_module.c90
-rw-r--r--drivers/scsi/bfa/bfa_modules.h (renamed from drivers/scsi/bfa/bfa_priv.h)71
-rw-r--r--drivers/scsi/bfa/bfa_modules_priv.h43
-rw-r--r--drivers/scsi/bfa/bfa_os_inc.h237
-rw-r--r--drivers/scsi/bfa/bfa_plog.h (renamed from drivers/scsi/bfa/include/cs/bfa_plog.h)124
-rw-r--r--drivers/scsi/bfa/bfa_port.c207
-rw-r--r--drivers/scsi/bfa/bfa_port.h65
-rw-r--r--drivers/scsi/bfa/bfa_port_priv.h94
-rw-r--r--drivers/scsi/bfa/bfa_rport.c906
-rw-r--r--drivers/scsi/bfa/bfa_rport_priv.h45
-rw-r--r--drivers/scsi/bfa/bfa_sgpg.c226
-rw-r--r--drivers/scsi/bfa/bfa_sgpg_priv.h79
-rw-r--r--drivers/scsi/bfa/bfa_sm.c38
-rw-r--r--drivers/scsi/bfa/bfa_svc.c5075
-rw-r--r--drivers/scsi/bfa/bfa_svc.h621
-rw-r--r--drivers/scsi/bfa/bfa_timer.c90
-rw-r--r--drivers/scsi/bfa/bfa_trcmod_priv.h64
-rw-r--r--drivers/scsi/bfa/bfa_tskim.c690
-rw-r--r--drivers/scsi/bfa/bfa_uf.c343
-rw-r--r--drivers/scsi/bfa/bfa_uf_priv.h47
-rw-r--r--drivers/scsi/bfa/bfad.c1469
-rw-r--r--drivers/scsi/bfa/bfad_attr.c295
-rw-r--r--drivers/scsi/bfa/bfad_attr.h56
-rw-r--r--drivers/scsi/bfa/bfad_debugfs.c89
-rw-r--r--drivers/scsi/bfa/bfad_drv.h276
-rw-r--r--drivers/scsi/bfa/bfad_fwimg.c131
-rw-r--r--drivers/scsi/bfa/bfad_im.c363
-rw-r--r--drivers/scsi/bfa/bfad_im.h47
-rw-r--r--drivers/scsi/bfa/bfad_im_compat.h45
-rw-r--r--drivers/scsi/bfa/bfad_intr.c222
-rw-r--r--drivers/scsi/bfa/bfad_ipfc.h42
-rw-r--r--drivers/scsi/bfa/bfad_os.c50
-rw-r--r--drivers/scsi/bfa/bfad_tm.h59
-rw-r--r--drivers/scsi/bfa/bfad_trcmod.h52
-rw-r--r--drivers/scsi/bfa/bfi.h579
-rw-r--r--drivers/scsi/bfa/bfi_cbreg.h (renamed from drivers/scsi/bfa/include/bfi/bfi_cbreg.h)26
-rw-r--r--drivers/scsi/bfa/bfi_ctreg.h636
-rw-r--r--drivers/scsi/bfa/bfi_ms.h775
-rw-r--r--drivers/scsi/bfa/fab.c62
-rw-r--r--drivers/scsi/bfa/fabric.c1323
-rw-r--r--drivers/scsi/bfa/fcbuild.h279
-rw-r--r--drivers/scsi/bfa/fcptm.c68
-rw-r--r--drivers/scsi/bfa/fcs.h30
-rw-r--r--drivers/scsi/bfa/fcs_auth.h37
-rw-r--r--drivers/scsi/bfa/fcs_fabric.h68
-rw-r--r--drivers/scsi/bfa/fcs_fcpim.h39
-rw-r--r--drivers/scsi/bfa/fcs_fcptm.h45
-rw-r--r--drivers/scsi/bfa/fcs_fcxp.h29
-rw-r--r--drivers/scsi/bfa/fcs_lport.h118
-rw-r--r--drivers/scsi/bfa/fcs_ms.h35
-rw-r--r--drivers/scsi/bfa/fcs_port.h31
-rw-r--r--drivers/scsi/bfa/fcs_rport.h61
-rw-r--r--drivers/scsi/bfa/fcs_trcmod.h56
-rw-r--r--drivers/scsi/bfa/fcs_uf.h31
-rw-r--r--drivers/scsi/bfa/fcs_vport.h32
-rw-r--r--drivers/scsi/bfa/fdmi.c1230
-rw-r--r--drivers/scsi/bfa/include/aen/bfa_aen.h96
-rw-r--r--drivers/scsi/bfa/include/aen/bfa_aen_adapter.h31
-rw-r--r--drivers/scsi/bfa/include/aen/bfa_aen_audit.h31
-rw-r--r--drivers/scsi/bfa/include/aen/bfa_aen_ethport.h35
-rw-r--r--drivers/scsi/bfa/include/aen/bfa_aen_ioc.h45
-rw-r--r--drivers/scsi/bfa/include/aen/bfa_aen_itnim.h33
-rw-r--r--drivers/scsi/bfa/include/aen/bfa_aen_lport.h51
-rw-r--r--drivers/scsi/bfa/include/aen/bfa_aen_port.h57
-rw-r--r--drivers/scsi/bfa/include/aen/bfa_aen_rport.h37
-rw-r--r--drivers/scsi/bfa/include/bfa.h203
-rw-r--r--drivers/scsi/bfa/include/bfa_fcpim.h177
-rw-r--r--drivers/scsi/bfa/include/bfa_fcptm.h47
-rw-r--r--drivers/scsi/bfa/include/bfa_svc.h338
-rw-r--r--drivers/scsi/bfa/include/bfa_timer.h53
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi.h174
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_boot.h34
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_cee.h119
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_ctreg.h640
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_fabric.h92
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_fcpim.h301
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_fcxp.h71
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_ioc.h208
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_iocfc.h179
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_lport.h89
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_lps.h104
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_pbc.h62
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_port.h115
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_pport.h118
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_rport.h104
-rw-r--r--drivers/scsi/bfa/include/bfi/bfi_uf.h52
-rw-r--r--drivers/scsi/bfa/include/cna/bfa_cna_trcmod.h40
-rw-r--r--drivers/scsi/bfa/include/cna/cee/bfa_cee.h77
-rw-r--r--drivers/scsi/bfa/include/cna/port/bfa_port.h70
-rw-r--r--drivers/scsi/bfa/include/cna/pstats/ethport_defs.h36
-rw-r--r--drivers/scsi/bfa/include/cna/pstats/phyport_defs.h218
-rw-r--r--drivers/scsi/bfa/include/cs/bfa_checksum.h60
-rw-r--r--drivers/scsi/bfa/include/cs/bfa_debug.h45
-rw-r--r--drivers/scsi/bfa/include/cs/bfa_log.h184
-rw-r--r--drivers/scsi/bfa/include/cs/bfa_perf.h34
-rw-r--r--drivers/scsi/bfa/include/cs/bfa_q.h81
-rw-r--r--drivers/scsi/bfa/include/cs/bfa_sm.h77
-rw-r--r--drivers/scsi/bfa/include/cs/bfa_trc.h176
-rw-r--r--drivers/scsi/bfa/include/cs/bfa_wc.h68
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_adapter.h83
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_aen.h83
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_audit.h38
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_auth.h134
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_boot.h81
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_cee.h157
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_driver.h41
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_ethport.h99
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_fcpim.h45
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_fcport.h88
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_ioc.h158
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_iocfc.h322
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_ipfc.h70
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_itnim.h136
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_led.h35
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_lport.h68
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_mfg.h144
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_pci.h48
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_pm.h33
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_pom.h56
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_port.h248
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_pport.h393
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_qos.h99
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_rport.h199
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_status.h282
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_tin.h118
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_tsensor.h43
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_types.h30
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_version.h22
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_vf.h74
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_vport.h91
-rw-r--r--drivers/scsi/bfa/include/fcb/bfa_fcb.h33
-rw-r--r--drivers/scsi/bfa/include/fcb/bfa_fcb_fcpim.h75
-rw-r--r--drivers/scsi/bfa/include/fcb/bfa_fcb_port.h113
-rw-r--r--drivers/scsi/bfa/include/fcb/bfa_fcb_rport.h80
-rw-r--r--drivers/scsi/bfa/include/fcb/bfa_fcb_vf.h47
-rw-r--r--drivers/scsi/bfa/include/fcb/bfa_fcb_vport.h48
-rw-r--r--drivers/scsi/bfa/include/fcs/bfa_fcs.h76
-rw-r--r--drivers/scsi/bfa/include/fcs/bfa_fcs_auth.h82
-rw-r--r--drivers/scsi/bfa/include/fcs/bfa_fcs_fabric.h112
-rw-r--r--drivers/scsi/bfa/include/fcs/bfa_fcs_fcpim.h132
-rw-r--r--drivers/scsi/bfa/include/fcs/bfa_fcs_fdmi.h63
-rw-r--r--drivers/scsi/bfa/include/fcs/bfa_fcs_lport.h219
-rw-r--r--drivers/scsi/bfa/include/fcs/bfa_fcs_rport.h105
-rw-r--r--drivers/scsi/bfa/include/fcs/bfa_fcs_vport.h67
-rw-r--r--drivers/scsi/bfa/include/log/bfa_log_fcs.h28
-rw-r--r--drivers/scsi/bfa/include/log/bfa_log_hal.h36
-rw-r--r--drivers/scsi/bfa/include/log/bfa_log_linux.h62
-rw-r--r--drivers/scsi/bfa/include/log/bfa_log_wdrv.h36
-rw-r--r--drivers/scsi/bfa/include/protocol/ct.h492
-rw-r--r--drivers/scsi/bfa/include/protocol/fc_sp.h224
-rw-r--r--drivers/scsi/bfa/include/protocol/fcp.h184
-rw-r--r--drivers/scsi/bfa/include/protocol/fdmi.h163
-rw-r--r--drivers/scsi/bfa/include/protocol/scsi.h1648
-rw-r--r--drivers/scsi/bfa/include/protocol/types.h42
-rw-r--r--drivers/scsi/bfa/loop.c213
-rw-r--r--drivers/scsi/bfa/lport_api.c303
-rw-r--r--drivers/scsi/bfa/lport_priv.h82
-rw-r--r--drivers/scsi/bfa/ms.c759
-rw-r--r--drivers/scsi/bfa/n2n.c105
-rw-r--r--drivers/scsi/bfa/ns.c1242
-rw-r--r--drivers/scsi/bfa/plog.c184
-rw-r--r--drivers/scsi/bfa/rport_api.c185
-rw-r--r--drivers/scsi/bfa/rport_ftrs.c379
-rw-r--r--drivers/scsi/bfa/scn.c482
-rw-r--r--drivers/scsi/bfa/vfapi.c292
-rw-r--r--drivers/scsi/bfa/vport.c903
211 files changed, 28500 insertions, 39453 deletions
diff --git a/drivers/scsi/bfa/Makefile b/drivers/scsi/bfa/Makefile
index ac3fdf02d5f6..4ce6f4942327 100644
--- a/drivers/scsi/bfa/Makefile
+++ b/drivers/scsi/bfa/Makefile
@@ -1,15 +1,6 @@
1obj-$(CONFIG_SCSI_BFA_FC) := bfa.o 1obj-$(CONFIG_SCSI_BFA_FC) := bfa.o
2 2
3bfa-y := bfad.o bfad_intr.o bfad_os.o bfad_im.o bfad_attr.o bfad_fwimg.o 3bfa-y := bfad.o bfad_im.o bfad_attr.o bfad_debugfs.o
4bfa-y += bfad_debugfs.o 4bfa-y += bfa_ioc.o bfa_ioc_cb.o bfa_ioc_ct.o bfa_hw_cb.o bfa_hw_ct.o
5bfa-y += bfa_core.o bfa_ioc.o bfa_ioc_ct.o bfa_ioc_cb.o bfa_iocfc.o bfa_fcxp.o 5bfa-y += bfa_fcs.o bfa_fcs_lport.o bfa_fcs_rport.o bfa_fcs_fcpim.o bfa_fcbuild.o
6bfa-y += bfa_lps.o bfa_hw_cb.o bfa_hw_ct.o bfa_intr.o bfa_timer.o bfa_rport.o 6bfa-y += bfa_port.o bfa_fcpim.o bfa_core.o bfa_svc.o
7bfa-y += bfa_fcport.o bfa_port.o bfa_uf.o bfa_sgpg.o bfa_module.o bfa_ioim.o
8bfa-y += bfa_itnim.o bfa_fcpim.o bfa_tskim.o bfa_log.o bfa_log_module.o
9bfa-y += bfa_csdebug.o bfa_sm.o plog.o
10
11bfa-y += fcbuild.o fabric.o fcpim.o vfapi.o fcptm.o bfa_fcs.o bfa_fcs_port.o
12bfa-y += bfa_fcs_uf.o bfa_fcs_lport.o fab.o fdmi.o ms.o ns.o scn.o loop.o
13bfa-y += lport_api.o n2n.o rport.o rport_api.o rport_ftrs.o vport.o
14
15ccflags-y := -I$(obj) -I$(obj)/include -I$(obj)/include/cna -DBFA_PERF_BUILD
diff --git a/drivers/scsi/bfa/bfa.h b/drivers/scsi/bfa/bfa.h
new file mode 100644
index 000000000000..7be6b5a8114b
--- /dev/null
+++ b/drivers/scsi/bfa/bfa.h
@@ -0,0 +1,408 @@
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#ifndef __BFA_H__
18#define __BFA_H__
19
20#include "bfad_drv.h"
21#include "bfa_cs.h"
22#include "bfa_plog.h"
23#include "bfa_defs_svc.h"
24#include "bfi.h"
25#include "bfa_ioc.h"
26
27struct bfa_s;
28
29typedef void (*bfa_isr_func_t) (struct bfa_s *bfa, struct bfi_msg_s *m);
30typedef void (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete);
31
32/*
33 * Interrupt message handlers
34 */
35void bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m);
36
37/*
38 * Request and response queue related defines
39 */
40#define BFA_REQQ_NELEMS_MIN (4)
41#define BFA_RSPQ_NELEMS_MIN (4)
42
43#define bfa_reqq_pi(__bfa, __reqq) ((__bfa)->iocfc.req_cq_pi[__reqq])
44#define bfa_reqq_ci(__bfa, __reqq) \
45 (*(u32 *)((__bfa)->iocfc.req_cq_shadow_ci[__reqq].kva))
46
47#define bfa_reqq_full(__bfa, __reqq) \
48 (((bfa_reqq_pi(__bfa, __reqq) + 1) & \
49 ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1)) == \
50 bfa_reqq_ci(__bfa, __reqq))
51
52#define bfa_reqq_next(__bfa, __reqq) \
53 (bfa_reqq_full(__bfa, __reqq) ? NULL : \
54 ((void *)((struct bfi_msg_s *)((__bfa)->iocfc.req_cq_ba[__reqq].kva) \
55 + bfa_reqq_pi((__bfa), (__reqq)))))
56
57#define bfa_reqq_produce(__bfa, __reqq) do { \
58 (__bfa)->iocfc.req_cq_pi[__reqq]++; \
59 (__bfa)->iocfc.req_cq_pi[__reqq] &= \
60 ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1); \
61 writel((__bfa)->iocfc.req_cq_pi[__reqq], \
62 (__bfa)->iocfc.bfa_regs.cpe_q_pi[__reqq]); \
63 mmiowb(); \
64 } while (0)
65
66#define bfa_rspq_pi(__bfa, __rspq) \
67 (*(u32 *)((__bfa)->iocfc.rsp_cq_shadow_pi[__rspq].kva))
68
69#define bfa_rspq_ci(__bfa, __rspq) ((__bfa)->iocfc.rsp_cq_ci[__rspq])
70#define bfa_rspq_elem(__bfa, __rspq, __ci) \
71 (&((struct bfi_msg_s *)((__bfa)->iocfc.rsp_cq_ba[__rspq].kva))[__ci])
72
73#define CQ_INCR(__index, __size) do { \
74 (__index)++; \
75 (__index) &= ((__size) - 1); \
76} while (0)
77
78/*
79 * Queue element to wait for room in request queue. FIFO order is
80 * maintained when fullfilling requests.
81 */
82struct bfa_reqq_wait_s {
83 struct list_head qe;
84 void (*qresume) (void *cbarg);
85 void *cbarg;
86};
87
88/*
89 * Circular queue usage assignments
90 */
91enum {
92 BFA_REQQ_IOC = 0, /* all low-priority IOC msgs */
93 BFA_REQQ_FCXP = 0, /* all FCXP messages */
94 BFA_REQQ_LPS = 0, /* all lport service msgs */
95 BFA_REQQ_PORT = 0, /* all port messages */
96 BFA_REQQ_FLASH = 0, /* for flash module */
97 BFA_REQQ_DIAG = 0, /* for diag module */
98 BFA_REQQ_RPORT = 0, /* all port messages */
99 BFA_REQQ_SBOOT = 0, /* all san boot messages */
100 BFA_REQQ_QOS_LO = 1, /* all low priority IO */
101 BFA_REQQ_QOS_MD = 2, /* all medium priority IO */
102 BFA_REQQ_QOS_HI = 3, /* all high priority IO */
103};
104
105static inline void
106bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
107 void *cbarg)
108{
109 wqe->qresume = qresume;
110 wqe->cbarg = cbarg;
111}
112
113#define bfa_reqq(__bfa, __reqq) (&(__bfa)->reqq_waitq[__reqq])
114
115/*
116 * static inline void
117 * bfa_reqq_wait(struct bfa_s *bfa, int reqq, struct bfa_reqq_wait_s *wqe)
118 */
119#define bfa_reqq_wait(__bfa, __reqq, __wqe) do { \
120 \
121 struct list_head *waitq = bfa_reqq(__bfa, __reqq); \
122 \
123 WARN_ON(((__reqq) >= BFI_IOC_MAX_CQS)); \
124 WARN_ON(!((__wqe)->qresume && (__wqe)->cbarg)); \
125 \
126 list_add_tail(&(__wqe)->qe, waitq); \
127 } while (0)
128
129#define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe)
130
131
132/*
133 * Generic BFA callback element.
134 */
135struct bfa_cb_qe_s {
136 struct list_head qe;
137 bfa_cb_cbfn_t cbfn;
138 bfa_boolean_t once;
139 u32 rsvd;
140 void *cbarg;
141};
142
143#define bfa_cb_queue(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
144 (__hcb_qe)->cbfn = (__cbfn); \
145 (__hcb_qe)->cbarg = (__cbarg); \
146 list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
147 } while (0)
148
149#define bfa_cb_dequeue(__hcb_qe) list_del(&(__hcb_qe)->qe)
150
151#define bfa_cb_queue_once(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
152 (__hcb_qe)->cbfn = (__cbfn); \
153 (__hcb_qe)->cbarg = (__cbarg); \
154 if (!(__hcb_qe)->once) { \
155 list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
156 (__hcb_qe)->once = BFA_TRUE; \
157 } \
158 } while (0)
159
160#define bfa_cb_queue_done(__hcb_qe) do { \
161 (__hcb_qe)->once = BFA_FALSE; \
162 } while (0)
163
164
165/*
166 * PCI devices supported by the current BFA
167 */
168struct bfa_pciid_s {
169 u16 device_id;
170 u16 vendor_id;
171};
172
173extern char bfa_version[];
174
175/*
176 * BFA memory resources
177 */
178enum bfa_mem_type {
179 BFA_MEM_TYPE_KVA = 1, /* Kernel Virtual Memory *(non-dma-able) */
180 BFA_MEM_TYPE_DMA = 2, /* DMA-able memory */
181 BFA_MEM_TYPE_MAX = BFA_MEM_TYPE_DMA,
182};
183
184struct bfa_mem_elem_s {
185 enum bfa_mem_type mem_type; /* see enum bfa_mem_type */
186 u32 mem_len; /* Total Length in Bytes */
187 u8 *kva; /* kernel virtual address */
188 u64 dma; /* dma address if DMA memory */
189 u8 *kva_curp; /* kva allocation cursor */
190 u64 dma_curp; /* dma allocation cursor */
191};
192
193struct bfa_meminfo_s {
194 struct bfa_mem_elem_s meminfo[BFA_MEM_TYPE_MAX];
195};
196#define bfa_meminfo_kva(_m) \
197 ((_m)->meminfo[BFA_MEM_TYPE_KVA - 1].kva_curp)
198#define bfa_meminfo_dma_virt(_m) \
199 ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].kva_curp)
200#define bfa_meminfo_dma_phys(_m) \
201 ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].dma_curp)
202
203struct bfa_iocfc_regs_s {
204 void __iomem *intr_status;
205 void __iomem *intr_mask;
206 void __iomem *cpe_q_pi[BFI_IOC_MAX_CQS];
207 void __iomem *cpe_q_ci[BFI_IOC_MAX_CQS];
208 void __iomem *cpe_q_depth[BFI_IOC_MAX_CQS];
209 void __iomem *cpe_q_ctrl[BFI_IOC_MAX_CQS];
210 void __iomem *rme_q_ci[BFI_IOC_MAX_CQS];
211 void __iomem *rme_q_pi[BFI_IOC_MAX_CQS];
212 void __iomem *rme_q_depth[BFI_IOC_MAX_CQS];
213 void __iomem *rme_q_ctrl[BFI_IOC_MAX_CQS];
214};
215
216/*
217 * MSIX vector handlers
218 */
219#define BFA_MSIX_MAX_VECTORS 22
220typedef void (*bfa_msix_handler_t)(struct bfa_s *bfa, int vec);
221struct bfa_msix_s {
222 int nvecs;
223 bfa_msix_handler_t handler[BFA_MSIX_MAX_VECTORS];
224};
225
226/*
227 * Chip specific interfaces
228 */
229struct bfa_hwif_s {
230 void (*hw_reginit)(struct bfa_s *bfa);
231 void (*hw_reqq_ack)(struct bfa_s *bfa, int reqq);
232 void (*hw_rspq_ack)(struct bfa_s *bfa, int rspq);
233 void (*hw_msix_init)(struct bfa_s *bfa, int nvecs);
234 void (*hw_msix_install)(struct bfa_s *bfa);
235 void (*hw_msix_uninstall)(struct bfa_s *bfa);
236 void (*hw_isr_mode_set)(struct bfa_s *bfa, bfa_boolean_t msix);
237 void (*hw_msix_getvecs)(struct bfa_s *bfa, u32 *vecmap,
238 u32 *nvecs, u32 *maxvec);
239 void (*hw_msix_get_rme_range) (struct bfa_s *bfa, u32 *start,
240 u32 *end);
241};
242typedef void (*bfa_cb_iocfc_t) (void *cbarg, enum bfa_status status);
243
244struct bfa_iocfc_s {
245 struct bfa_s *bfa;
246 struct bfa_iocfc_cfg_s cfg;
247 int action;
248 u32 req_cq_pi[BFI_IOC_MAX_CQS];
249 u32 rsp_cq_ci[BFI_IOC_MAX_CQS];
250 struct bfa_cb_qe_s init_hcb_qe;
251 struct bfa_cb_qe_s stop_hcb_qe;
252 struct bfa_cb_qe_s dis_hcb_qe;
253 struct bfa_cb_qe_s stats_hcb_qe;
254 bfa_boolean_t cfgdone;
255
256 struct bfa_dma_s cfg_info;
257 struct bfi_iocfc_cfg_s *cfginfo;
258 struct bfa_dma_s cfgrsp_dma;
259 struct bfi_iocfc_cfgrsp_s *cfgrsp;
260 struct bfi_iocfc_cfg_reply_s *cfg_reply;
261 struct bfa_dma_s req_cq_ba[BFI_IOC_MAX_CQS];
262 struct bfa_dma_s req_cq_shadow_ci[BFI_IOC_MAX_CQS];
263 struct bfa_dma_s rsp_cq_ba[BFI_IOC_MAX_CQS];
264 struct bfa_dma_s rsp_cq_shadow_pi[BFI_IOC_MAX_CQS];
265 struct bfa_iocfc_regs_s bfa_regs; /* BFA device registers */
266 struct bfa_hwif_s hwif;
267 bfa_cb_iocfc_t updateq_cbfn; /* bios callback function */
268 void *updateq_cbarg; /* bios callback arg */
269 u32 intr_mask;
270};
271
272#define bfa_lpuid(__bfa) \
273 bfa_ioc_portid(&(__bfa)->ioc)
274#define bfa_msix_init(__bfa, __nvecs) \
275 ((__bfa)->iocfc.hwif.hw_msix_init(__bfa, __nvecs))
276#define bfa_msix_install(__bfa) \
277 ((__bfa)->iocfc.hwif.hw_msix_install(__bfa))
278#define bfa_msix_uninstall(__bfa) \
279 ((__bfa)->iocfc.hwif.hw_msix_uninstall(__bfa))
280#define bfa_isr_mode_set(__bfa, __msix) \
281 ((__bfa)->iocfc.hwif.hw_isr_mode_set(__bfa, __msix))
282#define bfa_msix_getvecs(__bfa, __vecmap, __nvecs, __maxvec) \
283 ((__bfa)->iocfc.hwif.hw_msix_getvecs(__bfa, __vecmap, \
284 __nvecs, __maxvec))
285#define bfa_msix_get_rme_range(__bfa, __start, __end) \
286 ((__bfa)->iocfc.hwif.hw_msix_get_rme_range(__bfa, __start, __end))
287#define bfa_msix(__bfa, __vec) \
288 ((__bfa)->msix.handler[__vec](__bfa, __vec))
289
290/*
291 * FC specific IOC functions.
292 */
293void bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
294 u32 *dm_len);
295void bfa_iocfc_attach(struct bfa_s *bfa, void *bfad,
296 struct bfa_iocfc_cfg_s *cfg,
297 struct bfa_meminfo_s *meminfo,
298 struct bfa_pcidev_s *pcidev);
299void bfa_iocfc_init(struct bfa_s *bfa);
300void bfa_iocfc_start(struct bfa_s *bfa);
301void bfa_iocfc_stop(struct bfa_s *bfa);
302void bfa_iocfc_isr(void *bfa, struct bfi_mbmsg_s *msg);
303void bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa);
304bfa_boolean_t bfa_iocfc_is_operational(struct bfa_s *bfa);
305void bfa_iocfc_reset_queues(struct bfa_s *bfa);
306
307void bfa_msix_all(struct bfa_s *bfa, int vec);
308void bfa_msix_reqq(struct bfa_s *bfa, int vec);
309void bfa_msix_rspq(struct bfa_s *bfa, int vec);
310void bfa_msix_lpu_err(struct bfa_s *bfa, int vec);
311
312void bfa_hwcb_reginit(struct bfa_s *bfa);
313void bfa_hwcb_reqq_ack(struct bfa_s *bfa, int rspq);
314void bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq);
315void bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs);
316void bfa_hwcb_msix_install(struct bfa_s *bfa);
317void bfa_hwcb_msix_uninstall(struct bfa_s *bfa);
318void bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
319void bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *vecmap, u32 *nvecs,
320 u32 *maxvec);
321void bfa_hwcb_msix_get_rme_range(struct bfa_s *bfa, u32 *start,
322 u32 *end);
323void bfa_hwct_reginit(struct bfa_s *bfa);
324void bfa_hwct_reqq_ack(struct bfa_s *bfa, int rspq);
325void bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq);
326void bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs);
327void bfa_hwct_msix_install(struct bfa_s *bfa);
328void bfa_hwct_msix_uninstall(struct bfa_s *bfa);
329void bfa_hwct_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
330void bfa_hwct_msix_getvecs(struct bfa_s *bfa, u32 *vecmap, u32 *nvecs,
331 u32 *maxvec);
332void bfa_hwct_msix_get_rme_range(struct bfa_s *bfa, u32 *start,
333 u32 *end);
334void bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns);
335wwn_t bfa_iocfc_get_pwwn(struct bfa_s *bfa);
336wwn_t bfa_iocfc_get_nwwn(struct bfa_s *bfa);
337int bfa_iocfc_get_pbc_vports(struct bfa_s *bfa,
338 struct bfi_pbc_vport_s *pbc_vport);
339
340
341/*
342 *----------------------------------------------------------------------
343 * BFA public interfaces
344 *----------------------------------------------------------------------
345 */
346#define bfa_stats(_mod, _stats) ((_mod)->stats._stats++)
347#define bfa_ioc_get_stats(__bfa, __ioc_stats) \
348 bfa_ioc_fetch_stats(&(__bfa)->ioc, __ioc_stats)
349#define bfa_ioc_clear_stats(__bfa) \
350 bfa_ioc_clr_stats(&(__bfa)->ioc)
351#define bfa_get_nports(__bfa) \
352 bfa_ioc_get_nports(&(__bfa)->ioc)
353#define bfa_get_adapter_manufacturer(__bfa, __manufacturer) \
354 bfa_ioc_get_adapter_manufacturer(&(__bfa)->ioc, __manufacturer)
355#define bfa_get_adapter_model(__bfa, __model) \
356 bfa_ioc_get_adapter_model(&(__bfa)->ioc, __model)
357#define bfa_get_adapter_serial_num(__bfa, __serial_num) \
358 bfa_ioc_get_adapter_serial_num(&(__bfa)->ioc, __serial_num)
359#define bfa_get_adapter_fw_ver(__bfa, __fw_ver) \
360 bfa_ioc_get_adapter_fw_ver(&(__bfa)->ioc, __fw_ver)
361#define bfa_get_adapter_optrom_ver(__bfa, __optrom_ver) \
362 bfa_ioc_get_adapter_optrom_ver(&(__bfa)->ioc, __optrom_ver)
363#define bfa_get_pci_chip_rev(__bfa, __chip_rev) \
364 bfa_ioc_get_pci_chip_rev(&(__bfa)->ioc, __chip_rev)
365#define bfa_get_ioc_state(__bfa) \
366 bfa_ioc_get_state(&(__bfa)->ioc)
367#define bfa_get_type(__bfa) \
368 bfa_ioc_get_type(&(__bfa)->ioc)
369#define bfa_get_mac(__bfa) \
370 bfa_ioc_get_mac(&(__bfa)->ioc)
371#define bfa_get_mfg_mac(__bfa) \
372 bfa_ioc_get_mfg_mac(&(__bfa)->ioc)
373#define bfa_get_fw_clock_res(__bfa) \
374 ((__bfa)->iocfc.cfgrsp->fwcfg.fw_tick_res)
375
376void bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids);
377void bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg);
378void bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg);
379void bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg,
380 struct bfa_meminfo_s *meminfo);
381void bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
382 struct bfa_meminfo_s *meminfo,
383 struct bfa_pcidev_s *pcidev);
384void bfa_detach(struct bfa_s *bfa);
385void bfa_cb_init(void *bfad, bfa_status_t status);
386void bfa_cb_updateq(void *bfad, bfa_status_t status);
387
388bfa_boolean_t bfa_intx(struct bfa_s *bfa);
389void bfa_isr_enable(struct bfa_s *bfa);
390void bfa_isr_disable(struct bfa_s *bfa);
391
392void bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q);
393void bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q);
394void bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q);
395
396typedef void (*bfa_cb_ioc_t) (void *cbarg, enum bfa_status status);
397void bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr);
398
399
400bfa_status_t bfa_iocfc_israttr_set(struct bfa_s *bfa,
401 struct bfa_iocfc_intr_attr_s *attr);
402
403void bfa_iocfc_enable(struct bfa_s *bfa);
404void bfa_iocfc_disable(struct bfa_s *bfa);
405#define bfa_timer_start(_bfa, _timer, _timercb, _arg, _timeout) \
406 bfa_timer_begin(&(_bfa)->timer_mod, _timer, _timercb, _arg, _timeout)
407
408#endif /* __BFA_H__ */
diff --git a/drivers/scsi/bfa/bfa_callback_priv.h b/drivers/scsi/bfa/bfa_callback_priv.h
deleted file mode 100644
index 1e3265c9f7d4..000000000000
--- a/drivers/scsi/bfa/bfa_callback_priv.h
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_CALLBACK_PRIV_H__
19#define __BFA_CALLBACK_PRIV_H__
20
21#include <cs/bfa_q.h>
22
23typedef void (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete);
24
25/**
26 * Generic BFA callback element.
27 */
28struct bfa_cb_qe_s {
29 struct list_head qe;
30 bfa_cb_cbfn_t cbfn;
31 bfa_boolean_t once;
32 u32 rsvd;
33 void *cbarg;
34};
35
36#define bfa_cb_queue(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
37 (__hcb_qe)->cbfn = (__cbfn); \
38 (__hcb_qe)->cbarg = (__cbarg); \
39 list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
40} while (0)
41
42#define bfa_cb_dequeue(__hcb_qe) list_del(&(__hcb_qe)->qe)
43
44#define bfa_cb_queue_once(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
45 (__hcb_qe)->cbfn = (__cbfn); \
46 (__hcb_qe)->cbarg = (__cbarg); \
47 if (!(__hcb_qe)->once) { \
48 list_add_tail((__hcb_qe), &(__bfa)->comp_q); \
49 (__hcb_qe)->once = BFA_TRUE; \
50 } \
51} while (0)
52
53#define bfa_cb_queue_done(__hcb_qe) do { \
54 (__hcb_qe)->once = BFA_FALSE; \
55} while (0)
56
57#endif /* __BFA_CALLBACK_PRIV_H__ */
diff --git a/drivers/scsi/bfa/bfa_cb_ioim_macros.h b/drivers/scsi/bfa/bfa_cb_ioim_macros.h
deleted file mode 100644
index 3906ed926966..000000000000
--- a/drivers/scsi/bfa/bfa_cb_ioim_macros.h
+++ /dev/null
@@ -1,181 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_cb_ioim_macros.h BFA IOIM driver interface macros.
20 */
21
22#ifndef __BFA_HCB_IOIM_MACROS_H__
23#define __BFA_HCB_IOIM_MACROS_H__
24
25#include <bfa_os_inc.h>
26/*
27 * #include <linux/dma-mapping.h>
28 *
29 * #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> #include
30 * <scsi/scsi_device.h> #include <scsi/scsi_host.h>
31 */
32#include "bfad_im_compat.h"
33
34/*
35 * task attribute values in FCP-2 FCP_CMND IU
36 */
37#define SIMPLE_Q 0
38#define HEAD_OF_Q 1
39#define ORDERED_Q 2
40#define ACA_Q 4
41#define UNTAGGED 5
42
43static inline lun_t
44bfad_int_to_lun(u32 luno)
45{
46 union {
47 u16 scsi_lun[4];
48 lun_t bfa_lun;
49 } lun;
50
51 lun.bfa_lun = 0;
52 lun.scsi_lun[0] = bfa_os_htons(luno);
53
54 return lun.bfa_lun;
55}
56
57/**
58 * Get LUN for the I/O request
59 */
60#define bfa_cb_ioim_get_lun(__dio) \
61 bfad_int_to_lun(((struct scsi_cmnd *)__dio)->device->lun)
62
63/**
64 * Get CDB for the I/O request
65 */
66static inline u8 *
67bfa_cb_ioim_get_cdb(struct bfad_ioim_s *dio)
68{
69 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
70
71 return (u8 *) cmnd->cmnd;
72}
73
74/**
75 * Get I/O direction (read/write) for the I/O request
76 */
77static inline enum fcp_iodir
78bfa_cb_ioim_get_iodir(struct bfad_ioim_s *dio)
79{
80 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
81 enum dma_data_direction dmadir;
82
83 dmadir = cmnd->sc_data_direction;
84 if (dmadir == DMA_TO_DEVICE)
85 return FCP_IODIR_WRITE;
86 else if (dmadir == DMA_FROM_DEVICE)
87 return FCP_IODIR_READ;
88 else
89 return FCP_IODIR_NONE;
90}
91
92/**
93 * Get IO size in bytes for the I/O request
94 */
95static inline u32
96bfa_cb_ioim_get_size(struct bfad_ioim_s *dio)
97{
98 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
99
100 return scsi_bufflen(cmnd);
101}
102
103/**
104 * Get timeout for the I/O request
105 */
106static inline u8
107bfa_cb_ioim_get_timeout(struct bfad_ioim_s *dio)
108{
109 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
110 /*
111 * TBD: need a timeout for scsi passthru
112 */
113 if (cmnd->device->host == NULL)
114 return 4;
115
116 return 0;
117}
118
119/**
120 * Get Command Reference Number for the I/O request. 0 if none.
121 */
122static inline u8
123bfa_cb_ioim_get_crn(struct bfad_ioim_s *dio)
124{
125 return 0;
126}
127
128/**
129 * Get SAM-3 priority for the I/O request. 0 is default.
130 */
131static inline u8
132bfa_cb_ioim_get_priority(struct bfad_ioim_s *dio)
133{
134 return 0;
135}
136
137/**
138 * Get task attributes for the I/O request. Default is FCP_TASK_ATTR_SIMPLE(0).
139 */
140static inline u8
141bfa_cb_ioim_get_taskattr(struct bfad_ioim_s *dio)
142{
143 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
144 u8 task_attr = UNTAGGED;
145
146 if (cmnd->device->tagged_supported) {
147 switch (cmnd->tag) {
148 case HEAD_OF_QUEUE_TAG:
149 task_attr = HEAD_OF_Q;
150 break;
151 case ORDERED_QUEUE_TAG:
152 task_attr = ORDERED_Q;
153 break;
154 default:
155 task_attr = SIMPLE_Q;
156 break;
157 }
158 }
159
160 return task_attr;
161}
162
163/**
164 * Get CDB length in bytes for the I/O request. Default is FCP_CMND_CDB_LEN(16).
165 */
166static inline u8
167bfa_cb_ioim_get_cdblen(struct bfad_ioim_s *dio)
168{
169 struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
170
171 return cmnd->cmd_len;
172}
173
174/**
175 * Assign queue to be used for the I/O request. This value depends on whether
176 * the driver wants to use the queues via any specific algorithm. Currently,
177 * this is not supported.
178 */
179#define bfa_cb_ioim_get_reqq(__dio) BFA_FALSE
180
181#endif /* __BFA_HCB_IOIM_MACROS_H__ */
diff --git a/drivers/scsi/bfa/bfa_cee.c b/drivers/scsi/bfa/bfa_cee.c
deleted file mode 100644
index 2b917792c6bc..000000000000
--- a/drivers/scsi/bfa/bfa_cee.c
+++ /dev/null
@@ -1,492 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <defs/bfa_defs_cee.h>
19#include <cs/bfa_trc.h>
20#include <cs/bfa_log.h>
21#include <cs/bfa_debug.h>
22#include <cee/bfa_cee.h>
23#include <bfi/bfi_cee.h>
24#include <bfi/bfi.h>
25#include <bfa_ioc.h>
26#include <cna/bfa_cna_trcmod.h>
27
28BFA_TRC_FILE(CNA, CEE);
29
30#define bfa_ioc_portid(__ioc) ((__ioc)->port_id)
31#define bfa_lpuid(__arg) bfa_ioc_portid(&(__arg)->ioc)
32
33static void bfa_cee_format_lldp_cfg(struct bfa_cee_lldp_cfg_s *lldp_cfg);
34static void bfa_cee_format_dcbcx_stats(struct bfa_cee_dcbx_stats_s
35 *dcbcx_stats);
36static void bfa_cee_format_lldp_stats(struct bfa_cee_lldp_stats_s
37 *lldp_stats);
38static void bfa_cee_format_cfg_stats(struct bfa_cee_cfg_stats_s *cfg_stats);
39static void bfa_cee_format_cee_cfg(void *buffer);
40static void bfa_cee_format_cee_stats(void *buffer);
41
42static void
43bfa_cee_format_cee_stats(void *buffer)
44{
45 struct bfa_cee_stats_s *cee_stats = buffer;
46 bfa_cee_format_dcbcx_stats(&cee_stats->dcbx_stats);
47 bfa_cee_format_lldp_stats(&cee_stats->lldp_stats);
48 bfa_cee_format_cfg_stats(&cee_stats->cfg_stats);
49}
50
51static void
52bfa_cee_format_cee_cfg(void *buffer)
53{
54 struct bfa_cee_attr_s *cee_cfg = buffer;
55 bfa_cee_format_lldp_cfg(&cee_cfg->lldp_remote);
56}
57
58static void
59bfa_cee_format_dcbcx_stats(struct bfa_cee_dcbx_stats_s *dcbcx_stats)
60{
61 dcbcx_stats->subtlvs_unrecognized =
62 bfa_os_ntohl(dcbcx_stats->subtlvs_unrecognized);
63 dcbcx_stats->negotiation_failed =
64 bfa_os_ntohl(dcbcx_stats->negotiation_failed);
65 dcbcx_stats->remote_cfg_changed =
66 bfa_os_ntohl(dcbcx_stats->remote_cfg_changed);
67 dcbcx_stats->tlvs_received = bfa_os_ntohl(dcbcx_stats->tlvs_received);
68 dcbcx_stats->tlvs_invalid = bfa_os_ntohl(dcbcx_stats->tlvs_invalid);
69 dcbcx_stats->seqno = bfa_os_ntohl(dcbcx_stats->seqno);
70 dcbcx_stats->ackno = bfa_os_ntohl(dcbcx_stats->ackno);
71 dcbcx_stats->recvd_seqno = bfa_os_ntohl(dcbcx_stats->recvd_seqno);
72 dcbcx_stats->recvd_ackno = bfa_os_ntohl(dcbcx_stats->recvd_ackno);
73}
74
75static void
76bfa_cee_format_lldp_stats(struct bfa_cee_lldp_stats_s *lldp_stats)
77{
78 lldp_stats->frames_transmitted =
79 bfa_os_ntohl(lldp_stats->frames_transmitted);
80 lldp_stats->frames_aged_out = bfa_os_ntohl(lldp_stats->frames_aged_out);
81 lldp_stats->frames_discarded =
82 bfa_os_ntohl(lldp_stats->frames_discarded);
83 lldp_stats->frames_in_error = bfa_os_ntohl(lldp_stats->frames_in_error);
84 lldp_stats->frames_rcvd = bfa_os_ntohl(lldp_stats->frames_rcvd);
85 lldp_stats->tlvs_discarded = bfa_os_ntohl(lldp_stats->tlvs_discarded);
86 lldp_stats->tlvs_unrecognized =
87 bfa_os_ntohl(lldp_stats->tlvs_unrecognized);
88}
89
90static void
91bfa_cee_format_cfg_stats(struct bfa_cee_cfg_stats_s *cfg_stats)
92{
93 cfg_stats->cee_status_down = bfa_os_ntohl(cfg_stats->cee_status_down);
94 cfg_stats->cee_status_up = bfa_os_ntohl(cfg_stats->cee_status_up);
95 cfg_stats->cee_hw_cfg_changed =
96 bfa_os_ntohl(cfg_stats->cee_hw_cfg_changed);
97 cfg_stats->recvd_invalid_cfg =
98 bfa_os_ntohl(cfg_stats->recvd_invalid_cfg);
99}
100
101static void
102bfa_cee_format_lldp_cfg(struct bfa_cee_lldp_cfg_s *lldp_cfg)
103{
104 lldp_cfg->time_to_interval = bfa_os_ntohs(lldp_cfg->time_to_interval);
105 lldp_cfg->enabled_system_cap =
106 bfa_os_ntohs(lldp_cfg->enabled_system_cap);
107}
108
109/**
110 * bfa_cee_attr_meminfo()
111 *
112 *
113 * @param[in] void
114 *
115 * @return Size of DMA region
116 */
117static u32
118bfa_cee_attr_meminfo(void)
119{
120 return BFA_ROUNDUP(sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ);
121}
122
123/**
124 * bfa_cee_stats_meminfo()
125 *
126 *
127 * @param[in] void
128 *
129 * @return Size of DMA region
130 */
131static u32
132bfa_cee_stats_meminfo(void)
133{
134 return BFA_ROUNDUP(sizeof(struct bfa_cee_stats_s), BFA_DMA_ALIGN_SZ);
135}
136
137/**
138 * bfa_cee_get_attr_isr()
139 *
140 *
141 * @param[in] cee - Pointer to the CEE module
142 * status - Return status from the f/w
143 *
144 * @return void
145 */
146static void
147bfa_cee_get_attr_isr(struct bfa_cee_s *cee, bfa_status_t status)
148{
149 cee->get_attr_status = status;
150 bfa_trc(cee, 0);
151 if (status == BFA_STATUS_OK) {
152 bfa_trc(cee, 0);
153 /*
154 * The requested data has been copied to the DMA area, *process
155 * it.
156 */
157 memcpy(cee->attr, cee->attr_dma.kva,
158 sizeof(struct bfa_cee_attr_s));
159 bfa_cee_format_cee_cfg(cee->attr);
160 }
161 cee->get_attr_pending = BFA_FALSE;
162 if (cee->cbfn.get_attr_cbfn) {
163 bfa_trc(cee, 0);
164 cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg, status);
165 }
166 bfa_trc(cee, 0);
167}
168
169/**
170 * bfa_cee_get_attr_isr()
171 *
172 *
173 * @param[in] cee - Pointer to the CEE module
174 * status - Return status from the f/w
175 *
176 * @return void
177 */
178static void
179bfa_cee_get_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
180{
181 cee->get_stats_status = status;
182 bfa_trc(cee, 0);
183 if (status == BFA_STATUS_OK) {
184 bfa_trc(cee, 0);
185 /*
186 * The requested data has been copied to the DMA area, process
187 * it.
188 */
189 memcpy(cee->stats, cee->stats_dma.kva,
190 sizeof(struct bfa_cee_stats_s));
191 bfa_cee_format_cee_stats(cee->stats);
192 }
193 cee->get_stats_pending = BFA_FALSE;
194 bfa_trc(cee, 0);
195 if (cee->cbfn.get_stats_cbfn) {
196 bfa_trc(cee, 0);
197 cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg, status);
198 }
199 bfa_trc(cee, 0);
200}
201
202/**
203 * bfa_cee_get_attr_isr()
204 *
205 *
206 * @param[in] cee - Pointer to the CEE module
207 * status - Return status from the f/w
208 *
209 * @return void
210 */
211static void
212bfa_cee_reset_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
213{
214 cee->reset_stats_status = status;
215 cee->reset_stats_pending = BFA_FALSE;
216 if (cee->cbfn.reset_stats_cbfn)
217 cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg, status);
218}
219
220/**
221 * bfa_cee_meminfo()
222 *
223 *
224 * @param[in] void
225 *
226 * @return Size of DMA region
227 */
228u32
229bfa_cee_meminfo(void)
230{
231 return bfa_cee_attr_meminfo() + bfa_cee_stats_meminfo();
232}
233
234/**
235 * bfa_cee_mem_claim()
236 *
237 *
238 * @param[in] cee CEE module pointer
239 * dma_kva Kernel Virtual Address of CEE DMA Memory
240 * dma_pa Physical Address of CEE DMA Memory
241 *
242 * @return void
243 */
244void
245bfa_cee_mem_claim(struct bfa_cee_s *cee, u8 *dma_kva, u64 dma_pa)
246{
247 cee->attr_dma.kva = dma_kva;
248 cee->attr_dma.pa = dma_pa;
249 cee->stats_dma.kva = dma_kva + bfa_cee_attr_meminfo();
250 cee->stats_dma.pa = dma_pa + bfa_cee_attr_meminfo();
251 cee->attr = (struct bfa_cee_attr_s *)dma_kva;
252 cee->stats =
253 (struct bfa_cee_stats_s *)(dma_kva + bfa_cee_attr_meminfo());
254}
255
256/**
257 * bfa_cee_get_attr()
258 *
259 * Send the request to the f/w to fetch CEE attributes.
260 *
261 * @param[in] Pointer to the CEE module data structure.
262 *
263 * @return Status
264 */
265
266bfa_status_t
267bfa_cee_get_attr(struct bfa_cee_s *cee, struct bfa_cee_attr_s *attr,
268 bfa_cee_get_attr_cbfn_t cbfn, void *cbarg)
269{
270 struct bfi_cee_get_req_s *cmd;
271
272 bfa_assert((cee != NULL) && (cee->ioc != NULL));
273 bfa_trc(cee, 0);
274 if (!bfa_ioc_is_operational(cee->ioc)) {
275 bfa_trc(cee, 0);
276 return BFA_STATUS_IOC_FAILURE;
277 }
278 if (cee->get_attr_pending == BFA_TRUE) {
279 bfa_trc(cee, 0);
280 return BFA_STATUS_DEVBUSY;
281 }
282 cee->get_attr_pending = BFA_TRUE;
283 cmd = (struct bfi_cee_get_req_s *)cee->get_cfg_mb.msg;
284 cee->attr = attr;
285 cee->cbfn.get_attr_cbfn = cbfn;
286 cee->cbfn.get_attr_cbarg = cbarg;
287 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_CFG_REQ,
288 bfa_ioc_portid(cee->ioc));
289 bfa_dma_be_addr_set(cmd->dma_addr, cee->attr_dma.pa);
290 bfa_ioc_mbox_queue(cee->ioc, &cee->get_cfg_mb);
291 bfa_trc(cee, 0);
292
293 return BFA_STATUS_OK;
294}
295
296/**
297 * bfa_cee_get_stats()
298 *
299 * Send the request to the f/w to fetch CEE statistics.
300 *
301 * @param[in] Pointer to the CEE module data structure.
302 *
303 * @return Status
304 */
305
306bfa_status_t
307bfa_cee_get_stats(struct bfa_cee_s *cee, struct bfa_cee_stats_s *stats,
308 bfa_cee_get_stats_cbfn_t cbfn, void *cbarg)
309{
310 struct bfi_cee_get_req_s *cmd;
311
312 bfa_assert((cee != NULL) && (cee->ioc != NULL));
313
314 if (!bfa_ioc_is_operational(cee->ioc)) {
315 bfa_trc(cee, 0);
316 return BFA_STATUS_IOC_FAILURE;
317 }
318 if (cee->get_stats_pending == BFA_TRUE) {
319 bfa_trc(cee, 0);
320 return BFA_STATUS_DEVBUSY;
321 }
322 cee->get_stats_pending = BFA_TRUE;
323 cmd = (struct bfi_cee_get_req_s *)cee->get_stats_mb.msg;
324 cee->stats = stats;
325 cee->cbfn.get_stats_cbfn = cbfn;
326 cee->cbfn.get_stats_cbarg = cbarg;
327 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_STATS_REQ,
328 bfa_ioc_portid(cee->ioc));
329 bfa_dma_be_addr_set(cmd->dma_addr, cee->stats_dma.pa);
330 bfa_ioc_mbox_queue(cee->ioc, &cee->get_stats_mb);
331 bfa_trc(cee, 0);
332
333 return BFA_STATUS_OK;
334}
335
336/**
337 * bfa_cee_reset_stats()
338 *
339 *
340 * @param[in] Pointer to the CEE module data structure.
341 *
342 * @return Status
343 */
344
345bfa_status_t
346bfa_cee_reset_stats(struct bfa_cee_s *cee, bfa_cee_reset_stats_cbfn_t cbfn,
347 void *cbarg)
348{
349 struct bfi_cee_reset_stats_s *cmd;
350
351 bfa_assert((cee != NULL) && (cee->ioc != NULL));
352 if (!bfa_ioc_is_operational(cee->ioc)) {
353 bfa_trc(cee, 0);
354 return BFA_STATUS_IOC_FAILURE;
355 }
356 if (cee->reset_stats_pending == BFA_TRUE) {
357 bfa_trc(cee, 0);
358 return BFA_STATUS_DEVBUSY;
359 }
360 cee->reset_stats_pending = BFA_TRUE;
361 cmd = (struct bfi_cee_reset_stats_s *)cee->reset_stats_mb.msg;
362 cee->cbfn.reset_stats_cbfn = cbfn;
363 cee->cbfn.reset_stats_cbarg = cbarg;
364 bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_RESET_STATS,
365 bfa_ioc_portid(cee->ioc));
366 bfa_ioc_mbox_queue(cee->ioc, &cee->reset_stats_mb);
367 bfa_trc(cee, 0);
368 return BFA_STATUS_OK;
369}
370
371/**
372 * bfa_cee_isrs()
373 *
374 *
375 * @param[in] Pointer to the CEE module data structure.
376 *
377 * @return void
378 */
379
380void
381bfa_cee_isr(void *cbarg, struct bfi_mbmsg_s *m)
382{
383 union bfi_cee_i2h_msg_u *msg;
384 struct bfi_cee_get_rsp_s *get_rsp;
385 struct bfa_cee_s *cee = (struct bfa_cee_s *)cbarg;
386 msg = (union bfi_cee_i2h_msg_u *)m;
387 get_rsp = (struct bfi_cee_get_rsp_s *)m;
388 bfa_trc(cee, msg->mh.msg_id);
389 switch (msg->mh.msg_id) {
390 case BFI_CEE_I2H_GET_CFG_RSP:
391 bfa_trc(cee, get_rsp->cmd_status);
392 bfa_cee_get_attr_isr(cee, get_rsp->cmd_status);
393 break;
394 case BFI_CEE_I2H_GET_STATS_RSP:
395 bfa_cee_get_stats_isr(cee, get_rsp->cmd_status);
396 break;
397 case BFI_CEE_I2H_RESET_STATS_RSP:
398 bfa_cee_reset_stats_isr(cee, get_rsp->cmd_status);
399 break;
400 default:
401 bfa_assert(0);
402 }
403}
404
405/**
406 * bfa_cee_hbfail()
407 *
408 *
409 * @param[in] Pointer to the CEE module data structure.
410 *
411 * @return void
412 */
413
414void
415bfa_cee_hbfail(void *arg)
416{
417 struct bfa_cee_s *cee;
418 cee = (struct bfa_cee_s *)arg;
419
420 if (cee->get_attr_pending == BFA_TRUE) {
421 cee->get_attr_status = BFA_STATUS_FAILED;
422 cee->get_attr_pending = BFA_FALSE;
423 if (cee->cbfn.get_attr_cbfn) {
424 cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg,
425 BFA_STATUS_FAILED);
426 }
427 }
428 if (cee->get_stats_pending == BFA_TRUE) {
429 cee->get_stats_status = BFA_STATUS_FAILED;
430 cee->get_stats_pending = BFA_FALSE;
431 if (cee->cbfn.get_stats_cbfn) {
432 cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg,
433 BFA_STATUS_FAILED);
434 }
435 }
436 if (cee->reset_stats_pending == BFA_TRUE) {
437 cee->reset_stats_status = BFA_STATUS_FAILED;
438 cee->reset_stats_pending = BFA_FALSE;
439 if (cee->cbfn.reset_stats_cbfn) {
440 cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg,
441 BFA_STATUS_FAILED);
442 }
443 }
444}
445
446/**
447 * bfa_cee_attach()
448 *
449 *
450 * @param[in] cee - Pointer to the CEE module data structure
451 * ioc - Pointer to the ioc module data structure
452 * dev - Pointer to the device driver module data structure
453 * The device driver specific mbox ISR functions have
454 * this pointer as one of the parameters.
455 * trcmod -
456 * logmod -
457 *
458 * @return void
459 */
460void
461bfa_cee_attach(struct bfa_cee_s *cee, struct bfa_ioc_s *ioc, void *dev,
462 struct bfa_trc_mod_s *trcmod, struct bfa_log_mod_s *logmod)
463{
464 bfa_assert(cee != NULL);
465 cee->dev = dev;
466 cee->trcmod = trcmod;
467 cee->logmod = logmod;
468 cee->ioc = ioc;
469
470 bfa_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee);
471 bfa_ioc_hbfail_init(&cee->hbfail, bfa_cee_hbfail, cee);
472 bfa_ioc_hbfail_register(cee->ioc, &cee->hbfail);
473 bfa_trc(cee, 0);
474}
475
476/**
477 * bfa_cee_detach()
478 *
479 *
480 * @param[in] cee - Pointer to the CEE module data structure
481 *
482 * @return void
483 */
484void
485bfa_cee_detach(struct bfa_cee_s *cee)
486{
487 /*
488 * For now, just check if there is some ioctl pending and mark that as
489 * failed?
490 */
491 /* bfa_cee_hbfail(cee); */
492}
diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c
index 76fa5c5b40dd..91838c51fb76 100644
--- a/drivers/scsi/bfa/bfa_core.c
+++ b/drivers/scsi/bfa/bfa_core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,29 +15,1001 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#include <bfa.h> 18#include "bfad_drv.h"
19#include <defs/bfa_defs_pci.h> 19#include "bfa_modules.h"
20#include <cs/bfa_debug.h> 20#include "bfi_ctreg.h"
21#include <bfa_iocfc.h> 21
22 22BFA_TRC_FILE(HAL, CORE);
23#define DEF_CFG_NUM_FABRICS 1 23
24#define DEF_CFG_NUM_LPORTS 256 24/*
25#define DEF_CFG_NUM_CQS 4 25 * BFA module list terminated by NULL
26#define DEF_CFG_NUM_IOIM_REQS (BFA_IOIM_MAX) 26 */
27#define DEF_CFG_NUM_TSKIM_REQS 128 27static struct bfa_module_s *hal_mods[] = {
28#define DEF_CFG_NUM_FCXP_REQS 64 28 &hal_mod_sgpg,
29#define DEF_CFG_NUM_UF_BUFS 64 29 &hal_mod_fcport,
30#define DEF_CFG_NUM_RPORTS 1024 30 &hal_mod_fcxp,
31#define DEF_CFG_NUM_ITNIMS (DEF_CFG_NUM_RPORTS) 31 &hal_mod_lps,
32#define DEF_CFG_NUM_TINS 256 32 &hal_mod_uf,
33 33 &hal_mod_rport,
34#define DEF_CFG_NUM_SGPGS 2048 34 &hal_mod_fcpim,
35#define DEF_CFG_NUM_REQQ_ELEMS 256 35 NULL
36#define DEF_CFG_NUM_RSPQ_ELEMS 64 36};
37#define DEF_CFG_NUM_SBOOT_TGTS 16 37
38#define DEF_CFG_NUM_SBOOT_LUNS 16 38/*
39 39 * Message handlers for various modules.
40/** 40 */
41static bfa_isr_func_t bfa_isrs[BFI_MC_MAX] = {
42 bfa_isr_unhandled, /* NONE */
43 bfa_isr_unhandled, /* BFI_MC_IOC */
44 bfa_isr_unhandled, /* BFI_MC_DIAG */
45 bfa_isr_unhandled, /* BFI_MC_FLASH */
46 bfa_isr_unhandled, /* BFI_MC_CEE */
47 bfa_fcport_isr, /* BFI_MC_FCPORT */
48 bfa_isr_unhandled, /* BFI_MC_IOCFC */
49 bfa_isr_unhandled, /* BFI_MC_LL */
50 bfa_uf_isr, /* BFI_MC_UF */
51 bfa_fcxp_isr, /* BFI_MC_FCXP */
52 bfa_lps_isr, /* BFI_MC_LPS */
53 bfa_rport_isr, /* BFI_MC_RPORT */
54 bfa_itnim_isr, /* BFI_MC_ITNIM */
55 bfa_isr_unhandled, /* BFI_MC_IOIM_READ */
56 bfa_isr_unhandled, /* BFI_MC_IOIM_WRITE */
57 bfa_isr_unhandled, /* BFI_MC_IOIM_IO */
58 bfa_ioim_isr, /* BFI_MC_IOIM */
59 bfa_ioim_good_comp_isr, /* BFI_MC_IOIM_IOCOM */
60 bfa_tskim_isr, /* BFI_MC_TSKIM */
61 bfa_isr_unhandled, /* BFI_MC_SBOOT */
62 bfa_isr_unhandled, /* BFI_MC_IPFC */
63 bfa_isr_unhandled, /* BFI_MC_PORT */
64 bfa_isr_unhandled, /* --------- */
65 bfa_isr_unhandled, /* --------- */
66 bfa_isr_unhandled, /* --------- */
67 bfa_isr_unhandled, /* --------- */
68 bfa_isr_unhandled, /* --------- */
69 bfa_isr_unhandled, /* --------- */
70 bfa_isr_unhandled, /* --------- */
71 bfa_isr_unhandled, /* --------- */
72 bfa_isr_unhandled, /* --------- */
73 bfa_isr_unhandled, /* --------- */
74};
75/*
76 * Message handlers for mailbox command classes
77 */
78static bfa_ioc_mbox_mcfunc_t bfa_mbox_isrs[BFI_MC_MAX] = {
79 NULL,
80 NULL, /* BFI_MC_IOC */
81 NULL, /* BFI_MC_DIAG */
82 NULL, /* BFI_MC_FLASH */
83 NULL, /* BFI_MC_CEE */
84 NULL, /* BFI_MC_PORT */
85 bfa_iocfc_isr, /* BFI_MC_IOCFC */
86 NULL,
87};
88
89
90
91static void
92bfa_com_port_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi)
93{
94 struct bfa_port_s *port = &bfa->modules.port;
95 u32 dm_len;
96 u8 *dm_kva;
97 u64 dm_pa;
98
99 dm_len = bfa_port_meminfo();
100 dm_kva = bfa_meminfo_dma_virt(mi);
101 dm_pa = bfa_meminfo_dma_phys(mi);
102
103 memset(port, 0, sizeof(struct bfa_port_s));
104 bfa_port_attach(port, &bfa->ioc, bfa, bfa->trcmod);
105 bfa_port_mem_claim(port, dm_kva, dm_pa);
106
107 bfa_meminfo_dma_virt(mi) = dm_kva + dm_len;
108 bfa_meminfo_dma_phys(mi) = dm_pa + dm_len;
109}
110
111/*
112 * BFA IOC FC related definitions
113 */
114
115/*
116 * IOC local definitions
117 */
118#define BFA_IOCFC_TOV 5000 /* msecs */
119
120enum {
121 BFA_IOCFC_ACT_NONE = 0,
122 BFA_IOCFC_ACT_INIT = 1,
123 BFA_IOCFC_ACT_STOP = 2,
124 BFA_IOCFC_ACT_DISABLE = 3,
125};
126
127#define DEF_CFG_NUM_FABRICS 1
128#define DEF_CFG_NUM_LPORTS 256
129#define DEF_CFG_NUM_CQS 4
130#define DEF_CFG_NUM_IOIM_REQS (BFA_IOIM_MAX)
131#define DEF_CFG_NUM_TSKIM_REQS 128
132#define DEF_CFG_NUM_FCXP_REQS 64
133#define DEF_CFG_NUM_UF_BUFS 64
134#define DEF_CFG_NUM_RPORTS 1024
135#define DEF_CFG_NUM_ITNIMS (DEF_CFG_NUM_RPORTS)
136#define DEF_CFG_NUM_TINS 256
137
138#define DEF_CFG_NUM_SGPGS 2048
139#define DEF_CFG_NUM_REQQ_ELEMS 256
140#define DEF_CFG_NUM_RSPQ_ELEMS 64
141#define DEF_CFG_NUM_SBOOT_TGTS 16
142#define DEF_CFG_NUM_SBOOT_LUNS 16
143
144/*
145 * forward declaration for IOC FC functions
146 */
147static void bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status);
148static void bfa_iocfc_disable_cbfn(void *bfa_arg);
149static void bfa_iocfc_hbfail_cbfn(void *bfa_arg);
150static void bfa_iocfc_reset_cbfn(void *bfa_arg);
151static struct bfa_ioc_cbfn_s bfa_iocfc_cbfn;
152
153/*
154 * BFA Interrupt handling functions
155 */
156static void
157bfa_reqq_resume(struct bfa_s *bfa, int qid)
158{
159 struct list_head *waitq, *qe, *qen;
160 struct bfa_reqq_wait_s *wqe;
161
162 waitq = bfa_reqq(bfa, qid);
163 list_for_each_safe(qe, qen, waitq) {
164 /*
165 * Callback only as long as there is room in request queue
166 */
167 if (bfa_reqq_full(bfa, qid))
168 break;
169
170 list_del(qe);
171 wqe = (struct bfa_reqq_wait_s *) qe;
172 wqe->qresume(wqe->cbarg);
173 }
174}
175
176void
177bfa_msix_all(struct bfa_s *bfa, int vec)
178{
179 bfa_intx(bfa);
180}
181
182bfa_boolean_t
183bfa_intx(struct bfa_s *bfa)
184{
185 u32 intr, qintr;
186 int queue;
187
188 intr = readl(bfa->iocfc.bfa_regs.intr_status);
189 if (!intr)
190 return BFA_FALSE;
191
192 /*
193 * RME completion queue interrupt
194 */
195 qintr = intr & __HFN_INT_RME_MASK;
196 writel(qintr, bfa->iocfc.bfa_regs.intr_status);
197
198 for (queue = 0; queue < BFI_IOC_MAX_CQS_ASIC; queue++) {
199 if (intr & (__HFN_INT_RME_Q0 << queue))
200 bfa_msix_rspq(bfa, queue & (BFI_IOC_MAX_CQS - 1));
201 }
202 intr &= ~qintr;
203 if (!intr)
204 return BFA_TRUE;
205
206 /*
207 * CPE completion queue interrupt
208 */
209 qintr = intr & __HFN_INT_CPE_MASK;
210 writel(qintr, bfa->iocfc.bfa_regs.intr_status);
211
212 for (queue = 0; queue < BFI_IOC_MAX_CQS_ASIC; queue++) {
213 if (intr & (__HFN_INT_CPE_Q0 << queue))
214 bfa_msix_reqq(bfa, queue & (BFI_IOC_MAX_CQS - 1));
215 }
216 intr &= ~qintr;
217 if (!intr)
218 return BFA_TRUE;
219
220 bfa_msix_lpu_err(bfa, intr);
221
222 return BFA_TRUE;
223}
224
225void
226bfa_isr_enable(struct bfa_s *bfa)
227{
228 u32 intr_unmask;
229 int pci_func = bfa_ioc_pcifn(&bfa->ioc);
230
231 bfa_trc(bfa, pci_func);
232
233 bfa_msix_install(bfa);
234 intr_unmask = (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 |
235 __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS |
236 __HFN_INT_LL_HALT);
237
238 if (pci_func == 0)
239 intr_unmask |= (__HFN_INT_CPE_Q0 | __HFN_INT_CPE_Q1 |
240 __HFN_INT_CPE_Q2 | __HFN_INT_CPE_Q3 |
241 __HFN_INT_RME_Q0 | __HFN_INT_RME_Q1 |
242 __HFN_INT_RME_Q2 | __HFN_INT_RME_Q3 |
243 __HFN_INT_MBOX_LPU0);
244 else
245 intr_unmask |= (__HFN_INT_CPE_Q4 | __HFN_INT_CPE_Q5 |
246 __HFN_INT_CPE_Q6 | __HFN_INT_CPE_Q7 |
247 __HFN_INT_RME_Q4 | __HFN_INT_RME_Q5 |
248 __HFN_INT_RME_Q6 | __HFN_INT_RME_Q7 |
249 __HFN_INT_MBOX_LPU1);
250
251 writel(intr_unmask, bfa->iocfc.bfa_regs.intr_status);
252 writel(~intr_unmask, bfa->iocfc.bfa_regs.intr_mask);
253 bfa->iocfc.intr_mask = ~intr_unmask;
254 bfa_isr_mode_set(bfa, bfa->msix.nvecs != 0);
255}
256
257void
258bfa_isr_disable(struct bfa_s *bfa)
259{
260 bfa_isr_mode_set(bfa, BFA_FALSE);
261 writel(-1L, bfa->iocfc.bfa_regs.intr_mask);
262 bfa_msix_uninstall(bfa);
263}
264
265void
266bfa_msix_reqq(struct bfa_s *bfa, int qid)
267{
268 struct list_head *waitq;
269
270 qid &= (BFI_IOC_MAX_CQS - 1);
271
272 bfa->iocfc.hwif.hw_reqq_ack(bfa, qid);
273
274 /*
275 * Resume any pending requests in the corresponding reqq.
276 */
277 waitq = bfa_reqq(bfa, qid);
278 if (!list_empty(waitq))
279 bfa_reqq_resume(bfa, qid);
280}
281
282void
283bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m)
284{
285 bfa_trc(bfa, m->mhdr.msg_class);
286 bfa_trc(bfa, m->mhdr.msg_id);
287 bfa_trc(bfa, m->mhdr.mtag.i2htok);
288 WARN_ON(1);
289 bfa_trc_stop(bfa->trcmod);
290}
291
292void
293bfa_msix_rspq(struct bfa_s *bfa, int qid)
294{
295 struct bfi_msg_s *m;
296 u32 pi, ci;
297 struct list_head *waitq;
298
299 qid &= (BFI_IOC_MAX_CQS - 1);
300
301 bfa->iocfc.hwif.hw_rspq_ack(bfa, qid);
302
303 ci = bfa_rspq_ci(bfa, qid);
304 pi = bfa_rspq_pi(bfa, qid);
305
306 if (bfa->rme_process) {
307 while (ci != pi) {
308 m = bfa_rspq_elem(bfa, qid, ci);
309 bfa_isrs[m->mhdr.msg_class] (bfa, m);
310 CQ_INCR(ci, bfa->iocfc.cfg.drvcfg.num_rspq_elems);
311 }
312 }
313
314 /*
315 * update CI
316 */
317 bfa_rspq_ci(bfa, qid) = pi;
318 writel(pi, bfa->iocfc.bfa_regs.rme_q_ci[qid]);
319 mmiowb();
320
321 /*
322 * Resume any pending requests in the corresponding reqq.
323 */
324 waitq = bfa_reqq(bfa, qid);
325 if (!list_empty(waitq))
326 bfa_reqq_resume(bfa, qid);
327}
328
329void
330bfa_msix_lpu_err(struct bfa_s *bfa, int vec)
331{
332 u32 intr, curr_value;
333
334 intr = readl(bfa->iocfc.bfa_regs.intr_status);
335
336 if (intr & (__HFN_INT_MBOX_LPU0 | __HFN_INT_MBOX_LPU1))
337 bfa_ioc_mbox_isr(&bfa->ioc);
338
339 intr &= (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 |
340 __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS | __HFN_INT_LL_HALT);
341
342 if (intr) {
343 if (intr & __HFN_INT_LL_HALT) {
344 /*
345 * If LL_HALT bit is set then FW Init Halt LL Port
346 * Register needs to be cleared as well so Interrupt
347 * Status Register will be cleared.
348 */
349 curr_value = readl(bfa->ioc.ioc_regs.ll_halt);
350 curr_value &= ~__FW_INIT_HALT_P;
351 writel(curr_value, bfa->ioc.ioc_regs.ll_halt);
352 }
353
354 if (intr & __HFN_INT_ERR_PSS) {
355 /*
356 * ERR_PSS bit needs to be cleared as well in case
357 * interrups are shared so driver's interrupt handler is
358 * still called even though it is already masked out.
359 */
360 curr_value = readl(
361 bfa->ioc.ioc_regs.pss_err_status_reg);
362 curr_value &= __PSS_ERR_STATUS_SET;
363 writel(curr_value,
364 bfa->ioc.ioc_regs.pss_err_status_reg);
365 }
366
367 writel(intr, bfa->iocfc.bfa_regs.intr_status);
368 bfa_ioc_error_isr(&bfa->ioc);
369 }
370}
371
372/*
373 * BFA IOC FC related functions
374 */
375
376/*
377 * BFA IOC private functions
378 */
379
380static void
381bfa_iocfc_cqs_sz(struct bfa_iocfc_cfg_s *cfg, u32 *dm_len)
382{
383 int i, per_reqq_sz, per_rspq_sz;
384
385 per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ),
386 BFA_DMA_ALIGN_SZ);
387 per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ),
388 BFA_DMA_ALIGN_SZ);
389
390 /*
391 * Calculate CQ size
392 */
393 for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
394 *dm_len = *dm_len + per_reqq_sz;
395 *dm_len = *dm_len + per_rspq_sz;
396 }
397
398 /*
399 * Calculate Shadow CI/PI size
400 */
401 for (i = 0; i < cfg->fwcfg.num_cqs; i++)
402 *dm_len += (2 * BFA_CACHELINE_SZ);
403}
404
405static void
406bfa_iocfc_fw_cfg_sz(struct bfa_iocfc_cfg_s *cfg, u32 *dm_len)
407{
408 *dm_len +=
409 BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
410 *dm_len +=
411 BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
412 BFA_CACHELINE_SZ);
413}
414
415/*
416 * Use the Mailbox interface to send BFI_IOCFC_H2I_CFG_REQ
417 */
418static void
419bfa_iocfc_send_cfg(void *bfa_arg)
420{
421 struct bfa_s *bfa = bfa_arg;
422 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
423 struct bfi_iocfc_cfg_req_s cfg_req;
424 struct bfi_iocfc_cfg_s *cfg_info = iocfc->cfginfo;
425 struct bfa_iocfc_cfg_s *cfg = &iocfc->cfg;
426 int i;
427
428 WARN_ON(cfg->fwcfg.num_cqs > BFI_IOC_MAX_CQS);
429 bfa_trc(bfa, cfg->fwcfg.num_cqs);
430
431 bfa_iocfc_reset_queues(bfa);
432
433 /*
434 * initialize IOC configuration info
435 */
436 cfg_info->endian_sig = BFI_IOC_ENDIAN_SIG;
437 cfg_info->num_cqs = cfg->fwcfg.num_cqs;
438
439 bfa_dma_be_addr_set(cfg_info->cfgrsp_addr, iocfc->cfgrsp_dma.pa);
440 /*
441 * dma map REQ and RSP circular queues and shadow pointers
442 */
443 for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
444 bfa_dma_be_addr_set(cfg_info->req_cq_ba[i],
445 iocfc->req_cq_ba[i].pa);
446 bfa_dma_be_addr_set(cfg_info->req_shadow_ci[i],
447 iocfc->req_cq_shadow_ci[i].pa);
448 cfg_info->req_cq_elems[i] =
449 cpu_to_be16(cfg->drvcfg.num_reqq_elems);
450
451 bfa_dma_be_addr_set(cfg_info->rsp_cq_ba[i],
452 iocfc->rsp_cq_ba[i].pa);
453 bfa_dma_be_addr_set(cfg_info->rsp_shadow_pi[i],
454 iocfc->rsp_cq_shadow_pi[i].pa);
455 cfg_info->rsp_cq_elems[i] =
456 cpu_to_be16(cfg->drvcfg.num_rspq_elems);
457 }
458
459 /*
460 * Enable interrupt coalescing if it is driver init path
461 * and not ioc disable/enable path.
462 */
463 if (!iocfc->cfgdone)
464 cfg_info->intr_attr.coalesce = BFA_TRUE;
465
466 iocfc->cfgdone = BFA_FALSE;
467
468 /*
469 * dma map IOC configuration itself
470 */
471 bfi_h2i_set(cfg_req.mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_CFG_REQ,
472 bfa_lpuid(bfa));
473 bfa_dma_be_addr_set(cfg_req.ioc_cfg_dma_addr, iocfc->cfg_info.pa);
474
475 bfa_ioc_mbox_send(&bfa->ioc, &cfg_req,
476 sizeof(struct bfi_iocfc_cfg_req_s));
477}
478
479static void
480bfa_iocfc_init_mem(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
481 struct bfa_pcidev_s *pcidev)
482{
483 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
484
485 bfa->bfad = bfad;
486 iocfc->bfa = bfa;
487 iocfc->action = BFA_IOCFC_ACT_NONE;
488
489 iocfc->cfg = *cfg;
490
491 /*
492 * Initialize chip specific handlers.
493 */
494 if (bfa_asic_id_ct(bfa_ioc_devid(&bfa->ioc))) {
495 iocfc->hwif.hw_reginit = bfa_hwct_reginit;
496 iocfc->hwif.hw_reqq_ack = bfa_hwct_reqq_ack;
497 iocfc->hwif.hw_rspq_ack = bfa_hwct_rspq_ack;
498 iocfc->hwif.hw_msix_init = bfa_hwct_msix_init;
499 iocfc->hwif.hw_msix_install = bfa_hwct_msix_install;
500 iocfc->hwif.hw_msix_uninstall = bfa_hwct_msix_uninstall;
501 iocfc->hwif.hw_isr_mode_set = bfa_hwct_isr_mode_set;
502 iocfc->hwif.hw_msix_getvecs = bfa_hwct_msix_getvecs;
503 iocfc->hwif.hw_msix_get_rme_range = bfa_hwct_msix_get_rme_range;
504 } else {
505 iocfc->hwif.hw_reginit = bfa_hwcb_reginit;
506 iocfc->hwif.hw_reqq_ack = bfa_hwcb_reqq_ack;
507 iocfc->hwif.hw_rspq_ack = bfa_hwcb_rspq_ack;
508 iocfc->hwif.hw_msix_init = bfa_hwcb_msix_init;
509 iocfc->hwif.hw_msix_install = bfa_hwcb_msix_install;
510 iocfc->hwif.hw_msix_uninstall = bfa_hwcb_msix_uninstall;
511 iocfc->hwif.hw_isr_mode_set = bfa_hwcb_isr_mode_set;
512 iocfc->hwif.hw_msix_getvecs = bfa_hwcb_msix_getvecs;
513 iocfc->hwif.hw_msix_get_rme_range = bfa_hwcb_msix_get_rme_range;
514 }
515
516 iocfc->hwif.hw_reginit(bfa);
517 bfa->msix.nvecs = 0;
518}
519
520static void
521bfa_iocfc_mem_claim(struct bfa_s *bfa, struct bfa_iocfc_cfg_s *cfg,
522 struct bfa_meminfo_s *meminfo)
523{
524 u8 *dm_kva;
525 u64 dm_pa;
526 int i, per_reqq_sz, per_rspq_sz;
527 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
528 int dbgsz;
529
530 dm_kva = bfa_meminfo_dma_virt(meminfo);
531 dm_pa = bfa_meminfo_dma_phys(meminfo);
532
533 /*
534 * First allocate dma memory for IOC.
535 */
536 bfa_ioc_mem_claim(&bfa->ioc, dm_kva, dm_pa);
537 dm_kva += BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ);
538 dm_pa += BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ);
539
540 /*
541 * Claim DMA-able memory for the request/response queues and for shadow
542 * ci/pi registers
543 */
544 per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ),
545 BFA_DMA_ALIGN_SZ);
546 per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ),
547 BFA_DMA_ALIGN_SZ);
548
549 for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
550 iocfc->req_cq_ba[i].kva = dm_kva;
551 iocfc->req_cq_ba[i].pa = dm_pa;
552 memset(dm_kva, 0, per_reqq_sz);
553 dm_kva += per_reqq_sz;
554 dm_pa += per_reqq_sz;
555
556 iocfc->rsp_cq_ba[i].kva = dm_kva;
557 iocfc->rsp_cq_ba[i].pa = dm_pa;
558 memset(dm_kva, 0, per_rspq_sz);
559 dm_kva += per_rspq_sz;
560 dm_pa += per_rspq_sz;
561 }
562
563 for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
564 iocfc->req_cq_shadow_ci[i].kva = dm_kva;
565 iocfc->req_cq_shadow_ci[i].pa = dm_pa;
566 dm_kva += BFA_CACHELINE_SZ;
567 dm_pa += BFA_CACHELINE_SZ;
568
569 iocfc->rsp_cq_shadow_pi[i].kva = dm_kva;
570 iocfc->rsp_cq_shadow_pi[i].pa = dm_pa;
571 dm_kva += BFA_CACHELINE_SZ;
572 dm_pa += BFA_CACHELINE_SZ;
573 }
574
575 /*
576 * Claim DMA-able memory for the config info page
577 */
578 bfa->iocfc.cfg_info.kva = dm_kva;
579 bfa->iocfc.cfg_info.pa = dm_pa;
580 bfa->iocfc.cfginfo = (struct bfi_iocfc_cfg_s *) dm_kva;
581 dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
582 dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
583
584 /*
585 * Claim DMA-able memory for the config response
586 */
587 bfa->iocfc.cfgrsp_dma.kva = dm_kva;
588 bfa->iocfc.cfgrsp_dma.pa = dm_pa;
589 bfa->iocfc.cfgrsp = (struct bfi_iocfc_cfgrsp_s *) dm_kva;
590
591 dm_kva +=
592 BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
593 BFA_CACHELINE_SZ);
594 dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
595 BFA_CACHELINE_SZ);
596
597
598 bfa_meminfo_dma_virt(meminfo) = dm_kva;
599 bfa_meminfo_dma_phys(meminfo) = dm_pa;
600
601 dbgsz = (bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0;
602 if (dbgsz > 0) {
603 bfa_ioc_debug_memclaim(&bfa->ioc, bfa_meminfo_kva(meminfo));
604 bfa_meminfo_kva(meminfo) += dbgsz;
605 }
606}
607
608/*
609 * Start BFA submodules.
610 */
611static void
612bfa_iocfc_start_submod(struct bfa_s *bfa)
613{
614 int i;
615
616 bfa->rme_process = BFA_TRUE;
617
618 for (i = 0; hal_mods[i]; i++)
619 hal_mods[i]->start(bfa);
620}
621
622/*
623 * Disable BFA submodules.
624 */
625static void
626bfa_iocfc_disable_submod(struct bfa_s *bfa)
627{
628 int i;
629
630 for (i = 0; hal_mods[i]; i++)
631 hal_mods[i]->iocdisable(bfa);
632}
633
634static void
635bfa_iocfc_init_cb(void *bfa_arg, bfa_boolean_t complete)
636{
637 struct bfa_s *bfa = bfa_arg;
638
639 if (complete) {
640 if (bfa->iocfc.cfgdone)
641 bfa_cb_init(bfa->bfad, BFA_STATUS_OK);
642 else
643 bfa_cb_init(bfa->bfad, BFA_STATUS_FAILED);
644 } else {
645 if (bfa->iocfc.cfgdone)
646 bfa->iocfc.action = BFA_IOCFC_ACT_NONE;
647 }
648}
649
650static void
651bfa_iocfc_stop_cb(void *bfa_arg, bfa_boolean_t compl)
652{
653 struct bfa_s *bfa = bfa_arg;
654 struct bfad_s *bfad = bfa->bfad;
655
656 if (compl)
657 complete(&bfad->comp);
658 else
659 bfa->iocfc.action = BFA_IOCFC_ACT_NONE;
660}
661
662static void
663bfa_iocfc_disable_cb(void *bfa_arg, bfa_boolean_t compl)
664{
665 struct bfa_s *bfa = bfa_arg;
666 struct bfad_s *bfad = bfa->bfad;
667
668 if (compl)
669 complete(&bfad->disable_comp);
670}
671
672/*
673 * Update BFA configuration from firmware configuration.
674 */
675static void
676bfa_iocfc_cfgrsp(struct bfa_s *bfa)
677{
678 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
679 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
680 struct bfa_iocfc_fwcfg_s *fwcfg = &cfgrsp->fwcfg;
681
682 fwcfg->num_cqs = fwcfg->num_cqs;
683 fwcfg->num_ioim_reqs = be16_to_cpu(fwcfg->num_ioim_reqs);
684 fwcfg->num_tskim_reqs = be16_to_cpu(fwcfg->num_tskim_reqs);
685 fwcfg->num_fcxp_reqs = be16_to_cpu(fwcfg->num_fcxp_reqs);
686 fwcfg->num_uf_bufs = be16_to_cpu(fwcfg->num_uf_bufs);
687 fwcfg->num_rports = be16_to_cpu(fwcfg->num_rports);
688
689 iocfc->cfgdone = BFA_TRUE;
690
691 /*
692 * Configuration is complete - initialize/start submodules
693 */
694 bfa_fcport_init(bfa);
695
696 if (iocfc->action == BFA_IOCFC_ACT_INIT)
697 bfa_cb_queue(bfa, &iocfc->init_hcb_qe, bfa_iocfc_init_cb, bfa);
698 else
699 bfa_iocfc_start_submod(bfa);
700}
701void
702bfa_iocfc_reset_queues(struct bfa_s *bfa)
703{
704 int q;
705
706 for (q = 0; q < BFI_IOC_MAX_CQS; q++) {
707 bfa_reqq_ci(bfa, q) = 0;
708 bfa_reqq_pi(bfa, q) = 0;
709 bfa_rspq_ci(bfa, q) = 0;
710 bfa_rspq_pi(bfa, q) = 0;
711 }
712}
713
714/*
715 * IOC enable request is complete
716 */
717static void
718bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status)
719{
720 struct bfa_s *bfa = bfa_arg;
721
722 if (status != BFA_STATUS_OK) {
723 bfa_isr_disable(bfa);
724 if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
725 bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe,
726 bfa_iocfc_init_cb, bfa);
727 return;
728 }
729
730 bfa_iocfc_send_cfg(bfa);
731}
732
733/*
734 * IOC disable request is complete
735 */
736static void
737bfa_iocfc_disable_cbfn(void *bfa_arg)
738{
739 struct bfa_s *bfa = bfa_arg;
740
741 bfa_isr_disable(bfa);
742 bfa_iocfc_disable_submod(bfa);
743
744 if (bfa->iocfc.action == BFA_IOCFC_ACT_STOP)
745 bfa_cb_queue(bfa, &bfa->iocfc.stop_hcb_qe, bfa_iocfc_stop_cb,
746 bfa);
747 else {
748 WARN_ON(bfa->iocfc.action != BFA_IOCFC_ACT_DISABLE);
749 bfa_cb_queue(bfa, &bfa->iocfc.dis_hcb_qe, bfa_iocfc_disable_cb,
750 bfa);
751 }
752}
753
754/*
755 * Notify sub-modules of hardware failure.
756 */
757static void
758bfa_iocfc_hbfail_cbfn(void *bfa_arg)
759{
760 struct bfa_s *bfa = bfa_arg;
761
762 bfa->rme_process = BFA_FALSE;
763
764 bfa_isr_disable(bfa);
765 bfa_iocfc_disable_submod(bfa);
766
767 if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
768 bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe, bfa_iocfc_init_cb,
769 bfa);
770}
771
772/*
773 * Actions on chip-reset completion.
774 */
775static void
776bfa_iocfc_reset_cbfn(void *bfa_arg)
777{
778 struct bfa_s *bfa = bfa_arg;
779
780 bfa_iocfc_reset_queues(bfa);
781 bfa_isr_enable(bfa);
782}
783
784
785/*
786 * Query IOC memory requirement information.
787 */
788void
789bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
790 u32 *dm_len)
791{
792 /* dma memory for IOC */
793 *dm_len += BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ);
794
795 bfa_iocfc_fw_cfg_sz(cfg, dm_len);
796 bfa_iocfc_cqs_sz(cfg, dm_len);
797 *km_len += (bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0;
798}
799
800/*
801 * Query IOC memory requirement information.
802 */
803void
804bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
805 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
806{
807 int i;
808 struct bfa_ioc_s *ioc = &bfa->ioc;
809
810 bfa_iocfc_cbfn.enable_cbfn = bfa_iocfc_enable_cbfn;
811 bfa_iocfc_cbfn.disable_cbfn = bfa_iocfc_disable_cbfn;
812 bfa_iocfc_cbfn.hbfail_cbfn = bfa_iocfc_hbfail_cbfn;
813 bfa_iocfc_cbfn.reset_cbfn = bfa_iocfc_reset_cbfn;
814
815 ioc->trcmod = bfa->trcmod;
816 bfa_ioc_attach(&bfa->ioc, bfa, &bfa_iocfc_cbfn, &bfa->timer_mod);
817
818 /*
819 * Set FC mode for BFA_PCI_DEVICE_ID_CT_FC.
820 */
821 if (pcidev->device_id == BFA_PCI_DEVICE_ID_CT_FC)
822 bfa_ioc_set_fcmode(&bfa->ioc);
823
824 bfa_ioc_pci_init(&bfa->ioc, pcidev, BFI_MC_IOCFC);
825 bfa_ioc_mbox_register(&bfa->ioc, bfa_mbox_isrs);
826
827 bfa_iocfc_init_mem(bfa, bfad, cfg, pcidev);
828 bfa_iocfc_mem_claim(bfa, cfg, meminfo);
829 INIT_LIST_HEAD(&bfa->timer_mod.timer_q);
830
831 INIT_LIST_HEAD(&bfa->comp_q);
832 for (i = 0; i < BFI_IOC_MAX_CQS; i++)
833 INIT_LIST_HEAD(&bfa->reqq_waitq[i]);
834}
835
836/*
837 * Query IOC memory requirement information.
838 */
839void
840bfa_iocfc_init(struct bfa_s *bfa)
841{
842 bfa->iocfc.action = BFA_IOCFC_ACT_INIT;
843 bfa_ioc_enable(&bfa->ioc);
844}
845
846/*
847 * IOC start called from bfa_start(). Called to start IOC operations
848 * at driver instantiation for this instance.
849 */
850void
851bfa_iocfc_start(struct bfa_s *bfa)
852{
853 if (bfa->iocfc.cfgdone)
854 bfa_iocfc_start_submod(bfa);
855}
856
857/*
858 * IOC stop called from bfa_stop(). Called only when driver is unloaded
859 * for this instance.
860 */
861void
862bfa_iocfc_stop(struct bfa_s *bfa)
863{
864 bfa->iocfc.action = BFA_IOCFC_ACT_STOP;
865
866 bfa->rme_process = BFA_FALSE;
867 bfa_ioc_disable(&bfa->ioc);
868}
869
870void
871bfa_iocfc_isr(void *bfaarg, struct bfi_mbmsg_s *m)
872{
873 struct bfa_s *bfa = bfaarg;
874 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
875 union bfi_iocfc_i2h_msg_u *msg;
876
877 msg = (union bfi_iocfc_i2h_msg_u *) m;
878 bfa_trc(bfa, msg->mh.msg_id);
879
880 switch (msg->mh.msg_id) {
881 case BFI_IOCFC_I2H_CFG_REPLY:
882 iocfc->cfg_reply = &msg->cfg_reply;
883 bfa_iocfc_cfgrsp(bfa);
884 break;
885 case BFI_IOCFC_I2H_UPDATEQ_RSP:
886 iocfc->updateq_cbfn(iocfc->updateq_cbarg, BFA_STATUS_OK);
887 break;
888 default:
889 WARN_ON(1);
890 }
891}
892
893void
894bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr)
895{
896 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
897
898 attr->intr_attr.coalesce = iocfc->cfginfo->intr_attr.coalesce;
899
900 attr->intr_attr.delay = iocfc->cfginfo->intr_attr.delay ?
901 be16_to_cpu(iocfc->cfginfo->intr_attr.delay) :
902 be16_to_cpu(iocfc->cfgrsp->intr_attr.delay);
903
904 attr->intr_attr.latency = iocfc->cfginfo->intr_attr.latency ?
905 be16_to_cpu(iocfc->cfginfo->intr_attr.latency) :
906 be16_to_cpu(iocfc->cfgrsp->intr_attr.latency);
907
908 attr->config = iocfc->cfg;
909}
910
911bfa_status_t
912bfa_iocfc_israttr_set(struct bfa_s *bfa, struct bfa_iocfc_intr_attr_s *attr)
913{
914 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
915 struct bfi_iocfc_set_intr_req_s *m;
916
917 iocfc->cfginfo->intr_attr.coalesce = attr->coalesce;
918 iocfc->cfginfo->intr_attr.delay = cpu_to_be16(attr->delay);
919 iocfc->cfginfo->intr_attr.latency = cpu_to_be16(attr->latency);
920
921 if (!bfa_iocfc_is_operational(bfa))
922 return BFA_STATUS_OK;
923
924 m = bfa_reqq_next(bfa, BFA_REQQ_IOC);
925 if (!m)
926 return BFA_STATUS_DEVBUSY;
927
928 bfi_h2i_set(m->mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_SET_INTR_REQ,
929 bfa_lpuid(bfa));
930 m->coalesce = iocfc->cfginfo->intr_attr.coalesce;
931 m->delay = iocfc->cfginfo->intr_attr.delay;
932 m->latency = iocfc->cfginfo->intr_attr.latency;
933
934 bfa_trc(bfa, attr->delay);
935 bfa_trc(bfa, attr->latency);
936
937 bfa_reqq_produce(bfa, BFA_REQQ_IOC);
938 return BFA_STATUS_OK;
939}
940
941void
942bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa)
943{
944 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
945
946 iocfc->cfginfo->sense_buf_len = (BFI_IOIM_SNSLEN - 1);
947 bfa_dma_be_addr_set(iocfc->cfginfo->ioim_snsbase, snsbase_pa);
948}
949/*
950 * Enable IOC after it is disabled.
951 */
952void
953bfa_iocfc_enable(struct bfa_s *bfa)
954{
955 bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
956 "IOC Enable");
957 bfa_ioc_enable(&bfa->ioc);
958}
959
960void
961bfa_iocfc_disable(struct bfa_s *bfa)
962{
963 bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
964 "IOC Disable");
965 bfa->iocfc.action = BFA_IOCFC_ACT_DISABLE;
966
967 bfa->rme_process = BFA_FALSE;
968 bfa_ioc_disable(&bfa->ioc);
969}
970
971
972bfa_boolean_t
973bfa_iocfc_is_operational(struct bfa_s *bfa)
974{
975 return bfa_ioc_is_operational(&bfa->ioc) && bfa->iocfc.cfgdone;
976}
977
978/*
979 * Return boot target port wwns -- read from boot information in flash.
980 */
981void
982bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns)
983{
984 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
985 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
986 int i;
987
988 if (cfgrsp->pbc_cfg.boot_enabled && cfgrsp->pbc_cfg.nbluns) {
989 bfa_trc(bfa, cfgrsp->pbc_cfg.nbluns);
990 *nwwns = cfgrsp->pbc_cfg.nbluns;
991 for (i = 0; i < cfgrsp->pbc_cfg.nbluns; i++)
992 wwns[i] = cfgrsp->pbc_cfg.blun[i].tgt_pwwn;
993
994 return;
995 }
996
997 *nwwns = cfgrsp->bootwwns.nwwns;
998 memcpy(wwns, cfgrsp->bootwwns.wwn, sizeof(cfgrsp->bootwwns.wwn));
999}
1000
1001int
1002bfa_iocfc_get_pbc_vports(struct bfa_s *bfa, struct bfi_pbc_vport_s *pbc_vport)
1003{
1004 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
1005 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
1006
1007 memcpy(pbc_vport, cfgrsp->pbc_cfg.vport, sizeof(cfgrsp->pbc_cfg.vport));
1008 return cfgrsp->pbc_cfg.nvports;
1009}
1010
1011
1012/*
41 * Use this function query the memory requirement of the BFA library. 1013 * Use this function query the memory requirement of the BFA library.
42 * This function needs to be called before bfa_attach() to get the 1014 * This function needs to be called before bfa_attach() to get the
43 * memory required of the BFA layer for a given driver configuration. 1015 * memory required of the BFA layer for a given driver configuration.
@@ -45,16 +1017,16 @@
45 * This call will fail, if the cap is out of range compared to pre-defined 1017 * This call will fail, if the cap is out of range compared to pre-defined
46 * values within the BFA library 1018 * values within the BFA library
47 * 1019 *
48 * @param[in] cfg - pointer to bfa_ioc_cfg_t. Driver layer should indicate 1020 * @param[in] cfg - pointer to bfa_ioc_cfg_t. Driver layer should indicate
49 * its configuration in this structure. 1021 * its configuration in this structure.
50 * The default values for struct bfa_iocfc_cfg_s can be 1022 * The default values for struct bfa_iocfc_cfg_s can be
51 * fetched using bfa_cfg_get_default() API. 1023 * fetched using bfa_cfg_get_default() API.
52 * 1024 *
53 * If cap's boundary check fails, the library will use 1025 * If cap's boundary check fails, the library will use
54 * the default bfa_cap_t values (and log a warning msg). 1026 * the default bfa_cap_t values (and log a warning msg).
55 * 1027 *
56 * @param[out] meminfo - pointer to bfa_meminfo_t. This content 1028 * @param[out] meminfo - pointer to bfa_meminfo_t. This content
57 * indicates the memory type (see bfa_mem_type_t) and 1029 * indicates the memory type (see bfa_mem_type_t) and
58 * amount of memory required. 1030 * amount of memory required.
59 * 1031 *
60 * Driver should allocate the memory, populate the 1032 * Driver should allocate the memory, populate the
@@ -68,12 +1040,12 @@
68void 1040void
69bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo) 1041bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo)
70{ 1042{
71 int i; 1043 int i;
72 u32 km_len = 0, dm_len = 0; 1044 u32 km_len = 0, dm_len = 0;
73 1045
74 bfa_assert((cfg != NULL) && (meminfo != NULL)); 1046 WARN_ON((cfg == NULL) || (meminfo == NULL));
75 1047
76 bfa_os_memset((void *)meminfo, 0, sizeof(struct bfa_meminfo_s)); 1048 memset((void *)meminfo, 0, sizeof(struct bfa_meminfo_s));
77 meminfo->meminfo[BFA_MEM_TYPE_KVA - 1].mem_type = 1049 meminfo->meminfo[BFA_MEM_TYPE_KVA - 1].mem_type =
78 BFA_MEM_TYPE_KVA; 1050 BFA_MEM_TYPE_KVA;
79 meminfo->meminfo[BFA_MEM_TYPE_DMA - 1].mem_type = 1051 meminfo->meminfo[BFA_MEM_TYPE_DMA - 1].mem_type =
@@ -90,27 +1062,7 @@ bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo)
90 meminfo->meminfo[BFA_MEM_TYPE_DMA - 1].mem_len = dm_len; 1062 meminfo->meminfo[BFA_MEM_TYPE_DMA - 1].mem_len = dm_len;
91} 1063}
92 1064
93static void 1065/*
94bfa_com_port_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi)
95{
96 struct bfa_port_s *port = &bfa->modules.port;
97 uint32_t dm_len;
98 uint8_t *dm_kva;
99 uint64_t dm_pa;
100
101 dm_len = bfa_port_meminfo();
102 dm_kva = bfa_meminfo_dma_virt(mi);
103 dm_pa = bfa_meminfo_dma_phys(mi);
104
105 memset(port, 0, sizeof(struct bfa_port_s));
106 bfa_port_attach(port, &bfa->ioc, bfa, bfa->trcmod, bfa->logm);
107 bfa_port_mem_claim(port, dm_kva, dm_pa);
108
109 bfa_meminfo_dma_virt(mi) = dm_kva + dm_len;
110 bfa_meminfo_dma_phys(mi) = dm_pa + dm_len;
111}
112
113/**
114 * Use this function to do attach the driver instance with the BFA 1066 * Use this function to do attach the driver instance with the BFA
115 * library. This function will not trigger any HW initialization 1067 * library. This function will not trigger any HW initialization
116 * process (which will be done in bfa_init() call) 1068 * process (which will be done in bfa_init() call)
@@ -119,14 +1071,14 @@ bfa_com_port_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi)
119 * pre-defined values within the BFA library 1071 * pre-defined values within the BFA library
120 * 1072 *
121 * @param[out] bfa Pointer to bfa_t. 1073 * @param[out] bfa Pointer to bfa_t.
122 * @param[in] bfad Opaque handle back to the driver's IOC structure 1074 * @param[in] bfad Opaque handle back to the driver's IOC structure
123 * @param[in] cfg Pointer to bfa_ioc_cfg_t. Should be same structure 1075 * @param[in] cfg Pointer to bfa_ioc_cfg_t. Should be same structure
124 * that was used in bfa_cfg_get_meminfo(). 1076 * that was used in bfa_cfg_get_meminfo().
125 * @param[in] meminfo Pointer to bfa_meminfo_t. The driver should 1077 * @param[in] meminfo Pointer to bfa_meminfo_t. The driver should
126 * use the bfa_cfg_get_meminfo() call to 1078 * use the bfa_cfg_get_meminfo() call to
127 * find the memory blocks required, allocate the 1079 * find the memory blocks required, allocate the
128 * required memory and provide the starting addresses. 1080 * required memory and provide the starting addresses.
129 * @param[in] pcidev pointer to struct bfa_pcidev_s 1081 * @param[in] pcidev pointer to struct bfa_pcidev_s
130 * 1082 *
131 * @return 1083 * @return
132 * void 1084 * void
@@ -140,14 +1092,14 @@ void
140bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, 1092bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
141 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) 1093 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
142{ 1094{
143 int i; 1095 int i;
144 struct bfa_mem_elem_s *melem; 1096 struct bfa_mem_elem_s *melem;
145 1097
146 bfa->fcs = BFA_FALSE; 1098 bfa->fcs = BFA_FALSE;
147 1099
148 bfa_assert((cfg != NULL) && (meminfo != NULL)); 1100 WARN_ON((cfg == NULL) || (meminfo == NULL));
149 1101
150 /** 1102 /*
151 * initialize all memory pointers for iterative allocation 1103 * initialize all memory pointers for iterative allocation
152 */ 1104 */
153 for (i = 0; i < BFA_MEM_TYPE_MAX; i++) { 1105 for (i = 0; i < BFA_MEM_TYPE_MAX; i++) {
@@ -164,7 +1116,7 @@ bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
164 bfa_com_port_attach(bfa, meminfo); 1116 bfa_com_port_attach(bfa, meminfo);
165} 1117}
166 1118
167/** 1119/*
168 * Use this function to delete a BFA IOC. IOC should be stopped (by 1120 * Use this function to delete a BFA IOC. IOC should be stopped (by
169 * calling bfa_stop()) before this function call. 1121 * calling bfa_stop()) before this function call.
170 * 1122 *
@@ -184,93 +1136,7 @@ bfa_detach(struct bfa_s *bfa)
184 1136
185 for (i = 0; hal_mods[i]; i++) 1137 for (i = 0; hal_mods[i]; i++)
186 hal_mods[i]->detach(bfa); 1138 hal_mods[i]->detach(bfa);
187 1139 bfa_ioc_detach(&bfa->ioc);
188 bfa_iocfc_detach(bfa);
189}
190
191
192void
193bfa_init_trc(struct bfa_s *bfa, struct bfa_trc_mod_s *trcmod)
194{
195 bfa->trcmod = trcmod;
196}
197
198
199void
200bfa_init_log(struct bfa_s *bfa, struct bfa_log_mod_s *logmod)
201{
202 bfa->logm = logmod;
203}
204
205
206void
207bfa_init_aen(struct bfa_s *bfa, struct bfa_aen_s *aen)
208{
209 bfa->aen = aen;
210}
211
212void
213bfa_init_plog(struct bfa_s *bfa, struct bfa_plog_s *plog)
214{
215 bfa->plog = plog;
216}
217
218/**
219 * Initialize IOC.
220 *
221 * This function will return immediately, when the IOC initialization is
222 * completed, the bfa_cb_init() will be called.
223 *
224 * @param[in] bfa instance
225 *
226 * @return void
227 *
228 * Special Considerations:
229 *
230 * @note
231 * When this function returns, the driver should register the interrupt service
232 * routine(s) and enable the device interrupts. If this is not done,
233 * bfa_cb_init() will never get called
234 */
235void
236bfa_init(struct bfa_s *bfa)
237{
238 bfa_iocfc_init(bfa);
239}
240
241/**
242 * Use this function initiate the IOC configuration setup. This function
243 * will return immediately.
244 *
245 * @param[in] bfa instance
246 *
247 * @return None
248 */
249void
250bfa_start(struct bfa_s *bfa)
251{
252 bfa_iocfc_start(bfa);
253}
254
255/**
256 * Use this function quiese the IOC. This function will return immediately,
257 * when the IOC is actually stopped, the bfa_cb_stop() will be called.
258 *
259 * @param[in] bfa - pointer to bfa_t.
260 *
261 * @return None
262 *
263 * Special Considerations:
264 * bfa_cb_stop() could be called before or after bfa_stop() returns.
265 *
266 * @note
267 * In case of any failure, we could handle it automatically by doing a
268 * reset and then succeed the bfa_stop() call.
269 */
270void
271bfa_stop(struct bfa_s *bfa)
272{
273 bfa_iocfc_stop(bfa);
274} 1140}
275 1141
276void 1142void
@@ -283,9 +1149,9 @@ bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q)
283void 1149void
284bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q) 1150bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q)
285{ 1151{
286 struct list_head *qe; 1152 struct list_head *qe;
287 struct list_head *qen; 1153 struct list_head *qen;
288 struct bfa_cb_qe_s *hcb_qe; 1154 struct bfa_cb_qe_s *hcb_qe;
289 1155
290 list_for_each_safe(qe, qen, comp_q) { 1156 list_for_each_safe(qe, qen, comp_q) {
291 hcb_qe = (struct bfa_cb_qe_s *) qe; 1157 hcb_qe = (struct bfa_cb_qe_s *) qe;
@@ -296,8 +1162,8 @@ bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q)
296void 1162void
297bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q) 1163bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q)
298{ 1164{
299 struct list_head *qe; 1165 struct list_head *qe;
300 struct bfa_cb_qe_s *hcb_qe; 1166 struct bfa_cb_qe_s *hcb_qe;
301 1167
302 while (!list_empty(comp_q)) { 1168 while (!list_empty(comp_q)) {
303 bfa_q_deq(comp_q, &qe); 1169 bfa_q_deq(comp_q, &qe);
@@ -306,23 +1172,8 @@ bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q)
306 } 1172 }
307} 1173}
308 1174
309void
310bfa_attach_fcs(struct bfa_s *bfa)
311{
312 bfa->fcs = BFA_TRUE;
313}
314 1175
315/** 1176/*
316 * Periodic timer heart beat from driver
317 */
318void
319bfa_timer_tick(struct bfa_s *bfa)
320{
321 bfa_timer_beat(&bfa->timer_mod);
322}
323
324#ifndef BFA_BIOS_BUILD
325/**
326 * Return the list of PCI vendor/device id lists supported by this 1177 * Return the list of PCI vendor/device id lists supported by this
327 * BFA instance. 1178 * BFA instance.
328 */ 1179 */
@@ -336,11 +1187,11 @@ bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids)
336 {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT_FC}, 1187 {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT_FC},
337 }; 1188 };
338 1189
339 *npciids = ARRAY_SIZE(__pciids); 1190 *npciids = sizeof(__pciids) / sizeof(__pciids[0]);
340 *pciids = __pciids; 1191 *pciids = __pciids;
341} 1192}
342 1193
343/** 1194/*
344 * Use this function query the default struct bfa_iocfc_cfg_s value (compiled 1195 * Use this function query the default struct bfa_iocfc_cfg_s value (compiled
345 * into BFA layer). The OS driver can then turn back and overwrite entries that 1196 * into BFA layer). The OS driver can then turn back and overwrite entries that
346 * have been configured by the user. 1197 * have been configured by the user.
@@ -351,7 +1202,7 @@ bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids)
351 * void 1202 * void
352 * 1203 *
353 * Special Considerations: 1204 * Special Considerations:
354 * note 1205 * note
355 */ 1206 */
356void 1207void
357bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg) 1208bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg)
@@ -389,56 +1240,5 @@ bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg)
389 cfg->drvcfg.num_sgpgs = BFA_SGPG_MIN; 1240 cfg->drvcfg.num_sgpgs = BFA_SGPG_MIN;
390 cfg->drvcfg.num_reqq_elems = BFA_REQQ_NELEMS_MIN; 1241 cfg->drvcfg.num_reqq_elems = BFA_REQQ_NELEMS_MIN;
391 cfg->drvcfg.num_rspq_elems = BFA_RSPQ_NELEMS_MIN; 1242 cfg->drvcfg.num_rspq_elems = BFA_RSPQ_NELEMS_MIN;
392 cfg->drvcfg.min_cfg = BFA_TRUE; 1243 cfg->drvcfg.min_cfg = BFA_TRUE;
393}
394
395void
396bfa_get_attr(struct bfa_s *bfa, struct bfa_ioc_attr_s *ioc_attr)
397{
398 bfa_ioc_get_attr(&bfa->ioc, ioc_attr);
399}
400
401/**
402 * Retrieve firmware trace information on IOC failure.
403 */
404bfa_status_t
405bfa_debug_fwsave(struct bfa_s *bfa, void *trcdata, int *trclen)
406{
407 return bfa_ioc_debug_fwsave(&bfa->ioc, trcdata, trclen);
408}
409
410/**
411 * Clear the saved firmware trace information of an IOC.
412 */
413void
414bfa_debug_fwsave_clear(struct bfa_s *bfa)
415{
416 bfa_ioc_debug_fwsave_clear(&bfa->ioc);
417}
418
419/**
420 * Fetch firmware trace data.
421 *
422 * @param[in] bfa BFA instance
423 * @param[out] trcdata Firmware trace buffer
424 * @param[in,out] trclen Firmware trace buffer len
425 *
426 * @retval BFA_STATUS_OK Firmware trace is fetched.
427 * @retval BFA_STATUS_INPROGRESS Firmware trace fetch is in progress.
428 */
429bfa_status_t
430bfa_debug_fwtrc(struct bfa_s *bfa, void *trcdata, int *trclen)
431{
432 return bfa_ioc_debug_fwtrc(&bfa->ioc, trcdata, trclen);
433}
434
435/**
436 * Reset hw semaphore & usage cnt regs and initialize.
437 */
438void
439bfa_chip_reset(struct bfa_s *bfa)
440{
441 bfa_ioc_ownership_reset(&bfa->ioc);
442 bfa_ioc_pll_init(&bfa->ioc);
443} 1244}
444#endif
diff --git a/drivers/scsi/bfa/bfa_cs.h b/drivers/scsi/bfa/bfa_cs.h
new file mode 100644
index 000000000000..12bfeed268eb
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_cs.h
@@ -0,0 +1,366 @@
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/*
19 * bfa_cs.h BFA common services
20 */
21
22#ifndef __BFA_CS_H__
23#define __BFA_CS_H__
24
25#include "bfad_drv.h"
26
27/*
28 * BFA TRC
29 */
30
31#ifndef BFA_TRC_MAX
32#define BFA_TRC_MAX (4 * 1024)
33#endif
34
35#define BFA_TRC_TS(_trcm) \
36 ({ \
37 struct timeval tv; \
38 \
39 do_gettimeofday(&tv); \
40 (tv.tv_sec*1000000+tv.tv_usec); \
41 })
42
43#ifndef BFA_TRC_TS
44#define BFA_TRC_TS(_trcm) ((_trcm)->ticks++)
45#endif
46
47struct bfa_trc_s {
48#ifdef __BIG_ENDIAN
49 u16 fileno;
50 u16 line;
51#else
52 u16 line;
53 u16 fileno;
54#endif
55 u32 timestamp;
56 union {
57 struct {
58 u32 rsvd;
59 u32 u32;
60 } u32;
61 u64 u64;
62 } data;
63};
64
65struct bfa_trc_mod_s {
66 u32 head;
67 u32 tail;
68 u32 ntrc;
69 u32 stopped;
70 u32 ticks;
71 u32 rsvd[3];
72 struct bfa_trc_s trc[BFA_TRC_MAX];
73};
74
75enum {
76 BFA_TRC_HAL = 1, /* BFA modules */
77 BFA_TRC_FCS = 2, /* BFA FCS modules */
78 BFA_TRC_LDRV = 3, /* Linux driver modules */
79 BFA_TRC_CNA = 4, /* Common modules */
80};
81#define BFA_TRC_MOD_SH 10
82#define BFA_TRC_MOD(__mod) ((BFA_TRC_ ## __mod) << BFA_TRC_MOD_SH)
83
84/*
85 * Define a new tracing file (module). Module should match one defined above.
86 */
87#define BFA_TRC_FILE(__mod, __submod) \
88 static int __trc_fileno = ((BFA_TRC_ ## __mod ## _ ## __submod) | \
89 BFA_TRC_MOD(__mod))
90
91
92#define bfa_trc32(_trcp, _data) \
93 __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u32)_data)
94#define bfa_trc(_trcp, _data) \
95 __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u64)_data)
96
97static inline void
98bfa_trc_init(struct bfa_trc_mod_s *trcm)
99{
100 trcm->head = trcm->tail = trcm->stopped = 0;
101 trcm->ntrc = BFA_TRC_MAX;
102}
103
104static inline void
105bfa_trc_stop(struct bfa_trc_mod_s *trcm)
106{
107 trcm->stopped = 1;
108}
109
110static inline void
111__bfa_trc(struct bfa_trc_mod_s *trcm, int fileno, int line, u64 data)
112{
113 int tail = trcm->tail;
114 struct bfa_trc_s *trc = &trcm->trc[tail];
115
116 if (trcm->stopped)
117 return;
118
119 trc->fileno = (u16) fileno;
120 trc->line = (u16) line;
121 trc->data.u64 = data;
122 trc->timestamp = BFA_TRC_TS(trcm);
123
124 trcm->tail = (trcm->tail + 1) & (BFA_TRC_MAX - 1);
125 if (trcm->tail == trcm->head)
126 trcm->head = (trcm->head + 1) & (BFA_TRC_MAX - 1);
127}
128
129
130static inline void
131__bfa_trc32(struct bfa_trc_mod_s *trcm, int fileno, int line, u32 data)
132{
133 int tail = trcm->tail;
134 struct bfa_trc_s *trc = &trcm->trc[tail];
135
136 if (trcm->stopped)
137 return;
138
139 trc->fileno = (u16) fileno;
140 trc->line = (u16) line;
141 trc->data.u32.u32 = data;
142 trc->timestamp = BFA_TRC_TS(trcm);
143
144 trcm->tail = (trcm->tail + 1) & (BFA_TRC_MAX - 1);
145 if (trcm->tail == trcm->head)
146 trcm->head = (trcm->head + 1) & (BFA_TRC_MAX - 1);
147}
148
149#define bfa_sm_fault(__mod, __event) do { \
150 bfa_trc(__mod, (((u32)0xDEAD << 16) | __event)); \
151 printk(KERN_ERR "Assertion failure: %s:%d: %d", \
152 __FILE__, __LINE__, (__event)); \
153} while (0)
154
155/* BFA queue definitions */
156#define bfa_q_first(_q) ((void *)(((struct list_head *) (_q))->next))
157#define bfa_q_next(_qe) (((struct list_head *) (_qe))->next)
158#define bfa_q_prev(_qe) (((struct list_head *) (_qe))->prev)
159
160/*
161 * bfa_q_qe_init - to initialize a queue element
162 */
163#define bfa_q_qe_init(_qe) { \
164 bfa_q_next(_qe) = (struct list_head *) NULL; \
165 bfa_q_prev(_qe) = (struct list_head *) NULL; \
166}
167
168/*
169 * bfa_q_deq - dequeue an element from head of the queue
170 */
171#define bfa_q_deq(_q, _qe) { \
172 if (!list_empty(_q)) { \
173 (*((struct list_head **) (_qe))) = bfa_q_next(_q); \
174 bfa_q_prev(bfa_q_next(*((struct list_head **) _qe))) = \
175 (struct list_head *) (_q); \
176 bfa_q_next(_q) = bfa_q_next(*((struct list_head **) _qe));\
177 } else { \
178 *((struct list_head **) (_qe)) = (struct list_head *) NULL;\
179 } \
180}
181
182/*
183 * bfa_q_deq_tail - dequeue an element from tail of the queue
184 */
185#define bfa_q_deq_tail(_q, _qe) { \
186 if (!list_empty(_q)) { \
187 *((struct list_head **) (_qe)) = bfa_q_prev(_q); \
188 bfa_q_next(bfa_q_prev(*((struct list_head **) _qe))) = \
189 (struct list_head *) (_q); \
190 bfa_q_prev(_q) = bfa_q_prev(*(struct list_head **) _qe);\
191 } else { \
192 *((struct list_head **) (_qe)) = (struct list_head *) NULL;\
193 } \
194}
195
196static inline int
197bfa_q_is_on_q_func(struct list_head *q, struct list_head *qe)
198{
199 struct list_head *tqe;
200
201 tqe = bfa_q_next(q);
202 while (tqe != q) {
203 if (tqe == qe)
204 return 1;
205 tqe = bfa_q_next(tqe);
206 if (tqe == NULL)
207 break;
208 }
209 return 0;
210}
211
212#define bfa_q_is_on_q(_q, _qe) \
213 bfa_q_is_on_q_func(_q, (struct list_head *)(_qe))
214
215/*
216 * @ BFA state machine interfaces
217 */
218
219typedef void (*bfa_sm_t)(void *sm, int event);
220
221/*
222 * oc - object class eg. bfa_ioc
223 * st - state, eg. reset
224 * otype - object type, eg. struct bfa_ioc_s
225 * etype - object type, eg. enum ioc_event
226 */
227#define bfa_sm_state_decl(oc, st, otype, etype) \
228 static void oc ## _sm_ ## st(otype * fsm, etype event)
229
230#define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (bfa_sm_t)(_state))
231#define bfa_sm_send_event(_sm, _event) ((_sm)->sm((_sm), (_event)))
232#define bfa_sm_get_state(_sm) ((_sm)->sm)
233#define bfa_sm_cmp_state(_sm, _state) ((_sm)->sm == (bfa_sm_t)(_state))
234
235/*
236 * For converting from state machine function to state encoding.
237 */
238struct bfa_sm_table_s {
239 bfa_sm_t sm; /* state machine function */
240 int state; /* state machine encoding */
241 char *name; /* state name for display */
242};
243#define BFA_SM(_sm) ((bfa_sm_t)(_sm))
244
245/*
246 * State machine with entry actions.
247 */
248typedef void (*bfa_fsm_t)(void *fsm, int event);
249
250/*
251 * oc - object class eg. bfa_ioc
252 * st - state, eg. reset
253 * otype - object type, eg. struct bfa_ioc_s
254 * etype - object type, eg. enum ioc_event
255 */
256#define bfa_fsm_state_decl(oc, st, otype, etype) \
257 static void oc ## _sm_ ## st(otype * fsm, etype event); \
258 static void oc ## _sm_ ## st ## _entry(otype * fsm)
259
260#define bfa_fsm_set_state(_fsm, _state) do { \
261 (_fsm)->fsm = (bfa_fsm_t)(_state); \
262 _state ## _entry(_fsm); \
263} while (0)
264
265#define bfa_fsm_send_event(_fsm, _event) ((_fsm)->fsm((_fsm), (_event)))
266#define bfa_fsm_get_state(_fsm) ((_fsm)->fsm)
267#define bfa_fsm_cmp_state(_fsm, _state) \
268 ((_fsm)->fsm == (bfa_fsm_t)(_state))
269
270static inline int
271bfa_sm_to_state(struct bfa_sm_table_s *smt, bfa_sm_t sm)
272{
273 int i = 0;
274
275 while (smt[i].sm && smt[i].sm != sm)
276 i++;
277 return smt[i].state;
278}
279
280/*
281 * @ Generic wait counter.
282 */
283
284typedef void (*bfa_wc_resume_t) (void *cbarg);
285
286struct bfa_wc_s {
287 bfa_wc_resume_t wc_resume;
288 void *wc_cbarg;
289 int wc_count;
290};
291
292static inline void
293bfa_wc_up(struct bfa_wc_s *wc)
294{
295 wc->wc_count++;
296}
297
298static inline void
299bfa_wc_down(struct bfa_wc_s *wc)
300{
301 wc->wc_count--;
302 if (wc->wc_count == 0)
303 wc->wc_resume(wc->wc_cbarg);
304}
305
306/*
307 * Initialize a waiting counter.
308 */
309static inline void
310bfa_wc_init(struct bfa_wc_s *wc, bfa_wc_resume_t wc_resume, void *wc_cbarg)
311{
312 wc->wc_resume = wc_resume;
313 wc->wc_cbarg = wc_cbarg;
314 wc->wc_count = 0;
315 bfa_wc_up(wc);
316}
317
318/*
319 * Wait for counter to reach zero
320 */
321static inline void
322bfa_wc_wait(struct bfa_wc_s *wc)
323{
324 bfa_wc_down(wc);
325}
326
327static inline void
328wwn2str(char *wwn_str, u64 wwn)
329{
330 union {
331 u64 wwn;
332 u8 byte[8];
333 } w;
334
335 w.wwn = wwn;
336 sprintf(wwn_str, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", w.byte[0],
337 w.byte[1], w.byte[2], w.byte[3], w.byte[4], w.byte[5],
338 w.byte[6], w.byte[7]);
339}
340
341static inline void
342fcid2str(char *fcid_str, u32 fcid)
343{
344 union {
345 u32 fcid;
346 u8 byte[4];
347 } f;
348
349 f.fcid = fcid;
350 sprintf(fcid_str, "%02x:%02x:%02x", f.byte[1], f.byte[2], f.byte[3]);
351}
352
353#define bfa_swap_3b(_x) \
354 ((((_x) & 0xff) << 16) | \
355 ((_x) & 0x00ff00) | \
356 (((_x) & 0xff0000) >> 16))
357
358#ifndef __BIG_ENDIAN
359#define bfa_hton3b(_x) bfa_swap_3b(_x)
360#else
361#define bfa_hton3b(_x) (_x)
362#endif
363
364#define bfa_ntoh3b(_x) bfa_hton3b(_x)
365
366#endif /* __BFA_CS_H__ */
diff --git a/drivers/scsi/bfa/bfa_csdebug.c b/drivers/scsi/bfa/bfa_csdebug.c
deleted file mode 100644
index caeb1143a4e6..000000000000
--- a/drivers/scsi/bfa/bfa_csdebug.c
+++ /dev/null
@@ -1,58 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <cs/bfa_debug.h>
19#include <bfa_os_inc.h>
20#include <cs/bfa_q.h>
21#include <log/bfa_log_hal.h>
22
23/**
24 * cs_debug_api
25 */
26
27
28void
29bfa_panic(int line, char *file, char *panicstr)
30{
31 bfa_log(NULL, BFA_LOG_HAL_ASSERT, file, line, panicstr);
32 bfa_os_panic();
33}
34
35void
36bfa_sm_panic(struct bfa_log_mod_s *logm, int line, char *file, int event)
37{
38 bfa_log(logm, BFA_LOG_HAL_SM_ASSERT, file, line, event);
39 bfa_os_panic();
40}
41
42int
43bfa_q_is_on_q_func(struct list_head *q, struct list_head *qe)
44{
45 struct list_head *tqe;
46
47 tqe = bfa_q_next(q);
48 while (tqe != q) {
49 if (tqe == qe)
50 return 1;
51 tqe = bfa_q_next(tqe);
52 if (tqe == NULL)
53 break;
54 }
55 return 0;
56}
57
58
diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
new file mode 100644
index 000000000000..d85f93aea465
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -0,0 +1,466 @@
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_DEFS_H__
19#define __BFA_DEFS_H__
20
21#include "bfa_fc.h"
22#include "bfad_drv.h"
23
24#define BFA_MFG_SERIALNUM_SIZE 11
25#define STRSZ(_n) (((_n) + 4) & ~3)
26
27/*
28 * Manufacturing card type
29 */
30enum {
31 BFA_MFG_TYPE_CB_MAX = 825, /* Crossbow card type max */
32 BFA_MFG_TYPE_FC8P2 = 825, /* 8G 2port FC card */
33 BFA_MFG_TYPE_FC8P1 = 815, /* 8G 1port FC card */
34 BFA_MFG_TYPE_FC4P2 = 425, /* 4G 2port FC card */
35 BFA_MFG_TYPE_FC4P1 = 415, /* 4G 1port FC card */
36 BFA_MFG_TYPE_CNA10P2 = 1020, /* 10G 2port CNA card */
37 BFA_MFG_TYPE_CNA10P1 = 1010, /* 10G 1port CNA card */
38 BFA_MFG_TYPE_JAYHAWK = 804, /* Jayhawk mezz card */
39 BFA_MFG_TYPE_WANCHESE = 1007, /* Wanchese mezz card */
40 BFA_MFG_TYPE_ASTRA = 807, /* Astra mezz card */
41 BFA_MFG_TYPE_LIGHTNING_P0 = 902, /* Lightning mezz card - old */
42 BFA_MFG_TYPE_LIGHTNING = 1741, /* Lightning mezz card */
43 BFA_MFG_TYPE_INVALID = 0, /* Invalid card type */
44};
45
46#pragma pack(1)
47
48/*
49 * Check if Mezz card
50 */
51#define bfa_mfg_is_mezz(type) (( \
52 (type) == BFA_MFG_TYPE_JAYHAWK || \
53 (type) == BFA_MFG_TYPE_WANCHESE || \
54 (type) == BFA_MFG_TYPE_ASTRA || \
55 (type) == BFA_MFG_TYPE_LIGHTNING_P0 || \
56 (type) == BFA_MFG_TYPE_LIGHTNING))
57
58/*
59 * Check if the card having old wwn/mac handling
60 */
61#define bfa_mfg_is_old_wwn_mac_model(type) (( \
62 (type) == BFA_MFG_TYPE_FC8P2 || \
63 (type) == BFA_MFG_TYPE_FC8P1 || \
64 (type) == BFA_MFG_TYPE_FC4P2 || \
65 (type) == BFA_MFG_TYPE_FC4P1 || \
66 (type) == BFA_MFG_TYPE_CNA10P2 || \
67 (type) == BFA_MFG_TYPE_CNA10P1 || \
68 (type) == BFA_MFG_TYPE_JAYHAWK || \
69 (type) == BFA_MFG_TYPE_WANCHESE))
70
71#define bfa_mfg_increment_wwn_mac(m, i) \
72do { \
73 u32 t = ((u32)(m)[0] << 16) | ((u32)(m)[1] << 8) | \
74 (u32)(m)[2]; \
75 t += (i); \
76 (m)[0] = (t >> 16) & 0xFF; \
77 (m)[1] = (t >> 8) & 0xFF; \
78 (m)[2] = t & 0xFF; \
79} while (0)
80
81/*
82 * VPD data length
83 */
84#define BFA_MFG_VPD_LEN 512
85
86/*
87 * VPD vendor tag
88 */
89enum {
90 BFA_MFG_VPD_UNKNOWN = 0, /* vendor unknown */
91 BFA_MFG_VPD_IBM = 1, /* vendor IBM */
92 BFA_MFG_VPD_HP = 2, /* vendor HP */
93 BFA_MFG_VPD_DELL = 3, /* vendor DELL */
94 BFA_MFG_VPD_PCI_IBM = 0x08, /* PCI VPD IBM */
95 BFA_MFG_VPD_PCI_HP = 0x10, /* PCI VPD HP */
96 BFA_MFG_VPD_PCI_DELL = 0x20, /* PCI VPD DELL */
97 BFA_MFG_VPD_PCI_BRCD = 0xf8, /* PCI VPD Brocade */
98};
99
100/*
101 * All numerical fields are in big-endian format.
102 */
103struct bfa_mfg_vpd_s {
104 u8 version; /* vpd data version */
105 u8 vpd_sig[3]; /* characters 'V', 'P', 'D' */
106 u8 chksum; /* u8 checksum */
107 u8 vendor; /* vendor */
108 u8 len; /* vpd data length excluding header */
109 u8 rsv;
110 u8 data[BFA_MFG_VPD_LEN]; /* vpd data */
111};
112
113#pragma pack()
114
115/*
116 * Status return values
117 */
118enum bfa_status {
119 BFA_STATUS_OK = 0, /* Success */
120 BFA_STATUS_FAILED = 1, /* Operation failed */
121 BFA_STATUS_EINVAL = 2, /* Invalid params Check input
122 * parameters */
123 BFA_STATUS_ENOMEM = 3, /* Out of resources */
124 BFA_STATUS_ETIMER = 5, /* Timer expired - Retry, if persists,
125 * contact support */
126 BFA_STATUS_EPROTOCOL = 6, /* Protocol error */
127 BFA_STATUS_DEVBUSY = 13, /* Device busy - Retry operation */
128 BFA_STATUS_UNKNOWN_LWWN = 18, /* LPORT PWWN not found */
129 BFA_STATUS_UNKNOWN_RWWN = 19, /* RPORT PWWN not found */
130 BFA_STATUS_VPORT_EXISTS = 21, /* VPORT already exists */
131 BFA_STATUS_VPORT_MAX = 22, /* Reached max VPORT supported limit */
132 BFA_STATUS_UNSUPP_SPEED = 23, /* Invalid Speed Check speed setting */
133 BFA_STATUS_INVLD_DFSZ = 24, /* Invalid Max data field size */
134 BFA_STATUS_FABRIC_RJT = 29, /* Reject from attached fabric */
135 BFA_STATUS_VPORT_WWN_BP = 46, /* WWN is same as base port's WWN */
136 BFA_STATUS_NO_FCPIM_NEXUS = 52, /* No FCP Nexus exists with the rport */
137 BFA_STATUS_IOC_FAILURE = 56, /* IOC failure - Retry, if persists
138 * contact support */
139 BFA_STATUS_INVALID_WWN = 57, /* Invalid WWN */
140 BFA_STATUS_DIAG_BUSY = 71, /* diag busy */
141 BFA_STATUS_ENOFSAVE = 78, /* No saved firmware trace */
142 BFA_STATUS_IOC_DISABLED = 82, /* IOC is already disabled */
143 BFA_STATUS_INVALID_MAC = 134, /* Invalid MAC address */
144 BFA_STATUS_PBC = 154, /* Operation not allowed for pre-boot
145 * configuration */
146 BFA_STATUS_TRUNK_ENABLED = 164, /* Trunk is already enabled on
147 * this adapter */
148 BFA_STATUS_TRUNK_DISABLED = 165, /* Trunking is disabled on
149 * the adapter */
150 BFA_STATUS_IOPROFILE_OFF = 175, /* IO profile OFF */
151 BFA_STATUS_MAX_VAL /* Unknown error code */
152};
153#define bfa_status_t enum bfa_status
154
155enum bfa_eproto_status {
156 BFA_EPROTO_BAD_ACCEPT = 0,
157 BFA_EPROTO_UNKNOWN_RSP = 1
158};
159#define bfa_eproto_status_t enum bfa_eproto_status
160
161enum bfa_boolean {
162 BFA_FALSE = 0,
163 BFA_TRUE = 1
164};
165#define bfa_boolean_t enum bfa_boolean
166
167#define BFA_STRING_32 32
168#define BFA_VERSION_LEN 64
169
170/*
171 * ---------------------- adapter definitions ------------
172 */
173
174/*
175 * BFA adapter level attributes.
176 */
177enum {
178 BFA_ADAPTER_SERIAL_NUM_LEN = STRSZ(BFA_MFG_SERIALNUM_SIZE),
179 /*
180 *!< adapter serial num length
181 */
182 BFA_ADAPTER_MODEL_NAME_LEN = 16, /* model name length */
183 BFA_ADAPTER_MODEL_DESCR_LEN = 128, /* model description length */
184 BFA_ADAPTER_MFG_NAME_LEN = 8, /* manufacturer name length */
185 BFA_ADAPTER_SYM_NAME_LEN = 64, /* adapter symbolic name length */
186 BFA_ADAPTER_OS_TYPE_LEN = 64, /* adapter os type length */
187};
188
189struct bfa_adapter_attr_s {
190 char manufacturer[BFA_ADAPTER_MFG_NAME_LEN];
191 char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
192 u32 card_type;
193 char model[BFA_ADAPTER_MODEL_NAME_LEN];
194 char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN];
195 wwn_t pwwn;
196 char node_symname[FC_SYMNAME_MAX];
197 char hw_ver[BFA_VERSION_LEN];
198 char fw_ver[BFA_VERSION_LEN];
199 char optrom_ver[BFA_VERSION_LEN];
200 char os_type[BFA_ADAPTER_OS_TYPE_LEN];
201 struct bfa_mfg_vpd_s vpd;
202 struct mac_s mac;
203
204 u8 nports;
205 u8 max_speed;
206 u8 prototype;
207 char asic_rev;
208
209 u8 pcie_gen;
210 u8 pcie_lanes_orig;
211 u8 pcie_lanes;
212 u8 cna_capable;
213
214 u8 is_mezz;
215 u8 trunk_capable;
216};
217
218/*
219 * ---------------------- IOC definitions ------------
220 */
221
222enum {
223 BFA_IOC_DRIVER_LEN = 16,
224 BFA_IOC_CHIP_REV_LEN = 8,
225};
226
227/*
228 * Driver and firmware versions.
229 */
230struct bfa_ioc_driver_attr_s {
231 char driver[BFA_IOC_DRIVER_LEN]; /* driver name */
232 char driver_ver[BFA_VERSION_LEN]; /* driver version */
233 char fw_ver[BFA_VERSION_LEN]; /* firmware version */
234 char bios_ver[BFA_VERSION_LEN]; /* bios version */
235 char efi_ver[BFA_VERSION_LEN]; /* EFI version */
236 char ob_ver[BFA_VERSION_LEN]; /* openboot version */
237};
238
239/*
240 * IOC PCI device attributes
241 */
242struct bfa_ioc_pci_attr_s {
243 u16 vendor_id; /* PCI vendor ID */
244 u16 device_id; /* PCI device ID */
245 u16 ssid; /* subsystem ID */
246 u16 ssvid; /* subsystem vendor ID */
247 u32 pcifn; /* PCI device function */
248 u32 rsvd; /* padding */
249 char chip_rev[BFA_IOC_CHIP_REV_LEN]; /* chip revision */
250};
251
252/*
253 * IOC states
254 */
255enum bfa_ioc_state {
256 BFA_IOC_UNINIT = 1, /* IOC is in uninit state */
257 BFA_IOC_RESET = 2, /* IOC is in reset state */
258 BFA_IOC_SEMWAIT = 3, /* Waiting for IOC h/w semaphore */
259 BFA_IOC_HWINIT = 4, /* IOC h/w is being initialized */
260 BFA_IOC_GETATTR = 5, /* IOC is being configured */
261 BFA_IOC_OPERATIONAL = 6, /* IOC is operational */
262 BFA_IOC_INITFAIL = 7, /* IOC hardware failure */
263 BFA_IOC_FAIL = 8, /* IOC heart-beat failure */
264 BFA_IOC_DISABLING = 9, /* IOC is being disabled */
265 BFA_IOC_DISABLED = 10, /* IOC is disabled */
266 BFA_IOC_FWMISMATCH = 11, /* IOC f/w different from drivers */
267 BFA_IOC_ENABLING = 12, /* IOC is being enabled */
268};
269
270/*
271 * IOC firmware stats
272 */
273struct bfa_fw_ioc_stats_s {
274 u32 enable_reqs;
275 u32 disable_reqs;
276 u32 get_attr_reqs;
277 u32 dbg_sync;
278 u32 dbg_dump;
279 u32 unknown_reqs;
280};
281
282/*
283 * IOC driver stats
284 */
285struct bfa_ioc_drv_stats_s {
286 u32 ioc_isrs;
287 u32 ioc_enables;
288 u32 ioc_disables;
289 u32 ioc_hbfails;
290 u32 ioc_boots;
291 u32 stats_tmos;
292 u32 hb_count;
293 u32 disable_reqs;
294 u32 enable_reqs;
295 u32 disable_replies;
296 u32 enable_replies;
297};
298
299/*
300 * IOC statistics
301 */
302struct bfa_ioc_stats_s {
303 struct bfa_ioc_drv_stats_s drv_stats; /* driver IOC stats */
304 struct bfa_fw_ioc_stats_s fw_stats; /* firmware IOC stats */
305};
306
307enum bfa_ioc_type_e {
308 BFA_IOC_TYPE_FC = 1,
309 BFA_IOC_TYPE_FCoE = 2,
310 BFA_IOC_TYPE_LL = 3,
311};
312
313/*
314 * IOC attributes returned in queries
315 */
316struct bfa_ioc_attr_s {
317 enum bfa_ioc_type_e ioc_type;
318 enum bfa_ioc_state state; /* IOC state */
319 struct bfa_adapter_attr_s adapter_attr; /* HBA attributes */
320 struct bfa_ioc_driver_attr_s driver_attr; /* driver attr */
321 struct bfa_ioc_pci_attr_s pci_attr;
322 u8 port_id; /* port number */
323 u8 rsvd[7]; /* 64bit align */
324};
325
326/*
327 * ---------------------- mfg definitions ------------
328 */
329
330/*
331 * Checksum size
332 */
333#define BFA_MFG_CHKSUM_SIZE 16
334
335#define BFA_MFG_PARTNUM_SIZE 14
336#define BFA_MFG_SUPPLIER_ID_SIZE 10
337#define BFA_MFG_SUPPLIER_PARTNUM_SIZE 20
338#define BFA_MFG_SUPPLIER_SERIALNUM_SIZE 20
339#define BFA_MFG_SUPPLIER_REVISION_SIZE 4
340
341#pragma pack(1)
342
343/*
344 * All numerical fields are in big-endian format.
345 */
346struct bfa_mfg_block_s {
347 u8 version; /* manufacturing block version */
348 u8 mfg_sig[3]; /* characters 'M', 'F', 'G' */
349 u16 mfgsize; /* mfg block size */
350 u16 u16_chksum; /* old u16 checksum */
351 char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
352 char brcd_partnum[STRSZ(BFA_MFG_PARTNUM_SIZE)];
353 u8 mfg_day; /* manufacturing day */
354 u8 mfg_month; /* manufacturing month */
355 u16 mfg_year; /* manufacturing year */
356 wwn_t mfg_wwn; /* wwn base for this adapter */
357 u8 num_wwn; /* number of wwns assigned */
358 u8 mfg_speeds; /* speeds allowed for this adapter */
359 u8 rsv[2];
360 char supplier_id[STRSZ(BFA_MFG_SUPPLIER_ID_SIZE)];
361 char supplier_partnum[STRSZ(BFA_MFG_SUPPLIER_PARTNUM_SIZE)];
362 char
363 supplier_serialnum[STRSZ(BFA_MFG_SUPPLIER_SERIALNUM_SIZE)];
364 char
365 supplier_revision[STRSZ(BFA_MFG_SUPPLIER_REVISION_SIZE)];
366 mac_t mfg_mac; /* mac address */
367 u8 num_mac; /* number of mac addresses */
368 u8 rsv2;
369 u32 mfg_type; /* card type */
370 u8 rsv3[108];
371 u8 md5_chksum[BFA_MFG_CHKSUM_SIZE]; /* md5 checksum */
372};
373
374#pragma pack()
375
376/*
377 * ---------------------- pci definitions ------------
378 */
379
380/*
381 * PCI device and vendor ID information
382 */
383enum {
384 BFA_PCI_VENDOR_ID_BROCADE = 0x1657,
385 BFA_PCI_DEVICE_ID_FC_8G2P = 0x13,
386 BFA_PCI_DEVICE_ID_FC_8G1P = 0x17,
387 BFA_PCI_DEVICE_ID_CT = 0x14,
388 BFA_PCI_DEVICE_ID_CT_FC = 0x21,
389};
390
391#define bfa_asic_id_ct(devid) \
392 ((devid) == BFA_PCI_DEVICE_ID_CT || \
393 (devid) == BFA_PCI_DEVICE_ID_CT_FC)
394
395/*
396 * PCI sub-system device and vendor ID information
397 */
398enum {
399 BFA_PCI_FCOE_SSDEVICE_ID = 0x14,
400};
401
402/*
403 * Maximum number of device address ranges mapped through different BAR(s)
404 */
405#define BFA_PCI_ACCESS_RANGES 1
406
407/*
408 * Port speed settings. Each specific speed is a bit field. Use multiple
409 * bits to specify speeds to be selected for auto-negotiation.
410 */
411enum bfa_port_speed {
412 BFA_PORT_SPEED_UNKNOWN = 0,
413 BFA_PORT_SPEED_1GBPS = 1,
414 BFA_PORT_SPEED_2GBPS = 2,
415 BFA_PORT_SPEED_4GBPS = 4,
416 BFA_PORT_SPEED_8GBPS = 8,
417 BFA_PORT_SPEED_10GBPS = 10,
418 BFA_PORT_SPEED_16GBPS = 16,
419 BFA_PORT_SPEED_AUTO =
420 (BFA_PORT_SPEED_1GBPS | BFA_PORT_SPEED_2GBPS |
421 BFA_PORT_SPEED_4GBPS | BFA_PORT_SPEED_8GBPS),
422};
423#define bfa_port_speed_t enum bfa_port_speed
424
425enum {
426 BFA_BOOT_BOOTLUN_MAX = 4, /* maximum boot lun per IOC */
427 BFA_PREBOOT_BOOTLUN_MAX = 8, /* maximum preboot lun per IOC */
428};
429
430#define BOOT_CFG_REV1 1
431#define BOOT_CFG_VLAN 1
432
433/*
434 * Boot options setting. Boot options setting determines from where
435 * to get the boot lun information
436 */
437enum bfa_boot_bootopt {
438 BFA_BOOT_AUTO_DISCOVER = 0, /* Boot from blun provided by fabric */
439 BFA_BOOT_STORED_BLUN = 1, /* Boot from bluns stored in flash */
440 BFA_BOOT_FIRST_LUN = 2, /* Boot from first discovered blun */
441 BFA_BOOT_PBC = 3, /* Boot from pbc configured blun */
442};
443
444#pragma pack(1)
445/*
446 * Boot lun information.
447 */
448struct bfa_boot_bootlun_s {
449 wwn_t pwwn; /* port wwn of target */
450 struct scsi_lun lun; /* 64-bit lun */
451};
452#pragma pack()
453
454/*
455 * BOOT boot configuraton
456 */
457struct bfa_boot_pbc_s {
458 u8 enable; /* enable/disable SAN boot */
459 u8 speed; /* boot speed settings */
460 u8 topology; /* boot topology setting */
461 u8 rsvd1;
462 u32 nbluns; /* number of boot luns */
463 struct bfa_boot_bootlun_s pblun[BFA_PREBOOT_BOOTLUN_MAX];
464};
465
466#endif /* __BFA_DEFS_H__ */
diff --git a/drivers/scsi/bfa/bfa_defs_fcs.h b/drivers/scsi/bfa/bfa_defs_fcs.h
new file mode 100644
index 000000000000..191d34a58b9c
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_defs_fcs.h
@@ -0,0 +1,457 @@
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_DEFS_FCS_H__
19#define __BFA_DEFS_FCS_H__
20
21#include "bfa_fc.h"
22#include "bfa_defs_svc.h"
23
24/*
25 * VF states
26 */
27enum bfa_vf_state {
28 BFA_VF_UNINIT = 0, /* fabric is not yet initialized */
29 BFA_VF_LINK_DOWN = 1, /* link is down */
30 BFA_VF_FLOGI = 2, /* flogi is in progress */
31 BFA_VF_AUTH = 3, /* authentication in progress */
32 BFA_VF_NOFABRIC = 4, /* fabric is not present */
33 BFA_VF_ONLINE = 5, /* login to fabric is complete */
34 BFA_VF_EVFP = 6, /* EVFP is in progress */
35 BFA_VF_ISOLATED = 7, /* port isolated due to vf_id mismatch */
36};
37
38/*
39 * VF statistics
40 */
41struct bfa_vf_stats_s {
42 u32 flogi_sent; /* Num FLOGIs sent */
43 u32 flogi_rsp_err; /* FLOGI response errors */
44 u32 flogi_acc_err; /* FLOGI accept errors */
45 u32 flogi_accepts; /* FLOGI accepts received */
46 u32 flogi_rejects; /* FLOGI rejects received */
47 u32 flogi_unknown_rsp; /* Unknown responses for FLOGI */
48 u32 flogi_alloc_wait; /* Allocation waits prior to sending FLOGI */
49 u32 flogi_rcvd; /* FLOGIs received */
50 u32 flogi_rejected; /* Incoming FLOGIs rejected */
51 u32 fabric_onlines; /* Internal fabric online notification sent
52 * to other modules */
53 u32 fabric_offlines; /* Internal fabric offline notification sent
54 * to other modules */
55 u32 resvd; /* padding for 64 bit alignment */
56};
57
58/*
59 * VF attributes returned in queries
60 */
61struct bfa_vf_attr_s {
62 enum bfa_vf_state state; /* VF state */
63 u32 rsvd;
64 wwn_t fabric_name; /* fabric name */
65};
66
67#define BFA_FCS_MAX_LPORTS 256
68#define BFA_FCS_FABRIC_IPADDR_SZ 16
69
70/*
71 * symbolic names for base port/virtual port
72 */
73#define BFA_SYMNAME_MAXLEN 128 /* 128 bytes */
74struct bfa_lport_symname_s {
75 char symname[BFA_SYMNAME_MAXLEN];
76};
77
78/*
79* Roles of FCS port:
80 * - FCP IM and FCP TM roles cannot be enabled together for a FCS port
81 * - Create multiple ports if both IM and TM functions required.
82 * - Atleast one role must be specified.
83 */
84enum bfa_lport_role {
85 BFA_LPORT_ROLE_FCP_IM = 0x01, /* FCP initiator role */
86 BFA_LPORT_ROLE_FCP_MAX = BFA_LPORT_ROLE_FCP_IM,
87};
88
89/*
90 * FCS port configuration.
91 */
92struct bfa_lport_cfg_s {
93 wwn_t pwwn; /* port wwn */
94 wwn_t nwwn; /* node wwn */
95 struct bfa_lport_symname_s sym_name; /* vm port symbolic name */
96 bfa_boolean_t preboot_vp; /* vport created from PBC */
97 enum bfa_lport_role roles; /* FCS port roles */
98 u8 tag[16]; /* opaque tag from application */
99};
100
101/*
102 * FCS port states
103 */
104enum bfa_lport_state {
105 BFA_LPORT_UNINIT = 0, /* PORT is not yet initialized */
106 BFA_LPORT_FDISC = 1, /* FDISC is in progress */
107 BFA_LPORT_ONLINE = 2, /* login to fabric is complete */
108 BFA_LPORT_OFFLINE = 3, /* No login to fabric */
109};
110
111/*
112 * FCS port type.
113 */
114enum bfa_lport_type {
115 BFA_LPORT_TYPE_PHYSICAL = 0,
116 BFA_LPORT_TYPE_VIRTUAL,
117};
118
119/*
120 * FCS port offline reason.
121 */
122enum bfa_lport_offline_reason {
123 BFA_LPORT_OFFLINE_UNKNOWN = 0,
124 BFA_LPORT_OFFLINE_LINKDOWN,
125 BFA_LPORT_OFFLINE_FAB_UNSUPPORTED, /* NPIV not supported by the
126 * fabric */
127 BFA_LPORT_OFFLINE_FAB_NORESOURCES,
128 BFA_LPORT_OFFLINE_FAB_LOGOUT,
129};
130
131/*
132 * FCS lport info.
133 */
134struct bfa_lport_info_s {
135 u8 port_type; /* bfa_lport_type_t : physical or
136 * virtual */
137 u8 port_state; /* one of bfa_lport_state values */
138 u8 offline_reason; /* one of bfa_lport_offline_reason_t
139 * values */
140 wwn_t port_wwn;
141 wwn_t node_wwn;
142
143 /*
144 * following 4 feilds are valid for Physical Ports only
145 */
146 u32 max_vports_supp; /* Max supported vports */
147 u32 num_vports_inuse; /* Num of in use vports */
148 u32 max_rports_supp; /* Max supported rports */
149 u32 num_rports_inuse; /* Num of doscovered rports */
150
151};
152
153/*
154 * FCS port statistics
155 */
156struct bfa_lport_stats_s {
157 u32 ns_plogi_sent;
158 u32 ns_plogi_rsp_err;
159 u32 ns_plogi_acc_err;
160 u32 ns_plogi_accepts;
161 u32 ns_rejects; /* NS command rejects */
162 u32 ns_plogi_unknown_rsp;
163 u32 ns_plogi_alloc_wait;
164
165 u32 ns_retries; /* NS command retries */
166 u32 ns_timeouts; /* NS command timeouts */
167
168 u32 ns_rspnid_sent;
169 u32 ns_rspnid_accepts;
170 u32 ns_rspnid_rsp_err;
171 u32 ns_rspnid_rejects;
172 u32 ns_rspnid_alloc_wait;
173
174 u32 ns_rftid_sent;
175 u32 ns_rftid_accepts;
176 u32 ns_rftid_rsp_err;
177 u32 ns_rftid_rejects;
178 u32 ns_rftid_alloc_wait;
179
180 u32 ns_rffid_sent;
181 u32 ns_rffid_accepts;
182 u32 ns_rffid_rsp_err;
183 u32 ns_rffid_rejects;
184 u32 ns_rffid_alloc_wait;
185
186 u32 ns_gidft_sent;
187 u32 ns_gidft_accepts;
188 u32 ns_gidft_rsp_err;
189 u32 ns_gidft_rejects;
190 u32 ns_gidft_unknown_rsp;
191 u32 ns_gidft_alloc_wait;
192
193 /*
194 * Mgmt Server stats
195 */
196 u32 ms_retries; /* MS command retries */
197 u32 ms_timeouts; /* MS command timeouts */
198 u32 ms_plogi_sent;
199 u32 ms_plogi_rsp_err;
200 u32 ms_plogi_acc_err;
201 u32 ms_plogi_accepts;
202 u32 ms_rejects; /* MS command rejects */
203 u32 ms_plogi_unknown_rsp;
204 u32 ms_plogi_alloc_wait;
205
206 u32 num_rscn; /* Num of RSCN received */
207 u32 num_portid_rscn;/* Num portid format RSCN
208 * received */
209
210 u32 uf_recvs; /* Unsolicited recv frames */
211 u32 uf_recv_drops; /* Dropped received frames */
212
213 u32 plogi_rcvd; /* Received plogi */
214 u32 prli_rcvd; /* Received prli */
215 u32 adisc_rcvd; /* Received adisc */
216 u32 prlo_rcvd; /* Received prlo */
217 u32 logo_rcvd; /* Received logo */
218 u32 rpsc_rcvd; /* Received rpsc */
219 u32 un_handled_els_rcvd; /* Received unhandled ELS */
220 u32 rport_plogi_timeouts; /* Rport plogi retry timeout count */
221 u32 rport_del_max_plogi_retry; /* Deleted rport
222 * (max retry of plogi) */
223};
224
225/*
226 * BFA port attribute returned in queries
227 */
228struct bfa_lport_attr_s {
229 enum bfa_lport_state state; /* port state */
230 u32 pid; /* port ID */
231 struct bfa_lport_cfg_s port_cfg; /* port configuration */
232 enum bfa_port_type port_type; /* current topology */
233 u32 loopback; /* cable is externally looped back */
234 wwn_t fabric_name; /* attached switch's nwwn */
235 u8 fabric_ip_addr[BFA_FCS_FABRIC_IPADDR_SZ]; /* attached
236 * fabric's ip addr */
237 mac_t fpma_mac; /* Lport's FPMA Mac address */
238 u16 authfail; /* auth failed state */
239};
240
241
242/*
243 * VPORT states
244 */
245enum bfa_vport_state {
246 BFA_FCS_VPORT_UNINIT = 0,
247 BFA_FCS_VPORT_CREATED = 1,
248 BFA_FCS_VPORT_OFFLINE = 1,
249 BFA_FCS_VPORT_FDISC_SEND = 2,
250 BFA_FCS_VPORT_FDISC = 3,
251 BFA_FCS_VPORT_FDISC_RETRY = 4,
252 BFA_FCS_VPORT_ONLINE = 5,
253 BFA_FCS_VPORT_DELETING = 6,
254 BFA_FCS_VPORT_CLEANUP = 6,
255 BFA_FCS_VPORT_LOGO_SEND = 7,
256 BFA_FCS_VPORT_LOGO = 8,
257 BFA_FCS_VPORT_ERROR = 9,
258 BFA_FCS_VPORT_MAX_STATE,
259};
260
261/*
262 * vport statistics
263 */
264struct bfa_vport_stats_s {
265 struct bfa_lport_stats_s port_stats; /* base class (port) stats */
266 /*
267 * TODO - remove
268 */
269
270 u32 fdisc_sent; /* num fdisc sent */
271 u32 fdisc_accepts; /* fdisc accepts */
272 u32 fdisc_retries; /* fdisc retries */
273 u32 fdisc_timeouts; /* fdisc timeouts */
274 u32 fdisc_rsp_err; /* fdisc response error */
275 u32 fdisc_acc_bad; /* bad fdisc accepts */
276 u32 fdisc_rejects; /* fdisc rejects */
277 u32 fdisc_unknown_rsp;
278 /*
279 *!< fdisc rsp unknown error
280 */
281 u32 fdisc_alloc_wait;/* fdisc req (fcxp)alloc wait */
282
283 u32 logo_alloc_wait;/* logo req (fcxp) alloc wait */
284 u32 logo_sent; /* logo sent */
285 u32 logo_accepts; /* logo accepts */
286 u32 logo_rejects; /* logo rejects */
287 u32 logo_rsp_err; /* logo rsp errors */
288 u32 logo_unknown_rsp;
289 /* logo rsp unknown errors */
290
291 u32 fab_no_npiv; /* fabric does not support npiv */
292
293 u32 fab_offline; /* offline events from fab SM */
294 u32 fab_online; /* online events from fab SM */
295 u32 fab_cleanup; /* cleanup request from fab SM */
296 u32 rsvd;
297};
298
299/*
300 * BFA vport attribute returned in queries
301 */
302struct bfa_vport_attr_s {
303 struct bfa_lport_attr_s port_attr; /* base class (port) attributes */
304 enum bfa_vport_state vport_state; /* vport state */
305 u32 rsvd;
306};
307
308/*
309 * FCS remote port states
310 */
311enum bfa_rport_state {
312 BFA_RPORT_UNINIT = 0, /* PORT is not yet initialized */
313 BFA_RPORT_OFFLINE = 1, /* rport is offline */
314 BFA_RPORT_PLOGI = 2, /* PLOGI to rport is in progress */
315 BFA_RPORT_ONLINE = 3, /* login to rport is complete */
316 BFA_RPORT_PLOGI_RETRY = 4, /* retrying login to rport */
317 BFA_RPORT_NSQUERY = 5, /* nameserver query */
318 BFA_RPORT_ADISC = 6, /* ADISC authentication */
319 BFA_RPORT_LOGO = 7, /* logging out with rport */
320 BFA_RPORT_LOGORCV = 8, /* handling LOGO from rport */
321 BFA_RPORT_NSDISC = 9, /* re-discover rport */
322};
323
324/*
325 * Rport Scsi Function : Initiator/Target.
326 */
327enum bfa_rport_function {
328 BFA_RPORT_INITIATOR = 0x01, /* SCSI Initiator */
329 BFA_RPORT_TARGET = 0x02, /* SCSI Target */
330};
331
332/*
333 * port/node symbolic names for rport
334 */
335#define BFA_RPORT_SYMNAME_MAXLEN 255
336struct bfa_rport_symname_s {
337 char symname[BFA_RPORT_SYMNAME_MAXLEN];
338};
339
340/*
341 * FCS remote port statistics
342 */
343struct bfa_rport_stats_s {
344 u32 offlines; /* remote port offline count */
345 u32 onlines; /* remote port online count */
346 u32 rscns; /* RSCN affecting rport */
347 u32 plogis; /* plogis sent */
348 u32 plogi_accs; /* plogi accepts */
349 u32 plogi_timeouts; /* plogi timeouts */
350 u32 plogi_rejects; /* rcvd plogi rejects */
351 u32 plogi_failed; /* local failure */
352 u32 plogi_rcvd; /* plogis rcvd */
353 u32 prli_rcvd; /* inbound PRLIs */
354 u32 adisc_rcvd; /* ADISCs received */
355 u32 adisc_rejects; /* recvd ADISC rejects */
356 u32 adisc_sent; /* ADISC requests sent */
357 u32 adisc_accs; /* ADISC accepted by rport */
358 u32 adisc_failed; /* ADISC failed (no response) */
359 u32 adisc_rejected; /* ADISC rejected by us */
360 u32 logos; /* logos sent */
361 u32 logo_accs; /* LOGO accepts from rport */
362 u32 logo_failed; /* LOGO failures */
363 u32 logo_rejected; /* LOGO rejects from rport */
364 u32 logo_rcvd; /* LOGO from remote port */
365
366 u32 rpsc_rcvd; /* RPSC received */
367 u32 rpsc_rejects; /* recvd RPSC rejects */
368 u32 rpsc_sent; /* RPSC requests sent */
369 u32 rpsc_accs; /* RPSC accepted by rport */
370 u32 rpsc_failed; /* RPSC failed (no response) */
371 u32 rpsc_rejected; /* RPSC rejected by us */
372
373 u32 rjt_insuff_res; /* LS RJT with insuff resources */
374 struct bfa_rport_hal_stats_s hal_stats; /* BFA rport stats */
375};
376
377/*
378 * FCS remote port attributes returned in queries
379 */
380struct bfa_rport_attr_s {
381 wwn_t nwwn; /* node wwn */
382 wwn_t pwwn; /* port wwn */
383 enum fc_cos cos_supported; /* supported class of services */
384 u32 pid; /* port ID */
385 u32 df_sz; /* Max payload size */
386 enum bfa_rport_state state; /* Rport State machine state */
387 enum fc_cos fc_cos; /* FC classes of services */
388 bfa_boolean_t cisc; /* CISC capable device */
389 struct bfa_rport_symname_s symname; /* Symbolic Name */
390 enum bfa_rport_function scsi_function; /* Initiator/Target */
391 struct bfa_rport_qos_attr_s qos_attr; /* qos attributes */
392 enum bfa_port_speed curr_speed; /* operating speed got from
393 * RPSC ELS. UNKNOWN, if RPSC
394 * is not supported */
395 bfa_boolean_t trl_enforced; /* TRL enforced ? TRUE/FALSE */
396 enum bfa_port_speed assigned_speed; /* Speed assigned by the user.
397 * will be used if RPSC is not
398 * supported by the rport */
399};
400
401struct bfa_rport_remote_link_stats_s {
402 u32 lfc; /* Link Failure Count */
403 u32 lsyc; /* Loss of Synchronization Count */
404 u32 lsic; /* Loss of Signal Count */
405 u32 pspec; /* Primitive Sequence Protocol Error Count */
406 u32 itwc; /* Invalid Transmission Word Count */
407 u32 icc; /* Invalid CRC Count */
408};
409
410
411#define BFA_MAX_IO_INDEX 7
412#define BFA_NO_IO_INDEX 9
413
414/*
415 * FCS itnim states
416 */
417enum bfa_itnim_state {
418 BFA_ITNIM_OFFLINE = 0, /* offline */
419 BFA_ITNIM_PRLI_SEND = 1, /* prli send */
420 BFA_ITNIM_PRLI_SENT = 2, /* prli sent */
421 BFA_ITNIM_PRLI_RETRY = 3, /* prli retry */
422 BFA_ITNIM_HCB_ONLINE = 4, /* online callback */
423 BFA_ITNIM_ONLINE = 5, /* online */
424 BFA_ITNIM_HCB_OFFLINE = 6, /* offline callback */
425 BFA_ITNIM_INITIATIOR = 7, /* initiator */
426};
427
428/*
429 * FCS remote port statistics
430 */
431struct bfa_itnim_stats_s {
432 u32 onlines; /* num rport online */
433 u32 offlines; /* num rport offline */
434 u32 prli_sent; /* num prli sent out */
435 u32 fcxp_alloc_wait;/* num fcxp alloc waits */
436 u32 prli_rsp_err; /* num prli rsp errors */
437 u32 prli_rsp_acc; /* num prli rsp accepts */
438 u32 initiator; /* rport is an initiator */
439 u32 prli_rsp_parse_err; /* prli rsp parsing errors */
440 u32 prli_rsp_rjt; /* num prli rsp rejects */
441 u32 timeout; /* num timeouts detected */
442 u32 sler; /* num sler notification from BFA */
443 u32 rsvd; /* padding for 64 bit alignment */
444};
445
446/*
447 * FCS itnim attributes returned in queries
448 */
449struct bfa_itnim_attr_s {
450 enum bfa_itnim_state state; /* FCS itnim state */
451 u8 retry; /* data retransmision support */
452 u8 task_retry_id; /* task retry ident support */
453 u8 rec_support; /* REC supported */
454 u8 conf_comp; /* confirmed completion supp */
455};
456
457#endif /* __BFA_DEFS_FCS_H__ */
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
new file mode 100644
index 000000000000..207f598877c7
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -0,0 +1,1081 @@
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_DEFS_SVC_H__
19#define __BFA_DEFS_SVC_H__
20
21#include "bfa_defs.h"
22#include "bfa_fc.h"
23#include "bfi.h"
24
25#define BFA_IOCFC_INTR_DELAY 1125
26#define BFA_IOCFC_INTR_LATENCY 225
27#define BFA_IOCFCOE_INTR_DELAY 25
28#define BFA_IOCFCOE_INTR_LATENCY 5
29
30/*
31 * Interrupt coalescing configuration.
32 */
33#pragma pack(1)
34struct bfa_iocfc_intr_attr_s {
35 u8 coalesce; /* enable/disable coalescing */
36 u8 rsvd[3];
37 __be16 latency; /* latency in microseconds */
38 __be16 delay; /* delay in microseconds */
39};
40
41/*
42 * IOC firmware configuraton
43 */
44struct bfa_iocfc_fwcfg_s {
45 u16 num_fabrics; /* number of fabrics */
46 u16 num_lports; /* number of local lports */
47 u16 num_rports; /* number of remote ports */
48 u16 num_ioim_reqs; /* number of IO reqs */
49 u16 num_tskim_reqs; /* task management requests */
50 u16 num_iotm_reqs; /* number of TM IO reqs */
51 u16 num_tsktm_reqs; /* TM task management requests*/
52 u16 num_fcxp_reqs; /* unassisted FC exchanges */
53 u16 num_uf_bufs; /* unsolicited recv buffers */
54 u8 num_cqs;
55 u8 fw_tick_res; /* FW clock resolution in ms */
56 u8 rsvd[4];
57};
58#pragma pack()
59
60struct bfa_iocfc_drvcfg_s {
61 u16 num_reqq_elems; /* number of req queue elements */
62 u16 num_rspq_elems; /* number of rsp queue elements */
63 u16 num_sgpgs; /* number of total SG pages */
64 u16 num_sboot_tgts; /* number of SAN boot targets */
65 u16 num_sboot_luns; /* number of SAN boot luns */
66 u16 ioc_recover; /* IOC recovery mode */
67 u16 min_cfg; /* minimum configuration */
68 u16 path_tov; /* device path timeout */
69 bfa_boolean_t delay_comp; /* delay completion of
70 failed inflight IOs */
71 u32 rsvd;
72};
73
74/*
75 * IOC configuration
76 */
77struct bfa_iocfc_cfg_s {
78 struct bfa_iocfc_fwcfg_s fwcfg; /* firmware side config */
79 struct bfa_iocfc_drvcfg_s drvcfg; /* driver side config */
80};
81
82/*
83 * IOC firmware IO stats
84 */
85struct bfa_fw_io_stats_s {
86 u32 host_abort; /* IO aborted by host driver*/
87 u32 host_cleanup; /* IO clean up by host driver */
88
89 u32 fw_io_timeout; /* IOs timedout */
90 u32 fw_frm_parse; /* frame parsed by f/w */
91 u32 fw_frm_data; /* fcp_data frame parsed by f/w */
92 u32 fw_frm_rsp; /* fcp_rsp frame parsed by f/w */
93 u32 fw_frm_xfer_rdy; /* xfer_rdy frame parsed by f/w */
94 u32 fw_frm_bls_acc; /* BLS ACC frame parsed by f/w */
95 u32 fw_frm_tgt_abort; /* target ABTS parsed by f/w */
96 u32 fw_frm_unknown; /* unknown parsed by f/w */
97 u32 fw_data_dma; /* f/w DMA'ed the data frame */
98 u32 fw_frm_drop; /* f/w drop the frame */
99
100 u32 rec_timeout; /* FW rec timed out */
101 u32 error_rec; /* FW sending rec on
102 * an error condition*/
103 u32 wait_for_si; /* FW wait for SI */
104 u32 rec_rsp_inval; /* REC rsp invalid */
105 u32 seqr_io_abort; /* target does not know cmd so abort */
106 u32 seqr_io_retry; /* SEQR failed so retry IO */
107
108 u32 itn_cisc_upd_rsp; /* ITN cisc updated on fcp_rsp */
109 u32 itn_cisc_upd_data; /* ITN cisc updated on fcp_data */
110 u32 itn_cisc_upd_xfer_rdy; /* ITN cisc updated on fcp_data */
111
112 u32 fcp_data_lost; /* fcp data lost */
113
114 u32 ro_set_in_xfer_rdy; /* Target set RO in Xfer_rdy frame */
115 u32 xfer_rdy_ooo_err; /* Out of order Xfer_rdy received */
116 u32 xfer_rdy_unknown_err; /* unknown error in xfer_rdy frame */
117
118 u32 io_abort_timeout; /* ABTS timedout */
119 u32 sler_initiated; /* SLER initiated */
120
121 u32 unexp_fcp_rsp; /* fcp response in wrong state */
122
123 u32 fcp_rsp_under_run; /* fcp rsp IO underrun */
124 u32 fcp_rsp_under_run_wr; /* fcp rsp IO underrun for write */
125 u32 fcp_rsp_under_run_err; /* fcp rsp IO underrun error */
126 u32 fcp_rsp_resid_inval; /* invalid residue */
127 u32 fcp_rsp_over_run; /* fcp rsp IO overrun */
128 u32 fcp_rsp_over_run_err; /* fcp rsp IO overrun error */
129 u32 fcp_rsp_proto_err; /* protocol error in fcp rsp */
130 u32 fcp_rsp_sense_err; /* error in sense info in fcp rsp */
131 u32 fcp_conf_req; /* FCP conf requested */
132
133 u32 tgt_aborted_io; /* target initiated abort */
134
135 u32 ioh_edtov_timeout_event;/* IOH edtov timer popped */
136 u32 ioh_fcp_rsp_excp_event; /* IOH FCP_RSP exception */
137 u32 ioh_fcp_conf_event; /* IOH FCP_CONF */
138 u32 ioh_mult_frm_rsp_event; /* IOH multi_frame FCP_RSP */
139 u32 ioh_hit_class2_event; /* IOH hit class2 */
140 u32 ioh_miss_other_event; /* IOH miss other */
141 u32 ioh_seq_cnt_err_event; /* IOH seq cnt error */
142 u32 ioh_len_err_event; /* IOH len error - fcp_dl !=
143 * bytes xfered */
144 u32 ioh_seq_len_err_event; /* IOH seq len error */
145 u32 ioh_data_oor_event; /* Data out of range */
146 u32 ioh_ro_ooo_event; /* Relative offset out of range */
147 u32 ioh_cpu_owned_event; /* IOH hit -iost owned by f/w */
148 u32 ioh_unexp_frame_event; /* unexpected frame received
149 * count */
150 u32 ioh_err_int; /* IOH error int during data-phase
151 * for scsi write
152 */
153};
154
155/*
156 * IOC port firmware stats
157 */
158
159struct bfa_fw_port_fpg_stats_s {
160 u32 intr_evt;
161 u32 intr;
162 u32 intr_excess;
163 u32 intr_cause0;
164 u32 intr_other;
165 u32 intr_other_ign;
166 u32 sig_lost;
167 u32 sig_regained;
168 u32 sync_lost;
169 u32 sync_to;
170 u32 sync_regained;
171 u32 div2_overflow;
172 u32 div2_underflow;
173 u32 efifo_overflow;
174 u32 efifo_underflow;
175 u32 idle_rx;
176 u32 lrr_rx;
177 u32 lr_rx;
178 u32 ols_rx;
179 u32 nos_rx;
180 u32 lip_rx;
181 u32 arbf0_rx;
182 u32 arb_rx;
183 u32 mrk_rx;
184 u32 const_mrk_rx;
185 u32 prim_unknown;
186};
187
188
189struct bfa_fw_port_lksm_stats_s {
190 u32 hwsm_success; /* hwsm state machine success */
191 u32 hwsm_fails; /* hwsm fails */
192 u32 hwsm_wdtov; /* hwsm timed out */
193 u32 swsm_success; /* swsm success */
194 u32 swsm_fails; /* swsm fails */
195 u32 swsm_wdtov; /* swsm timed out */
196 u32 busybufs; /* link init failed due to busybuf */
197 u32 buf_waits; /* bufwait state entries */
198 u32 link_fails; /* link failures */
199 u32 psp_errors; /* primitive sequence protocol errors */
200 u32 lr_unexp; /* No. of times LR rx-ed unexpectedly */
201 u32 lrr_unexp; /* No. of times LRR rx-ed unexpectedly */
202 u32 lr_tx; /* No. of times LR tx started */
203 u32 lrr_tx; /* No. of times LRR tx started */
204 u32 ols_tx; /* No. of times OLS tx started */
205 u32 nos_tx; /* No. of times NOS tx started */
206 u32 hwsm_lrr_rx; /* No. of times LRR rx-ed by HWSM */
207 u32 hwsm_lr_rx; /* No. of times LR rx-ed by HWSM */
208};
209
210struct bfa_fw_port_snsm_stats_s {
211 u32 hwsm_success; /* Successful hwsm terminations */
212 u32 hwsm_fails; /* hwsm fail count */
213 u32 hwsm_wdtov; /* hwsm timed out */
214 u32 swsm_success; /* swsm success */
215 u32 swsm_wdtov; /* swsm timed out */
216 u32 error_resets; /* error resets initiated by upsm */
217 u32 sync_lost; /* Sync loss count */
218 u32 sig_lost; /* Signal loss count */
219};
220
221struct bfa_fw_port_physm_stats_s {
222 u32 module_inserts; /* Module insert count */
223 u32 module_xtracts; /* Module extracts count */
224 u32 module_invalids; /* Invalid module inserted count */
225 u32 module_read_ign; /* Module validation status ignored */
226 u32 laser_faults; /* Laser fault count */
227 u32 rsvd;
228};
229
230struct bfa_fw_fip_stats_s {
231 u32 vlan_req; /* vlan discovery requests */
232 u32 vlan_notify; /* vlan notifications */
233 u32 vlan_err; /* vlan response error */
234 u32 vlan_timeouts; /* vlan disvoery timeouts */
235 u32 vlan_invalids; /* invalid vlan in discovery advert. */
236 u32 disc_req; /* Discovery solicit requests */
237 u32 disc_rsp; /* Discovery solicit response */
238 u32 disc_err; /* Discovery advt. parse errors */
239 u32 disc_unsol; /* Discovery unsolicited */
240 u32 disc_timeouts; /* Discovery timeouts */
241 u32 disc_fcf_unavail; /* Discovery FCF Not Avail. */
242 u32 linksvc_unsupp; /* Unsupported link service req */
243 u32 linksvc_err; /* Parse error in link service req */
244 u32 logo_req; /* FIP logos received */
245 u32 clrvlink_req; /* Clear virtual link req */
246 u32 op_unsupp; /* Unsupported FIP operation */
247 u32 untagged; /* Untagged frames (ignored) */
248 u32 invalid_version; /* Invalid FIP version */
249};
250
251struct bfa_fw_lps_stats_s {
252 u32 mac_invalids; /* Invalid mac assigned */
253 u32 rsvd;
254};
255
256struct bfa_fw_fcoe_stats_s {
257 u32 cee_linkups; /* CEE link up count */
258 u32 cee_linkdns; /* CEE link down count */
259 u32 fip_linkups; /* FIP link up count */
260 u32 fip_linkdns; /* FIP link up count */
261 u32 fip_fails; /* FIP fail count */
262 u32 mac_invalids; /* Invalid mac assigned */
263};
264
265/*
266 * IOC firmware FCoE port stats
267 */
268struct bfa_fw_fcoe_port_stats_s {
269 struct bfa_fw_fcoe_stats_s fcoe_stats;
270 struct bfa_fw_fip_stats_s fip_stats;
271};
272
273/*
274 * IOC firmware FC uport stats
275 */
276struct bfa_fw_fc_uport_stats_s {
277 struct bfa_fw_port_snsm_stats_s snsm_stats;
278 struct bfa_fw_port_lksm_stats_s lksm_stats;
279};
280
281/*
282 * IOC firmware FC port stats
283 */
284union bfa_fw_fc_port_stats_s {
285 struct bfa_fw_fc_uport_stats_s fc_stats;
286 struct bfa_fw_fcoe_port_stats_s fcoe_stats;
287};
288
289/*
290 * IOC firmware port stats
291 */
292struct bfa_fw_port_stats_s {
293 struct bfa_fw_port_fpg_stats_s fpg_stats;
294 struct bfa_fw_port_physm_stats_s physm_stats;
295 union bfa_fw_fc_port_stats_s fc_port;
296};
297
298/*
299 * fcxchg module statistics
300 */
301struct bfa_fw_fcxchg_stats_s {
302 u32 ua_tag_inv;
303 u32 ua_state_inv;
304};
305
306struct bfa_fw_lpsm_stats_s {
307 u32 cls_rx;
308 u32 cls_tx;
309};
310
311/*
312 * Trunk statistics
313 */
314struct bfa_fw_trunk_stats_s {
315 u32 emt_recvd; /* Trunk EMT received */
316 u32 emt_accepted; /* Trunk EMT Accepted */
317 u32 emt_rejected; /* Trunk EMT rejected */
318 u32 etp_recvd; /* Trunk ETP received */
319 u32 etp_accepted; /* Trunk ETP Accepted */
320 u32 etp_rejected; /* Trunk ETP rejected */
321 u32 lr_recvd; /* Trunk LR received */
322 u32 rsvd; /* padding for 64 bit alignment */
323};
324
325struct bfa_fw_advsm_stats_s {
326 u32 flogi_sent; /* Flogi sent */
327 u32 flogi_acc_recvd; /* Flogi Acc received */
328 u32 flogi_rjt_recvd; /* Flogi rejects received */
329 u32 flogi_retries; /* Flogi retries */
330
331 u32 elp_recvd; /* ELP received */
332 u32 elp_accepted; /* ELP Accepted */
333 u32 elp_rejected; /* ELP rejected */
334 u32 elp_dropped; /* ELP dropped */
335};
336
337/*
338 * IOCFC firmware stats
339 */
340struct bfa_fw_iocfc_stats_s {
341 u32 cfg_reqs; /* cfg request */
342 u32 updq_reqs; /* update queue request */
343 u32 ic_reqs; /* interrupt coalesce reqs */
344 u32 unknown_reqs;
345 u32 set_intr_reqs; /* set interrupt reqs */
346};
347
348/*
349 * IOC attributes returned in queries
350 */
351struct bfa_iocfc_attr_s {
352 struct bfa_iocfc_cfg_s config; /* IOCFC config */
353 struct bfa_iocfc_intr_attr_s intr_attr; /* interrupt attr */
354};
355
356/*
357 * Eth_sndrcv mod stats
358 */
359struct bfa_fw_eth_sndrcv_stats_s {
360 u32 crc_err;
361 u32 rsvd; /* 64bit align */
362};
363
364/*
365 * CT MAC mod stats
366 */
367struct bfa_fw_mac_mod_stats_s {
368 u32 mac_on; /* MAC got turned-on */
369 u32 link_up; /* link-up */
370 u32 signal_off; /* lost signal */
371 u32 dfe_on; /* DFE on */
372 u32 mac_reset; /* # of MAC reset to bring lnk up */
373 u32 pcs_reset; /* # of PCS reset to bring lnk up */
374 u32 loopback; /* MAC got into serdes loopback */
375 u32 lb_mac_reset;
376 /* # of MAC reset to bring link up in loopback */
377 u32 lb_pcs_reset;
378 /* # of PCS reset to bring link up in loopback */
379 u32 rsvd; /* 64bit align */
380};
381
382/*
383 * CT MOD stats
384 */
385struct bfa_fw_ct_mod_stats_s {
386 u32 rxa_rds_undrun; /* RxA RDS underrun */
387 u32 rad_bpc_ovfl; /* RAD BPC overflow */
388 u32 rad_rlb_bpc_ovfl; /* RAD RLB BPC overflow */
389 u32 bpc_fcs_err; /* BPC FCS_ERR */
390 u32 txa_tso_hdr; /* TxA TSO header too long */
391 u32 rsvd; /* 64bit align */
392};
393
394/*
395 * IOC firmware stats
396 */
397struct bfa_fw_stats_s {
398 struct bfa_fw_ioc_stats_s ioc_stats;
399 struct bfa_fw_iocfc_stats_s iocfc_stats;
400 struct bfa_fw_io_stats_s io_stats;
401 struct bfa_fw_port_stats_s port_stats;
402 struct bfa_fw_fcxchg_stats_s fcxchg_stats;
403 struct bfa_fw_lpsm_stats_s lpsm_stats;
404 struct bfa_fw_lps_stats_s lps_stats;
405 struct bfa_fw_trunk_stats_s trunk_stats;
406 struct bfa_fw_advsm_stats_s advsm_stats;
407 struct bfa_fw_mac_mod_stats_s macmod_stats;
408 struct bfa_fw_ct_mod_stats_s ctmod_stats;
409 struct bfa_fw_eth_sndrcv_stats_s ethsndrcv_stats;
410};
411
412#define BFA_IOCFC_PATHTOV_MAX 60
413#define BFA_IOCFC_QDEPTH_MAX 2000
414
415/*
416 * QoS states
417 */
418enum bfa_qos_state {
419 BFA_QOS_ONLINE = 1, /* QoS is online */
420 BFA_QOS_OFFLINE = 2, /* QoS is offline */
421};
422
423/*
424 * QoS Priority levels.
425 */
426enum bfa_qos_priority {
427 BFA_QOS_UNKNOWN = 0,
428 BFA_QOS_HIGH = 1, /* QoS Priority Level High */
429 BFA_QOS_MED = 2, /* QoS Priority Level Medium */
430 BFA_QOS_LOW = 3, /* QoS Priority Level Low */
431};
432
433/*
434 * QoS bandwidth allocation for each priority level
435 */
436enum bfa_qos_bw_alloc {
437 BFA_QOS_BW_HIGH = 60, /* bandwidth allocation for High */
438 BFA_QOS_BW_MED = 30, /* bandwidth allocation for Medium */
439 BFA_QOS_BW_LOW = 10, /* bandwidth allocation for Low */
440};
441#pragma pack(1)
442/*
443 * QoS attribute returned in QoS Query
444 */
445struct bfa_qos_attr_s {
446 u8 state; /* QoS current state */
447 u8 rsvd[3];
448 u32 total_bb_cr; /* Total BB Credits */
449};
450
451/*
452 * These fields should be displayed only from the CLI.
453 * There will be a separate BFAL API (get_qos_vc_attr ?)
454 * to retrieve this.
455 *
456 */
457#define BFA_QOS_MAX_VC 16
458
459struct bfa_qos_vc_info_s {
460 u8 vc_credit;
461 u8 borrow_credit;
462 u8 priority;
463 u8 resvd;
464};
465
466struct bfa_qos_vc_attr_s {
467 u16 total_vc_count; /* Total VC Count */
468 u16 shared_credit;
469 u32 elp_opmode_flags;
470 struct bfa_qos_vc_info_s vc_info[BFA_QOS_MAX_VC]; /* as many as
471 * total_vc_count */
472};
473
474/*
475 * QoS statistics
476 */
477struct bfa_qos_stats_s {
478 u32 flogi_sent; /* QoS Flogi sent */
479 u32 flogi_acc_recvd; /* QoS Flogi Acc received */
480 u32 flogi_rjt_recvd; /* QoS Flogi rejects received */
481 u32 flogi_retries; /* QoS Flogi retries */
482
483 u32 elp_recvd; /* QoS ELP received */
484 u32 elp_accepted; /* QoS ELP Accepted */
485 u32 elp_rejected; /* QoS ELP rejected */
486 u32 elp_dropped; /* QoS ELP dropped */
487
488 u32 qos_rscn_recvd; /* QoS RSCN received */
489 u32 rsvd; /* padding for 64 bit alignment */
490};
491
492/*
493 * FCoE statistics
494 */
495struct bfa_fcoe_stats_s {
496 u64 secs_reset; /* Seconds since stats reset */
497 u64 cee_linkups; /* CEE link up */
498 u64 cee_linkdns; /* CEE link down */
499 u64 fip_linkups; /* FIP link up */
500 u64 fip_linkdns; /* FIP link down */
501 u64 fip_fails; /* FIP failures */
502 u64 mac_invalids; /* Invalid mac assignments */
503 u64 vlan_req; /* Vlan requests */
504 u64 vlan_notify; /* Vlan notifications */
505 u64 vlan_err; /* Vlan notification errors */
506 u64 vlan_timeouts; /* Vlan request timeouts */
507 u64 vlan_invalids; /* Vlan invalids */
508 u64 disc_req; /* Discovery requests */
509 u64 disc_rsp; /* Discovery responses */
510 u64 disc_err; /* Discovery error frames */
511 u64 disc_unsol; /* Discovery unsolicited */
512 u64 disc_timeouts; /* Discovery timeouts */
513 u64 disc_fcf_unavail; /* Discovery FCF not avail */
514 u64 linksvc_unsupp; /* FIP link service req unsupp. */
515 u64 linksvc_err; /* FIP link service req errors */
516 u64 logo_req; /* FIP logos received */
517 u64 clrvlink_req; /* Clear virtual link requests */
518 u64 op_unsupp; /* FIP operation unsupp. */
519 u64 untagged; /* FIP untagged frames */
520 u64 txf_ucast; /* Tx FCoE unicast frames */
521 u64 txf_ucast_vlan; /* Tx FCoE unicast vlan frames */
522 u64 txf_ucast_octets; /* Tx FCoE unicast octets */
523 u64 txf_mcast; /* Tx FCoE multicast frames */
524 u64 txf_mcast_vlan; /* Tx FCoE multicast vlan frames */
525 u64 txf_mcast_octets; /* Tx FCoE multicast octets */
526 u64 txf_bcast; /* Tx FCoE broadcast frames */
527 u64 txf_bcast_vlan; /* Tx FCoE broadcast vlan frames */
528 u64 txf_bcast_octets; /* Tx FCoE broadcast octets */
529 u64 txf_timeout; /* Tx timeouts */
530 u64 txf_parity_errors; /* Transmit parity err */
531 u64 txf_fid_parity_errors; /* Transmit FID parity err */
532 u64 rxf_ucast_octets; /* Rx FCoE unicast octets */
533 u64 rxf_ucast; /* Rx FCoE unicast frames */
534 u64 rxf_ucast_vlan; /* Rx FCoE unicast vlan frames */
535 u64 rxf_mcast_octets; /* Rx FCoE multicast octets */
536 u64 rxf_mcast; /* Rx FCoE multicast frames */
537 u64 rxf_mcast_vlan; /* Rx FCoE multicast vlan frames */
538 u64 rxf_bcast_octets; /* Rx FCoE broadcast octets */
539 u64 rxf_bcast; /* Rx FCoE broadcast frames */
540 u64 rxf_bcast_vlan; /* Rx FCoE broadcast vlan frames */
541};
542
543/*
544 * QoS or FCoE stats (fcport stats excluding physical FC port stats)
545 */
546union bfa_fcport_stats_u {
547 struct bfa_qos_stats_s fcqos;
548 struct bfa_fcoe_stats_s fcoe;
549};
550#pragma pack()
551
552struct bfa_fcpim_del_itn_stats_s {
553 u32 del_itn_iocomp_aborted; /* Aborted IO requests */
554 u32 del_itn_iocomp_timedout; /* IO timeouts */
555 u32 del_itn_iocom_sqer_needed; /* IO retry for SQ error recovery */
556 u32 del_itn_iocom_res_free; /* Delayed freeing of IO resources */
557 u32 del_itn_iocom_hostabrts; /* Host IO abort requests */
558 u32 del_itn_total_ios; /* Total IO count */
559 u32 del_io_iocdowns; /* IO cleaned-up due to IOC down */
560 u32 del_tm_iocdowns; /* TM cleaned-up due to IOC down */
561};
562
563struct bfa_itnim_iostats_s {
564
565 u32 total_ios; /* Total IO Requests */
566 u32 input_reqs; /* Data in-bound requests */
567 u32 output_reqs; /* Data out-bound requests */
568 u32 io_comps; /* Total IO Completions */
569 u32 wr_throughput; /* Write data transferred in bytes */
570 u32 rd_throughput; /* Read data transferred in bytes */
571
572 u32 iocomp_ok; /* Slowpath IO completions */
573 u32 iocomp_underrun; /* IO underrun */
574 u32 iocomp_overrun; /* IO overrun */
575 u32 qwait; /* IO Request-Q wait */
576 u32 qresumes; /* IO Request-Q wait done */
577 u32 no_iotags; /* No free IO tag */
578 u32 iocomp_timedout; /* IO timeouts */
579 u32 iocom_nexus_abort; /* IO failure due to target offline */
580 u32 iocom_proto_err; /* IO protocol errors */
581 u32 iocom_dif_err; /* IO SBC-3 protection errors */
582
583 u32 iocom_sqer_needed; /* fcp-2 error recovery failed */
584 u32 iocom_res_free; /* Delayed freeing of IO tag */
585
586
587 u32 io_aborts; /* Host IO abort requests */
588 u32 iocom_hostabrts; /* Host IO abort completions */
589 u32 io_cleanups; /* IO clean-up requests */
590 u32 path_tov_expired; /* IO path tov expired */
591 u32 iocomp_aborted; /* IO abort completions */
592 u32 io_iocdowns; /* IO cleaned-up due to IOC down */
593 u32 iocom_utags; /* IO comp with unknown tags */
594
595 u32 io_tmaborts; /* Abort request due to TM command */
596 u32 tm_io_comps; /* Abort completion due to TM command */
597
598 u32 creates; /* IT Nexus create requests */
599 u32 fw_create; /* IT Nexus FW create requests */
600 u32 create_comps; /* IT Nexus FW create completions */
601 u32 onlines; /* IT Nexus onlines */
602 u32 offlines; /* IT Nexus offlines */
603 u32 fw_delete; /* IT Nexus FW delete requests */
604 u32 delete_comps; /* IT Nexus FW delete completions */
605 u32 deletes; /* IT Nexus delete requests */
606 u32 sler_events; /* SLER events */
607 u32 ioc_disabled; /* Num IOC disables */
608 u32 cleanup_comps; /* IT Nexus cleanup completions */
609
610 u32 tm_cmnds; /* TM Requests */
611 u32 tm_fw_rsps; /* TM Completions */
612 u32 tm_success; /* TM initiated IO cleanup success */
613 u32 tm_failures; /* TM initiated IO cleanup failure */
614 u32 no_tskims; /* No free TM tag */
615 u32 tm_qwait; /* TM Request-Q wait */
616 u32 tm_qresumes; /* TM Request-Q wait done */
617
618 u32 tm_iocdowns; /* TM cleaned-up due to IOC down */
619 u32 tm_cleanups; /* TM cleanup requests */
620 u32 tm_cleanup_comps; /* TM cleanup completions */
621};
622
623/* Modify char* port_stt[] in bfal_port.c if a new state was added */
624enum bfa_port_states {
625 BFA_PORT_ST_UNINIT = 1,
626 BFA_PORT_ST_ENABLING_QWAIT = 2,
627 BFA_PORT_ST_ENABLING = 3,
628 BFA_PORT_ST_LINKDOWN = 4,
629 BFA_PORT_ST_LINKUP = 5,
630 BFA_PORT_ST_DISABLING_QWAIT = 6,
631 BFA_PORT_ST_DISABLING = 7,
632 BFA_PORT_ST_DISABLED = 8,
633 BFA_PORT_ST_STOPPED = 9,
634 BFA_PORT_ST_IOCDOWN = 10,
635 BFA_PORT_ST_IOCDIS = 11,
636 BFA_PORT_ST_FWMISMATCH = 12,
637 BFA_PORT_ST_PREBOOT_DISABLED = 13,
638 BFA_PORT_ST_TOGGLING_QWAIT = 14,
639 BFA_PORT_ST_MAX_STATE,
640};
641
642/*
643 * Port operational type (in sync with SNIA port type).
644 */
645enum bfa_port_type {
646 BFA_PORT_TYPE_UNKNOWN = 1, /* port type is unknown */
647 BFA_PORT_TYPE_NPORT = 5, /* P2P with switched fabric */
648 BFA_PORT_TYPE_NLPORT = 6, /* public loop */
649 BFA_PORT_TYPE_LPORT = 20, /* private loop */
650 BFA_PORT_TYPE_P2P = 21, /* P2P with no switched fabric */
651 BFA_PORT_TYPE_VPORT = 22, /* NPIV - virtual port */
652};
653
654/*
655 * Port topology setting. A port's topology and fabric login status
656 * determine its operational type.
657 */
658enum bfa_port_topology {
659 BFA_PORT_TOPOLOGY_NONE = 0, /* No valid topology */
660 BFA_PORT_TOPOLOGY_P2P = 1, /* P2P only */
661 BFA_PORT_TOPOLOGY_LOOP = 2, /* LOOP topology */
662 BFA_PORT_TOPOLOGY_AUTO = 3, /* auto topology selection */
663};
664
665/*
666 * Physical port loopback types.
667 */
668enum bfa_port_opmode {
669 BFA_PORT_OPMODE_NORMAL = 0x00, /* normal non-loopback mode */
670 BFA_PORT_OPMODE_LB_INT = 0x01, /* internal loop back */
671 BFA_PORT_OPMODE_LB_SLW = 0x02, /* serial link wrapback (serdes) */
672 BFA_PORT_OPMODE_LB_EXT = 0x04, /* external loop back (serdes) */
673 BFA_PORT_OPMODE_LB_CBL = 0x08, /* cabled loop back */
674 BFA_PORT_OPMODE_LB_NLINT = 0x20, /* NL_Port internal loopback */
675};
676
677#define BFA_PORT_OPMODE_LB_HARD(_mode) \
678 ((_mode == BFA_PORT_OPMODE_LB_INT) || \
679 (_mode == BFA_PORT_OPMODE_LB_SLW) || \
680 (_mode == BFA_PORT_OPMODE_LB_EXT))
681
682/*
683 * Port link state
684 */
685enum bfa_port_linkstate {
686 BFA_PORT_LINKUP = 1, /* Physical port/Trunk link up */
687 BFA_PORT_LINKDOWN = 2, /* Physical port/Trunk link down */
688};
689
690/*
691 * Port link state reason code
692 */
693enum bfa_port_linkstate_rsn {
694 BFA_PORT_LINKSTATE_RSN_NONE = 0,
695 BFA_PORT_LINKSTATE_RSN_DISABLED = 1,
696 BFA_PORT_LINKSTATE_RSN_RX_NOS = 2,
697 BFA_PORT_LINKSTATE_RSN_RX_OLS = 3,
698 BFA_PORT_LINKSTATE_RSN_RX_LIP = 4,
699 BFA_PORT_LINKSTATE_RSN_RX_LIPF7 = 5,
700 BFA_PORT_LINKSTATE_RSN_SFP_REMOVED = 6,
701 BFA_PORT_LINKSTATE_RSN_PORT_FAULT = 7,
702 BFA_PORT_LINKSTATE_RSN_RX_LOS = 8,
703 BFA_PORT_LINKSTATE_RSN_LOCAL_FAULT = 9,
704 BFA_PORT_LINKSTATE_RSN_REMOTE_FAULT = 10,
705 BFA_PORT_LINKSTATE_RSN_TIMEOUT = 11,
706
707
708
709 /* CEE related reason codes/errors */
710 CEE_LLDP_INFO_AGED_OUT = 20,
711 CEE_LLDP_SHUTDOWN_TLV_RCVD = 21,
712 CEE_PEER_NOT_ADVERTISE_DCBX = 22,
713 CEE_PEER_NOT_ADVERTISE_PG = 23,
714 CEE_PEER_NOT_ADVERTISE_PFC = 24,
715 CEE_PEER_NOT_ADVERTISE_FCOE = 25,
716 CEE_PG_NOT_COMPATIBLE = 26,
717 CEE_PFC_NOT_COMPATIBLE = 27,
718 CEE_FCOE_NOT_COMPATIBLE = 28,
719 CEE_BAD_PG_RCVD = 29,
720 CEE_BAD_BW_RCVD = 30,
721 CEE_BAD_PFC_RCVD = 31,
722 CEE_BAD_APP_PRI_RCVD = 32,
723 CEE_FCOE_PRI_PFC_OFF = 33,
724 CEE_DUP_CONTROL_TLV_RCVD = 34,
725 CEE_DUP_FEAT_TLV_RCVD = 35,
726 CEE_APPLY_NEW_CFG = 36, /* reason, not error */
727 CEE_PROTOCOL_INIT = 37, /* reason, not error */
728 CEE_PHY_LINK_DOWN = 38,
729 CEE_LLS_FCOE_ABSENT = 39,
730 CEE_LLS_FCOE_DOWN = 40,
731 CEE_ISCSI_NOT_COMPATIBLE = 41,
732 CEE_ISCSI_PRI_PFC_OFF = 42,
733 CEE_ISCSI_PRI_OVERLAP_FCOE_PRI = 43
734};
735#pragma pack(1)
736/*
737 * Physical port configuration
738 */
739struct bfa_port_cfg_s {
740 u8 topology; /* bfa_port_topology */
741 u8 speed; /* enum bfa_port_speed */
742 u8 trunked; /* trunked or not */
743 u8 qos_enabled; /* qos enabled or not */
744 u8 cfg_hardalpa; /* is hard alpa configured */
745 u8 hardalpa; /* configured hard alpa */
746 __be16 maxfrsize; /* maximum frame size */
747 u8 rx_bbcredit; /* receive buffer credits */
748 u8 tx_bbcredit; /* transmit buffer credits */
749 u8 ratelimit; /* ratelimit enabled or not */
750 u8 trl_def_speed; /* ratelimit default speed */
751 u16 path_tov; /* device path timeout */
752 u16 q_depth; /* SCSI Queue depth */
753};
754#pragma pack()
755
756/*
757 * Port attribute values.
758 */
759struct bfa_port_attr_s {
760 /*
761 * Static fields
762 */
763 wwn_t nwwn; /* node wwn */
764 wwn_t pwwn; /* port wwn */
765 wwn_t factorynwwn; /* factory node wwn */
766 wwn_t factorypwwn; /* factory port wwn */
767 enum fc_cos cos_supported; /* supported class of services */
768 u32 rsvd;
769 struct fc_symname_s port_symname; /* port symbolic name */
770 enum bfa_port_speed speed_supported; /* supported speeds */
771 bfa_boolean_t pbind_enabled;
772
773 /*
774 * Configured values
775 */
776 struct bfa_port_cfg_s pport_cfg; /* pport cfg */
777
778 /*
779 * Dynamic field - info from BFA
780 */
781 enum bfa_port_states port_state; /* current port state */
782 enum bfa_port_speed speed; /* current speed */
783 enum bfa_port_topology topology; /* current topology */
784 bfa_boolean_t beacon; /* current beacon status */
785 bfa_boolean_t link_e2e_beacon; /* link beacon is on */
786 bfa_boolean_t plog_enabled; /* portlog is enabled */
787
788 /*
789 * Dynamic field - info from FCS
790 */
791 u32 pid; /* port ID */
792 enum bfa_port_type port_type; /* current topology */
793 u32 loopback; /* external loopback */
794 u32 authfail; /* auth fail state */
795 bfa_boolean_t io_profile; /* get it from fcpim mod */
796 u8 pad[4]; /* for 64-bit alignement */
797
798 /* FCoE specific */
799 u16 fcoe_vlan;
800 u8 rsvd1[6];
801};
802
803/*
804 * Port FCP mappings.
805 */
806struct bfa_port_fcpmap_s {
807 char osdevname[256];
808 u32 bus;
809 u32 target;
810 u32 oslun;
811 u32 fcid;
812 wwn_t nwwn;
813 wwn_t pwwn;
814 u64 fcplun;
815 char luid[256];
816};
817
818/*
819 * Port RNID info.
820 */
821struct bfa_port_rnid_s {
822 wwn_t wwn;
823 u32 unittype;
824 u32 portid;
825 u32 attached_nodes_num;
826 u16 ip_version;
827 u16 udp_port;
828 u8 ipaddr[16];
829 u16 rsvd;
830 u16 topologydiscoveryflags;
831};
832
833#pragma pack(1)
834struct bfa_fcport_fcf_s {
835 wwn_t name; /* FCF name */
836 wwn_t fabric_name; /* Fabric Name */
837 u8 fipenabled; /* FIP enabled or not */
838 u8 fipfailed; /* FIP failed or not */
839 u8 resv[2];
840 u8 pri; /* FCF priority */
841 u8 version; /* FIP version used */
842 u8 available; /* Available for login */
843 u8 fka_disabled; /* FKA is disabled */
844 u8 maxsz_verified; /* FCoE max size verified */
845 u8 fc_map[3]; /* FC map */
846 __be16 vlan; /* FCoE vlan tag/priority */
847 u32 fka_adv_per; /* FIP ka advert. period */
848 mac_t mac; /* FCF mac */
849};
850
851/*
852 * Trunk states for BCU/BFAL
853 */
854enum bfa_trunk_state {
855 BFA_TRUNK_DISABLED = 0, /* Trunk is not configured */
856 BFA_TRUNK_ONLINE = 1, /* Trunk is online */
857 BFA_TRUNK_OFFLINE = 2, /* Trunk is offline */
858};
859
860/*
861 * VC attributes for trunked link
862 */
863struct bfa_trunk_vc_attr_s {
864 u32 bb_credit;
865 u32 elp_opmode_flags;
866 u32 req_credit;
867 u16 vc_credits[8];
868};
869
870/*
871 * Link state information
872 */
873struct bfa_port_link_s {
874 u8 linkstate; /* Link state bfa_port_linkstate */
875 u8 linkstate_rsn; /* bfa_port_linkstate_rsn_t */
876 u8 topology; /* P2P/LOOP bfa_port_topology */
877 u8 speed; /* Link speed (1/2/4/8 G) */
878 u32 linkstate_opt; /* Linkstate optional data (debug) */
879 u8 trunked; /* Trunked or not (1 or 0) */
880 u8 resvd[3];
881 struct bfa_qos_attr_s qos_attr; /* QoS Attributes */
882 union {
883 struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */
884 struct bfa_trunk_vc_attr_s trunk_vc_attr;
885 struct bfa_fcport_fcf_s fcf; /* FCF information (for FCoE) */
886 } vc_fcf;
887};
888#pragma pack()
889
890enum bfa_trunk_link_fctl {
891 BFA_TRUNK_LINK_FCTL_NORMAL,
892 BFA_TRUNK_LINK_FCTL_VC,
893 BFA_TRUNK_LINK_FCTL_VC_QOS,
894};
895
896enum bfa_trunk_link_state {
897 BFA_TRUNK_LINK_STATE_UP = 1, /* link part of trunk */
898 BFA_TRUNK_LINK_STATE_DN_LINKDN = 2, /* physical link down */
899 BFA_TRUNK_LINK_STATE_DN_GRP_MIS = 3, /* trunk group different */
900 BFA_TRUNK_LINK_STATE_DN_SPD_MIS = 4, /* speed mismatch */
901 BFA_TRUNK_LINK_STATE_DN_MODE_MIS = 5, /* remote port not trunked */
902};
903
904#define BFA_TRUNK_MAX_PORTS 2
905struct bfa_trunk_link_attr_s {
906 wwn_t trunk_wwn;
907 enum bfa_trunk_link_fctl fctl;
908 enum bfa_trunk_link_state link_state;
909 enum bfa_port_speed speed;
910 u32 deskew;
911};
912
913struct bfa_trunk_attr_s {
914 enum bfa_trunk_state state;
915 enum bfa_port_speed speed;
916 u32 port_id;
917 u32 rsvd;
918 struct bfa_trunk_link_attr_s link_attr[BFA_TRUNK_MAX_PORTS];
919};
920
921struct bfa_rport_hal_stats_s {
922 u32 sm_un_cr; /* uninit: create events */
923 u32 sm_un_unexp; /* uninit: exception events */
924 u32 sm_cr_on; /* created: online events */
925 u32 sm_cr_del; /* created: delete events */
926 u32 sm_cr_hwf; /* created: IOC down */
927 u32 sm_cr_unexp; /* created: exception events */
928 u32 sm_fwc_rsp; /* fw create: f/w responses */
929 u32 sm_fwc_del; /* fw create: delete events */
930 u32 sm_fwc_off; /* fw create: offline events */
931 u32 sm_fwc_hwf; /* fw create: IOC down */
932 u32 sm_fwc_unexp; /* fw create: exception events*/
933 u32 sm_on_off; /* online: offline events */
934 u32 sm_on_del; /* online: delete events */
935 u32 sm_on_hwf; /* online: IOC down events */
936 u32 sm_on_unexp; /* online: exception events */
937 u32 sm_fwd_rsp; /* fw delete: fw responses */
938 u32 sm_fwd_del; /* fw delete: delete events */
939 u32 sm_fwd_hwf; /* fw delete: IOC down events */
940 u32 sm_fwd_unexp; /* fw delete: exception events*/
941 u32 sm_off_del; /* offline: delete events */
942 u32 sm_off_on; /* offline: online events */
943 u32 sm_off_hwf; /* offline: IOC down events */
944 u32 sm_off_unexp; /* offline: exception events */
945 u32 sm_del_fwrsp; /* delete: fw responses */
946 u32 sm_del_hwf; /* delete: IOC down events */
947 u32 sm_del_unexp; /* delete: exception events */
948 u32 sm_delp_fwrsp; /* delete pend: fw responses */
949 u32 sm_delp_hwf; /* delete pend: IOC downs */
950 u32 sm_delp_unexp; /* delete pend: exceptions */
951 u32 sm_offp_fwrsp; /* off-pending: fw responses */
952 u32 sm_offp_del; /* off-pending: deletes */
953 u32 sm_offp_hwf; /* off-pending: IOC downs */
954 u32 sm_offp_unexp; /* off-pending: exceptions */
955 u32 sm_iocd_off; /* IOC down: offline events */
956 u32 sm_iocd_del; /* IOC down: delete events */
957 u32 sm_iocd_on; /* IOC down: online events */
958 u32 sm_iocd_unexp; /* IOC down: exceptions */
959 u32 rsvd;
960};
961#pragma pack(1)
962/*
963 * Rport's QoS attributes
964 */
965struct bfa_rport_qos_attr_s {
966 u8 qos_priority; /* rport's QoS priority */
967 u8 rsvd[3];
968 u32 qos_flow_id; /* QoS flow Id */
969};
970#pragma pack()
971
972#define BFA_IOBUCKET_MAX 14
973
974struct bfa_itnim_latency_s {
975 u32 min[BFA_IOBUCKET_MAX];
976 u32 max[BFA_IOBUCKET_MAX];
977 u32 count[BFA_IOBUCKET_MAX];
978 u32 avg[BFA_IOBUCKET_MAX];
979};
980
981struct bfa_itnim_ioprofile_s {
982 u32 clock_res_mul;
983 u32 clock_res_div;
984 u32 index;
985 u32 io_profile_start_time; /* IO profile start time */
986 u32 iocomps[BFA_IOBUCKET_MAX]; /* IO completed */
987 struct bfa_itnim_latency_s io_latency;
988};
989
990/*
991 * FC physical port statistics.
992 */
993struct bfa_port_fc_stats_s {
994 u64 secs_reset; /* Seconds since stats is reset */
995 u64 tx_frames; /* Tx frames */
996 u64 tx_words; /* Tx words */
997 u64 tx_lip; /* Tx LIP */
998 u64 tx_nos; /* Tx NOS */
999 u64 tx_ols; /* Tx OLS */
1000 u64 tx_lr; /* Tx LR */
1001 u64 tx_lrr; /* Tx LRR */
1002 u64 rx_frames; /* Rx frames */
1003 u64 rx_words; /* Rx words */
1004 u64 lip_count; /* Rx LIP */
1005 u64 nos_count; /* Rx NOS */
1006 u64 ols_count; /* Rx OLS */
1007 u64 lr_count; /* Rx LR */
1008 u64 lrr_count; /* Rx LRR */
1009 u64 invalid_crcs; /* Rx CRC err frames */
1010 u64 invalid_crc_gd_eof; /* Rx CRC err good EOF frames */
1011 u64 undersized_frm; /* Rx undersized frames */
1012 u64 oversized_frm; /* Rx oversized frames */
1013 u64 bad_eof_frm; /* Rx frames with bad EOF */
1014 u64 error_frames; /* Errored frames */
1015 u64 dropped_frames; /* Dropped frames */
1016 u64 link_failures; /* Link Failure (LF) count */
1017 u64 loss_of_syncs; /* Loss of sync count */
1018 u64 loss_of_signals; /* Loss of signal count */
1019 u64 primseq_errs; /* Primitive sequence protocol err. */
1020 u64 bad_os_count; /* Invalid ordered sets */
1021 u64 err_enc_out; /* Encoding err nonframe_8b10b */
1022 u64 err_enc; /* Encoding err frame_8b10b */
1023};
1024
1025/*
1026 * Eth Physical Port statistics.
1027 */
1028struct bfa_port_eth_stats_s {
1029 u64 secs_reset; /* Seconds since stats is reset */
1030 u64 frame_64; /* Frames 64 bytes */
1031 u64 frame_65_127; /* Frames 65-127 bytes */
1032 u64 frame_128_255; /* Frames 128-255 bytes */
1033 u64 frame_256_511; /* Frames 256-511 bytes */
1034 u64 frame_512_1023; /* Frames 512-1023 bytes */
1035 u64 frame_1024_1518; /* Frames 1024-1518 bytes */
1036 u64 frame_1519_1522; /* Frames 1519-1522 bytes */
1037 u64 tx_bytes; /* Tx bytes */
1038 u64 tx_packets; /* Tx packets */
1039 u64 tx_mcast_packets; /* Tx multicast packets */
1040 u64 tx_bcast_packets; /* Tx broadcast packets */
1041 u64 tx_control_frame; /* Tx control frame */
1042 u64 tx_drop; /* Tx drops */
1043 u64 tx_jabber; /* Tx jabber */
1044 u64 tx_fcs_error; /* Tx FCS errors */
1045 u64 tx_fragments; /* Tx fragments */
1046 u64 rx_bytes; /* Rx bytes */
1047 u64 rx_packets; /* Rx packets */
1048 u64 rx_mcast_packets; /* Rx multicast packets */
1049 u64 rx_bcast_packets; /* Rx broadcast packets */
1050 u64 rx_control_frames; /* Rx control frames */
1051 u64 rx_unknown_opcode; /* Rx unknown opcode */
1052 u64 rx_drop; /* Rx drops */
1053 u64 rx_jabber; /* Rx jabber */
1054 u64 rx_fcs_error; /* Rx FCS errors */
1055 u64 rx_alignment_error; /* Rx alignment errors */
1056 u64 rx_frame_length_error; /* Rx frame len errors */
1057 u64 rx_code_error; /* Rx code errors */
1058 u64 rx_fragments; /* Rx fragments */
1059 u64 rx_pause; /* Rx pause */
1060 u64 rx_zero_pause; /* Rx zero pause */
1061 u64 tx_pause; /* Tx pause */
1062 u64 tx_zero_pause; /* Tx zero pause */
1063 u64 rx_fcoe_pause; /* Rx FCoE pause */
1064 u64 rx_fcoe_zero_pause; /* Rx FCoE zero pause */
1065 u64 tx_fcoe_pause; /* Tx FCoE pause */
1066 u64 tx_fcoe_zero_pause; /* Tx FCoE zero pause */
1067 u64 rx_iscsi_pause; /* Rx iSCSI pause */
1068 u64 rx_iscsi_zero_pause; /* Rx iSCSI zero pause */
1069 u64 tx_iscsi_pause; /* Tx iSCSI pause */
1070 u64 tx_iscsi_zero_pause; /* Tx iSCSI zero pause */
1071};
1072
1073/*
1074 * Port statistics.
1075 */
1076union bfa_port_stats_u {
1077 struct bfa_port_fc_stats_s fc;
1078 struct bfa_port_eth_stats_s eth;
1079};
1080
1081#endif /* __BFA_DEFS_SVC_H__ */
diff --git a/drivers/scsi/bfa/include/protocol/fc.h b/drivers/scsi/bfa/bfa_fc.h
index 436dd7c5643a..bf0067e0fd0d 100644
--- a/drivers/scsi/bfa/include/protocol/fc.h
+++ b/drivers/scsi/bfa/bfa_fc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,18 +15,52 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#ifndef __FC_H__ 18#ifndef __BFA_FC_H__
19#define __FC_H__ 19#define __BFA_FC_H__
20 20
21#include <protocol/types.h> 21#include "bfad_drv.h"
22
23typedef u64 wwn_t;
24
25#define WWN_NULL (0)
26#define FC_SYMNAME_MAX 256 /* max name server symbolic name size */
22 27
23#pragma pack(1) 28#pragma pack(1)
24 29
30#define MAC_ADDRLEN (6)
31struct mac_s { u8 mac[MAC_ADDRLEN]; };
32#define mac_t struct mac_s
33
34/*
35 * generic SCSI cdb definition
36 */
37#define SCSI_MAX_CDBLEN 16
38struct scsi_cdb_s {
39 u8 scsi_cdb[SCSI_MAX_CDBLEN];
40};
41
42/* ------------------------------------------------------------
43 * SCSI status byte values
44 * ------------------------------------------------------------
45 */
46#define SCSI_STATUS_GOOD 0x00
47#define SCSI_STATUS_CHECK_CONDITION 0x02
48#define SCSI_STATUS_CONDITION_MET 0x04
49#define SCSI_STATUS_BUSY 0x08
50#define SCSI_STATUS_INTERMEDIATE 0x10
51#define SCSI_STATUS_ICM 0x14 /* intermediate condition met */
52#define SCSI_STATUS_RESERVATION_CONFLICT 0x18
53#define SCSI_STATUS_COMMAND_TERMINATED 0x22
54#define SCSI_STATUS_QUEUE_FULL 0x28
55#define SCSI_STATUS_ACA_ACTIVE 0x30
56
57#define SCSI_MAX_ALLOC_LEN 0xFF /* maximum allocarion length */
58
25/* 59/*
26 * Fibre Channel Header Structure (FCHS) definition 60 * Fibre Channel Header Structure (FCHS) definition
27 */ 61 */
28struct fchs_s { 62struct fchs_s {
29#ifdef __BIGENDIAN 63#ifdef __BIG_ENDIAN
30 u32 routing:4; /* routing bits */ 64 u32 routing:4; /* routing bits */
31 u32 cat_info:4; /* category info */ 65 u32 cat_info:4; /* category info */
32#else 66#else
@@ -38,34 +72,19 @@ struct fchs_s {
38 u32 cs_ctl:8; /* class specific control */ 72 u32 cs_ctl:8; /* class specific control */
39 u32 s_id:24; /* source identifier */ 73 u32 s_id:24; /* source identifier */
40 74
41 u32 type:8; /* data structure type */ 75 u32 type:8; /* data structure type */
42 u32 f_ctl:24; /* initial frame control */ 76 u32 f_ctl:24; /* initial frame control */
43 77
44 u8 seq_id; /* sequence identifier */ 78 u8 seq_id; /* sequence identifier */
45 u8 df_ctl; /* data field control */ 79 u8 df_ctl; /* data field control */
46 u16 seq_cnt; /* sequence count */ 80 u16 seq_cnt; /* sequence count */
47 81
48 u16 ox_id; /* originator exchange ID */ 82 __be16 ox_id; /* originator exchange ID */
49 u16 rx_id; /* responder exchange ID */ 83 u16 rx_id; /* responder exchange ID */
50 84
51 u32 ro; /* relative offset */ 85 u32 ro; /* relative offset */
52}; 86};
53 87
54#define FC_SOF_LEN 4
55#define FC_EOF_LEN 4
56#define FC_CRC_LEN 4
57
58/*
59 * Fibre Channel BB_E Header Structure
60 */
61struct fcbbehs_s {
62 u16 ver_rsvd;
63 u32 rsvd[2];
64 u32 rsvd__sof;
65};
66
67#define FC_SEQ_ID_MAX 256
68
69/* 88/*
70 * routing bit definitions 89 * routing bit definitions
71 */ 90 */
@@ -112,22 +131,6 @@ enum {
112}; 131};
113 132
114/* 133/*
115 * information category for Link Control
116 */
117enum {
118 FC_CAT_ACK_1 = 0x00,
119 FC_CAT_ACK_0_N = 0x01,
120 FC_CAT_P_RJT = 0x02,
121 FC_CAT_F_RJT = 0x03,
122 FC_CAT_P_BSY = 0x04,
123 FC_CAT_F_BSY_DATA = 0x05,
124 FC_CAT_F_BSY_LINK_CTL = 0x06,
125 FC_CAT_F_LCR = 0x07,
126 FC_CAT_NTY = 0x08,
127 FC_CAT_END = 0x09,
128};
129
130/*
131 * Type Field Definitions. FC-PH Section 18.5 pg. 165 134 * Type Field Definitions. FC-PH Section 18.5 pg. 165
132 */ 135 */
133enum { 136enum {
@@ -140,13 +143,11 @@ enum {
140 FC_TYPE_FC_FSS = 0x22, /* Fabric Switch Services */ 143 FC_TYPE_FC_FSS = 0x22, /* Fabric Switch Services */
141 FC_TYPE_FC_AL = 0x23, /* FC-AL */ 144 FC_TYPE_FC_AL = 0x23, /* FC-AL */
142 FC_TYPE_FC_SNMP = 0x24, /* FC-SNMP */ 145 FC_TYPE_FC_SNMP = 0x24, /* FC-SNMP */
146 FC_TYPE_FC_SPINFAB = 0xEE, /* SPINFAB */
147 FC_TYPE_FC_DIAG = 0xEF, /* DIAG */
143 FC_TYPE_MAX = 256, /* 256 FC-4 types */ 148 FC_TYPE_MAX = 256, /* 256 FC-4 types */
144}; 149};
145 150
146struct fc_fc4types_s{
147 u8 bits[FC_TYPE_MAX / 8];
148};
149
150/* 151/*
151 * Frame Control Definitions. FC-PH Table-45. pg. 168 152 * Frame Control Definitions. FC-PH Table-45. pg. 168
152 */ 153 */
@@ -168,7 +169,7 @@ enum {
168 */ 169 */
169enum { 170enum {
170 FC_MIN_WELL_KNOWN_ADDR = 0xFFFFF0, 171 FC_MIN_WELL_KNOWN_ADDR = 0xFFFFF0,
171 FC_DOMAIN_CONTROLLER_MASK = 0xFFFC00, 172 FC_DOMAIN_CONTROLLER_MASK = 0xFFFC00,
172 FC_ALIAS_SERVER = 0xFFFFF8, 173 FC_ALIAS_SERVER = 0xFFFFF8,
173 FC_MGMT_SERVER = 0xFFFFFA, 174 FC_MGMT_SERVER = 0xFFFFFA,
174 FC_TIME_SERVER = 0xFFFFFB, 175 FC_TIME_SERVER = 0xFFFFFB,
@@ -201,7 +202,7 @@ enum {
201/* 202/*
202 * generic ELS command 203 * generic ELS command
203 */ 204 */
204struct fc_els_cmd_s{ 205struct fc_els_cmd_s {
205 u32 els_code:8; /* ELS Command Code */ 206 u32 els_code:8; /* ELS Command Code */
206 u32 reserved:24; 207 u32 reserved:24;
207}; 208};
@@ -233,6 +234,8 @@ enum {
233 FC_ELS_PDISC = 0x50, /* Discover N_Port Parameters. */ 234 FC_ELS_PDISC = 0x50, /* Discover N_Port Parameters. */
234 FC_ELS_FDISC = 0x51, /* Discover F_Port Parameters. */ 235 FC_ELS_FDISC = 0x51, /* Discover F_Port Parameters. */
235 FC_ELS_ADISC = 0x52, /* Discover Address. */ 236 FC_ELS_ADISC = 0x52, /* Discover Address. */
237 FC_ELS_FARP_REQ = 0x54, /* FARP Request. */
238 FC_ELS_FARP_REP = 0x55, /* FARP Reply. */
236 FC_ELS_FAN = 0x60, /* Fabric Address Notification */ 239 FC_ELS_FAN = 0x60, /* Fabric Address Notification */
237 FC_ELS_RSCN = 0x61, /* Reg State Change Notification */ 240 FC_ELS_RSCN = 0x61, /* Reg State Change Notification */
238 FC_ELS_SCR = 0x62, /* State Change Registration. */ 241 FC_ELS_SCR = 0x62, /* State Change Registration. */
@@ -247,7 +250,6 @@ enum {
247 FC_ELS_AUTH = 0x90, /* Authentication. Ref FC-SP */ 250 FC_ELS_AUTH = 0x90, /* Authentication. Ref FC-SP */
248 FC_ELS_RFCN = 0x97, /* Request Fabric Change Notification. Ref 251 FC_ELS_RFCN = 0x97, /* Request Fabric Change Notification. Ref
249 *FC-SP */ 252 *FC-SP */
250
251}; 253};
252 254
253/* 255/*
@@ -272,13 +274,13 @@ enum {
272 * N_Port PLOGI Common Service Parameters. 274 * N_Port PLOGI Common Service Parameters.
273 * FC-PH-x. Figure-76. pg. 308. 275 * FC-PH-x. Figure-76. pg. 308.
274 */ 276 */
275struct fc_plogi_csp_s{ 277struct fc_plogi_csp_s {
276 u8 verhi; /* FC-PH high version */ 278 u8 verhi; /* FC-PH high version */
277 u8 verlo; /* FC-PH low version */ 279 u8 verlo; /* FC-PH low version */
278 u16 bbcred; /* BB_Credit */ 280 __be16 bbcred; /* BB_Credit */
279 281
280#ifdef __BIGENDIAN 282#ifdef __BIG_ENDIAN
281 u8 ciro:1, /* continuously increasing RO */ 283 u8 ciro:1, /* continuously increasing RO */
282 rro:1, /* random relative offset */ 284 rro:1, /* random relative offset */
283 npiv_supp:1, /* NPIV supported */ 285 npiv_supp:1, /* NPIV supported */
284 port_type:1, /* N_Port/F_port */ 286 port_type:1, /* N_Port/F_port */
@@ -287,7 +289,7 @@ struct fc_plogi_csp_s{
287 vvl_info:1, /* VVL Info included */ 289 vvl_info:1, /* VVL Info included */
288 reserved1:1; 290 reserved1:1;
289 291
290 u8 hg_supp:1, 292 u8 hg_supp:1,
291 query_dbc:1, 293 query_dbc:1,
292 security:1, 294 security:1,
293 sync_cap:1, 295 sync_cap:1,
@@ -296,7 +298,7 @@ struct fc_plogi_csp_s{
296 cisc:1, /* continuously increasing seq count */ 298 cisc:1, /* continuously increasing seq count */
297 payload:1; 299 payload:1;
298#else 300#else
299 u8 reserved2:2, 301 u8 reserved2:2,
300 resolution:1, /* ms/ns ED_TOV resolution */ 302 resolution:1, /* ms/ns ED_TOV resolution */
301 altbbcred:1, /* alternate BB_Credit */ 303 altbbcred:1, /* alternate BB_Credit */
302 port_type:1, /* N_Port/F_port */ 304 port_type:1, /* N_Port/F_port */
@@ -304,7 +306,7 @@ struct fc_plogi_csp_s{
304 rro:1, /* random relative offset */ 306 rro:1, /* random relative offset */
305 ciro:1; /* continuously increasing RO */ 307 ciro:1; /* continuously increasing RO */
306 308
307 u8 payload:1, 309 u8 payload:1,
308 cisc:1, /* continuously increasing seq count */ 310 cisc:1, /* continuously increasing seq count */
309 dh_dup_supp:1, 311 dh_dup_supp:1,
310 r_t_tov:1, 312 r_t_tov:1,
@@ -313,26 +315,22 @@ struct fc_plogi_csp_s{
313 query_dbc:1, 315 query_dbc:1,
314 hg_supp:1; 316 hg_supp:1;
315#endif 317#endif
316 318 __be16 rxsz; /* receive data_field size */
317 u16 rxsz; /* recieve data_field size */ 319 __be16 conseq;
318 320 __be16 ro_bitmap;
319 u16 conseq; 321 __be32 e_d_tov;
320 u16 ro_bitmap;
321
322 u32 e_d_tov;
323}; 322};
324 323
325/* 324/*
326 * N_Port PLOGI Class Specific Parameters. 325 * N_Port PLOGI Class Specific Parameters.
327 * FC-PH-x. Figure 78. pg. 318. 326 * FC-PH-x. Figure 78. pg. 318.
328 */ 327 */
329struct fc_plogi_clp_s{ 328struct fc_plogi_clp_s {
330#ifdef __BIGENDIAN 329#ifdef __BIG_ENDIAN
331 u32 class_valid:1; 330 u32 class_valid:1;
332 u32 intermix:1; /* class intermix supported if set =1. 331 u32 intermix:1; /* class intermix supported if set =1.
333 * valid only for class1. Reserved for 332 * valid only for class1. Reserved for
334 * class2 & class3 333 * class2 & class3 */
335 */
336 u32 reserved1:2; 334 u32 reserved1:2;
337 u32 sequential:1; 335 u32 sequential:1;
338 u32 reserved2:3; 336 u32 reserved2:3;
@@ -341,12 +339,10 @@ struct fc_plogi_clp_s{
341 u32 sequential:1; 339 u32 sequential:1;
342 u32 reserved1:2; 340 u32 reserved1:2;
343 u32 intermix:1; /* class intermix supported if set =1. 341 u32 intermix:1; /* class intermix supported if set =1.
344 * valid only for class1. Reserved for 342 * valid only for class1. Reserved for
345 * class2 & class3 343 * class2 & class3 */
346 */
347 u32 class_valid:1; 344 u32 class_valid:1;
348#endif 345#endif
349
350 u32 reserved3:24; 346 u32 reserved3:24;
351 347
352 u32 reserved4:16; 348 u32 reserved4:16;
@@ -354,38 +350,38 @@ struct fc_plogi_clp_s{
354 350
355 u32 reserved5:8; 351 u32 reserved5:8;
356 u32 conseq:8; 352 u32 conseq:8;
357 u32 e2e_credit:16; /* end to end credit */ 353 u32 e2e_credit:16; /* end to end credit */
358 354
359 u32 reserved7:8; 355 u32 reserved7:8;
360 u32 ospx:8; 356 u32 ospx:8;
361 u32 reserved8:16; 357 u32 reserved8:16;
362}; 358};
363 359
364#define FLOGI_VVL_BRCD 0x42524344 /* ASCII value for each character in 360/* ASCII value for each character in string "BRCD" */
365 * string "BRCD" */ 361#define FLOGI_VVL_BRCD 0x42524344
366 362
367/* 363/*
368 * PLOGI els command and reply payload 364 * PLOGI els command and reply payload
369 */ 365 */
370struct fc_logi_s{ 366struct fc_logi_s {
371 struct fc_els_cmd_s els_cmd; /* ELS command code */ 367 struct fc_els_cmd_s els_cmd; /* ELS command code */
372 struct fc_plogi_csp_s csp; /* common service params */ 368 struct fc_plogi_csp_s csp; /* common service params */
373 wwn_t port_name; 369 wwn_t port_name;
374 wwn_t node_name; 370 wwn_t node_name;
375 struct fc_plogi_clp_s class1; /* class 1 service parameters */ 371 struct fc_plogi_clp_s class1; /* class 1 service parameters */
376 struct fc_plogi_clp_s class2; /* class 2 service parameters */ 372 struct fc_plogi_clp_s class2; /* class 2 service parameters */
377 struct fc_plogi_clp_s class3; /* class 3 service parameters */ 373 struct fc_plogi_clp_s class3; /* class 3 service parameters */
378 struct fc_plogi_clp_s class4; /* class 4 service parameters */ 374 struct fc_plogi_clp_s class4; /* class 4 service parameters */
379 u8 vvl[16]; /* vendor version level */ 375 u8 vvl[16]; /* vendor version level */
380}; 376};
381 377
382/* 378/*
383 * LOGO els command payload 379 * LOGO els command payload
384 */ 380 */
385struct fc_logo_s{ 381struct fc_logo_s {
386 struct fc_els_cmd_s els_cmd; /* ELS command code */ 382 struct fc_els_cmd_s els_cmd; /* ELS command code */
387 u32 res1:8; 383 u32 res1:8;
388 u32 nport_id:24; /* N_Port identifier of source */ 384 u32 nport_id:24; /* N_Port identifier of source */
389 wwn_t orig_port_name; /* Port name of the LOGO originator */ 385 wwn_t orig_port_name; /* Port name of the LOGO originator */
390}; 386};
391 387
@@ -393,19 +389,19 @@ struct fc_logo_s{
393 * ADISC els command payload 389 * ADISC els command payload
394 */ 390 */
395struct fc_adisc_s { 391struct fc_adisc_s {
396 struct fc_els_cmd_s els_cmd; /* ELS command code */ 392 struct fc_els_cmd_s els_cmd; /* ELS command code */
397 u32 res1:8; 393 u32 res1:8;
398 u32 orig_HA:24; /* originator hard address */ 394 u32 orig_HA:24; /* originator hard address */
399 wwn_t orig_port_name; /* originator port name */ 395 wwn_t orig_port_name; /* originator port name */
400 wwn_t orig_node_name; /* originator node name */ 396 wwn_t orig_node_name; /* originator node name */
401 u32 res2:8; 397 u32 res2:8;
402 u32 nport_id:24; /* originator NPortID */ 398 u32 nport_id:24; /* originator NPortID */
403}; 399};
404 400
405/* 401/*
406 * Exchange status block 402 * Exchange status block
407 */ 403 */
408struct fc_exch_status_blk_s{ 404struct fc_exch_status_blk_s {
409 u32 oxid:16; 405 u32 oxid:16;
410 u32 rxid:16; 406 u32 rxid:16;
411 u32 res1:8; 407 u32 res1:8;
@@ -423,9 +419,9 @@ struct fc_exch_status_blk_s{
423 * RES els command payload 419 * RES els command payload
424 */ 420 */
425struct fc_res_s { 421struct fc_res_s {
426 struct fc_els_cmd_s els_cmd; /* ELS command code */ 422 struct fc_els_cmd_s els_cmd; /* ELS command code */
427 u32 res1:8; 423 u32 res1:8;
428 u32 nport_id:24; /* N_Port identifier of source */ 424 u32 nport_id:24; /* N_Port identifier of source */
429 u32 oxid:16; 425 u32 oxid:16;
430 u32 rxid:16; 426 u32 rxid:16;
431 u8 assoc_hdr[32]; 427 u8 assoc_hdr[32];
@@ -434,16 +430,16 @@ struct fc_res_s {
434/* 430/*
435 * RES els accept payload 431 * RES els accept payload
436 */ 432 */
437struct fc_res_acc_s{ 433struct fc_res_acc_s {
438 struct fc_els_cmd_s els_cmd; /* ELS command code */ 434 struct fc_els_cmd_s els_cmd; /* ELS command code */
439 struct fc_exch_status_blk_s fc_exch_blk; /* Exchange status block */ 435 struct fc_exch_status_blk_s fc_exch_blk; /* Exchange status block */
440}; 436};
441 437
442/* 438/*
443 * REC els command payload 439 * REC els command payload
444 */ 440 */
445struct fc_rec_s { 441struct fc_rec_s {
446 struct fc_els_cmd_s els_cmd; /* ELS command code */ 442 struct fc_els_cmd_s els_cmd; /* ELS command code */
447 u32 res1:8; 443 u32 res1:8;
448 u32 nport_id:24; /* N_Port identifier of source */ 444 u32 nport_id:24; /* N_Port identifier of source */
449 u32 oxid:16; 445 u32 oxid:16;
@@ -451,9 +447,9 @@ struct fc_rec_s {
451}; 447};
452 448
453#define FC_REC_ESB_OWN_RSP 0x80000000 /* responder owns */ 449#define FC_REC_ESB_OWN_RSP 0x80000000 /* responder owns */
454#define FC_REC_ESB_SI 0x40000000 /* SI is owned */ 450#define FC_REC_ESB_SI 0x40000000 /* SI is owned */
455#define FC_REC_ESB_COMP 0x20000000 /* exchange is complete */ 451#define FC_REC_ESB_COMP 0x20000000 /* exchange is complete */
456#define FC_REC_ESB_ENDCOND_ABN 0x10000000 /* abnormal ending */ 452#define FC_REC_ESB_ENDCOND_ABN 0x10000000 /* abnormal ending */
457#define FC_REC_ESB_RQACT 0x04000000 /* recovery qual active */ 453#define FC_REC_ESB_RQACT 0x04000000 /* recovery qual active */
458#define FC_REC_ESB_ERRP_MSK 0x03000000 454#define FC_REC_ESB_ERRP_MSK 0x03000000
459#define FC_REC_ESB_OXID_INV 0x00800000 /* invalid OXID */ 455#define FC_REC_ESB_OXID_INV 0x00800000 /* invalid OXID */
@@ -464,22 +460,22 @@ struct fc_rec_s {
464 * REC els accept payload 460 * REC els accept payload
465 */ 461 */
466struct fc_rec_acc_s { 462struct fc_rec_acc_s {
467 struct fc_els_cmd_s els_cmd; /* ELS command code */ 463 struct fc_els_cmd_s els_cmd; /* ELS command code */
468 u32 oxid:16; 464 u32 oxid:16;
469 u32 rxid:16; 465 u32 rxid:16;
470 u32 res1:8; 466 u32 res1:8;
471 u32 orig_id:24; /* N_Port id of exchange originator */ 467 u32 orig_id:24; /* N_Port id of exchange originator */
472 u32 res2:8; 468 u32 res2:8;
473 u32 resp_id:24; /* N_Port id of exchange responder */ 469 u32 resp_id:24; /* N_Port id of exchange responder */
474 u32 count; /* data transfer count */ 470 u32 count; /* data transfer count */
475 u32 e_stat; /* exchange status */ 471 u32 e_stat; /* exchange status */
476}; 472};
477 473
478/* 474/*
479 * RSI els payload 475 * RSI els payload
480 */ 476 */
481struct fc_rsi_s { 477struct fc_rsi_s {
482 struct fc_els_cmd_s els_cmd; 478 struct fc_els_cmd_s els_cmd;
483 u32 res1:8; 479 u32 res1:8;
484 u32 orig_sid:24; 480 u32 orig_sid:24;
485 u32 oxid:16; 481 u32 oxid:16;
@@ -490,9 +486,9 @@ struct fc_rsi_s {
490 * structure for PRLI paramater pages, both request & response 486 * structure for PRLI paramater pages, both request & response
491 * see FC-PH-X table 113 & 115 for explanation also FCP table 8 487 * see FC-PH-X table 113 & 115 for explanation also FCP table 8
492 */ 488 */
493struct fc_prli_params_s{ 489struct fc_prli_params_s {
494 u32 reserved:16; 490 u32 reserved:16;
495#ifdef __BIGENDIAN 491#ifdef __BIG_ENDIAN
496 u32 reserved1:5; 492 u32 reserved1:5;
497 u32 rec_support:1; 493 u32 rec_support:1;
498 u32 task_retry_id:1; 494 u32 task_retry_id:1;
@@ -531,10 +527,10 @@ enum {
531 FC_PRLI_ACC_PREDEF_IMG = 0x5, /* predefined image - no prli needed */ 527 FC_PRLI_ACC_PREDEF_IMG = 0x5, /* predefined image - no prli needed */
532}; 528};
533 529
534struct fc_prli_params_page_s{ 530struct fc_prli_params_page_s {
535 u32 type:8; 531 u32 type:8;
536 u32 codext:8; 532 u32 codext:8;
537#ifdef __BIGENDIAN 533#ifdef __BIG_ENDIAN
538 u32 origprocasv:1; 534 u32 origprocasv:1;
539 u32 rsppav:1; 535 u32 rsppav:1;
540 u32 imagepair:1; 536 u32 imagepair:1;
@@ -551,13 +547,13 @@ struct fc_prli_params_page_s{
551 547
552 u32 origprocas; 548 u32 origprocas;
553 u32 rspprocas; 549 u32 rspprocas;
554 struct fc_prli_params_s servparams; 550 struct fc_prli_params_s servparams;
555}; 551};
556 552
557/* 553/*
558 * PRLI request and accept payload, FC-PH-X tables 112 & 114 554 * PRLI request and accept payload, FC-PH-X tables 112 & 114
559 */ 555 */
560struct fc_prli_s{ 556struct fc_prli_s {
561 u32 command:8; 557 u32 command:8;
562 u32 pglen:8; 558 u32 pglen:8;
563 u32 pagebytes:16; 559 u32 pagebytes:16;
@@ -567,21 +563,17 @@ struct fc_prli_s{
567/* 563/*
568 * PRLO logout params page 564 * PRLO logout params page
569 */ 565 */
570struct fc_prlo_params_page_s{ 566struct fc_prlo_params_page_s {
571 u32 type:8; 567 u32 type:8;
572 u32 type_ext:8; 568 u32 type_ext:8;
573#ifdef __BIGENDIAN 569#ifdef __BIG_ENDIAN
574 u32 opa_valid:1; /* originator process associator 570 u32 opa_valid:1; /* originator process associator valid */
575 * valid
576 */
577 u32 rpa_valid:1; /* responder process associator valid */ 571 u32 rpa_valid:1; /* responder process associator valid */
578 u32 res1:14; 572 u32 res1:14;
579#else 573#else
580 u32 res1:14; 574 u32 res1:14;
581 u32 rpa_valid:1; /* responder process associator valid */ 575 u32 rpa_valid:1; /* responder process associator valid */
582 u32 opa_valid:1; /* originator process associator 576 u32 opa_valid:1; /* originator process associator valid */
583 * valid
584 */
585#endif 577#endif
586 u32 orig_process_assc; 578 u32 orig_process_assc;
587 u32 resp_process_assc; 579 u32 resp_process_assc;
@@ -592,32 +584,28 @@ struct fc_prlo_params_page_s{
592/* 584/*
593 * PRLO els command payload 585 * PRLO els command payload
594 */ 586 */
595struct fc_prlo_s{ 587struct fc_prlo_s {
596 u32 command:8; 588 u32 command:8;
597 u32 page_len:8; 589 u32 page_len:8;
598 u32 payload_len:16; 590 u32 payload_len:16;
599 struct fc_prlo_params_page_s prlo_params[1]; 591 struct fc_prlo_params_page_s prlo_params[1];
600}; 592};
601 593
602/* 594/*
603 * PRLO Logout response parameter page 595 * PRLO Logout response parameter page
604 */ 596 */
605struct fc_prlo_acc_params_page_s{ 597struct fc_prlo_acc_params_page_s {
606 u32 type:8; 598 u32 type:8;
607 u32 type_ext:8; 599 u32 type_ext:8;
608 600
609#ifdef __BIGENDIAN 601#ifdef __BIG_ENDIAN
610 u32 opa_valid:1; /* originator process associator 602 u32 opa_valid:1; /* originator process associator valid */
611 * valid
612 */
613 u32 rpa_valid:1; /* responder process associator valid */ 603 u32 rpa_valid:1; /* responder process associator valid */
614 u32 res1:14; 604 u32 res1:14;
615#else 605#else
616 u32 res1:14; 606 u32 res1:14;
617 u32 rpa_valid:1; /* responder process associator valid */ 607 u32 rpa_valid:1; /* responder process associator valid */
618 u32 opa_valid:1; /* originator process associator 608 u32 opa_valid:1; /* originator process associator valid */
619 * valid
620 */
621#endif 609#endif
622 u32 orig_process_assc; 610 u32 orig_process_assc;
623 u32 resp_process_assc; 611 u32 resp_process_assc;
@@ -628,7 +616,7 @@ struct fc_prlo_acc_params_page_s{
628/* 616/*
629 * PRLO els command ACC payload 617 * PRLO els command ACC payload
630 */ 618 */
631struct fc_prlo_acc_s{ 619struct fc_prlo_acc_s {
632 u32 command:8; 620 u32 command:8;
633 u32 page_len:8; 621 u32 page_len:8;
634 u32 payload_len:16; 622 u32 payload_len:16;
@@ -650,7 +638,7 @@ enum {
650 FC_VU_SCR_REG_FUNC_FABRIC_NAME_CHANGE = 0x01 638 FC_VU_SCR_REG_FUNC_FABRIC_NAME_CHANGE = 0x01
651}; 639};
652 640
653struct fc_scr_s{ 641struct fc_scr_s {
654 u32 command:8; 642 u32 command:8;
655 u32 res:24; 643 u32 res:24;
656 u32 vu_reg_func:8; /* Vendor Unique Registrations */ 644 u32 vu_reg_func:8; /* Vendor Unique Registrations */
@@ -674,9 +662,9 @@ enum {
674 * LS_RJT els reply payload 662 * LS_RJT els reply payload
675 */ 663 */
676struct fc_ls_rjt_s { 664struct fc_ls_rjt_s {
677 struct fc_els_cmd_s els_cmd; /* ELS command code */ 665 struct fc_els_cmd_s els_cmd; /* ELS command code */
678 u32 res1:8; 666 u32 res1:8;
679 u32 reason_code:8; /* Reason code for reject */ 667 u32 reason_code:8; /* Reason code for reject */
680 u32 reason_code_expl:8; /* Reason code explanation */ 668 u32 reason_code_expl:8; /* Reason code explanation */
681 u32 vendor_unique:8; /* Vendor specific */ 669 u32 vendor_unique:8; /* Vendor specific */
682}; 670};
@@ -722,8 +710,8 @@ enum {
722/* 710/*
723 * RRQ els command payload 711 * RRQ els command payload
724 */ 712 */
725struct fc_rrq_s{ 713struct fc_rrq_s {
726 struct fc_els_cmd_s els_cmd; /* ELS command code */ 714 struct fc_els_cmd_s els_cmd; /* ELS command code */
727 u32 res1:8; 715 u32 res1:8;
728 u32 s_id:24; /* exchange originator S_ID */ 716 u32 s_id:24; /* exchange originator S_ID */
729 717
@@ -736,34 +724,34 @@ struct fc_rrq_s{
736/* 724/*
737 * ABTS BA_ACC reply payload 725 * ABTS BA_ACC reply payload
738 */ 726 */
739struct fc_ba_acc_s{ 727struct fc_ba_acc_s {
740 u32 seq_id_valid:8; /* set to 0x00 for Abort Exchange */ 728 u32 seq_id_valid:8; /* set to 0x00 for Abort Exchange */
741 u32 seq_id:8; /* invalid for Abort Exchange */ 729 u32 seq_id:8; /* invalid for Abort Exchange */
742 u32 res2:16; 730 u32 res2:16;
743 u32 ox_id:16; /* OX_ID from ABTS frame */ 731 u32 ox_id:16; /* OX_ID from ABTS frame */
744 u32 rx_id:16; /* RX_ID from ABTS frame */ 732 u32 rx_id:16; /* RX_ID from ABTS frame */
745 u32 low_seq_cnt:16; /* set to 0x0000 for Abort Exchange */ 733 u32 low_seq_cnt:16; /* set to 0x0000 for Abort Exchange */
746 u32 high_seq_cnt:16;/* set to 0xFFFF for Abort Exchange */ 734 u32 high_seq_cnt:16; /* set to 0xFFFF for Abort Exchange */
747}; 735};
748 736
749/* 737/*
750 * ABTS BA_RJT reject payload 738 * ABTS BA_RJT reject payload
751 */ 739 */
752struct fc_ba_rjt_s{ 740struct fc_ba_rjt_s {
753 u32 res1:8; /* Reserved */ 741 u32 res1:8; /* Reserved */
754 u32 reason_code:8; /* reason code for reject */ 742 u32 reason_code:8; /* reason code for reject */
755 u32 reason_expl:8; /* reason code explanation */ 743 u32 reason_expl:8; /* reason code explanation */
756 u32 vendor_unique:8;/* vendor unique reason code,set to 0 */ 744 u32 vendor_unique:8; /* vendor unique reason code,set to 0 */
757}; 745};
758 746
759/* 747/*
760 * TPRLO logout parameter page 748 * TPRLO logout parameter page
761 */ 749 */
762struct fc_tprlo_params_page_s{ 750struct fc_tprlo_params_page_s {
763 u32 type:8; 751 u32 type:8;
764 u32 type_ext:8; 752 u32 type_ext:8;
765 753
766#ifdef __BIGENDIAN 754#ifdef __BIG_ENDIAN
767 u32 opa_valid:1; 755 u32 opa_valid:1;
768 u32 rpa_valid:1; 756 u32 rpa_valid:1;
769 u32 tpo_nport_valid:1; 757 u32 tpo_nport_valid:1;
@@ -787,7 +775,7 @@ struct fc_tprlo_params_page_s{
787/* 775/*
788 * TPRLO ELS command payload 776 * TPRLO ELS command payload
789 */ 777 */
790struct fc_tprlo_s{ 778struct fc_tprlo_s {
791 u32 command:8; 779 u32 command:8;
792 u32 page_len:8; 780 u32 page_len:8;
793 u32 payload_len:16; 781 u32 payload_len:16;
@@ -795,7 +783,7 @@ struct fc_tprlo_s{
795 struct fc_tprlo_params_page_s tprlo_params[1]; 783 struct fc_tprlo_params_page_s tprlo_params[1];
796}; 784};
797 785
798enum fc_tprlo_type{ 786enum fc_tprlo_type {
799 FC_GLOBAL_LOGO = 1, 787 FC_GLOBAL_LOGO = 1,
800 FC_TPR_LOGO 788 FC_TPR_LOGO
801}; 789};
@@ -803,7 +791,7 @@ enum fc_tprlo_type{
803/* 791/*
804 * TPRLO els command ACC payload 792 * TPRLO els command ACC payload
805 */ 793 */
806struct fc_tprlo_acc_s{ 794struct fc_tprlo_acc_s {
807 u32 command:8; 795 u32 command:8;
808 u32 page_len:8; 796 u32 page_len:8;
809 u32 payload_len:16; 797 u32 payload_len:16;
@@ -815,24 +803,24 @@ struct fc_tprlo_acc_s{
815 */ 803 */
816#define FC_RSCN_PGLEN 0x4 804#define FC_RSCN_PGLEN 0x4
817 805
818enum fc_rscn_format{ 806enum fc_rscn_format {
819 FC_RSCN_FORMAT_PORTID = 0x0, 807 FC_RSCN_FORMAT_PORTID = 0x0,
820 FC_RSCN_FORMAT_AREA = 0x1, 808 FC_RSCN_FORMAT_AREA = 0x1,
821 FC_RSCN_FORMAT_DOMAIN = 0x2, 809 FC_RSCN_FORMAT_DOMAIN = 0x2,
822 FC_RSCN_FORMAT_FABRIC = 0x3, 810 FC_RSCN_FORMAT_FABRIC = 0x3,
823}; 811};
824 812
825struct fc_rscn_event_s{ 813struct fc_rscn_event_s {
826 u32 format:2; 814 u32 format:2;
827 u32 qualifier:4; 815 u32 qualifier:4;
828 u32 resvd:2; 816 u32 resvd:2;
829 u32 portid:24; 817 u32 portid:24;
830}; 818};
831 819
832struct fc_rscn_pl_s{ 820struct fc_rscn_pl_s {
833 u8 command; 821 u8 command;
834 u8 pagelen; 822 u8 pagelen;
835 u16 payldlen; 823 __be16 payldlen;
836 struct fc_rscn_event_s event[1]; 824 struct fc_rscn_event_s event[1];
837}; 825};
838 826
@@ -840,18 +828,17 @@ struct fc_rscn_pl_s{
840 * ECHO els command req payload 828 * ECHO els command req payload
841 */ 829 */
842struct fc_echo_s { 830struct fc_echo_s {
843 struct fc_els_cmd_s els_cmd; 831 struct fc_els_cmd_s els_cmd;
844}; 832};
845 833
846/* 834/*
847 * RNID els command 835 * RNID els command
848 */ 836 */
837#define RNID_NODEID_DATA_FORMAT_COMMON 0x00
838#define RNID_NODEID_DATA_FORMAT_FCP3 0x08
839#define RNID_NODEID_DATA_FORMAT_DISCOVERY 0xDF
849 840
850#define RNID_NODEID_DATA_FORMAT_COMMON 0x00 841#define RNID_ASSOCIATED_TYPE_UNKNOWN 0x00000001
851#define RNID_NODEID_DATA_FORMAT_FCP3 0x08
852#define RNID_NODEID_DATA_FORMAT_DISCOVERY 0xDF
853
854#define RNID_ASSOCIATED_TYPE_UNKNOWN 0x00000001
855#define RNID_ASSOCIATED_TYPE_OTHER 0x00000002 842#define RNID_ASSOCIATED_TYPE_OTHER 0x00000002
856#define RNID_ASSOCIATED_TYPE_HUB 0x00000003 843#define RNID_ASSOCIATED_TYPE_HUB 0x00000003
857#define RNID_ASSOCIATED_TYPE_SWITCH 0x00000004 844#define RNID_ASSOCIATED_TYPE_SWITCH 0x00000004
@@ -868,8 +855,8 @@ struct fc_echo_s {
868/* 855/*
869 * RNID els command payload 856 * RNID els command payload
870 */ 857 */
871struct fc_rnid_cmd_s{ 858struct fc_rnid_cmd_s {
872 struct fc_els_cmd_s els_cmd; 859 struct fc_els_cmd_s els_cmd;
873 u32 node_id_data_format:8; 860 u32 node_id_data_format:8;
874 u32 reserved:24; 861 u32 reserved:24;
875}; 862};
@@ -878,16 +865,16 @@ struct fc_rnid_cmd_s{
878 * RNID els response payload 865 * RNID els response payload
879 */ 866 */
880 867
881struct fc_rnid_common_id_data_s{ 868struct fc_rnid_common_id_data_s {
882 wwn_t port_name; 869 wwn_t port_name;
883 wwn_t node_name; 870 wwn_t node_name;
884}; 871};
885 872
886struct fc_rnid_general_topology_data_s{ 873struct fc_rnid_general_topology_data_s {
887 u32 vendor_unique[4]; 874 u32 vendor_unique[4];
888 u32 asso_type; 875 __be32 asso_type;
889 u32 phy_port_num; 876 u32 phy_port_num;
890 u32 num_attached_nodes; 877 __be32 num_attached_nodes;
891 u32 node_mgmt:8; 878 u32 node_mgmt:8;
892 u32 ip_version:8; 879 u32 ip_version:8;
893 u32 udp_tcp_port_num:16; 880 u32 udp_tcp_port_num:16;
@@ -896,8 +883,8 @@ struct fc_rnid_general_topology_data_s{
896 u32 vendor_specific:16; 883 u32 vendor_specific:16;
897}; 884};
898 885
899struct fc_rnid_acc_s{ 886struct fc_rnid_acc_s {
900 struct fc_els_cmd_s els_cmd; 887 struct fc_els_cmd_s els_cmd;
901 u32 node_id_data_format:8; 888 u32 node_id_data_format:8;
902 u32 common_id_data_length:8; 889 u32 common_id_data_length:8;
903 u32 reserved:8; 890 u32 reserved:8;
@@ -920,7 +907,7 @@ struct fc_rnid_acc_s{
920#define RNID_ASSOCIATED_TYPE_VIRTUALIZATION_DEVICE 0x00000003 907#define RNID_ASSOCIATED_TYPE_VIRTUALIZATION_DEVICE 0x00000003
921#define RNID_ASSOCIATED_TYPE_MULTI_FUNCTION_DEVICE 0x000000FF 908#define RNID_ASSOCIATED_TYPE_MULTI_FUNCTION_DEVICE 0x000000FF
922 909
923enum fc_rpsc_speed_cap{ 910enum fc_rpsc_speed_cap {
924 RPSC_SPEED_CAP_1G = 0x8000, 911 RPSC_SPEED_CAP_1G = 0x8000,
925 RPSC_SPEED_CAP_2G = 0x4000, 912 RPSC_SPEED_CAP_2G = 0x4000,
926 RPSC_SPEED_CAP_4G = 0x2000, 913 RPSC_SPEED_CAP_4G = 0x2000,
@@ -931,7 +918,7 @@ enum fc_rpsc_speed_cap{
931 RPSC_SPEED_CAP_UNKNOWN = 0x0001, 918 RPSC_SPEED_CAP_UNKNOWN = 0x0001,
932}; 919};
933 920
934enum fc_rpsc_op_speed_s{ 921enum fc_rpsc_op_speed {
935 RPSC_OP_SPEED_1G = 0x8000, 922 RPSC_OP_SPEED_1G = 0x8000,
936 RPSC_OP_SPEED_2G = 0x4000, 923 RPSC_OP_SPEED_2G = 0x4000,
937 RPSC_OP_SPEED_4G = 0x2000, 924 RPSC_OP_SPEED_4G = 0x2000,
@@ -939,67 +926,26 @@ enum fc_rpsc_op_speed_s{
939 RPSC_OP_SPEED_8G = 0x0800, 926 RPSC_OP_SPEED_8G = 0x0800,
940 RPSC_OP_SPEED_16G = 0x0400, 927 RPSC_OP_SPEED_16G = 0x0400,
941 928
942 RPSC_OP_SPEED_NOT_EST = 0x0001, /*! speed not established */ 929 RPSC_OP_SPEED_NOT_EST = 0x0001, /* speed not established */
943};
944
945struct fc_rpsc_speed_info_s{
946 u16 port_speed_cap; /*! see fc_rpsc_speed_cap_t */
947 u16 port_op_speed; /*! see fc_rpsc_op_speed_t */
948}; 930};
949 931
950enum link_e2e_beacon_subcmd{ 932struct fc_rpsc_speed_info_s {
951 LINK_E2E_BEACON_ON = 1, 933 __be16 port_speed_cap; /* see enum fc_rpsc_speed_cap */
952 LINK_E2E_BEACON_OFF = 2 934 __be16 port_op_speed; /* see enum fc_rpsc_op_speed */
953};
954
955enum beacon_type{
956 BEACON_TYPE_NORMAL = 1, /*! Normal Beaconing. Green */
957 BEACON_TYPE_WARN = 2, /*! Warning Beaconing. Yellow/Amber */
958 BEACON_TYPE_CRITICAL = 3 /*! Critical Beaconing. Red */
959};
960
961struct link_e2e_beacon_param_s {
962 u8 beacon_type; /* Beacon Type. See beacon_type_t */
963 u8 beacon_frequency;
964 /* Beacon frequency. Number of blinks
965 * per 10 seconds
966 */
967 u16 beacon_duration;/* Beacon duration (in Seconds). The
968 * command operation should be
969 * terminated at the end of this
970 * timeout value.
971 *
972 * Ignored if diag_sub_cmd is
973 * LINK_E2E_BEACON_OFF.
974 *
975 * If 0, beaconing will continue till a
976 * BEACON OFF request is received
977 */
978}; 935};
979 936
980/* 937/*
981 * Link E2E beacon request/good response format. For LS_RJTs use fc_ls_rjt_t
982 */
983struct link_e2e_beacon_req_s{
984 u32 ls_code; /*! FC_ELS_E2E_LBEACON in requests *
985 *or FC_ELS_ACC in good replies */
986 u32 ls_sub_cmd; /*! See link_e2e_beacon_subcmd_t */
987 struct link_e2e_beacon_param_s beacon_parm;
988};
989
990/**
991 * If RPSC request is sent to the Domain Controller, the request is for 938 * If RPSC request is sent to the Domain Controller, the request is for
992 * all the ports within that domain (TODO - I don't think FOS implements 939 * all the ports within that domain.
993 * this...).
994 */ 940 */
995struct fc_rpsc_cmd_s{ 941struct fc_rpsc_cmd_s {
996 struct fc_els_cmd_s els_cmd; 942 struct fc_els_cmd_s els_cmd;
997}; 943};
998 944
999/* 945/*
1000 * RPSC Acc 946 * RPSC Acc
1001 */ 947 */
1002struct fc_rpsc_acc_s{ 948struct fc_rpsc_acc_s {
1003 u32 command:8; 949 u32 command:8;
1004 u32 rsvd:8; 950 u32 rsvd:8;
1005 u32 num_entries:16; 951 u32 num_entries:16;
@@ -1007,23 +953,23 @@ struct fc_rpsc_acc_s{
1007 struct fc_rpsc_speed_info_s speed_info[1]; 953 struct fc_rpsc_speed_info_s speed_info[1];
1008}; 954};
1009 955
1010/** 956/*
1011 * If RPSC2 request is sent to the Domain Controller, 957 * If RPSC2 request is sent to the Domain Controller,
1012 */ 958 */
1013#define FC_BRCD_TOKEN 0x42524344 959#define FC_BRCD_TOKEN 0x42524344
1014 960
1015struct fc_rpsc2_cmd_s{ 961struct fc_rpsc2_cmd_s {
1016 struct fc_els_cmd_s els_cmd; 962 struct fc_els_cmd_s els_cmd;
1017 u32 token; 963 __be32 token;
1018 u16 resvd; 964 u16 resvd;
1019 u16 num_pids; /* Number of pids in the request */ 965 __be16 num_pids; /* Number of pids in the request */
1020 struct { 966 struct {
1021 u32 rsvd1:8; 967 u32 rsvd1:8;
1022 u32 pid:24; /* port identifier */ 968 u32 pid:24; /* port identifier */
1023 } pid_list[1]; 969 } pid_list[1];
1024}; 970};
1025 971
1026enum fc_rpsc2_port_type{ 972enum fc_rpsc2_port_type {
1027 RPSC2_PORT_TYPE_UNKNOWN = 0, 973 RPSC2_PORT_TYPE_UNKNOWN = 0,
1028 RPSC2_PORT_TYPE_NPORT = 1, 974 RPSC2_PORT_TYPE_NPORT = 1,
1029 RPSC2_PORT_TYPE_NLPORT = 2, 975 RPSC2_PORT_TYPE_NLPORT = 2,
@@ -1034,29 +980,29 @@ enum fc_rpsc2_port_type{
1034/* 980/*
1035 * RPSC2 portInfo entry structure 981 * RPSC2 portInfo entry structure
1036 */ 982 */
1037struct fc_rpsc2_port_info_s{ 983struct fc_rpsc2_port_info_s {
1038 u32 pid; /* PID */ 984 __be32 pid; /* PID */
1039 u16 resvd1; 985 u16 resvd1;
1040 u16 index; /* port number / index */ 986 __be16 index; /* port number / index */
1041 u8 resvd2; 987 u8 resvd2;
1042 u8 type; /* port type N/NL/... */ 988 u8 type; /* port type N/NL/... */
1043 u16 speed; /* port Operating Speed */ 989 __be16 speed; /* port Operating Speed */
1044}; 990};
1045 991
1046/* 992/*
1047 * RPSC2 Accept payload 993 * RPSC2 Accept payload
1048 */ 994 */
1049struct fc_rpsc2_acc_s{ 995struct fc_rpsc2_acc_s {
1050 u8 els_cmd; 996 u8 els_cmd;
1051 u8 resvd; 997 u8 resvd;
1052 u16 num_pids; /* Number of pids in the request */ 998 __be16 num_pids; /* Number of pids in the request */
1053 struct fc_rpsc2_port_info_s port_info[1]; /* port information */ 999 struct fc_rpsc2_port_info_s port_info[1]; /* port information */
1054}; 1000};
1055 1001
1056/** 1002/*
1057 * bit fields so that multiple classes can be specified 1003 * bit fields so that multiple classes can be specified
1058 */ 1004 */
1059enum fc_cos{ 1005enum fc_cos {
1060 FC_CLASS_2 = 0x04, 1006 FC_CLASS_2 = 0x04,
1061 FC_CLASS_3 = 0x08, 1007 FC_CLASS_3 = 0x08,
1062 FC_CLASS_2_3 = 0x0C, 1008 FC_CLASS_2_3 = 0x0C,
@@ -1065,22 +1011,18 @@ enum fc_cos{
1065/* 1011/*
1066 * symbolic name 1012 * symbolic name
1067 */ 1013 */
1068struct fc_symname_s{ 1014struct fc_symname_s {
1069 u8 symname[FC_SYMNAME_MAX]; 1015 u8 symname[FC_SYMNAME_MAX];
1070}; 1016};
1071 1017
1072struct fc_alpabm_s{
1073 u8 alpa_bm[FC_ALPA_MAX / 8];
1074};
1075
1076/* 1018/*
1077 * protocol default timeout values 1019 * protocol default timeout values
1078 */ 1020 */
1079#define FC_ED_TOV 2 1021#define FC_ED_TOV 2
1080#define FC_REC_TOV (FC_ED_TOV + 1) 1022#define FC_REC_TOV (FC_ED_TOV + 1)
1081#define FC_RA_TOV 10 1023#define FC_RA_TOV 10
1082#define FC_ELS_TOV (2 * FC_RA_TOV) 1024#define FC_ELS_TOV (2 * FC_RA_TOV)
1083#define FC_FCCT_TOV (3 * FC_RA_TOV) 1025#define FC_FCCT_TOV (3 * FC_RA_TOV)
1084 1026
1085/* 1027/*
1086 * virtual fabric related defines 1028 * virtual fabric related defines
@@ -1090,11 +1032,11 @@ struct fc_alpabm_s{
1090#define FC_VF_ID_MAX 0xEFF 1032#define FC_VF_ID_MAX 0xEFF
1091#define FC_VF_ID_CTL 0xFEF /* control VF_ID */ 1033#define FC_VF_ID_CTL 0xFEF /* control VF_ID */
1092 1034
1093/** 1035/*
1094 * Virtual Fabric Tagging header format 1036 * Virtual Fabric Tagging header format
1095 * @caution This is defined only in BIG ENDIAN format. 1037 * @caution This is defined only in BIG ENDIAN format.
1096 */ 1038 */
1097struct fc_vft_s{ 1039struct fc_vft_s {
1098 u32 r_ctl:8; 1040 u32 r_ctl:8;
1099 u32 ver:2; 1041 u32 ver:2;
1100 u32 type:4; 1042 u32 type:4;
@@ -1106,6 +1048,560 @@ struct fc_vft_s{
1106 u32 res_c:24; 1048 u32 res_c:24;
1107}; 1049};
1108 1050
1109#pragma pack() 1051/*
1052 * FCP
1053 */
1054enum {
1055 FCP_RJT = 0x01000000, /* SRR reject */
1056 FCP_SRR_ACCEPT = 0x02000000, /* SRR accept */
1057 FCP_SRR = 0x14000000, /* Sequence Retransmission Request */
1058};
1110 1059
1060/*
1061 * FCP_CMND definitions
1062 */
1063#define FCP_CMND_CDB_LEN 16
1064#define FCP_CMND_LUN_LEN 8
1065
1066struct fcp_cmnd_s {
1067 struct scsi_lun lun; /* 64-bit LU number */
1068 u8 crn; /* command reference number */
1069#ifdef __BIG_ENDIAN
1070 u8 resvd:1,
1071 priority:4, /* FCP-3: SAM-3 priority */
1072 taskattr:3; /* scsi task attribute */
1073#else
1074 u8 taskattr:3, /* scsi task attribute */
1075 priority:4, /* FCP-3: SAM-3 priority */
1076 resvd:1;
1077#endif
1078 u8 tm_flags; /* task management flags */
1079#ifdef __BIG_ENDIAN
1080 u8 addl_cdb_len:6, /* additional CDB length words */
1081 iodir:2; /* read/write FCP_DATA IUs */
1082#else
1083 u8 iodir:2, /* read/write FCP_DATA IUs */
1084 addl_cdb_len:6; /* additional CDB length */
1111#endif 1085#endif
1086 struct scsi_cdb_s cdb;
1087
1088 __be32 fcp_dl; /* bytes to be transferred */
1089};
1090
1091#define fcp_cmnd_cdb_len(_cmnd) ((_cmnd)->addl_cdb_len * 4 + FCP_CMND_CDB_LEN)
1092#define fcp_cmnd_fcpdl(_cmnd) ((&(_cmnd)->fcp_dl)[(_cmnd)->addl_cdb_len])
1093
1094/*
1095 * struct fcp_cmnd_s .iodir field values
1096 */
1097enum fcp_iodir {
1098 FCP_IODIR_NONE = 0,
1099 FCP_IODIR_WRITE = 1,
1100 FCP_IODIR_READ = 2,
1101 FCP_IODIR_RW = 3,
1102};
1103
1104/*
1105 * Task management flags field - only one bit shall be set
1106 */
1107enum fcp_tm_cmnd {
1108 FCP_TM_ABORT_TASK_SET = BIT(1),
1109 FCP_TM_CLEAR_TASK_SET = BIT(2),
1110 FCP_TM_LUN_RESET = BIT(4),
1111 FCP_TM_TARGET_RESET = BIT(5), /* obsolete in FCP-3 */
1112 FCP_TM_CLEAR_ACA = BIT(6),
1113};
1114
1115/*
1116 * FCP_RSP residue flags
1117 */
1118enum fcp_residue {
1119 FCP_NO_RESIDUE = 0, /* no residue */
1120 FCP_RESID_OVER = 1, /* more data left that was not sent */
1121 FCP_RESID_UNDER = 2, /* less data than requested */
1122};
1123
1124struct fcp_rspinfo_s {
1125 u32 res0:24;
1126 u32 rsp_code:8; /* response code (as above) */
1127 u32 res1;
1128};
1129
1130struct fcp_resp_s {
1131 u32 reserved[2]; /* 2 words reserved */
1132 u16 reserved2;
1133#ifdef __BIG_ENDIAN
1134 u8 reserved3:3;
1135 u8 fcp_conf_req:1; /* FCP_CONF is requested */
1136 u8 resid_flags:2; /* underflow/overflow */
1137 u8 sns_len_valid:1; /* sense len is valid */
1138 u8 rsp_len_valid:1; /* response len is valid */
1139#else
1140 u8 rsp_len_valid:1; /* response len is valid */
1141 u8 sns_len_valid:1; /* sense len is valid */
1142 u8 resid_flags:2; /* underflow/overflow */
1143 u8 fcp_conf_req:1; /* FCP_CONF is requested */
1144 u8 reserved3:3;
1145#endif
1146 u8 scsi_status; /* one byte SCSI status */
1147 u32 residue; /* residual data bytes */
1148 u32 sns_len; /* length od sense info */
1149 u32 rsp_len; /* length of response info */
1150};
1151
1152#define fcp_snslen(__fcprsp) ((__fcprsp)->sns_len_valid ? \
1153 (__fcprsp)->sns_len : 0)
1154#define fcp_rsplen(__fcprsp) ((__fcprsp)->rsp_len_valid ? \
1155 (__fcprsp)->rsp_len : 0)
1156#define fcp_rspinfo(__fcprsp) ((struct fcp_rspinfo_s *)((__fcprsp) + 1))
1157#define fcp_snsinfo(__fcprsp) (((u8 *)fcp_rspinfo(__fcprsp)) + \
1158 fcp_rsplen(__fcprsp))
1159/*
1160 * CT
1161 */
1162struct ct_hdr_s {
1163 u32 rev_id:8; /* Revision of the CT */
1164 u32 in_id:24; /* Initiator Id */
1165 u32 gs_type:8; /* Generic service Type */
1166 u32 gs_sub_type:8; /* Generic service sub type */
1167 u32 options:8; /* options */
1168 u32 rsvrd:8; /* reserved */
1169 u32 cmd_rsp_code:16;/* ct command/response code */
1170 u32 max_res_size:16;/* maximum/residual size */
1171 u32 frag_id:8; /* fragment ID */
1172 u32 reason_code:8; /* reason code */
1173 u32 exp_code:8; /* explanation code */
1174 u32 vendor_unq:8; /* vendor unique */
1175};
1176
1177/*
1178 * defines for the Revision
1179 */
1180enum {
1181 CT_GS3_REVISION = 0x01,
1182};
1183
1184/*
1185 * defines for gs_type
1186 */
1187enum {
1188 CT_GSTYPE_KEYSERVICE = 0xF7,
1189 CT_GSTYPE_ALIASSERVICE = 0xF8,
1190 CT_GSTYPE_MGMTSERVICE = 0xFA,
1191 CT_GSTYPE_TIMESERVICE = 0xFB,
1192 CT_GSTYPE_DIRSERVICE = 0xFC,
1193};
1194
1195/*
1196 * defines for gs_sub_type for gs type directory service
1197 */
1198enum {
1199 CT_GSSUBTYPE_NAMESERVER = 0x02,
1200};
1201
1202/*
1203 * defines for gs_sub_type for gs type management service
1204 */
1205enum {
1206 CT_GSSUBTYPE_CFGSERVER = 0x01,
1207 CT_GSSUBTYPE_UNZONED_NS = 0x02,
1208 CT_GSSUBTYPE_ZONESERVER = 0x03,
1209 CT_GSSUBTYPE_LOCKSERVER = 0x04,
1210 CT_GSSUBTYPE_HBA_MGMTSERVER = 0x10, /* for FDMI */
1211};
1212
1213/*
1214 * defines for CT response code field
1215 */
1216enum {
1217 CT_RSP_REJECT = 0x8001,
1218 CT_RSP_ACCEPT = 0x8002,
1219};
1220
1221/*
1222 * defintions for CT reason code
1223 */
1224enum {
1225 CT_RSN_INV_CMD = 0x01,
1226 CT_RSN_INV_VER = 0x02,
1227 CT_RSN_LOGIC_ERR = 0x03,
1228 CT_RSN_INV_SIZE = 0x04,
1229 CT_RSN_LOGICAL_BUSY = 0x05,
1230 CT_RSN_PROTO_ERR = 0x07,
1231 CT_RSN_UNABLE_TO_PERF = 0x09,
1232 CT_RSN_NOT_SUPP = 0x0B,
1233 CT_RSN_SERVER_NOT_AVBL = 0x0D,
1234 CT_RSN_SESSION_COULD_NOT_BE_ESTBD = 0x0E,
1235 CT_RSN_VENDOR_SPECIFIC = 0xFF,
1236
1237};
1238
1239/*
1240 * definitions for explanations code for Name server
1241 */
1242enum {
1243 CT_NS_EXP_NOADDITIONAL = 0x00,
1244 CT_NS_EXP_ID_NOT_REG = 0x01,
1245 CT_NS_EXP_PN_NOT_REG = 0x02,
1246 CT_NS_EXP_NN_NOT_REG = 0x03,
1247 CT_NS_EXP_CS_NOT_REG = 0x04,
1248 CT_NS_EXP_IPN_NOT_REG = 0x05,
1249 CT_NS_EXP_IPA_NOT_REG = 0x06,
1250 CT_NS_EXP_FT_NOT_REG = 0x07,
1251 CT_NS_EXP_SPN_NOT_REG = 0x08,
1252 CT_NS_EXP_SNN_NOT_REG = 0x09,
1253 CT_NS_EXP_PT_NOT_REG = 0x0A,
1254 CT_NS_EXP_IPP_NOT_REG = 0x0B,
1255 CT_NS_EXP_FPN_NOT_REG = 0x0C,
1256 CT_NS_EXP_HA_NOT_REG = 0x0D,
1257 CT_NS_EXP_FD_NOT_REG = 0x0E,
1258 CT_NS_EXP_FF_NOT_REG = 0x0F,
1259 CT_NS_EXP_ACCESSDENIED = 0x10,
1260 CT_NS_EXP_UNACCEPTABLE_ID = 0x11,
1261 CT_NS_EXP_DATABASEEMPTY = 0x12,
1262 CT_NS_EXP_NOT_REG_IN_SCOPE = 0x13,
1263 CT_NS_EXP_DOM_ID_NOT_PRESENT = 0x14,
1264 CT_NS_EXP_PORT_NUM_NOT_PRESENT = 0x15,
1265 CT_NS_EXP_NO_DEVICE_ATTACHED = 0x16
1266};
1267
1268/*
1269 * defintions for the explanation code for all servers
1270 */
1271enum {
1272 CT_EXP_AUTH_EXCEPTION = 0xF1,
1273 CT_EXP_DB_FULL = 0xF2,
1274 CT_EXP_DB_EMPTY = 0xF3,
1275 CT_EXP_PROCESSING_REQ = 0xF4,
1276 CT_EXP_UNABLE_TO_VERIFY_CONN = 0xF5,
1277 CT_EXP_DEVICES_NOT_IN_CMN_ZONE = 0xF6
1278};
1279
1280/*
1281 * Command codes for Name server
1282 */
1283enum {
1284 GS_GID_PN = 0x0121, /* Get Id on port name */
1285 GS_GPN_ID = 0x0112, /* Get port name on ID */
1286 GS_GNN_ID = 0x0113, /* Get node name on ID */
1287 GS_GID_FT = 0x0171, /* Get Id on FC4 type */
1288 GS_GSPN_ID = 0x0118, /* Get symbolic PN on ID */
1289 GS_RFT_ID = 0x0217, /* Register fc4type on ID */
1290 GS_RSPN_ID = 0x0218, /* Register symbolic PN on ID */
1291 GS_RPN_ID = 0x0212, /* Register port name */
1292 GS_RNN_ID = 0x0213, /* Register node name */
1293 GS_RCS_ID = 0x0214, /* Register class of service */
1294 GS_RPT_ID = 0x021A, /* Register port type */
1295 GS_GA_NXT = 0x0100, /* Get all next */
1296 GS_RFF_ID = 0x021F, /* Register FC4 Feature */
1297};
1298
1299struct fcgs_id_req_s {
1300 u32 rsvd:8;
1301 u32 dap:24; /* port identifier */
1302};
1303#define fcgs_gpnid_req_t struct fcgs_id_req_s
1304#define fcgs_gnnid_req_t struct fcgs_id_req_s
1305#define fcgs_gspnid_req_t struct fcgs_id_req_s
1306
1307struct fcgs_gidpn_req_s {
1308 wwn_t port_name; /* port wwn */
1309};
1310
1311struct fcgs_gidpn_resp_s {
1312 u32 rsvd:8;
1313 u32 dap:24; /* port identifier */
1314};
1315
1316/*
1317 * RFT_ID
1318 */
1319struct fcgs_rftid_req_s {
1320 u32 rsvd:8;
1321 u32 dap:24; /* port identifier */
1322 __be32 fc4_type[8]; /* fc4 types */
1323};
1324
1325/*
1326 * RFF_ID : Register FC4 features.
1327 */
1328#define FC_GS_FCP_FC4_FEATURE_INITIATOR 0x02
1329#define FC_GS_FCP_FC4_FEATURE_TARGET 0x01
1330
1331struct fcgs_rffid_req_s {
1332 u32 rsvd:8;
1333 u32 dap:24; /* port identifier */
1334 u32 rsvd1:16;
1335 u32 fc4ftr_bits:8; /* fc4 feature bits */
1336 u32 fc4_type:8; /* corresponding FC4 Type */
1337};
1338
1339/*
1340 * GID_FT Request
1341 */
1342struct fcgs_gidft_req_s {
1343 u8 reserved;
1344 u8 domain_id; /* domain, 0 - all fabric */
1345 u8 area_id; /* area, 0 - whole domain */
1346 u8 fc4_type; /* FC_TYPE_FCP for SCSI devices */
1347};
1348
1349/*
1350 * GID_FT Response
1351 */
1352struct fcgs_gidft_resp_s {
1353 u8 last:1; /* last port identifier flag */
1354 u8 reserved:7;
1355 u32 pid:24; /* port identifier */
1356};
1357
1358/*
1359 * RSPN_ID
1360 */
1361struct fcgs_rspnid_req_s {
1362 u32 rsvd:8;
1363 u32 dap:24; /* port identifier */
1364 u8 spn_len; /* symbolic port name length */
1365 u8 spn[256]; /* symbolic port name */
1366};
1367
1368/*
1369 * RPN_ID
1370 */
1371struct fcgs_rpnid_req_s {
1372 u32 rsvd:8;
1373 u32 port_id:24;
1374 wwn_t port_name;
1375};
1376
1377/*
1378 * RNN_ID
1379 */
1380struct fcgs_rnnid_req_s {
1381 u32 rsvd:8;
1382 u32 port_id:24;
1383 wwn_t node_name;
1384};
1385
1386/*
1387 * RCS_ID
1388 */
1389struct fcgs_rcsid_req_s {
1390 u32 rsvd:8;
1391 u32 port_id:24;
1392 u32 cos;
1393};
1394
1395/*
1396 * RPT_ID
1397 */
1398struct fcgs_rptid_req_s {
1399 u32 rsvd:8;
1400 u32 port_id:24;
1401 u32 port_type:8;
1402 u32 rsvd1:24;
1403};
1404
1405/*
1406 * GA_NXT Request
1407 */
1408struct fcgs_ganxt_req_s {
1409 u32 rsvd:8;
1410 u32 port_id:24;
1411};
1412
1413/*
1414 * GA_NXT Response
1415 */
1416struct fcgs_ganxt_rsp_s {
1417 u32 port_type:8; /* Port Type */
1418 u32 port_id:24; /* Port Identifier */
1419 wwn_t port_name; /* Port Name */
1420 u8 spn_len; /* Length of Symbolic Port Name */
1421 char spn[255]; /* Symbolic Port Name */
1422 wwn_t node_name; /* Node Name */
1423 u8 snn_len; /* Length of Symbolic Node Name */
1424 char snn[255]; /* Symbolic Node Name */
1425 u8 ipa[8]; /* Initial Process Associator */
1426 u8 ip[16]; /* IP Address */
1427 u32 cos; /* Class of Service */
1428 u32 fc4types[8]; /* FC-4 TYPEs */
1429 wwn_t fabric_port_name; /* Fabric Port Name */
1430 u32 rsvd:8; /* Reserved */
1431 u32 hard_addr:24; /* Hard Address */
1432};
1433
1434/*
1435 * Command codes for Fabric Configuration Server
1436 */
1437enum {
1438 GS_FC_GFN_CMD = 0x0114, /* GS FC Get Fabric Name */
1439 GS_FC_GMAL_CMD = 0x0116, /* GS FC GMAL */
1440 GS_FC_TRACE_CMD = 0x0400, /* GS FC Trace Route */
1441 GS_FC_PING_CMD = 0x0401, /* GS FC Ping */
1442};
1443
1444/*
1445 * GMAL Command ( Get ( interconnect Element) Management Address List)
1446 * To retrieve the IP Address of a Switch.
1447 */
1448#define CT_GMAL_RESP_PREFIX_TELNET "telnet://"
1449#define CT_GMAL_RESP_PREFIX_HTTP "http://"
1450
1451/* GMAL/GFN request */
1452struct fcgs_req_s {
1453 wwn_t wwn; /* PWWN/NWWN */
1454};
1455
1456#define fcgs_gmal_req_t struct fcgs_req_s
1457#define fcgs_gfn_req_t struct fcgs_req_s
1458
1459/* Accept Response to GMAL */
1460struct fcgs_gmal_resp_s {
1461 __be32 ms_len; /* Num of entries */
1462 u8 ms_ma[256];
1463};
1464
1465struct fcgs_gmal_entry_s {
1466 u8 len;
1467 u8 prefix[7]; /* like "http://" */
1468 u8 ip_addr[248];
1469};
1470
1471/*
1472 * FDMI Command Codes
1473 */
1474#define FDMI_GRHL 0x0100
1475#define FDMI_GHAT 0x0101
1476#define FDMI_GRPL 0x0102
1477#define FDMI_GPAT 0x0110
1478#define FDMI_RHBA 0x0200
1479#define FDMI_RHAT 0x0201
1480#define FDMI_RPRT 0x0210
1481#define FDMI_RPA 0x0211
1482#define FDMI_DHBA 0x0300
1483#define FDMI_DPRT 0x0310
1484
1485/*
1486 * FDMI reason codes
1487 */
1488#define FDMI_NO_ADDITIONAL_EXP 0x00
1489#define FDMI_HBA_ALREADY_REG 0x10
1490#define FDMI_HBA_ATTRIB_NOT_REG 0x11
1491#define FDMI_HBA_ATTRIB_MULTIPLE 0x12
1492#define FDMI_HBA_ATTRIB_LENGTH_INVALID 0x13
1493#define FDMI_HBA_ATTRIB_NOT_PRESENT 0x14
1494#define FDMI_PORT_ORIG_NOT_IN_LIST 0x15
1495#define FDMI_PORT_HBA_NOT_IN_LIST 0x16
1496#define FDMI_PORT_ATTRIB_NOT_REG 0x20
1497#define FDMI_PORT_NOT_REG 0x21
1498#define FDMI_PORT_ATTRIB_MULTIPLE 0x22
1499#define FDMI_PORT_ATTRIB_LENGTH_INVALID 0x23
1500#define FDMI_PORT_ALREADY_REGISTEREED 0x24
1501
1502/*
1503 * FDMI Transmission Speed Mask values
1504 */
1505#define FDMI_TRANS_SPEED_1G 0x00000001
1506#define FDMI_TRANS_SPEED_2G 0x00000002
1507#define FDMI_TRANS_SPEED_10G 0x00000004
1508#define FDMI_TRANS_SPEED_4G 0x00000008
1509#define FDMI_TRANS_SPEED_8G 0x00000010
1510#define FDMI_TRANS_SPEED_16G 0x00000020
1511#define FDMI_TRANS_SPEED_UNKNOWN 0x00008000
1512
1513/*
1514 * FDMI HBA attribute types
1515 */
1516enum fdmi_hba_attribute_type {
1517 FDMI_HBA_ATTRIB_NODENAME = 1, /* 0x0001 */
1518 FDMI_HBA_ATTRIB_MANUFACTURER, /* 0x0002 */
1519 FDMI_HBA_ATTRIB_SERIALNUM, /* 0x0003 */
1520 FDMI_HBA_ATTRIB_MODEL, /* 0x0004 */
1521 FDMI_HBA_ATTRIB_MODEL_DESC, /* 0x0005 */
1522 FDMI_HBA_ATTRIB_HW_VERSION, /* 0x0006 */
1523 FDMI_HBA_ATTRIB_DRIVER_VERSION, /* 0x0007 */
1524 FDMI_HBA_ATTRIB_ROM_VERSION, /* 0x0008 */
1525 FDMI_HBA_ATTRIB_FW_VERSION, /* 0x0009 */
1526 FDMI_HBA_ATTRIB_OS_NAME, /* 0x000A */
1527 FDMI_HBA_ATTRIB_MAX_CT, /* 0x000B */
1528
1529 FDMI_HBA_ATTRIB_MAX_TYPE
1530};
1531
1532/*
1533 * FDMI Port attribute types
1534 */
1535enum fdmi_port_attribute_type {
1536 FDMI_PORT_ATTRIB_FC4_TYPES = 1, /* 0x0001 */
1537 FDMI_PORT_ATTRIB_SUPP_SPEED, /* 0x0002 */
1538 FDMI_PORT_ATTRIB_PORT_SPEED, /* 0x0003 */
1539 FDMI_PORT_ATTRIB_FRAME_SIZE, /* 0x0004 */
1540 FDMI_PORT_ATTRIB_DEV_NAME, /* 0x0005 */
1541 FDMI_PORT_ATTRIB_HOST_NAME, /* 0x0006 */
1542
1543 FDMI_PORT_ATTR_MAX_TYPE
1544};
1545
1546/*
1547 * FDMI attribute
1548 */
1549struct fdmi_attr_s {
1550 __be16 type;
1551 __be16 len;
1552 u8 value[1];
1553};
1554
1555/*
1556 * HBA Attribute Block
1557 */
1558struct fdmi_hba_attr_s {
1559 __be32 attr_count; /* # of attributes */
1560 struct fdmi_attr_s hba_attr; /* n attributes */
1561};
1562
1563/*
1564 * Registered Port List
1565 */
1566struct fdmi_port_list_s {
1567 __be32 num_ports; /* number Of Port Entries */
1568 wwn_t port_entry; /* one or more */
1569};
1570
1571/*
1572 * Port Attribute Block
1573 */
1574struct fdmi_port_attr_s {
1575 __be32 attr_count; /* # of attributes */
1576 struct fdmi_attr_s port_attr; /* n attributes */
1577};
1578
1579/*
1580 * FDMI Register HBA Attributes
1581 */
1582struct fdmi_rhba_s {
1583 wwn_t hba_id; /* HBA Identifier */
1584 struct fdmi_port_list_s port_list; /* Registered Port List */
1585 struct fdmi_hba_attr_s hba_attr_blk; /* HBA attribute block */
1586};
1587
1588/*
1589 * FDMI Register Port
1590 */
1591struct fdmi_rprt_s {
1592 wwn_t hba_id; /* HBA Identifier */
1593 wwn_t port_name; /* Port wwn */
1594 struct fdmi_port_attr_s port_attr_blk; /* Port Attr Block */
1595};
1596
1597/*
1598 * FDMI Register Port Attributes
1599 */
1600struct fdmi_rpa_s {
1601 wwn_t port_name; /* port wwn */
1602 struct fdmi_port_attr_s port_attr_blk; /* Port Attr Block */
1603};
1604
1605#pragma pack()
1606
1607#endif /* __BFA_FC_H__ */
diff --git a/drivers/scsi/bfa/fcbuild.c b/drivers/scsi/bfa/bfa_fcbuild.c
index fee5456451cb..b7e253451654 100644
--- a/drivers/scsi/bfa/fcbuild.c
+++ b/drivers/scsi/bfa/bfa_fcbuild.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -18,25 +18,25 @@
18 * fcbuild.c - FC link service frame building and parsing routines 18 * fcbuild.c - FC link service frame building and parsing routines
19 */ 19 */
20 20
21#include <bfa_os_inc.h> 21#include "bfad_drv.h"
22#include "fcbuild.h" 22#include "bfa_fcbuild.h"
23 23
24/* 24/*
25 * static build functions 25 * static build functions
26 */ 26 */
27static void fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, 27static void fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
28 u16 ox_id); 28 __be16 ox_id);
29static void fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, 29static void fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
30 u16 ox_id); 30 __be16 ox_id);
31static struct fchs_s fc_els_req_tmpl; 31static struct fchs_s fc_els_req_tmpl;
32static struct fchs_s fc_els_rsp_tmpl; 32static struct fchs_s fc_els_rsp_tmpl;
33static struct fchs_s fc_bls_req_tmpl; 33static struct fchs_s fc_bls_req_tmpl;
34static struct fchs_s fc_bls_rsp_tmpl; 34static struct fchs_s fc_bls_rsp_tmpl;
35static struct fc_ba_acc_s ba_acc_tmpl; 35static struct fc_ba_acc_s ba_acc_tmpl;
36static struct fc_logi_s plogi_tmpl; 36static struct fc_logi_s plogi_tmpl;
37static struct fc_prli_s prli_tmpl; 37static struct fc_prli_s prli_tmpl;
38static struct fc_rrq_s rrq_tmpl; 38static struct fc_rrq_s rrq_tmpl;
39static struct fchs_s fcp_fchs_tmpl; 39static struct fchs_s fcp_fchs_tmpl;
40 40
41void 41void
42fcbuild_init(void) 42fcbuild_init(void)
@@ -48,7 +48,7 @@ fcbuild_init(void)
48 fc_els_req_tmpl.cat_info = FC_CAT_LD_REQUEST; 48 fc_els_req_tmpl.cat_info = FC_CAT_LD_REQUEST;
49 fc_els_req_tmpl.type = FC_TYPE_ELS; 49 fc_els_req_tmpl.type = FC_TYPE_ELS;
50 fc_els_req_tmpl.f_ctl = 50 fc_els_req_tmpl.f_ctl =
51 bfa_os_hton3b(FCTL_SEQ_INI | FCTL_FS_EXCH | FCTL_END_SEQ | 51 bfa_hton3b(FCTL_SEQ_INI | FCTL_FS_EXCH | FCTL_END_SEQ |
52 FCTL_SI_XFER); 52 FCTL_SI_XFER);
53 fc_els_req_tmpl.rx_id = FC_RXID_ANY; 53 fc_els_req_tmpl.rx_id = FC_RXID_ANY;
54 54
@@ -59,7 +59,7 @@ fcbuild_init(void)
59 fc_els_rsp_tmpl.cat_info = FC_CAT_LD_REPLY; 59 fc_els_rsp_tmpl.cat_info = FC_CAT_LD_REPLY;
60 fc_els_rsp_tmpl.type = FC_TYPE_ELS; 60 fc_els_rsp_tmpl.type = FC_TYPE_ELS;
61 fc_els_rsp_tmpl.f_ctl = 61 fc_els_rsp_tmpl.f_ctl =
62 bfa_os_hton3b(FCTL_EC_RESP | FCTL_SEQ_INI | FCTL_LS_EXCH | 62 bfa_hton3b(FCTL_EC_RESP | FCTL_SEQ_INI | FCTL_LS_EXCH |
63 FCTL_END_SEQ | FCTL_SI_XFER); 63 FCTL_END_SEQ | FCTL_SI_XFER);
64 fc_els_rsp_tmpl.rx_id = FC_RXID_ANY; 64 fc_els_rsp_tmpl.rx_id = FC_RXID_ANY;
65 65
@@ -68,7 +68,7 @@ fcbuild_init(void)
68 */ 68 */
69 fc_bls_req_tmpl.routing = FC_RTG_BASIC_LINK; 69 fc_bls_req_tmpl.routing = FC_RTG_BASIC_LINK;
70 fc_bls_req_tmpl.type = FC_TYPE_BLS; 70 fc_bls_req_tmpl.type = FC_TYPE_BLS;
71 fc_bls_req_tmpl.f_ctl = bfa_os_hton3b(FCTL_END_SEQ | FCTL_SI_XFER); 71 fc_bls_req_tmpl.f_ctl = bfa_hton3b(FCTL_END_SEQ | FCTL_SI_XFER);
72 fc_bls_req_tmpl.rx_id = FC_RXID_ANY; 72 fc_bls_req_tmpl.rx_id = FC_RXID_ANY;
73 73
74 /* 74 /*
@@ -78,7 +78,7 @@ fcbuild_init(void)
78 fc_bls_rsp_tmpl.cat_info = FC_CAT_BA_ACC; 78 fc_bls_rsp_tmpl.cat_info = FC_CAT_BA_ACC;
79 fc_bls_rsp_tmpl.type = FC_TYPE_BLS; 79 fc_bls_rsp_tmpl.type = FC_TYPE_BLS;
80 fc_bls_rsp_tmpl.f_ctl = 80 fc_bls_rsp_tmpl.f_ctl =
81 bfa_os_hton3b(FCTL_EC_RESP | FCTL_SEQ_INI | FCTL_LS_EXCH | 81 bfa_hton3b(FCTL_EC_RESP | FCTL_SEQ_INI | FCTL_LS_EXCH |
82 FCTL_END_SEQ | FCTL_SI_XFER); 82 FCTL_END_SEQ | FCTL_SI_XFER);
83 fc_bls_rsp_tmpl.rx_id = FC_RXID_ANY; 83 fc_bls_rsp_tmpl.rx_id = FC_RXID_ANY;
84 84
@@ -94,13 +94,13 @@ fcbuild_init(void)
94 */ 94 */
95 plogi_tmpl.csp.verhi = FC_PH_VER_PH_3; 95 plogi_tmpl.csp.verhi = FC_PH_VER_PH_3;
96 plogi_tmpl.csp.verlo = FC_PH_VER_4_3; 96 plogi_tmpl.csp.verlo = FC_PH_VER_4_3;
97 plogi_tmpl.csp.bbcred = bfa_os_htons(0x0004); 97 plogi_tmpl.csp.bbcred = cpu_to_be16(0x0004);
98 plogi_tmpl.csp.ciro = 0x1; 98 plogi_tmpl.csp.ciro = 0x1;
99 plogi_tmpl.csp.cisc = 0x0; 99 plogi_tmpl.csp.cisc = 0x0;
100 plogi_tmpl.csp.altbbcred = 0x0; 100 plogi_tmpl.csp.altbbcred = 0x0;
101 plogi_tmpl.csp.conseq = bfa_os_htons(0x00FF); 101 plogi_tmpl.csp.conseq = cpu_to_be16(0x00FF);
102 plogi_tmpl.csp.ro_bitmap = bfa_os_htons(0x0002); 102 plogi_tmpl.csp.ro_bitmap = cpu_to_be16(0x0002);
103 plogi_tmpl.csp.e_d_tov = bfa_os_htonl(2000); 103 plogi_tmpl.csp.e_d_tov = cpu_to_be32(2000);
104 104
105 plogi_tmpl.class3.class_valid = 1; 105 plogi_tmpl.class3.class_valid = 1;
106 plogi_tmpl.class3.sequential = 1; 106 plogi_tmpl.class3.sequential = 1;
@@ -112,7 +112,7 @@ fcbuild_init(void)
112 */ 112 */
113 prli_tmpl.command = FC_ELS_PRLI; 113 prli_tmpl.command = FC_ELS_PRLI;
114 prli_tmpl.pglen = 0x10; 114 prli_tmpl.pglen = 0x10;
115 prli_tmpl.pagebytes = bfa_os_htons(0x0014); 115 prli_tmpl.pagebytes = cpu_to_be16(0x0014);
116 prli_tmpl.parampage.type = FC_TYPE_FCP; 116 prli_tmpl.parampage.type = FC_TYPE_FCP;
117 prli_tmpl.parampage.imagepair = 1; 117 prli_tmpl.parampage.imagepair = 1;
118 prli_tmpl.parampage.servparams.rxrdisab = 1; 118 prli_tmpl.parampage.servparams.rxrdisab = 1;
@@ -123,55 +123,52 @@ fcbuild_init(void)
123 rrq_tmpl.els_cmd.els_code = FC_ELS_RRQ; 123 rrq_tmpl.els_cmd.els_code = FC_ELS_RRQ;
124 124
125 /* 125 /*
126 * fcp_fchs_tmpl 126 * fcp_struct fchs_s mpl
127 */ 127 */
128 fcp_fchs_tmpl.routing = FC_RTG_FC4_DEV_DATA; 128 fcp_fchs_tmpl.routing = FC_RTG_FC4_DEV_DATA;
129 fcp_fchs_tmpl.cat_info = FC_CAT_UNSOLICIT_CMD; 129 fcp_fchs_tmpl.cat_info = FC_CAT_UNSOLICIT_CMD;
130 fcp_fchs_tmpl.type = FC_TYPE_FCP; 130 fcp_fchs_tmpl.type = FC_TYPE_FCP;
131 fcp_fchs_tmpl.f_ctl = 131 fcp_fchs_tmpl.f_ctl =
132 bfa_os_hton3b(FCTL_FS_EXCH | FCTL_END_SEQ | FCTL_SI_XFER); 132 bfa_hton3b(FCTL_FS_EXCH | FCTL_END_SEQ | FCTL_SI_XFER);
133 fcp_fchs_tmpl.seq_id = 1; 133 fcp_fchs_tmpl.seq_id = 1;
134 fcp_fchs_tmpl.rx_id = FC_RXID_ANY; 134 fcp_fchs_tmpl.rx_id = FC_RXID_ANY;
135} 135}
136 136
137static void 137static void
138fc_gs_fchdr_build(struct fchs_s *fchs, u32 d_id, u32 s_id, 138fc_gs_fchdr_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u32 ox_id)
139 u32 ox_id)
140{ 139{
141 bfa_os_memset(fchs, 0, sizeof(struct fchs_s)); 140 memset(fchs, 0, sizeof(struct fchs_s));
142 141
143 fchs->routing = FC_RTG_FC4_DEV_DATA; 142 fchs->routing = FC_RTG_FC4_DEV_DATA;
144 fchs->cat_info = FC_CAT_UNSOLICIT_CTRL; 143 fchs->cat_info = FC_CAT_UNSOLICIT_CTRL;
145 fchs->type = FC_TYPE_SERVICES; 144 fchs->type = FC_TYPE_SERVICES;
146 fchs->f_ctl = 145 fchs->f_ctl =
147 bfa_os_hton3b(FCTL_SEQ_INI | FCTL_FS_EXCH | FCTL_END_SEQ | 146 bfa_hton3b(FCTL_SEQ_INI | FCTL_FS_EXCH | FCTL_END_SEQ |
148 FCTL_SI_XFER); 147 FCTL_SI_XFER);
149 fchs->rx_id = FC_RXID_ANY; 148 fchs->rx_id = FC_RXID_ANY;
150 fchs->d_id = (d_id); 149 fchs->d_id = (d_id);
151 fchs->s_id = (s_id); 150 fchs->s_id = (s_id);
152 fchs->ox_id = bfa_os_htons(ox_id); 151 fchs->ox_id = cpu_to_be16(ox_id);
153 152
154 /** 153 /*
155 * @todo no need to set ox_id for request 154 * @todo no need to set ox_id for request
156 * no need to set rx_id for response 155 * no need to set rx_id for response
157 */ 156 */
158} 157}
159 158
160void 159void
161fc_els_req_build(struct fchs_s *fchs, u32 d_id, u32 s_id, 160fc_els_req_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id)
162 u16 ox_id)
163{ 161{
164 bfa_os_memcpy(fchs, &fc_els_req_tmpl, sizeof(struct fchs_s)); 162 memcpy(fchs, &fc_els_req_tmpl, sizeof(struct fchs_s));
165 fchs->d_id = (d_id); 163 fchs->d_id = (d_id);
166 fchs->s_id = (s_id); 164 fchs->s_id = (s_id);
167 fchs->ox_id = bfa_os_htons(ox_id); 165 fchs->ox_id = cpu_to_be16(ox_id);
168} 166}
169 167
170static void 168static void
171fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, 169fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id)
172 u16 ox_id)
173{ 170{
174 bfa_os_memcpy(fchs, &fc_els_rsp_tmpl, sizeof(struct fchs_s)); 171 memcpy(fchs, &fc_els_rsp_tmpl, sizeof(struct fchs_s));
175 fchs->d_id = d_id; 172 fchs->d_id = d_id;
176 fchs->s_id = s_id; 173 fchs->s_id = s_id;
177 fchs->ox_id = ox_id; 174 fchs->ox_id = ox_id;
@@ -180,8 +177,8 @@ fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
180enum fc_parse_status 177enum fc_parse_status
181fc_els_rsp_parse(struct fchs_s *fchs, int len) 178fc_els_rsp_parse(struct fchs_s *fchs, int len)
182{ 179{
183 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1); 180 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
184 struct fc_ls_rjt_s *ls_rjt = (struct fc_ls_rjt_s *) els_cmd; 181 struct fc_ls_rjt_s *ls_rjt = (struct fc_ls_rjt_s *) els_cmd;
185 182
186 len = len; 183 len = len;
187 184
@@ -199,10 +196,9 @@ fc_els_rsp_parse(struct fchs_s *fchs, int len)
199} 196}
200 197
201static void 198static void
202fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, 199fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id)
203 u16 ox_id)
204{ 200{
205 bfa_os_memcpy(fchs, &fc_bls_rsp_tmpl, sizeof(struct fchs_s)); 201 memcpy(fchs, &fc_bls_rsp_tmpl, sizeof(struct fchs_s));
206 fchs->d_id = d_id; 202 fchs->d_id = d_id;
207 fchs->s_id = s_id; 203 fchs->s_id = s_id;
208 fchs->ox_id = ox_id; 204 fchs->ox_id = ox_id;
@@ -210,12 +206,12 @@ fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
210 206
211static u16 207static u16
212fc_plogi_x_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id, 208fc_plogi_x_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
213 u16 ox_id, wwn_t port_name, wwn_t node_name, 209 __be16 ox_id, wwn_t port_name, wwn_t node_name,
214 u16 pdu_size, u8 els_code) 210 u16 pdu_size, u8 els_code)
215{ 211{
216 struct fc_logi_s *plogi = (struct fc_logi_s *) (pld); 212 struct fc_logi_s *plogi = (struct fc_logi_s *) (pld);
217 213
218 bfa_os_memcpy(plogi, &plogi_tmpl, sizeof(struct fc_logi_s)); 214 memcpy(plogi, &plogi_tmpl, sizeof(struct fc_logi_s));
219 215
220 plogi->els_cmd.els_code = els_code; 216 plogi->els_cmd.els_code = els_code;
221 if (els_code == FC_ELS_PLOGI) 217 if (els_code == FC_ELS_PLOGI)
@@ -223,29 +219,28 @@ fc_plogi_x_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
223 else 219 else
224 fc_els_rsp_build(fchs, d_id, s_id, ox_id); 220 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
225 221
226 plogi->csp.rxsz = plogi->class3.rxsz = bfa_os_htons(pdu_size); 222 plogi->csp.rxsz = plogi->class3.rxsz = cpu_to_be16(pdu_size);
227 223
228 bfa_os_memcpy(&plogi->port_name, &port_name, sizeof(wwn_t)); 224 memcpy(&plogi->port_name, &port_name, sizeof(wwn_t));
229 bfa_os_memcpy(&plogi->node_name, &node_name, sizeof(wwn_t)); 225 memcpy(&plogi->node_name, &node_name, sizeof(wwn_t));
230 226
231 return sizeof(struct fc_logi_s); 227 return sizeof(struct fc_logi_s);
232} 228}
233 229
234u16 230u16
235fc_flogi_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id, 231fc_flogi_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
236 u16 ox_id, wwn_t port_name, wwn_t node_name, 232 u16 ox_id, wwn_t port_name, wwn_t node_name, u16 pdu_size,
237 u16 pdu_size, u8 set_npiv, u8 set_auth, 233 u8 set_npiv, u8 set_auth, u16 local_bb_credits)
238 u16 local_bb_credits)
239{ 234{
240 u32 d_id = bfa_os_hton3b(FC_FABRIC_PORT); 235 u32 d_id = bfa_hton3b(FC_FABRIC_PORT);
241 u32 *vvl_info; 236 __be32 *vvl_info;
242 237
243 bfa_os_memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s)); 238 memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s));
244 239
245 flogi->els_cmd.els_code = FC_ELS_FLOGI; 240 flogi->els_cmd.els_code = FC_ELS_FLOGI;
246 fc_els_req_build(fchs, d_id, s_id, ox_id); 241 fc_els_req_build(fchs, d_id, s_id, ox_id);
247 242
248 flogi->csp.rxsz = flogi->class3.rxsz = bfa_os_htons(pdu_size); 243 flogi->csp.rxsz = flogi->class3.rxsz = cpu_to_be16(pdu_size);
249 flogi->port_name = port_name; 244 flogi->port_name = port_name;
250 flogi->node_name = node_name; 245 flogi->node_name = node_name;
251 246
@@ -258,51 +253,50 @@ fc_flogi_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
258 /* set AUTH capability */ 253 /* set AUTH capability */
259 flogi->csp.security = set_auth; 254 flogi->csp.security = set_auth;
260 255
261 flogi->csp.bbcred = bfa_os_htons(local_bb_credits); 256 flogi->csp.bbcred = cpu_to_be16(local_bb_credits);
262 257
263 /* Set brcd token in VVL */ 258 /* Set brcd token in VVL */
264 vvl_info = (u32 *)&flogi->vvl[0]; 259 vvl_info = (u32 *)&flogi->vvl[0];
265 260
266 /* set the flag to indicate the presence of VVL */ 261 /* set the flag to indicate the presence of VVL */
267 flogi->csp.npiv_supp = 1; /* @todo. field name is not correct */ 262 flogi->csp.npiv_supp = 1; /* @todo. field name is not correct */
268 vvl_info[0] = bfa_os_htonl(FLOGI_VVL_BRCD); 263 vvl_info[0] = cpu_to_be32(FLOGI_VVL_BRCD);
269 264
270 return sizeof(struct fc_logi_s); 265 return sizeof(struct fc_logi_s);
271} 266}
272 267
273u16 268u16
274fc_flogi_acc_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id, 269fc_flogi_acc_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
275 u16 ox_id, wwn_t port_name, wwn_t node_name, 270 __be16 ox_id, wwn_t port_name, wwn_t node_name,
276 u16 pdu_size, u16 local_bb_credits) 271 u16 pdu_size, u16 local_bb_credits)
277{ 272{
278 u32 d_id = 0; 273 u32 d_id = 0;
279 274
280 bfa_os_memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s)); 275 memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s));
281 fc_els_rsp_build(fchs, d_id, s_id, ox_id); 276 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
282 277
283 flogi->els_cmd.els_code = FC_ELS_ACC; 278 flogi->els_cmd.els_code = FC_ELS_ACC;
284 flogi->csp.rxsz = flogi->class3.rxsz = bfa_os_htons(pdu_size); 279 flogi->csp.rxsz = flogi->class3.rxsz = cpu_to_be16(pdu_size);
285 flogi->port_name = port_name; 280 flogi->port_name = port_name;
286 flogi->node_name = node_name; 281 flogi->node_name = node_name;
287 282
288 flogi->csp.bbcred = bfa_os_htons(local_bb_credits); 283 flogi->csp.bbcred = cpu_to_be16(local_bb_credits);
289 284
290 return sizeof(struct fc_logi_s); 285 return sizeof(struct fc_logi_s);
291} 286}
292 287
293u16 288u16
294fc_fdisc_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id, 289fc_fdisc_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
295 u16 ox_id, wwn_t port_name, wwn_t node_name, 290 u16 ox_id, wwn_t port_name, wwn_t node_name, u16 pdu_size)
296 u16 pdu_size)
297{ 291{
298 u32 d_id = bfa_os_hton3b(FC_FABRIC_PORT); 292 u32 d_id = bfa_hton3b(FC_FABRIC_PORT);
299 293
300 bfa_os_memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s)); 294 memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s));
301 295
302 flogi->els_cmd.els_code = FC_ELS_FDISC; 296 flogi->els_cmd.els_code = FC_ELS_FDISC;
303 fc_els_req_build(fchs, d_id, s_id, ox_id); 297 fc_els_req_build(fchs, d_id, s_id, ox_id);
304 298
305 flogi->csp.rxsz = flogi->class3.rxsz = bfa_os_htons(pdu_size); 299 flogi->csp.rxsz = flogi->class3.rxsz = cpu_to_be16(pdu_size);
306 flogi->port_name = port_name; 300 flogi->port_name = port_name;
307 flogi->node_name = node_name; 301 flogi->node_name = node_name;
308 302
@@ -330,9 +324,9 @@ fc_plogi_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
330enum fc_parse_status 324enum fc_parse_status
331fc_plogi_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name) 325fc_plogi_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
332{ 326{
333 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1); 327 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
334 struct fc_logi_s *plogi; 328 struct fc_logi_s *plogi;
335 struct fc_ls_rjt_s *ls_rjt; 329 struct fc_ls_rjt_s *ls_rjt;
336 330
337 switch (els_cmd->els_code) { 331 switch (els_cmd->els_code) {
338 case FC_ELS_LS_RJT: 332 case FC_ELS_LS_RJT:
@@ -352,7 +346,7 @@ fc_plogi_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
352 if (!plogi->class3.class_valid) 346 if (!plogi->class3.class_valid)
353 return FC_PARSE_FAILURE; 347 return FC_PARSE_FAILURE;
354 348
355 if (bfa_os_ntohs(plogi->class3.rxsz) < (FC_MIN_PDUSZ)) 349 if (be16_to_cpu(plogi->class3.rxsz) < (FC_MIN_PDUSZ))
356 return FC_PARSE_FAILURE; 350 return FC_PARSE_FAILURE;
357 351
358 return FC_PARSE_OK; 352 return FC_PARSE_OK;
@@ -364,13 +358,13 @@ fc_plogi_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
364enum fc_parse_status 358enum fc_parse_status
365fc_plogi_parse(struct fchs_s *fchs) 359fc_plogi_parse(struct fchs_s *fchs)
366{ 360{
367 struct fc_logi_s *plogi = (struct fc_logi_s *) (fchs + 1); 361 struct fc_logi_s *plogi = (struct fc_logi_s *) (fchs + 1);
368 362
369 if (plogi->class3.class_valid != 1) 363 if (plogi->class3.class_valid != 1)
370 return FC_PARSE_FAILURE; 364 return FC_PARSE_FAILURE;
371 365
372 if ((bfa_os_ntohs(plogi->class3.rxsz) < FC_MIN_PDUSZ) 366 if ((be16_to_cpu(plogi->class3.rxsz) < FC_MIN_PDUSZ)
373 || (bfa_os_ntohs(plogi->class3.rxsz) > FC_MAX_PDUSZ) 367 || (be16_to_cpu(plogi->class3.rxsz) > FC_MAX_PDUSZ)
374 || (plogi->class3.rxsz == 0)) 368 || (plogi->class3.rxsz == 0))
375 return FC_PARSE_FAILURE; 369 return FC_PARSE_FAILURE;
376 370
@@ -381,10 +375,10 @@ u16
381fc_prli_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id, 375fc_prli_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
382 u16 ox_id) 376 u16 ox_id)
383{ 377{
384 struct fc_prli_s *prli = (struct fc_prli_s *) (pld); 378 struct fc_prli_s *prli = (struct fc_prli_s *) (pld);
385 379
386 fc_els_req_build(fchs, d_id, s_id, ox_id); 380 fc_els_req_build(fchs, d_id, s_id, ox_id);
387 bfa_os_memcpy(prli, &prli_tmpl, sizeof(struct fc_prli_s)); 381 memcpy(prli, &prli_tmpl, sizeof(struct fc_prli_s));
388 382
389 prli->command = FC_ELS_PRLI; 383 prli->command = FC_ELS_PRLI;
390 prli->parampage.servparams.initiator = 1; 384 prli->parampage.servparams.initiator = 1;
@@ -398,19 +392,16 @@ fc_prli_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
398 392
399u16 393u16
400fc_prli_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id, 394fc_prli_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
401 u16 ox_id, enum bfa_port_role role) 395 __be16 ox_id, enum bfa_lport_role role)
402{ 396{
403 struct fc_prli_s *prli = (struct fc_prli_s *) (pld); 397 struct fc_prli_s *prli = (struct fc_prli_s *) (pld);
404 398
405 fc_els_rsp_build(fchs, d_id, s_id, ox_id); 399 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
406 bfa_os_memcpy(prli, &prli_tmpl, sizeof(struct fc_prli_s)); 400 memcpy(prli, &prli_tmpl, sizeof(struct fc_prli_s));
407 401
408 prli->command = FC_ELS_ACC; 402 prli->command = FC_ELS_ACC;
409 403
410 if ((role & BFA_PORT_ROLE_FCP_TM) == BFA_PORT_ROLE_FCP_TM) 404 prli->parampage.servparams.initiator = 1;
411 prli->parampage.servparams.target = 1;
412 else
413 prli->parampage.servparams.initiator = 1;
414 405
415 prli->parampage.rspcode = FC_PRLI_ACC_XQTD; 406 prli->parampage.rspcode = FC_PRLI_ACC_XQTD;
416 407
@@ -452,8 +443,8 @@ fc_prli_parse(struct fc_prli_s *prli)
452} 443}
453 444
454u16 445u16
455fc_logo_build(struct fchs_s *fchs, struct fc_logo_s *logo, u32 d_id, 446fc_logo_build(struct fchs_s *fchs, struct fc_logo_s *logo, u32 d_id, u32 s_id,
456 u32 s_id, u16 ox_id, wwn_t port_name) 447 u16 ox_id, wwn_t port_name)
457{ 448{
458 fc_els_req_build(fchs, d_id, s_id, ox_id); 449 fc_els_req_build(fchs, d_id, s_id, ox_id);
459 450
@@ -465,9 +456,9 @@ fc_logo_build(struct fchs_s *fchs, struct fc_logo_s *logo, u32 d_id,
465 return sizeof(struct fc_logo_s); 456 return sizeof(struct fc_logo_s);
466} 457}
467 458
468static u16 459static u16
469fc_adisc_x_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id, 460fc_adisc_x_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
470 u32 s_id, u16 ox_id, wwn_t port_name, 461 u32 s_id, __be16 ox_id, wwn_t port_name,
471 wwn_t node_name, u8 els_code) 462 wwn_t node_name, u8 els_code)
472{ 463{
473 memset(adisc, '\0', sizeof(struct fc_adisc_s)); 464 memset(adisc, '\0', sizeof(struct fc_adisc_s));
@@ -489,8 +480,7 @@ fc_adisc_x_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
489 480
490u16 481u16
491fc_adisc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id, 482fc_adisc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
492 u32 s_id, u16 ox_id, wwn_t port_name, 483 u32 s_id, __be16 ox_id, wwn_t port_name, wwn_t node_name)
493 wwn_t node_name)
494{ 484{
495 return fc_adisc_x_build(fchs, adisc, d_id, s_id, ox_id, port_name, 485 return fc_adisc_x_build(fchs, adisc, d_id, s_id, ox_id, port_name,
496 node_name, FC_ELS_ADISC); 486 node_name, FC_ELS_ADISC);
@@ -498,7 +488,7 @@ fc_adisc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
498 488
499u16 489u16
500fc_adisc_acc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id, 490fc_adisc_acc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
501 u32 s_id, u16 ox_id, wwn_t port_name, 491 u32 s_id, __be16 ox_id, wwn_t port_name,
502 wwn_t node_name) 492 wwn_t node_name)
503{ 493{
504 return fc_adisc_x_build(fchs, adisc, d_id, s_id, ox_id, port_name, 494 return fc_adisc_x_build(fchs, adisc, d_id, s_id, ox_id, port_name,
@@ -523,10 +513,10 @@ fc_adisc_rsp_parse(struct fc_adisc_s *adisc, int len, wwn_t port_name,
523} 513}
524 514
525enum fc_parse_status 515enum fc_parse_status
526fc_adisc_parse(struct fchs_s *fchs, void *pld, u32 host_dap, 516fc_adisc_parse(struct fchs_s *fchs, void *pld, u32 host_dap, wwn_t node_name,
527 wwn_t node_name, wwn_t port_name) 517 wwn_t port_name)
528{ 518{
529 struct fc_adisc_s *adisc = (struct fc_adisc_s *) pld; 519 struct fc_adisc_s *adisc = (struct fc_adisc_s *) pld;
530 520
531 if (adisc->els_cmd.els_code != FC_ELS_ACC) 521 if (adisc->els_cmd.els_code != FC_ELS_ACC)
532 return FC_PARSE_FAILURE; 522 return FC_PARSE_FAILURE;
@@ -542,13 +532,13 @@ fc_adisc_parse(struct fchs_s *fchs, void *pld, u32 host_dap,
542enum fc_parse_status 532enum fc_parse_status
543fc_pdisc_parse(struct fchs_s *fchs, wwn_t node_name, wwn_t port_name) 533fc_pdisc_parse(struct fchs_s *fchs, wwn_t node_name, wwn_t port_name)
544{ 534{
545 struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1); 535 struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
546 536
547 if (pdisc->class3.class_valid != 1) 537 if (pdisc->class3.class_valid != 1)
548 return FC_PARSE_FAILURE; 538 return FC_PARSE_FAILURE;
549 539
550 if ((bfa_os_ntohs(pdisc->class3.rxsz) < 540 if ((be16_to_cpu(pdisc->class3.rxsz) <
551 (FC_MIN_PDUSZ - sizeof(struct fchs_s))) 541 (FC_MIN_PDUSZ - sizeof(struct fchs_s)))
552 || (pdisc->class3.rxsz == 0)) 542 || (pdisc->class3.rxsz == 0))
553 return FC_PARSE_FAILURE; 543 return FC_PARSE_FAILURE;
554 544
@@ -564,11 +554,11 @@ fc_pdisc_parse(struct fchs_s *fchs, wwn_t node_name, wwn_t port_name)
564u16 554u16
565fc_abts_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id) 555fc_abts_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id)
566{ 556{
567 bfa_os_memcpy(fchs, &fc_bls_req_tmpl, sizeof(struct fchs_s)); 557 memcpy(fchs, &fc_bls_req_tmpl, sizeof(struct fchs_s));
568 fchs->cat_info = FC_CAT_ABTS; 558 fchs->cat_info = FC_CAT_ABTS;
569 fchs->d_id = (d_id); 559 fchs->d_id = (d_id);
570 fchs->s_id = (s_id); 560 fchs->s_id = (s_id);
571 fchs->ox_id = bfa_os_htons(ox_id); 561 fchs->ox_id = cpu_to_be16(ox_id);
572 562
573 return sizeof(struct fchs_s); 563 return sizeof(struct fchs_s);
574} 564}
@@ -584,17 +574,17 @@ fc_abts_rsp_parse(struct fchs_s *fchs, int len)
584} 574}
585 575
586u16 576u16
587fc_rrq_build(struct fchs_s *fchs, struct fc_rrq_s *rrq, u32 d_id, 577fc_rrq_build(struct fchs_s *fchs, struct fc_rrq_s *rrq, u32 d_id, u32 s_id,
588 u32 s_id, u16 ox_id, u16 rrq_oxid) 578 u16 ox_id, u16 rrq_oxid)
589{ 579{
590 fc_els_req_build(fchs, d_id, s_id, ox_id); 580 fc_els_req_build(fchs, d_id, s_id, ox_id);
591 581
592 /* 582 /*
593 * build rrq payload 583 * build rrq payload
594 */ 584 */
595 bfa_os_memcpy(rrq, &rrq_tmpl, sizeof(struct fc_rrq_s)); 585 memcpy(rrq, &rrq_tmpl, sizeof(struct fc_rrq_s));
596 rrq->s_id = (s_id); 586 rrq->s_id = (s_id);
597 rrq->ox_id = bfa_os_htons(rrq_oxid); 587 rrq->ox_id = cpu_to_be16(rrq_oxid);
598 rrq->rx_id = FC_RXID_ANY; 588 rrq->rx_id = FC_RXID_ANY;
599 589
600 return sizeof(struct fc_rrq_s); 590 return sizeof(struct fc_rrq_s);
@@ -602,9 +592,9 @@ fc_rrq_build(struct fchs_s *fchs, struct fc_rrq_s *rrq, u32 d_id,
602 592
603u16 593u16
604fc_logo_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id, 594fc_logo_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
605 u16 ox_id) 595 __be16 ox_id)
606{ 596{
607 struct fc_els_cmd_s *acc = pld; 597 struct fc_els_cmd_s *acc = pld;
608 598
609 fc_els_rsp_build(fchs, d_id, s_id, ox_id); 599 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
610 600
@@ -616,7 +606,7 @@ fc_logo_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
616 606
617u16 607u16
618fc_ls_rjt_build(struct fchs_s *fchs, struct fc_ls_rjt_s *ls_rjt, u32 d_id, 608fc_ls_rjt_build(struct fchs_s *fchs, struct fc_ls_rjt_s *ls_rjt, u32 d_id,
619 u32 s_id, u16 ox_id, u8 reason_code, 609 u32 s_id, __be16 ox_id, u8 reason_code,
620 u8 reason_code_expl) 610 u8 reason_code_expl)
621{ 611{
622 fc_els_rsp_build(fchs, d_id, s_id, ox_id); 612 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
@@ -632,11 +622,11 @@ fc_ls_rjt_build(struct fchs_s *fchs, struct fc_ls_rjt_s *ls_rjt, u32 d_id,
632 622
633u16 623u16
634fc_ba_acc_build(struct fchs_s *fchs, struct fc_ba_acc_s *ba_acc, u32 d_id, 624fc_ba_acc_build(struct fchs_s *fchs, struct fc_ba_acc_s *ba_acc, u32 d_id,
635 u32 s_id, u16 ox_id, u16 rx_id) 625 u32 s_id, __be16 ox_id, u16 rx_id)
636{ 626{
637 fc_bls_rsp_build(fchs, d_id, s_id, ox_id); 627 fc_bls_rsp_build(fchs, d_id, s_id, ox_id);
638 628
639 bfa_os_memcpy(ba_acc, &ba_acc_tmpl, sizeof(struct fc_ba_acc_s)); 629 memcpy(ba_acc, &ba_acc_tmpl, sizeof(struct fc_ba_acc_s));
640 630
641 fchs->rx_id = rx_id; 631 fchs->rx_id = rx_id;
642 632
@@ -647,8 +637,8 @@ fc_ba_acc_build(struct fchs_s *fchs, struct fc_ba_acc_s *ba_acc, u32 d_id,
647} 637}
648 638
649u16 639u16
650fc_ls_acc_build(struct fchs_s *fchs, struct fc_els_cmd_s *els_cmd, 640fc_ls_acc_build(struct fchs_s *fchs, struct fc_els_cmd_s *els_cmd, u32 d_id,
651 u32 d_id, u32 s_id, u16 ox_id) 641 u32 s_id, __be16 ox_id)
652{ 642{
653 fc_els_rsp_build(fchs, d_id, s_id, ox_id); 643 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
654 memset(els_cmd, 0, sizeof(struct fc_els_cmd_s)); 644 memset(els_cmd, 0, sizeof(struct fc_els_cmd_s));
@@ -661,23 +651,22 @@ int
661fc_logout_params_pages(struct fchs_s *fc_frame, u8 els_code) 651fc_logout_params_pages(struct fchs_s *fc_frame, u8 els_code)
662{ 652{
663 int num_pages = 0; 653 int num_pages = 0;
664 struct fc_prlo_s *prlo; 654 struct fc_prlo_s *prlo;
665 struct fc_tprlo_s *tprlo; 655 struct fc_tprlo_s *tprlo;
666 656
667 if (els_code == FC_ELS_PRLO) { 657 if (els_code == FC_ELS_PRLO) {
668 prlo = (struct fc_prlo_s *) (fc_frame + 1); 658 prlo = (struct fc_prlo_s *) (fc_frame + 1);
669 num_pages = (bfa_os_ntohs(prlo->payload_len) - 4) / 16; 659 num_pages = (be16_to_cpu(prlo->payload_len) - 4) / 16;
670 } else { 660 } else {
671 tprlo = (struct fc_tprlo_s *) (fc_frame + 1); 661 tprlo = (struct fc_tprlo_s *) (fc_frame + 1);
672 num_pages = (bfa_os_ntohs(tprlo->payload_len) - 4) / 16; 662 num_pages = (be16_to_cpu(tprlo->payload_len) - 4) / 16;
673 } 663 }
674 return num_pages; 664 return num_pages;
675} 665}
676 666
677u16 667u16
678fc_tprlo_acc_build(struct fchs_s *fchs, struct fc_tprlo_acc_s *tprlo_acc, 668fc_tprlo_acc_build(struct fchs_s *fchs, struct fc_tprlo_acc_s *tprlo_acc,
679 u32 d_id, u32 s_id, u16 ox_id, 669 u32 d_id, u32 s_id, __be16 ox_id, int num_pages)
680 int num_pages)
681{ 670{
682 int page; 671 int page;
683 672
@@ -687,7 +676,7 @@ fc_tprlo_acc_build(struct fchs_s *fchs, struct fc_tprlo_acc_s *tprlo_acc,
687 tprlo_acc->command = FC_ELS_ACC; 676 tprlo_acc->command = FC_ELS_ACC;
688 677
689 tprlo_acc->page_len = 0x10; 678 tprlo_acc->page_len = 0x10;
690 tprlo_acc->payload_len = bfa_os_htons((num_pages * 16) + 4); 679 tprlo_acc->payload_len = cpu_to_be16((num_pages * 16) + 4);
691 680
692 for (page = 0; page < num_pages; page++) { 681 for (page = 0; page < num_pages; page++) {
693 tprlo_acc->tprlo_acc_params[page].opa_valid = 0; 682 tprlo_acc->tprlo_acc_params[page].opa_valid = 0;
@@ -696,13 +685,12 @@ fc_tprlo_acc_build(struct fchs_s *fchs, struct fc_tprlo_acc_s *tprlo_acc,
696 tprlo_acc->tprlo_acc_params[page].orig_process_assc = 0; 685 tprlo_acc->tprlo_acc_params[page].orig_process_assc = 0;
697 tprlo_acc->tprlo_acc_params[page].resp_process_assc = 0; 686 tprlo_acc->tprlo_acc_params[page].resp_process_assc = 0;
698 } 687 }
699 return bfa_os_ntohs(tprlo_acc->payload_len); 688 return be16_to_cpu(tprlo_acc->payload_len);
700} 689}
701 690
702u16 691u16
703fc_prlo_acc_build(struct fchs_s *fchs, struct fc_prlo_acc_s *prlo_acc, 692fc_prlo_acc_build(struct fchs_s *fchs, struct fc_prlo_acc_s *prlo_acc, u32 d_id,
704 u32 d_id, u32 s_id, u16 ox_id, 693 u32 s_id, __be16 ox_id, int num_pages)
705 int num_pages)
706{ 694{
707 int page; 695 int page;
708 696
@@ -711,7 +699,7 @@ fc_prlo_acc_build(struct fchs_s *fchs, struct fc_prlo_acc_s *prlo_acc,
711 memset(prlo_acc, 0, (num_pages * 16) + 4); 699 memset(prlo_acc, 0, (num_pages * 16) + 4);
712 prlo_acc->command = FC_ELS_ACC; 700 prlo_acc->command = FC_ELS_ACC;
713 prlo_acc->page_len = 0x10; 701 prlo_acc->page_len = 0x10;
714 prlo_acc->payload_len = bfa_os_htons((num_pages * 16) + 4); 702 prlo_acc->payload_len = cpu_to_be16((num_pages * 16) + 4);
715 703
716 for (page = 0; page < num_pages; page++) { 704 for (page = 0; page < num_pages; page++) {
717 prlo_acc->prlo_acc_params[page].opa_valid = 0; 705 prlo_acc->prlo_acc_params[page].opa_valid = 0;
@@ -721,12 +709,12 @@ fc_prlo_acc_build(struct fchs_s *fchs, struct fc_prlo_acc_s *prlo_acc,
721 prlo_acc->prlo_acc_params[page].resp_process_assc = 0; 709 prlo_acc->prlo_acc_params[page].resp_process_assc = 0;
722 } 710 }
723 711
724 return bfa_os_ntohs(prlo_acc->payload_len); 712 return be16_to_cpu(prlo_acc->payload_len);
725} 713}
726 714
727u16 715u16
728fc_rnid_build(struct fchs_s *fchs, struct fc_rnid_cmd_s *rnid, u32 d_id, 716fc_rnid_build(struct fchs_s *fchs, struct fc_rnid_cmd_s *rnid, u32 d_id,
729 u32 s_id, u16 ox_id, u32 data_format) 717 u32 s_id, u16 ox_id, u32 data_format)
730{ 718{
731 fc_els_req_build(fchs, d_id, s_id, ox_id); 719 fc_els_req_build(fchs, d_id, s_id, ox_id);
732 720
@@ -739,11 +727,10 @@ fc_rnid_build(struct fchs_s *fchs, struct fc_rnid_cmd_s *rnid, u32 d_id,
739} 727}
740 728
741u16 729u16
742fc_rnid_acc_build(struct fchs_s *fchs, struct fc_rnid_acc_s *rnid_acc, 730fc_rnid_acc_build(struct fchs_s *fchs, struct fc_rnid_acc_s *rnid_acc, u32 d_id,
743 u32 d_id, u32 s_id, u16 ox_id, 731 u32 s_id, __be16 ox_id, u32 data_format,
744 u32 data_format, 732 struct fc_rnid_common_id_data_s *common_id_data,
745 struct fc_rnid_common_id_data_s *common_id_data, 733 struct fc_rnid_general_topology_data_s *gen_topo_data)
746 struct fc_rnid_general_topology_data_s *gen_topo_data)
747{ 734{
748 memset(rnid_acc, 0, sizeof(struct fc_rnid_acc_s)); 735 memset(rnid_acc, 0, sizeof(struct fc_rnid_acc_s));
749 736
@@ -758,7 +745,7 @@ fc_rnid_acc_build(struct fchs_s *fchs, struct fc_rnid_acc_s *rnid_acc,
758 if (data_format == RNID_NODEID_DATA_FORMAT_DISCOVERY) { 745 if (data_format == RNID_NODEID_DATA_FORMAT_DISCOVERY) {
759 rnid_acc->specific_id_data_length = 746 rnid_acc->specific_id_data_length =
760 sizeof(struct fc_rnid_general_topology_data_s); 747 sizeof(struct fc_rnid_general_topology_data_s);
761 bfa_os_assign(rnid_acc->gen_topology_data, *gen_topo_data); 748 rnid_acc->gen_topology_data = *gen_topo_data;
762 return sizeof(struct fc_rnid_acc_s); 749 return sizeof(struct fc_rnid_acc_s);
763 } else { 750 } else {
764 return sizeof(struct fc_rnid_acc_s) - 751 return sizeof(struct fc_rnid_acc_s) -
@@ -769,7 +756,7 @@ fc_rnid_acc_build(struct fchs_s *fchs, struct fc_rnid_acc_s *rnid_acc,
769 756
770u16 757u16
771fc_rpsc_build(struct fchs_s *fchs, struct fc_rpsc_cmd_s *rpsc, u32 d_id, 758fc_rpsc_build(struct fchs_s *fchs, struct fc_rpsc_cmd_s *rpsc, u32 d_id,
772 u32 s_id, u16 ox_id) 759 u32 s_id, u16 ox_id)
773{ 760{
774 fc_els_req_build(fchs, d_id, s_id, ox_id); 761 fc_els_req_build(fchs, d_id, s_id, ox_id);
775 762
@@ -780,58 +767,50 @@ fc_rpsc_build(struct fchs_s *fchs, struct fc_rpsc_cmd_s *rpsc, u32 d_id,
780} 767}
781 768
782u16 769u16
783fc_rpsc2_build(struct fchs_s *fchs, struct fc_rpsc2_cmd_s *rpsc2, 770fc_rpsc2_build(struct fchs_s *fchs, struct fc_rpsc2_cmd_s *rpsc2, u32 d_id,
784 u32 d_id, u32 s_id, u32 *pid_list, 771 u32 s_id, u32 *pid_list, u16 npids)
785 u16 npids)
786{ 772{
787 u32 dctlr_id = FC_DOMAIN_CTRLR(bfa_os_hton3b(d_id)); 773 u32 dctlr_id = FC_DOMAIN_CTRLR(bfa_hton3b(d_id));
788 int i = 0; 774 int i = 0;
789 775
790 fc_els_req_build(fchs, bfa_os_hton3b(dctlr_id), s_id, 0); 776 fc_els_req_build(fchs, bfa_hton3b(dctlr_id), s_id, 0);
791 777
792 memset(rpsc2, 0, sizeof(struct fc_rpsc2_cmd_s)); 778 memset(rpsc2, 0, sizeof(struct fc_rpsc2_cmd_s));
793 779
794 rpsc2->els_cmd.els_code = FC_ELS_RPSC; 780 rpsc2->els_cmd.els_code = FC_ELS_RPSC;
795 rpsc2->token = bfa_os_htonl(FC_BRCD_TOKEN); 781 rpsc2->token = cpu_to_be32(FC_BRCD_TOKEN);
796 rpsc2->num_pids = bfa_os_htons(npids); 782 rpsc2->num_pids = cpu_to_be16(npids);
797 for (i = 0; i < npids; i++) 783 for (i = 0; i < npids; i++)
798 rpsc2->pid_list[i].pid = pid_list[i]; 784 rpsc2->pid_list[i].pid = pid_list[i];
799 785
800 return sizeof(struct fc_rpsc2_cmd_s) + ((npids - 1) * 786 return sizeof(struct fc_rpsc2_cmd_s) + ((npids - 1) * (sizeof(u32)));
801 (sizeof(u32)));
802} 787}
803 788
804u16 789u16
805fc_rpsc_acc_build(struct fchs_s *fchs, struct fc_rpsc_acc_s *rpsc_acc, 790fc_rpsc_acc_build(struct fchs_s *fchs, struct fc_rpsc_acc_s *rpsc_acc,
806 u32 d_id, u32 s_id, u16 ox_id, 791 u32 d_id, u32 s_id, __be16 ox_id,
807 struct fc_rpsc_speed_info_s *oper_speed) 792 struct fc_rpsc_speed_info_s *oper_speed)
808{ 793{
809 memset(rpsc_acc, 0, sizeof(struct fc_rpsc_acc_s)); 794 memset(rpsc_acc, 0, sizeof(struct fc_rpsc_acc_s));
810 795
811 fc_els_rsp_build(fchs, d_id, s_id, ox_id); 796 fc_els_rsp_build(fchs, d_id, s_id, ox_id);
812 797
813 rpsc_acc->command = FC_ELS_ACC; 798 rpsc_acc->command = FC_ELS_ACC;
814 rpsc_acc->num_entries = bfa_os_htons(1); 799 rpsc_acc->num_entries = cpu_to_be16(1);
815 800
816 rpsc_acc->speed_info[0].port_speed_cap = 801 rpsc_acc->speed_info[0].port_speed_cap =
817 bfa_os_htons(oper_speed->port_speed_cap); 802 cpu_to_be16(oper_speed->port_speed_cap);
818 803
819 rpsc_acc->speed_info[0].port_op_speed = 804 rpsc_acc->speed_info[0].port_op_speed =
820 bfa_os_htons(oper_speed->port_op_speed); 805 cpu_to_be16(oper_speed->port_op_speed);
821 806
822 return sizeof(struct fc_rpsc_acc_s); 807 return sizeof(struct fc_rpsc_acc_s);
823
824} 808}
825 809
826/*
827 * TBD -
828 * . get rid of unnecessary memsets
829 */
830
831u16 810u16
832fc_logo_rsp_parse(struct fchs_s *fchs, int len) 811fc_logo_rsp_parse(struct fchs_s *fchs, int len)
833{ 812{
834 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1); 813 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
835 814
836 len = len; 815 len = len;
837 if (els_cmd->els_code != FC_ELS_ACC) 816 if (els_cmd->els_code != FC_ELS_ACC)
@@ -841,18 +820,17 @@ fc_logo_rsp_parse(struct fchs_s *fchs, int len)
841} 820}
842 821
843u16 822u16
844fc_pdisc_build(struct fchs_s *fchs, u32 d_id, u32 s_id, 823fc_pdisc_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
845 u16 ox_id, wwn_t port_name, wwn_t node_name, 824 wwn_t port_name, wwn_t node_name, u16 pdu_size)
846 u16 pdu_size)
847{ 825{
848 struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1); 826 struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
849 827
850 bfa_os_memcpy(pdisc, &plogi_tmpl, sizeof(struct fc_logi_s)); 828 memcpy(pdisc, &plogi_tmpl, sizeof(struct fc_logi_s));
851 829
852 pdisc->els_cmd.els_code = FC_ELS_PDISC; 830 pdisc->els_cmd.els_code = FC_ELS_PDISC;
853 fc_els_req_build(fchs, d_id, s_id, ox_id); 831 fc_els_req_build(fchs, d_id, s_id, ox_id);
854 832
855 pdisc->csp.rxsz = pdisc->class3.rxsz = bfa_os_htons(pdu_size); 833 pdisc->csp.rxsz = pdisc->class3.rxsz = cpu_to_be16(pdu_size);
856 pdisc->port_name = port_name; 834 pdisc->port_name = port_name;
857 pdisc->node_name = node_name; 835 pdisc->node_name = node_name;
858 836
@@ -862,7 +840,7 @@ fc_pdisc_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
862u16 840u16
863fc_pdisc_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name) 841fc_pdisc_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
864{ 842{
865 struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1); 843 struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
866 844
867 if (len < sizeof(struct fc_logi_s)) 845 if (len < sizeof(struct fc_logi_s))
868 return FC_PARSE_LEN_INVAL; 846 return FC_PARSE_LEN_INVAL;
@@ -876,7 +854,7 @@ fc_pdisc_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
876 if (!pdisc->class3.class_valid) 854 if (!pdisc->class3.class_valid)
877 return FC_PARSE_NWWN_NOT_EQUAL; 855 return FC_PARSE_NWWN_NOT_EQUAL;
878 856
879 if (bfa_os_ntohs(pdisc->class3.rxsz) < (FC_MIN_PDUSZ)) 857 if (be16_to_cpu(pdisc->class3.rxsz) < (FC_MIN_PDUSZ))
880 return FC_PARSE_RXSZ_INVAL; 858 return FC_PARSE_RXSZ_INVAL;
881 859
882 return FC_PARSE_OK; 860 return FC_PARSE_OK;
@@ -886,14 +864,14 @@ u16
886fc_prlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id, 864fc_prlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
887 int num_pages) 865 int num_pages)
888{ 866{
889 struct fc_prlo_s *prlo = (struct fc_prlo_s *) (fchs + 1); 867 struct fc_prlo_s *prlo = (struct fc_prlo_s *) (fchs + 1);
890 int page; 868 int page;
891 869
892 fc_els_req_build(fchs, d_id, s_id, ox_id); 870 fc_els_req_build(fchs, d_id, s_id, ox_id);
893 memset(prlo, 0, (num_pages * 16) + 4); 871 memset(prlo, 0, (num_pages * 16) + 4);
894 prlo->command = FC_ELS_PRLO; 872 prlo->command = FC_ELS_PRLO;
895 prlo->page_len = 0x10; 873 prlo->page_len = 0x10;
896 prlo->payload_len = bfa_os_htons((num_pages * 16) + 4); 874 prlo->payload_len = cpu_to_be16((num_pages * 16) + 4);
897 875
898 for (page = 0; page < num_pages; page++) { 876 for (page = 0; page < num_pages; page++) {
899 prlo->prlo_params[page].type = FC_TYPE_FCP; 877 prlo->prlo_params[page].type = FC_TYPE_FCP;
@@ -903,13 +881,13 @@ fc_prlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
903 prlo->prlo_params[page].resp_process_assc = 0; 881 prlo->prlo_params[page].resp_process_assc = 0;
904 } 882 }
905 883
906 return bfa_os_ntohs(prlo->payload_len); 884 return be16_to_cpu(prlo->payload_len);
907} 885}
908 886
909u16 887u16
910fc_prlo_rsp_parse(struct fchs_s *fchs, int len) 888fc_prlo_rsp_parse(struct fchs_s *fchs, int len)
911{ 889{
912 struct fc_prlo_acc_s *prlo = (struct fc_prlo_acc_s *) (fchs + 1); 890 struct fc_prlo_acc_s *prlo = (struct fc_prlo_acc_s *) (fchs + 1);
913 int num_pages = 0; 891 int num_pages = 0;
914 int page = 0; 892 int page = 0;
915 893
@@ -918,7 +896,7 @@ fc_prlo_rsp_parse(struct fchs_s *fchs, int len)
918 if (prlo->command != FC_ELS_ACC) 896 if (prlo->command != FC_ELS_ACC)
919 return FC_PARSE_FAILURE; 897 return FC_PARSE_FAILURE;
920 898
921 num_pages = ((bfa_os_ntohs(prlo->payload_len)) - 4) / 16; 899 num_pages = ((be16_to_cpu(prlo->payload_len)) - 4) / 16;
922 900
923 for (page = 0; page < num_pages; page++) { 901 for (page = 0; page < num_pages; page++) {
924 if (prlo->prlo_acc_params[page].type != FC_TYPE_FCP) 902 if (prlo->prlo_acc_params[page].type != FC_TYPE_FCP)
@@ -941,18 +919,17 @@ fc_prlo_rsp_parse(struct fchs_s *fchs, int len)
941} 919}
942 920
943u16 921u16
944fc_tprlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, 922fc_tprlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
945 u16 ox_id, int num_pages, 923 int num_pages, enum fc_tprlo_type tprlo_type, u32 tpr_id)
946 enum fc_tprlo_type tprlo_type, u32 tpr_id)
947{ 924{
948 struct fc_tprlo_s *tprlo = (struct fc_tprlo_s *) (fchs + 1); 925 struct fc_tprlo_s *tprlo = (struct fc_tprlo_s *) (fchs + 1);
949 int page; 926 int page;
950 927
951 fc_els_req_build(fchs, d_id, s_id, ox_id); 928 fc_els_req_build(fchs, d_id, s_id, ox_id);
952 memset(tprlo, 0, (num_pages * 16) + 4); 929 memset(tprlo, 0, (num_pages * 16) + 4);
953 tprlo->command = FC_ELS_TPRLO; 930 tprlo->command = FC_ELS_TPRLO;
954 tprlo->page_len = 0x10; 931 tprlo->page_len = 0x10;
955 tprlo->payload_len = bfa_os_htons((num_pages * 16) + 4); 932 tprlo->payload_len = cpu_to_be16((num_pages * 16) + 4);
956 933
957 for (page = 0; page < num_pages; page++) { 934 for (page = 0; page < num_pages; page++) {
958 tprlo->tprlo_params[page].type = FC_TYPE_FCP; 935 tprlo->tprlo_params[page].type = FC_TYPE_FCP;
@@ -968,7 +945,7 @@ fc_tprlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
968 } 945 }
969 } 946 }
970 947
971 return bfa_os_ntohs(tprlo->payload_len); 948 return be16_to_cpu(tprlo->payload_len);
972} 949}
973 950
974u16 951u16
@@ -983,7 +960,7 @@ fc_tprlo_rsp_parse(struct fchs_s *fchs, int len)
983 if (tprlo->command != FC_ELS_ACC) 960 if (tprlo->command != FC_ELS_ACC)
984 return FC_PARSE_ACC_INVAL; 961 return FC_PARSE_ACC_INVAL;
985 962
986 num_pages = (bfa_os_ntohs(tprlo->payload_len) - 4) / 16; 963 num_pages = (be16_to_cpu(tprlo->payload_len) - 4) / 16;
987 964
988 for (page = 0; page < num_pages; page++) { 965 for (page = 0; page < num_pages; page++) {
989 if (tprlo->tprlo_acc_params[page].type != FC_TYPE_FCP) 966 if (tprlo->tprlo_acc_params[page].type != FC_TYPE_FCP)
@@ -1003,7 +980,7 @@ fc_tprlo_rsp_parse(struct fchs_s *fchs, int len)
1003enum fc_parse_status 980enum fc_parse_status
1004fc_rrq_rsp_parse(struct fchs_s *fchs, int len) 981fc_rrq_rsp_parse(struct fchs_s *fchs, int len)
1005{ 982{
1006 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1); 983 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
1007 984
1008 len = len; 985 len = len;
1009 if (els_cmd->els_code != FC_ELS_ACC) 986 if (els_cmd->els_code != FC_ELS_ACC)
@@ -1013,11 +990,10 @@ fc_rrq_rsp_parse(struct fchs_s *fchs, int len)
1013} 990}
1014 991
1015u16 992u16
1016fc_ba_rjt_build(struct fchs_s *fchs, u32 d_id, u32 s_id, 993fc_ba_rjt_build(struct fchs_s *fchs, u32 d_id, u32 s_id, __be16 ox_id,
1017 u16 ox_id, u32 reason_code, 994 u32 reason_code, u32 reason_expl)
1018 u32 reason_expl)
1019{ 995{
1020 struct fc_ba_rjt_s *ba_rjt = (struct fc_ba_rjt_s *) (fchs + 1); 996 struct fc_ba_rjt_s *ba_rjt = (struct fc_ba_rjt_s *) (fchs + 1);
1021 997
1022 fc_bls_rsp_build(fchs, d_id, s_id, ox_id); 998 fc_bls_rsp_build(fchs, d_id, s_id, ox_id);
1023 999
@@ -1030,48 +1006,46 @@ fc_ba_rjt_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
1030static void 1006static void
1031fc_gs_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code) 1007fc_gs_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code)
1032{ 1008{
1033 bfa_os_memset(cthdr, 0, sizeof(struct ct_hdr_s)); 1009 memset(cthdr, 0, sizeof(struct ct_hdr_s));
1034 cthdr->rev_id = CT_GS3_REVISION; 1010 cthdr->rev_id = CT_GS3_REVISION;
1035 cthdr->gs_type = CT_GSTYPE_DIRSERVICE; 1011 cthdr->gs_type = CT_GSTYPE_DIRSERVICE;
1036 cthdr->gs_sub_type = CT_GSSUBTYPE_NAMESERVER; 1012 cthdr->gs_sub_type = CT_GSSUBTYPE_NAMESERVER;
1037 cthdr->cmd_rsp_code = bfa_os_htons(cmd_code); 1013 cthdr->cmd_rsp_code = cpu_to_be16(cmd_code);
1038} 1014}
1039 1015
1040static void 1016static void
1041fc_gs_fdmi_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code) 1017fc_gs_fdmi_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code)
1042{ 1018{
1043 bfa_os_memset(cthdr, 0, sizeof(struct ct_hdr_s)); 1019 memset(cthdr, 0, sizeof(struct ct_hdr_s));
1044 cthdr->rev_id = CT_GS3_REVISION; 1020 cthdr->rev_id = CT_GS3_REVISION;
1045 cthdr->gs_type = CT_GSTYPE_MGMTSERVICE; 1021 cthdr->gs_type = CT_GSTYPE_MGMTSERVICE;
1046 cthdr->gs_sub_type = CT_GSSUBTYPE_HBA_MGMTSERVER; 1022 cthdr->gs_sub_type = CT_GSSUBTYPE_HBA_MGMTSERVER;
1047 cthdr->cmd_rsp_code = bfa_os_htons(cmd_code); 1023 cthdr->cmd_rsp_code = cpu_to_be16(cmd_code);
1048} 1024}
1049 1025
1050static void 1026static void
1051fc_gs_ms_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code, 1027fc_gs_ms_cthdr_build(struct ct_hdr_s *cthdr, u32 s_id, u16 cmd_code,
1052 u8 sub_type) 1028 u8 sub_type)
1053{ 1029{
1054 bfa_os_memset(cthdr, 0, sizeof(struct ct_hdr_s)); 1030 memset(cthdr, 0, sizeof(struct ct_hdr_s));
1055 cthdr->rev_id = CT_GS3_REVISION; 1031 cthdr->rev_id = CT_GS3_REVISION;
1056 cthdr->gs_type = CT_GSTYPE_MGMTSERVICE; 1032 cthdr->gs_type = CT_GSTYPE_MGMTSERVICE;
1057 cthdr->gs_sub_type = sub_type; 1033 cthdr->gs_sub_type = sub_type;
1058 cthdr->cmd_rsp_code = bfa_os_htons(cmd_code); 1034 cthdr->cmd_rsp_code = cpu_to_be16(cmd_code);
1059} 1035}
1060 1036
1061u16 1037u16
1062fc_gidpn_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id, 1038fc_gidpn_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1063 wwn_t port_name) 1039 wwn_t port_name)
1064{ 1040{
1065 1041 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1066 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1042 struct fcgs_gidpn_req_s *gidpn = (struct fcgs_gidpn_req_s *)(cthdr + 1);
1067 struct fcgs_gidpn_req_s *gidpn = 1043 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1068 (struct fcgs_gidpn_req_s *) (cthdr + 1);
1069 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER);
1070 1044
1071 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id); 1045 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1072 fc_gs_cthdr_build(cthdr, s_id, GS_GID_PN); 1046 fc_gs_cthdr_build(cthdr, s_id, GS_GID_PN);
1073 1047
1074 bfa_os_memset(gidpn, 0, sizeof(struct fcgs_gidpn_req_s)); 1048 memset(gidpn, 0, sizeof(struct fcgs_gidpn_req_s));
1075 gidpn->port_name = port_name; 1049 gidpn->port_name = port_name;
1076 return sizeof(struct fcgs_gidpn_req_s) + sizeof(struct ct_hdr_s); 1050 return sizeof(struct fcgs_gidpn_req_s) + sizeof(struct ct_hdr_s);
1077} 1051}
@@ -1080,15 +1054,14 @@ u16
1080fc_gpnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id, 1054fc_gpnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1081 u32 port_id) 1055 u32 port_id)
1082{ 1056{
1083 1057 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1084 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1085 fcgs_gpnid_req_t *gpnid = (fcgs_gpnid_req_t *) (cthdr + 1); 1058 fcgs_gpnid_req_t *gpnid = (fcgs_gpnid_req_t *) (cthdr + 1);
1086 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER); 1059 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1087 1060
1088 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id); 1061 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1089 fc_gs_cthdr_build(cthdr, s_id, GS_GPN_ID); 1062 fc_gs_cthdr_build(cthdr, s_id, GS_GPN_ID);
1090 1063
1091 bfa_os_memset(gpnid, 0, sizeof(fcgs_gpnid_req_t)); 1064 memset(gpnid, 0, sizeof(fcgs_gpnid_req_t));
1092 gpnid->dap = port_id; 1065 gpnid->dap = port_id;
1093 return sizeof(fcgs_gpnid_req_t) + sizeof(struct ct_hdr_s); 1066 return sizeof(fcgs_gpnid_req_t) + sizeof(struct ct_hdr_s);
1094} 1067}
@@ -1097,15 +1070,14 @@ u16
1097fc_gnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id, 1070fc_gnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1098 u32 port_id) 1071 u32 port_id)
1099{ 1072{
1100 1073 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1101 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1102 fcgs_gnnid_req_t *gnnid = (fcgs_gnnid_req_t *) (cthdr + 1); 1074 fcgs_gnnid_req_t *gnnid = (fcgs_gnnid_req_t *) (cthdr + 1);
1103 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER); 1075 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1104 1076
1105 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id); 1077 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1106 fc_gs_cthdr_build(cthdr, s_id, GS_GNN_ID); 1078 fc_gs_cthdr_build(cthdr, s_id, GS_GNN_ID);
1107 1079
1108 bfa_os_memset(gnnid, 0, sizeof(fcgs_gnnid_req_t)); 1080 memset(gnnid, 0, sizeof(fcgs_gnnid_req_t));
1109 gnnid->dap = port_id; 1081 gnnid->dap = port_id;
1110 return sizeof(fcgs_gnnid_req_t) + sizeof(struct ct_hdr_s); 1082 return sizeof(fcgs_gnnid_req_t) + sizeof(struct ct_hdr_s);
1111} 1083}
@@ -1113,7 +1085,7 @@ fc_gnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1113u16 1085u16
1114fc_ct_rsp_parse(struct ct_hdr_s *cthdr) 1086fc_ct_rsp_parse(struct ct_hdr_s *cthdr)
1115{ 1087{
1116 if (bfa_os_ntohs(cthdr->cmd_rsp_code) != CT_RSP_ACCEPT) { 1088 if (be16_to_cpu(cthdr->cmd_rsp_code) != CT_RSP_ACCEPT) {
1117 if (cthdr->reason_code == CT_RSN_LOGICAL_BUSY) 1089 if (cthdr->reason_code == CT_RSN_LOGICAL_BUSY)
1118 return FC_PARSE_BUSY; 1090 return FC_PARSE_BUSY;
1119 else 1091 else
@@ -1124,14 +1096,14 @@ fc_ct_rsp_parse(struct ct_hdr_s *cthdr)
1124} 1096}
1125 1097
1126u16 1098u16
1127fc_scr_build(struct fchs_s *fchs, struct fc_scr_s *scr, u8 set_br_reg, 1099fc_scr_build(struct fchs_s *fchs, struct fc_scr_s *scr,
1128 u32 s_id, u16 ox_id) 1100 u8 set_br_reg, u32 s_id, u16 ox_id)
1129{ 1101{
1130 u32 d_id = bfa_os_hton3b(FC_FABRIC_CONTROLLER); 1102 u32 d_id = bfa_hton3b(FC_FABRIC_CONTROLLER);
1131 1103
1132 fc_els_req_build(fchs, d_id, s_id, ox_id); 1104 fc_els_req_build(fchs, d_id, s_id, ox_id);
1133 1105
1134 bfa_os_memset(scr, 0, sizeof(struct fc_scr_s)); 1106 memset(scr, 0, sizeof(struct fc_scr_s));
1135 scr->command = FC_ELS_SCR; 1107 scr->command = FC_ELS_SCR;
1136 scr->reg_func = FC_SCR_REG_FUNC_FULL; 1108 scr->reg_func = FC_SCR_REG_FUNC_FULL;
1137 if (set_br_reg) 1109 if (set_br_reg)
@@ -1141,10 +1113,10 @@ fc_scr_build(struct fchs_s *fchs, struct fc_scr_s *scr, u8 set_br_reg,
1141} 1113}
1142 1114
1143u16 1115u16
1144fc_rscn_build(struct fchs_s *fchs, struct fc_rscn_pl_s *rscn, u32 s_id, 1116fc_rscn_build(struct fchs_s *fchs, struct fc_rscn_pl_s *rscn,
1145 u16 ox_id) 1117 u32 s_id, u16 ox_id)
1146{ 1118{
1147 u32 d_id = bfa_os_hton3b(FC_FABRIC_CONTROLLER); 1119 u32 d_id = bfa_hton3b(FC_FABRIC_CONTROLLER);
1148 u16 payldlen; 1120 u16 payldlen;
1149 1121
1150 fc_els_req_build(fchs, d_id, s_id, ox_id); 1122 fc_els_req_build(fchs, d_id, s_id, ox_id);
@@ -1152,7 +1124,7 @@ fc_rscn_build(struct fchs_s *fchs, struct fc_rscn_pl_s *rscn, u32 s_id,
1152 rscn->pagelen = sizeof(rscn->event[0]); 1124 rscn->pagelen = sizeof(rscn->event[0]);
1153 1125
1154 payldlen = sizeof(u32) + rscn->pagelen; 1126 payldlen = sizeof(u32) + rscn->pagelen;
1155 rscn->payldlen = bfa_os_htons(payldlen); 1127 rscn->payldlen = cpu_to_be16(payldlen);
1156 1128
1157 rscn->event[0].format = FC_RSCN_FORMAT_PORTID; 1129 rscn->event[0].format = FC_RSCN_FORMAT_PORTID;
1158 rscn->event[0].portid = s_id; 1130 rscn->event[0].portid = s_id;
@@ -1162,53 +1134,44 @@ fc_rscn_build(struct fchs_s *fchs, struct fc_rscn_pl_s *rscn, u32 s_id,
1162 1134
1163u16 1135u16
1164fc_rftid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id, 1136fc_rftid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1165 enum bfa_port_role roles) 1137 enum bfa_lport_role roles)
1166{ 1138{
1167 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1139 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1168 struct fcgs_rftid_req_s *rftid = 1140 struct fcgs_rftid_req_s *rftid = (struct fcgs_rftid_req_s *)(cthdr + 1);
1169 (struct fcgs_rftid_req_s *) (cthdr + 1); 1141 u32 type_value, d_id = bfa_hton3b(FC_NAME_SERVER);
1170 u32 type_value, d_id = bfa_os_hton3b(FC_NAME_SERVER);
1171 u8 index; 1142 u8 index;
1172 1143
1173 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id); 1144 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1174 fc_gs_cthdr_build(cthdr, s_id, GS_RFT_ID); 1145 fc_gs_cthdr_build(cthdr, s_id, GS_RFT_ID);
1175 1146
1176 bfa_os_memset(rftid, 0, sizeof(struct fcgs_rftid_req_s)); 1147 memset(rftid, 0, sizeof(struct fcgs_rftid_req_s));
1177 1148
1178 rftid->dap = s_id; 1149 rftid->dap = s_id;
1179 1150
1180 /* By default, FCP FC4 Type is registered */ 1151 /* By default, FCP FC4 Type is registered */
1181 index = FC_TYPE_FCP >> 5; 1152 index = FC_TYPE_FCP >> 5;
1182 type_value = 1 << (FC_TYPE_FCP % 32); 1153 type_value = 1 << (FC_TYPE_FCP % 32);
1183 rftid->fc4_type[index] = bfa_os_htonl(type_value); 1154 rftid->fc4_type[index] = cpu_to_be32(type_value);
1184
1185 if (roles & BFA_PORT_ROLE_FCP_IPFC) {
1186 index = FC_TYPE_IP >> 5;
1187 type_value = 1 << (FC_TYPE_IP % 32);
1188 rftid->fc4_type[index] |= bfa_os_htonl(type_value);
1189 }
1190 1155
1191 return sizeof(struct fcgs_rftid_req_s) + sizeof(struct ct_hdr_s); 1156 return sizeof(struct fcgs_rftid_req_s) + sizeof(struct ct_hdr_s);
1192} 1157}
1193 1158
1194u16 1159u16
1195fc_rftid_build_sol(struct fchs_s *fchs, void *pyld, u32 s_id, 1160fc_rftid_build_sol(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1196 u16 ox_id, u8 *fc4_bitmap, 1161 u8 *fc4_bitmap, u32 bitmap_size)
1197 u32 bitmap_size)
1198{ 1162{
1199 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1163 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1200 struct fcgs_rftid_req_s *rftid = 1164 struct fcgs_rftid_req_s *rftid = (struct fcgs_rftid_req_s *)(cthdr + 1);
1201 (struct fcgs_rftid_req_s *) (cthdr + 1); 1165 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1202 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER);
1203 1166
1204 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id); 1167 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1205 fc_gs_cthdr_build(cthdr, s_id, GS_RFT_ID); 1168 fc_gs_cthdr_build(cthdr, s_id, GS_RFT_ID);
1206 1169
1207 bfa_os_memset(rftid, 0, sizeof(struct fcgs_rftid_req_s)); 1170 memset(rftid, 0, sizeof(struct fcgs_rftid_req_s));
1208 1171
1209 rftid->dap = s_id; 1172 rftid->dap = s_id;
1210 bfa_os_memcpy((void *)rftid->fc4_type, (void *)fc4_bitmap, 1173 memcpy((void *)rftid->fc4_type, (void *)fc4_bitmap,
1211 (bitmap_size < 32 ? bitmap_size : 32)); 1174 (bitmap_size < 32 ? bitmap_size : 32));
1212 1175
1213 return sizeof(struct fcgs_rftid_req_s) + sizeof(struct ct_hdr_s); 1176 return sizeof(struct fcgs_rftid_req_s) + sizeof(struct ct_hdr_s);
1214} 1177}
@@ -1217,19 +1180,18 @@ u16
1217fc_rffid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id, 1180fc_rffid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1218 u8 fc4_type, u8 fc4_ftrs) 1181 u8 fc4_type, u8 fc4_ftrs)
1219{ 1182{
1220 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1183 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1221 struct fcgs_rffid_req_s *rffid = 1184 struct fcgs_rffid_req_s *rffid = (struct fcgs_rffid_req_s *)(cthdr + 1);
1222 (struct fcgs_rffid_req_s *) (cthdr + 1); 1185 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1223 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER);
1224 1186
1225 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id); 1187 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1226 fc_gs_cthdr_build(cthdr, s_id, GS_RFF_ID); 1188 fc_gs_cthdr_build(cthdr, s_id, GS_RFF_ID);
1227 1189
1228 bfa_os_memset(rffid, 0, sizeof(struct fcgs_rffid_req_s)); 1190 memset(rffid, 0, sizeof(struct fcgs_rffid_req_s));
1229 1191
1230 rffid->dap = s_id; 1192 rffid->dap = s_id;
1231 rffid->fc4ftr_bits = fc4_ftrs; 1193 rffid->fc4ftr_bits = fc4_ftrs;
1232 rffid->fc4_type = fc4_type; 1194 rffid->fc4_type = fc4_type;
1233 1195
1234 return sizeof(struct fcgs_rffid_req_s) + sizeof(struct ct_hdr_s); 1196 return sizeof(struct fcgs_rffid_req_s) + sizeof(struct ct_hdr_s);
1235} 1197}
@@ -1239,15 +1201,15 @@ fc_rspnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1239 u8 *name) 1201 u8 *name)
1240{ 1202{
1241 1203
1242 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1204 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1243 struct fcgs_rspnid_req_s *rspnid = 1205 struct fcgs_rspnid_req_s *rspnid =
1244 (struct fcgs_rspnid_req_s *) (cthdr + 1); 1206 (struct fcgs_rspnid_req_s *)(cthdr + 1);
1245 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER); 1207 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1246 1208
1247 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id); 1209 fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
1248 fc_gs_cthdr_build(cthdr, s_id, GS_RSPN_ID); 1210 fc_gs_cthdr_build(cthdr, s_id, GS_RSPN_ID);
1249 1211
1250 bfa_os_memset(rspnid, 0, sizeof(struct fcgs_rspnid_req_s)); 1212 memset(rspnid, 0, sizeof(struct fcgs_rspnid_req_s));
1251 1213
1252 rspnid->dap = s_id; 1214 rspnid->dap = s_id;
1253 rspnid->spn_len = (u8) strlen((char *)name); 1215 rspnid->spn_len = (u8) strlen((char *)name);
@@ -1257,20 +1219,18 @@ fc_rspnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
1257} 1219}
1258 1220
1259u16 1221u16
1260fc_gid_ft_build(struct fchs_s *fchs, void *pyld, u32 s_id, 1222fc_gid_ft_build(struct fchs_s *fchs, void *pyld, u32 s_id, u8 fc4_type)
1261 u8 fc4_type)
1262{ 1223{
1263 1224
1264 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1225 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1265 struct fcgs_gidft_req_s *gidft = 1226 struct fcgs_gidft_req_s *gidft = (struct fcgs_gidft_req_s *)(cthdr + 1);
1266 (struct fcgs_gidft_req_s *) (cthdr + 1); 1227 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1267 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER);
1268 1228
1269 fc_gs_fchdr_build(fchs, d_id, s_id, 0); 1229 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1270 1230
1271 fc_gs_cthdr_build(cthdr, s_id, GS_GID_FT); 1231 fc_gs_cthdr_build(cthdr, s_id, GS_GID_FT);
1272 1232
1273 bfa_os_memset(gidft, 0, sizeof(struct fcgs_gidft_req_s)); 1233 memset(gidft, 0, sizeof(struct fcgs_gidft_req_s));
1274 gidft->fc4_type = fc4_type; 1234 gidft->fc4_type = fc4_type;
1275 gidft->domain_id = 0; 1235 gidft->domain_id = 0;
1276 gidft->area_id = 0; 1236 gidft->area_id = 0;
@@ -1282,15 +1242,14 @@ u16
1282fc_rpnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id, 1242fc_rpnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
1283 wwn_t port_name) 1243 wwn_t port_name)
1284{ 1244{
1285 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1245 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1286 struct fcgs_rpnid_req_s *rpnid = 1246 struct fcgs_rpnid_req_s *rpnid = (struct fcgs_rpnid_req_s *)(cthdr + 1);
1287 (struct fcgs_rpnid_req_s *) (cthdr + 1); 1247 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1288 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER);
1289 1248
1290 fc_gs_fchdr_build(fchs, d_id, s_id, 0); 1249 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1291 fc_gs_cthdr_build(cthdr, s_id, GS_RPN_ID); 1250 fc_gs_cthdr_build(cthdr, s_id, GS_RPN_ID);
1292 1251
1293 bfa_os_memset(rpnid, 0, sizeof(struct fcgs_rpnid_req_s)); 1252 memset(rpnid, 0, sizeof(struct fcgs_rpnid_req_s));
1294 rpnid->port_id = port_id; 1253 rpnid->port_id = port_id;
1295 rpnid->port_name = port_name; 1254 rpnid->port_name = port_name;
1296 1255
@@ -1301,15 +1260,14 @@ u16
1301fc_rnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id, 1260fc_rnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
1302 wwn_t node_name) 1261 wwn_t node_name)
1303{ 1262{
1304 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1263 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1305 struct fcgs_rnnid_req_s *rnnid = 1264 struct fcgs_rnnid_req_s *rnnid = (struct fcgs_rnnid_req_s *)(cthdr + 1);
1306 (struct fcgs_rnnid_req_s *) (cthdr + 1); 1265 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1307 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER);
1308 1266
1309 fc_gs_fchdr_build(fchs, d_id, s_id, 0); 1267 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1310 fc_gs_cthdr_build(cthdr, s_id, GS_RNN_ID); 1268 fc_gs_cthdr_build(cthdr, s_id, GS_RNN_ID);
1311 1269
1312 bfa_os_memset(rnnid, 0, sizeof(struct fcgs_rnnid_req_s)); 1270 memset(rnnid, 0, sizeof(struct fcgs_rnnid_req_s));
1313 rnnid->port_id = port_id; 1271 rnnid->port_id = port_id;
1314 rnnid->node_name = node_name; 1272 rnnid->node_name = node_name;
1315 1273
@@ -1320,15 +1278,15 @@ u16
1320fc_rcsid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id, 1278fc_rcsid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
1321 u32 cos) 1279 u32 cos)
1322{ 1280{
1323 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1281 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1324 struct fcgs_rcsid_req_s *rcsid = 1282 struct fcgs_rcsid_req_s *rcsid =
1325 (struct fcgs_rcsid_req_s *) (cthdr + 1); 1283 (struct fcgs_rcsid_req_s *) (cthdr + 1);
1326 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER); 1284 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1327 1285
1328 fc_gs_fchdr_build(fchs, d_id, s_id, 0); 1286 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1329 fc_gs_cthdr_build(cthdr, s_id, GS_RCS_ID); 1287 fc_gs_cthdr_build(cthdr, s_id, GS_RCS_ID);
1330 1288
1331 bfa_os_memset(rcsid, 0, sizeof(struct fcgs_rcsid_req_s)); 1289 memset(rcsid, 0, sizeof(struct fcgs_rcsid_req_s));
1332 rcsid->port_id = port_id; 1290 rcsid->port_id = port_id;
1333 rcsid->cos = cos; 1291 rcsid->cos = cos;
1334 1292
@@ -1339,15 +1297,14 @@ u16
1339fc_rptid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id, 1297fc_rptid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
1340 u8 port_type) 1298 u8 port_type)
1341{ 1299{
1342 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1300 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1343 struct fcgs_rptid_req_s *rptid = 1301 struct fcgs_rptid_req_s *rptid = (struct fcgs_rptid_req_s *)(cthdr + 1);
1344 (struct fcgs_rptid_req_s *) (cthdr + 1); 1302 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1345 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER);
1346 1303
1347 fc_gs_fchdr_build(fchs, d_id, s_id, 0); 1304 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1348 fc_gs_cthdr_build(cthdr, s_id, GS_RPT_ID); 1305 fc_gs_cthdr_build(cthdr, s_id, GS_RPT_ID);
1349 1306
1350 bfa_os_memset(rptid, 0, sizeof(struct fcgs_rptid_req_s)); 1307 memset(rptid, 0, sizeof(struct fcgs_rptid_req_s));
1351 rptid->port_id = port_id; 1308 rptid->port_id = port_id;
1352 rptid->port_type = port_type; 1309 rptid->port_type = port_type;
1353 1310
@@ -1357,15 +1314,14 @@ fc_rptid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id,
1357u16 1314u16
1358fc_ganxt_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id) 1315fc_ganxt_build(struct fchs_s *fchs, void *pyld, u32 s_id, u32 port_id)
1359{ 1316{
1360 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1317 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1361 struct fcgs_ganxt_req_s *ganxt = 1318 struct fcgs_ganxt_req_s *ganxt = (struct fcgs_ganxt_req_s *)(cthdr + 1);
1362 (struct fcgs_ganxt_req_s *) (cthdr + 1); 1319 u32 d_id = bfa_hton3b(FC_NAME_SERVER);
1363 u32 d_id = bfa_os_hton3b(FC_NAME_SERVER);
1364 1320
1365 fc_gs_fchdr_build(fchs, d_id, s_id, 0); 1321 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1366 fc_gs_cthdr_build(cthdr, s_id, GS_GA_NXT); 1322 fc_gs_cthdr_build(cthdr, s_id, GS_GA_NXT);
1367 1323
1368 bfa_os_memset(ganxt, 0, sizeof(struct fcgs_ganxt_req_s)); 1324 memset(ganxt, 0, sizeof(struct fcgs_ganxt_req_s));
1369 ganxt->port_id = port_id; 1325 ganxt->port_id = port_id;
1370 1326
1371 return sizeof(struct ct_hdr_s) + sizeof(struct fcgs_ganxt_req_s); 1327 return sizeof(struct ct_hdr_s) + sizeof(struct fcgs_ganxt_req_s);
@@ -1379,8 +1335,8 @@ fc_fdmi_reqhdr_build(struct fchs_s *fchs, void *pyld, u32 s_id,
1379 u16 cmd_code) 1335 u16 cmd_code)
1380{ 1336{
1381 1337
1382 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1338 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1383 u32 d_id = bfa_os_hton3b(FC_MGMT_SERVER); 1339 u32 d_id = bfa_hton3b(FC_MGMT_SERVER);
1384 1340
1385 fc_gs_fchdr_build(fchs, d_id, s_id, 0); 1341 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1386 fc_gs_fdmi_cthdr_build(cthdr, s_id, cmd_code); 1342 fc_gs_fdmi_cthdr_build(cthdr, s_id, cmd_code);
@@ -1395,7 +1351,7 @@ void
1395fc_get_fc4type_bitmask(u8 fc4_type, u8 *bit_mask) 1351fc_get_fc4type_bitmask(u8 fc4_type, u8 *bit_mask)
1396{ 1352{
1397 u8 index; 1353 u8 index;
1398 u32 *ptr = (u32 *) bit_mask; 1354 __be32 *ptr = (__be32 *) bit_mask;
1399 u32 type_value; 1355 u32 type_value;
1400 1356
1401 /* 1357 /*
@@ -1404,25 +1360,25 @@ fc_get_fc4type_bitmask(u8 fc4_type, u8 *bit_mask)
1404 1360
1405 index = fc4_type >> 5; 1361 index = fc4_type >> 5;
1406 type_value = 1 << (fc4_type % 32); 1362 type_value = 1 << (fc4_type % 32);
1407 ptr[index] = bfa_os_htonl(type_value); 1363 ptr[index] = cpu_to_be32(type_value);
1408 1364
1409} 1365}
1410 1366
1411/* 1367/*
1412 * GMAL Request 1368 * GMAL Request
1413 */ 1369 */
1414u16 1370u16
1415fc_gmal_req_build(struct fchs_s *fchs, void *pyld, u32 s_id, wwn_t wwn) 1371fc_gmal_req_build(struct fchs_s *fchs, void *pyld, u32 s_id, wwn_t wwn)
1416{ 1372{
1417 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1373 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1418 fcgs_gmal_req_t *gmal = (fcgs_gmal_req_t *) (cthdr + 1); 1374 fcgs_gmal_req_t *gmal = (fcgs_gmal_req_t *) (cthdr + 1);
1419 u32 d_id = bfa_os_hton3b(FC_MGMT_SERVER); 1375 u32 d_id = bfa_hton3b(FC_MGMT_SERVER);
1420 1376
1421 fc_gs_fchdr_build(fchs, d_id, s_id, 0); 1377 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1422 fc_gs_ms_cthdr_build(cthdr, s_id, GS_FC_GMAL_CMD, 1378 fc_gs_ms_cthdr_build(cthdr, s_id, GS_FC_GMAL_CMD,
1423 CT_GSSUBTYPE_CFGSERVER); 1379 CT_GSSUBTYPE_CFGSERVER);
1424 1380
1425 bfa_os_memset(gmal, 0, sizeof(fcgs_gmal_req_t)); 1381 memset(gmal, 0, sizeof(fcgs_gmal_req_t));
1426 gmal->wwn = wwn; 1382 gmal->wwn = wwn;
1427 1383
1428 return sizeof(struct ct_hdr_s) + sizeof(fcgs_gmal_req_t); 1384 return sizeof(struct ct_hdr_s) + sizeof(fcgs_gmal_req_t);
@@ -1434,15 +1390,15 @@ fc_gmal_req_build(struct fchs_s *fchs, void *pyld, u32 s_id, wwn_t wwn)
1434u16 1390u16
1435fc_gfn_req_build(struct fchs_s *fchs, void *pyld, u32 s_id, wwn_t wwn) 1391fc_gfn_req_build(struct fchs_s *fchs, void *pyld, u32 s_id, wwn_t wwn)
1436{ 1392{
1437 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld; 1393 struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
1438 fcgs_gfn_req_t *gfn = (fcgs_gfn_req_t *) (cthdr + 1); 1394 fcgs_gfn_req_t *gfn = (fcgs_gfn_req_t *) (cthdr + 1);
1439 u32 d_id = bfa_os_hton3b(FC_MGMT_SERVER); 1395 u32 d_id = bfa_hton3b(FC_MGMT_SERVER);
1440 1396
1441 fc_gs_fchdr_build(fchs, d_id, s_id, 0); 1397 fc_gs_fchdr_build(fchs, d_id, s_id, 0);
1442 fc_gs_ms_cthdr_build(cthdr, s_id, GS_FC_GFN_CMD, 1398 fc_gs_ms_cthdr_build(cthdr, s_id, GS_FC_GFN_CMD,
1443 CT_GSSUBTYPE_CFGSERVER); 1399 CT_GSSUBTYPE_CFGSERVER);
1444 1400
1445 bfa_os_memset(gfn, 0, sizeof(fcgs_gfn_req_t)); 1401 memset(gfn, 0, sizeof(fcgs_gfn_req_t));
1446 gfn->wwn = wwn; 1402 gfn->wwn = wwn;
1447 1403
1448 return sizeof(struct ct_hdr_s) + sizeof(fcgs_gfn_req_t); 1404 return sizeof(struct ct_hdr_s) + sizeof(fcgs_gfn_req_t);
diff --git a/drivers/scsi/bfa/bfa_fcbuild.h b/drivers/scsi/bfa/bfa_fcbuild.h
new file mode 100644
index 000000000000..ece51ec7620b
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_fcbuild.h
@@ -0,0 +1,316 @@
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 * fcbuild.h - FC link service frame building and parsing routines
19 */
20
21#ifndef __FCBUILD_H__
22#define __FCBUILD_H__
23
24#include "bfad_drv.h"
25#include "bfa_fc.h"
26#include "bfa_defs_fcs.h"
27
28/*
29 * Utility Macros/functions
30 */
31
32#define wwn_is_equal(_wwn1, _wwn2) \
33 (memcmp(&(_wwn1), &(_wwn2), sizeof(wwn_t)) == 0)
34
35#define fc_roundup(_l, _s) (((_l) + ((_s) - 1)) & ~((_s) - 1))
36
37/*
38 * Given the fc response length, this routine will return
39 * the length of the actual payload bytes following the CT header.
40 *
41 * Assumes the input response length does not include the crc, eof, etc.
42 */
43static inline u32
44fc_get_ctresp_pyld_len(u32 resp_len)
45{
46 return resp_len - sizeof(struct ct_hdr_s);
47}
48
49/*
50 * Convert bfa speed to rpsc speed value.
51 */
52static inline enum bfa_port_speed
53fc_rpsc_operspeed_to_bfa_speed(enum fc_rpsc_op_speed speed)
54{
55 switch (speed) {
56
57 case RPSC_OP_SPEED_1G:
58 return BFA_PORT_SPEED_1GBPS;
59
60 case RPSC_OP_SPEED_2G:
61 return BFA_PORT_SPEED_2GBPS;
62
63 case RPSC_OP_SPEED_4G:
64 return BFA_PORT_SPEED_4GBPS;
65
66 case RPSC_OP_SPEED_8G:
67 return BFA_PORT_SPEED_8GBPS;
68
69 case RPSC_OP_SPEED_10G:
70 return BFA_PORT_SPEED_10GBPS;
71
72 default:
73 return BFA_PORT_SPEED_UNKNOWN;
74 }
75}
76
77/*
78 * Convert RPSC speed to bfa speed value.
79 */
80static inline enum fc_rpsc_op_speed
81fc_bfa_speed_to_rpsc_operspeed(enum bfa_port_speed op_speed)
82{
83 switch (op_speed) {
84
85 case BFA_PORT_SPEED_1GBPS:
86 return RPSC_OP_SPEED_1G;
87
88 case BFA_PORT_SPEED_2GBPS:
89 return RPSC_OP_SPEED_2G;
90
91 case BFA_PORT_SPEED_4GBPS:
92 return RPSC_OP_SPEED_4G;
93
94 case BFA_PORT_SPEED_8GBPS:
95 return RPSC_OP_SPEED_8G;
96
97 case BFA_PORT_SPEED_10GBPS:
98 return RPSC_OP_SPEED_10G;
99
100 default:
101 return RPSC_OP_SPEED_NOT_EST;
102 }
103}
104
105enum fc_parse_status {
106 FC_PARSE_OK = 0,
107 FC_PARSE_FAILURE = 1,
108 FC_PARSE_BUSY = 2,
109 FC_PARSE_LEN_INVAL,
110 FC_PARSE_ACC_INVAL,
111 FC_PARSE_PWWN_NOT_EQUAL,
112 FC_PARSE_NWWN_NOT_EQUAL,
113 FC_PARSE_RXSZ_INVAL,
114 FC_PARSE_NOT_FCP,
115 FC_PARSE_OPAFLAG_INVAL,
116 FC_PARSE_RPAFLAG_INVAL,
117 FC_PARSE_OPA_INVAL,
118 FC_PARSE_RPA_INVAL,
119
120};
121
122struct fc_templates_s {
123 struct fchs_s fc_els_req;
124 struct fchs_s fc_bls_req;
125 struct fc_logi_s plogi;
126 struct fc_rrq_s rrq;
127};
128
129void fcbuild_init(void);
130
131u16 fc_flogi_build(struct fchs_s *fchs, struct fc_logi_s *flogi,
132 u32 s_id, u16 ox_id, wwn_t port_name, wwn_t node_name,
133 u16 pdu_size, u8 set_npiv, u8 set_auth,
134 u16 local_bb_credits);
135
136u16 fc_fdisc_build(struct fchs_s *buf, struct fc_logi_s *flogi, u32 s_id,
137 u16 ox_id, wwn_t port_name, wwn_t node_name,
138 u16 pdu_size);
139
140u16 fc_flogi_acc_build(struct fchs_s *fchs, struct fc_logi_s *flogi,
141 u32 s_id, __be16 ox_id,
142 wwn_t port_name, wwn_t node_name,
143 u16 pdu_size,
144 u16 local_bb_credits);
145
146u16 fc_plogi_build(struct fchs_s *fchs, void *pld, u32 d_id,
147 u32 s_id, u16 ox_id, wwn_t port_name,
148 wwn_t node_name, u16 pdu_size);
149
150enum fc_parse_status fc_plogi_parse(struct fchs_s *fchs);
151
152u16 fc_abts_build(struct fchs_s *buf, u32 d_id, u32 s_id,
153 u16 ox_id);
154
155enum fc_parse_status fc_abts_rsp_parse(struct fchs_s *buf, int len);
156
157u16 fc_rrq_build(struct fchs_s *buf, struct fc_rrq_s *rrq, u32 d_id,
158 u32 s_id, u16 ox_id, u16 rrq_oxid);
159enum fc_parse_status fc_rrq_rsp_parse(struct fchs_s *buf, int len);
160
161u16 fc_rspnid_build(struct fchs_s *fchs, void *pld, u32 s_id,
162 u16 ox_id, u8 *name);
163
164u16 fc_rftid_build(struct fchs_s *fchs, void *pld, u32 s_id,
165 u16 ox_id, enum bfa_lport_role role);
166
167u16 fc_rftid_build_sol(struct fchs_s *fchs, void *pyld, u32 s_id,
168 u16 ox_id, u8 *fc4_bitmap,
169 u32 bitmap_size);
170
171u16 fc_rffid_build(struct fchs_s *fchs, void *pyld, u32 s_id,
172 u16 ox_id, u8 fc4_type, u8 fc4_ftrs);
173
174u16 fc_gidpn_build(struct fchs_s *fchs, void *pyld, u32 s_id,
175 u16 ox_id, wwn_t port_name);
176
177u16 fc_gpnid_build(struct fchs_s *fchs, void *pld, u32 s_id,
178 u16 ox_id, u32 port_id);
179
180u16 fc_scr_build(struct fchs_s *fchs, struct fc_scr_s *scr,
181 u8 set_br_reg, u32 s_id, u16 ox_id);
182
183u16 fc_plogi_acc_build(struct fchs_s *fchs, void *pld, u32 d_id,
184 u32 s_id, u16 ox_id,
185 wwn_t port_name, wwn_t node_name,
186 u16 pdu_size);
187
188u16 fc_adisc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc,
189 u32 d_id, u32 s_id, __be16 ox_id, wwn_t port_name,
190 wwn_t node_name);
191
192enum fc_parse_status fc_adisc_parse(struct fchs_s *fchs, void *pld,
193 u32 host_dap, wwn_t node_name, wwn_t port_name);
194
195enum fc_parse_status fc_adisc_rsp_parse(struct fc_adisc_s *adisc, int len,
196 wwn_t port_name, wwn_t node_name);
197
198u16 fc_adisc_acc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc,
199 u32 d_id, u32 s_id, __be16 ox_id,
200 wwn_t port_name, wwn_t node_name);
201u16 fc_ls_rjt_build(struct fchs_s *fchs, struct fc_ls_rjt_s *ls_rjt,
202 u32 d_id, u32 s_id, __be16 ox_id,
203 u8 reason_code, u8 reason_code_expl);
204u16 fc_ls_acc_build(struct fchs_s *fchs, struct fc_els_cmd_s *els_cmd,
205 u32 d_id, u32 s_id, __be16 ox_id);
206u16 fc_prli_build(struct fchs_s *fchs, void *pld, u32 d_id,
207 u32 s_id, u16 ox_id);
208
209enum fc_parse_status fc_prli_rsp_parse(struct fc_prli_s *prli, int len);
210
211u16 fc_prli_acc_build(struct fchs_s *fchs, void *pld, u32 d_id,
212 u32 s_id, __be16 ox_id,
213 enum bfa_lport_role role);
214
215u16 fc_rnid_build(struct fchs_s *fchs, struct fc_rnid_cmd_s *rnid,
216 u32 d_id, u32 s_id, u16 ox_id,
217 u32 data_format);
218
219u16 fc_rnid_acc_build(struct fchs_s *fchs,
220 struct fc_rnid_acc_s *rnid_acc, u32 d_id, u32 s_id,
221 __be16 ox_id, u32 data_format,
222 struct fc_rnid_common_id_data_s *common_id_data,
223 struct fc_rnid_general_topology_data_s *gen_topo_data);
224
225u16 fc_rpsc2_build(struct fchs_s *fchs, struct fc_rpsc2_cmd_s *rps2c,
226 u32 d_id, u32 s_id, u32 *pid_list, u16 npids);
227u16 fc_rpsc_build(struct fchs_s *fchs, struct fc_rpsc_cmd_s *rpsc,
228 u32 d_id, u32 s_id, u16 ox_id);
229u16 fc_rpsc_acc_build(struct fchs_s *fchs,
230 struct fc_rpsc_acc_s *rpsc_acc, u32 d_id, u32 s_id,
231 __be16 ox_id, struct fc_rpsc_speed_info_s *oper_speed);
232u16 fc_gid_ft_build(struct fchs_s *fchs, void *pld, u32 s_id,
233 u8 fc4_type);
234
235u16 fc_rpnid_build(struct fchs_s *fchs, void *pyld, u32 s_id,
236 u32 port_id, wwn_t port_name);
237
238u16 fc_rnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id,
239 u32 port_id, wwn_t node_name);
240
241u16 fc_rcsid_build(struct fchs_s *fchs, void *pyld, u32 s_id,
242 u32 port_id, u32 cos);
243
244u16 fc_rptid_build(struct fchs_s *fchs, void *pyld, u32 s_id,
245 u32 port_id, u8 port_type);
246
247u16 fc_ganxt_build(struct fchs_s *fchs, void *pyld, u32 s_id,
248 u32 port_id);
249
250u16 fc_logo_build(struct fchs_s *fchs, struct fc_logo_s *logo, u32 d_id,
251 u32 s_id, u16 ox_id, wwn_t port_name);
252
253u16 fc_logo_acc_build(struct fchs_s *fchs, void *pld, u32 d_id,
254 u32 s_id, __be16 ox_id);
255
256u16 fc_fdmi_reqhdr_build(struct fchs_s *fchs, void *pyld, u32 s_id,
257 u16 cmd_code);
258u16 fc_gmal_req_build(struct fchs_s *fchs, void *pyld, u32 s_id, wwn_t wwn);
259u16 fc_gfn_req_build(struct fchs_s *fchs, void *pyld, u32 s_id, wwn_t wwn);
260
261void fc_get_fc4type_bitmask(u8 fc4_type, u8 *bit_mask);
262
263void fc_els_req_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
264 __be16 ox_id);
265
266enum fc_parse_status fc_els_rsp_parse(struct fchs_s *fchs, int len);
267
268enum fc_parse_status fc_plogi_rsp_parse(struct fchs_s *fchs, int len,
269 wwn_t port_name);
270
271enum fc_parse_status fc_prli_parse(struct fc_prli_s *prli);
272
273enum fc_parse_status fc_pdisc_parse(struct fchs_s *fchs, wwn_t node_name,
274 wwn_t port_name);
275
276u16 fc_ba_acc_build(struct fchs_s *fchs, struct fc_ba_acc_s *ba_acc, u32 d_id,
277 u32 s_id, __be16 ox_id, u16 rx_id);
278
279int fc_logout_params_pages(struct fchs_s *fc_frame, u8 els_code);
280
281u16 fc_tprlo_acc_build(struct fchs_s *fchs, struct fc_tprlo_acc_s *tprlo_acc,
282 u32 d_id, u32 s_id, __be16 ox_id, int num_pages);
283
284u16 fc_prlo_acc_build(struct fchs_s *fchs, struct fc_prlo_acc_s *prlo_acc,
285 u32 d_id, u32 s_id, __be16 ox_id, int num_pages);
286
287u16 fc_logo_rsp_parse(struct fchs_s *fchs, int len);
288
289u16 fc_pdisc_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
290 u16 ox_id, wwn_t port_name, wwn_t node_name,
291 u16 pdu_size);
292
293u16 fc_pdisc_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name);
294
295u16 fc_prlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
296 u16 ox_id, int num_pages);
297
298u16 fc_prlo_rsp_parse(struct fchs_s *fchs, int len);
299
300u16 fc_tprlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
301 u16 ox_id, int num_pages, enum fc_tprlo_type tprlo_type,
302 u32 tpr_id);
303
304u16 fc_tprlo_rsp_parse(struct fchs_s *fchs, int len);
305
306u16 fc_ba_rjt_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
307 __be16 ox_id, u32 reason_code, u32 reason_expl);
308
309u16 fc_gnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
310 u32 port_id);
311
312u16 fc_ct_rsp_parse(struct ct_hdr_s *cthdr);
313
314u16 fc_rscn_build(struct fchs_s *fchs, struct fc_rscn_pl_s *rscn, u32 s_id,
315 u16 ox_id);
316#endif
diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
index 8c703d8dc94b..c0353cdca929 100644
--- a/drivers/scsi/bfa/bfa_fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcpim.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,18 +15,276 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#include <bfa.h> 18#include "bfad_drv.h"
19#include <log/bfa_log_hal.h> 19#include "bfa_modules.h"
20 20
21BFA_TRC_FILE(HAL, FCPIM); 21BFA_TRC_FILE(HAL, FCPIM);
22BFA_MODULE(fcpim); 22BFA_MODULE(fcpim);
23 23
24/** 24/*
25 * hal_fcpim_mod BFA FCP Initiator Mode module 25 * BFA ITNIM Related definitions
26 */
27static void bfa_itnim_update_del_itn_stats(struct bfa_itnim_s *itnim);
28
29#define BFA_ITNIM_FROM_TAG(_fcpim, _tag) \
30 (((_fcpim)->itnim_arr + ((_tag) & ((_fcpim)->num_itnims - 1))))
31
32#define bfa_fcpim_additn(__itnim) \
33 list_add_tail(&(__itnim)->qe, &(__itnim)->fcpim->itnim_q)
34#define bfa_fcpim_delitn(__itnim) do { \
35 WARN_ON(!bfa_q_is_on_q(&(__itnim)->fcpim->itnim_q, __itnim)); \
36 bfa_itnim_update_del_itn_stats(__itnim); \
37 list_del(&(__itnim)->qe); \
38 WARN_ON(!list_empty(&(__itnim)->io_q)); \
39 WARN_ON(!list_empty(&(__itnim)->io_cleanup_q)); \
40 WARN_ON(!list_empty(&(__itnim)->pending_q)); \
41} while (0)
42
43#define bfa_itnim_online_cb(__itnim) do { \
44 if ((__itnim)->bfa->fcs) \
45 bfa_cb_itnim_online((__itnim)->ditn); \
46 else { \
47 bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe, \
48 __bfa_cb_itnim_online, (__itnim)); \
49 } \
50} while (0)
51
52#define bfa_itnim_offline_cb(__itnim) do { \
53 if ((__itnim)->bfa->fcs) \
54 bfa_cb_itnim_offline((__itnim)->ditn); \
55 else { \
56 bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe, \
57 __bfa_cb_itnim_offline, (__itnim)); \
58 } \
59} while (0)
60
61#define bfa_itnim_sler_cb(__itnim) do { \
62 if ((__itnim)->bfa->fcs) \
63 bfa_cb_itnim_sler((__itnim)->ditn); \
64 else { \
65 bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe, \
66 __bfa_cb_itnim_sler, (__itnim)); \
67 } \
68} while (0)
69
70/*
71 * itnim state machine event
72 */
73enum bfa_itnim_event {
74 BFA_ITNIM_SM_CREATE = 1, /* itnim is created */
75 BFA_ITNIM_SM_ONLINE = 2, /* itnim is online */
76 BFA_ITNIM_SM_OFFLINE = 3, /* itnim is offline */
77 BFA_ITNIM_SM_FWRSP = 4, /* firmware response */
78 BFA_ITNIM_SM_DELETE = 5, /* deleting an existing itnim */
79 BFA_ITNIM_SM_CLEANUP = 6, /* IO cleanup completion */
80 BFA_ITNIM_SM_SLER = 7, /* second level error recovery */
81 BFA_ITNIM_SM_HWFAIL = 8, /* IOC h/w failure event */
82 BFA_ITNIM_SM_QRESUME = 9, /* queue space available */
83};
84
85/*
86 * BFA IOIM related definitions
87 */
88#define bfa_ioim_move_to_comp_q(__ioim) do { \
89 list_del(&(__ioim)->qe); \
90 list_add_tail(&(__ioim)->qe, &(__ioim)->fcpim->ioim_comp_q); \
91} while (0)
92
93
94#define bfa_ioim_cb_profile_comp(__fcpim, __ioim) do { \
95 if ((__fcpim)->profile_comp) \
96 (__fcpim)->profile_comp(__ioim); \
97} while (0)
98
99#define bfa_ioim_cb_profile_start(__fcpim, __ioim) do { \
100 if ((__fcpim)->profile_start) \
101 (__fcpim)->profile_start(__ioim); \
102} while (0)
103
104/*
105 * IO state machine events
26 */ 106 */
107enum bfa_ioim_event {
108 BFA_IOIM_SM_START = 1, /* io start request from host */
109 BFA_IOIM_SM_COMP_GOOD = 2, /* io good comp, resource free */
110 BFA_IOIM_SM_COMP = 3, /* io comp, resource is free */
111 BFA_IOIM_SM_COMP_UTAG = 4, /* io comp, resource is free */
112 BFA_IOIM_SM_DONE = 5, /* io comp, resource not free */
113 BFA_IOIM_SM_FREE = 6, /* io resource is freed */
114 BFA_IOIM_SM_ABORT = 7, /* abort request from scsi stack */
115 BFA_IOIM_SM_ABORT_COMP = 8, /* abort from f/w */
116 BFA_IOIM_SM_ABORT_DONE = 9, /* abort completion from f/w */
117 BFA_IOIM_SM_QRESUME = 10, /* CQ space available to queue IO */
118 BFA_IOIM_SM_SGALLOCED = 11, /* SG page allocation successful */
119 BFA_IOIM_SM_SQRETRY = 12, /* sequence recovery retry */
120 BFA_IOIM_SM_HCB = 13, /* bfa callback complete */
121 BFA_IOIM_SM_CLEANUP = 14, /* IO cleanup from itnim */
122 BFA_IOIM_SM_TMSTART = 15, /* IO cleanup from tskim */
123 BFA_IOIM_SM_TMDONE = 16, /* IO cleanup from tskim */
124 BFA_IOIM_SM_HWFAIL = 17, /* IOC h/w failure event */
125 BFA_IOIM_SM_IOTOV = 18, /* ITN offline TOV */
126};
127
27 128
28/** 129/*
29 * Compute and return memory needed by FCP(im) module. 130 * BFA TSKIM related definitions
131 */
132
133/*
134 * task management completion handling
135 */
136#define bfa_tskim_qcomp(__tskim, __cbfn) do { \
137 bfa_cb_queue((__tskim)->bfa, &(__tskim)->hcb_qe, __cbfn, (__tskim));\
138 bfa_tskim_notify_comp(__tskim); \
139} while (0)
140
141#define bfa_tskim_notify_comp(__tskim) do { \
142 if ((__tskim)->notify) \
143 bfa_itnim_tskdone((__tskim)->itnim); \
144} while (0)
145
146
147enum bfa_tskim_event {
148 BFA_TSKIM_SM_START = 1, /* TM command start */
149 BFA_TSKIM_SM_DONE = 2, /* TM completion */
150 BFA_TSKIM_SM_QRESUME = 3, /* resume after qfull */
151 BFA_TSKIM_SM_HWFAIL = 5, /* IOC h/w failure event */
152 BFA_TSKIM_SM_HCB = 6, /* BFA callback completion */
153 BFA_TSKIM_SM_IOS_DONE = 7, /* IO and sub TM completions */
154 BFA_TSKIM_SM_CLEANUP = 8, /* TM cleanup on ITN offline */
155 BFA_TSKIM_SM_CLEANUP_DONE = 9, /* TM abort completion */
156};
157
158/*
159 * forward declaration for BFA ITNIM functions
160 */
161static void bfa_itnim_iocdisable_cleanup(struct bfa_itnim_s *itnim);
162static bfa_boolean_t bfa_itnim_send_fwcreate(struct bfa_itnim_s *itnim);
163static bfa_boolean_t bfa_itnim_send_fwdelete(struct bfa_itnim_s *itnim);
164static void bfa_itnim_cleanp_comp(void *itnim_cbarg);
165static void bfa_itnim_cleanup(struct bfa_itnim_s *itnim);
166static void __bfa_cb_itnim_online(void *cbarg, bfa_boolean_t complete);
167static void __bfa_cb_itnim_offline(void *cbarg, bfa_boolean_t complete);
168static void __bfa_cb_itnim_sler(void *cbarg, bfa_boolean_t complete);
169static void bfa_itnim_iotov_online(struct bfa_itnim_s *itnim);
170static void bfa_itnim_iotov_cleanup(struct bfa_itnim_s *itnim);
171static void bfa_itnim_iotov(void *itnim_arg);
172static void bfa_itnim_iotov_start(struct bfa_itnim_s *itnim);
173static void bfa_itnim_iotov_stop(struct bfa_itnim_s *itnim);
174static void bfa_itnim_iotov_delete(struct bfa_itnim_s *itnim);
175
176/*
177 * forward declaration of ITNIM state machine
178 */
179static void bfa_itnim_sm_uninit(struct bfa_itnim_s *itnim,
180 enum bfa_itnim_event event);
181static void bfa_itnim_sm_created(struct bfa_itnim_s *itnim,
182 enum bfa_itnim_event event);
183static void bfa_itnim_sm_fwcreate(struct bfa_itnim_s *itnim,
184 enum bfa_itnim_event event);
185static void bfa_itnim_sm_delete_pending(struct bfa_itnim_s *itnim,
186 enum bfa_itnim_event event);
187static void bfa_itnim_sm_online(struct bfa_itnim_s *itnim,
188 enum bfa_itnim_event event);
189static void bfa_itnim_sm_sler(struct bfa_itnim_s *itnim,
190 enum bfa_itnim_event event);
191static void bfa_itnim_sm_cleanup_offline(struct bfa_itnim_s *itnim,
192 enum bfa_itnim_event event);
193static void bfa_itnim_sm_cleanup_delete(struct bfa_itnim_s *itnim,
194 enum bfa_itnim_event event);
195static void bfa_itnim_sm_fwdelete(struct bfa_itnim_s *itnim,
196 enum bfa_itnim_event event);
197static void bfa_itnim_sm_offline(struct bfa_itnim_s *itnim,
198 enum bfa_itnim_event event);
199static void bfa_itnim_sm_iocdisable(struct bfa_itnim_s *itnim,
200 enum bfa_itnim_event event);
201static void bfa_itnim_sm_deleting(struct bfa_itnim_s *itnim,
202 enum bfa_itnim_event event);
203static void bfa_itnim_sm_fwcreate_qfull(struct bfa_itnim_s *itnim,
204 enum bfa_itnim_event event);
205static void bfa_itnim_sm_fwdelete_qfull(struct bfa_itnim_s *itnim,
206 enum bfa_itnim_event event);
207static void bfa_itnim_sm_deleting_qfull(struct bfa_itnim_s *itnim,
208 enum bfa_itnim_event event);
209
210/*
211 * forward declaration for BFA IOIM functions
212 */
213static bfa_boolean_t bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim);
214static bfa_boolean_t bfa_ioim_sgpg_alloc(struct bfa_ioim_s *ioim);
215static bfa_boolean_t bfa_ioim_send_abort(struct bfa_ioim_s *ioim);
216static void bfa_ioim_notify_cleanup(struct bfa_ioim_s *ioim);
217static void __bfa_cb_ioim_good_comp(void *cbarg, bfa_boolean_t complete);
218static void __bfa_cb_ioim_comp(void *cbarg, bfa_boolean_t complete);
219static void __bfa_cb_ioim_abort(void *cbarg, bfa_boolean_t complete);
220static void __bfa_cb_ioim_failed(void *cbarg, bfa_boolean_t complete);
221static void __bfa_cb_ioim_pathtov(void *cbarg, bfa_boolean_t complete);
222static bfa_boolean_t bfa_ioim_is_abortable(struct bfa_ioim_s *ioim);
223
224/*
225 * forward declaration of BFA IO state machine
226 */
227static void bfa_ioim_sm_uninit(struct bfa_ioim_s *ioim,
228 enum bfa_ioim_event event);
229static void bfa_ioim_sm_sgalloc(struct bfa_ioim_s *ioim,
230 enum bfa_ioim_event event);
231static void bfa_ioim_sm_active(struct bfa_ioim_s *ioim,
232 enum bfa_ioim_event event);
233static void bfa_ioim_sm_abort(struct bfa_ioim_s *ioim,
234 enum bfa_ioim_event event);
235static void bfa_ioim_sm_cleanup(struct bfa_ioim_s *ioim,
236 enum bfa_ioim_event event);
237static void bfa_ioim_sm_qfull(struct bfa_ioim_s *ioim,
238 enum bfa_ioim_event event);
239static void bfa_ioim_sm_abort_qfull(struct bfa_ioim_s *ioim,
240 enum bfa_ioim_event event);
241static void bfa_ioim_sm_cleanup_qfull(struct bfa_ioim_s *ioim,
242 enum bfa_ioim_event event);
243static void bfa_ioim_sm_hcb(struct bfa_ioim_s *ioim,
244 enum bfa_ioim_event event);
245static void bfa_ioim_sm_hcb_free(struct bfa_ioim_s *ioim,
246 enum bfa_ioim_event event);
247static void bfa_ioim_sm_resfree(struct bfa_ioim_s *ioim,
248 enum bfa_ioim_event event);
249static void bfa_ioim_sm_cmnd_retry(struct bfa_ioim_s *ioim,
250 enum bfa_ioim_event event);
251/*
252 * forward declaration for BFA TSKIM functions
253 */
254static void __bfa_cb_tskim_done(void *cbarg, bfa_boolean_t complete);
255static void __bfa_cb_tskim_failed(void *cbarg, bfa_boolean_t complete);
256static bfa_boolean_t bfa_tskim_match_scope(struct bfa_tskim_s *tskim,
257 struct scsi_lun lun);
258static void bfa_tskim_gather_ios(struct bfa_tskim_s *tskim);
259static void bfa_tskim_cleanp_comp(void *tskim_cbarg);
260static void bfa_tskim_cleanup_ios(struct bfa_tskim_s *tskim);
261static bfa_boolean_t bfa_tskim_send(struct bfa_tskim_s *tskim);
262static bfa_boolean_t bfa_tskim_send_abort(struct bfa_tskim_s *tskim);
263static void bfa_tskim_iocdisable_ios(struct bfa_tskim_s *tskim);
264
265/*
266 * forward declaration of BFA TSKIM state machine
267 */
268static void bfa_tskim_sm_uninit(struct bfa_tskim_s *tskim,
269 enum bfa_tskim_event event);
270static void bfa_tskim_sm_active(struct bfa_tskim_s *tskim,
271 enum bfa_tskim_event event);
272static void bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim,
273 enum bfa_tskim_event event);
274static void bfa_tskim_sm_iocleanup(struct bfa_tskim_s *tskim,
275 enum bfa_tskim_event event);
276static void bfa_tskim_sm_qfull(struct bfa_tskim_s *tskim,
277 enum bfa_tskim_event event);
278static void bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s *tskim,
279 enum bfa_tskim_event event);
280static void bfa_tskim_sm_hcb(struct bfa_tskim_s *tskim,
281 enum bfa_tskim_event event);
282/*
283 * BFA FCP Initiator Mode module
284 */
285
286/*
287 * Compute and return memory needed by FCP(im) module.
30 */ 288 */
31static void 289static void
32bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len, 290bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
@@ -34,7 +292,7 @@ bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
34{ 292{
35 bfa_itnim_meminfo(cfg, km_len, dm_len); 293 bfa_itnim_meminfo(cfg, km_len, dm_len);
36 294
37 /** 295 /*
38 * IO memory 296 * IO memory
39 */ 297 */
40 if (cfg->fwcfg.num_ioim_reqs < BFA_IOIM_MIN) 298 if (cfg->fwcfg.num_ioim_reqs < BFA_IOIM_MIN)
@@ -47,7 +305,7 @@ bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
47 305
48 *dm_len += cfg->fwcfg.num_ioim_reqs * BFI_IOIM_SNSLEN; 306 *dm_len += cfg->fwcfg.num_ioim_reqs * BFI_IOIM_SNSLEN;
49 307
50 /** 308 /*
51 * task management command memory 309 * task management command memory
52 */ 310 */
53 if (cfg->fwcfg.num_tskim_reqs < BFA_TSKIM_MIN) 311 if (cfg->fwcfg.num_tskim_reqs < BFA_TSKIM_MIN)
@@ -58,7 +316,7 @@ bfa_fcpim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
58 316
59static void 317static void
60bfa_fcpim_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg, 318bfa_fcpim_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
61 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev) 319 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
62{ 320{
63 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 321 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
64 322
@@ -67,12 +325,14 @@ bfa_fcpim_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
67 bfa_trc(bfa, cfg->fwcfg.num_ioim_reqs); 325 bfa_trc(bfa, cfg->fwcfg.num_ioim_reqs);
68 bfa_trc(bfa, cfg->fwcfg.num_tskim_reqs); 326 bfa_trc(bfa, cfg->fwcfg.num_tskim_reqs);
69 327
70 fcpim->bfa = bfa; 328 fcpim->bfa = bfa;
71 fcpim->num_itnims = cfg->fwcfg.num_rports; 329 fcpim->num_itnims = cfg->fwcfg.num_rports;
72 fcpim->num_ioim_reqs = cfg->fwcfg.num_ioim_reqs; 330 fcpim->num_ioim_reqs = cfg->fwcfg.num_ioim_reqs;
73 fcpim->num_tskim_reqs = cfg->fwcfg.num_tskim_reqs; 331 fcpim->num_tskim_reqs = cfg->fwcfg.num_tskim_reqs;
74 fcpim->path_tov = cfg->drvcfg.path_tov; 332 fcpim->path_tov = cfg->drvcfg.path_tov;
75 fcpim->delay_comp = cfg->drvcfg.delay_comp; 333 fcpim->delay_comp = cfg->drvcfg.delay_comp;
334 fcpim->profile_comp = NULL;
335 fcpim->profile_start = NULL;
76 336
77 bfa_itnim_attach(fcpim, meminfo); 337 bfa_itnim_attach(fcpim, meminfo);
78 bfa_tskim_attach(fcpim, meminfo); 338 bfa_tskim_attach(fcpim, meminfo);
@@ -82,10 +342,6 @@ bfa_fcpim_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
82static void 342static void
83bfa_fcpim_detach(struct bfa_s *bfa) 343bfa_fcpim_detach(struct bfa_s *bfa)
84{ 344{
85 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
86
87 bfa_ioim_detach(fcpim);
88 bfa_tskim_detach(fcpim);
89} 345}
90 346
91static void 347static void
@@ -103,7 +359,7 @@ bfa_fcpim_iocdisable(struct bfa_s *bfa)
103{ 359{
104 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 360 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
105 struct bfa_itnim_s *itnim; 361 struct bfa_itnim_s *itnim;
106 struct list_head *qe, *qen; 362 struct list_head *qe, *qen;
107 363
108 list_for_each_safe(qe, qen, &fcpim->itnim_q) { 364 list_for_each_safe(qe, qen, &fcpim->itnim_q) {
109 itnim = (struct bfa_itnim_s *) qe; 365 itnim = (struct bfa_itnim_s *) qe;
@@ -129,66 +385,2851 @@ bfa_fcpim_path_tov_get(struct bfa_s *bfa)
129 return fcpim->path_tov / 1000; 385 return fcpim->path_tov / 1000;
130} 386}
131 387
132bfa_status_t 388u16
133bfa_fcpim_get_modstats(struct bfa_s *bfa, struct bfa_fcpim_stats_s *modstats) 389bfa_fcpim_qdepth_get(struct bfa_s *bfa)
134{ 390{
135 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 391 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
136 392
137 *modstats = fcpim->stats; 393 return fcpim->q_depth;
394}
138 395
139 return BFA_STATUS_OK; 396/*
397 * BFA ITNIM module state machine functions
398 */
399
400/*
401 * Beginning/unallocated state - no events expected.
402 */
403static void
404bfa_itnim_sm_uninit(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
405{
406 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
407 bfa_trc(itnim->bfa, event);
408
409 switch (event) {
410 case BFA_ITNIM_SM_CREATE:
411 bfa_sm_set_state(itnim, bfa_itnim_sm_created);
412 itnim->is_online = BFA_FALSE;
413 bfa_fcpim_additn(itnim);
414 break;
415
416 default:
417 bfa_sm_fault(itnim->bfa, event);
418 }
140} 419}
141 420
142bfa_status_t 421/*
143bfa_fcpim_clr_modstats(struct bfa_s *bfa) 422 * Beginning state, only online event expected.
423 */
424static void
425bfa_itnim_sm_created(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
426{
427 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
428 bfa_trc(itnim->bfa, event);
429
430 switch (event) {
431 case BFA_ITNIM_SM_ONLINE:
432 if (bfa_itnim_send_fwcreate(itnim))
433 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
434 else
435 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate_qfull);
436 break;
437
438 case BFA_ITNIM_SM_DELETE:
439 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
440 bfa_fcpim_delitn(itnim);
441 break;
442
443 case BFA_ITNIM_SM_HWFAIL:
444 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
445 break;
446
447 default:
448 bfa_sm_fault(itnim->bfa, event);
449 }
450}
451
452/*
453 * Waiting for itnim create response from firmware.
454 */
455static void
456bfa_itnim_sm_fwcreate(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
457{
458 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
459 bfa_trc(itnim->bfa, event);
460
461 switch (event) {
462 case BFA_ITNIM_SM_FWRSP:
463 bfa_sm_set_state(itnim, bfa_itnim_sm_online);
464 itnim->is_online = BFA_TRUE;
465 bfa_itnim_iotov_online(itnim);
466 bfa_itnim_online_cb(itnim);
467 break;
468
469 case BFA_ITNIM_SM_DELETE:
470 bfa_sm_set_state(itnim, bfa_itnim_sm_delete_pending);
471 break;
472
473 case BFA_ITNIM_SM_OFFLINE:
474 if (bfa_itnim_send_fwdelete(itnim))
475 bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete);
476 else
477 bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete_qfull);
478 break;
479
480 case BFA_ITNIM_SM_HWFAIL:
481 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
482 break;
483
484 default:
485 bfa_sm_fault(itnim->bfa, event);
486 }
487}
488
489static void
490bfa_itnim_sm_fwcreate_qfull(struct bfa_itnim_s *itnim,
491 enum bfa_itnim_event event)
492{
493 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
494 bfa_trc(itnim->bfa, event);
495
496 switch (event) {
497 case BFA_ITNIM_SM_QRESUME:
498 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
499 bfa_itnim_send_fwcreate(itnim);
500 break;
501
502 case BFA_ITNIM_SM_DELETE:
503 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
504 bfa_reqq_wcancel(&itnim->reqq_wait);
505 bfa_fcpim_delitn(itnim);
506 break;
507
508 case BFA_ITNIM_SM_OFFLINE:
509 bfa_sm_set_state(itnim, bfa_itnim_sm_offline);
510 bfa_reqq_wcancel(&itnim->reqq_wait);
511 bfa_itnim_offline_cb(itnim);
512 break;
513
514 case BFA_ITNIM_SM_HWFAIL:
515 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
516 bfa_reqq_wcancel(&itnim->reqq_wait);
517 break;
518
519 default:
520 bfa_sm_fault(itnim->bfa, event);
521 }
522}
523
524/*
525 * Waiting for itnim create response from firmware, a delete is pending.
526 */
527static void
528bfa_itnim_sm_delete_pending(struct bfa_itnim_s *itnim,
529 enum bfa_itnim_event event)
530{
531 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
532 bfa_trc(itnim->bfa, event);
533
534 switch (event) {
535 case BFA_ITNIM_SM_FWRSP:
536 if (bfa_itnim_send_fwdelete(itnim))
537 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
538 else
539 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting_qfull);
540 break;
541
542 case BFA_ITNIM_SM_HWFAIL:
543 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
544 bfa_fcpim_delitn(itnim);
545 break;
546
547 default:
548 bfa_sm_fault(itnim->bfa, event);
549 }
550}
551
552/*
553 * Online state - normal parking state.
554 */
555static void
556bfa_itnim_sm_online(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
557{
558 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
559 bfa_trc(itnim->bfa, event);
560
561 switch (event) {
562 case BFA_ITNIM_SM_OFFLINE:
563 bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_offline);
564 itnim->is_online = BFA_FALSE;
565 bfa_itnim_iotov_start(itnim);
566 bfa_itnim_cleanup(itnim);
567 break;
568
569 case BFA_ITNIM_SM_DELETE:
570 bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_delete);
571 itnim->is_online = BFA_FALSE;
572 bfa_itnim_cleanup(itnim);
573 break;
574
575 case BFA_ITNIM_SM_SLER:
576 bfa_sm_set_state(itnim, bfa_itnim_sm_sler);
577 itnim->is_online = BFA_FALSE;
578 bfa_itnim_iotov_start(itnim);
579 bfa_itnim_sler_cb(itnim);
580 break;
581
582 case BFA_ITNIM_SM_HWFAIL:
583 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
584 itnim->is_online = BFA_FALSE;
585 bfa_itnim_iotov_start(itnim);
586 bfa_itnim_iocdisable_cleanup(itnim);
587 break;
588
589 default:
590 bfa_sm_fault(itnim->bfa, event);
591 }
592}
593
594/*
595 * Second level error recovery need.
596 */
597static void
598bfa_itnim_sm_sler(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
599{
600 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
601 bfa_trc(itnim->bfa, event);
602
603 switch (event) {
604 case BFA_ITNIM_SM_OFFLINE:
605 bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_offline);
606 bfa_itnim_cleanup(itnim);
607 break;
608
609 case BFA_ITNIM_SM_DELETE:
610 bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_delete);
611 bfa_itnim_cleanup(itnim);
612 bfa_itnim_iotov_delete(itnim);
613 break;
614
615 case BFA_ITNIM_SM_HWFAIL:
616 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
617 bfa_itnim_iocdisable_cleanup(itnim);
618 break;
619
620 default:
621 bfa_sm_fault(itnim->bfa, event);
622 }
623}
624
625/*
626 * Going offline. Waiting for active IO cleanup.
627 */
628static void
629bfa_itnim_sm_cleanup_offline(struct bfa_itnim_s *itnim,
630 enum bfa_itnim_event event)
631{
632 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
633 bfa_trc(itnim->bfa, event);
634
635 switch (event) {
636 case BFA_ITNIM_SM_CLEANUP:
637 if (bfa_itnim_send_fwdelete(itnim))
638 bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete);
639 else
640 bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete_qfull);
641 break;
642
643 case BFA_ITNIM_SM_DELETE:
644 bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_delete);
645 bfa_itnim_iotov_delete(itnim);
646 break;
647
648 case BFA_ITNIM_SM_HWFAIL:
649 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
650 bfa_itnim_iocdisable_cleanup(itnim);
651 bfa_itnim_offline_cb(itnim);
652 break;
653
654 case BFA_ITNIM_SM_SLER:
655 break;
656
657 default:
658 bfa_sm_fault(itnim->bfa, event);
659 }
660}
661
662/*
663 * Deleting itnim. Waiting for active IO cleanup.
664 */
665static void
666bfa_itnim_sm_cleanup_delete(struct bfa_itnim_s *itnim,
667 enum bfa_itnim_event event)
668{
669 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
670 bfa_trc(itnim->bfa, event);
671
672 switch (event) {
673 case BFA_ITNIM_SM_CLEANUP:
674 if (bfa_itnim_send_fwdelete(itnim))
675 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
676 else
677 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting_qfull);
678 break;
679
680 case BFA_ITNIM_SM_HWFAIL:
681 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
682 bfa_itnim_iocdisable_cleanup(itnim);
683 break;
684
685 default:
686 bfa_sm_fault(itnim->bfa, event);
687 }
688}
689
690/*
691 * Rport offline. Fimrware itnim is being deleted - awaiting f/w response.
692 */
693static void
694bfa_itnim_sm_fwdelete(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
695{
696 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
697 bfa_trc(itnim->bfa, event);
698
699 switch (event) {
700 case BFA_ITNIM_SM_FWRSP:
701 bfa_sm_set_state(itnim, bfa_itnim_sm_offline);
702 bfa_itnim_offline_cb(itnim);
703 break;
704
705 case BFA_ITNIM_SM_DELETE:
706 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
707 break;
708
709 case BFA_ITNIM_SM_HWFAIL:
710 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
711 bfa_itnim_offline_cb(itnim);
712 break;
713
714 default:
715 bfa_sm_fault(itnim->bfa, event);
716 }
717}
718
719static void
720bfa_itnim_sm_fwdelete_qfull(struct bfa_itnim_s *itnim,
721 enum bfa_itnim_event event)
722{
723 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
724 bfa_trc(itnim->bfa, event);
725
726 switch (event) {
727 case BFA_ITNIM_SM_QRESUME:
728 bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete);
729 bfa_itnim_send_fwdelete(itnim);
730 break;
731
732 case BFA_ITNIM_SM_DELETE:
733 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting_qfull);
734 break;
735
736 case BFA_ITNIM_SM_HWFAIL:
737 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
738 bfa_reqq_wcancel(&itnim->reqq_wait);
739 bfa_itnim_offline_cb(itnim);
740 break;
741
742 default:
743 bfa_sm_fault(itnim->bfa, event);
744 }
745}
746
747/*
748 * Offline state.
749 */
750static void
751bfa_itnim_sm_offline(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
752{
753 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
754 bfa_trc(itnim->bfa, event);
755
756 switch (event) {
757 case BFA_ITNIM_SM_DELETE:
758 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
759 bfa_itnim_iotov_delete(itnim);
760 bfa_fcpim_delitn(itnim);
761 break;
762
763 case BFA_ITNIM_SM_ONLINE:
764 if (bfa_itnim_send_fwcreate(itnim))
765 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
766 else
767 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate_qfull);
768 break;
769
770 case BFA_ITNIM_SM_HWFAIL:
771 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
772 break;
773
774 default:
775 bfa_sm_fault(itnim->bfa, event);
776 }
777}
778
779static void
780bfa_itnim_sm_iocdisable(struct bfa_itnim_s *itnim,
781 enum bfa_itnim_event event)
782{
783 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
784 bfa_trc(itnim->bfa, event);
785
786 switch (event) {
787 case BFA_ITNIM_SM_DELETE:
788 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
789 bfa_itnim_iotov_delete(itnim);
790 bfa_fcpim_delitn(itnim);
791 break;
792
793 case BFA_ITNIM_SM_OFFLINE:
794 bfa_itnim_offline_cb(itnim);
795 break;
796
797 case BFA_ITNIM_SM_ONLINE:
798 if (bfa_itnim_send_fwcreate(itnim))
799 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
800 else
801 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate_qfull);
802 break;
803
804 case BFA_ITNIM_SM_HWFAIL:
805 break;
806
807 default:
808 bfa_sm_fault(itnim->bfa, event);
809 }
810}
811
812/*
813 * Itnim is deleted, waiting for firmware response to delete.
814 */
815static void
816bfa_itnim_sm_deleting(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
817{
818 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
819 bfa_trc(itnim->bfa, event);
820
821 switch (event) {
822 case BFA_ITNIM_SM_FWRSP:
823 case BFA_ITNIM_SM_HWFAIL:
824 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
825 bfa_fcpim_delitn(itnim);
826 break;
827
828 default:
829 bfa_sm_fault(itnim->bfa, event);
830 }
831}
832
833static void
834bfa_itnim_sm_deleting_qfull(struct bfa_itnim_s *itnim,
835 enum bfa_itnim_event event)
836{
837 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
838 bfa_trc(itnim->bfa, event);
839
840 switch (event) {
841 case BFA_ITNIM_SM_QRESUME:
842 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
843 bfa_itnim_send_fwdelete(itnim);
844 break;
845
846 case BFA_ITNIM_SM_HWFAIL:
847 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
848 bfa_reqq_wcancel(&itnim->reqq_wait);
849 bfa_fcpim_delitn(itnim);
850 break;
851
852 default:
853 bfa_sm_fault(itnim->bfa, event);
854 }
855}
856
857/*
858 * Initiate cleanup of all IOs on an IOC failure.
859 */
860static void
861bfa_itnim_iocdisable_cleanup(struct bfa_itnim_s *itnim)
862{
863 struct bfa_tskim_s *tskim;
864 struct bfa_ioim_s *ioim;
865 struct list_head *qe, *qen;
866
867 list_for_each_safe(qe, qen, &itnim->tsk_q) {
868 tskim = (struct bfa_tskim_s *) qe;
869 bfa_tskim_iocdisable(tskim);
870 }
871
872 list_for_each_safe(qe, qen, &itnim->io_q) {
873 ioim = (struct bfa_ioim_s *) qe;
874 bfa_ioim_iocdisable(ioim);
875 }
876
877 /*
878 * For IO request in pending queue, we pretend an early timeout.
879 */
880 list_for_each_safe(qe, qen, &itnim->pending_q) {
881 ioim = (struct bfa_ioim_s *) qe;
882 bfa_ioim_tov(ioim);
883 }
884
885 list_for_each_safe(qe, qen, &itnim->io_cleanup_q) {
886 ioim = (struct bfa_ioim_s *) qe;
887 bfa_ioim_iocdisable(ioim);
888 }
889}
890
891/*
892 * IO cleanup completion
893 */
894static void
895bfa_itnim_cleanp_comp(void *itnim_cbarg)
896{
897 struct bfa_itnim_s *itnim = itnim_cbarg;
898
899 bfa_stats(itnim, cleanup_comps);
900 bfa_sm_send_event(itnim, BFA_ITNIM_SM_CLEANUP);
901}
902
903/*
904 * Initiate cleanup of all IOs.
905 */
906static void
907bfa_itnim_cleanup(struct bfa_itnim_s *itnim)
908{
909 struct bfa_ioim_s *ioim;
910 struct bfa_tskim_s *tskim;
911 struct list_head *qe, *qen;
912
913 bfa_wc_init(&itnim->wc, bfa_itnim_cleanp_comp, itnim);
914
915 list_for_each_safe(qe, qen, &itnim->io_q) {
916 ioim = (struct bfa_ioim_s *) qe;
917
918 /*
919 * Move IO to a cleanup queue from active queue so that a later
920 * TM will not pickup this IO.
921 */
922 list_del(&ioim->qe);
923 list_add_tail(&ioim->qe, &itnim->io_cleanup_q);
924
925 bfa_wc_up(&itnim->wc);
926 bfa_ioim_cleanup(ioim);
927 }
928
929 list_for_each_safe(qe, qen, &itnim->tsk_q) {
930 tskim = (struct bfa_tskim_s *) qe;
931 bfa_wc_up(&itnim->wc);
932 bfa_tskim_cleanup(tskim);
933 }
934
935 bfa_wc_wait(&itnim->wc);
936}
937
938static void
939__bfa_cb_itnim_online(void *cbarg, bfa_boolean_t complete)
940{
941 struct bfa_itnim_s *itnim = cbarg;
942
943 if (complete)
944 bfa_cb_itnim_online(itnim->ditn);
945}
946
947static void
948__bfa_cb_itnim_offline(void *cbarg, bfa_boolean_t complete)
949{
950 struct bfa_itnim_s *itnim = cbarg;
951
952 if (complete)
953 bfa_cb_itnim_offline(itnim->ditn);
954}
955
956static void
957__bfa_cb_itnim_sler(void *cbarg, bfa_boolean_t complete)
958{
959 struct bfa_itnim_s *itnim = cbarg;
960
961 if (complete)
962 bfa_cb_itnim_sler(itnim->ditn);
963}
964
965/*
966 * Call to resume any I/O requests waiting for room in request queue.
967 */
968static void
969bfa_itnim_qresume(void *cbarg)
970{
971 struct bfa_itnim_s *itnim = cbarg;
972
973 bfa_sm_send_event(itnim, BFA_ITNIM_SM_QRESUME);
974}
975
976/*
977 * bfa_itnim_public
978 */
979
980void
981bfa_itnim_iodone(struct bfa_itnim_s *itnim)
982{
983 bfa_wc_down(&itnim->wc);
984}
985
986void
987bfa_itnim_tskdone(struct bfa_itnim_s *itnim)
988{
989 bfa_wc_down(&itnim->wc);
990}
991
992void
993bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
994 u32 *dm_len)
995{
996 /*
997 * ITN memory
998 */
999 *km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_itnim_s);
1000}
1001
1002void
1003bfa_itnim_attach(struct bfa_fcpim_mod_s *fcpim, struct bfa_meminfo_s *minfo)
1004{
1005 struct bfa_s *bfa = fcpim->bfa;
1006 struct bfa_itnim_s *itnim;
1007 int i, j;
1008
1009 INIT_LIST_HEAD(&fcpim->itnim_q);
1010
1011 itnim = (struct bfa_itnim_s *) bfa_meminfo_kva(minfo);
1012 fcpim->itnim_arr = itnim;
1013
1014 for (i = 0; i < fcpim->num_itnims; i++, itnim++) {
1015 memset(itnim, 0, sizeof(struct bfa_itnim_s));
1016 itnim->bfa = bfa;
1017 itnim->fcpim = fcpim;
1018 itnim->reqq = BFA_REQQ_QOS_LO;
1019 itnim->rport = BFA_RPORT_FROM_TAG(bfa, i);
1020 itnim->iotov_active = BFA_FALSE;
1021 bfa_reqq_winit(&itnim->reqq_wait, bfa_itnim_qresume, itnim);
1022
1023 INIT_LIST_HEAD(&itnim->io_q);
1024 INIT_LIST_HEAD(&itnim->io_cleanup_q);
1025 INIT_LIST_HEAD(&itnim->pending_q);
1026 INIT_LIST_HEAD(&itnim->tsk_q);
1027 INIT_LIST_HEAD(&itnim->delay_comp_q);
1028 for (j = 0; j < BFA_IOBUCKET_MAX; j++)
1029 itnim->ioprofile.io_latency.min[j] = ~0;
1030 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
1031 }
1032
1033 bfa_meminfo_kva(minfo) = (u8 *) itnim;
1034}
1035
1036void
1037bfa_itnim_iocdisable(struct bfa_itnim_s *itnim)
1038{
1039 bfa_stats(itnim, ioc_disabled);
1040 bfa_sm_send_event(itnim, BFA_ITNIM_SM_HWFAIL);
1041}
1042
1043static bfa_boolean_t
1044bfa_itnim_send_fwcreate(struct bfa_itnim_s *itnim)
1045{
1046 struct bfi_itnim_create_req_s *m;
1047
1048 itnim->msg_no++;
1049
1050 /*
1051 * check for room in queue to send request now
1052 */
1053 m = bfa_reqq_next(itnim->bfa, itnim->reqq);
1054 if (!m) {
1055 bfa_reqq_wait(itnim->bfa, itnim->reqq, &itnim->reqq_wait);
1056 return BFA_FALSE;
1057 }
1058
1059 bfi_h2i_set(m->mh, BFI_MC_ITNIM, BFI_ITNIM_H2I_CREATE_REQ,
1060 bfa_lpuid(itnim->bfa));
1061 m->fw_handle = itnim->rport->fw_handle;
1062 m->class = FC_CLASS_3;
1063 m->seq_rec = itnim->seq_rec;
1064 m->msg_no = itnim->msg_no;
1065 bfa_stats(itnim, fw_create);
1066
1067 /*
1068 * queue I/O message to firmware
1069 */
1070 bfa_reqq_produce(itnim->bfa, itnim->reqq);
1071 return BFA_TRUE;
1072}
1073
1074static bfa_boolean_t
1075bfa_itnim_send_fwdelete(struct bfa_itnim_s *itnim)
1076{
1077 struct bfi_itnim_delete_req_s *m;
1078
1079 /*
1080 * check for room in queue to send request now
1081 */
1082 m = bfa_reqq_next(itnim->bfa, itnim->reqq);
1083 if (!m) {
1084 bfa_reqq_wait(itnim->bfa, itnim->reqq, &itnim->reqq_wait);
1085 return BFA_FALSE;
1086 }
1087
1088 bfi_h2i_set(m->mh, BFI_MC_ITNIM, BFI_ITNIM_H2I_DELETE_REQ,
1089 bfa_lpuid(itnim->bfa));
1090 m->fw_handle = itnim->rport->fw_handle;
1091 bfa_stats(itnim, fw_delete);
1092
1093 /*
1094 * queue I/O message to firmware
1095 */
1096 bfa_reqq_produce(itnim->bfa, itnim->reqq);
1097 return BFA_TRUE;
1098}
1099
1100/*
1101 * Cleanup all pending failed inflight requests.
1102 */
1103static void
1104bfa_itnim_delayed_comp(struct bfa_itnim_s *itnim, bfa_boolean_t iotov)
1105{
1106 struct bfa_ioim_s *ioim;
1107 struct list_head *qe, *qen;
1108
1109 list_for_each_safe(qe, qen, &itnim->delay_comp_q) {
1110 ioim = (struct bfa_ioim_s *)qe;
1111 bfa_ioim_delayed_comp(ioim, iotov);
1112 }
1113}
1114
1115/*
1116 * Start all pending IO requests.
1117 */
1118static void
1119bfa_itnim_iotov_online(struct bfa_itnim_s *itnim)
1120{
1121 struct bfa_ioim_s *ioim;
1122
1123 bfa_itnim_iotov_stop(itnim);
1124
1125 /*
1126 * Abort all inflight IO requests in the queue
1127 */
1128 bfa_itnim_delayed_comp(itnim, BFA_FALSE);
1129
1130 /*
1131 * Start all pending IO requests.
1132 */
1133 while (!list_empty(&itnim->pending_q)) {
1134 bfa_q_deq(&itnim->pending_q, &ioim);
1135 list_add_tail(&ioim->qe, &itnim->io_q);
1136 bfa_ioim_start(ioim);
1137 }
1138}
1139
1140/*
1141 * Fail all pending IO requests
1142 */
1143static void
1144bfa_itnim_iotov_cleanup(struct bfa_itnim_s *itnim)
1145{
1146 struct bfa_ioim_s *ioim;
1147
1148 /*
1149 * Fail all inflight IO requests in the queue
1150 */
1151 bfa_itnim_delayed_comp(itnim, BFA_TRUE);
1152
1153 /*
1154 * Fail any pending IO requests.
1155 */
1156 while (!list_empty(&itnim->pending_q)) {
1157 bfa_q_deq(&itnim->pending_q, &ioim);
1158 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
1159 bfa_ioim_tov(ioim);
1160 }
1161}
1162
1163/*
1164 * IO TOV timer callback. Fail any pending IO requests.
1165 */
1166static void
1167bfa_itnim_iotov(void *itnim_arg)
1168{
1169 struct bfa_itnim_s *itnim = itnim_arg;
1170
1171 itnim->iotov_active = BFA_FALSE;
1172
1173 bfa_cb_itnim_tov_begin(itnim->ditn);
1174 bfa_itnim_iotov_cleanup(itnim);
1175 bfa_cb_itnim_tov(itnim->ditn);
1176}
1177
1178/*
1179 * Start IO TOV timer for failing back pending IO requests in offline state.
1180 */
1181static void
1182bfa_itnim_iotov_start(struct bfa_itnim_s *itnim)
1183{
1184 if (itnim->fcpim->path_tov > 0) {
1185
1186 itnim->iotov_active = BFA_TRUE;
1187 WARN_ON(!bfa_itnim_hold_io(itnim));
1188 bfa_timer_start(itnim->bfa, &itnim->timer,
1189 bfa_itnim_iotov, itnim, itnim->fcpim->path_tov);
1190 }
1191}
1192
1193/*
1194 * Stop IO TOV timer.
1195 */
1196static void
1197bfa_itnim_iotov_stop(struct bfa_itnim_s *itnim)
1198{
1199 if (itnim->iotov_active) {
1200 itnim->iotov_active = BFA_FALSE;
1201 bfa_timer_stop(&itnim->timer);
1202 }
1203}
1204
1205/*
1206 * Stop IO TOV timer.
1207 */
1208static void
1209bfa_itnim_iotov_delete(struct bfa_itnim_s *itnim)
1210{
1211 bfa_boolean_t pathtov_active = BFA_FALSE;
1212
1213 if (itnim->iotov_active)
1214 pathtov_active = BFA_TRUE;
1215
1216 bfa_itnim_iotov_stop(itnim);
1217 if (pathtov_active)
1218 bfa_cb_itnim_tov_begin(itnim->ditn);
1219 bfa_itnim_iotov_cleanup(itnim);
1220 if (pathtov_active)
1221 bfa_cb_itnim_tov(itnim->ditn);
1222}
1223
1224static void
1225bfa_itnim_update_del_itn_stats(struct bfa_itnim_s *itnim)
1226{
1227 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(itnim->bfa);
1228 fcpim->del_itn_stats.del_itn_iocomp_aborted +=
1229 itnim->stats.iocomp_aborted;
1230 fcpim->del_itn_stats.del_itn_iocomp_timedout +=
1231 itnim->stats.iocomp_timedout;
1232 fcpim->del_itn_stats.del_itn_iocom_sqer_needed +=
1233 itnim->stats.iocom_sqer_needed;
1234 fcpim->del_itn_stats.del_itn_iocom_res_free +=
1235 itnim->stats.iocom_res_free;
1236 fcpim->del_itn_stats.del_itn_iocom_hostabrts +=
1237 itnim->stats.iocom_hostabrts;
1238 fcpim->del_itn_stats.del_itn_total_ios += itnim->stats.total_ios;
1239 fcpim->del_itn_stats.del_io_iocdowns += itnim->stats.io_iocdowns;
1240 fcpim->del_itn_stats.del_tm_iocdowns += itnim->stats.tm_iocdowns;
1241}
1242
1243/*
1244 * bfa_itnim_public
1245 */
1246
1247/*
1248 * Itnim interrupt processing.
1249 */
1250void
1251bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
144{ 1252{
145 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 1253 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
1254 union bfi_itnim_i2h_msg_u msg;
1255 struct bfa_itnim_s *itnim;
146 1256
147 memset(&fcpim->stats, 0, sizeof(struct bfa_fcpim_stats_s)); 1257 bfa_trc(bfa, m->mhdr.msg_id);
148 1258
149 return BFA_STATUS_OK; 1259 msg.msg = m;
1260
1261 switch (m->mhdr.msg_id) {
1262 case BFI_ITNIM_I2H_CREATE_RSP:
1263 itnim = BFA_ITNIM_FROM_TAG(fcpim,
1264 msg.create_rsp->bfa_handle);
1265 WARN_ON(msg.create_rsp->status != BFA_STATUS_OK);
1266 bfa_stats(itnim, create_comps);
1267 bfa_sm_send_event(itnim, BFA_ITNIM_SM_FWRSP);
1268 break;
1269
1270 case BFI_ITNIM_I2H_DELETE_RSP:
1271 itnim = BFA_ITNIM_FROM_TAG(fcpim,
1272 msg.delete_rsp->bfa_handle);
1273 WARN_ON(msg.delete_rsp->status != BFA_STATUS_OK);
1274 bfa_stats(itnim, delete_comps);
1275 bfa_sm_send_event(itnim, BFA_ITNIM_SM_FWRSP);
1276 break;
1277
1278 case BFI_ITNIM_I2H_SLER_EVENT:
1279 itnim = BFA_ITNIM_FROM_TAG(fcpim,
1280 msg.sler_event->bfa_handle);
1281 bfa_stats(itnim, sler_events);
1282 bfa_sm_send_event(itnim, BFA_ITNIM_SM_SLER);
1283 break;
1284
1285 default:
1286 bfa_trc(bfa, m->mhdr.msg_id);
1287 WARN_ON(1);
1288 }
1289}
1290
1291/*
1292 * bfa_itnim_api
1293 */
1294
1295struct bfa_itnim_s *
1296bfa_itnim_create(struct bfa_s *bfa, struct bfa_rport_s *rport, void *ditn)
1297{
1298 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
1299 struct bfa_itnim_s *itnim;
1300
1301 itnim = BFA_ITNIM_FROM_TAG(fcpim, rport->rport_tag);
1302 WARN_ON(itnim->rport != rport);
1303
1304 itnim->ditn = ditn;
1305
1306 bfa_stats(itnim, creates);
1307 bfa_sm_send_event(itnim, BFA_ITNIM_SM_CREATE);
1308
1309 return itnim;
1310}
1311
1312void
1313bfa_itnim_delete(struct bfa_itnim_s *itnim)
1314{
1315 bfa_stats(itnim, deletes);
1316 bfa_sm_send_event(itnim, BFA_ITNIM_SM_DELETE);
1317}
1318
1319void
1320bfa_itnim_online(struct bfa_itnim_s *itnim, bfa_boolean_t seq_rec)
1321{
1322 itnim->seq_rec = seq_rec;
1323 bfa_stats(itnim, onlines);
1324 bfa_sm_send_event(itnim, BFA_ITNIM_SM_ONLINE);
1325}
1326
1327void
1328bfa_itnim_offline(struct bfa_itnim_s *itnim)
1329{
1330 bfa_stats(itnim, offlines);
1331 bfa_sm_send_event(itnim, BFA_ITNIM_SM_OFFLINE);
1332}
1333
1334/*
1335 * Return true if itnim is considered offline for holding off IO request.
1336 * IO is not held if itnim is being deleted.
1337 */
1338bfa_boolean_t
1339bfa_itnim_hold_io(struct bfa_itnim_s *itnim)
1340{
1341 return itnim->fcpim->path_tov && itnim->iotov_active &&
1342 (bfa_sm_cmp_state(itnim, bfa_itnim_sm_fwcreate) ||
1343 bfa_sm_cmp_state(itnim, bfa_itnim_sm_sler) ||
1344 bfa_sm_cmp_state(itnim, bfa_itnim_sm_cleanup_offline) ||
1345 bfa_sm_cmp_state(itnim, bfa_itnim_sm_fwdelete) ||
1346 bfa_sm_cmp_state(itnim, bfa_itnim_sm_offline) ||
1347 bfa_sm_cmp_state(itnim, bfa_itnim_sm_iocdisable));
1348}
1349
1350void
1351bfa_itnim_clear_stats(struct bfa_itnim_s *itnim)
1352{
1353 int j;
1354 memset(&itnim->stats, 0, sizeof(itnim->stats));
1355 memset(&itnim->ioprofile, 0, sizeof(itnim->ioprofile));
1356 for (j = 0; j < BFA_IOBUCKET_MAX; j++)
1357 itnim->ioprofile.io_latency.min[j] = ~0;
1358}
1359
1360/*
1361 * BFA IO module state machine functions
1362 */
1363
1364/*
1365 * IO is not started (unallocated).
1366 */
1367static void
1368bfa_ioim_sm_uninit(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1369{
1370 switch (event) {
1371 case BFA_IOIM_SM_START:
1372 if (!bfa_itnim_is_online(ioim->itnim)) {
1373 if (!bfa_itnim_hold_io(ioim->itnim)) {
1374 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1375 list_del(&ioim->qe);
1376 list_add_tail(&ioim->qe,
1377 &ioim->fcpim->ioim_comp_q);
1378 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
1379 __bfa_cb_ioim_pathtov, ioim);
1380 } else {
1381 list_del(&ioim->qe);
1382 list_add_tail(&ioim->qe,
1383 &ioim->itnim->pending_q);
1384 }
1385 break;
1386 }
1387
1388 if (ioim->nsges > BFI_SGE_INLINE) {
1389 if (!bfa_ioim_sgpg_alloc(ioim)) {
1390 bfa_sm_set_state(ioim, bfa_ioim_sm_sgalloc);
1391 return;
1392 }
1393 }
1394
1395 if (!bfa_ioim_send_ioreq(ioim)) {
1396 bfa_sm_set_state(ioim, bfa_ioim_sm_qfull);
1397 break;
1398 }
1399
1400 bfa_sm_set_state(ioim, bfa_ioim_sm_active);
1401 break;
1402
1403 case BFA_IOIM_SM_IOTOV:
1404 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1405 bfa_ioim_move_to_comp_q(ioim);
1406 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
1407 __bfa_cb_ioim_pathtov, ioim);
1408 break;
1409
1410 case BFA_IOIM_SM_ABORT:
1411 /*
1412 * IO in pending queue can get abort requests. Complete abort
1413 * requests immediately.
1414 */
1415 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1416 WARN_ON(!bfa_q_is_on_q(&ioim->itnim->pending_q, ioim));
1417 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
1418 __bfa_cb_ioim_abort, ioim);
1419 break;
1420
1421 default:
1422 bfa_sm_fault(ioim->bfa, event);
1423 }
1424}
1425
1426/*
1427 * IO is waiting for SG pages.
1428 */
1429static void
1430bfa_ioim_sm_sgalloc(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1431{
1432 bfa_trc(ioim->bfa, ioim->iotag);
1433 bfa_trc(ioim->bfa, event);
1434
1435 switch (event) {
1436 case BFA_IOIM_SM_SGALLOCED:
1437 if (!bfa_ioim_send_ioreq(ioim)) {
1438 bfa_sm_set_state(ioim, bfa_ioim_sm_qfull);
1439 break;
1440 }
1441 bfa_sm_set_state(ioim, bfa_ioim_sm_active);
1442 break;
1443
1444 case BFA_IOIM_SM_CLEANUP:
1445 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1446 bfa_sgpg_wcancel(ioim->bfa, &ioim->iosp->sgpg_wqe);
1447 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
1448 ioim);
1449 bfa_ioim_notify_cleanup(ioim);
1450 break;
1451
1452 case BFA_IOIM_SM_ABORT:
1453 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1454 bfa_sgpg_wcancel(ioim->bfa, &ioim->iosp->sgpg_wqe);
1455 bfa_ioim_move_to_comp_q(ioim);
1456 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
1457 ioim);
1458 break;
1459
1460 case BFA_IOIM_SM_HWFAIL:
1461 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1462 bfa_sgpg_wcancel(ioim->bfa, &ioim->iosp->sgpg_wqe);
1463 bfa_ioim_move_to_comp_q(ioim);
1464 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
1465 ioim);
1466 break;
1467
1468 default:
1469 bfa_sm_fault(ioim->bfa, event);
1470 }
1471}
1472
1473/*
1474 * IO is active.
1475 */
1476static void
1477bfa_ioim_sm_active(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1478{
1479 switch (event) {
1480 case BFA_IOIM_SM_COMP_GOOD:
1481 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1482 bfa_ioim_move_to_comp_q(ioim);
1483 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
1484 __bfa_cb_ioim_good_comp, ioim);
1485 break;
1486
1487 case BFA_IOIM_SM_COMP:
1488 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1489 bfa_ioim_move_to_comp_q(ioim);
1490 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_comp,
1491 ioim);
1492 break;
1493
1494 case BFA_IOIM_SM_DONE:
1495 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
1496 bfa_ioim_move_to_comp_q(ioim);
1497 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_comp,
1498 ioim);
1499 break;
1500
1501 case BFA_IOIM_SM_ABORT:
1502 ioim->iosp->abort_explicit = BFA_TRUE;
1503 ioim->io_cbfn = __bfa_cb_ioim_abort;
1504
1505 if (bfa_ioim_send_abort(ioim))
1506 bfa_sm_set_state(ioim, bfa_ioim_sm_abort);
1507 else {
1508 bfa_sm_set_state(ioim, bfa_ioim_sm_abort_qfull);
1509 bfa_stats(ioim->itnim, qwait);
1510 bfa_reqq_wait(ioim->bfa, ioim->reqq,
1511 &ioim->iosp->reqq_wait);
1512 }
1513 break;
1514
1515 case BFA_IOIM_SM_CLEANUP:
1516 ioim->iosp->abort_explicit = BFA_FALSE;
1517 ioim->io_cbfn = __bfa_cb_ioim_failed;
1518
1519 if (bfa_ioim_send_abort(ioim))
1520 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup);
1521 else {
1522 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup_qfull);
1523 bfa_stats(ioim->itnim, qwait);
1524 bfa_reqq_wait(ioim->bfa, ioim->reqq,
1525 &ioim->iosp->reqq_wait);
1526 }
1527 break;
1528
1529 case BFA_IOIM_SM_HWFAIL:
1530 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1531 bfa_ioim_move_to_comp_q(ioim);
1532 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
1533 ioim);
1534 break;
1535
1536 case BFA_IOIM_SM_SQRETRY:
1537 if (bfa_ioim_maxretry_reached(ioim)) {
1538 /* max retry reached, free IO */
1539 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
1540 bfa_ioim_move_to_comp_q(ioim);
1541 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
1542 __bfa_cb_ioim_failed, ioim);
1543 break;
1544 }
1545 /* waiting for IO tag resource free */
1546 bfa_sm_set_state(ioim, bfa_ioim_sm_cmnd_retry);
1547 break;
1548
1549 default:
1550 bfa_sm_fault(ioim->bfa, event);
1551 }
1552}
1553
1554/*
1555 * IO is retried with new tag.
1556 */
1557static void
1558bfa_ioim_sm_cmnd_retry(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1559{
1560 switch (event) {
1561 case BFA_IOIM_SM_FREE:
1562 /* abts and rrq done. Now retry the IO with new tag */
1563 bfa_ioim_update_iotag(ioim);
1564 if (!bfa_ioim_send_ioreq(ioim)) {
1565 bfa_sm_set_state(ioim, bfa_ioim_sm_qfull);
1566 break;
1567 }
1568 bfa_sm_set_state(ioim, bfa_ioim_sm_active);
1569 break;
1570
1571 case BFA_IOIM_SM_CLEANUP:
1572 ioim->iosp->abort_explicit = BFA_FALSE;
1573 ioim->io_cbfn = __bfa_cb_ioim_failed;
1574
1575 if (bfa_ioim_send_abort(ioim))
1576 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup);
1577 else {
1578 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup_qfull);
1579 bfa_stats(ioim->itnim, qwait);
1580 bfa_reqq_wait(ioim->bfa, ioim->reqq,
1581 &ioim->iosp->reqq_wait);
1582 }
1583 break;
1584
1585 case BFA_IOIM_SM_HWFAIL:
1586 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1587 bfa_ioim_move_to_comp_q(ioim);
1588 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
1589 __bfa_cb_ioim_failed, ioim);
1590 break;
1591
1592 case BFA_IOIM_SM_ABORT:
1593 /* in this state IO abort is done.
1594 * Waiting for IO tag resource free.
1595 */
1596 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
1597 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
1598 ioim);
1599 break;
1600
1601 default:
1602 bfa_sm_fault(ioim->bfa, event);
1603 }
1604}
1605
1606/*
1607 * IO is being aborted, waiting for completion from firmware.
1608 */
1609static void
1610bfa_ioim_sm_abort(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1611{
1612 bfa_trc(ioim->bfa, ioim->iotag);
1613 bfa_trc(ioim->bfa, event);
1614
1615 switch (event) {
1616 case BFA_IOIM_SM_COMP_GOOD:
1617 case BFA_IOIM_SM_COMP:
1618 case BFA_IOIM_SM_DONE:
1619 case BFA_IOIM_SM_FREE:
1620 break;
1621
1622 case BFA_IOIM_SM_ABORT_DONE:
1623 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
1624 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
1625 ioim);
1626 break;
1627
1628 case BFA_IOIM_SM_ABORT_COMP:
1629 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1630 bfa_ioim_move_to_comp_q(ioim);
1631 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
1632 ioim);
1633 break;
1634
1635 case BFA_IOIM_SM_COMP_UTAG:
1636 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1637 bfa_ioim_move_to_comp_q(ioim);
1638 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
1639 ioim);
1640 break;
1641
1642 case BFA_IOIM_SM_CLEANUP:
1643 WARN_ON(ioim->iosp->abort_explicit != BFA_TRUE);
1644 ioim->iosp->abort_explicit = BFA_FALSE;
1645
1646 if (bfa_ioim_send_abort(ioim))
1647 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup);
1648 else {
1649 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup_qfull);
1650 bfa_stats(ioim->itnim, qwait);
1651 bfa_reqq_wait(ioim->bfa, ioim->reqq,
1652 &ioim->iosp->reqq_wait);
1653 }
1654 break;
1655
1656 case BFA_IOIM_SM_HWFAIL:
1657 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1658 bfa_ioim_move_to_comp_q(ioim);
1659 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
1660 ioim);
1661 break;
1662
1663 default:
1664 bfa_sm_fault(ioim->bfa, event);
1665 }
1666}
1667
1668/*
1669 * IO is being cleaned up (implicit abort), waiting for completion from
1670 * firmware.
1671 */
1672static void
1673bfa_ioim_sm_cleanup(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1674{
1675 bfa_trc(ioim->bfa, ioim->iotag);
1676 bfa_trc(ioim->bfa, event);
1677
1678 switch (event) {
1679 case BFA_IOIM_SM_COMP_GOOD:
1680 case BFA_IOIM_SM_COMP:
1681 case BFA_IOIM_SM_DONE:
1682 case BFA_IOIM_SM_FREE:
1683 break;
1684
1685 case BFA_IOIM_SM_ABORT:
1686 /*
1687 * IO is already being aborted implicitly
1688 */
1689 ioim->io_cbfn = __bfa_cb_ioim_abort;
1690 break;
1691
1692 case BFA_IOIM_SM_ABORT_DONE:
1693 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
1694 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
1695 bfa_ioim_notify_cleanup(ioim);
1696 break;
1697
1698 case BFA_IOIM_SM_ABORT_COMP:
1699 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1700 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
1701 bfa_ioim_notify_cleanup(ioim);
1702 break;
1703
1704 case BFA_IOIM_SM_COMP_UTAG:
1705 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1706 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
1707 bfa_ioim_notify_cleanup(ioim);
1708 break;
1709
1710 case BFA_IOIM_SM_HWFAIL:
1711 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1712 bfa_ioim_move_to_comp_q(ioim);
1713 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
1714 ioim);
1715 break;
1716
1717 case BFA_IOIM_SM_CLEANUP:
1718 /*
1719 * IO can be in cleanup state already due to TM command.
1720 * 2nd cleanup request comes from ITN offline event.
1721 */
1722 break;
1723
1724 default:
1725 bfa_sm_fault(ioim->bfa, event);
1726 }
1727}
1728
1729/*
1730 * IO is waiting for room in request CQ
1731 */
1732static void
1733bfa_ioim_sm_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1734{
1735 bfa_trc(ioim->bfa, ioim->iotag);
1736 bfa_trc(ioim->bfa, event);
1737
1738 switch (event) {
1739 case BFA_IOIM_SM_QRESUME:
1740 bfa_sm_set_state(ioim, bfa_ioim_sm_active);
1741 bfa_ioim_send_ioreq(ioim);
1742 break;
1743
1744 case BFA_IOIM_SM_ABORT:
1745 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1746 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
1747 bfa_ioim_move_to_comp_q(ioim);
1748 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
1749 ioim);
1750 break;
1751
1752 case BFA_IOIM_SM_CLEANUP:
1753 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1754 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
1755 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
1756 ioim);
1757 bfa_ioim_notify_cleanup(ioim);
1758 break;
1759
1760 case BFA_IOIM_SM_HWFAIL:
1761 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1762 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
1763 bfa_ioim_move_to_comp_q(ioim);
1764 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
1765 ioim);
1766 break;
1767
1768 default:
1769 bfa_sm_fault(ioim->bfa, event);
1770 }
1771}
1772
1773/*
1774 * Active IO is being aborted, waiting for room in request CQ.
1775 */
1776static void
1777bfa_ioim_sm_abort_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1778{
1779 bfa_trc(ioim->bfa, ioim->iotag);
1780 bfa_trc(ioim->bfa, event);
1781
1782 switch (event) {
1783 case BFA_IOIM_SM_QRESUME:
1784 bfa_sm_set_state(ioim, bfa_ioim_sm_abort);
1785 bfa_ioim_send_abort(ioim);
1786 break;
1787
1788 case BFA_IOIM_SM_CLEANUP:
1789 WARN_ON(ioim->iosp->abort_explicit != BFA_TRUE);
1790 ioim->iosp->abort_explicit = BFA_FALSE;
1791 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup_qfull);
1792 break;
1793
1794 case BFA_IOIM_SM_COMP_GOOD:
1795 case BFA_IOIM_SM_COMP:
1796 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1797 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
1798 bfa_ioim_move_to_comp_q(ioim);
1799 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
1800 ioim);
1801 break;
1802
1803 case BFA_IOIM_SM_DONE:
1804 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
1805 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
1806 bfa_ioim_move_to_comp_q(ioim);
1807 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
1808 ioim);
1809 break;
1810
1811 case BFA_IOIM_SM_HWFAIL:
1812 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1813 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
1814 bfa_ioim_move_to_comp_q(ioim);
1815 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
1816 ioim);
1817 break;
1818
1819 default:
1820 bfa_sm_fault(ioim->bfa, event);
1821 }
1822}
1823
1824/*
1825 * Active IO is being cleaned up, waiting for room in request CQ.
1826 */
1827static void
1828bfa_ioim_sm_cleanup_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1829{
1830 bfa_trc(ioim->bfa, ioim->iotag);
1831 bfa_trc(ioim->bfa, event);
1832
1833 switch (event) {
1834 case BFA_IOIM_SM_QRESUME:
1835 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup);
1836 bfa_ioim_send_abort(ioim);
1837 break;
1838
1839 case BFA_IOIM_SM_ABORT:
1840 /*
1841 * IO is already being cleaned up implicitly
1842 */
1843 ioim->io_cbfn = __bfa_cb_ioim_abort;
1844 break;
1845
1846 case BFA_IOIM_SM_COMP_GOOD:
1847 case BFA_IOIM_SM_COMP:
1848 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1849 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
1850 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
1851 bfa_ioim_notify_cleanup(ioim);
1852 break;
1853
1854 case BFA_IOIM_SM_DONE:
1855 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
1856 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
1857 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
1858 bfa_ioim_notify_cleanup(ioim);
1859 break;
1860
1861 case BFA_IOIM_SM_HWFAIL:
1862 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1863 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
1864 bfa_ioim_move_to_comp_q(ioim);
1865 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
1866 ioim);
1867 break;
1868
1869 default:
1870 bfa_sm_fault(ioim->bfa, event);
1871 }
1872}
1873
1874/*
1875 * IO bfa callback is pending.
1876 */
1877static void
1878bfa_ioim_sm_hcb(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1879{
1880 switch (event) {
1881 case BFA_IOIM_SM_HCB:
1882 bfa_sm_set_state(ioim, bfa_ioim_sm_uninit);
1883 bfa_ioim_free(ioim);
1884 break;
1885
1886 case BFA_IOIM_SM_CLEANUP:
1887 bfa_ioim_notify_cleanup(ioim);
1888 break;
1889
1890 case BFA_IOIM_SM_HWFAIL:
1891 break;
1892
1893 default:
1894 bfa_sm_fault(ioim->bfa, event);
1895 }
1896}
1897
1898/*
1899 * IO bfa callback is pending. IO resource cannot be freed.
1900 */
1901static void
1902bfa_ioim_sm_hcb_free(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1903{
1904 bfa_trc(ioim->bfa, ioim->iotag);
1905 bfa_trc(ioim->bfa, event);
1906
1907 switch (event) {
1908 case BFA_IOIM_SM_HCB:
1909 bfa_sm_set_state(ioim, bfa_ioim_sm_resfree);
1910 list_del(&ioim->qe);
1911 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_resfree_q);
1912 break;
1913
1914 case BFA_IOIM_SM_FREE:
1915 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1916 break;
1917
1918 case BFA_IOIM_SM_CLEANUP:
1919 bfa_ioim_notify_cleanup(ioim);
1920 break;
1921
1922 case BFA_IOIM_SM_HWFAIL:
1923 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
1924 break;
1925
1926 default:
1927 bfa_sm_fault(ioim->bfa, event);
1928 }
1929}
1930
1931/*
1932 * IO is completed, waiting resource free from firmware.
1933 */
1934static void
1935bfa_ioim_sm_resfree(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
1936{
1937 bfa_trc(ioim->bfa, ioim->iotag);
1938 bfa_trc(ioim->bfa, event);
1939
1940 switch (event) {
1941 case BFA_IOIM_SM_FREE:
1942 bfa_sm_set_state(ioim, bfa_ioim_sm_uninit);
1943 bfa_ioim_free(ioim);
1944 break;
1945
1946 case BFA_IOIM_SM_CLEANUP:
1947 bfa_ioim_notify_cleanup(ioim);
1948 break;
1949
1950 case BFA_IOIM_SM_HWFAIL:
1951 break;
1952
1953 default:
1954 bfa_sm_fault(ioim->bfa, event);
1955 }
1956}
1957
1958
1959static void
1960__bfa_cb_ioim_good_comp(void *cbarg, bfa_boolean_t complete)
1961{
1962 struct bfa_ioim_s *ioim = cbarg;
1963
1964 if (!complete) {
1965 bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
1966 return;
1967 }
1968
1969 bfa_cb_ioim_good_comp(ioim->bfa->bfad, ioim->dio);
1970}
1971
1972static void
1973__bfa_cb_ioim_comp(void *cbarg, bfa_boolean_t complete)
1974{
1975 struct bfa_ioim_s *ioim = cbarg;
1976 struct bfi_ioim_rsp_s *m;
1977 u8 *snsinfo = NULL;
1978 u8 sns_len = 0;
1979 s32 residue = 0;
1980
1981 if (!complete) {
1982 bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
1983 return;
1984 }
1985
1986 m = (struct bfi_ioim_rsp_s *) &ioim->iosp->comp_rspmsg;
1987 if (m->io_status == BFI_IOIM_STS_OK) {
1988 /*
1989 * setup sense information, if present
1990 */
1991 if ((m->scsi_status == SCSI_STATUS_CHECK_CONDITION) &&
1992 m->sns_len) {
1993 sns_len = m->sns_len;
1994 snsinfo = ioim->iosp->snsinfo;
1995 }
1996
1997 /*
1998 * setup residue value correctly for normal completions
1999 */
2000 if (m->resid_flags == FCP_RESID_UNDER) {
2001 residue = be32_to_cpu(m->residue);
2002 bfa_stats(ioim->itnim, iocomp_underrun);
2003 }
2004 if (m->resid_flags == FCP_RESID_OVER) {
2005 residue = be32_to_cpu(m->residue);
2006 residue = -residue;
2007 bfa_stats(ioim->itnim, iocomp_overrun);
2008 }
2009 }
2010
2011 bfa_cb_ioim_done(ioim->bfa->bfad, ioim->dio, m->io_status,
2012 m->scsi_status, sns_len, snsinfo, residue);
2013}
2014
2015static void
2016__bfa_cb_ioim_failed(void *cbarg, bfa_boolean_t complete)
2017{
2018 struct bfa_ioim_s *ioim = cbarg;
2019
2020 if (!complete) {
2021 bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
2022 return;
2023 }
2024
2025 bfa_cb_ioim_done(ioim->bfa->bfad, ioim->dio, BFI_IOIM_STS_ABORTED,
2026 0, 0, NULL, 0);
2027}
2028
2029static void
2030__bfa_cb_ioim_pathtov(void *cbarg, bfa_boolean_t complete)
2031{
2032 struct bfa_ioim_s *ioim = cbarg;
2033
2034 bfa_stats(ioim->itnim, path_tov_expired);
2035 if (!complete) {
2036 bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
2037 return;
2038 }
2039
2040 bfa_cb_ioim_done(ioim->bfa->bfad, ioim->dio, BFI_IOIM_STS_PATHTOV,
2041 0, 0, NULL, 0);
2042}
2043
2044static void
2045__bfa_cb_ioim_abort(void *cbarg, bfa_boolean_t complete)
2046{
2047 struct bfa_ioim_s *ioim = cbarg;
2048
2049 if (!complete) {
2050 bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
2051 return;
2052 }
2053
2054 bfa_cb_ioim_abort(ioim->bfa->bfad, ioim->dio);
2055}
2056
2057static void
2058bfa_ioim_sgpg_alloced(void *cbarg)
2059{
2060 struct bfa_ioim_s *ioim = cbarg;
2061
2062 ioim->nsgpgs = BFA_SGPG_NPAGE(ioim->nsges);
2063 list_splice_tail_init(&ioim->iosp->sgpg_wqe.sgpg_q, &ioim->sgpg_q);
2064 ioim->sgpg = bfa_q_first(&ioim->sgpg_q);
2065 bfa_sm_send_event(ioim, BFA_IOIM_SM_SGALLOCED);
2066}
2067
2068/*
2069 * Send I/O request to firmware.
2070 */
2071static bfa_boolean_t
2072bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim)
2073{
2074 struct bfa_itnim_s *itnim = ioim->itnim;
2075 struct bfi_ioim_req_s *m;
2076 static struct fcp_cmnd_s cmnd_z0 = { { { 0 } } };
2077 struct bfi_sge_s *sge, *sgpge;
2078 u32 pgdlen = 0;
2079 u32 fcp_dl;
2080 u64 addr;
2081 struct scatterlist *sg;
2082 struct bfa_sgpg_s *sgpg;
2083 struct scsi_cmnd *cmnd = (struct scsi_cmnd *) ioim->dio;
2084 u32 i, sge_id, pgcumsz;
2085 enum dma_data_direction dmadir;
2086
2087 /*
2088 * check for room in queue to send request now
2089 */
2090 m = bfa_reqq_next(ioim->bfa, ioim->reqq);
2091 if (!m) {
2092 bfa_stats(ioim->itnim, qwait);
2093 bfa_reqq_wait(ioim->bfa, ioim->reqq,
2094 &ioim->iosp->reqq_wait);
2095 return BFA_FALSE;
2096 }
2097
2098 /*
2099 * build i/o request message next
2100 */
2101 m->io_tag = cpu_to_be16(ioim->iotag);
2102 m->rport_hdl = ioim->itnim->rport->fw_handle;
2103 m->io_timeout = 0;
2104
2105 sge = &m->sges[0];
2106 sgpg = ioim->sgpg;
2107 sge_id = 0;
2108 sgpge = NULL;
2109 pgcumsz = 0;
2110 scsi_for_each_sg(cmnd, sg, ioim->nsges, i) {
2111 if (i == 0) {
2112 /* build inline IO SG element */
2113 addr = bfa_sgaddr_le(sg_dma_address(sg));
2114 sge->sga = *(union bfi_addr_u *) &addr;
2115 pgdlen = sg_dma_len(sg);
2116 sge->sg_len = pgdlen;
2117 sge->flags = (ioim->nsges > BFI_SGE_INLINE) ?
2118 BFI_SGE_DATA_CPL : BFI_SGE_DATA_LAST;
2119 bfa_sge_to_be(sge);
2120 sge++;
2121 } else {
2122 if (sge_id == 0)
2123 sgpge = sgpg->sgpg->sges;
2124
2125 addr = bfa_sgaddr_le(sg_dma_address(sg));
2126 sgpge->sga = *(union bfi_addr_u *) &addr;
2127 sgpge->sg_len = sg_dma_len(sg);
2128 pgcumsz += sgpge->sg_len;
2129
2130 /* set flags */
2131 if (i < (ioim->nsges - 1) &&
2132 sge_id < (BFI_SGPG_DATA_SGES - 1))
2133 sgpge->flags = BFI_SGE_DATA;
2134 else if (i < (ioim->nsges - 1))
2135 sgpge->flags = BFI_SGE_DATA_CPL;
2136 else
2137 sgpge->flags = BFI_SGE_DATA_LAST;
2138
2139 bfa_sge_to_le(sgpge);
2140
2141 sgpge++;
2142 if (i == (ioim->nsges - 1)) {
2143 sgpge->flags = BFI_SGE_PGDLEN;
2144 sgpge->sga.a32.addr_lo = 0;
2145 sgpge->sga.a32.addr_hi = 0;
2146 sgpge->sg_len = pgcumsz;
2147 bfa_sge_to_le(sgpge);
2148 } else if (++sge_id == BFI_SGPG_DATA_SGES) {
2149 sgpg = (struct bfa_sgpg_s *) bfa_q_next(sgpg);
2150 sgpge->flags = BFI_SGE_LINK;
2151 sgpge->sga = sgpg->sgpg_pa;
2152 sgpge->sg_len = pgcumsz;
2153 bfa_sge_to_le(sgpge);
2154 sge_id = 0;
2155 pgcumsz = 0;
2156 }
2157 }
2158 }
2159
2160 if (ioim->nsges > BFI_SGE_INLINE) {
2161 sge->sga = ioim->sgpg->sgpg_pa;
2162 } else {
2163 sge->sga.a32.addr_lo = 0;
2164 sge->sga.a32.addr_hi = 0;
2165 }
2166 sge->sg_len = pgdlen;
2167 sge->flags = BFI_SGE_PGDLEN;
2168 bfa_sge_to_be(sge);
2169
2170 /*
2171 * set up I/O command parameters
2172 */
2173 m->cmnd = cmnd_z0;
2174 int_to_scsilun(cmnd->device->lun, &m->cmnd.lun);
2175 dmadir = cmnd->sc_data_direction;
2176 if (dmadir == DMA_TO_DEVICE)
2177 m->cmnd.iodir = FCP_IODIR_WRITE;
2178 else if (dmadir == DMA_FROM_DEVICE)
2179 m->cmnd.iodir = FCP_IODIR_READ;
2180 else
2181 m->cmnd.iodir = FCP_IODIR_NONE;
2182
2183 m->cmnd.cdb = *(struct scsi_cdb_s *) cmnd->cmnd;
2184 fcp_dl = scsi_bufflen(cmnd);
2185 m->cmnd.fcp_dl = cpu_to_be32(fcp_dl);
2186
2187 /*
2188 * set up I/O message header
2189 */
2190 switch (m->cmnd.iodir) {
2191 case FCP_IODIR_READ:
2192 bfi_h2i_set(m->mh, BFI_MC_IOIM_READ, 0, bfa_lpuid(ioim->bfa));
2193 bfa_stats(itnim, input_reqs);
2194 ioim->itnim->stats.rd_throughput += fcp_dl;
2195 break;
2196 case FCP_IODIR_WRITE:
2197 bfi_h2i_set(m->mh, BFI_MC_IOIM_WRITE, 0, bfa_lpuid(ioim->bfa));
2198 bfa_stats(itnim, output_reqs);
2199 ioim->itnim->stats.wr_throughput += fcp_dl;
2200 break;
2201 case FCP_IODIR_RW:
2202 bfa_stats(itnim, input_reqs);
2203 bfa_stats(itnim, output_reqs);
2204 default:
2205 bfi_h2i_set(m->mh, BFI_MC_IOIM_IO, 0, bfa_lpuid(ioim->bfa));
2206 }
2207 if (itnim->seq_rec ||
2208 (scsi_bufflen(cmnd) & (sizeof(u32) - 1)))
2209 bfi_h2i_set(m->mh, BFI_MC_IOIM_IO, 0, bfa_lpuid(ioim->bfa));
2210
2211 /*
2212 * queue I/O message to firmware
2213 */
2214 bfa_reqq_produce(ioim->bfa, ioim->reqq);
2215 return BFA_TRUE;
2216}
2217
2218/*
2219 * Setup any additional SG pages needed.Inline SG element is setup
2220 * at queuing time.
2221 */
2222static bfa_boolean_t
2223bfa_ioim_sgpg_alloc(struct bfa_ioim_s *ioim)
2224{
2225 u16 nsgpgs;
2226
2227 WARN_ON(ioim->nsges <= BFI_SGE_INLINE);
2228
2229 /*
2230 * allocate SG pages needed
2231 */
2232 nsgpgs = BFA_SGPG_NPAGE(ioim->nsges);
2233 if (!nsgpgs)
2234 return BFA_TRUE;
2235
2236 if (bfa_sgpg_malloc(ioim->bfa, &ioim->sgpg_q, nsgpgs)
2237 != BFA_STATUS_OK) {
2238 bfa_sgpg_wait(ioim->bfa, &ioim->iosp->sgpg_wqe, nsgpgs);
2239 return BFA_FALSE;
2240 }
2241
2242 ioim->nsgpgs = nsgpgs;
2243 ioim->sgpg = bfa_q_first(&ioim->sgpg_q);
2244
2245 return BFA_TRUE;
2246}
2247
2248/*
2249 * Send I/O abort request to firmware.
2250 */
2251static bfa_boolean_t
2252bfa_ioim_send_abort(struct bfa_ioim_s *ioim)
2253{
2254 struct bfi_ioim_abort_req_s *m;
2255 enum bfi_ioim_h2i msgop;
2256
2257 /*
2258 * check for room in queue to send request now
2259 */
2260 m = bfa_reqq_next(ioim->bfa, ioim->reqq);
2261 if (!m)
2262 return BFA_FALSE;
2263
2264 /*
2265 * build i/o request message next
2266 */
2267 if (ioim->iosp->abort_explicit)
2268 msgop = BFI_IOIM_H2I_IOABORT_REQ;
2269 else
2270 msgop = BFI_IOIM_H2I_IOCLEANUP_REQ;
2271
2272 bfi_h2i_set(m->mh, BFI_MC_IOIM, msgop, bfa_lpuid(ioim->bfa));
2273 m->io_tag = cpu_to_be16(ioim->iotag);
2274 m->abort_tag = ++ioim->abort_tag;
2275
2276 /*
2277 * queue I/O message to firmware
2278 */
2279 bfa_reqq_produce(ioim->bfa, ioim->reqq);
2280 return BFA_TRUE;
2281}
2282
2283/*
2284 * Call to resume any I/O requests waiting for room in request queue.
2285 */
2286static void
2287bfa_ioim_qresume(void *cbarg)
2288{
2289 struct bfa_ioim_s *ioim = cbarg;
2290
2291 bfa_stats(ioim->itnim, qresumes);
2292 bfa_sm_send_event(ioim, BFA_IOIM_SM_QRESUME);
2293}
2294
2295
2296static void
2297bfa_ioim_notify_cleanup(struct bfa_ioim_s *ioim)
2298{
2299 /*
2300 * Move IO from itnim queue to fcpim global queue since itnim will be
2301 * freed.
2302 */
2303 list_del(&ioim->qe);
2304 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
2305
2306 if (!ioim->iosp->tskim) {
2307 if (ioim->fcpim->delay_comp && ioim->itnim->iotov_active) {
2308 bfa_cb_dequeue(&ioim->hcb_qe);
2309 list_del(&ioim->qe);
2310 list_add_tail(&ioim->qe, &ioim->itnim->delay_comp_q);
2311 }
2312 bfa_itnim_iodone(ioim->itnim);
2313 } else
2314 bfa_wc_down(&ioim->iosp->tskim->wc);
2315}
2316
2317static bfa_boolean_t
2318bfa_ioim_is_abortable(struct bfa_ioim_s *ioim)
2319{
2320 if ((bfa_sm_cmp_state(ioim, bfa_ioim_sm_uninit) &&
2321 (!bfa_q_is_on_q(&ioim->itnim->pending_q, ioim))) ||
2322 (bfa_sm_cmp_state(ioim, bfa_ioim_sm_abort)) ||
2323 (bfa_sm_cmp_state(ioim, bfa_ioim_sm_abort_qfull)) ||
2324 (bfa_sm_cmp_state(ioim, bfa_ioim_sm_hcb)) ||
2325 (bfa_sm_cmp_state(ioim, bfa_ioim_sm_hcb_free)) ||
2326 (bfa_sm_cmp_state(ioim, bfa_ioim_sm_resfree)))
2327 return BFA_FALSE;
2328
2329 return BFA_TRUE;
150} 2330}
151 2331
152void 2332void
153bfa_fcpim_qdepth_set(struct bfa_s *bfa, u16 q_depth) 2333bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim, bfa_boolean_t iotov)
2334{
2335 /*
2336 * If path tov timer expired, failback with PATHTOV status - these
2337 * IO requests are not normally retried by IO stack.
2338 *
2339 * Otherwise device cameback online and fail it with normal failed
2340 * status so that IO stack retries these failed IO requests.
2341 */
2342 if (iotov)
2343 ioim->io_cbfn = __bfa_cb_ioim_pathtov;
2344 else {
2345 ioim->io_cbfn = __bfa_cb_ioim_failed;
2346 bfa_stats(ioim->itnim, iocom_nexus_abort);
2347 }
2348 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
2349
2350 /*
2351 * Move IO to fcpim global queue since itnim will be
2352 * freed.
2353 */
2354 list_del(&ioim->qe);
2355 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
2356}
2357
2358
2359/*
2360 * Memory allocation and initialization.
2361 */
2362void
2363bfa_ioim_attach(struct bfa_fcpim_mod_s *fcpim, struct bfa_meminfo_s *minfo)
2364{
2365 struct bfa_ioim_s *ioim;
2366 struct bfa_ioim_sp_s *iosp;
2367 u16 i;
2368 u8 *snsinfo;
2369 u32 snsbufsz;
2370
2371 /*
2372 * claim memory first
2373 */
2374 ioim = (struct bfa_ioim_s *) bfa_meminfo_kva(minfo);
2375 fcpim->ioim_arr = ioim;
2376 bfa_meminfo_kva(minfo) = (u8 *) (ioim + fcpim->num_ioim_reqs);
2377
2378 iosp = (struct bfa_ioim_sp_s *) bfa_meminfo_kva(minfo);
2379 fcpim->ioim_sp_arr = iosp;
2380 bfa_meminfo_kva(minfo) = (u8 *) (iosp + fcpim->num_ioim_reqs);
2381
2382 /*
2383 * Claim DMA memory for per IO sense data.
2384 */
2385 snsbufsz = fcpim->num_ioim_reqs * BFI_IOIM_SNSLEN;
2386 fcpim->snsbase.pa = bfa_meminfo_dma_phys(minfo);
2387 bfa_meminfo_dma_phys(minfo) += snsbufsz;
2388
2389 fcpim->snsbase.kva = bfa_meminfo_dma_virt(minfo);
2390 bfa_meminfo_dma_virt(minfo) += snsbufsz;
2391 snsinfo = fcpim->snsbase.kva;
2392 bfa_iocfc_set_snsbase(fcpim->bfa, fcpim->snsbase.pa);
2393
2394 /*
2395 * Initialize ioim free queues
2396 */
2397 INIT_LIST_HEAD(&fcpim->ioim_free_q);
2398 INIT_LIST_HEAD(&fcpim->ioim_resfree_q);
2399 INIT_LIST_HEAD(&fcpim->ioim_comp_q);
2400
2401 for (i = 0; i < fcpim->num_ioim_reqs;
2402 i++, ioim++, iosp++, snsinfo += BFI_IOIM_SNSLEN) {
2403 /*
2404 * initialize IOIM
2405 */
2406 memset(ioim, 0, sizeof(struct bfa_ioim_s));
2407 ioim->iotag = i;
2408 ioim->bfa = fcpim->bfa;
2409 ioim->fcpim = fcpim;
2410 ioim->iosp = iosp;
2411 iosp->snsinfo = snsinfo;
2412 INIT_LIST_HEAD(&ioim->sgpg_q);
2413 bfa_reqq_winit(&ioim->iosp->reqq_wait,
2414 bfa_ioim_qresume, ioim);
2415 bfa_sgpg_winit(&ioim->iosp->sgpg_wqe,
2416 bfa_ioim_sgpg_alloced, ioim);
2417 bfa_sm_set_state(ioim, bfa_ioim_sm_uninit);
2418
2419 list_add_tail(&ioim->qe, &fcpim->ioim_free_q);
2420 }
2421}
2422
2423void
2424bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
154{ 2425{
155 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 2426 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
2427 struct bfi_ioim_rsp_s *rsp = (struct bfi_ioim_rsp_s *) m;
2428 struct bfa_ioim_s *ioim;
2429 u16 iotag;
2430 enum bfa_ioim_event evt = BFA_IOIM_SM_COMP;
2431
2432 iotag = be16_to_cpu(rsp->io_tag);
2433
2434 ioim = BFA_IOIM_FROM_TAG(fcpim, iotag);
2435 WARN_ON(ioim->iotag != iotag);
2436
2437 bfa_trc(ioim->bfa, ioim->iotag);
2438 bfa_trc(ioim->bfa, rsp->io_status);
2439 bfa_trc(ioim->bfa, rsp->reuse_io_tag);
2440
2441 if (bfa_sm_cmp_state(ioim, bfa_ioim_sm_active))
2442 ioim->iosp->comp_rspmsg = *m;
2443
2444 switch (rsp->io_status) {
2445 case BFI_IOIM_STS_OK:
2446 bfa_stats(ioim->itnim, iocomp_ok);
2447 if (rsp->reuse_io_tag == 0)
2448 evt = BFA_IOIM_SM_DONE;
2449 else
2450 evt = BFA_IOIM_SM_COMP;
2451 break;
2452
2453 case BFI_IOIM_STS_TIMEDOUT:
2454 bfa_stats(ioim->itnim, iocomp_timedout);
2455 case BFI_IOIM_STS_ABORTED:
2456 rsp->io_status = BFI_IOIM_STS_ABORTED;
2457 bfa_stats(ioim->itnim, iocomp_aborted);
2458 if (rsp->reuse_io_tag == 0)
2459 evt = BFA_IOIM_SM_DONE;
2460 else
2461 evt = BFA_IOIM_SM_COMP;
2462 break;
2463
2464 case BFI_IOIM_STS_PROTO_ERR:
2465 bfa_stats(ioim->itnim, iocom_proto_err);
2466 WARN_ON(!rsp->reuse_io_tag);
2467 evt = BFA_IOIM_SM_COMP;
2468 break;
2469
2470 case BFI_IOIM_STS_SQER_NEEDED:
2471 bfa_stats(ioim->itnim, iocom_sqer_needed);
2472 WARN_ON(rsp->reuse_io_tag != 0);
2473 evt = BFA_IOIM_SM_SQRETRY;
2474 break;
156 2475
157 bfa_assert(q_depth <= BFA_IOCFC_QDEPTH_MAX); 2476 case BFI_IOIM_STS_RES_FREE:
2477 bfa_stats(ioim->itnim, iocom_res_free);
2478 evt = BFA_IOIM_SM_FREE;
2479 break;
158 2480
159 fcpim->q_depth = q_depth; 2481 case BFI_IOIM_STS_HOST_ABORTED:
2482 bfa_stats(ioim->itnim, iocom_hostabrts);
2483 if (rsp->abort_tag != ioim->abort_tag) {
2484 bfa_trc(ioim->bfa, rsp->abort_tag);
2485 bfa_trc(ioim->bfa, ioim->abort_tag);
2486 return;
2487 }
2488
2489 if (rsp->reuse_io_tag)
2490 evt = BFA_IOIM_SM_ABORT_COMP;
2491 else
2492 evt = BFA_IOIM_SM_ABORT_DONE;
2493 break;
2494
2495 case BFI_IOIM_STS_UTAG:
2496 bfa_stats(ioim->itnim, iocom_utags);
2497 evt = BFA_IOIM_SM_COMP_UTAG;
2498 break;
2499
2500 default:
2501 WARN_ON(1);
2502 }
2503
2504 bfa_sm_send_event(ioim, evt);
160} 2505}
161 2506
162u16 2507void
163bfa_fcpim_qdepth_get(struct bfa_s *bfa) 2508bfa_ioim_good_comp_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
164{ 2509{
165 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 2510 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
2511 struct bfi_ioim_rsp_s *rsp = (struct bfi_ioim_rsp_s *) m;
2512 struct bfa_ioim_s *ioim;
2513 u16 iotag;
166 2514
167 return fcpim->q_depth; 2515 iotag = be16_to_cpu(rsp->io_tag);
2516
2517 ioim = BFA_IOIM_FROM_TAG(fcpim, iotag);
2518 WARN_ON(BFA_IOIM_TAG_2_ID(ioim->iotag) != iotag);
2519
2520 bfa_ioim_cb_profile_comp(fcpim, ioim);
2521 bfa_sm_send_event(ioim, BFA_IOIM_SM_COMP_GOOD);
168} 2522}
169 2523
2524/*
2525 * Called by itnim to clean up IO while going offline.
2526 */
170void 2527void
171bfa_fcpim_update_ioredirect(struct bfa_s *bfa) 2528bfa_ioim_cleanup(struct bfa_ioim_s *ioim)
172{ 2529{
173 bfa_boolean_t ioredirect; 2530 bfa_trc(ioim->bfa, ioim->iotag);
2531 bfa_stats(ioim->itnim, io_cleanups);
2532
2533 ioim->iosp->tskim = NULL;
2534 bfa_sm_send_event(ioim, BFA_IOIM_SM_CLEANUP);
2535}
2536
2537void
2538bfa_ioim_cleanup_tm(struct bfa_ioim_s *ioim, struct bfa_tskim_s *tskim)
2539{
2540 bfa_trc(ioim->bfa, ioim->iotag);
2541 bfa_stats(ioim->itnim, io_tmaborts);
2542
2543 ioim->iosp->tskim = tskim;
2544 bfa_sm_send_event(ioim, BFA_IOIM_SM_CLEANUP);
2545}
2546
2547/*
2548 * IOC failure handling.
2549 */
2550void
2551bfa_ioim_iocdisable(struct bfa_ioim_s *ioim)
2552{
2553 bfa_trc(ioim->bfa, ioim->iotag);
2554 bfa_stats(ioim->itnim, io_iocdowns);
2555 bfa_sm_send_event(ioim, BFA_IOIM_SM_HWFAIL);
2556}
2557
2558/*
2559 * IO offline TOV popped. Fail the pending IO.
2560 */
2561void
2562bfa_ioim_tov(struct bfa_ioim_s *ioim)
2563{
2564 bfa_trc(ioim->bfa, ioim->iotag);
2565 bfa_sm_send_event(ioim, BFA_IOIM_SM_IOTOV);
2566}
2567
2568
2569/*
2570 * Allocate IOIM resource for initiator mode I/O request.
2571 */
2572struct bfa_ioim_s *
2573bfa_ioim_alloc(struct bfa_s *bfa, struct bfad_ioim_s *dio,
2574 struct bfa_itnim_s *itnim, u16 nsges)
2575{
2576 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
2577 struct bfa_ioim_s *ioim;
174 2578
175 /* 2579 /*
176 * IO redirection is turned off when QoS is enabled and vice versa 2580 * alocate IOIM resource
177 */ 2581 */
178 ioredirect = bfa_fcport_is_qos_enabled(bfa) ? BFA_FALSE : BFA_TRUE; 2582 bfa_q_deq(&fcpim->ioim_free_q, &ioim);
2583 if (!ioim) {
2584 bfa_stats(itnim, no_iotags);
2585 return NULL;
2586 }
2587
2588 ioim->dio = dio;
2589 ioim->itnim = itnim;
2590 ioim->nsges = nsges;
2591 ioim->nsgpgs = 0;
2592
2593 bfa_stats(itnim, total_ios);
2594 fcpim->ios_active++;
2595
2596 list_add_tail(&ioim->qe, &itnim->io_q);
2597
2598 return ioim;
2599}
2600
2601void
2602bfa_ioim_free(struct bfa_ioim_s *ioim)
2603{
2604 struct bfa_fcpim_mod_s *fcpim = ioim->fcpim;
2605
2606 if (ioim->nsgpgs > 0)
2607 bfa_sgpg_mfree(ioim->bfa, &ioim->sgpg_q, ioim->nsgpgs);
2608
2609 bfa_stats(ioim->itnim, io_comps);
2610 fcpim->ios_active--;
2611
2612 ioim->iotag &= BFA_IOIM_IOTAG_MASK;
2613 list_del(&ioim->qe);
2614 list_add_tail(&ioim->qe, &fcpim->ioim_free_q);
2615}
2616
2617void
2618bfa_ioim_start(struct bfa_ioim_s *ioim)
2619{
2620 bfa_ioim_cb_profile_start(ioim->fcpim, ioim);
179 2621
180 /* 2622 /*
181 * Notify the bfad module of a possible state change in 2623 * Obtain the queue over which this request has to be issued
182 * IO redirection capability, due to a QoS state change. bfad will
183 * check on the support for io redirection and update the
184 * fcpim's ioredirect state accordingly.
185 */ 2624 */
186 bfa_cb_ioredirect_state_change((void *)(bfa->bfad), ioredirect); 2625 ioim->reqq = bfa_fcpim_ioredirect_enabled(ioim->bfa) ?
2626 BFA_FALSE : bfa_itnim_get_reqq(ioim);
2627
2628 bfa_sm_send_event(ioim, BFA_IOIM_SM_START);
2629}
2630
2631/*
2632 * Driver I/O abort request.
2633 */
2634bfa_status_t
2635bfa_ioim_abort(struct bfa_ioim_s *ioim)
2636{
2637
2638 bfa_trc(ioim->bfa, ioim->iotag);
2639
2640 if (!bfa_ioim_is_abortable(ioim))
2641 return BFA_STATUS_FAILED;
2642
2643 bfa_stats(ioim->itnim, io_aborts);
2644 bfa_sm_send_event(ioim, BFA_IOIM_SM_ABORT);
2645
2646 return BFA_STATUS_OK;
2647}
2648
2649/*
2650 * BFA TSKIM state machine functions
2651 */
2652
2653/*
2654 * Task management command beginning state.
2655 */
2656static void
2657bfa_tskim_sm_uninit(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
2658{
2659 bfa_trc(tskim->bfa, event);
2660
2661 switch (event) {
2662 case BFA_TSKIM_SM_START:
2663 bfa_sm_set_state(tskim, bfa_tskim_sm_active);
2664 bfa_tskim_gather_ios(tskim);
2665
2666 /*
2667 * If device is offline, do not send TM on wire. Just cleanup
2668 * any pending IO requests and complete TM request.
2669 */
2670 if (!bfa_itnim_is_online(tskim->itnim)) {
2671 bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
2672 tskim->tsk_status = BFI_TSKIM_STS_OK;
2673 bfa_tskim_cleanup_ios(tskim);
2674 return;
2675 }
2676
2677 if (!bfa_tskim_send(tskim)) {
2678 bfa_sm_set_state(tskim, bfa_tskim_sm_qfull);
2679 bfa_stats(tskim->itnim, tm_qwait);
2680 bfa_reqq_wait(tskim->bfa, tskim->itnim->reqq,
2681 &tskim->reqq_wait);
2682 }
2683 break;
2684
2685 default:
2686 bfa_sm_fault(tskim->bfa, event);
2687 }
2688}
2689
2690/*
2691 * TM command is active, awaiting completion from firmware to
2692 * cleanup IO requests in TM scope.
2693 */
2694static void
2695bfa_tskim_sm_active(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
2696{
2697 bfa_trc(tskim->bfa, event);
2698
2699 switch (event) {
2700 case BFA_TSKIM_SM_DONE:
2701 bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
2702 bfa_tskim_cleanup_ios(tskim);
2703 break;
2704
2705 case BFA_TSKIM_SM_CLEANUP:
2706 bfa_sm_set_state(tskim, bfa_tskim_sm_cleanup);
2707 if (!bfa_tskim_send_abort(tskim)) {
2708 bfa_sm_set_state(tskim, bfa_tskim_sm_cleanup_qfull);
2709 bfa_stats(tskim->itnim, tm_qwait);
2710 bfa_reqq_wait(tskim->bfa, tskim->itnim->reqq,
2711 &tskim->reqq_wait);
2712 }
2713 break;
2714
2715 case BFA_TSKIM_SM_HWFAIL:
2716 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
2717 bfa_tskim_iocdisable_ios(tskim);
2718 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
2719 break;
2720
2721 default:
2722 bfa_sm_fault(tskim->bfa, event);
2723 }
2724}
2725
2726/*
2727 * An active TM is being cleaned up since ITN is offline. Awaiting cleanup
2728 * completion event from firmware.
2729 */
2730static void
2731bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
2732{
2733 bfa_trc(tskim->bfa, event);
2734
2735 switch (event) {
2736 case BFA_TSKIM_SM_DONE:
2737 /*
2738 * Ignore and wait for ABORT completion from firmware.
2739 */
2740 break;
2741
2742 case BFA_TSKIM_SM_CLEANUP_DONE:
2743 bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
2744 bfa_tskim_cleanup_ios(tskim);
2745 break;
2746
2747 case BFA_TSKIM_SM_HWFAIL:
2748 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
2749 bfa_tskim_iocdisable_ios(tskim);
2750 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
2751 break;
2752
2753 default:
2754 bfa_sm_fault(tskim->bfa, event);
2755 }
2756}
2757
2758static void
2759bfa_tskim_sm_iocleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
2760{
2761 bfa_trc(tskim->bfa, event);
2762
2763 switch (event) {
2764 case BFA_TSKIM_SM_IOS_DONE:
2765 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
2766 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_done);
2767 break;
2768
2769 case BFA_TSKIM_SM_CLEANUP:
2770 /*
2771 * Ignore, TM command completed on wire.
2772 * Notify TM conmpletion on IO cleanup completion.
2773 */
2774 break;
2775
2776 case BFA_TSKIM_SM_HWFAIL:
2777 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
2778 bfa_tskim_iocdisable_ios(tskim);
2779 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
2780 break;
2781
2782 default:
2783 bfa_sm_fault(tskim->bfa, event);
2784 }
2785}
2786
2787/*
2788 * Task management command is waiting for room in request CQ
2789 */
2790static void
2791bfa_tskim_sm_qfull(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
2792{
2793 bfa_trc(tskim->bfa, event);
2794
2795 switch (event) {
2796 case BFA_TSKIM_SM_QRESUME:
2797 bfa_sm_set_state(tskim, bfa_tskim_sm_active);
2798 bfa_tskim_send(tskim);
2799 break;
2800
2801 case BFA_TSKIM_SM_CLEANUP:
2802 /*
2803 * No need to send TM on wire since ITN is offline.
2804 */
2805 bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
2806 bfa_reqq_wcancel(&tskim->reqq_wait);
2807 bfa_tskim_cleanup_ios(tskim);
2808 break;
2809
2810 case BFA_TSKIM_SM_HWFAIL:
2811 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
2812 bfa_reqq_wcancel(&tskim->reqq_wait);
2813 bfa_tskim_iocdisable_ios(tskim);
2814 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
2815 break;
2816
2817 default:
2818 bfa_sm_fault(tskim->bfa, event);
2819 }
2820}
2821
2822/*
2823 * Task management command is active, awaiting for room in request CQ
2824 * to send clean up request.
2825 */
2826static void
2827bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s *tskim,
2828 enum bfa_tskim_event event)
2829{
2830 bfa_trc(tskim->bfa, event);
2831
2832 switch (event) {
2833 case BFA_TSKIM_SM_DONE:
2834 bfa_reqq_wcancel(&tskim->reqq_wait);
2835 /*
2836 * Fall through !!!
2837 */
2838 case BFA_TSKIM_SM_QRESUME:
2839 bfa_sm_set_state(tskim, bfa_tskim_sm_cleanup);
2840 bfa_tskim_send_abort(tskim);
2841 break;
2842
2843 case BFA_TSKIM_SM_HWFAIL:
2844 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
2845 bfa_reqq_wcancel(&tskim->reqq_wait);
2846 bfa_tskim_iocdisable_ios(tskim);
2847 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
2848 break;
2849
2850 default:
2851 bfa_sm_fault(tskim->bfa, event);
2852 }
2853}
2854
2855/*
2856 * BFA callback is pending
2857 */
2858static void
2859bfa_tskim_sm_hcb(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
2860{
2861 bfa_trc(tskim->bfa, event);
2862
2863 switch (event) {
2864 case BFA_TSKIM_SM_HCB:
2865 bfa_sm_set_state(tskim, bfa_tskim_sm_uninit);
2866 bfa_tskim_free(tskim);
2867 break;
2868
2869 case BFA_TSKIM_SM_CLEANUP:
2870 bfa_tskim_notify_comp(tskim);
2871 break;
2872
2873 case BFA_TSKIM_SM_HWFAIL:
2874 break;
2875
2876 default:
2877 bfa_sm_fault(tskim->bfa, event);
2878 }
2879}
2880
2881static void
2882__bfa_cb_tskim_done(void *cbarg, bfa_boolean_t complete)
2883{
2884 struct bfa_tskim_s *tskim = cbarg;
2885
2886 if (!complete) {
2887 bfa_sm_send_event(tskim, BFA_TSKIM_SM_HCB);
2888 return;
2889 }
2890
2891 bfa_stats(tskim->itnim, tm_success);
2892 bfa_cb_tskim_done(tskim->bfa->bfad, tskim->dtsk, tskim->tsk_status);
2893}
2894
2895static void
2896__bfa_cb_tskim_failed(void *cbarg, bfa_boolean_t complete)
2897{
2898 struct bfa_tskim_s *tskim = cbarg;
2899
2900 if (!complete) {
2901 bfa_sm_send_event(tskim, BFA_TSKIM_SM_HCB);
2902 return;
2903 }
2904
2905 bfa_stats(tskim->itnim, tm_failures);
2906 bfa_cb_tskim_done(tskim->bfa->bfad, tskim->dtsk,
2907 BFI_TSKIM_STS_FAILED);
2908}
2909
2910static bfa_boolean_t
2911bfa_tskim_match_scope(struct bfa_tskim_s *tskim, struct scsi_lun lun)
2912{
2913 switch (tskim->tm_cmnd) {
2914 case FCP_TM_TARGET_RESET:
2915 return BFA_TRUE;
2916
2917 case FCP_TM_ABORT_TASK_SET:
2918 case FCP_TM_CLEAR_TASK_SET:
2919 case FCP_TM_LUN_RESET:
2920 case FCP_TM_CLEAR_ACA:
2921 return !memcmp(&tskim->lun, &lun, sizeof(lun));
2922
2923 default:
2924 WARN_ON(1);
2925 }
2926
2927 return BFA_FALSE;
2928}
2929
2930/*
2931 * Gather affected IO requests and task management commands.
2932 */
2933static void
2934bfa_tskim_gather_ios(struct bfa_tskim_s *tskim)
2935{
2936 struct bfa_itnim_s *itnim = tskim->itnim;
2937 struct bfa_ioim_s *ioim;
2938 struct list_head *qe, *qen;
2939 struct scsi_cmnd *cmnd;
2940 struct scsi_lun scsilun;
2941
2942 INIT_LIST_HEAD(&tskim->io_q);
2943
2944 /*
2945 * Gather any active IO requests first.
2946 */
2947 list_for_each_safe(qe, qen, &itnim->io_q) {
2948 ioim = (struct bfa_ioim_s *) qe;
2949 cmnd = (struct scsi_cmnd *) ioim->dio;
2950 int_to_scsilun(cmnd->device->lun, &scsilun);
2951 if (bfa_tskim_match_scope(tskim, scsilun)) {
2952 list_del(&ioim->qe);
2953 list_add_tail(&ioim->qe, &tskim->io_q);
2954 }
2955 }
2956
2957 /*
2958 * Failback any pending IO requests immediately.
2959 */
2960 list_for_each_safe(qe, qen, &itnim->pending_q) {
2961 ioim = (struct bfa_ioim_s *) qe;
2962 cmnd = (struct scsi_cmnd *) ioim->dio;
2963 int_to_scsilun(cmnd->device->lun, &scsilun);
2964 if (bfa_tskim_match_scope(tskim, scsilun)) {
2965 list_del(&ioim->qe);
2966 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
2967 bfa_ioim_tov(ioim);
2968 }
2969 }
2970}
2971
2972/*
2973 * IO cleanup completion
2974 */
2975static void
2976bfa_tskim_cleanp_comp(void *tskim_cbarg)
2977{
2978 struct bfa_tskim_s *tskim = tskim_cbarg;
2979
2980 bfa_stats(tskim->itnim, tm_io_comps);
2981 bfa_sm_send_event(tskim, BFA_TSKIM_SM_IOS_DONE);
2982}
2983
2984/*
2985 * Gather affected IO requests and task management commands.
2986 */
2987static void
2988bfa_tskim_cleanup_ios(struct bfa_tskim_s *tskim)
2989{
2990 struct bfa_ioim_s *ioim;
2991 struct list_head *qe, *qen;
2992
2993 bfa_wc_init(&tskim->wc, bfa_tskim_cleanp_comp, tskim);
2994
2995 list_for_each_safe(qe, qen, &tskim->io_q) {
2996 ioim = (struct bfa_ioim_s *) qe;
2997 bfa_wc_up(&tskim->wc);
2998 bfa_ioim_cleanup_tm(ioim, tskim);
2999 }
3000
3001 bfa_wc_wait(&tskim->wc);
3002}
3003
3004/*
3005 * Send task management request to firmware.
3006 */
3007static bfa_boolean_t
3008bfa_tskim_send(struct bfa_tskim_s *tskim)
3009{
3010 struct bfa_itnim_s *itnim = tskim->itnim;
3011 struct bfi_tskim_req_s *m;
3012
3013 /*
3014 * check for room in queue to send request now
3015 */
3016 m = bfa_reqq_next(tskim->bfa, itnim->reqq);
3017 if (!m)
3018 return BFA_FALSE;
3019
3020 /*
3021 * build i/o request message next
3022 */
3023 bfi_h2i_set(m->mh, BFI_MC_TSKIM, BFI_TSKIM_H2I_TM_REQ,
3024 bfa_lpuid(tskim->bfa));
3025
3026 m->tsk_tag = cpu_to_be16(tskim->tsk_tag);
3027 m->itn_fhdl = tskim->itnim->rport->fw_handle;
3028 m->t_secs = tskim->tsecs;
3029 m->lun = tskim->lun;
3030 m->tm_flags = tskim->tm_cmnd;
3031
3032 /*
3033 * queue I/O message to firmware
3034 */
3035 bfa_reqq_produce(tskim->bfa, itnim->reqq);
3036 return BFA_TRUE;
3037}
3038
3039/*
3040 * Send abort request to cleanup an active TM to firmware.
3041 */
3042static bfa_boolean_t
3043bfa_tskim_send_abort(struct bfa_tskim_s *tskim)
3044{
3045 struct bfa_itnim_s *itnim = tskim->itnim;
3046 struct bfi_tskim_abortreq_s *m;
3047
3048 /*
3049 * check for room in queue to send request now
3050 */
3051 m = bfa_reqq_next(tskim->bfa, itnim->reqq);
3052 if (!m)
3053 return BFA_FALSE;
3054
3055 /*
3056 * build i/o request message next
3057 */
3058 bfi_h2i_set(m->mh, BFI_MC_TSKIM, BFI_TSKIM_H2I_ABORT_REQ,
3059 bfa_lpuid(tskim->bfa));
3060
3061 m->tsk_tag = cpu_to_be16(tskim->tsk_tag);
3062
3063 /*
3064 * queue I/O message to firmware
3065 */
3066 bfa_reqq_produce(tskim->bfa, itnim->reqq);
3067 return BFA_TRUE;
3068}
3069
3070/*
3071 * Call to resume task management cmnd waiting for room in request queue.
3072 */
3073static void
3074bfa_tskim_qresume(void *cbarg)
3075{
3076 struct bfa_tskim_s *tskim = cbarg;
3077
3078 bfa_stats(tskim->itnim, tm_qresumes);
3079 bfa_sm_send_event(tskim, BFA_TSKIM_SM_QRESUME);
3080}
3081
3082/*
3083 * Cleanup IOs associated with a task mangement command on IOC failures.
3084 */
3085static void
3086bfa_tskim_iocdisable_ios(struct bfa_tskim_s *tskim)
3087{
3088 struct bfa_ioim_s *ioim;
3089 struct list_head *qe, *qen;
3090
3091 list_for_each_safe(qe, qen, &tskim->io_q) {
3092 ioim = (struct bfa_ioim_s *) qe;
3093 bfa_ioim_iocdisable(ioim);
3094 }
3095}
3096
3097/*
3098 * Notification on completions from related ioim.
3099 */
3100void
3101bfa_tskim_iodone(struct bfa_tskim_s *tskim)
3102{
3103 bfa_wc_down(&tskim->wc);
3104}
3105
3106/*
3107 * Handle IOC h/w failure notification from itnim.
3108 */
3109void
3110bfa_tskim_iocdisable(struct bfa_tskim_s *tskim)
3111{
3112 tskim->notify = BFA_FALSE;
3113 bfa_stats(tskim->itnim, tm_iocdowns);
3114 bfa_sm_send_event(tskim, BFA_TSKIM_SM_HWFAIL);
3115}
3116
3117/*
3118 * Cleanup TM command and associated IOs as part of ITNIM offline.
3119 */
3120void
3121bfa_tskim_cleanup(struct bfa_tskim_s *tskim)
3122{
3123 tskim->notify = BFA_TRUE;
3124 bfa_stats(tskim->itnim, tm_cleanups);
3125 bfa_sm_send_event(tskim, BFA_TSKIM_SM_CLEANUP);
3126}
3127
3128/*
3129 * Memory allocation and initialization.
3130 */
3131void
3132bfa_tskim_attach(struct bfa_fcpim_mod_s *fcpim, struct bfa_meminfo_s *minfo)
3133{
3134 struct bfa_tskim_s *tskim;
3135 u16 i;
3136
3137 INIT_LIST_HEAD(&fcpim->tskim_free_q);
3138
3139 tskim = (struct bfa_tskim_s *) bfa_meminfo_kva(minfo);
3140 fcpim->tskim_arr = tskim;
3141
3142 for (i = 0; i < fcpim->num_tskim_reqs; i++, tskim++) {
3143 /*
3144 * initialize TSKIM
3145 */
3146 memset(tskim, 0, sizeof(struct bfa_tskim_s));
3147 tskim->tsk_tag = i;
3148 tskim->bfa = fcpim->bfa;
3149 tskim->fcpim = fcpim;
3150 tskim->notify = BFA_FALSE;
3151 bfa_reqq_winit(&tskim->reqq_wait, bfa_tskim_qresume,
3152 tskim);
3153 bfa_sm_set_state(tskim, bfa_tskim_sm_uninit);
3154
3155 list_add_tail(&tskim->qe, &fcpim->tskim_free_q);
3156 }
3157
3158 bfa_meminfo_kva(minfo) = (u8 *) tskim;
187} 3159}
188 3160
189void 3161void
190bfa_fcpim_set_ioredirect(struct bfa_s *bfa, bfa_boolean_t state) 3162bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
3163{
3164 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
3165 struct bfi_tskim_rsp_s *rsp = (struct bfi_tskim_rsp_s *) m;
3166 struct bfa_tskim_s *tskim;
3167 u16 tsk_tag = be16_to_cpu(rsp->tsk_tag);
3168
3169 tskim = BFA_TSKIM_FROM_TAG(fcpim, tsk_tag);
3170 WARN_ON(tskim->tsk_tag != tsk_tag);
3171
3172 tskim->tsk_status = rsp->tsk_status;
3173
3174 /*
3175 * Firmware sends BFI_TSKIM_STS_ABORTED status for abort
3176 * requests. All other statuses are for normal completions.
3177 */
3178 if (rsp->tsk_status == BFI_TSKIM_STS_ABORTED) {
3179 bfa_stats(tskim->itnim, tm_cleanup_comps);
3180 bfa_sm_send_event(tskim, BFA_TSKIM_SM_CLEANUP_DONE);
3181 } else {
3182 bfa_stats(tskim->itnim, tm_fw_rsps);
3183 bfa_sm_send_event(tskim, BFA_TSKIM_SM_DONE);
3184 }
3185}
3186
3187
3188struct bfa_tskim_s *
3189bfa_tskim_alloc(struct bfa_s *bfa, struct bfad_tskim_s *dtsk)
191{ 3190{
192 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa); 3191 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
193 fcpim->ioredirect = state; 3192 struct bfa_tskim_s *tskim;
3193
3194 bfa_q_deq(&fcpim->tskim_free_q, &tskim);
3195
3196 if (tskim)
3197 tskim->dtsk = dtsk;
3198
3199 return tskim;
3200}
3201
3202void
3203bfa_tskim_free(struct bfa_tskim_s *tskim)
3204{
3205 WARN_ON(!bfa_q_is_on_q_func(&tskim->itnim->tsk_q, &tskim->qe));
3206 list_del(&tskim->qe);
3207 list_add_tail(&tskim->qe, &tskim->fcpim->tskim_free_q);
3208}
3209
3210/*
3211 * Start a task management command.
3212 *
3213 * @param[in] tskim BFA task management command instance
3214 * @param[in] itnim i-t nexus for the task management command
3215 * @param[in] lun lun, if applicable
3216 * @param[in] tm_cmnd Task management command code.
3217 * @param[in] t_secs Timeout in seconds
3218 *
3219 * @return None.
3220 */
3221void
3222bfa_tskim_start(struct bfa_tskim_s *tskim, struct bfa_itnim_s *itnim,
3223 struct scsi_lun lun,
3224 enum fcp_tm_cmnd tm_cmnd, u8 tsecs)
3225{
3226 tskim->itnim = itnim;
3227 tskim->lun = lun;
3228 tskim->tm_cmnd = tm_cmnd;
3229 tskim->tsecs = tsecs;
3230 tskim->notify = BFA_FALSE;
3231 bfa_stats(itnim, tm_cmnds);
3232
3233 list_add_tail(&tskim->qe, &itnim->tsk_q);
3234 bfa_sm_send_event(tskim, BFA_TSKIM_SM_START);
194} 3235}
diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
new file mode 100644
index 000000000000..1e38dade8423
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_fcpim.h
@@ -0,0 +1,355 @@
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_FCPIM_H__
19#define __BFA_FCPIM_H__
20
21#include "bfa.h"
22#include "bfa_svc.h"
23#include "bfi_ms.h"
24#include "bfa_defs_svc.h"
25#include "bfa_cs.h"
26
27
28#define BFA_ITNIM_MIN 32
29#define BFA_ITNIM_MAX 1024
30
31#define BFA_IOIM_MIN 8
32#define BFA_IOIM_MAX 2000
33
34#define BFA_TSKIM_MIN 4
35#define BFA_TSKIM_MAX 512
36#define BFA_FCPIM_PATHTOV_DEF (30 * 1000) /* in millisecs */
37#define BFA_FCPIM_PATHTOV_MAX (90 * 1000) /* in millisecs */
38
39
40#define bfa_itnim_ioprofile_update(__itnim, __index) \
41 (__itnim->ioprofile.iocomps[__index]++)
42
43#define BFA_IOIM_RETRY_TAG_OFFSET 11
44#define BFA_IOIM_IOTAG_MASK 0x07ff /* 2K IOs */
45#define BFA_IOIM_RETRY_MAX 7
46
47/* Buckets are are 512 bytes to 2MB */
48static inline u32
49bfa_ioim_get_index(u32 n) {
50 int pos = 0;
51 if (n >= (1UL)<<22)
52 return BFA_IOBUCKET_MAX - 1;
53 n >>= 8;
54 if (n >= (1UL)<<16)
55 n >>= 16; pos += 16;
56 if (n >= 1 << 8)
57 n >>= 8; pos += 8;
58 if (n >= 1 << 4)
59 n >>= 4; pos += 4;
60 if (n >= 1 << 2)
61 n >>= 2; pos += 2;
62 if (n >= 1 << 1)
63 pos += 1;
64
65 return (n == 0) ? (0) : pos;
66}
67
68/*
69 * forward declarations
70 */
71struct bfa_ioim_s;
72struct bfa_tskim_s;
73struct bfad_ioim_s;
74struct bfad_tskim_s;
75
76typedef void (*bfa_fcpim_profile_t) (struct bfa_ioim_s *ioim);
77
78struct bfa_fcpim_mod_s {
79 struct bfa_s *bfa;
80 struct bfa_itnim_s *itnim_arr;
81 struct bfa_ioim_s *ioim_arr;
82 struct bfa_ioim_sp_s *ioim_sp_arr;
83 struct bfa_tskim_s *tskim_arr;
84 struct bfa_dma_s snsbase;
85 int num_itnims;
86 int num_ioim_reqs;
87 int num_tskim_reqs;
88 u32 path_tov;
89 u16 q_depth;
90 u8 reqq; /* Request queue to be used */
91 u8 rsvd;
92 struct list_head itnim_q; /* queue of active itnim */
93 struct list_head ioim_free_q; /* free IO resources */
94 struct list_head ioim_resfree_q; /* IOs waiting for f/w */
95 struct list_head ioim_comp_q; /* IO global comp Q */
96 struct list_head tskim_free_q;
97 u32 ios_active; /* current active IOs */
98 u32 delay_comp;
99 struct bfa_fcpim_del_itn_stats_s del_itn_stats;
100 bfa_boolean_t ioredirect;
101 bfa_boolean_t io_profile;
102 u32 io_profile_start_time;
103 bfa_fcpim_profile_t profile_comp;
104 bfa_fcpim_profile_t profile_start;
105};
106
107/*
108 * BFA IO (initiator mode)
109 */
110struct bfa_ioim_s {
111 struct list_head qe; /* queue elememt */
112 bfa_sm_t sm; /* BFA ioim state machine */
113 struct bfa_s *bfa; /* BFA module */
114 struct bfa_fcpim_mod_s *fcpim; /* parent fcpim module */
115 struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */
116 struct bfad_ioim_s *dio; /* driver IO handle */
117 u16 iotag; /* FWI IO tag */
118 u16 abort_tag; /* unqiue abort request tag */
119 u16 nsges; /* number of SG elements */
120 u16 nsgpgs; /* number of SG pages */
121 struct bfa_sgpg_s *sgpg; /* first SG page */
122 struct list_head sgpg_q; /* allocated SG pages */
123 struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
124 bfa_cb_cbfn_t io_cbfn; /* IO completion handler */
125 struct bfa_ioim_sp_s *iosp; /* slow-path IO handling */
126 u8 reqq; /* Request queue for I/O */
127 u64 start_time; /* IO's Profile start val */
128};
129
130struct bfa_ioim_sp_s {
131 struct bfi_msg_s comp_rspmsg; /* IO comp f/w response */
132 u8 *snsinfo; /* sense info for this IO */
133 struct bfa_sgpg_wqe_s sgpg_wqe; /* waitq elem for sgpg */
134 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
135 bfa_boolean_t abort_explicit; /* aborted by OS */
136 struct bfa_tskim_s *tskim; /* Relevant TM cmd */
137};
138
139/*
140 * BFA Task management command (initiator mode)
141 */
142struct bfa_tskim_s {
143 struct list_head qe;
144 bfa_sm_t sm;
145 struct bfa_s *bfa; /* BFA module */
146 struct bfa_fcpim_mod_s *fcpim; /* parent fcpim module */
147 struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */
148 struct bfad_tskim_s *dtsk; /* driver task mgmt cmnd */
149 bfa_boolean_t notify; /* notify itnim on TM comp */
150 struct scsi_lun lun; /* lun if applicable */
151 enum fcp_tm_cmnd tm_cmnd; /* task management command */
152 u16 tsk_tag; /* FWI IO tag */
153 u8 tsecs; /* timeout in seconds */
154 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
155 struct list_head io_q; /* queue of affected IOs */
156 struct bfa_wc_s wc; /* waiting counter */
157 struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
158 enum bfi_tskim_status tsk_status; /* TM status */
159};
160
161/*
162 * BFA i-t-n (initiator mode)
163 */
164struct bfa_itnim_s {
165 struct list_head qe; /* queue element */
166 bfa_sm_t sm; /* i-t-n im BFA state machine */
167 struct bfa_s *bfa; /* bfa instance */
168 struct bfa_rport_s *rport; /* bfa rport */
169 void *ditn; /* driver i-t-n structure */
170 struct bfi_mhdr_s mhdr; /* pre-built mhdr */
171 u8 msg_no; /* itnim/rport firmware handle */
172 u8 reqq; /* CQ for requests */
173 struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
174 struct list_head pending_q; /* queue of pending IO requests */
175 struct list_head io_q; /* queue of active IO requests */
176 struct list_head io_cleanup_q; /* IO being cleaned up */
177 struct list_head tsk_q; /* queue of active TM commands */
178 struct list_head delay_comp_q; /* queue of failed inflight cmds */
179 bfa_boolean_t seq_rec; /* SQER supported */
180 bfa_boolean_t is_online; /* itnim is ONLINE for IO */
181 bfa_boolean_t iotov_active; /* IO TOV timer is active */
182 struct bfa_wc_s wc; /* waiting counter */
183 struct bfa_timer_s timer; /* pending IO TOV */
184 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
185 struct bfa_fcpim_mod_s *fcpim; /* fcpim module */
186 struct bfa_itnim_iostats_s stats;
187 struct bfa_itnim_ioprofile_s ioprofile;
188};
189
190#define bfa_itnim_is_online(_itnim) ((_itnim)->is_online)
191#define BFA_FCPIM_MOD(_hal) (&(_hal)->modules.fcpim_mod)
192#define BFA_IOIM_TAG_2_ID(_iotag) ((_iotag) & BFA_IOIM_IOTAG_MASK)
193#define BFA_IOIM_FROM_TAG(_fcpim, _iotag) \
194 (&fcpim->ioim_arr[(_iotag & BFA_IOIM_IOTAG_MASK)])
195#define BFA_TSKIM_FROM_TAG(_fcpim, _tmtag) \
196 (&fcpim->tskim_arr[_tmtag & (fcpim->num_tskim_reqs - 1)])
197
198#define bfa_io_profile_start_time(_bfa) \
199 (_bfa->modules.fcpim_mod.io_profile_start_time)
200#define bfa_fcpim_get_io_profile(_bfa) \
201 (_bfa->modules.fcpim_mod.io_profile)
202#define bfa_ioim_update_iotag(__ioim) do { \
203 uint16_t k = (__ioim)->iotag >> BFA_IOIM_RETRY_TAG_OFFSET; \
204 k++; (__ioim)->iotag &= BFA_IOIM_IOTAG_MASK; \
205 (__ioim)->iotag |= k << BFA_IOIM_RETRY_TAG_OFFSET; \
206} while (0)
207
208static inline bfa_boolean_t
209bfa_ioim_maxretry_reached(struct bfa_ioim_s *ioim)
210{
211 uint16_t k = ioim->iotag >> BFA_IOIM_RETRY_TAG_OFFSET;
212 if (k < BFA_IOIM_RETRY_MAX)
213 return BFA_FALSE;
214 return BFA_TRUE;
215}
216
217/*
218 * function prototypes
219 */
220void bfa_ioim_attach(struct bfa_fcpim_mod_s *fcpim,
221 struct bfa_meminfo_s *minfo);
222void bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
223void bfa_ioim_good_comp_isr(struct bfa_s *bfa,
224 struct bfi_msg_s *msg);
225void bfa_ioim_cleanup(struct bfa_ioim_s *ioim);
226void bfa_ioim_cleanup_tm(struct bfa_ioim_s *ioim,
227 struct bfa_tskim_s *tskim);
228void bfa_ioim_iocdisable(struct bfa_ioim_s *ioim);
229void bfa_ioim_tov(struct bfa_ioim_s *ioim);
230
231void bfa_tskim_attach(struct bfa_fcpim_mod_s *fcpim,
232 struct bfa_meminfo_s *minfo);
233void bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
234void bfa_tskim_iodone(struct bfa_tskim_s *tskim);
235void bfa_tskim_iocdisable(struct bfa_tskim_s *tskim);
236void bfa_tskim_cleanup(struct bfa_tskim_s *tskim);
237
238void bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
239 u32 *dm_len);
240void bfa_itnim_attach(struct bfa_fcpim_mod_s *fcpim,
241 struct bfa_meminfo_s *minfo);
242void bfa_itnim_detach(struct bfa_fcpim_mod_s *fcpim);
243void bfa_itnim_iocdisable(struct bfa_itnim_s *itnim);
244void bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
245void bfa_itnim_iodone(struct bfa_itnim_s *itnim);
246void bfa_itnim_tskdone(struct bfa_itnim_s *itnim);
247bfa_boolean_t bfa_itnim_hold_io(struct bfa_itnim_s *itnim);
248
249/*
250 * bfa fcpim module API functions
251 */
252void bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov);
253u16 bfa_fcpim_path_tov_get(struct bfa_s *bfa);
254u16 bfa_fcpim_qdepth_get(struct bfa_s *bfa);
255
256#define bfa_fcpim_ioredirect_enabled(__bfa) \
257 (((struct bfa_fcpim_mod_s *)(BFA_FCPIM_MOD(__bfa)))->ioredirect)
258
259#define bfa_fcpim_get_next_reqq(__bfa, __qid) \
260{ \
261 struct bfa_fcpim_mod_s *__fcpim = BFA_FCPIM_MOD(__bfa); \
262 __fcpim->reqq++; \
263 __fcpim->reqq &= (BFI_IOC_MAX_CQS - 1); \
264 *(__qid) = __fcpim->reqq; \
265}
266
267#define bfa_iocfc_map_msg_to_qid(__msg, __qid) \
268 *(__qid) = (u8)((__msg) & (BFI_IOC_MAX_CQS - 1));
269/*
270 * bfa itnim API functions
271 */
272struct bfa_itnim_s *bfa_itnim_create(struct bfa_s *bfa,
273 struct bfa_rport_s *rport, void *itnim);
274void bfa_itnim_delete(struct bfa_itnim_s *itnim);
275void bfa_itnim_online(struct bfa_itnim_s *itnim, bfa_boolean_t seq_rec);
276void bfa_itnim_offline(struct bfa_itnim_s *itnim);
277void bfa_itnim_clear_stats(struct bfa_itnim_s *itnim);
278bfa_status_t bfa_itnim_get_ioprofile(struct bfa_itnim_s *itnim,
279 struct bfa_itnim_ioprofile_s *ioprofile);
280
281#define bfa_itnim_get_reqq(__ioim) (((struct bfa_ioim_s *)__ioim)->itnim->reqq)
282
283/*
284 * BFA completion callback for bfa_itnim_online().
285 */
286void bfa_cb_itnim_online(void *itnim);
287
288/*
289 * BFA completion callback for bfa_itnim_offline().
290 */
291void bfa_cb_itnim_offline(void *itnim);
292void bfa_cb_itnim_tov_begin(void *itnim);
293void bfa_cb_itnim_tov(void *itnim);
294
295/*
296 * BFA notification to FCS/driver for second level error recovery.
297 * Atleast one I/O request has timedout and target is unresponsive to
298 * repeated abort requests. Second level error recovery should be initiated
299 * by starting implicit logout and recovery procedures.
300 */
301void bfa_cb_itnim_sler(void *itnim);
302
303/*
304 * bfa ioim API functions
305 */
306struct bfa_ioim_s *bfa_ioim_alloc(struct bfa_s *bfa,
307 struct bfad_ioim_s *dio,
308 struct bfa_itnim_s *itnim,
309 u16 nsgles);
310
311void bfa_ioim_free(struct bfa_ioim_s *ioim);
312void bfa_ioim_start(struct bfa_ioim_s *ioim);
313bfa_status_t bfa_ioim_abort(struct bfa_ioim_s *ioim);
314void bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim,
315 bfa_boolean_t iotov);
316/*
317 * I/O completion notification.
318 *
319 * @param[in] dio driver IO structure
320 * @param[in] io_status IO completion status
321 * @param[in] scsi_status SCSI status returned by target
322 * @param[in] sns_len SCSI sense length, 0 if none
323 * @param[in] sns_info SCSI sense data, if any
324 * @param[in] residue Residual length
325 *
326 * @return None
327 */
328void bfa_cb_ioim_done(void *bfad, struct bfad_ioim_s *dio,
329 enum bfi_ioim_status io_status,
330 u8 scsi_status, int sns_len,
331 u8 *sns_info, s32 residue);
332
333/*
334 * I/O good completion notification.
335 */
336void bfa_cb_ioim_good_comp(void *bfad, struct bfad_ioim_s *dio);
337
338/*
339 * I/O abort completion notification
340 */
341void bfa_cb_ioim_abort(void *bfad, struct bfad_ioim_s *dio);
342
343/*
344 * bfa tskim API functions
345 */
346struct bfa_tskim_s *bfa_tskim_alloc(struct bfa_s *bfa,
347 struct bfad_tskim_s *dtsk);
348void bfa_tskim_free(struct bfa_tskim_s *tskim);
349void bfa_tskim_start(struct bfa_tskim_s *tskim,
350 struct bfa_itnim_s *itnim, struct scsi_lun lun,
351 enum fcp_tm_cmnd tm, u8 t_secs);
352void bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk,
353 enum bfi_tskim_status tsk_status);
354
355#endif /* __BFA_FCPIM_H__ */
diff --git a/drivers/scsi/bfa/bfa_fcpim_priv.h b/drivers/scsi/bfa/bfa_fcpim_priv.h
deleted file mode 100644
index 762516cb5cb2..000000000000
--- a/drivers/scsi/bfa/bfa_fcpim_priv.h
+++ /dev/null
@@ -1,192 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_FCPIM_PRIV_H__
19#define __BFA_FCPIM_PRIV_H__
20
21#include <bfa_fcpim.h>
22#include <defs/bfa_defs_fcpim.h>
23#include <cs/bfa_wc.h>
24#include "bfa_sgpg_priv.h"
25
26#define BFA_ITNIM_MIN 32
27#define BFA_ITNIM_MAX 1024
28
29#define BFA_IOIM_MIN 8
30#define BFA_IOIM_MAX 2000
31
32#define BFA_TSKIM_MIN 4
33#define BFA_TSKIM_MAX 512
34#define BFA_FCPIM_PATHTOV_DEF (30 * 1000) /* in millisecs */
35#define BFA_FCPIM_PATHTOV_MAX (90 * 1000) /* in millisecs */
36
37#define bfa_fcpim_stats(__fcpim, __stats) \
38 ((__fcpim)->stats.__stats++)
39
40struct bfa_fcpim_mod_s {
41 struct bfa_s *bfa;
42 struct bfa_itnim_s *itnim_arr;
43 struct bfa_ioim_s *ioim_arr;
44 struct bfa_ioim_sp_s *ioim_sp_arr;
45 struct bfa_tskim_s *tskim_arr;
46 struct bfa_dma_s snsbase;
47 int num_itnims;
48 int num_ioim_reqs;
49 int num_tskim_reqs;
50 u32 path_tov;
51 u16 q_depth;
52 u8 reqq; /* Request queue to be used */
53 u8 rsvd;
54 struct list_head itnim_q; /* queue of active itnim */
55 struct list_head ioim_free_q; /* free IO resources */
56 struct list_head ioim_resfree_q; /* IOs waiting for f/w */
57 struct list_head ioim_comp_q; /* IO global comp Q */
58 struct list_head tskim_free_q;
59 u32 ios_active; /* current active IOs */
60 u32 delay_comp;
61 struct bfa_fcpim_stats_s stats;
62 bfa_boolean_t ioredirect;
63};
64
65struct bfa_ioim_s;
66struct bfa_tskim_s;
67
68/**
69 * BFA IO (initiator mode)
70 */
71struct bfa_ioim_s {
72 struct list_head qe; /* queue elememt */
73 bfa_sm_t sm; /* BFA ioim state machine */
74 struct bfa_s *bfa; /* BFA module */
75 struct bfa_fcpim_mod_s *fcpim; /* parent fcpim module */
76 struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */
77 struct bfad_ioim_s *dio; /* driver IO handle */
78 u16 iotag; /* FWI IO tag */
79 u16 abort_tag; /* unqiue abort request tag */
80 u16 nsges; /* number of SG elements */
81 u16 nsgpgs; /* number of SG pages */
82 struct bfa_sgpg_s *sgpg; /* first SG page */
83 struct list_head sgpg_q; /* allocated SG pages */
84 struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
85 bfa_cb_cbfn_t io_cbfn; /* IO completion handler */
86 struct bfa_ioim_sp_s *iosp; /* slow-path IO handling */
87 u8 reqq; /* Request queue for I/O */
88};
89
90struct bfa_ioim_sp_s {
91 struct bfi_msg_s comp_rspmsg; /* IO comp f/w response */
92 u8 *snsinfo; /* sense info for this IO */
93 struct bfa_sgpg_wqe_s sgpg_wqe; /* waitq elem for sgpg */
94 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
95 bfa_boolean_t abort_explicit; /* aborted by OS */
96 struct bfa_tskim_s *tskim; /* Relevant TM cmd */
97};
98
99/**
100 * BFA Task management command (initiator mode)
101 */
102struct bfa_tskim_s {
103 struct list_head qe;
104 bfa_sm_t sm;
105 struct bfa_s *bfa; /* BFA module */
106 struct bfa_fcpim_mod_s *fcpim; /* parent fcpim module */
107 struct bfa_itnim_s *itnim; /* i-t-n nexus for this IO */
108 struct bfad_tskim_s *dtsk; /* driver task mgmt cmnd */
109 bfa_boolean_t notify; /* notify itnim on TM comp */
110 lun_t lun; /* lun if applicable */
111 enum fcp_tm_cmnd tm_cmnd; /* task management command */
112 u16 tsk_tag; /* FWI IO tag */
113 u8 tsecs; /* timeout in seconds */
114 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
115 struct list_head io_q; /* queue of affected IOs */
116 struct bfa_wc_s wc; /* waiting counter */
117 struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
118 enum bfi_tskim_status tsk_status; /* TM status */
119};
120
121/**
122 * BFA i-t-n (initiator mode)
123 */
124struct bfa_itnim_s {
125 struct list_head qe; /* queue element */
126 bfa_sm_t sm; /* i-t-n im BFA state machine */
127 struct bfa_s *bfa; /* bfa instance */
128 struct bfa_rport_s *rport; /* bfa rport */
129 void *ditn; /* driver i-t-n structure */
130 struct bfi_mhdr_s mhdr; /* pre-built mhdr */
131 u8 msg_no; /* itnim/rport firmware handle */
132 u8 reqq; /* CQ for requests */
133 struct bfa_cb_qe_s hcb_qe; /* bfa callback qelem */
134 struct list_head pending_q; /* queue of pending IO requests*/
135 struct list_head io_q; /* queue of active IO requests */
136 struct list_head io_cleanup_q; /* IO being cleaned up */
137 struct list_head tsk_q; /* queue of active TM commands */
138 struct list_head delay_comp_q;/* queue of failed inflight cmds */
139 bfa_boolean_t seq_rec; /* SQER supported */
140 bfa_boolean_t is_online; /* itnim is ONLINE for IO */
141 bfa_boolean_t iotov_active; /* IO TOV timer is active */
142 struct bfa_wc_s wc; /* waiting counter */
143 struct bfa_timer_s timer; /* pending IO TOV */
144 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
145 struct bfa_fcpim_mod_s *fcpim; /* fcpim module */
146 struct bfa_itnim_hal_stats_s stats;
147 struct bfa_itnim_latency_s io_latency;
148};
149
150#define bfa_itnim_is_online(_itnim) ((_itnim)->is_online)
151#define BFA_FCPIM_MOD(_hal) (&(_hal)->modules.fcpim_mod)
152#define BFA_IOIM_FROM_TAG(_fcpim, _iotag) \
153 (&fcpim->ioim_arr[_iotag])
154#define BFA_TSKIM_FROM_TAG(_fcpim, _tmtag) \
155 (&fcpim->tskim_arr[_tmtag & (fcpim->num_tskim_reqs - 1)])
156
157/*
158 * function prototypes
159 */
160void bfa_ioim_attach(struct bfa_fcpim_mod_s *fcpim,
161 struct bfa_meminfo_s *minfo);
162void bfa_ioim_detach(struct bfa_fcpim_mod_s *fcpim);
163void bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
164void bfa_ioim_good_comp_isr(struct bfa_s *bfa,
165 struct bfi_msg_s *msg);
166void bfa_ioim_cleanup(struct bfa_ioim_s *ioim);
167void bfa_ioim_cleanup_tm(struct bfa_ioim_s *ioim,
168 struct bfa_tskim_s *tskim);
169void bfa_ioim_iocdisable(struct bfa_ioim_s *ioim);
170void bfa_ioim_tov(struct bfa_ioim_s *ioim);
171
172void bfa_tskim_attach(struct bfa_fcpim_mod_s *fcpim,
173 struct bfa_meminfo_s *minfo);
174void bfa_tskim_detach(struct bfa_fcpim_mod_s *fcpim);
175void bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
176void bfa_tskim_iodone(struct bfa_tskim_s *tskim);
177void bfa_tskim_iocdisable(struct bfa_tskim_s *tskim);
178void bfa_tskim_cleanup(struct bfa_tskim_s *tskim);
179
180void bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
181 u32 *dm_len);
182void bfa_itnim_attach(struct bfa_fcpim_mod_s *fcpim,
183 struct bfa_meminfo_s *minfo);
184void bfa_itnim_detach(struct bfa_fcpim_mod_s *fcpim);
185void bfa_itnim_iocdisable(struct bfa_itnim_s *itnim);
186void bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
187void bfa_itnim_iodone(struct bfa_itnim_s *itnim);
188void bfa_itnim_tskdone(struct bfa_itnim_s *itnim);
189bfa_boolean_t bfa_itnim_hold_io(struct bfa_itnim_s *itnim);
190
191#endif /* __BFA_FCPIM_PRIV_H__ */
192
diff --git a/drivers/scsi/bfa/bfa_fcport.c b/drivers/scsi/bfa/bfa_fcport.c
deleted file mode 100644
index 76867b5577fa..000000000000
--- a/drivers/scsi/bfa/bfa_fcport.c
+++ /dev/null
@@ -1,1962 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
19#include <bfa_svc.h>
20#include <bfi/bfi_pport.h>
21#include <bfi/bfi_pbc.h>
22#include <cs/bfa_debug.h>
23#include <aen/bfa_aen.h>
24#include <cs/bfa_plog.h>
25#include <aen/bfa_aen_port.h>
26
27BFA_TRC_FILE(HAL, FCPORT);
28BFA_MODULE(fcport);
29
30/*
31 * The port is considered disabled if corresponding physical port or IOC are
32 * disabled explicitly
33 */
34#define BFA_PORT_IS_DISABLED(bfa) \
35 ((bfa_fcport_is_disabled(bfa) == BFA_TRUE) || \
36 (bfa_ioc_is_disabled(&bfa->ioc) == BFA_TRUE))
37
38/*
39 * forward declarations
40 */
41static bfa_boolean_t bfa_fcport_send_enable(struct bfa_fcport_s *fcport);
42static bfa_boolean_t bfa_fcport_send_disable(struct bfa_fcport_s *fcport);
43static void bfa_fcport_update_linkinfo(struct bfa_fcport_s *fcport);
44static void bfa_fcport_reset_linkinfo(struct bfa_fcport_s *fcport);
45static void bfa_fcport_set_wwns(struct bfa_fcport_s *fcport);
46static void __bfa_cb_fcport_event(void *cbarg, bfa_boolean_t complete);
47static void bfa_fcport_callback(struct bfa_fcport_s *fcport,
48 enum bfa_pport_linkstate event);
49static void bfa_fcport_queue_cb(struct bfa_fcport_ln_s *ln,
50 enum bfa_pport_linkstate event);
51static void __bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete);
52static void bfa_fcport_stats_get_timeout(void *cbarg);
53static void bfa_fcport_stats_clr_timeout(void *cbarg);
54
55/**
56 * bfa_pport_private
57 */
58
59/**
60 * BFA port state machine events
61 */
62enum bfa_fcport_sm_event {
63 BFA_FCPORT_SM_START = 1, /* start port state machine */
64 BFA_FCPORT_SM_STOP = 2, /* stop port state machine */
65 BFA_FCPORT_SM_ENABLE = 3, /* enable port */
66 BFA_FCPORT_SM_DISABLE = 4, /* disable port state machine */
67 BFA_FCPORT_SM_FWRSP = 5, /* firmware enable/disable rsp */
68 BFA_FCPORT_SM_LINKUP = 6, /* firmware linkup event */
69 BFA_FCPORT_SM_LINKDOWN = 7, /* firmware linkup down */
70 BFA_FCPORT_SM_QRESUME = 8, /* CQ space available */
71 BFA_FCPORT_SM_HWFAIL = 9, /* IOC h/w failure */
72};
73
74/**
75 * BFA port link notification state machine events
76 */
77
78enum bfa_fcport_ln_sm_event {
79 BFA_FCPORT_LN_SM_LINKUP = 1, /* linkup event */
80 BFA_FCPORT_LN_SM_LINKDOWN = 2, /* linkdown event */
81 BFA_FCPORT_LN_SM_NOTIFICATION = 3 /* done notification */
82};
83
84static void bfa_fcport_sm_uninit(struct bfa_fcport_s *fcport,
85 enum bfa_fcport_sm_event event);
86static void bfa_fcport_sm_enabling_qwait(struct bfa_fcport_s *fcport,
87 enum bfa_fcport_sm_event event);
88static void bfa_fcport_sm_enabling(struct bfa_fcport_s *fcport,
89 enum bfa_fcport_sm_event event);
90static void bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport,
91 enum bfa_fcport_sm_event event);
92static void bfa_fcport_sm_linkup(struct bfa_fcport_s *fcport,
93 enum bfa_fcport_sm_event event);
94static void bfa_fcport_sm_disabling(struct bfa_fcport_s *fcport,
95 enum bfa_fcport_sm_event event);
96static void bfa_fcport_sm_disabling_qwait(struct bfa_fcport_s *fcport,
97 enum bfa_fcport_sm_event event);
98static void bfa_fcport_sm_disabled(struct bfa_fcport_s *fcport,
99 enum bfa_fcport_sm_event event);
100static void bfa_fcport_sm_stopped(struct bfa_fcport_s *fcport,
101 enum bfa_fcport_sm_event event);
102static void bfa_fcport_sm_iocdown(struct bfa_fcport_s *fcport,
103 enum bfa_fcport_sm_event event);
104static void bfa_fcport_sm_iocfail(struct bfa_fcport_s *fcport,
105 enum bfa_fcport_sm_event event);
106
107static void bfa_fcport_ln_sm_dn(struct bfa_fcport_ln_s *ln,
108 enum bfa_fcport_ln_sm_event event);
109static void bfa_fcport_ln_sm_dn_nf(struct bfa_fcport_ln_s *ln,
110 enum bfa_fcport_ln_sm_event event);
111static void bfa_fcport_ln_sm_dn_up_nf(struct bfa_fcport_ln_s *ln,
112 enum bfa_fcport_ln_sm_event event);
113static void bfa_fcport_ln_sm_up(struct bfa_fcport_ln_s *ln,
114 enum bfa_fcport_ln_sm_event event);
115static void bfa_fcport_ln_sm_up_nf(struct bfa_fcport_ln_s *ln,
116 enum bfa_fcport_ln_sm_event event);
117static void bfa_fcport_ln_sm_up_dn_nf(struct bfa_fcport_ln_s *ln,
118 enum bfa_fcport_ln_sm_event event);
119static void bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln,
120 enum bfa_fcport_ln_sm_event event);
121
122static struct bfa_sm_table_s hal_pport_sm_table[] = {
123 {BFA_SM(bfa_fcport_sm_uninit), BFA_PPORT_ST_UNINIT},
124 {BFA_SM(bfa_fcport_sm_enabling_qwait), BFA_PPORT_ST_ENABLING_QWAIT},
125 {BFA_SM(bfa_fcport_sm_enabling), BFA_PPORT_ST_ENABLING},
126 {BFA_SM(bfa_fcport_sm_linkdown), BFA_PPORT_ST_LINKDOWN},
127 {BFA_SM(bfa_fcport_sm_linkup), BFA_PPORT_ST_LINKUP},
128 {BFA_SM(bfa_fcport_sm_disabling_qwait), BFA_PPORT_ST_DISABLING_QWAIT},
129 {BFA_SM(bfa_fcport_sm_disabling), BFA_PPORT_ST_DISABLING},
130 {BFA_SM(bfa_fcport_sm_disabled), BFA_PPORT_ST_DISABLED},
131 {BFA_SM(bfa_fcport_sm_stopped), BFA_PPORT_ST_STOPPED},
132 {BFA_SM(bfa_fcport_sm_iocdown), BFA_PPORT_ST_IOCDOWN},
133 {BFA_SM(bfa_fcport_sm_iocfail), BFA_PPORT_ST_IOCDOWN},
134};
135
136static void
137bfa_fcport_aen_post(struct bfa_fcport_s *fcport, enum bfa_port_aen_event event)
138{
139 union bfa_aen_data_u aen_data;
140 struct bfa_log_mod_s *logmod = fcport->bfa->logm;
141 wwn_t pwwn = fcport->pwwn;
142 char pwwn_ptr[BFA_STRING_32];
143
144 memset(&aen_data, 0, sizeof(aen_data));
145 wwn2str(pwwn_ptr, pwwn);
146 bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, event), pwwn_ptr);
147
148 aen_data.port.ioc_type = bfa_get_type(fcport->bfa);
149 aen_data.port.pwwn = pwwn;
150}
151
152static void
153bfa_fcport_sm_uninit(struct bfa_fcport_s *fcport,
154 enum bfa_fcport_sm_event event)
155{
156 bfa_trc(fcport->bfa, event);
157
158 switch (event) {
159 case BFA_FCPORT_SM_START:
160 /**
161 * Start event after IOC is configured and BFA is started.
162 */
163 if (bfa_fcport_send_enable(fcport))
164 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
165 else
166 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait);
167 break;
168
169 case BFA_FCPORT_SM_ENABLE:
170 /**
171 * Port is persistently configured to be in enabled state. Do
172 * not change state. Port enabling is done when START event is
173 * received.
174 */
175 break;
176
177 case BFA_FCPORT_SM_DISABLE:
178 /**
179 * If a port is persistently configured to be disabled, the
180 * first event will a port disable request.
181 */
182 bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
183 break;
184
185 case BFA_FCPORT_SM_HWFAIL:
186 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
187 break;
188
189 default:
190 bfa_sm_fault(fcport->bfa, event);
191 }
192}
193
194static void
195bfa_fcport_sm_enabling_qwait(struct bfa_fcport_s *fcport,
196 enum bfa_fcport_sm_event event)
197{
198 bfa_trc(fcport->bfa, event);
199
200 switch (event) {
201 case BFA_FCPORT_SM_QRESUME:
202 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
203 bfa_fcport_send_enable(fcport);
204 break;
205
206 case BFA_FCPORT_SM_STOP:
207 bfa_reqq_wcancel(&fcport->reqq_wait);
208 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
209 break;
210
211 case BFA_FCPORT_SM_ENABLE:
212 /**
213 * Already enable is in progress.
214 */
215 break;
216
217 case BFA_FCPORT_SM_DISABLE:
218 /**
219 * Just send disable request to firmware when room becomes
220 * available in request queue.
221 */
222 bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
223 bfa_reqq_wcancel(&fcport->reqq_wait);
224 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
225 BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
226 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE);
227 break;
228
229 case BFA_FCPORT_SM_LINKUP:
230 case BFA_FCPORT_SM_LINKDOWN:
231 /**
232 * Possible to get link events when doing back-to-back
233 * enable/disables.
234 */
235 break;
236
237 case BFA_FCPORT_SM_HWFAIL:
238 bfa_reqq_wcancel(&fcport->reqq_wait);
239 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
240 break;
241
242 default:
243 bfa_sm_fault(fcport->bfa, event);
244 }
245}
246
247static void
248bfa_fcport_sm_enabling(struct bfa_fcport_s *fcport,
249 enum bfa_fcport_sm_event event)
250{
251 bfa_trc(fcport->bfa, event);
252
253 switch (event) {
254 case BFA_FCPORT_SM_FWRSP:
255 case BFA_FCPORT_SM_LINKDOWN:
256 bfa_sm_set_state(fcport, bfa_fcport_sm_linkdown);
257 break;
258
259 case BFA_FCPORT_SM_LINKUP:
260 bfa_fcport_update_linkinfo(fcport);
261 bfa_sm_set_state(fcport, bfa_fcport_sm_linkup);
262
263 bfa_assert(fcport->event_cbfn);
264 bfa_fcport_callback(fcport, BFA_PPORT_LINKUP);
265 break;
266
267 case BFA_FCPORT_SM_ENABLE:
268 /**
269 * Already being enabled.
270 */
271 break;
272
273 case BFA_FCPORT_SM_DISABLE:
274 if (bfa_fcport_send_disable(fcport))
275 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
276 else
277 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait);
278
279 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
280 BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
281 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE);
282 break;
283
284 case BFA_FCPORT_SM_STOP:
285 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
286 break;
287
288 case BFA_FCPORT_SM_HWFAIL:
289 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
290 break;
291
292 default:
293 bfa_sm_fault(fcport->bfa, event);
294 }
295}
296
297static void
298bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport,
299 enum bfa_fcport_sm_event event)
300{
301 struct bfi_fcport_event_s *pevent = fcport->event_arg.i2hmsg.event;
302 bfa_trc(fcport->bfa, event);
303
304 switch (event) {
305 case BFA_FCPORT_SM_LINKUP:
306 bfa_fcport_update_linkinfo(fcport);
307 bfa_sm_set_state(fcport, bfa_fcport_sm_linkup);
308 bfa_assert(fcport->event_cbfn);
309 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
310 BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkup");
311
312 if (!bfa_ioc_get_fcmode(&fcport->bfa->ioc)) {
313
314 bfa_trc(fcport->bfa,
315 pevent->link_state.vc_fcf.fcf.fipenabled);
316 bfa_trc(fcport->bfa,
317 pevent->link_state.vc_fcf.fcf.fipfailed);
318
319 if (pevent->link_state.vc_fcf.fcf.fipfailed)
320 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
321 BFA_PL_EID_FIP_FCF_DISC, 0,
322 "FIP FCF Discovery Failed");
323 else
324 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
325 BFA_PL_EID_FIP_FCF_DISC, 0,
326 "FIP FCF Discovered");
327 }
328
329 bfa_fcport_callback(fcport, BFA_PPORT_LINKUP);
330 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ONLINE);
331 /**
332 * If QoS is enabled and it is not online,
333 * Send a separate event.
334 */
335 if ((fcport->cfg.qos_enabled)
336 && (bfa_os_ntohl(fcport->qos_attr.state) != BFA_QOS_ONLINE))
337 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_QOS_NEG);
338
339 break;
340
341 case BFA_FCPORT_SM_LINKDOWN:
342 /**
343 * Possible to get link down event.
344 */
345 break;
346
347 case BFA_FCPORT_SM_ENABLE:
348 /**
349 * Already enabled.
350 */
351 break;
352
353 case BFA_FCPORT_SM_DISABLE:
354 if (bfa_fcport_send_disable(fcport))
355 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
356 else
357 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait);
358
359 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
360 BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
361 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE);
362 break;
363
364 case BFA_FCPORT_SM_STOP:
365 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
366 break;
367
368 case BFA_FCPORT_SM_HWFAIL:
369 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
370 break;
371
372 default:
373 bfa_sm_fault(fcport->bfa, event);
374 }
375}
376
377static void
378bfa_fcport_sm_linkup(struct bfa_fcport_s *fcport,
379 enum bfa_fcport_sm_event event)
380{
381 bfa_trc(fcport->bfa, event);
382
383 switch (event) {
384 case BFA_FCPORT_SM_ENABLE:
385 /**
386 * Already enabled.
387 */
388 break;
389
390 case BFA_FCPORT_SM_DISABLE:
391 if (bfa_fcport_send_disable(fcport))
392 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
393 else
394 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait);
395
396 bfa_fcport_reset_linkinfo(fcport);
397 bfa_fcport_callback(fcport, BFA_PPORT_LINKDOWN);
398 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
399 BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
400 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE);
401 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISABLE);
402 break;
403
404 case BFA_FCPORT_SM_LINKDOWN:
405 bfa_sm_set_state(fcport, bfa_fcport_sm_linkdown);
406 bfa_fcport_reset_linkinfo(fcport);
407 bfa_fcport_callback(fcport, BFA_PPORT_LINKDOWN);
408 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
409 BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkdown");
410 if (BFA_PORT_IS_DISABLED(fcport->bfa))
411 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE);
412 else
413 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
414 break;
415
416 case BFA_FCPORT_SM_STOP:
417 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
418 bfa_fcport_reset_linkinfo(fcport);
419 if (BFA_PORT_IS_DISABLED(fcport->bfa))
420 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE);
421 else
422 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
423 break;
424
425 case BFA_FCPORT_SM_HWFAIL:
426 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
427 bfa_fcport_reset_linkinfo(fcport);
428 bfa_fcport_callback(fcport, BFA_PPORT_LINKDOWN);
429 if (BFA_PORT_IS_DISABLED(fcport->bfa))
430 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_OFFLINE);
431 else
432 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_DISCONNECT);
433 break;
434
435 default:
436 bfa_sm_fault(fcport->bfa, event);
437 }
438}
439
440static void
441bfa_fcport_sm_disabling_qwait(struct bfa_fcport_s *fcport,
442 enum bfa_fcport_sm_event event)
443{
444 bfa_trc(fcport->bfa, event);
445
446 switch (event) {
447 case BFA_FCPORT_SM_QRESUME:
448 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
449 bfa_fcport_send_disable(fcport);
450 break;
451
452 case BFA_FCPORT_SM_STOP:
453 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
454 bfa_reqq_wcancel(&fcport->reqq_wait);
455 break;
456
457 case BFA_FCPORT_SM_DISABLE:
458 /**
459 * Already being disabled.
460 */
461 break;
462
463 case BFA_FCPORT_SM_LINKUP:
464 case BFA_FCPORT_SM_LINKDOWN:
465 /**
466 * Possible to get link events when doing back-to-back
467 * enable/disables.
468 */
469 break;
470
471 case BFA_FCPORT_SM_HWFAIL:
472 bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
473 bfa_reqq_wcancel(&fcport->reqq_wait);
474 break;
475
476 default:
477 bfa_sm_fault(fcport->bfa, event);
478 }
479}
480
481static void
482bfa_fcport_sm_disabling(struct bfa_fcport_s *fcport,
483 enum bfa_fcport_sm_event event)
484{
485 bfa_trc(fcport->bfa, event);
486
487 switch (event) {
488 case BFA_FCPORT_SM_FWRSP:
489 bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
490 break;
491
492 case BFA_FCPORT_SM_DISABLE:
493 /**
494 * Already being disabled.
495 */
496 break;
497
498 case BFA_FCPORT_SM_ENABLE:
499 if (bfa_fcport_send_enable(fcport))
500 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
501 else
502 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait);
503
504 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
505 BFA_PL_EID_PORT_ENABLE, 0, "Port Enable");
506 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ENABLE);
507 break;
508
509 case BFA_FCPORT_SM_STOP:
510 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
511 break;
512
513 case BFA_FCPORT_SM_LINKUP:
514 case BFA_FCPORT_SM_LINKDOWN:
515 /**
516 * Possible to get link events when doing back-to-back
517 * enable/disables.
518 */
519 break;
520
521 case BFA_FCPORT_SM_HWFAIL:
522 bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
523 break;
524
525 default:
526 bfa_sm_fault(fcport->bfa, event);
527 }
528}
529
530static void
531bfa_fcport_sm_disabled(struct bfa_fcport_s *fcport,
532 enum bfa_fcport_sm_event event)
533{
534 bfa_trc(fcport->bfa, event);
535
536 switch (event) {
537 case BFA_FCPORT_SM_START:
538 /**
539 * Ignore start event for a port that is disabled.
540 */
541 break;
542
543 case BFA_FCPORT_SM_STOP:
544 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
545 break;
546
547 case BFA_FCPORT_SM_ENABLE:
548 if (bfa_fcport_send_enable(fcport))
549 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
550 else
551 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait);
552
553 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
554 BFA_PL_EID_PORT_ENABLE, 0, "Port Enable");
555 bfa_fcport_aen_post(fcport, BFA_PORT_AEN_ENABLE);
556 break;
557
558 case BFA_FCPORT_SM_DISABLE:
559 /**
560 * Already disabled.
561 */
562 break;
563
564 case BFA_FCPORT_SM_HWFAIL:
565 bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
566 break;
567
568 default:
569 bfa_sm_fault(fcport->bfa, event);
570 }
571}
572
573static void
574bfa_fcport_sm_stopped(struct bfa_fcport_s *fcport,
575 enum bfa_fcport_sm_event event)
576{
577 bfa_trc(fcport->bfa, event);
578
579 switch (event) {
580 case BFA_FCPORT_SM_START:
581 if (bfa_fcport_send_enable(fcport))
582 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
583 else
584 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait);
585 break;
586
587 default:
588 /**
589 * Ignore all other events.
590 */
591 ;
592 }
593}
594
595/**
596 * Port is enabled. IOC is down/failed.
597 */
598static void
599bfa_fcport_sm_iocdown(struct bfa_fcport_s *fcport,
600 enum bfa_fcport_sm_event event)
601{
602 bfa_trc(fcport->bfa, event);
603
604 switch (event) {
605 case BFA_FCPORT_SM_START:
606 if (bfa_fcport_send_enable(fcport))
607 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
608 else
609 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling_qwait);
610 break;
611
612 default:
613 /**
614 * Ignore all events.
615 */
616 ;
617 }
618}
619
620/**
621 * Port is disabled. IOC is down/failed.
622 */
623static void
624bfa_fcport_sm_iocfail(struct bfa_fcport_s *fcport,
625 enum bfa_fcport_sm_event event)
626{
627 bfa_trc(fcport->bfa, event);
628
629 switch (event) {
630 case BFA_FCPORT_SM_START:
631 bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
632 break;
633
634 case BFA_FCPORT_SM_ENABLE:
635 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
636 break;
637
638 default:
639 /**
640 * Ignore all events.
641 */
642 ;
643 }
644}
645
646/**
647 * Link state is down
648 */
649static void
650bfa_fcport_ln_sm_dn(struct bfa_fcport_ln_s *ln,
651 enum bfa_fcport_ln_sm_event event)
652{
653 bfa_trc(ln->fcport->bfa, event);
654
655 switch (event) {
656 case BFA_FCPORT_LN_SM_LINKUP:
657 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_nf);
658 bfa_fcport_queue_cb(ln, BFA_PPORT_LINKUP);
659 break;
660
661 default:
662 bfa_sm_fault(ln->fcport->bfa, event);
663 }
664}
665
666/**
667 * Link state is waiting for down notification
668 */
669static void
670bfa_fcport_ln_sm_dn_nf(struct bfa_fcport_ln_s *ln,
671 enum bfa_fcport_ln_sm_event event)
672{
673 bfa_trc(ln->fcport->bfa, event);
674
675 switch (event) {
676 case BFA_FCPORT_LN_SM_LINKUP:
677 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_up_nf);
678 break;
679
680 case BFA_FCPORT_LN_SM_NOTIFICATION:
681 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn);
682 break;
683
684 default:
685 bfa_sm_fault(ln->fcport->bfa, event);
686 }
687}
688
689/**
690 * Link state is waiting for down notification and there is a pending up
691 */
692static void
693bfa_fcport_ln_sm_dn_up_nf(struct bfa_fcport_ln_s *ln,
694 enum bfa_fcport_ln_sm_event event)
695{
696 bfa_trc(ln->fcport->bfa, event);
697
698 switch (event) {
699 case BFA_FCPORT_LN_SM_LINKDOWN:
700 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf);
701 break;
702
703 case BFA_FCPORT_LN_SM_NOTIFICATION:
704 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_nf);
705 bfa_fcport_queue_cb(ln, BFA_PPORT_LINKUP);
706 break;
707
708 default:
709 bfa_sm_fault(ln->fcport->bfa, event);
710 }
711}
712
713/**
714 * Link state is up
715 */
716static void
717bfa_fcport_ln_sm_up(struct bfa_fcport_ln_s *ln,
718 enum bfa_fcport_ln_sm_event event)
719{
720 bfa_trc(ln->fcport->bfa, event);
721
722 switch (event) {
723 case BFA_FCPORT_LN_SM_LINKDOWN:
724 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf);
725 bfa_fcport_queue_cb(ln, BFA_PPORT_LINKDOWN);
726 break;
727
728 default:
729 bfa_sm_fault(ln->fcport->bfa, event);
730 }
731}
732
733/**
734 * Link state is waiting for up notification
735 */
736static void
737bfa_fcport_ln_sm_up_nf(struct bfa_fcport_ln_s *ln,
738 enum bfa_fcport_ln_sm_event event)
739{
740 bfa_trc(ln->fcport->bfa, event);
741
742 switch (event) {
743 case BFA_FCPORT_LN_SM_LINKDOWN:
744 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_nf);
745 break;
746
747 case BFA_FCPORT_LN_SM_NOTIFICATION:
748 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up);
749 break;
750
751 default:
752 bfa_sm_fault(ln->fcport->bfa, event);
753 }
754}
755
756/**
757 * Link state is waiting for up notification and there is a pending down
758 */
759static void
760bfa_fcport_ln_sm_up_dn_nf(struct bfa_fcport_ln_s *ln,
761 enum bfa_fcport_ln_sm_event event)
762{
763 bfa_trc(ln->fcport->bfa, event);
764
765 switch (event) {
766 case BFA_FCPORT_LN_SM_LINKUP:
767 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_up_nf);
768 break;
769
770 case BFA_FCPORT_LN_SM_NOTIFICATION:
771 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf);
772 bfa_fcport_queue_cb(ln, BFA_PPORT_LINKDOWN);
773 break;
774
775 default:
776 bfa_sm_fault(ln->fcport->bfa, event);
777 }
778}
779
780/**
781 * Link state is waiting for up notification and there are pending down and up
782 */
783static void
784bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln,
785 enum bfa_fcport_ln_sm_event event)
786{
787 bfa_trc(ln->fcport->bfa, event);
788
789 switch (event) {
790 case BFA_FCPORT_LN_SM_LINKDOWN:
791 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_nf);
792 break;
793
794 case BFA_FCPORT_LN_SM_NOTIFICATION:
795 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_up_nf);
796 bfa_fcport_queue_cb(ln, BFA_PPORT_LINKDOWN);
797 break;
798
799 default:
800 bfa_sm_fault(ln->fcport->bfa, event);
801 }
802}
803
804/**
805 * bfa_pport_private
806 */
807
808static void
809__bfa_cb_fcport_event(void *cbarg, bfa_boolean_t complete)
810{
811 struct bfa_fcport_ln_s *ln = cbarg;
812
813 if (complete)
814 ln->fcport->event_cbfn(ln->fcport->event_cbarg, ln->ln_event);
815 else
816 bfa_sm_send_event(ln, BFA_FCPORT_LN_SM_NOTIFICATION);
817}
818
819static void
820bfa_fcport_callback(struct bfa_fcport_s *fcport, enum bfa_pport_linkstate event)
821{
822 if (fcport->bfa->fcs) {
823 fcport->event_cbfn(fcport->event_cbarg, event);
824 return;
825 }
826
827 switch (event) {
828 case BFA_PPORT_LINKUP:
829 bfa_sm_send_event(&fcport->ln, BFA_FCPORT_LN_SM_LINKUP);
830 break;
831 case BFA_PPORT_LINKDOWN:
832 bfa_sm_send_event(&fcport->ln, BFA_FCPORT_LN_SM_LINKDOWN);
833 break;
834 default:
835 bfa_assert(0);
836 }
837}
838
839static void
840bfa_fcport_queue_cb(struct bfa_fcport_ln_s *ln, enum bfa_pport_linkstate event)
841{
842 ln->ln_event = event;
843 bfa_cb_queue(ln->fcport->bfa, &ln->ln_qe, __bfa_cb_fcport_event, ln);
844}
845
846#define FCPORT_STATS_DMA_SZ (BFA_ROUNDUP(sizeof(union bfa_fcport_stats_u), \
847 BFA_CACHELINE_SZ))
848
849static void
850bfa_fcport_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len,
851 u32 *dm_len)
852{
853 *dm_len += FCPORT_STATS_DMA_SZ;
854}
855
856static void
857bfa_fcport_qresume(void *cbarg)
858{
859 struct bfa_fcport_s *fcport = cbarg;
860
861 bfa_sm_send_event(fcport, BFA_FCPORT_SM_QRESUME);
862}
863
864static void
865bfa_fcport_mem_claim(struct bfa_fcport_s *fcport, struct bfa_meminfo_s *meminfo)
866{
867 u8 *dm_kva;
868 u64 dm_pa;
869
870 dm_kva = bfa_meminfo_dma_virt(meminfo);
871 dm_pa = bfa_meminfo_dma_phys(meminfo);
872
873 fcport->stats_kva = dm_kva;
874 fcport->stats_pa = dm_pa;
875 fcport->stats = (union bfa_fcport_stats_u *)dm_kva;
876
877 dm_kva += FCPORT_STATS_DMA_SZ;
878 dm_pa += FCPORT_STATS_DMA_SZ;
879
880 bfa_meminfo_dma_virt(meminfo) = dm_kva;
881 bfa_meminfo_dma_phys(meminfo) = dm_pa;
882}
883
884/**
885 * Memory initialization.
886 */
887static void
888bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
889 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
890{
891 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
892 struct bfa_pport_cfg_s *port_cfg = &fcport->cfg;
893 struct bfa_fcport_ln_s *ln = &fcport->ln;
894 struct bfa_timeval_s tv;
895
896 bfa_os_memset(fcport, 0, sizeof(struct bfa_fcport_s));
897 fcport->bfa = bfa;
898 ln->fcport = fcport;
899
900 bfa_fcport_mem_claim(fcport, meminfo);
901
902 bfa_sm_set_state(fcport, bfa_fcport_sm_uninit);
903 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn);
904
905 /**
906 * initialize time stamp for stats reset
907 */
908 bfa_os_gettimeofday(&tv);
909 fcport->stats_reset_time = tv.tv_sec;
910
911 /**
912 * initialize and set default configuration
913 */
914 port_cfg->topology = BFA_PPORT_TOPOLOGY_P2P;
915 port_cfg->speed = BFA_PPORT_SPEED_AUTO;
916 port_cfg->trunked = BFA_FALSE;
917 port_cfg->maxfrsize = 0;
918
919 port_cfg->trl_def_speed = BFA_PPORT_SPEED_1GBPS;
920
921 bfa_reqq_winit(&fcport->reqq_wait, bfa_fcport_qresume, fcport);
922}
923
924static void
925bfa_fcport_detach(struct bfa_s *bfa)
926{
927}
928
929/**
930 * Called when IOC is ready.
931 */
932static void
933bfa_fcport_start(struct bfa_s *bfa)
934{
935 bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_START);
936}
937
938/**
939 * Called before IOC is stopped.
940 */
941static void
942bfa_fcport_stop(struct bfa_s *bfa)
943{
944 bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_STOP);
945}
946
947/**
948 * Called when IOC failure is detected.
949 */
950static void
951bfa_fcport_iocdisable(struct bfa_s *bfa)
952{
953 bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_HWFAIL);
954}
955
956static void
957bfa_fcport_update_linkinfo(struct bfa_fcport_s *fcport)
958{
959 struct bfi_fcport_event_s *pevent = fcport->event_arg.i2hmsg.event;
960
961 fcport->speed = pevent->link_state.speed;
962 fcport->topology = pevent->link_state.topology;
963
964 if (fcport->topology == BFA_PPORT_TOPOLOGY_LOOP)
965 fcport->myalpa = 0;
966
967 /*
968 * QoS Details
969 */
970 bfa_os_assign(fcport->qos_attr, pevent->link_state.qos_attr);
971 bfa_os_assign(fcport->qos_vc_attr,
972 pevent->link_state.vc_fcf.qos_vc_attr);
973
974
975 bfa_trc(fcport->bfa, fcport->speed);
976 bfa_trc(fcport->bfa, fcport->topology);
977}
978
979static void
980bfa_fcport_reset_linkinfo(struct bfa_fcport_s *fcport)
981{
982 fcport->speed = BFA_PPORT_SPEED_UNKNOWN;
983 fcport->topology = BFA_PPORT_TOPOLOGY_NONE;
984}
985
986/**
987 * Send port enable message to firmware.
988 */
989static bfa_boolean_t
990bfa_fcport_send_enable(struct bfa_fcport_s *fcport)
991{
992 struct bfi_fcport_enable_req_s *m;
993
994 /**
995 * Increment message tag before queue check, so that responses to old
996 * requests are discarded.
997 */
998 fcport->msgtag++;
999
1000 /**
1001 * check for room in queue to send request now
1002 */
1003 m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
1004 if (!m) {
1005 bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
1006 &fcport->reqq_wait);
1007 return BFA_FALSE;
1008 }
1009
1010 bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_ENABLE_REQ,
1011 bfa_lpuid(fcport->bfa));
1012 m->nwwn = fcport->nwwn;
1013 m->pwwn = fcport->pwwn;
1014 m->port_cfg = fcport->cfg;
1015 m->msgtag = fcport->msgtag;
1016 m->port_cfg.maxfrsize = bfa_os_htons(fcport->cfg.maxfrsize);
1017 bfa_dma_be_addr_set(m->stats_dma_addr, fcport->stats_pa);
1018 bfa_trc(fcport->bfa, m->stats_dma_addr.a32.addr_lo);
1019 bfa_trc(fcport->bfa, m->stats_dma_addr.a32.addr_hi);
1020
1021 /**
1022 * queue I/O message to firmware
1023 */
1024 bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT);
1025 return BFA_TRUE;
1026}
1027
1028/**
1029 * Send port disable message to firmware.
1030 */
1031static bfa_boolean_t
1032bfa_fcport_send_disable(struct bfa_fcport_s *fcport)
1033{
1034 struct bfi_fcport_req_s *m;
1035
1036 /**
1037 * Increment message tag before queue check, so that responses to old
1038 * requests are discarded.
1039 */
1040 fcport->msgtag++;
1041
1042 /**
1043 * check for room in queue to send request now
1044 */
1045 m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
1046 if (!m) {
1047 bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
1048 &fcport->reqq_wait);
1049 return BFA_FALSE;
1050 }
1051
1052 bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_DISABLE_REQ,
1053 bfa_lpuid(fcport->bfa));
1054 m->msgtag = fcport->msgtag;
1055
1056 /**
1057 * queue I/O message to firmware
1058 */
1059 bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT);
1060
1061 return BFA_TRUE;
1062}
1063
1064static void
1065bfa_fcport_set_wwns(struct bfa_fcport_s *fcport)
1066{
1067 fcport->pwwn = bfa_ioc_get_pwwn(&fcport->bfa->ioc);
1068 fcport->nwwn = bfa_ioc_get_nwwn(&fcport->bfa->ioc);
1069
1070 bfa_trc(fcport->bfa, fcport->pwwn);
1071 bfa_trc(fcport->bfa, fcport->nwwn);
1072}
1073
1074static void
1075bfa_fcport_send_txcredit(void *port_cbarg)
1076{
1077
1078 struct bfa_fcport_s *fcport = port_cbarg;
1079 struct bfi_fcport_set_svc_params_req_s *m;
1080
1081 /**
1082 * check for room in queue to send request now
1083 */
1084 m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
1085 if (!m) {
1086 bfa_trc(fcport->bfa, fcport->cfg.tx_bbcredit);
1087 return;
1088 }
1089
1090 bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ,
1091 bfa_lpuid(fcport->bfa));
1092 m->tx_bbcredit = bfa_os_htons((u16) fcport->cfg.tx_bbcredit);
1093
1094 /**
1095 * queue I/O message to firmware
1096 */
1097 bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT);
1098}
1099
1100static void
1101bfa_fcport_qos_stats_swap(struct bfa_qos_stats_s *d,
1102 struct bfa_qos_stats_s *s)
1103{
1104 u32 *dip = (u32 *) d;
1105 u32 *sip = (u32 *) s;
1106 int i;
1107
1108 /* Now swap the 32 bit fields */
1109 for (i = 0; i < (sizeof(struct bfa_qos_stats_s)/sizeof(u32)); ++i)
1110 dip[i] = bfa_os_ntohl(sip[i]);
1111}
1112
1113static void
1114bfa_fcport_fcoe_stats_swap(struct bfa_fcoe_stats_s *d,
1115 struct bfa_fcoe_stats_s *s)
1116{
1117 u32 *dip = (u32 *) d;
1118 u32 *sip = (u32 *) s;
1119 int i;
1120
1121 for (i = 0; i < ((sizeof(struct bfa_fcoe_stats_s))/sizeof(u32));
1122 i = i + 2) {
1123#ifdef __BIGENDIAN
1124 dip[i] = bfa_os_ntohl(sip[i]);
1125 dip[i + 1] = bfa_os_ntohl(sip[i + 1]);
1126#else
1127 dip[i] = bfa_os_ntohl(sip[i + 1]);
1128 dip[i + 1] = bfa_os_ntohl(sip[i]);
1129#endif
1130 }
1131}
1132
1133static void
1134__bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete)
1135{
1136 struct bfa_fcport_s *fcport = cbarg;
1137
1138 if (complete) {
1139 if (fcport->stats_status == BFA_STATUS_OK) {
1140 struct bfa_timeval_s tv;
1141
1142 /* Swap FC QoS or FCoE stats */
1143 if (bfa_ioc_get_fcmode(&fcport->bfa->ioc)) {
1144 bfa_fcport_qos_stats_swap(
1145 &fcport->stats_ret->fcqos,
1146 &fcport->stats->fcqos);
1147 } else {
1148 bfa_fcport_fcoe_stats_swap(
1149 &fcport->stats_ret->fcoe,
1150 &fcport->stats->fcoe);
1151
1152 bfa_os_gettimeofday(&tv);
1153 fcport->stats_ret->fcoe.secs_reset =
1154 tv.tv_sec - fcport->stats_reset_time;
1155 }
1156 }
1157 fcport->stats_cbfn(fcport->stats_cbarg, fcport->stats_status);
1158 } else {
1159 fcport->stats_busy = BFA_FALSE;
1160 fcport->stats_status = BFA_STATUS_OK;
1161 }
1162}
1163
1164static void
1165bfa_fcport_stats_get_timeout(void *cbarg)
1166{
1167 struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
1168
1169 bfa_trc(fcport->bfa, fcport->stats_qfull);
1170
1171 if (fcport->stats_qfull) {
1172 bfa_reqq_wcancel(&fcport->stats_reqq_wait);
1173 fcport->stats_qfull = BFA_FALSE;
1174 }
1175
1176 fcport->stats_status = BFA_STATUS_ETIMER;
1177 bfa_cb_queue(fcport->bfa, &fcport->hcb_qe, __bfa_cb_fcport_stats_get,
1178 fcport);
1179}
1180
1181static void
1182bfa_fcport_send_stats_get(void *cbarg)
1183{
1184 struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
1185 struct bfi_fcport_req_s *msg;
1186
1187 msg = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
1188
1189 if (!msg) {
1190 fcport->stats_qfull = BFA_TRUE;
1191 bfa_reqq_winit(&fcport->stats_reqq_wait,
1192 bfa_fcport_send_stats_get, fcport);
1193 bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
1194 &fcport->stats_reqq_wait);
1195 return;
1196 }
1197 fcport->stats_qfull = BFA_FALSE;
1198
1199 bfa_os_memset(msg, 0, sizeof(struct bfi_fcport_req_s));
1200 bfi_h2i_set(msg->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_STATS_GET_REQ,
1201 bfa_lpuid(fcport->bfa));
1202 bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT);
1203}
1204
1205static void
1206__bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete)
1207{
1208 struct bfa_fcport_s *fcport = cbarg;
1209
1210 if (complete) {
1211 struct bfa_timeval_s tv;
1212
1213 /**
1214 * re-initialize time stamp for stats reset
1215 */
1216 bfa_os_gettimeofday(&tv);
1217 fcport->stats_reset_time = tv.tv_sec;
1218
1219 fcport->stats_cbfn(fcport->stats_cbarg, fcport->stats_status);
1220 } else {
1221 fcport->stats_busy = BFA_FALSE;
1222 fcport->stats_status = BFA_STATUS_OK;
1223 }
1224}
1225
1226static void
1227bfa_fcport_stats_clr_timeout(void *cbarg)
1228{
1229 struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
1230
1231 bfa_trc(fcport->bfa, fcport->stats_qfull);
1232
1233 if (fcport->stats_qfull) {
1234 bfa_reqq_wcancel(&fcport->stats_reqq_wait);
1235 fcport->stats_qfull = BFA_FALSE;
1236 }
1237
1238 fcport->stats_status = BFA_STATUS_ETIMER;
1239 bfa_cb_queue(fcport->bfa, &fcport->hcb_qe,
1240 __bfa_cb_fcport_stats_clr, fcport);
1241}
1242
1243static void
1244bfa_fcport_send_stats_clear(void *cbarg)
1245{
1246 struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
1247 struct bfi_fcport_req_s *msg;
1248
1249 msg = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
1250
1251 if (!msg) {
1252 fcport->stats_qfull = BFA_TRUE;
1253 bfa_reqq_winit(&fcport->stats_reqq_wait,
1254 bfa_fcport_send_stats_clear, fcport);
1255 bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
1256 &fcport->stats_reqq_wait);
1257 return;
1258 }
1259 fcport->stats_qfull = BFA_FALSE;
1260
1261 bfa_os_memset(msg, 0, sizeof(struct bfi_fcport_req_s));
1262 bfi_h2i_set(msg->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_STATS_CLEAR_REQ,
1263 bfa_lpuid(fcport->bfa));
1264 bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT);
1265}
1266
1267/**
1268 * bfa_pport_public
1269 */
1270
1271/**
1272 * Called to initialize port attributes
1273 */
1274void
1275bfa_fcport_init(struct bfa_s *bfa)
1276{
1277 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1278
1279 /**
1280 * Initialize port attributes from IOC hardware data.
1281 */
1282 bfa_fcport_set_wwns(fcport);
1283 if (fcport->cfg.maxfrsize == 0)
1284 fcport->cfg.maxfrsize = bfa_ioc_maxfrsize(&bfa->ioc);
1285 fcport->cfg.rx_bbcredit = bfa_ioc_rx_bbcredit(&bfa->ioc);
1286 fcport->speed_sup = bfa_ioc_speed_sup(&bfa->ioc);
1287
1288 bfa_assert(fcport->cfg.maxfrsize);
1289 bfa_assert(fcport->cfg.rx_bbcredit);
1290 bfa_assert(fcport->speed_sup);
1291}
1292
1293
1294/**
1295 * Firmware message handler.
1296 */
1297void
1298bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
1299{
1300 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1301 union bfi_fcport_i2h_msg_u i2hmsg;
1302
1303 i2hmsg.msg = msg;
1304 fcport->event_arg.i2hmsg = i2hmsg;
1305
1306 switch (msg->mhdr.msg_id) {
1307 case BFI_FCPORT_I2H_ENABLE_RSP:
1308 if (fcport->msgtag == i2hmsg.penable_rsp->msgtag)
1309 bfa_sm_send_event(fcport, BFA_FCPORT_SM_FWRSP);
1310 break;
1311
1312 case BFI_FCPORT_I2H_DISABLE_RSP:
1313 if (fcport->msgtag == i2hmsg.pdisable_rsp->msgtag)
1314 bfa_sm_send_event(fcport, BFA_FCPORT_SM_FWRSP);
1315 break;
1316
1317 case BFI_FCPORT_I2H_EVENT:
1318 switch (i2hmsg.event->link_state.linkstate) {
1319 case BFA_PPORT_LINKUP:
1320 bfa_sm_send_event(fcport, BFA_FCPORT_SM_LINKUP);
1321 break;
1322 case BFA_PPORT_LINKDOWN:
1323 bfa_sm_send_event(fcport, BFA_FCPORT_SM_LINKDOWN);
1324 break;
1325 case BFA_PPORT_TRUNK_LINKDOWN:
1326 /** todo: event notification */
1327 break;
1328 }
1329 break;
1330
1331 case BFI_FCPORT_I2H_STATS_GET_RSP:
1332 /*
1333 * check for timer pop before processing the rsp
1334 */
1335 if (fcport->stats_busy == BFA_FALSE ||
1336 fcport->stats_status == BFA_STATUS_ETIMER)
1337 break;
1338
1339 bfa_timer_stop(&fcport->timer);
1340 fcport->stats_status = i2hmsg.pstatsget_rsp->status;
1341 bfa_cb_queue(fcport->bfa, &fcport->hcb_qe,
1342 __bfa_cb_fcport_stats_get, fcport);
1343 break;
1344
1345 case BFI_FCPORT_I2H_STATS_CLEAR_RSP:
1346 /*
1347 * check for timer pop before processing the rsp
1348 */
1349 if (fcport->stats_busy == BFA_FALSE ||
1350 fcport->stats_status == BFA_STATUS_ETIMER)
1351 break;
1352
1353 bfa_timer_stop(&fcport->timer);
1354 fcport->stats_status = BFA_STATUS_OK;
1355 bfa_cb_queue(fcport->bfa, &fcport->hcb_qe,
1356 __bfa_cb_fcport_stats_clr, fcport);
1357 break;
1358
1359 default:
1360 bfa_assert(0);
1361 break;
1362 }
1363}
1364
1365/**
1366 * bfa_pport_api
1367 */
1368
1369/**
1370 * Registered callback for port events.
1371 */
1372void
1373bfa_fcport_event_register(struct bfa_s *bfa,
1374 void (*cbfn) (void *cbarg, bfa_pport_event_t event),
1375 void *cbarg)
1376{
1377 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1378
1379 fcport->event_cbfn = cbfn;
1380 fcport->event_cbarg = cbarg;
1381}
1382
1383bfa_status_t
1384bfa_fcport_enable(struct bfa_s *bfa)
1385{
1386 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1387 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
1388 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
1389
1390 /* if port is PBC disabled, return error */
1391 if (cfgrsp->pbc_cfg.port_enabled == BFI_PBC_PORT_DISABLED) {
1392 bfa_trc(bfa, fcport->pwwn);
1393 return BFA_STATUS_PBC;
1394 }
1395
1396 if (bfa_ioc_is_disabled(&bfa->ioc))
1397 return BFA_STATUS_IOC_DISABLED;
1398
1399 if (fcport->diag_busy)
1400 return BFA_STATUS_DIAG_BUSY;
1401 else if (bfa_sm_cmp_state
1402 (BFA_FCPORT_MOD(bfa), bfa_fcport_sm_disabling_qwait))
1403 return BFA_STATUS_DEVBUSY;
1404
1405 bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_ENABLE);
1406 return BFA_STATUS_OK;
1407}
1408
1409bfa_status_t
1410bfa_fcport_disable(struct bfa_s *bfa)
1411{
1412 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1413 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
1414 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
1415
1416 /* if port is PBC disabled, return error */
1417 if (cfgrsp->pbc_cfg.port_enabled == BFI_PBC_PORT_DISABLED) {
1418 bfa_trc(bfa, fcport->pwwn);
1419 return BFA_STATUS_PBC;
1420 }
1421
1422 bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_DISABLE);
1423 return BFA_STATUS_OK;
1424}
1425
1426/**
1427 * Configure port speed.
1428 */
1429bfa_status_t
1430bfa_fcport_cfg_speed(struct bfa_s *bfa, enum bfa_pport_speed speed)
1431{
1432 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1433
1434 bfa_trc(bfa, speed);
1435
1436 if ((speed != BFA_PPORT_SPEED_AUTO) && (speed > fcport->speed_sup)) {
1437 bfa_trc(bfa, fcport->speed_sup);
1438 return BFA_STATUS_UNSUPP_SPEED;
1439 }
1440
1441 fcport->cfg.speed = speed;
1442
1443 return BFA_STATUS_OK;
1444}
1445
1446/**
1447 * Get current speed.
1448 */
1449enum bfa_pport_speed
1450bfa_fcport_get_speed(struct bfa_s *bfa)
1451{
1452 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1453
1454 return fcport->speed;
1455}
1456
1457/**
1458 * Configure port topology.
1459 */
1460bfa_status_t
1461bfa_fcport_cfg_topology(struct bfa_s *bfa, enum bfa_pport_topology topology)
1462{
1463 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1464
1465 bfa_trc(bfa, topology);
1466 bfa_trc(bfa, fcport->cfg.topology);
1467
1468 switch (topology) {
1469 case BFA_PPORT_TOPOLOGY_P2P:
1470 case BFA_PPORT_TOPOLOGY_LOOP:
1471 case BFA_PPORT_TOPOLOGY_AUTO:
1472 break;
1473
1474 default:
1475 return BFA_STATUS_EINVAL;
1476 }
1477
1478 fcport->cfg.topology = topology;
1479 return BFA_STATUS_OK;
1480}
1481
1482/**
1483 * Get current topology.
1484 */
1485enum bfa_pport_topology
1486bfa_fcport_get_topology(struct bfa_s *bfa)
1487{
1488 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1489
1490 return fcport->topology;
1491}
1492
1493bfa_status_t
1494bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa)
1495{
1496 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1497
1498 bfa_trc(bfa, alpa);
1499 bfa_trc(bfa, fcport->cfg.cfg_hardalpa);
1500 bfa_trc(bfa, fcport->cfg.hardalpa);
1501
1502 fcport->cfg.cfg_hardalpa = BFA_TRUE;
1503 fcport->cfg.hardalpa = alpa;
1504
1505 return BFA_STATUS_OK;
1506}
1507
1508bfa_status_t
1509bfa_fcport_clr_hardalpa(struct bfa_s *bfa)
1510{
1511 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1512
1513 bfa_trc(bfa, fcport->cfg.cfg_hardalpa);
1514 bfa_trc(bfa, fcport->cfg.hardalpa);
1515
1516 fcport->cfg.cfg_hardalpa = BFA_FALSE;
1517 return BFA_STATUS_OK;
1518}
1519
1520bfa_boolean_t
1521bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa)
1522{
1523 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1524
1525 *alpa = fcport->cfg.hardalpa;
1526 return fcport->cfg.cfg_hardalpa;
1527}
1528
1529u8
1530bfa_fcport_get_myalpa(struct bfa_s *bfa)
1531{
1532 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1533
1534 return fcport->myalpa;
1535}
1536
1537bfa_status_t
1538bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxfrsize)
1539{
1540 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1541
1542 bfa_trc(bfa, maxfrsize);
1543 bfa_trc(bfa, fcport->cfg.maxfrsize);
1544
1545 /*
1546 * with in range
1547 */
1548 if ((maxfrsize > FC_MAX_PDUSZ) || (maxfrsize < FC_MIN_PDUSZ))
1549 return BFA_STATUS_INVLD_DFSZ;
1550
1551 /*
1552 * power of 2, if not the max frame size of 2112
1553 */
1554 if ((maxfrsize != FC_MAX_PDUSZ) && (maxfrsize & (maxfrsize - 1)))
1555 return BFA_STATUS_INVLD_DFSZ;
1556
1557 fcport->cfg.maxfrsize = maxfrsize;
1558 return BFA_STATUS_OK;
1559}
1560
1561u16
1562bfa_fcport_get_maxfrsize(struct bfa_s *bfa)
1563{
1564 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1565
1566 return fcport->cfg.maxfrsize;
1567}
1568
1569u32
1570bfa_fcport_mypid(struct bfa_s *bfa)
1571{
1572 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1573
1574 return fcport->mypid;
1575}
1576
1577u8
1578bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa)
1579{
1580 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1581
1582 return fcport->cfg.rx_bbcredit;
1583}
1584
1585void
1586bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit)
1587{
1588 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1589
1590 fcport->cfg.tx_bbcredit = (u8) tx_bbcredit;
1591 bfa_fcport_send_txcredit(fcport);
1592}
1593
1594/**
1595 * Get port attributes.
1596 */
1597
1598wwn_t
1599bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node)
1600{
1601 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1602 if (node)
1603 return fcport->nwwn;
1604 else
1605 return fcport->pwwn;
1606}
1607
1608void
1609bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_pport_attr_s *attr)
1610{
1611 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1612 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
1613 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
1614
1615 bfa_os_memset(attr, 0, sizeof(struct bfa_pport_attr_s));
1616
1617 attr->nwwn = fcport->nwwn;
1618 attr->pwwn = fcport->pwwn;
1619
1620 attr->factorypwwn = bfa_ioc_get_mfg_pwwn(&bfa->ioc);
1621 attr->factorynwwn = bfa_ioc_get_mfg_nwwn(&bfa->ioc);
1622
1623 bfa_os_memcpy(&attr->pport_cfg, &fcport->cfg,
1624 sizeof(struct bfa_pport_cfg_s));
1625 /*
1626 * speed attributes
1627 */
1628 attr->pport_cfg.speed = fcport->cfg.speed;
1629 attr->speed_supported = fcport->speed_sup;
1630 attr->speed = fcport->speed;
1631 attr->cos_supported = FC_CLASS_3;
1632
1633 /*
1634 * topology attributes
1635 */
1636 attr->pport_cfg.topology = fcport->cfg.topology;
1637 attr->topology = fcport->topology;
1638
1639 /*
1640 * beacon attributes
1641 */
1642 attr->beacon = fcport->beacon;
1643 attr->link_e2e_beacon = fcport->link_e2e_beacon;
1644 attr->plog_enabled = bfa_plog_get_setting(fcport->bfa->plog);
1645
1646 attr->pport_cfg.path_tov = bfa_fcpim_path_tov_get(bfa);
1647 attr->pport_cfg.q_depth = bfa_fcpim_qdepth_get(bfa);
1648
1649 /* PBC Disabled State */
1650 if (cfgrsp->pbc_cfg.port_enabled == BFI_PBC_PORT_DISABLED)
1651 attr->port_state = BFA_PPORT_ST_PREBOOT_DISABLED;
1652 else {
1653 attr->port_state = bfa_sm_to_state(
1654 hal_pport_sm_table, fcport->sm);
1655 if (bfa_ioc_is_disabled(&fcport->bfa->ioc))
1656 attr->port_state = BFA_PPORT_ST_IOCDIS;
1657 else if (bfa_ioc_fw_mismatch(&fcport->bfa->ioc))
1658 attr->port_state = BFA_PPORT_ST_FWMISMATCH;
1659 }
1660}
1661
1662#define BFA_FCPORT_STATS_TOV 1000
1663
1664/**
1665 * Fetch port attributes (FCQoS or FCoE).
1666 */
1667bfa_status_t
1668bfa_fcport_get_stats(struct bfa_s *bfa, union bfa_fcport_stats_u *stats,
1669 bfa_cb_pport_t cbfn, void *cbarg)
1670{
1671 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1672
1673 if (fcport->stats_busy) {
1674 bfa_trc(bfa, fcport->stats_busy);
1675 return BFA_STATUS_DEVBUSY;
1676 }
1677
1678 fcport->stats_busy = BFA_TRUE;
1679 fcport->stats_ret = stats;
1680 fcport->stats_cbfn = cbfn;
1681 fcport->stats_cbarg = cbarg;
1682
1683 bfa_fcport_send_stats_get(fcport);
1684
1685 bfa_timer_start(bfa, &fcport->timer, bfa_fcport_stats_get_timeout,
1686 fcport, BFA_FCPORT_STATS_TOV);
1687 return BFA_STATUS_OK;
1688}
1689
1690/**
1691 * Reset port statistics (FCQoS or FCoE).
1692 */
1693bfa_status_t
1694bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg)
1695{
1696 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1697
1698 if (fcport->stats_busy) {
1699 bfa_trc(bfa, fcport->stats_busy);
1700 return BFA_STATUS_DEVBUSY;
1701 }
1702
1703 fcport->stats_busy = BFA_TRUE;
1704 fcport->stats_cbfn = cbfn;
1705 fcport->stats_cbarg = cbarg;
1706
1707 bfa_fcport_send_stats_clear(fcport);
1708
1709 bfa_timer_start(bfa, &fcport->timer, bfa_fcport_stats_clr_timeout,
1710 fcport, BFA_FCPORT_STATS_TOV);
1711 return BFA_STATUS_OK;
1712}
1713
1714/**
1715 * Fetch FCQoS port statistics
1716 */
1717bfa_status_t
1718bfa_fcport_get_qos_stats(struct bfa_s *bfa, union bfa_fcport_stats_u *stats,
1719 bfa_cb_pport_t cbfn, void *cbarg)
1720{
1721 /* Meaningful only for FC mode */
1722 bfa_assert(bfa_ioc_get_fcmode(&bfa->ioc));
1723
1724 return bfa_fcport_get_stats(bfa, stats, cbfn, cbarg);
1725}
1726
1727/**
1728 * Reset FCoE port statistics
1729 */
1730bfa_status_t
1731bfa_fcport_clear_qos_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg)
1732{
1733 /* Meaningful only for FC mode */
1734 bfa_assert(bfa_ioc_get_fcmode(&bfa->ioc));
1735
1736 return bfa_fcport_clear_stats(bfa, cbfn, cbarg);
1737}
1738
1739/**
1740 * Fetch FCQoS port statistics
1741 */
1742bfa_status_t
1743bfa_fcport_get_fcoe_stats(struct bfa_s *bfa, union bfa_fcport_stats_u *stats,
1744 bfa_cb_pport_t cbfn, void *cbarg)
1745{
1746 /* Meaningful only for FCoE mode */
1747 bfa_assert(!bfa_ioc_get_fcmode(&bfa->ioc));
1748
1749 return bfa_fcport_get_stats(bfa, stats, cbfn, cbarg);
1750}
1751
1752/**
1753 * Reset FCoE port statistics
1754 */
1755bfa_status_t
1756bfa_fcport_clear_fcoe_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn, void *cbarg)
1757{
1758 /* Meaningful only for FCoE mode */
1759 bfa_assert(!bfa_ioc_get_fcmode(&bfa->ioc));
1760
1761 return bfa_fcport_clear_stats(bfa, cbfn, cbarg);
1762}
1763
1764bfa_status_t
1765bfa_fcport_trunk_enable(struct bfa_s *bfa, u8 bitmap)
1766{
1767 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1768
1769 bfa_trc(bfa, bitmap);
1770 bfa_trc(bfa, fcport->cfg.trunked);
1771 bfa_trc(bfa, fcport->cfg.trunk_ports);
1772
1773 if (!bitmap || (bitmap & (bitmap - 1)))
1774 return BFA_STATUS_EINVAL;
1775
1776 fcport->cfg.trunked = BFA_TRUE;
1777 fcport->cfg.trunk_ports = bitmap;
1778
1779 return BFA_STATUS_OK;
1780}
1781
1782void
1783bfa_fcport_qos_get_attr(struct bfa_s *bfa, struct bfa_qos_attr_s *qos_attr)
1784{
1785 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1786
1787 qos_attr->state = bfa_os_ntohl(fcport->qos_attr.state);
1788 qos_attr->total_bb_cr = bfa_os_ntohl(fcport->qos_attr.total_bb_cr);
1789}
1790
1791void
1792bfa_fcport_qos_get_vc_attr(struct bfa_s *bfa,
1793 struct bfa_qos_vc_attr_s *qos_vc_attr)
1794{
1795 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1796 struct bfa_qos_vc_attr_s *bfa_vc_attr = &fcport->qos_vc_attr;
1797 u32 i = 0;
1798
1799 qos_vc_attr->total_vc_count = bfa_os_ntohs(bfa_vc_attr->total_vc_count);
1800 qos_vc_attr->shared_credit = bfa_os_ntohs(bfa_vc_attr->shared_credit);
1801 qos_vc_attr->elp_opmode_flags =
1802 bfa_os_ntohl(bfa_vc_attr->elp_opmode_flags);
1803
1804 /*
1805 * Individual VC info
1806 */
1807 while (i < qos_vc_attr->total_vc_count) {
1808 qos_vc_attr->vc_info[i].vc_credit =
1809 bfa_vc_attr->vc_info[i].vc_credit;
1810 qos_vc_attr->vc_info[i].borrow_credit =
1811 bfa_vc_attr->vc_info[i].borrow_credit;
1812 qos_vc_attr->vc_info[i].priority =
1813 bfa_vc_attr->vc_info[i].priority;
1814 ++i;
1815 }
1816}
1817
1818/**
1819 * Fetch port attributes.
1820 */
1821bfa_status_t
1822bfa_fcport_trunk_disable(struct bfa_s *bfa)
1823{
1824 return BFA_STATUS_OK;
1825}
1826
1827bfa_boolean_t
1828bfa_fcport_trunk_query(struct bfa_s *bfa, u32 *bitmap)
1829{
1830 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1831
1832 *bitmap = fcport->cfg.trunk_ports;
1833 return fcport->cfg.trunked;
1834}
1835
1836bfa_boolean_t
1837bfa_fcport_is_disabled(struct bfa_s *bfa)
1838{
1839 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1840
1841 return bfa_sm_to_state(hal_pport_sm_table, fcport->sm) ==
1842 BFA_PPORT_ST_DISABLED;
1843
1844}
1845
1846bfa_boolean_t
1847bfa_fcport_is_ratelim(struct bfa_s *bfa)
1848{
1849 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1850
1851 return fcport->cfg.ratelimit ? BFA_TRUE : BFA_FALSE;
1852
1853}
1854
1855void
1856bfa_fcport_cfg_qos(struct bfa_s *bfa, bfa_boolean_t on_off)
1857{
1858 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1859 enum bfa_ioc_type_e ioc_type = bfa_get_type(bfa);
1860
1861 bfa_trc(bfa, on_off);
1862 bfa_trc(bfa, fcport->cfg.qos_enabled);
1863
1864 bfa_trc(bfa, ioc_type);
1865
1866 if (ioc_type == BFA_IOC_TYPE_FC) {
1867 fcport->cfg.qos_enabled = on_off;
1868 /**
1869 * Notify fcpim of the change in QoS state
1870 */
1871 bfa_fcpim_update_ioredirect(bfa);
1872 }
1873}
1874
1875void
1876bfa_fcport_cfg_ratelim(struct bfa_s *bfa, bfa_boolean_t on_off)
1877{
1878 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1879
1880 bfa_trc(bfa, on_off);
1881 bfa_trc(bfa, fcport->cfg.ratelimit);
1882
1883 fcport->cfg.ratelimit = on_off;
1884 if (fcport->cfg.trl_def_speed == BFA_PPORT_SPEED_UNKNOWN)
1885 fcport->cfg.trl_def_speed = BFA_PPORT_SPEED_1GBPS;
1886}
1887
1888/**
1889 * Configure default minimum ratelim speed
1890 */
1891bfa_status_t
1892bfa_fcport_cfg_ratelim_speed(struct bfa_s *bfa, enum bfa_pport_speed speed)
1893{
1894 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1895
1896 bfa_trc(bfa, speed);
1897
1898 /*
1899 * Auto and speeds greater than the supported speed, are invalid
1900 */
1901 if ((speed == BFA_PPORT_SPEED_AUTO) || (speed > fcport->speed_sup)) {
1902 bfa_trc(bfa, fcport->speed_sup);
1903 return BFA_STATUS_UNSUPP_SPEED;
1904 }
1905
1906 fcport->cfg.trl_def_speed = speed;
1907
1908 return BFA_STATUS_OK;
1909}
1910
1911/**
1912 * Get default minimum ratelim speed
1913 */
1914enum bfa_pport_speed
1915bfa_fcport_get_ratelim_speed(struct bfa_s *bfa)
1916{
1917 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1918
1919 bfa_trc(bfa, fcport->cfg.trl_def_speed);
1920 return fcport->cfg.trl_def_speed;
1921
1922}
1923
1924void
1925bfa_fcport_busy(struct bfa_s *bfa, bfa_boolean_t status)
1926{
1927 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1928
1929 bfa_trc(bfa, status);
1930 bfa_trc(bfa, fcport->diag_busy);
1931
1932 fcport->diag_busy = status;
1933}
1934
1935void
1936bfa_fcport_beacon(struct bfa_s *bfa, bfa_boolean_t beacon,
1937 bfa_boolean_t link_e2e_beacon)
1938{
1939 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1940
1941 bfa_trc(bfa, beacon);
1942 bfa_trc(bfa, link_e2e_beacon);
1943 bfa_trc(bfa, fcport->beacon);
1944 bfa_trc(bfa, fcport->link_e2e_beacon);
1945
1946 fcport->beacon = beacon;
1947 fcport->link_e2e_beacon = link_e2e_beacon;
1948}
1949
1950bfa_boolean_t
1951bfa_fcport_is_linkup(struct bfa_s *bfa)
1952{
1953 return bfa_sm_cmp_state(BFA_FCPORT_MOD(bfa), bfa_fcport_sm_linkup);
1954}
1955
1956bfa_boolean_t
1957bfa_fcport_is_qos_enabled(struct bfa_s *bfa)
1958{
1959 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
1960
1961 return fcport->cfg.qos_enabled;
1962}
diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c
index d1a99209bf5f..9b43ca4b6778 100644
--- a/drivers/scsi/bfa/bfa_fcs.c
+++ b/drivers/scsi/bfa/bfa_fcs.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,95 +15,88 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18/** 18/*
19 * bfa_fcs.c BFA FCS main 19 * bfa_fcs.c BFA FCS main
20 */ 20 */
21 21
22#include <fcs/bfa_fcs.h>
23#include "fcs_port.h"
24#include "fcs_uf.h"
25#include "fcs_vport.h"
26#include "fcs_rport.h"
27#include "fcs_fabric.h"
28#include "fcs_fcpim.h"
29#include "fcs_fcptm.h"
30#include "fcbuild.h"
31#include "fcs.h"
32#include "bfad_drv.h" 22#include "bfad_drv.h"
33#include <fcb/bfa_fcb.h> 23#include "bfa_fcs.h"
24#include "bfa_fcbuild.h"
25
26BFA_TRC_FILE(FCS, FCS);
34 27
35/** 28/*
36 * FCS sub-modules 29 * FCS sub-modules
37 */ 30 */
38struct bfa_fcs_mod_s { 31struct bfa_fcs_mod_s {
39 void (*attach) (struct bfa_fcs_s *fcs); 32 void (*attach) (struct bfa_fcs_s *fcs);
40 void (*modinit) (struct bfa_fcs_s *fcs); 33 void (*modinit) (struct bfa_fcs_s *fcs);
41 void (*modexit) (struct bfa_fcs_s *fcs); 34 void (*modexit) (struct bfa_fcs_s *fcs);
42}; 35};
43 36
44#define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit } 37#define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
45 38
46static struct bfa_fcs_mod_s fcs_modules[] = { 39static struct bfa_fcs_mod_s fcs_modules[] = {
47 { bfa_fcs_pport_attach, NULL, NULL }, 40 { bfa_fcs_port_attach, NULL, NULL },
48 { bfa_fcs_uf_attach, NULL, NULL }, 41 { bfa_fcs_uf_attach, NULL, NULL },
49 { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit, 42 { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit,
50 bfa_fcs_fabric_modexit }, 43 bfa_fcs_fabric_modexit },
51}; 44};
52 45
53/** 46/*
54 * fcs_api BFA FCS API 47 * fcs_api BFA FCS API
55 */ 48 */
56 49
57static void 50static void
58bfa_fcs_exit_comp(void *fcs_cbarg) 51bfa_fcs_exit_comp(void *fcs_cbarg)
59{ 52{
60 struct bfa_fcs_s *fcs = fcs_cbarg; 53 struct bfa_fcs_s *fcs = fcs_cbarg;
61 struct bfad_s *bfad = fcs->bfad; 54 struct bfad_s *bfad = fcs->bfad;
62 55
63 complete(&bfad->comp); 56 complete(&bfad->comp);
64} 57}
65 58
66 59
67 60
68/** 61/*
69 * fcs_api BFA FCS API 62 * fcs_api BFA FCS API
70 */ 63 */
71 64
72/** 65/*
73 * fcs attach -- called once to initialize data structures at driver attach time 66 * fcs attach -- called once to initialize data structures at driver attach time
74 */ 67 */
75void 68void
76bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad, 69bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad,
77 bfa_boolean_t min_cfg) 70 bfa_boolean_t min_cfg)
78{ 71{
79 int i; 72 int i;
80 struct bfa_fcs_mod_s *mod; 73 struct bfa_fcs_mod_s *mod;
81 74
82 fcs->bfa = bfa; 75 fcs->bfa = bfa;
83 fcs->bfad = bfad; 76 fcs->bfad = bfad;
84 fcs->min_cfg = min_cfg; 77 fcs->min_cfg = min_cfg;
85 78
86 bfa_attach_fcs(bfa); 79 bfa->fcs = BFA_TRUE;
87 fcbuild_init(); 80 fcbuild_init();
88 81
89 for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) { 82 for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) {
90 mod = &fcs_modules[i]; 83 mod = &fcs_modules[i];
91 if (mod->attach) 84 if (mod->attach)
92 mod->attach(fcs); 85 mod->attach(fcs);
93 } 86 }
94} 87}
95 88
96/** 89/*
97 * fcs initialization, called once after bfa initialization is complete 90 * fcs initialization, called once after bfa initialization is complete
98 */ 91 */
99void 92void
100bfa_fcs_init(struct bfa_fcs_s *fcs) 93bfa_fcs_init(struct bfa_fcs_s *fcs)
101{ 94{
102 int i, npbc_vports; 95 int i, npbc_vports;
103 struct bfa_fcs_mod_s *mod; 96 struct bfa_fcs_mod_s *mod;
104 struct bfi_pbc_vport_s pbc_vports[BFI_PBC_MAX_VPORTS]; 97 struct bfi_pbc_vport_s pbc_vports[BFI_PBC_MAX_VPORTS];
105 98
106 for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) { 99 for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) {
107 mod = &fcs_modules[i]; 100 mod = &fcs_modules[i];
108 if (mod->modinit) 101 if (mod->modinit)
109 mod->modinit(fcs); 102 mod->modinit(fcs);
@@ -111,28 +104,21 @@ bfa_fcs_init(struct bfa_fcs_s *fcs)
111 /* Initialize pbc vports */ 104 /* Initialize pbc vports */
112 if (!fcs->min_cfg) { 105 if (!fcs->min_cfg) {
113 npbc_vports = 106 npbc_vports =
114 bfa_iocfc_get_pbc_vports(fcs->bfa, pbc_vports); 107 bfa_iocfc_get_pbc_vports(fcs->bfa, pbc_vports);
115 for (i = 0; i < npbc_vports; i++) 108 for (i = 0; i < npbc_vports; i++)
116 bfa_fcb_pbc_vport_create(fcs->bfa->bfad, pbc_vports[i]); 109 bfa_fcb_pbc_vport_create(fcs->bfa->bfad, pbc_vports[i]);
117 } 110 }
118} 111}
119 112
120/**
121 * Start FCS operations.
122 */
123void
124bfa_fcs_start(struct bfa_fcs_s *fcs)
125{
126 bfa_fcs_fabric_modstart(fcs);
127}
128 113
129/** 114/*
130 * FCS driver details initialization. 115 * brief
116 * FCS driver details initialization.
131 * 117 *
132 * param[in] fcs FCS instance 118 * param[in] fcs FCS instance
133 * param[in] driver_info Driver Details 119 * param[in] driver_info Driver Details
134 * 120 *
135 * return None 121 * return None
136 */ 122 */
137void 123void
138bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs, 124bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
@@ -144,38 +130,24 @@ bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
144 bfa_fcs_fabric_psymb_init(&fcs->fabric); 130 bfa_fcs_fabric_psymb_init(&fcs->fabric);
145} 131}
146 132
147/** 133/*
148 * @brief 134 * brief
149 * FCS FDMI Driver Parameter Initialization 135 * FCS instance cleanup and exit.
150 *
151 * @param[in] fcs FCS instance
152 * @param[in] fdmi_enable TRUE/FALSE
153 *
154 * @return None
155 */
156void
157bfa_fcs_set_fdmi_param(struct bfa_fcs_s *fcs, bfa_boolean_t fdmi_enable)
158{
159
160 fcs->fdmi_enabled = fdmi_enable;
161
162}
163
164/**
165 * FCS instance cleanup and exit.
166 * 136 *
167 * param[in] fcs FCS instance 137 * param[in] fcs FCS instance
168 * return None 138 * return None
169 */ 139 */
170void 140void
171bfa_fcs_exit(struct bfa_fcs_s *fcs) 141bfa_fcs_exit(struct bfa_fcs_s *fcs)
172{ 142{
173 struct bfa_fcs_mod_s *mod; 143 struct bfa_fcs_mod_s *mod;
174 int i; 144 int nmods, i;
175 145
176 bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs); 146 bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs);
177 147
178 for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) { 148 nmods = sizeof(fcs_modules) / sizeof(fcs_modules[0]);
149
150 for (i = 0; i < nmods; i++) {
179 151
180 mod = &fcs_modules[i]; 152 mod = &fcs_modules[i];
181 if (mod->modexit) { 153 if (mod->modexit) {
@@ -188,30 +160,1242 @@ bfa_fcs_exit(struct bfa_fcs_s *fcs)
188} 160}
189 161
190 162
163/*
164 * Fabric module implementation.
165 */
166
167#define BFA_FCS_FABRIC_RETRY_DELAY (2000) /* Milliseconds */
168#define BFA_FCS_FABRIC_CLEANUP_DELAY (10000) /* Milliseconds */
169
170#define bfa_fcs_fabric_set_opertype(__fabric) do { \
171 if (bfa_fcport_get_topology((__fabric)->fcs->bfa) \
172 == BFA_PORT_TOPOLOGY_P2P) \
173 (__fabric)->oper_type = BFA_PORT_TYPE_NPORT; \
174 else \
175 (__fabric)->oper_type = BFA_PORT_TYPE_NLPORT; \
176} while (0)
177
178/*
179 * forward declarations
180 */
181static void bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric);
182static void bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric);
183static void bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric);
184static void bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric);
185static void bfa_fcs_fabric_delay(void *cbarg);
186static void bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric);
187static void bfa_fcs_fabric_delete_comp(void *cbarg);
188static void bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric,
189 struct fchs_s *fchs, u16 len);
190static void bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric,
191 struct fchs_s *fchs, u16 len);
192static void bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric);
193static void bfa_fcs_fabric_flogiacc_comp(void *fcsarg,
194 struct bfa_fcxp_s *fcxp, void *cbarg,
195 bfa_status_t status,
196 u32 rsp_len,
197 u32 resid_len,
198 struct fchs_s *rspfchs);
199
200static void bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric,
201 enum bfa_fcs_fabric_event event);
202static void bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric,
203 enum bfa_fcs_fabric_event event);
204static void bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric,
205 enum bfa_fcs_fabric_event event);
206static void bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
207 enum bfa_fcs_fabric_event event);
208static void bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric,
209 enum bfa_fcs_fabric_event event);
210static void bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric,
211 enum bfa_fcs_fabric_event event);
212static void bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
213 enum bfa_fcs_fabric_event event);
214static void bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric,
215 enum bfa_fcs_fabric_event event);
216static void bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric,
217 enum bfa_fcs_fabric_event event);
218static void bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric,
219 enum bfa_fcs_fabric_event event);
220static void bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric,
221 enum bfa_fcs_fabric_event event);
222/*
223 * Beginning state before fabric creation.
224 */
225static void
226bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric,
227 enum bfa_fcs_fabric_event event)
228{
229 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
230 bfa_trc(fabric->fcs, event);
231
232 switch (event) {
233 case BFA_FCS_FABRIC_SM_CREATE:
234 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created);
235 bfa_fcs_fabric_init(fabric);
236 bfa_fcs_lport_init(&fabric->bport, &fabric->bport.port_cfg);
237 break;
238
239 case BFA_FCS_FABRIC_SM_LINK_UP:
240 case BFA_FCS_FABRIC_SM_LINK_DOWN:
241 break;
242
243 default:
244 bfa_sm_fault(fabric->fcs, event);
245 }
246}
247
248/*
249 * Beginning state before fabric creation.
250 */
251static void
252bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric,
253 enum bfa_fcs_fabric_event event)
254{
255 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
256 bfa_trc(fabric->fcs, event);
257
258 switch (event) {
259 case BFA_FCS_FABRIC_SM_START:
260 if (bfa_fcport_is_linkup(fabric->fcs->bfa)) {
261 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
262 bfa_fcs_fabric_login(fabric);
263 } else
264 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
265 break;
266
267 case BFA_FCS_FABRIC_SM_LINK_UP:
268 case BFA_FCS_FABRIC_SM_LINK_DOWN:
269 break;
270
271 case BFA_FCS_FABRIC_SM_DELETE:
272 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
273 bfa_wc_down(&fabric->fcs->wc);
274 break;
275
276 default:
277 bfa_sm_fault(fabric->fcs, event);
278 }
279}
280
281/*
282 * Link is down, awaiting LINK UP event from port. This is also the
283 * first state at fabric creation.
284 */
285static void
286bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric,
287 enum bfa_fcs_fabric_event event)
288{
289 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
290 bfa_trc(fabric->fcs, event);
291
292 switch (event) {
293 case BFA_FCS_FABRIC_SM_LINK_UP:
294 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
295 bfa_fcs_fabric_login(fabric);
296 break;
297
298 case BFA_FCS_FABRIC_SM_RETRY_OP:
299 break;
300
301 case BFA_FCS_FABRIC_SM_DELETE:
302 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
303 bfa_fcs_fabric_delete(fabric);
304 break;
305
306 default:
307 bfa_sm_fault(fabric->fcs, event);
308 }
309}
310
311/*
312 * FLOGI is in progress, awaiting FLOGI reply.
313 */
314static void
315bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
316 enum bfa_fcs_fabric_event event)
317{
318 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
319 bfa_trc(fabric->fcs, event);
320
321 switch (event) {
322 case BFA_FCS_FABRIC_SM_CONT_OP:
323
324 bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
325 fabric->bb_credit);
326 fabric->fab_type = BFA_FCS_FABRIC_SWITCHED;
327
328 if (fabric->auth_reqd && fabric->is_auth) {
329 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth);
330 bfa_trc(fabric->fcs, event);
331 } else {
332 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
333 bfa_fcs_fabric_notify_online(fabric);
334 }
335 break;
336
337 case BFA_FCS_FABRIC_SM_RETRY_OP:
338 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi_retry);
339 bfa_timer_start(fabric->fcs->bfa, &fabric->delay_timer,
340 bfa_fcs_fabric_delay, fabric,
341 BFA_FCS_FABRIC_RETRY_DELAY);
342 break;
343
344 case BFA_FCS_FABRIC_SM_LOOPBACK:
345 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_loopback);
346 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
347 bfa_fcs_fabric_set_opertype(fabric);
348 break;
349
350 case BFA_FCS_FABRIC_SM_NO_FABRIC:
351 fabric->fab_type = BFA_FCS_FABRIC_N2N;
352 bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
353 fabric->bb_credit);
354 bfa_fcs_fabric_notify_online(fabric);
355 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_nofabric);
356 break;
357
358 case BFA_FCS_FABRIC_SM_LINK_DOWN:
359 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
360 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
361 break;
362
363 case BFA_FCS_FABRIC_SM_DELETE:
364 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
365 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
366 bfa_fcs_fabric_delete(fabric);
367 break;
368
369 default:
370 bfa_sm_fault(fabric->fcs, event);
371 }
372}
373
374
375static void
376bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric,
377 enum bfa_fcs_fabric_event event)
378{
379 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
380 bfa_trc(fabric->fcs, event);
381
382 switch (event) {
383 case BFA_FCS_FABRIC_SM_DELAYED:
384 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
385 bfa_fcs_fabric_login(fabric);
386 break;
387
388 case BFA_FCS_FABRIC_SM_LINK_DOWN:
389 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
390 bfa_timer_stop(&fabric->delay_timer);
391 break;
392
393 case BFA_FCS_FABRIC_SM_DELETE:
394 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
395 bfa_timer_stop(&fabric->delay_timer);
396 bfa_fcs_fabric_delete(fabric);
397 break;
398
399 default:
400 bfa_sm_fault(fabric->fcs, event);
401 }
402}
403
404/*
405 * Authentication is in progress, awaiting authentication results.
406 */
407static void
408bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric,
409 enum bfa_fcs_fabric_event event)
410{
411 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
412 bfa_trc(fabric->fcs, event);
413
414 switch (event) {
415 case BFA_FCS_FABRIC_SM_AUTH_FAILED:
416 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
417 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
418 break;
419
420 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
421 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
422 bfa_fcs_fabric_notify_online(fabric);
423 break;
424
425 case BFA_FCS_FABRIC_SM_PERF_EVFP:
426 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp);
427 break;
428
429 case BFA_FCS_FABRIC_SM_LINK_DOWN:
430 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
431 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
432 break;
433
434 case BFA_FCS_FABRIC_SM_DELETE:
435 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
436 bfa_fcs_fabric_delete(fabric);
437 break;
438
439 default:
440 bfa_sm_fault(fabric->fcs, event);
441 }
442}
443
444/*
445 * Authentication failed
446 */
447void
448bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
449 enum bfa_fcs_fabric_event event)
450{
451 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
452 bfa_trc(fabric->fcs, event);
453
454 switch (event) {
455 case BFA_FCS_FABRIC_SM_LINK_DOWN:
456 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
457 bfa_fcs_fabric_notify_offline(fabric);
458 break;
459
460 case BFA_FCS_FABRIC_SM_DELETE:
461 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
462 bfa_fcs_fabric_delete(fabric);
463 break;
464
465 default:
466 bfa_sm_fault(fabric->fcs, event);
467 }
468}
469
470/*
471 * Port is in loopback mode.
472 */
473void
474bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
475 enum bfa_fcs_fabric_event event)
476{
477 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
478 bfa_trc(fabric->fcs, event);
479
480 switch (event) {
481 case BFA_FCS_FABRIC_SM_LINK_DOWN:
482 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
483 bfa_fcs_fabric_notify_offline(fabric);
484 break;
485
486 case BFA_FCS_FABRIC_SM_DELETE:
487 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
488 bfa_fcs_fabric_delete(fabric);
489 break;
490
491 default:
492 bfa_sm_fault(fabric->fcs, event);
493 }
494}
495
496/*
497 * There is no attached fabric - private loop or NPort-to-NPort topology.
498 */
499static void
500bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
501 enum bfa_fcs_fabric_event event)
502{
503 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
504 bfa_trc(fabric->fcs, event);
505
506 switch (event) {
507 case BFA_FCS_FABRIC_SM_LINK_DOWN:
508 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
509 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
510 bfa_fcs_fabric_notify_offline(fabric);
511 break;
512
513 case BFA_FCS_FABRIC_SM_DELETE:
514 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
515 bfa_fcs_fabric_delete(fabric);
516 break;
517
518 case BFA_FCS_FABRIC_SM_NO_FABRIC:
519 bfa_trc(fabric->fcs, fabric->bb_credit);
520 bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
521 fabric->bb_credit);
522 break;
523
524 default:
525 bfa_sm_fault(fabric->fcs, event);
526 }
527}
528
529/*
530 * Fabric is online - normal operating state.
531 */
532void
533bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
534 enum bfa_fcs_fabric_event event)
535{
536 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
537 bfa_trc(fabric->fcs, event);
538
539 switch (event) {
540 case BFA_FCS_FABRIC_SM_LINK_DOWN:
541 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
542 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
543 bfa_fcs_fabric_notify_offline(fabric);
544 break;
545
546 case BFA_FCS_FABRIC_SM_DELETE:
547 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
548 bfa_fcs_fabric_delete(fabric);
549 break;
550
551 case BFA_FCS_FABRIC_SM_AUTH_FAILED:
552 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
553 bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
554 break;
555
556 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
557 break;
558
559 default:
560 bfa_sm_fault(fabric->fcs, event);
561 }
562}
563
564/*
565 * Exchanging virtual fabric parameters.
566 */
567static void
568bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric,
569 enum bfa_fcs_fabric_event event)
570{
571 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
572 bfa_trc(fabric->fcs, event);
573
574 switch (event) {
575 case BFA_FCS_FABRIC_SM_CONT_OP:
576 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp_done);
577 break;
578
579 case BFA_FCS_FABRIC_SM_ISOLATE:
580 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_isolated);
581 break;
582
583 default:
584 bfa_sm_fault(fabric->fcs, event);
585 }
586}
587
588/*
589 * EVFP exchange complete and VFT tagging is enabled.
590 */
591static void
592bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric,
593 enum bfa_fcs_fabric_event event)
594{
595 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
596 bfa_trc(fabric->fcs, event);
597}
598
599/*
600 * Port is isolated after EVFP exchange due to VF_ID mismatch (N and F).
601 */
602static void
603bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric,
604 enum bfa_fcs_fabric_event event)
605{
606 struct bfad_s *bfad = (struct bfad_s *)fabric->fcs->bfad;
607 char pwwn_ptr[BFA_STRING_32];
608
609 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
610 bfa_trc(fabric->fcs, event);
611 wwn2str(pwwn_ptr, fabric->bport.port_cfg.pwwn);
612
613 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
614 "Port is isolated due to VF_ID mismatch. "
615 "PWWN: %s Port VF_ID: %04x switch port VF_ID: %04x.",
616 pwwn_ptr, fabric->fcs->port_vfid,
617 fabric->event_arg.swp_vfid);
618}
619
620/*
621 * Fabric is being deleted, awaiting vport delete completions.
622 */
623static void
624bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric,
625 enum bfa_fcs_fabric_event event)
626{
627 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
628 bfa_trc(fabric->fcs, event);
629
630 switch (event) {
631 case BFA_FCS_FABRIC_SM_DELCOMP:
632 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
633 bfa_wc_down(&fabric->fcs->wc);
634 break;
635
636 case BFA_FCS_FABRIC_SM_LINK_UP:
637 break;
638
639 case BFA_FCS_FABRIC_SM_LINK_DOWN:
640 bfa_fcs_fabric_notify_offline(fabric);
641 break;
642
643 default:
644 bfa_sm_fault(fabric->fcs, event);
645 }
646}
647
648
649
650/*
651 * fcs_fabric_private fabric private functions
652 */
653
654static void
655bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric)
656{
657 struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg;
658
659 port_cfg->roles = BFA_LPORT_ROLE_FCP_IM;
660 port_cfg->nwwn = fabric->fcs->bfa->ioc.attr->nwwn;
661 port_cfg->pwwn = fabric->fcs->bfa->ioc.attr->pwwn;
662}
663
664/*
665 * Port Symbolic Name Creation for base port.
666 */
667void
668bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)
669{
670 struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg;
671 char model[BFA_ADAPTER_MODEL_NAME_LEN] = {0};
672 struct bfa_fcs_driver_info_s *driver_info = &fabric->fcs->driver_info;
673
674 bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
675
676 /* Model name/number */
677 strncpy((char *)&port_cfg->sym_name, model,
678 BFA_FCS_PORT_SYMBNAME_MODEL_SZ);
679 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
680 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
681
682 /* Driver Version */
683 strncat((char *)&port_cfg->sym_name, (char *)driver_info->version,
684 BFA_FCS_PORT_SYMBNAME_VERSION_SZ);
685 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
686 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
687
688 /* Host machine name */
689 strncat((char *)&port_cfg->sym_name,
690 (char *)driver_info->host_machine_name,
691 BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ);
692 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
693 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
694
695 /*
696 * Host OS Info :
697 * If OS Patch Info is not there, do not truncate any bytes from the
698 * OS name string and instead copy the entire OS info string (64 bytes).
699 */
700 if (driver_info->host_os_patch[0] == '\0') {
701 strncat((char *)&port_cfg->sym_name,
702 (char *)driver_info->host_os_name,
703 BFA_FCS_OS_STR_LEN);
704 strncat((char *)&port_cfg->sym_name,
705 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
706 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
707 } else {
708 strncat((char *)&port_cfg->sym_name,
709 (char *)driver_info->host_os_name,
710 BFA_FCS_PORT_SYMBNAME_OSINFO_SZ);
711 strncat((char *)&port_cfg->sym_name,
712 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
713 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
714
715 /* Append host OS Patch Info */
716 strncat((char *)&port_cfg->sym_name,
717 (char *)driver_info->host_os_patch,
718 BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ);
719 }
720
721 /* null terminate */
722 port_cfg->sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
723}
724
725/*
726 * bfa lps login completion callback
727 */
728void
729bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status)
730{
731 struct bfa_fcs_fabric_s *fabric = uarg;
732
733 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
734 bfa_trc(fabric->fcs, status);
735
736 switch (status) {
737 case BFA_STATUS_OK:
738 fabric->stats.flogi_accepts++;
739 break;
740
741 case BFA_STATUS_INVALID_MAC:
742 /* Only for CNA */
743 fabric->stats.flogi_acc_err++;
744 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
745
746 return;
747
748 case BFA_STATUS_EPROTOCOL:
749 switch (fabric->lps->ext_status) {
750 case BFA_EPROTO_BAD_ACCEPT:
751 fabric->stats.flogi_acc_err++;
752 break;
753
754 case BFA_EPROTO_UNKNOWN_RSP:
755 fabric->stats.flogi_unknown_rsp++;
756 break;
757
758 default:
759 break;
760 }
761 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
762
763 return;
764
765 case BFA_STATUS_FABRIC_RJT:
766 fabric->stats.flogi_rejects++;
767 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
768 return;
769
770 default:
771 fabric->stats.flogi_rsp_err++;
772 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
773 return;
774 }
775
776 fabric->bb_credit = fabric->lps->pr_bbcred;
777 bfa_trc(fabric->fcs, fabric->bb_credit);
778
779 if (!(fabric->lps->brcd_switch))
780 fabric->fabric_name = fabric->lps->pr_nwwn;
781
782 /*
783 * Check port type. It should be 1 = F-port.
784 */
785 if (fabric->lps->fport) {
786 fabric->bport.pid = fabric->lps->lp_pid;
787 fabric->is_npiv = fabric->lps->npiv_en;
788 fabric->is_auth = fabric->lps->auth_req;
789 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_CONT_OP);
790 } else {
791 /*
792 * Nport-2-Nport direct attached
793 */
794 fabric->bport.port_topo.pn2n.rem_port_wwn =
795 fabric->lps->pr_pwwn;
796 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC);
797 }
798
799 bfa_trc(fabric->fcs, fabric->bport.pid);
800 bfa_trc(fabric->fcs, fabric->is_npiv);
801 bfa_trc(fabric->fcs, fabric->is_auth);
802}
803/*
804 * Allocate and send FLOGI.
805 */
806static void
807bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric)
808{
809 struct bfa_s *bfa = fabric->fcs->bfa;
810 struct bfa_lport_cfg_s *pcfg = &fabric->bport.port_cfg;
811 u8 alpa = 0;
812
813 if (bfa_fcport_get_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP)
814 alpa = bfa_fcport_get_myalpa(bfa);
815
816 bfa_lps_flogi(fabric->lps, fabric, alpa, bfa_fcport_get_maxfrsize(bfa),
817 pcfg->pwwn, pcfg->nwwn, fabric->auth_reqd);
818
819 fabric->stats.flogi_sent++;
820}
821
822static void
823bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric)
824{
825 struct bfa_fcs_vport_s *vport;
826 struct list_head *qe, *qen;
827
828 bfa_trc(fabric->fcs, fabric->fabric_name);
829
830 bfa_fcs_fabric_set_opertype(fabric);
831 fabric->stats.fabric_onlines++;
832
833 /*
834 * notify online event to base and then virtual ports
835 */
836 bfa_fcs_lport_online(&fabric->bport);
837
838 list_for_each_safe(qe, qen, &fabric->vport_q) {
839 vport = (struct bfa_fcs_vport_s *) qe;
840 bfa_fcs_vport_online(vport);
841 }
842}
843
844static void
845bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric)
846{
847 struct bfa_fcs_vport_s *vport;
848 struct list_head *qe, *qen;
849
850 bfa_trc(fabric->fcs, fabric->fabric_name);
851 fabric->stats.fabric_offlines++;
852
853 /*
854 * notify offline event first to vports and then base port.
855 */
856 list_for_each_safe(qe, qen, &fabric->vport_q) {
857 vport = (struct bfa_fcs_vport_s *) qe;
858 bfa_fcs_vport_offline(vport);
859 }
860
861 bfa_fcs_lport_offline(&fabric->bport);
862
863 fabric->fabric_name = 0;
864 fabric->fabric_ip_addr[0] = 0;
865}
866
867static void
868bfa_fcs_fabric_delay(void *cbarg)
869{
870 struct bfa_fcs_fabric_s *fabric = cbarg;
871
872 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELAYED);
873}
874
875/*
876 * Delete all vports and wait for vport delete completions.
877 */
878static void
879bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric)
880{
881 struct bfa_fcs_vport_s *vport;
882 struct list_head *qe, *qen;
883
884 list_for_each_safe(qe, qen, &fabric->vport_q) {
885 vport = (struct bfa_fcs_vport_s *) qe;
886 bfa_fcs_vport_fcs_delete(vport);
887 }
888
889 bfa_fcs_lport_delete(&fabric->bport);
890 bfa_wc_wait(&fabric->wc);
891}
892
893static void
894bfa_fcs_fabric_delete_comp(void *cbarg)
895{
896 struct bfa_fcs_fabric_s *fabric = cbarg;
897
898 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELCOMP);
899}
900
901/*
902 * fcs_fabric_public fabric public functions
903 */
904
905/*
906 * Attach time initialization.
907 */
191void 908void
192bfa_fcs_trc_init(struct bfa_fcs_s *fcs, struct bfa_trc_mod_s *trcmod) 909bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs)
910{
911 struct bfa_fcs_fabric_s *fabric;
912
913 fabric = &fcs->fabric;
914 memset(fabric, 0, sizeof(struct bfa_fcs_fabric_s));
915
916 /*
917 * Initialize base fabric.
918 */
919 fabric->fcs = fcs;
920 INIT_LIST_HEAD(&fabric->vport_q);
921 INIT_LIST_HEAD(&fabric->vf_q);
922 fabric->lps = bfa_lps_alloc(fcs->bfa);
923 WARN_ON(!fabric->lps);
924
925 /*
926 * Initialize fabric delete completion handler. Fabric deletion is
927 * complete when the last vport delete is complete.
928 */
929 bfa_wc_init(&fabric->wc, bfa_fcs_fabric_delete_comp, fabric);
930 bfa_wc_up(&fabric->wc); /* For the base port */
931
932 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
933 bfa_fcs_lport_attach(&fabric->bport, fabric->fcs, FC_VF_ID_NULL, NULL);
934}
935
936void
937bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs)
938{
939 bfa_sm_send_event(&fcs->fabric, BFA_FCS_FABRIC_SM_CREATE);
940 bfa_trc(fcs, 0);
941}
942
943/*
944 * Module cleanup
945 */
946void
947bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs)
948{
949 struct bfa_fcs_fabric_s *fabric;
950
951 bfa_trc(fcs, 0);
952
953 /*
954 * Cleanup base fabric.
955 */
956 fabric = &fcs->fabric;
957 bfa_lps_delete(fabric->lps);
958 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELETE);
959}
960
961/*
962 * Fabric module start -- kick starts FCS actions
963 */
964void
965bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs)
966{
967 struct bfa_fcs_fabric_s *fabric;
968
969 bfa_trc(fcs, 0);
970 fabric = &fcs->fabric;
971 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_START);
972}
973
974
975/*
976 * Link up notification from BFA physical port module.
977 */
978void
979bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric)
980{
981 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
982 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_UP);
983}
984
985/*
986 * Link down notification from BFA physical port module.
987 */
988void
989bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric)
990{
991 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
992 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_DOWN);
993}
994
995/*
996 * A child vport is being created in the fabric.
997 *
998 * Call from vport module at vport creation. A list of base port and vports
999 * belonging to a fabric is maintained to propagate link events.
1000 *
1001 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
1002 * param[in] vport - Vport being created.
1003 *
1004 * @return None (always succeeds)
1005 */
1006void
1007bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
1008 struct bfa_fcs_vport_s *vport)
1009{
1010 /*
1011 * - add vport to fabric's vport_q
1012 */
1013 bfa_trc(fabric->fcs, fabric->vf_id);
1014
1015 list_add_tail(&vport->qe, &fabric->vport_q);
1016 fabric->num_vports++;
1017 bfa_wc_up(&fabric->wc);
1018}
1019
1020/*
1021 * A child vport is being deleted from fabric.
1022 *
1023 * Vport is being deleted.
1024 */
1025void
1026bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
1027 struct bfa_fcs_vport_s *vport)
1028{
1029 list_del(&vport->qe);
1030 fabric->num_vports--;
1031 bfa_wc_down(&fabric->wc);
1032}
1033
1034
1035/*
1036 * Lookup for a vport within a fabric given its pwwn
1037 */
1038struct bfa_fcs_vport_s *
1039bfa_fcs_fabric_vport_lookup(struct bfa_fcs_fabric_s *fabric, wwn_t pwwn)
193{ 1040{
194 fcs->trcmod = trcmod; 1041 struct bfa_fcs_vport_s *vport;
1042 struct list_head *qe;
1043
1044 list_for_each(qe, &fabric->vport_q) {
1045 vport = (struct bfa_fcs_vport_s *) qe;
1046 if (bfa_fcs_lport_get_pwwn(&vport->lport) == pwwn)
1047 return vport;
1048 }
1049
1050 return NULL;
195} 1051}
196 1052
197 1053
1054/*
1055 * Get OUI of the attached switch.
1056 *
1057 * Note : Use of this function should be avoided as much as possible.
1058 * This function should be used only if there is any requirement
1059* to check for FOS version below 6.3.
1060 * To check if the attached fabric is a brocade fabric, use
1061 * bfa_lps_is_brcd_fabric() which works for FOS versions 6.3
1062 * or above only.
1063 */
1064
1065u16
1066bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric)
1067{
1068 wwn_t fab_nwwn;
1069 u8 *tmp;
1070 u16 oui;
1071
1072 fab_nwwn = fabric->lps->pr_nwwn;
1073
1074 tmp = (u8 *)&fab_nwwn;
1075 oui = (tmp[3] << 8) | tmp[4];
1076
1077 return oui;
1078}
1079/*
1080 * Unsolicited frame receive handling.
1081 */
198void 1082void
199bfa_fcs_log_init(struct bfa_fcs_s *fcs, struct bfa_log_mod_s *logmod) 1083bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs,
1084 u16 len)
1085{
1086 u32 pid = fchs->d_id;
1087 struct bfa_fcs_vport_s *vport;
1088 struct list_head *qe;
1089 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
1090 struct fc_logi_s *flogi = (struct fc_logi_s *) els_cmd;
1091
1092 bfa_trc(fabric->fcs, len);
1093 bfa_trc(fabric->fcs, pid);
1094
1095 /*
1096 * Look for our own FLOGI frames being looped back. This means an
1097 * external loopback cable is in place. Our own FLOGI frames are
1098 * sometimes looped back when switch port gets temporarily bypassed.
1099 */
1100 if ((pid == bfa_ntoh3b(FC_FABRIC_PORT)) &&
1101 (els_cmd->els_code == FC_ELS_FLOGI) &&
1102 (flogi->port_name == bfa_fcs_lport_get_pwwn(&fabric->bport))) {
1103 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LOOPBACK);
1104 return;
1105 }
1106
1107 /*
1108 * FLOGI/EVFP exchanges should be consumed by base fabric.
1109 */
1110 if (fchs->d_id == bfa_hton3b(FC_FABRIC_PORT)) {
1111 bfa_trc(fabric->fcs, pid);
1112 bfa_fcs_fabric_process_uf(fabric, fchs, len);
1113 return;
1114 }
1115
1116 if (fabric->bport.pid == pid) {
1117 /*
1118 * All authentication frames should be routed to auth
1119 */
1120 bfa_trc(fabric->fcs, els_cmd->els_code);
1121 if (els_cmd->els_code == FC_ELS_AUTH) {
1122 bfa_trc(fabric->fcs, els_cmd->els_code);
1123 return;
1124 }
1125
1126 bfa_trc(fabric->fcs, *(u8 *) ((u8 *) fchs));
1127 bfa_fcs_lport_uf_recv(&fabric->bport, fchs, len);
1128 return;
1129 }
1130
1131 /*
1132 * look for a matching local port ID
1133 */
1134 list_for_each(qe, &fabric->vport_q) {
1135 vport = (struct bfa_fcs_vport_s *) qe;
1136 if (vport->lport.pid == pid) {
1137 bfa_fcs_lport_uf_recv(&vport->lport, fchs, len);
1138 return;
1139 }
1140 }
1141 bfa_trc(fabric->fcs, els_cmd->els_code);
1142 bfa_fcs_lport_uf_recv(&fabric->bport, fchs, len);
1143}
1144
1145/*
1146 * Unsolicited frames to be processed by fabric.
1147 */
1148static void
1149bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs,
1150 u16 len)
1151{
1152 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
1153
1154 bfa_trc(fabric->fcs, els_cmd->els_code);
1155
1156 switch (els_cmd->els_code) {
1157 case FC_ELS_FLOGI:
1158 bfa_fcs_fabric_process_flogi(fabric, fchs, len);
1159 break;
1160
1161 default:
1162 /*
1163 * need to generate a LS_RJT
1164 */
1165 break;
1166 }
1167}
1168
1169/*
1170 * Process incoming FLOGI
1171 */
1172static void
1173bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric,
1174 struct fchs_s *fchs, u16 len)
200{ 1175{
201 fcs->logm = logmod; 1176 struct fc_logi_s *flogi = (struct fc_logi_s *) (fchs + 1);
1177 struct bfa_fcs_lport_s *bport = &fabric->bport;
1178
1179 bfa_trc(fabric->fcs, fchs->s_id);
1180
1181 fabric->stats.flogi_rcvd++;
1182 /*
1183 * Check port type. It should be 0 = n-port.
1184 */
1185 if (flogi->csp.port_type) {
1186 /*
1187 * @todo: may need to send a LS_RJT
1188 */
1189 bfa_trc(fabric->fcs, flogi->port_name);
1190 fabric->stats.flogi_rejected++;
1191 return;
1192 }
1193
1194 fabric->bb_credit = be16_to_cpu(flogi->csp.bbcred);
1195 bport->port_topo.pn2n.rem_port_wwn = flogi->port_name;
1196 bport->port_topo.pn2n.reply_oxid = fchs->ox_id;
1197
1198 /*
1199 * Send a Flogi Acc
1200 */
1201 bfa_fcs_fabric_send_flogi_acc(fabric);
1202 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC);
202} 1203}
203 1204
1205static void
1206bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric)
1207{
1208 struct bfa_lport_cfg_s *pcfg = &fabric->bport.port_cfg;
1209 struct bfa_fcs_lport_n2n_s *n2n_port = &fabric->bport.port_topo.pn2n;
1210 struct bfa_s *bfa = fabric->fcs->bfa;
1211 struct bfa_fcxp_s *fcxp;
1212 u16 reqlen;
1213 struct fchs_s fchs;
204 1214
1215 fcxp = bfa_fcs_fcxp_alloc(fabric->fcs);
1216 /*
1217 * Do not expect this failure -- expect remote node to retry
1218 */
1219 if (!fcxp)
1220 return;
1221
1222 reqlen = fc_flogi_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
1223 bfa_hton3b(FC_FABRIC_PORT),
1224 n2n_port->reply_oxid, pcfg->pwwn,
1225 pcfg->nwwn,
1226 bfa_fcport_get_maxfrsize(bfa),
1227 bfa_fcport_get_rx_bbcredit(bfa));
1228
1229 bfa_fcxp_send(fcxp, NULL, fabric->vf_id, fabric->lps->lp_tag,
1230 BFA_FALSE, FC_CLASS_3,
1231 reqlen, &fchs, bfa_fcs_fabric_flogiacc_comp, fabric,
1232 FC_MAX_PDUSZ, 0);
1233}
1234
1235/*
1236 * Flogi Acc completion callback.
1237 */
1238static void
1239bfa_fcs_fabric_flogiacc_comp(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1240 bfa_status_t status, u32 rsp_len,
1241 u32 resid_len, struct fchs_s *rspfchs)
1242{
1243 struct bfa_fcs_fabric_s *fabric = cbarg;
1244
1245 bfa_trc(fabric->fcs, status);
1246}
1247
1248/*
1249 *
1250 * @param[in] fabric - fabric
1251 * @param[in] wwn_t - new fabric name
1252 *
1253 * @return - none
1254 */
205void 1255void
206bfa_fcs_aen_init(struct bfa_fcs_s *fcs, struct bfa_aen_s *aen) 1256bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
1257 wwn_t fabric_name)
1258{
1259 struct bfad_s *bfad = (struct bfad_s *)fabric->fcs->bfad;
1260 char pwwn_ptr[BFA_STRING_32];
1261 char fwwn_ptr[BFA_STRING_32];
1262
1263 bfa_trc(fabric->fcs, fabric_name);
1264
1265 if (fabric->fabric_name == 0) {
1266 /*
1267 * With BRCD switches, we don't get Fabric Name in FLOGI.
1268 * Don't generate a fabric name change event in this case.
1269 */
1270 fabric->fabric_name = fabric_name;
1271 } else {
1272 fabric->fabric_name = fabric_name;
1273 wwn2str(pwwn_ptr, bfa_fcs_lport_get_pwwn(&fabric->bport));
1274 wwn2str(fwwn_ptr,
1275 bfa_fcs_lport_get_fabric_name(&fabric->bport));
1276 BFA_LOG(KERN_WARNING, bfad, bfa_log_level,
1277 "Base port WWN = %s Fabric WWN = %s\n",
1278 pwwn_ptr, fwwn_ptr);
1279 }
1280}
1281
1282/*
1283 * Returns FCS vf structure for a given vf_id.
1284 *
1285 * param[in] vf_id - VF_ID
1286 *
1287 * return
1288 * If lookup succeeds, retuns fcs vf object, otherwise returns NULL
1289 */
1290bfa_fcs_vf_t *
1291bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id)
207{ 1292{
208 fcs->aen = aen; 1293 bfa_trc(fcs, vf_id);
1294 if (vf_id == FC_VF_ID_NULL)
1295 return &fcs->fabric;
1296
1297 return NULL;
1298}
1299
1300/*
1301 * BFA FCS PPORT ( physical port)
1302 */
1303static void
1304bfa_fcs_port_event_handler(void *cbarg, enum bfa_port_linkstate event)
1305{
1306 struct bfa_fcs_s *fcs = cbarg;
1307
1308 bfa_trc(fcs, event);
1309
1310 switch (event) {
1311 case BFA_PORT_LINKUP:
1312 bfa_fcs_fabric_link_up(&fcs->fabric);
1313 break;
1314
1315 case BFA_PORT_LINKDOWN:
1316 bfa_fcs_fabric_link_down(&fcs->fabric);
1317 break;
1318
1319 default:
1320 WARN_ON(1);
1321 }
209} 1322}
210 1323
211void 1324void
212bfa_fcs_modexit_comp(struct bfa_fcs_s *fcs) 1325bfa_fcs_port_attach(struct bfa_fcs_s *fcs)
213{ 1326{
214 bfa_wc_down(&fcs->wc); 1327 bfa_fcport_event_register(fcs->bfa, bfa_fcs_port_event_handler, fcs);
215} 1328}
216 1329
1330/*
1331 * BFA FCS UF ( Unsolicited Frames)
1332 */
217 1333
1334/*
1335 * BFA callback for unsolicited frame receive handler.
1336 *
1337 * @param[in] cbarg callback arg for receive handler
1338 * @param[in] uf unsolicited frame descriptor
1339 *
1340 * @return None
1341 */
1342static void
1343bfa_fcs_uf_recv(void *cbarg, struct bfa_uf_s *uf)
1344{
1345 struct bfa_fcs_s *fcs = (struct bfa_fcs_s *) cbarg;
1346 struct fchs_s *fchs = bfa_uf_get_frmbuf(uf);
1347 u16 len = bfa_uf_get_frmlen(uf);
1348 struct fc_vft_s *vft;
1349 struct bfa_fcs_fabric_s *fabric;
1350
1351 /*
1352 * check for VFT header
1353 */
1354 if (fchs->routing == FC_RTG_EXT_HDR &&
1355 fchs->cat_info == FC_CAT_VFT_HDR) {
1356 bfa_stats(fcs, uf.tagged);
1357 vft = bfa_uf_get_frmbuf(uf);
1358 if (fcs->port_vfid == vft->vf_id)
1359 fabric = &fcs->fabric;
1360 else
1361 fabric = bfa_fcs_vf_lookup(fcs, (u16) vft->vf_id);
1362
1363 /*
1364 * drop frame if vfid is unknown
1365 */
1366 if (!fabric) {
1367 WARN_ON(1);
1368 bfa_stats(fcs, uf.vfid_unknown);
1369 bfa_uf_free(uf);
1370 return;
1371 }
1372
1373 /*
1374 * skip vft header
1375 */
1376 fchs = (struct fchs_s *) (vft + 1);
1377 len -= sizeof(struct fc_vft_s);
1378
1379 bfa_trc(fcs, vft->vf_id);
1380 } else {
1381 bfa_stats(fcs, uf.untagged);
1382 fabric = &fcs->fabric;
1383 }
1384
1385 bfa_trc(fcs, ((u32 *) fchs)[0]);
1386 bfa_trc(fcs, ((u32 *) fchs)[1]);
1387 bfa_trc(fcs, ((u32 *) fchs)[2]);
1388 bfa_trc(fcs, ((u32 *) fchs)[3]);
1389 bfa_trc(fcs, ((u32 *) fchs)[4]);
1390 bfa_trc(fcs, ((u32 *) fchs)[5]);
1391 bfa_trc(fcs, len);
1392
1393 bfa_fcs_fabric_uf_recv(fabric, fchs, len);
1394 bfa_uf_free(uf);
1395}
1396
1397void
1398bfa_fcs_uf_attach(struct bfa_fcs_s *fcs)
1399{
1400 bfa_uf_recv_register(fcs->bfa, bfa_fcs_uf_recv, fcs);
1401}
diff --git a/drivers/scsi/bfa/bfa_fcs.h b/drivers/scsi/bfa/bfa_fcs.h
new file mode 100644
index 000000000000..61cdce4bd913
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_fcs.h
@@ -0,0 +1,804 @@
1/*
2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef __BFA_FCS_H__
19#define __BFA_FCS_H__
20
21#include "bfa_cs.h"
22#include "bfa_defs.h"
23#include "bfa_defs_fcs.h"
24#include "bfa_modules.h"
25#include "bfa_fc.h"
26
27#define BFA_FCS_OS_STR_LEN 64
28
29/*
30 * 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 BFA_LPS_SM_SET_N2N_PID = 8, /* Set assigned PID for n2n */
42};
43
44
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)
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
65#define BFA_FCS_PID_IS_WKA(pid) ((bfa_ntoh3b(pid) > 0xFFF000) ? 1 : 0)
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;
127 __be16 reply_oxid; /* ox_id from the req flogi to be
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
214/*
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
234/*
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
257/*
258 * Get FC port ID for a logical port.
259 */
260#define bfa_fcs_lport_get_fcid(_lport) ((_lport)->pid)
261#define bfa_fcs_lport_get_pwwn(_lport) ((_lport)->port_cfg.pwwn)
262#define bfa_fcs_lport_get_nwwn(_lport) ((_lport)->port_cfg.nwwn)
263#define bfa_fcs_lport_get_psym_name(_lport) ((_lport)->port_cfg.sym_name)
264#define bfa_fcs_lport_is_initiator(_lport) \
265 ((_lport)->port_cfg.roles & BFA_LPORT_ROLE_FCP_IM)
266#define bfa_fcs_lport_get_nrports(_lport) \
267 ((_lport) ? (_lport)->num_rports : 0)
268
269static inline struct bfad_port_s *
270bfa_fcs_lport_get_drvport(struct bfa_fcs_lport_s *port)
271{
272 return port->bfad_port;
273}
274
275#define bfa_fcs_lport_get_opertype(_lport) ((_lport)->fabric->oper_type)
276#define bfa_fcs_lport_get_fabric_name(_lport) ((_lport)->fabric->fabric_name)
277#define bfa_fcs_lport_get_fabric_ipaddr(_lport) \
278 ((_lport)->fabric->fabric_ip_addr)
279
280/*
281 * bfa fcs port public functions
282 */
283
284bfa_boolean_t bfa_fcs_lport_is_online(struct bfa_fcs_lport_s *port);
285struct bfa_fcs_lport_s *bfa_fcs_get_base_port(struct bfa_fcs_s *fcs);
286void bfa_fcs_lport_get_rports(struct bfa_fcs_lport_s *port,
287 wwn_t rport_wwns[], int *nrports);
288
289wwn_t bfa_fcs_lport_get_rport(struct bfa_fcs_lport_s *port, wwn_t wwn,
290 int index, int nrports, bfa_boolean_t bwwn);
291
292struct bfa_fcs_lport_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs,
293 u16 vf_id, wwn_t lpwwn);
294
295void bfa_fcs_lport_get_info(struct bfa_fcs_lport_s *port,
296 struct bfa_lport_info_s *port_info);
297void bfa_fcs_lport_get_attr(struct bfa_fcs_lport_s *port,
298 struct bfa_lport_attr_s *port_attr);
299void bfa_fcs_lport_get_stats(struct bfa_fcs_lport_s *fcs_port,
300 struct bfa_lport_stats_s *port_stats);
301void bfa_fcs_lport_clear_stats(struct bfa_fcs_lport_s *fcs_port);
302enum bfa_port_speed bfa_fcs_lport_get_rport_max_speed(
303 struct bfa_fcs_lport_s *port);
304
305/* MS FCS routines */
306void bfa_fcs_lport_ms_init(struct bfa_fcs_lport_s *port);
307void bfa_fcs_lport_ms_offline(struct bfa_fcs_lport_s *port);
308void bfa_fcs_lport_ms_online(struct bfa_fcs_lport_s *port);
309void bfa_fcs_lport_ms_fabric_rscn(struct bfa_fcs_lport_s *port);
310
311/* FDMI FCS routines */
312void bfa_fcs_lport_fdmi_init(struct bfa_fcs_lport_ms_s *ms);
313void bfa_fcs_lport_fdmi_offline(struct bfa_fcs_lport_ms_s *ms);
314void bfa_fcs_lport_fdmi_online(struct bfa_fcs_lport_ms_s *ms);
315void bfa_fcs_lport_uf_recv(struct bfa_fcs_lport_s *lport, struct fchs_s *fchs,
316 u16 len);
317void bfa_fcs_lport_attach(struct bfa_fcs_lport_s *lport, struct bfa_fcs_s *fcs,
318 u16 vf_id, struct bfa_fcs_vport_s *vport);
319void bfa_fcs_lport_init(struct bfa_fcs_lport_s *lport,
320 struct bfa_lport_cfg_s *port_cfg);
321void bfa_fcs_lport_online(struct bfa_fcs_lport_s *port);
322void bfa_fcs_lport_offline(struct bfa_fcs_lport_s *port);
323void bfa_fcs_lport_delete(struct bfa_fcs_lport_s *port);
324struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pid(
325 struct bfa_fcs_lport_s *port, u32 pid);
326struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pwwn(
327 struct bfa_fcs_lport_s *port, wwn_t pwwn);
328struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_nwwn(
329 struct bfa_fcs_lport_s *port, wwn_t nwwn);
330void bfa_fcs_lport_add_rport(struct bfa_fcs_lport_s *port,
331 struct bfa_fcs_rport_s *rport);
332void bfa_fcs_lport_del_rport(struct bfa_fcs_lport_s *port,
333 struct bfa_fcs_rport_s *rport);
334void bfa_fcs_lport_ns_init(struct bfa_fcs_lport_s *vport);
335void bfa_fcs_lport_ns_offline(struct bfa_fcs_lport_s *vport);
336void bfa_fcs_lport_ns_online(struct bfa_fcs_lport_s *vport);
337void bfa_fcs_lport_ns_query(struct bfa_fcs_lport_s *port);
338void bfa_fcs_lport_scn_init(struct bfa_fcs_lport_s *vport);
339void bfa_fcs_lport_scn_offline(struct bfa_fcs_lport_s *vport);
340void bfa_fcs_lport_scn_online(struct bfa_fcs_lport_s *vport);
341void bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s *port,
342 struct fchs_s *rx_frame, u32 len);
343
344struct bfa_fcs_vport_s {
345 struct list_head qe; /* queue elem */
346 bfa_sm_t sm; /* state machine */
347 bfa_fcs_lport_t lport; /* logical port */
348 struct bfa_timer_s timer;
349 struct bfad_vport_s *vport_drv; /* Driver private */
350 struct bfa_vport_stats_s vport_stats; /* vport statistics */
351 struct bfa_lps_s *lps; /* Lport login service*/
352 int fdisc_retries;
353};
354
355#define bfa_fcs_vport_get_port(vport) \
356 ((struct bfa_fcs_lport_s *)(&vport->port))
357
358/*
359 * bfa fcs vport public functions
360 */
361bfa_status_t bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport,
362 struct bfa_fcs_s *fcs, u16 vf_id,
363 struct bfa_lport_cfg_s *port_cfg,
364 struct bfad_vport_s *vport_drv);
365bfa_status_t bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s *vport,
366 struct bfa_fcs_s *fcs, u16 vf_id,
367 struct bfa_lport_cfg_s *port_cfg,
368 struct bfad_vport_s *vport_drv);
369bfa_boolean_t bfa_fcs_is_pbc_vport(struct bfa_fcs_vport_s *vport);
370bfa_status_t bfa_fcs_vport_delete(struct bfa_fcs_vport_s *vport);
371bfa_status_t bfa_fcs_vport_start(struct bfa_fcs_vport_s *vport);
372bfa_status_t bfa_fcs_vport_stop(struct bfa_fcs_vport_s *vport);
373void bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport,
374 struct bfa_vport_attr_s *vport_attr);
375struct bfa_fcs_vport_s *bfa_fcs_vport_lookup(struct bfa_fcs_s *fcs,
376 u16 vf_id, wwn_t vpwwn);
377void bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s *vport);
378void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport);
379void bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport);
380void bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport);
381void bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s *vport);
382
383#define BFA_FCS_RPORT_DEF_DEL_TIMEOUT 90 /* in secs */
384#define BFA_FCS_RPORT_MAX_RETRIES (5)
385
386/*
387 * forward declarations
388 */
389struct bfad_rport_s;
390
391struct bfa_fcs_itnim_s;
392struct bfa_fcs_tin_s;
393struct bfa_fcs_iprp_s;
394
395/* Rport Features (RPF) */
396struct bfa_fcs_rpf_s {
397 bfa_sm_t sm; /* state machine */
398 struct bfa_fcs_rport_s *rport; /* parent rport */
399 struct bfa_timer_s timer; /* general purpose timer */
400 struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
401 struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
402 int rpsc_retries; /* max RPSC retry attempts */
403 enum bfa_port_speed rpsc_speed;
404 /* Current Speed from RPSC. O if RPSC fails */
405 enum bfa_port_speed assigned_speed;
406 /*
407 * Speed assigned by the user. will be used if RPSC is
408 * not supported by the rport.
409 */
410};
411
412struct bfa_fcs_rport_s {
413 struct list_head qe; /* used by port/vport */
414 struct bfa_fcs_lport_s *port; /* parent FCS port */
415 struct bfa_fcs_s *fcs; /* fcs instance */
416 struct bfad_rport_s *rp_drv; /* driver peer instance */
417 u32 pid; /* port ID of rport */
418 u16 maxfrsize; /* maximum frame size */
419 __be16 reply_oxid; /* OX_ID of inbound requests */
420 enum fc_cos fc_cos; /* FC classes of service supp */
421 bfa_boolean_t cisc; /* CISC capable device */
422 bfa_boolean_t prlo; /* processing prlo or LOGO */
423 wwn_t pwwn; /* port wwn of rport */
424 wwn_t nwwn; /* node wwn of rport */
425 struct bfa_rport_symname_s psym_name; /* port symbolic name */
426 bfa_sm_t sm; /* state machine */
427 struct bfa_timer_s timer; /* general purpose timer */
428 struct bfa_fcs_itnim_s *itnim; /* ITN initiator mode role */
429 struct bfa_fcs_tin_s *tin; /* ITN initiator mode role */
430 struct bfa_fcs_iprp_s *iprp; /* IP/FC role */
431 struct bfa_rport_s *bfa_rport; /* BFA Rport */
432 struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
433 int plogi_retries; /* max plogi retry attempts */
434 int ns_retries; /* max NS query retry attempts */
435 struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
436 struct bfa_rport_stats_s stats; /* rport stats */
437 enum bfa_rport_function scsi_function; /* Initiator/Target */
438 struct bfa_fcs_rpf_s rpf; /* Rport features module */
439};
440
441static inline struct bfa_rport_s *
442bfa_fcs_rport_get_halrport(struct bfa_fcs_rport_s *rport)
443{
444 return rport->bfa_rport;
445}
446
447/*
448 * bfa fcs rport API functions
449 */
450struct bfa_fcs_rport_s *bfa_fcs_rport_lookup(struct bfa_fcs_lport_s *port,
451 wwn_t rpwwn);
452struct bfa_fcs_rport_s *bfa_fcs_rport_lookup_by_nwwn(
453 struct bfa_fcs_lport_s *port, wwn_t rnwwn);
454void bfa_fcs_rport_set_del_timeout(u8 rport_tmo);
455
456void bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport,
457 struct fchs_s *fchs, u16 len);
458void bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport);
459
460struct bfa_fcs_rport_s *bfa_fcs_rport_create(struct bfa_fcs_lport_s *port,
461 u32 pid);
462void bfa_fcs_rport_start(struct bfa_fcs_lport_s *port, struct fchs_s *rx_fchs,
463 struct fc_logi_s *plogi_rsp);
464void bfa_fcs_rport_plogi_create(struct bfa_fcs_lport_s *port,
465 struct fchs_s *rx_fchs,
466 struct fc_logi_s *plogi);
467void bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs,
468 struct fc_logi_s *plogi);
469void bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, __be16 ox_id);
470
471void bfa_fcs_rport_itntm_ack(struct bfa_fcs_rport_s *rport);
472void bfa_fcs_rport_fcptm_offline_done(struct bfa_fcs_rport_s *rport);
473int bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport);
474struct bfa_fcs_rport_s *bfa_fcs_rport_create_by_wwn(
475 struct bfa_fcs_lport_s *port, wwn_t wwn);
476void bfa_fcs_rpf_init(struct bfa_fcs_rport_s *rport);
477void bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s *rport);
478void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport);
479
480/*
481 * forward declarations
482 */
483struct bfad_itnim_s;
484
485struct bfa_fcs_itnim_s {
486 bfa_sm_t sm; /* state machine */
487 struct bfa_fcs_rport_s *rport; /* parent remote rport */
488 struct bfad_itnim_s *itnim_drv; /* driver peer instance */
489 struct bfa_fcs_s *fcs; /* fcs instance */
490 struct bfa_timer_s timer; /* timer functions */
491 struct bfa_itnim_s *bfa_itnim; /* BFA itnim struct */
492 u32 prli_retries; /* max prli retry attempts */
493 bfa_boolean_t seq_rec; /* seq recovery support */
494 bfa_boolean_t rec_support; /* REC supported */
495 bfa_boolean_t conf_comp; /* FCP_CONF support */
496 bfa_boolean_t task_retry_id; /* task retry id supp */
497 struct bfa_fcxp_wqe_s fcxp_wqe; /* wait qelem for fcxp */
498 struct bfa_fcxp_s *fcxp; /* FCXP in use */
499 struct bfa_itnim_stats_s stats; /* itn statistics */
500};
501#define bfa_fcs_fcxp_alloc(__fcs) \
502 bfa_fcxp_alloc(NULL, (__fcs)->bfa, 0, 0, NULL, NULL, NULL, NULL)
503
504#define bfa_fcs_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, __alloc_cbarg) \
505 bfa_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, __alloc_cbarg, \
506 NULL, 0, 0, NULL, NULL, NULL, NULL)
507
508static inline struct bfad_port_s *
509bfa_fcs_itnim_get_drvport(struct bfa_fcs_itnim_s *itnim)
510{
511 return itnim->rport->port->bfad_port;
512}
513
514
515static inline struct bfa_fcs_lport_s *
516bfa_fcs_itnim_get_port(struct bfa_fcs_itnim_s *itnim)
517{
518 return itnim->rport->port;
519}
520
521
522static inline wwn_t
523bfa_fcs_itnim_get_nwwn(struct bfa_fcs_itnim_s *itnim)
524{
525 return itnim->rport->nwwn;
526}
527
528
529static inline wwn_t
530bfa_fcs_itnim_get_pwwn(struct bfa_fcs_itnim_s *itnim)
531{
532 return itnim->rport->pwwn;
533}
534
535
536static inline u32
537bfa_fcs_itnim_get_fcid(struct bfa_fcs_itnim_s *itnim)
538{
539 return itnim->rport->pid;
540}
541
542
543static inline u32
544bfa_fcs_itnim_get_maxfrsize(struct bfa_fcs_itnim_s *itnim)
545{
546 return itnim->rport->maxfrsize;
547}
548
549
550static inline enum fc_cos
551bfa_fcs_itnim_get_cos(struct bfa_fcs_itnim_s *itnim)
552{
553 return itnim->rport->fc_cos;
554}
555
556
557static inline struct bfad_itnim_s *
558bfa_fcs_itnim_get_drvitn(struct bfa_fcs_itnim_s *itnim)
559{
560 return itnim->itnim_drv;
561}
562
563
564static inline struct bfa_itnim_s *
565bfa_fcs_itnim_get_halitn(struct bfa_fcs_itnim_s *itnim)
566{
567 return itnim->bfa_itnim;
568}
569
570/*
571 * bfa fcs FCP Initiator mode API functions
572 */
573void bfa_fcs_itnim_get_attr(struct bfa_fcs_itnim_s *itnim,
574 struct bfa_itnim_attr_s *attr);
575void bfa_fcs_itnim_get_stats(struct bfa_fcs_itnim_s *itnim,
576 struct bfa_itnim_stats_s *stats);
577struct bfa_fcs_itnim_s *bfa_fcs_itnim_lookup(struct bfa_fcs_lport_s *port,
578 wwn_t rpwwn);
579bfa_status_t bfa_fcs_itnim_attr_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
580 struct bfa_itnim_attr_s *attr);
581bfa_status_t bfa_fcs_itnim_stats_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
582 struct bfa_itnim_stats_s *stats);
583bfa_status_t bfa_fcs_itnim_stats_clear(struct bfa_fcs_lport_s *port,
584 wwn_t rpwwn);
585struct bfa_fcs_itnim_s *bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport);
586void bfa_fcs_itnim_delete(struct bfa_fcs_itnim_s *itnim);
587void bfa_fcs_itnim_rport_offline(struct bfa_fcs_itnim_s *itnim);
588void bfa_fcs_itnim_rport_online(struct bfa_fcs_itnim_s *itnim);
589bfa_status_t bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim);
590void bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s *itnim);
591void bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim,
592 struct fchs_s *fchs, u16 len);
593
594#define BFA_FCS_FDMI_SUPORTED_SPEEDS (FDMI_TRANS_SPEED_1G | \
595 FDMI_TRANS_SPEED_2G | \
596 FDMI_TRANS_SPEED_4G | \
597 FDMI_TRANS_SPEED_8G)
598
599/*
600 * HBA Attribute Block : BFA internal representation. Note : Some variable
601 * sizes have been trimmed to suit BFA For Ex : Model will be "Brocade". Based
602 * on this the size has been reduced to 16 bytes from the standard's 64 bytes.
603 */
604struct bfa_fcs_fdmi_hba_attr_s {
605 wwn_t node_name;
606 u8 manufacturer[64];
607 u8 serial_num[64];
608 u8 model[16];
609 u8 model_desc[256];
610 u8 hw_version[8];
611 u8 driver_version[8];
612 u8 option_rom_ver[BFA_VERSION_LEN];
613 u8 fw_version[8];
614 u8 os_name[256];
615 __be32 max_ct_pyld;
616};
617
618/*
619 * Port Attribute Block
620 */
621struct bfa_fcs_fdmi_port_attr_s {
622 u8 supp_fc4_types[32]; /* supported FC4 types */
623 __be32 supp_speed; /* supported speed */
624 __be32 curr_speed; /* current Speed */
625 __be32 max_frm_size; /* max frame size */
626 u8 os_device_name[256]; /* OS device Name */
627 u8 host_name[256]; /* host name */
628};
629
630struct bfa_fcs_stats_s {
631 struct {
632 u32 untagged; /* untagged receive frames */
633 u32 tagged; /* tagged receive frames */
634 u32 vfid_unknown; /* VF id is unknown */
635 } uf;
636};
637
638struct bfa_fcs_driver_info_s {
639 u8 version[BFA_VERSION_LEN]; /* Driver Version */
640 u8 host_machine_name[BFA_FCS_OS_STR_LEN];
641 u8 host_os_name[BFA_FCS_OS_STR_LEN]; /* OS name and version */
642 u8 host_os_patch[BFA_FCS_OS_STR_LEN]; /* patch or service pack */
643 u8 os_device_name[BFA_FCS_OS_STR_LEN]; /* Driver Device Name */
644};
645
646struct bfa_fcs_s {
647 struct bfa_s *bfa; /* corresponding BFA bfa instance */
648 struct bfad_s *bfad; /* corresponding BDA driver instance */
649 struct bfa_trc_mod_s *trcmod; /* tracing module */
650 bfa_boolean_t vf_enabled; /* VF mode is enabled */
651 bfa_boolean_t fdmi_enabled; /* FDMI is enabled */
652 bfa_boolean_t min_cfg; /* min cfg enabled/disabled */
653 u16 port_vfid; /* port default VF ID */
654 struct bfa_fcs_driver_info_s driver_info;
655 struct bfa_fcs_fabric_s fabric; /* base fabric state machine */
656 struct bfa_fcs_stats_s stats; /* FCS statistics */
657 struct bfa_wc_s wc; /* waiting counter */
658};
659
660/*
661 * fcs_fabric_sm fabric state machine functions
662 */
663
664/*
665 * Fabric state machine events
666 */
667enum bfa_fcs_fabric_event {
668 BFA_FCS_FABRIC_SM_CREATE = 1, /* create from driver */
669 BFA_FCS_FABRIC_SM_DELETE = 2, /* delete from driver */
670 BFA_FCS_FABRIC_SM_LINK_DOWN = 3, /* link down from port */
671 BFA_FCS_FABRIC_SM_LINK_UP = 4, /* link up from port */
672 BFA_FCS_FABRIC_SM_CONT_OP = 5, /* flogi/auth continue op */
673 BFA_FCS_FABRIC_SM_RETRY_OP = 6, /* flogi/auth retry op */
674 BFA_FCS_FABRIC_SM_NO_FABRIC = 7, /* from flogi/auth */
675 BFA_FCS_FABRIC_SM_PERF_EVFP = 8, /* from flogi/auth */
676 BFA_FCS_FABRIC_SM_ISOLATE = 9, /* from EVFP processing */
677 BFA_FCS_FABRIC_SM_NO_TAGGING = 10, /* no VFT tagging from EVFP */
678 BFA_FCS_FABRIC_SM_DELAYED = 11, /* timeout delay event */
679 BFA_FCS_FABRIC_SM_AUTH_FAILED = 12, /* auth failed */
680 BFA_FCS_FABRIC_SM_AUTH_SUCCESS = 13, /* auth successful */
681 BFA_FCS_FABRIC_SM_DELCOMP = 14, /* all vports deleted event */
682 BFA_FCS_FABRIC_SM_LOOPBACK = 15, /* Received our own FLOGI */
683 BFA_FCS_FABRIC_SM_START = 16, /* from driver */
684};
685
686/*
687 * fcs_rport_sm FCS rport state machine events
688 */
689
690enum rport_event {
691 RPSM_EVENT_PLOGI_SEND = 1, /* new rport; start with PLOGI */
692 RPSM_EVENT_PLOGI_RCVD = 2, /* Inbound PLOGI from remote port */
693 RPSM_EVENT_PLOGI_COMP = 3, /* PLOGI completed to rport */
694 RPSM_EVENT_LOGO_RCVD = 4, /* LOGO from remote device */
695 RPSM_EVENT_LOGO_IMP = 5, /* implicit logo for SLER */
696 RPSM_EVENT_FCXP_SENT = 6, /* Frame from has been sent */
697 RPSM_EVENT_DELETE = 7, /* RPORT delete request */
698 RPSM_EVENT_SCN = 8, /* state change notification */
699 RPSM_EVENT_ACCEPTED = 9, /* Good response from remote device */
700 RPSM_EVENT_FAILED = 10, /* Request to rport failed. */
701 RPSM_EVENT_TIMEOUT = 11, /* Rport SM timeout event */
702 RPSM_EVENT_HCB_ONLINE = 12, /* BFA rport online callback */
703 RPSM_EVENT_HCB_OFFLINE = 13, /* BFA rport offline callback */
704 RPSM_EVENT_FC4_OFFLINE = 14, /* FC-4 offline complete */
705 RPSM_EVENT_ADDRESS_CHANGE = 15, /* Rport's PID has changed */
706 RPSM_EVENT_ADDRESS_DISC = 16, /* Need to Discover rport's PID */
707 RPSM_EVENT_PRLO_RCVD = 17, /* PRLO from remote device */
708 RPSM_EVENT_PLOGI_RETRY = 18, /* Retry PLOGI continuously */
709};
710
711/*
712 * bfa fcs API functions
713 */
714void bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa,
715 struct bfad_s *bfad,
716 bfa_boolean_t min_cfg);
717void bfa_fcs_init(struct bfa_fcs_s *fcs);
718void bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
719 struct bfa_fcs_driver_info_s *driver_info);
720void bfa_fcs_exit(struct bfa_fcs_s *fcs);
721
722/*
723 * bfa fcs vf public functions
724 */
725bfa_fcs_vf_t *bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id);
726
727/*
728 * fabric protected interface functions
729 */
730void bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs);
731void bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs);
732void bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs);
733void bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric);
734void bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric);
735void bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
736 struct bfa_fcs_vport_s *vport);
737void bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
738 struct bfa_fcs_vport_s *vport);
739struct bfa_fcs_vport_s *bfa_fcs_fabric_vport_lookup(
740 struct bfa_fcs_fabric_s *fabric, wwn_t pwwn);
741void bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs);
742void bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric,
743 struct fchs_s *fchs, u16 len);
744void bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric);
745void bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
746 wwn_t fabric_name);
747u16 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric);
748void bfa_fcs_uf_attach(struct bfa_fcs_s *fcs);
749void bfa_fcs_port_attach(struct bfa_fcs_s *fcs);
750void bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
751 enum bfa_fcs_fabric_event event);
752void bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
753 enum bfa_fcs_fabric_event event);
754void bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
755 enum bfa_fcs_fabric_event event);
756
757/*
758 * BFA FCS callback interfaces
759 */
760
761/*
762 * fcb Main fcs callbacks
763 */
764
765struct bfad_port_s;
766struct bfad_vf_s;
767struct bfad_vport_s;
768struct bfad_rport_s;
769
770/*
771 * lport callbacks
772 */
773struct bfad_port_s *bfa_fcb_lport_new(struct bfad_s *bfad,
774 struct bfa_fcs_lport_s *port,
775 enum bfa_lport_role roles,
776 struct bfad_vf_s *vf_drv,
777 struct bfad_vport_s *vp_drv);
778void bfa_fcb_lport_delete(struct bfad_s *bfad, enum bfa_lport_role roles,
779 struct bfad_vf_s *vf_drv,
780 struct bfad_vport_s *vp_drv);
781
782/*
783 * vport callbacks
784 */
785void bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s);
786
787/*
788 * rport callbacks
789 */
790bfa_status_t bfa_fcb_rport_alloc(struct bfad_s *bfad,
791 struct bfa_fcs_rport_s **rport,
792 struct bfad_rport_s **rport_drv);
793
794/*
795 * itnim callbacks
796 */
797void bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
798 struct bfad_itnim_s **itnim_drv);
799void bfa_fcb_itnim_free(struct bfad_s *bfad,
800 struct bfad_itnim_s *itnim_drv);
801void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv);
802void bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv);
803
804#endif /* __BFA_FCS_H__ */
diff --git a/drivers/scsi/bfa/fcpim.c b/drivers/scsi/bfa/bfa_fcs_fcpim.c
index 6b8976ad22fa..e7b49f4cb51f 100644
--- a/drivers/scsi/bfa/fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcs_fcpim.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,42 +15,30 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18/** 18/*
19 * fcpim.c - FCP initiator mode i-t nexus state machine 19 * fcpim.c - FCP initiator mode i-t nexus state machine
20 */ 20 */
21 21
22#include <bfa.h> 22#include "bfad_drv.h"
23#include <bfa_svc.h> 23#include "bfa_fcs.h"
24#include "fcs_fcpim.h" 24#include "bfa_fcbuild.h"
25#include "fcs_rport.h" 25#include "bfad_im.h"
26#include "fcs_lport.h"
27#include "fcs_trcmod.h"
28#include "fcs_fcxp.h"
29#include "fcs.h"
30#include <fcs/bfa_fcs_fcpim.h>
31#include <fcb/bfa_fcb_fcpim.h>
32#include <aen/bfa_aen_itnim.h>
33 26
34BFA_TRC_FILE(FCS, FCPIM); 27BFA_TRC_FILE(FCS, FCPIM);
35 28
36/* 29/*
37 * forward declarations 30 * forward declarations
38 */ 31 */
39static void bfa_fcs_itnim_timeout(void *arg); 32static void bfa_fcs_itnim_timeout(void *arg);
40static void bfa_fcs_itnim_free(struct bfa_fcs_itnim_s *itnim); 33static void bfa_fcs_itnim_free(struct bfa_fcs_itnim_s *itnim);
41static void bfa_fcs_itnim_send_prli(void *itnim_cbarg, 34static void bfa_fcs_itnim_send_prli(void *itnim_cbarg,
42 struct bfa_fcxp_s *fcxp_alloced); 35 struct bfa_fcxp_s *fcxp_alloced);
43static void bfa_fcs_itnim_prli_response(void *fcsarg, 36static void bfa_fcs_itnim_prli_response(void *fcsarg,
44 struct bfa_fcxp_s *fcxp, 37 struct bfa_fcxp_s *fcxp, void *cbarg,
45 void *cbarg, 38 bfa_status_t req_status, u32 rsp_len,
46 bfa_status_t req_status, 39 u32 resid_len, struct fchs_s *rsp_fchs);
47 u32 rsp_len, 40
48 u32 resid_len, 41/*
49 struct fchs_s *rsp_fchs);
50static void bfa_fcs_itnim_aen_post(struct bfa_fcs_itnim_s *itnim,
51 enum bfa_itnim_aen_event event);
52
53/**
54 * fcs_itnim_sm FCS itnim state machine events 42 * fcs_itnim_sm FCS itnim state machine events
55 */ 43 */
56 44
@@ -61,28 +49,28 @@ enum bfa_fcs_itnim_event {
61 BFA_FCS_ITNIM_SM_RSP_OK = 4, /* good response */ 49 BFA_FCS_ITNIM_SM_RSP_OK = 4, /* good response */
62 BFA_FCS_ITNIM_SM_RSP_ERROR = 5, /* error response */ 50 BFA_FCS_ITNIM_SM_RSP_ERROR = 5, /* error response */
63 BFA_FCS_ITNIM_SM_TIMEOUT = 6, /* delay timeout */ 51 BFA_FCS_ITNIM_SM_TIMEOUT = 6, /* delay timeout */
64 BFA_FCS_ITNIM_SM_HCB_OFFLINE = 7, /* BFA online callback */ 52 BFA_FCS_ITNIM_SM_HCB_OFFLINE = 7, /* BFA online callback */
65 BFA_FCS_ITNIM_SM_HCB_ONLINE = 8, /* BFA offline callback */ 53 BFA_FCS_ITNIM_SM_HCB_ONLINE = 8, /* BFA offline callback */
66 BFA_FCS_ITNIM_SM_INITIATOR = 9, /* rport is initiator */ 54 BFA_FCS_ITNIM_SM_INITIATOR = 9, /* rport is initiator */
67 BFA_FCS_ITNIM_SM_DELETE = 10, /* delete event from rport */ 55 BFA_FCS_ITNIM_SM_DELETE = 10, /* delete event from rport */
68 BFA_FCS_ITNIM_SM_PRLO = 11, /* delete event from rport */ 56 BFA_FCS_ITNIM_SM_PRLO = 11, /* delete event from rport */
69}; 57};
70 58
71static void bfa_fcs_itnim_sm_offline(struct bfa_fcs_itnim_s *itnim, 59static void bfa_fcs_itnim_sm_offline(struct bfa_fcs_itnim_s *itnim,
72 enum bfa_fcs_itnim_event event); 60 enum bfa_fcs_itnim_event event);
73static void bfa_fcs_itnim_sm_prli_send(struct bfa_fcs_itnim_s *itnim, 61static void bfa_fcs_itnim_sm_prli_send(struct bfa_fcs_itnim_s *itnim,
74 enum bfa_fcs_itnim_event event); 62 enum bfa_fcs_itnim_event event);
75static void bfa_fcs_itnim_sm_prli(struct bfa_fcs_itnim_s *itnim, 63static void bfa_fcs_itnim_sm_prli(struct bfa_fcs_itnim_s *itnim,
76 enum bfa_fcs_itnim_event event); 64 enum bfa_fcs_itnim_event event);
77static void bfa_fcs_itnim_sm_prli_retry(struct bfa_fcs_itnim_s *itnim, 65static void bfa_fcs_itnim_sm_prli_retry(struct bfa_fcs_itnim_s *itnim,
78 enum bfa_fcs_itnim_event event); 66 enum bfa_fcs_itnim_event event);
79static void bfa_fcs_itnim_sm_hcb_online(struct bfa_fcs_itnim_s *itnim, 67static void bfa_fcs_itnim_sm_hcb_online(struct bfa_fcs_itnim_s *itnim,
80 enum bfa_fcs_itnim_event event); 68 enum bfa_fcs_itnim_event event);
81static void bfa_fcs_itnim_sm_online(struct bfa_fcs_itnim_s *itnim, 69static void bfa_fcs_itnim_sm_online(struct bfa_fcs_itnim_s *itnim,
82 enum bfa_fcs_itnim_event event); 70 enum bfa_fcs_itnim_event event);
83static void bfa_fcs_itnim_sm_hcb_offline(struct bfa_fcs_itnim_s *itnim, 71static void bfa_fcs_itnim_sm_hcb_offline(struct bfa_fcs_itnim_s *itnim,
84 enum bfa_fcs_itnim_event event); 72 enum bfa_fcs_itnim_event event);
85static void bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s *itnim, 73static void bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s *itnim,
86 enum bfa_fcs_itnim_event event); 74 enum bfa_fcs_itnim_event event);
87 75
88static struct bfa_sm_table_s itnim_sm_table[] = { 76static struct bfa_sm_table_s itnim_sm_table[] = {
@@ -96,13 +84,13 @@ static struct bfa_sm_table_s itnim_sm_table[] = {
96 {BFA_SM(bfa_fcs_itnim_sm_initiator), BFA_ITNIM_INITIATIOR}, 84 {BFA_SM(bfa_fcs_itnim_sm_initiator), BFA_ITNIM_INITIATIOR},
97}; 85};
98 86
99/** 87/*
100 * fcs_itnim_sm FCS itnim state machine 88 * fcs_itnim_sm FCS itnim state machine
101 */ 89 */
102 90
103static void 91static void
104bfa_fcs_itnim_sm_offline(struct bfa_fcs_itnim_s *itnim, 92bfa_fcs_itnim_sm_offline(struct bfa_fcs_itnim_s *itnim,
105 enum bfa_fcs_itnim_event event) 93 enum bfa_fcs_itnim_event event)
106{ 94{
107 bfa_trc(itnim->fcs, itnim->rport->pwwn); 95 bfa_trc(itnim->fcs, itnim->rport->pwwn);
108 bfa_trc(itnim->fcs, event); 96 bfa_trc(itnim->fcs, event);
@@ -115,7 +103,7 @@ bfa_fcs_itnim_sm_offline(struct bfa_fcs_itnim_s *itnim,
115 break; 103 break;
116 104
117 case BFA_FCS_ITNIM_SM_OFFLINE: 105 case BFA_FCS_ITNIM_SM_OFFLINE:
118 bfa_fcs_rport_itnim_ack(itnim->rport); 106 bfa_sm_send_event(itnim->rport, RPSM_EVENT_FC4_OFFLINE);
119 break; 107 break;
120 108
121 case BFA_FCS_ITNIM_SM_INITIATOR: 109 case BFA_FCS_ITNIM_SM_INITIATOR:
@@ -134,7 +122,7 @@ bfa_fcs_itnim_sm_offline(struct bfa_fcs_itnim_s *itnim,
134 122
135static void 123static void
136bfa_fcs_itnim_sm_prli_send(struct bfa_fcs_itnim_s *itnim, 124bfa_fcs_itnim_sm_prli_send(struct bfa_fcs_itnim_s *itnim,
137 enum bfa_fcs_itnim_event event) 125 enum bfa_fcs_itnim_event event)
138{ 126{
139 bfa_trc(itnim->fcs, itnim->rport->pwwn); 127 bfa_trc(itnim->fcs, itnim->rport->pwwn);
140 bfa_trc(itnim->fcs, event); 128 bfa_trc(itnim->fcs, event);
@@ -152,7 +140,7 @@ bfa_fcs_itnim_sm_prli_send(struct bfa_fcs_itnim_s *itnim,
152 case BFA_FCS_ITNIM_SM_OFFLINE: 140 case BFA_FCS_ITNIM_SM_OFFLINE:
153 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline); 141 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline);
154 bfa_fcxp_walloc_cancel(itnim->fcs->bfa, &itnim->fcxp_wqe); 142 bfa_fcxp_walloc_cancel(itnim->fcs->bfa, &itnim->fcxp_wqe);
155 bfa_fcs_rport_itnim_ack(itnim->rport); 143 bfa_sm_send_event(itnim->rport, RPSM_EVENT_FC4_OFFLINE);
156 break; 144 break;
157 145
158 case BFA_FCS_ITNIM_SM_DELETE: 146 case BFA_FCS_ITNIM_SM_DELETE:
@@ -168,7 +156,7 @@ bfa_fcs_itnim_sm_prli_send(struct bfa_fcs_itnim_s *itnim,
168 156
169static void 157static void
170bfa_fcs_itnim_sm_prli(struct bfa_fcs_itnim_s *itnim, 158bfa_fcs_itnim_sm_prli(struct bfa_fcs_itnim_s *itnim,
171 enum bfa_fcs_itnim_event event) 159 enum bfa_fcs_itnim_event event)
172{ 160{
173 bfa_trc(itnim->fcs, itnim->rport->pwwn); 161 bfa_trc(itnim->fcs, itnim->rport->pwwn);
174 bfa_trc(itnim->fcs, event); 162 bfa_trc(itnim->fcs, event);
@@ -193,7 +181,7 @@ bfa_fcs_itnim_sm_prli(struct bfa_fcs_itnim_s *itnim,
193 case BFA_FCS_ITNIM_SM_OFFLINE: 181 case BFA_FCS_ITNIM_SM_OFFLINE:
194 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline); 182 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline);
195 bfa_fcxp_discard(itnim->fcxp); 183 bfa_fcxp_discard(itnim->fcxp);
196 bfa_fcs_rport_itnim_ack(itnim->rport); 184 bfa_sm_send_event(itnim->rport, RPSM_EVENT_FC4_OFFLINE);
197 break; 185 break;
198 186
199 case BFA_FCS_ITNIM_SM_INITIATOR: 187 case BFA_FCS_ITNIM_SM_INITIATOR:
@@ -229,14 +217,15 @@ bfa_fcs_itnim_sm_prli_retry(struct bfa_fcs_itnim_s *itnim,
229 } else { 217 } else {
230 /* invoke target offline */ 218 /* invoke target offline */
231 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline); 219 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline);
232 bfa_fcs_rport_logo_imp(itnim->rport); 220 bfa_sm_send_event(itnim->rport, RPSM_EVENT_LOGO_IMP);
233 } 221 }
234 break; 222 break;
235 223
224
236 case BFA_FCS_ITNIM_SM_OFFLINE: 225 case BFA_FCS_ITNIM_SM_OFFLINE:
237 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline); 226 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline);
238 bfa_timer_stop(&itnim->timer); 227 bfa_timer_stop(&itnim->timer);
239 bfa_fcs_rport_itnim_ack(itnim->rport); 228 bfa_sm_send_event(itnim->rport, RPSM_EVENT_FC4_OFFLINE);
240 break; 229 break;
241 230
242 case BFA_FCS_ITNIM_SM_INITIATOR: 231 case BFA_FCS_ITNIM_SM_INITIATOR:
@@ -259,6 +248,10 @@ static void
259bfa_fcs_itnim_sm_hcb_online(struct bfa_fcs_itnim_s *itnim, 248bfa_fcs_itnim_sm_hcb_online(struct bfa_fcs_itnim_s *itnim,
260 enum bfa_fcs_itnim_event event) 249 enum bfa_fcs_itnim_event event)
261{ 250{
251 struct bfad_s *bfad = (struct bfad_s *)itnim->fcs->bfad;
252 char lpwwn_buf[BFA_STRING_32];
253 char rpwwn_buf[BFA_STRING_32];
254
262 bfa_trc(itnim->fcs, itnim->rport->pwwn); 255 bfa_trc(itnim->fcs, itnim->rport->pwwn);
263 bfa_trc(itnim->fcs, event); 256 bfa_trc(itnim->fcs, event);
264 257
@@ -266,13 +259,17 @@ bfa_fcs_itnim_sm_hcb_online(struct bfa_fcs_itnim_s *itnim,
266 case BFA_FCS_ITNIM_SM_HCB_ONLINE: 259 case BFA_FCS_ITNIM_SM_HCB_ONLINE:
267 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_online); 260 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_online);
268 bfa_fcb_itnim_online(itnim->itnim_drv); 261 bfa_fcb_itnim_online(itnim->itnim_drv);
269 bfa_fcs_itnim_aen_post(itnim, BFA_ITNIM_AEN_ONLINE); 262 wwn2str(lpwwn_buf, bfa_fcs_lport_get_pwwn(itnim->rport->port));
263 wwn2str(rpwwn_buf, itnim->rport->pwwn);
264 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
265 "Target (WWN = %s) is online for initiator (WWN = %s)\n",
266 rpwwn_buf, lpwwn_buf);
270 break; 267 break;
271 268
272 case BFA_FCS_ITNIM_SM_OFFLINE: 269 case BFA_FCS_ITNIM_SM_OFFLINE:
273 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline); 270 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline);
274 bfa_itnim_offline(itnim->bfa_itnim); 271 bfa_itnim_offline(itnim->bfa_itnim);
275 bfa_fcs_rport_itnim_ack(itnim->rport); 272 bfa_sm_send_event(itnim->rport, RPSM_EVENT_FC4_OFFLINE);
276 break; 273 break;
277 274
278 case BFA_FCS_ITNIM_SM_DELETE: 275 case BFA_FCS_ITNIM_SM_DELETE:
@@ -287,8 +284,12 @@ bfa_fcs_itnim_sm_hcb_online(struct bfa_fcs_itnim_s *itnim,
287 284
288static void 285static void
289bfa_fcs_itnim_sm_online(struct bfa_fcs_itnim_s *itnim, 286bfa_fcs_itnim_sm_online(struct bfa_fcs_itnim_s *itnim,
290 enum bfa_fcs_itnim_event event) 287 enum bfa_fcs_itnim_event event)
291{ 288{
289 struct bfad_s *bfad = (struct bfad_s *)itnim->fcs->bfad;
290 char lpwwn_buf[BFA_STRING_32];
291 char rpwwn_buf[BFA_STRING_32];
292
292 bfa_trc(itnim->fcs, itnim->rport->pwwn); 293 bfa_trc(itnim->fcs, itnim->rport->pwwn);
293 bfa_trc(itnim->fcs, event); 294 bfa_trc(itnim->fcs, event);
294 295
@@ -297,10 +298,16 @@ bfa_fcs_itnim_sm_online(struct bfa_fcs_itnim_s *itnim,
297 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_hcb_offline); 298 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_hcb_offline);
298 bfa_fcb_itnim_offline(itnim->itnim_drv); 299 bfa_fcb_itnim_offline(itnim->itnim_drv);
299 bfa_itnim_offline(itnim->bfa_itnim); 300 bfa_itnim_offline(itnim->bfa_itnim);
300 if (bfa_fcs_port_is_online(itnim->rport->port) == BFA_TRUE) 301 wwn2str(lpwwn_buf, bfa_fcs_lport_get_pwwn(itnim->rport->port));
301 bfa_fcs_itnim_aen_post(itnim, BFA_ITNIM_AEN_DISCONNECT); 302 wwn2str(rpwwn_buf, itnim->rport->pwwn);
303 if (bfa_fcs_lport_is_online(itnim->rport->port) == BFA_TRUE)
304 BFA_LOG(KERN_ERR, bfad, bfa_log_level,
305 "Target (WWN = %s) connectivity lost for "
306 "initiator (WWN = %s)\n", rpwwn_buf, lpwwn_buf);
302 else 307 else
303 bfa_fcs_itnim_aen_post(itnim, BFA_ITNIM_AEN_OFFLINE); 308 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
309 "Target (WWN = %s) offlined by initiator (WWN = %s)\n",
310 rpwwn_buf, lpwwn_buf);
304 break; 311 break;
305 312
306 case BFA_FCS_ITNIM_SM_DELETE: 313 case BFA_FCS_ITNIM_SM_DELETE:
@@ -323,7 +330,7 @@ bfa_fcs_itnim_sm_hcb_offline(struct bfa_fcs_itnim_s *itnim,
323 switch (event) { 330 switch (event) {
324 case BFA_FCS_ITNIM_SM_HCB_OFFLINE: 331 case BFA_FCS_ITNIM_SM_HCB_OFFLINE:
325 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline); 332 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline);
326 bfa_fcs_rport_itnim_ack(itnim->rport); 333 bfa_sm_send_event(itnim->rport, RPSM_EVENT_FC4_OFFLINE);
327 break; 334 break;
328 335
329 case BFA_FCS_ITNIM_SM_DELETE: 336 case BFA_FCS_ITNIM_SM_DELETE:
@@ -343,7 +350,7 @@ bfa_fcs_itnim_sm_hcb_offline(struct bfa_fcs_itnim_s *itnim,
343 */ 350 */
344static void 351static void
345bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s *itnim, 352bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s *itnim,
346 enum bfa_fcs_itnim_event event) 353 enum bfa_fcs_itnim_event event)
347{ 354{
348 bfa_trc(itnim->fcs, itnim->rport->pwwn); 355 bfa_trc(itnim->fcs, itnim->rport->pwwn);
349 bfa_trc(itnim->fcs, event); 356 bfa_trc(itnim->fcs, event);
@@ -351,7 +358,7 @@ bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s *itnim,
351 switch (event) { 358 switch (event) {
352 case BFA_FCS_ITNIM_SM_OFFLINE: 359 case BFA_FCS_ITNIM_SM_OFFLINE:
353 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline); 360 bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline);
354 bfa_fcs_rport_itnim_ack(itnim->rport); 361 bfa_sm_send_event(itnim->rport, RPSM_EVENT_FC4_OFFLINE);
355 break; 362 break;
356 363
357 case BFA_FCS_ITNIM_SM_RSP_ERROR: 364 case BFA_FCS_ITNIM_SM_RSP_ERROR:
@@ -369,71 +376,34 @@ bfa_fcs_itnim_sm_initiator(struct bfa_fcs_itnim_s *itnim,
369 } 376 }
370} 377}
371 378
372
373
374/**
375 * itnim_private FCS ITNIM private interfaces
376 */
377
378static void
379bfa_fcs_itnim_aen_post(struct bfa_fcs_itnim_s *itnim,
380 enum bfa_itnim_aen_event event)
381{
382 struct bfa_fcs_rport_s *rport = itnim->rport;
383 union bfa_aen_data_u aen_data;
384 struct bfa_log_mod_s *logmod = rport->fcs->logm;
385 wwn_t lpwwn = bfa_fcs_port_get_pwwn(rport->port);
386 wwn_t rpwwn = rport->pwwn;
387 char lpwwn_ptr[BFA_STRING_32];
388 char rpwwn_ptr[BFA_STRING_32];
389
390 /*
391 * Don't post events for well known addresses
392 */
393 if (BFA_FCS_PID_IS_WKA(rport->pid))
394 return;
395
396 wwn2str(lpwwn_ptr, lpwwn);
397 wwn2str(rpwwn_ptr, rpwwn);
398
399 bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_ITNIM, event),
400 rpwwn_ptr, lpwwn_ptr);
401
402 aen_data.itnim.vf_id = rport->port->fabric->vf_id;
403 aen_data.itnim.ppwwn =
404 bfa_fcs_port_get_pwwn(bfa_fcs_get_base_port(itnim->fcs));
405 aen_data.itnim.lpwwn = lpwwn;
406 aen_data.itnim.rpwwn = rpwwn;
407}
408
409static void 379static void
410bfa_fcs_itnim_send_prli(void *itnim_cbarg, struct bfa_fcxp_s *fcxp_alloced) 380bfa_fcs_itnim_send_prli(void *itnim_cbarg, struct bfa_fcxp_s *fcxp_alloced)
411{ 381{
412 struct bfa_fcs_itnim_s *itnim = itnim_cbarg; 382 struct bfa_fcs_itnim_s *itnim = itnim_cbarg;
413 struct bfa_fcs_rport_s *rport = itnim->rport; 383 struct bfa_fcs_rport_s *rport = itnim->rport;
414 struct bfa_fcs_port_s *port = rport->port; 384 struct bfa_fcs_lport_s *port = rport->port;
415 struct fchs_s fchs; 385 struct fchs_s fchs;
416 struct bfa_fcxp_s *fcxp; 386 struct bfa_fcxp_s *fcxp;
417 int len; 387 int len;
418 388
419 bfa_trc(itnim->fcs, itnim->rport->pwwn); 389 bfa_trc(itnim->fcs, itnim->rport->pwwn);
420 390
421 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs); 391 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
422 if (!fcxp) { 392 if (!fcxp) {
423 itnim->stats.fcxp_alloc_wait++; 393 itnim->stats.fcxp_alloc_wait++;
424 bfa_fcxp_alloc_wait(port->fcs->bfa, &itnim->fcxp_wqe, 394 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &itnim->fcxp_wqe,
425 bfa_fcs_itnim_send_prli, itnim); 395 bfa_fcs_itnim_send_prli, itnim);
426 return; 396 return;
427 } 397 }
428 itnim->fcxp = fcxp; 398 itnim->fcxp = fcxp;
429 399
430 len = fc_prli_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), itnim->rport->pid, 400 len = fc_prli_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
431 bfa_fcs_port_get_fcid(port), 0); 401 itnim->rport->pid, bfa_fcs_lport_get_fcid(port), 0);
432 402
433 bfa_fcxp_send(fcxp, rport->bfa_rport, port->fabric->vf_id, port->lp_tag, 403 bfa_fcxp_send(fcxp, rport->bfa_rport, port->fabric->vf_id, port->lp_tag,
434 BFA_FALSE, FC_CLASS_3, len, &fchs, 404 BFA_FALSE, FC_CLASS_3, len, &fchs,
435 bfa_fcs_itnim_prli_response, (void *)itnim, FC_MAX_PDUSZ, 405 bfa_fcs_itnim_prli_response, (void *)itnim,
436 FC_ELS_TOV); 406 FC_MAX_PDUSZ, FC_ELS_TOV);
437 407
438 itnim->stats.prli_sent++; 408 itnim->stats.prli_sent++;
439 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_FRMSENT); 409 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_FRMSENT);
@@ -444,10 +414,10 @@ bfa_fcs_itnim_prli_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
444 bfa_status_t req_status, u32 rsp_len, 414 bfa_status_t req_status, u32 rsp_len,
445 u32 resid_len, struct fchs_s *rsp_fchs) 415 u32 resid_len, struct fchs_s *rsp_fchs)
446{ 416{
447 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *)cbarg; 417 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *) cbarg;
448 struct fc_els_cmd_s *els_cmd; 418 struct fc_els_cmd_s *els_cmd;
449 struct fc_prli_s *prli_resp; 419 struct fc_prli_s *prli_resp;
450 struct fc_ls_rjt_s *ls_rjt; 420 struct fc_ls_rjt_s *ls_rjt;
451 struct fc_prli_params_s *sparams; 421 struct fc_prli_params_s *sparams;
452 422
453 bfa_trc(itnim->fcs, req_status); 423 bfa_trc(itnim->fcs, req_status);
@@ -475,7 +445,7 @@ bfa_fcs_itnim_prli_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
475 if (prli_resp->parampage.servparams.initiator) { 445 if (prli_resp->parampage.servparams.initiator) {
476 bfa_trc(itnim->fcs, prli_resp->parampage.type); 446 bfa_trc(itnim->fcs, prli_resp->parampage.type);
477 itnim->rport->scsi_function = 447 itnim->rport->scsi_function =
478 BFA_RPORT_INITIATOR; 448 BFA_RPORT_INITIATOR;
479 itnim->stats.prli_rsp_acc++; 449 itnim->stats.prli_rsp_acc++;
480 bfa_sm_send_event(itnim, 450 bfa_sm_send_event(itnim,
481 BFA_FCS_ITNIM_SM_RSP_OK); 451 BFA_FCS_ITNIM_SM_RSP_OK);
@@ -488,10 +458,10 @@ bfa_fcs_itnim_prli_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
488 itnim->rport->scsi_function = BFA_RPORT_TARGET; 458 itnim->rport->scsi_function = BFA_RPORT_TARGET;
489 459
490 sparams = &prli_resp->parampage.servparams; 460 sparams = &prli_resp->parampage.servparams;
491 itnim->seq_rec = sparams->retry; 461 itnim->seq_rec = sparams->retry;
492 itnim->rec_support = sparams->rec_support; 462 itnim->rec_support = sparams->rec_support;
493 itnim->task_retry_id = sparams->task_retry_id; 463 itnim->task_retry_id = sparams->task_retry_id;
494 itnim->conf_comp = sparams->confirm; 464 itnim->conf_comp = sparams->confirm;
495 465
496 itnim->stats.prli_rsp_acc++; 466 itnim->stats.prli_rsp_acc++;
497 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_RSP_OK); 467 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_RSP_OK);
@@ -509,7 +479,7 @@ bfa_fcs_itnim_prli_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
509static void 479static void
510bfa_fcs_itnim_timeout(void *arg) 480bfa_fcs_itnim_timeout(void *arg)
511{ 481{
512 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *)arg; 482 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *) arg;
513 483
514 itnim->stats.timeout++; 484 itnim->stats.timeout++;
515 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_TIMEOUT); 485 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_TIMEOUT);
@@ -524,21 +494,21 @@ bfa_fcs_itnim_free(struct bfa_fcs_itnim_s *itnim)
524 494
525 495
526 496
527/** 497/*
528 * itnim_public FCS ITNIM public interfaces 498 * itnim_public FCS ITNIM public interfaces
529 */ 499 */
530 500
531/** 501/*
532 * Called by rport when a new rport is created. 502 * Called by rport when a new rport is created.
533 * 503 *
534 * @param[in] rport - remote port. 504 * @param[in] rport - remote port.
535 */ 505 */
536struct bfa_fcs_itnim_s * 506struct bfa_fcs_itnim_s *
537bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport) 507bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport)
538{ 508{
539 struct bfa_fcs_port_s *port = rport->port; 509 struct bfa_fcs_lport_s *port = rport->port;
540 struct bfa_fcs_itnim_s *itnim; 510 struct bfa_fcs_itnim_s *itnim;
541 struct bfad_itnim_s *itnim_drv; 511 struct bfad_itnim_s *itnim_drv;
542 struct bfa_itnim_s *bfa_itnim; 512 struct bfa_itnim_s *bfa_itnim;
543 513
544 /* 514 /*
@@ -560,19 +530,20 @@ bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport)
560 /* 530 /*
561 * call BFA to create the itnim 531 * call BFA to create the itnim
562 */ 532 */
563 bfa_itnim = bfa_itnim_create(port->fcs->bfa, rport->bfa_rport, itnim); 533 bfa_itnim =
534 bfa_itnim_create(port->fcs->bfa, rport->bfa_rport, itnim);
564 535
565 if (bfa_itnim == NULL) { 536 if (bfa_itnim == NULL) {
566 bfa_trc(port->fcs, rport->pwwn); 537 bfa_trc(port->fcs, rport->pwwn);
567 bfa_fcb_itnim_free(port->fcs->bfad, itnim_drv); 538 bfa_fcb_itnim_free(port->fcs->bfad, itnim_drv);
568 bfa_assert(0); 539 WARN_ON(1);
569 return NULL; 540 return NULL;
570 } 541 }
571 542
572 itnim->bfa_itnim = bfa_itnim; 543 itnim->bfa_itnim = bfa_itnim;
573 itnim->seq_rec = BFA_FALSE; 544 itnim->seq_rec = BFA_FALSE;
574 itnim->rec_support = BFA_FALSE; 545 itnim->rec_support = BFA_FALSE;
575 itnim->conf_comp = BFA_FALSE; 546 itnim->conf_comp = BFA_FALSE;
576 itnim->task_retry_id = BFA_FALSE; 547 itnim->task_retry_id = BFA_FALSE;
577 548
578 /* 549 /*
@@ -583,8 +554,8 @@ bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport)
583 return itnim; 554 return itnim;
584} 555}
585 556
586/** 557/*
587 * Called by rport to delete the instance of FCPIM. 558 * Called by rport to delete the instance of FCPIM.
588 * 559 *
589 * @param[in] rport - remote port. 560 * @param[in] rport - remote port.
590 */ 561 */
@@ -595,7 +566,7 @@ bfa_fcs_itnim_delete(struct bfa_fcs_itnim_s *itnim)
595 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_DELETE); 566 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_DELETE);
596} 567}
597 568
598/** 569/*
599 * Notification from rport that PLOGI is complete to initiate FC-4 session. 570 * Notification from rport that PLOGI is complete to initiate FC-4 session.
600 */ 571 */
601void 572void
@@ -607,15 +578,15 @@ bfa_fcs_itnim_rport_online(struct bfa_fcs_itnim_s *itnim)
607 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_ONLINE); 578 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_ONLINE);
608 } else { 579 } else {
609 /* 580 /*
610 * For well known addresses, we set the itnim to initiator 581 * For well known addresses, we set the itnim to initiator
611 * state 582 * state
612 */ 583 */
613 itnim->stats.initiator++; 584 itnim->stats.initiator++;
614 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_INITIATOR); 585 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_INITIATOR);
615 } 586 }
616} 587}
617 588
618/** 589/*
619 * Called by rport to handle a remote device offline. 590 * Called by rport to handle a remote device offline.
620 */ 591 */
621void 592void
@@ -625,7 +596,7 @@ bfa_fcs_itnim_rport_offline(struct bfa_fcs_itnim_s *itnim)
625 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_OFFLINE); 596 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_OFFLINE);
626} 597}
627 598
628/** 599/*
629 * Called by rport when remote port is known to be an initiator from 600 * Called by rport when remote port is known to be an initiator from
630 * PRLI received. 601 * PRLI received.
631 */ 602 */
@@ -637,7 +608,7 @@ bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s *itnim)
637 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_INITIATOR); 608 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_INITIATOR);
638} 609}
639 610
640/** 611/*
641 * Called by rport to check if the itnim is online. 612 * Called by rport to check if the itnim is online.
642 */ 613 */
643bfa_status_t 614bfa_status_t
@@ -651,60 +622,60 @@ bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim)
651 622
652 default: 623 default:
653 return BFA_STATUS_NO_FCPIM_NEXUS; 624 return BFA_STATUS_NO_FCPIM_NEXUS;
654
655 } 625 }
656} 626}
657 627
658/** 628/*
659 * BFA completion callback for bfa_itnim_online(). 629 * BFA completion callback for bfa_itnim_online().
660 */ 630 */
661void 631void
662bfa_cb_itnim_online(void *cbarg) 632bfa_cb_itnim_online(void *cbarg)
663{ 633{
664 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *)cbarg; 634 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *) cbarg;
665 635
666 bfa_trc(itnim->fcs, itnim->rport->pwwn); 636 bfa_trc(itnim->fcs, itnim->rport->pwwn);
667 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_HCB_ONLINE); 637 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_HCB_ONLINE);
668} 638}
669 639
670/** 640/*
671 * BFA completion callback for bfa_itnim_offline(). 641 * BFA completion callback for bfa_itnim_offline().
672 */ 642 */
673void 643void
674bfa_cb_itnim_offline(void *cb_arg) 644bfa_cb_itnim_offline(void *cb_arg)
675{ 645{
676 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *)cb_arg; 646 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *) cb_arg;
677 647
678 bfa_trc(itnim->fcs, itnim->rport->pwwn); 648 bfa_trc(itnim->fcs, itnim->rport->pwwn);
679 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_HCB_OFFLINE); 649 bfa_sm_send_event(itnim, BFA_FCS_ITNIM_SM_HCB_OFFLINE);
680} 650}
681 651
682/** 652/*
683 * Mark the beginning of PATH TOV handling. IO completion callbacks 653 * Mark the beginning of PATH TOV handling. IO completion callbacks
684 * are still pending. 654 * are still pending.
685 */ 655 */
686void 656void
687bfa_cb_itnim_tov_begin(void *cb_arg) 657bfa_cb_itnim_tov_begin(void *cb_arg)
688{ 658{
689 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *)cb_arg; 659 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *) cb_arg;
690 660
691 bfa_trc(itnim->fcs, itnim->rport->pwwn); 661 bfa_trc(itnim->fcs, itnim->rport->pwwn);
692} 662}
693 663
694/** 664/*
695 * Mark the end of PATH TOV handling. All pending IOs are already cleaned up. 665 * Mark the end of PATH TOV handling. All pending IOs are already cleaned up.
696 */ 666 */
697void 667void
698bfa_cb_itnim_tov(void *cb_arg) 668bfa_cb_itnim_tov(void *cb_arg)
699{ 669{
700 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *)cb_arg; 670 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *) cb_arg;
671 struct bfad_itnim_s *itnim_drv = itnim->itnim_drv;
701 672
702 bfa_trc(itnim->fcs, itnim->rport->pwwn); 673 bfa_trc(itnim->fcs, itnim->rport->pwwn);
703 bfa_fcb_itnim_tov(itnim->itnim_drv); 674 itnim_drv->state = ITNIM_STATE_TIMEOUT;
704} 675}
705 676
706/** 677/*
707 * BFA notification to FCS/driver for second level error recovery. 678 * BFA notification to FCS/driver for second level error recovery.
708 * 679 *
709 * Atleast one I/O request has timedout and target is unresponsive to 680 * Atleast one I/O request has timedout and target is unresponsive to
710 * repeated abort requests. Second level error recovery should be initiated 681 * repeated abort requests. Second level error recovery should be initiated
@@ -713,15 +684,15 @@ bfa_cb_itnim_tov(void *cb_arg)
713void 684void
714bfa_cb_itnim_sler(void *cb_arg) 685bfa_cb_itnim_sler(void *cb_arg)
715{ 686{
716 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *)cb_arg; 687 struct bfa_fcs_itnim_s *itnim = (struct bfa_fcs_itnim_s *) cb_arg;
717 688
718 itnim->stats.sler++; 689 itnim->stats.sler++;
719 bfa_trc(itnim->fcs, itnim->rport->pwwn); 690 bfa_trc(itnim->fcs, itnim->rport->pwwn);
720 bfa_fcs_rport_logo_imp(itnim->rport); 691 bfa_sm_send_event(itnim->rport, RPSM_EVENT_LOGO_IMP);
721} 692}
722 693
723struct bfa_fcs_itnim_s * 694struct bfa_fcs_itnim_s *
724bfa_fcs_itnim_lookup(struct bfa_fcs_port_s *port, wwn_t rpwwn) 695bfa_fcs_itnim_lookup(struct bfa_fcs_lport_s *port, wwn_t rpwwn)
725{ 696{
726 struct bfa_fcs_rport_s *rport; 697 struct bfa_fcs_rport_s *rport;
727 rport = bfa_fcs_rport_lookup(port, rpwwn); 698 rport = bfa_fcs_rport_lookup(port, rpwwn);
@@ -729,12 +700,12 @@ bfa_fcs_itnim_lookup(struct bfa_fcs_port_s *port, wwn_t rpwwn)
729 if (!rport) 700 if (!rport)
730 return NULL; 701 return NULL;
731 702
732 bfa_assert(rport->itnim != NULL); 703 WARN_ON(rport->itnim == NULL);
733 return rport->itnim; 704 return rport->itnim;
734} 705}
735 706
736bfa_status_t 707bfa_status_t
737bfa_fcs_itnim_attr_get(struct bfa_fcs_port_s *port, wwn_t rpwwn, 708bfa_fcs_itnim_attr_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
738 struct bfa_itnim_attr_s *attr) 709 struct bfa_itnim_attr_s *attr)
739{ 710{
740 struct bfa_fcs_itnim_s *itnim = NULL; 711 struct bfa_fcs_itnim_s *itnim = NULL;
@@ -744,55 +715,53 @@ bfa_fcs_itnim_attr_get(struct bfa_fcs_port_s *port, wwn_t rpwwn,
744 if (itnim == NULL) 715 if (itnim == NULL)
745 return BFA_STATUS_NO_FCPIM_NEXUS; 716 return BFA_STATUS_NO_FCPIM_NEXUS;
746 717
747 attr->state = bfa_sm_to_state(itnim_sm_table, itnim->sm); 718 attr->state = bfa_sm_to_state(itnim_sm_table, itnim->sm);
748 attr->retry = itnim->seq_rec; 719 attr->retry = itnim->seq_rec;
749 attr->rec_support = itnim->rec_support; 720 attr->rec_support = itnim->rec_support;
750 attr->conf_comp = itnim->conf_comp; 721 attr->conf_comp = itnim->conf_comp;
751 attr->task_retry_id = itnim->task_retry_id; 722 attr->task_retry_id = itnim->task_retry_id;
752 bfa_os_memset(&attr->io_latency, 0, sizeof(struct bfa_itnim_latency_s));
753
754 return BFA_STATUS_OK; 723 return BFA_STATUS_OK;
755} 724}
756 725
757bfa_status_t 726bfa_status_t
758bfa_fcs_itnim_stats_get(struct bfa_fcs_port_s *port, wwn_t rpwwn, 727bfa_fcs_itnim_stats_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
759 struct bfa_itnim_stats_s *stats) 728 struct bfa_itnim_stats_s *stats)
760{ 729{
761 struct bfa_fcs_itnim_s *itnim = NULL; 730 struct bfa_fcs_itnim_s *itnim = NULL;
762 731
763 bfa_assert(port != NULL); 732 WARN_ON(port == NULL);
764 733
765 itnim = bfa_fcs_itnim_lookup(port, rpwwn); 734 itnim = bfa_fcs_itnim_lookup(port, rpwwn);
766 735
767 if (itnim == NULL) 736 if (itnim == NULL)
768 return BFA_STATUS_NO_FCPIM_NEXUS; 737 return BFA_STATUS_NO_FCPIM_NEXUS;
769 738
770 bfa_os_memcpy(stats, &itnim->stats, sizeof(struct bfa_itnim_stats_s)); 739 memcpy(stats, &itnim->stats, sizeof(struct bfa_itnim_stats_s));
771 740
772 return BFA_STATUS_OK; 741 return BFA_STATUS_OK;
773} 742}
774 743
775bfa_status_t 744bfa_status_t
776bfa_fcs_itnim_stats_clear(struct bfa_fcs_port_s *port, wwn_t rpwwn) 745bfa_fcs_itnim_stats_clear(struct bfa_fcs_lport_s *port, wwn_t rpwwn)
777{ 746{
778 struct bfa_fcs_itnim_s *itnim = NULL; 747 struct bfa_fcs_itnim_s *itnim = NULL;
779 748
780 bfa_assert(port != NULL); 749 WARN_ON(port == NULL);
781 750
782 itnim = bfa_fcs_itnim_lookup(port, rpwwn); 751 itnim = bfa_fcs_itnim_lookup(port, rpwwn);
783 752
784 if (itnim == NULL) 753 if (itnim == NULL)
785 return BFA_STATUS_NO_FCPIM_NEXUS; 754 return BFA_STATUS_NO_FCPIM_NEXUS;
786 755
787 bfa_os_memset(&itnim->stats, 0, sizeof(struct bfa_itnim_stats_s)); 756 memset(&itnim->stats, 0, sizeof(struct bfa_itnim_stats_s));
788 return BFA_STATUS_OK; 757 return BFA_STATUS_OK;
789} 758}
790 759
791void 760void
792bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim, struct fchs_s *fchs, 761bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim,
793 u16 len) 762 struct fchs_s *fchs, u16 len)
794{ 763{
795 struct fc_els_cmd_s *els_cmd; 764 struct fc_els_cmd_s *els_cmd;
796 765
797 bfa_trc(itnim->fcs, fchs->type); 766 bfa_trc(itnim->fcs, fchs->type);
798 767
@@ -809,16 +778,6 @@ bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim, struct fchs_s *fchs,
809 break; 778 break;
810 779
811 default: 780 default:
812 bfa_assert(0); 781 WARN_ON(1);
813 } 782 }
814} 783}
815
816void
817bfa_fcs_itnim_pause(struct bfa_fcs_itnim_s *itnim)
818{
819}
820
821void
822bfa_fcs_itnim_resume(struct bfa_fcs_itnim_s *itnim)
823{
824}
diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
index 35df20e68a52..1d6be8c14473 100644
--- a/drivers/scsi/bfa/bfa_fcs_lport.c
+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,74 +15,60 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18/** 18#include "bfad_drv.h"
19 * bfa_fcs_port.c BFA FCS port 19#include "bfa_fcs.h"
20 */ 20#include "bfa_fcbuild.h"
21 21#include "bfa_fc.h"
22#include <fcs/bfa_fcs.h>
23#include <fcs/bfa_fcs_lport.h>
24#include <fcs/bfa_fcs_rport.h>
25#include <fcb/bfa_fcb_port.h>
26#include <bfa_svc.h>
27#include <log/bfa_log_fcs.h>
28#include "fcs.h"
29#include "fcs_lport.h"
30#include "fcs_vport.h"
31#include "fcs_rport.h"
32#include "fcs_fcxp.h"
33#include "fcs_trcmod.h"
34#include "lport_priv.h"
35#include <aen/bfa_aen_lport.h>
36 22
37BFA_TRC_FILE(FCS, PORT); 23BFA_TRC_FILE(FCS, PORT);
38 24
39/** 25static void bfa_fcs_lport_send_ls_rjt(struct bfa_fcs_lport_s *port,
40 * Forward declarations 26 struct fchs_s *rx_fchs, u8 reason_code,
41 */ 27 u8 reason_code_expl);
42 28static void bfa_fcs_lport_plogi(struct bfa_fcs_lport_s *port,
43static void bfa_fcs_port_aen_post(struct bfa_fcs_port_s *port, 29 struct fchs_s *rx_fchs, struct fc_logi_s *plogi);
44 enum bfa_lport_aen_event event); 30static void bfa_fcs_lport_online_actions(struct bfa_fcs_lport_s *port);
45static void bfa_fcs_port_send_ls_rjt(struct bfa_fcs_port_s *port, 31static void bfa_fcs_lport_offline_actions(struct bfa_fcs_lport_s *port);
46 struct fchs_s *rx_fchs, u8 reason_code, 32static void bfa_fcs_lport_unknown_init(struct bfa_fcs_lport_s *port);
47 u8 reason_code_expl); 33static void bfa_fcs_lport_unknown_online(struct bfa_fcs_lport_s *port);
48static void bfa_fcs_port_plogi(struct bfa_fcs_port_s *port, 34static void bfa_fcs_lport_unknown_offline(struct bfa_fcs_lport_s *port);
49 struct fchs_s *rx_fchs, 35static void bfa_fcs_lport_deleted(struct bfa_fcs_lport_s *port);
50 struct fc_logi_s *plogi); 36static void bfa_fcs_lport_echo(struct bfa_fcs_lport_s *port,
51static void bfa_fcs_port_online_actions(struct bfa_fcs_port_s *port);
52static void bfa_fcs_port_offline_actions(struct bfa_fcs_port_s *port);
53static void bfa_fcs_port_unknown_init(struct bfa_fcs_port_s *port);
54static void bfa_fcs_port_unknown_online(struct bfa_fcs_port_s *port);
55static void bfa_fcs_port_unknown_offline(struct bfa_fcs_port_s *port);
56static void bfa_fcs_port_deleted(struct bfa_fcs_port_s *port);
57static void bfa_fcs_port_echo(struct bfa_fcs_port_s *port,
58 struct fchs_s *rx_fchs, 37 struct fchs_s *rx_fchs,
59 struct fc_echo_s *echo, u16 len); 38 struct fc_echo_s *echo, u16 len);
60static void bfa_fcs_port_rnid(struct bfa_fcs_port_s *port, 39static void bfa_fcs_lport_rnid(struct bfa_fcs_lport_s *port,
61 struct fchs_s *rx_fchs, 40 struct fchs_s *rx_fchs,
62 struct fc_rnid_cmd_s *rnid, u16 len); 41 struct fc_rnid_cmd_s *rnid, u16 len);
63static void bfa_fs_port_get_gen_topo_data(struct bfa_fcs_port_s *port, 42static void bfa_fs_port_get_gen_topo_data(struct bfa_fcs_lport_s *port,
64 struct fc_rnid_general_topology_data_s *gen_topo_data); 43 struct fc_rnid_general_topology_data_s *gen_topo_data);
65 44
45static void bfa_fcs_lport_fab_init(struct bfa_fcs_lport_s *port);
46static void bfa_fcs_lport_fab_online(struct bfa_fcs_lport_s *port);
47static void bfa_fcs_lport_fab_offline(struct bfa_fcs_lport_s *port);
48
49static void bfa_fcs_lport_n2n_init(struct bfa_fcs_lport_s *port);
50static void bfa_fcs_lport_n2n_online(struct bfa_fcs_lport_s *port);
51static void bfa_fcs_lport_n2n_offline(struct bfa_fcs_lport_s *port);
52
66static struct { 53static struct {
67 void (*init) (struct bfa_fcs_port_s *port); 54 void (*init) (struct bfa_fcs_lport_s *port);
68 void (*online) (struct bfa_fcs_port_s *port); 55 void (*online) (struct bfa_fcs_lport_s *port);
69 void (*offline) (struct bfa_fcs_port_s *port); 56 void (*offline) (struct bfa_fcs_lport_s *port);
70} __port_action[] = { 57} __port_action[] = {
71 { 58 {
72 bfa_fcs_port_unknown_init, bfa_fcs_port_unknown_online, 59 bfa_fcs_lport_unknown_init, bfa_fcs_lport_unknown_online,
73 bfa_fcs_port_unknown_offline}, { 60 bfa_fcs_lport_unknown_offline}, {
74 bfa_fcs_port_fab_init, bfa_fcs_port_fab_online, 61 bfa_fcs_lport_fab_init, bfa_fcs_lport_fab_online,
75 bfa_fcs_port_fab_offline}, { 62 bfa_fcs_lport_fab_offline}, {
76 bfa_fcs_port_loop_init, bfa_fcs_port_loop_online, 63 bfa_fcs_lport_n2n_init, bfa_fcs_lport_n2n_online,
77 bfa_fcs_port_loop_offline}, { 64 bfa_fcs_lport_n2n_offline},
78bfa_fcs_port_n2n_init, bfa_fcs_port_n2n_online, 65 };
79 bfa_fcs_port_n2n_offline},}; 66
80 67/*
81/**
82 * fcs_port_sm FCS logical port state machine 68 * fcs_port_sm FCS logical port state machine
83 */ 69 */
84 70
85enum bfa_fcs_port_event { 71enum bfa_fcs_lport_event {
86 BFA_FCS_PORT_SM_CREATE = 1, 72 BFA_FCS_PORT_SM_CREATE = 1,
87 BFA_FCS_PORT_SM_ONLINE = 2, 73 BFA_FCS_PORT_SM_ONLINE = 2,
88 BFA_FCS_PORT_SM_OFFLINE = 3, 74 BFA_FCS_PORT_SM_OFFLINE = 3,
@@ -90,27 +76,28 @@ enum bfa_fcs_port_event {
90 BFA_FCS_PORT_SM_DELRPORT = 5, 76 BFA_FCS_PORT_SM_DELRPORT = 5,
91}; 77};
92 78
93static void bfa_fcs_port_sm_uninit(struct bfa_fcs_port_s *port, 79static void bfa_fcs_lport_sm_uninit(struct bfa_fcs_lport_s *port,
94 enum bfa_fcs_port_event event); 80 enum bfa_fcs_lport_event event);
95static void bfa_fcs_port_sm_init(struct bfa_fcs_port_s *port, 81static void bfa_fcs_lport_sm_init(struct bfa_fcs_lport_s *port,
96 enum bfa_fcs_port_event event); 82 enum bfa_fcs_lport_event event);
97static void bfa_fcs_port_sm_online(struct bfa_fcs_port_s *port, 83static void bfa_fcs_lport_sm_online(struct bfa_fcs_lport_s *port,
98 enum bfa_fcs_port_event event); 84 enum bfa_fcs_lport_event event);
99static void bfa_fcs_port_sm_offline(struct bfa_fcs_port_s *port, 85static void bfa_fcs_lport_sm_offline(struct bfa_fcs_lport_s *port,
100 enum bfa_fcs_port_event event); 86 enum bfa_fcs_lport_event event);
101static void bfa_fcs_port_sm_deleting(struct bfa_fcs_port_s *port, 87static void bfa_fcs_lport_sm_deleting(struct bfa_fcs_lport_s *port,
102 enum bfa_fcs_port_event event); 88 enum bfa_fcs_lport_event event);
103 89
104static void 90static void
105bfa_fcs_port_sm_uninit(struct bfa_fcs_port_s *port, 91bfa_fcs_lport_sm_uninit(
106 enum bfa_fcs_port_event event) 92 struct bfa_fcs_lport_s *port,
93 enum bfa_fcs_lport_event event)
107{ 94{
108 bfa_trc(port->fcs, port->port_cfg.pwwn); 95 bfa_trc(port->fcs, port->port_cfg.pwwn);
109 bfa_trc(port->fcs, event); 96 bfa_trc(port->fcs, event);
110 97
111 switch (event) { 98 switch (event) {
112 case BFA_FCS_PORT_SM_CREATE: 99 case BFA_FCS_PORT_SM_CREATE:
113 bfa_sm_set_state(port, bfa_fcs_port_sm_init); 100 bfa_sm_set_state(port, bfa_fcs_lport_sm_init);
114 break; 101 break;
115 102
116 default: 103 default:
@@ -119,20 +106,21 @@ bfa_fcs_port_sm_uninit(struct bfa_fcs_port_s *port,
119} 106}
120 107
121static void 108static void
122bfa_fcs_port_sm_init(struct bfa_fcs_port_s *port, enum bfa_fcs_port_event event) 109bfa_fcs_lport_sm_init(struct bfa_fcs_lport_s *port,
110 enum bfa_fcs_lport_event event)
123{ 111{
124 bfa_trc(port->fcs, port->port_cfg.pwwn); 112 bfa_trc(port->fcs, port->port_cfg.pwwn);
125 bfa_trc(port->fcs, event); 113 bfa_trc(port->fcs, event);
126 114
127 switch (event) { 115 switch (event) {
128 case BFA_FCS_PORT_SM_ONLINE: 116 case BFA_FCS_PORT_SM_ONLINE:
129 bfa_sm_set_state(port, bfa_fcs_port_sm_online); 117 bfa_sm_set_state(port, bfa_fcs_lport_sm_online);
130 bfa_fcs_port_online_actions(port); 118 bfa_fcs_lport_online_actions(port);
131 break; 119 break;
132 120
133 case BFA_FCS_PORT_SM_DELETE: 121 case BFA_FCS_PORT_SM_DELETE:
134 bfa_sm_set_state(port, bfa_fcs_port_sm_uninit); 122 bfa_sm_set_state(port, bfa_fcs_lport_sm_uninit);
135 bfa_fcs_port_deleted(port); 123 bfa_fcs_lport_deleted(port);
136 break; 124 break;
137 125
138 case BFA_FCS_PORT_SM_OFFLINE: 126 case BFA_FCS_PORT_SM_OFFLINE:
@@ -144,19 +132,20 @@ bfa_fcs_port_sm_init(struct bfa_fcs_port_s *port, enum bfa_fcs_port_event event)
144} 132}
145 133
146static void 134static void
147bfa_fcs_port_sm_online(struct bfa_fcs_port_s *port, 135bfa_fcs_lport_sm_online(
148 enum bfa_fcs_port_event event) 136 struct bfa_fcs_lport_s *port,
137 enum bfa_fcs_lport_event event)
149{ 138{
150 struct bfa_fcs_rport_s *rport; 139 struct bfa_fcs_rport_s *rport;
151 struct list_head *qe, *qen; 140 struct list_head *qe, *qen;
152 141
153 bfa_trc(port->fcs, port->port_cfg.pwwn); 142 bfa_trc(port->fcs, port->port_cfg.pwwn);
154 bfa_trc(port->fcs, event); 143 bfa_trc(port->fcs, event);
155 144
156 switch (event) { 145 switch (event) {
157 case BFA_FCS_PORT_SM_OFFLINE: 146 case BFA_FCS_PORT_SM_OFFLINE:
158 bfa_sm_set_state(port, bfa_fcs_port_sm_offline); 147 bfa_sm_set_state(port, bfa_fcs_lport_sm_offline);
159 bfa_fcs_port_offline_actions(port); 148 bfa_fcs_lport_offline_actions(port);
160 break; 149 break;
161 150
162 case BFA_FCS_PORT_SM_DELETE: 151 case BFA_FCS_PORT_SM_DELETE:
@@ -164,13 +153,13 @@ bfa_fcs_port_sm_online(struct bfa_fcs_port_s *port,
164 __port_action[port->fabric->fab_type].offline(port); 153 __port_action[port->fabric->fab_type].offline(port);
165 154
166 if (port->num_rports == 0) { 155 if (port->num_rports == 0) {
167 bfa_sm_set_state(port, bfa_fcs_port_sm_uninit); 156 bfa_sm_set_state(port, bfa_fcs_lport_sm_uninit);
168 bfa_fcs_port_deleted(port); 157 bfa_fcs_lport_deleted(port);
169 } else { 158 } else {
170 bfa_sm_set_state(port, bfa_fcs_port_sm_deleting); 159 bfa_sm_set_state(port, bfa_fcs_lport_sm_deleting);
171 list_for_each_safe(qe, qen, &port->rport_q) { 160 list_for_each_safe(qe, qen, &port->rport_q) {
172 rport = (struct bfa_fcs_rport_s *)qe; 161 rport = (struct bfa_fcs_rport_s *) qe;
173 bfa_fcs_rport_delete(rport); 162 bfa_sm_send_event(rport, RPSM_EVENT_DELETE);
174 } 163 }
175 } 164 }
176 break; 165 break;
@@ -184,30 +173,31 @@ bfa_fcs_port_sm_online(struct bfa_fcs_port_s *port,
184} 173}
185 174
186static void 175static void
187bfa_fcs_port_sm_offline(struct bfa_fcs_port_s *port, 176bfa_fcs_lport_sm_offline(
188 enum bfa_fcs_port_event event) 177 struct bfa_fcs_lport_s *port,
178 enum bfa_fcs_lport_event event)
189{ 179{
190 struct bfa_fcs_rport_s *rport; 180 struct bfa_fcs_rport_s *rport;
191 struct list_head *qe, *qen; 181 struct list_head *qe, *qen;
192 182
193 bfa_trc(port->fcs, port->port_cfg.pwwn); 183 bfa_trc(port->fcs, port->port_cfg.pwwn);
194 bfa_trc(port->fcs, event); 184 bfa_trc(port->fcs, event);
195 185
196 switch (event) { 186 switch (event) {
197 case BFA_FCS_PORT_SM_ONLINE: 187 case BFA_FCS_PORT_SM_ONLINE:
198 bfa_sm_set_state(port, bfa_fcs_port_sm_online); 188 bfa_sm_set_state(port, bfa_fcs_lport_sm_online);
199 bfa_fcs_port_online_actions(port); 189 bfa_fcs_lport_online_actions(port);
200 break; 190 break;
201 191
202 case BFA_FCS_PORT_SM_DELETE: 192 case BFA_FCS_PORT_SM_DELETE:
203 if (port->num_rports == 0) { 193 if (port->num_rports == 0) {
204 bfa_sm_set_state(port, bfa_fcs_port_sm_uninit); 194 bfa_sm_set_state(port, bfa_fcs_lport_sm_uninit);
205 bfa_fcs_port_deleted(port); 195 bfa_fcs_lport_deleted(port);
206 } else { 196 } else {
207 bfa_sm_set_state(port, bfa_fcs_port_sm_deleting); 197 bfa_sm_set_state(port, bfa_fcs_lport_sm_deleting);
208 list_for_each_safe(qe, qen, &port->rport_q) { 198 list_for_each_safe(qe, qen, &port->rport_q) {
209 rport = (struct bfa_fcs_rport_s *)qe; 199 rport = (struct bfa_fcs_rport_s *) qe;
210 bfa_fcs_rport_delete(rport); 200 bfa_sm_send_event(rport, RPSM_EVENT_DELETE);
211 } 201 }
212 } 202 }
213 break; 203 break;
@@ -222,8 +212,9 @@ bfa_fcs_port_sm_offline(struct bfa_fcs_port_s *port,
222} 212}
223 213
224static void 214static void
225bfa_fcs_port_sm_deleting(struct bfa_fcs_port_s *port, 215bfa_fcs_lport_sm_deleting(
226 enum bfa_fcs_port_event event) 216 struct bfa_fcs_lport_s *port,
217 enum bfa_fcs_lport_event event)
227{ 218{
228 bfa_trc(port->fcs, port->port_cfg.pwwn); 219 bfa_trc(port->fcs, port->port_cfg.pwwn);
229 bfa_trc(port->fcs, event); 220 bfa_trc(port->fcs, event);
@@ -231,8 +222,8 @@ bfa_fcs_port_sm_deleting(struct bfa_fcs_port_s *port,
231 switch (event) { 222 switch (event) {
232 case BFA_FCS_PORT_SM_DELRPORT: 223 case BFA_FCS_PORT_SM_DELRPORT:
233 if (port->num_rports == 0) { 224 if (port->num_rports == 0) {
234 bfa_sm_set_state(port, bfa_fcs_port_sm_uninit); 225 bfa_sm_set_state(port, bfa_fcs_lport_sm_uninit);
235 bfa_fcs_port_deleted(port); 226 bfa_fcs_lport_deleted(port);
236 } 227 }
237 break; 228 break;
238 229
@@ -241,74 +232,44 @@ bfa_fcs_port_sm_deleting(struct bfa_fcs_port_s *port,
241 } 232 }
242} 233}
243 234
244 235/*
245
246/**
247 * fcs_port_pvt 236 * fcs_port_pvt
248 */ 237 */
249 238
250/**
251 * Send AEN notification
252 */
253static void
254bfa_fcs_port_aen_post(struct bfa_fcs_port_s *port,
255 enum bfa_lport_aen_event event)
256{
257 union bfa_aen_data_u aen_data;
258 struct bfa_log_mod_s *logmod = port->fcs->logm;
259 enum bfa_port_role role = port->port_cfg.roles;
260 wwn_t lpwwn = bfa_fcs_port_get_pwwn(port);
261 char lpwwn_ptr[BFA_STRING_32];
262 char *role_str[BFA_PORT_ROLE_FCP_MAX / 2 + 1] =
263 { "Initiator", "Target", "IPFC" };
264
265 wwn2str(lpwwn_ptr, lpwwn);
266
267 bfa_assert(role <= BFA_PORT_ROLE_FCP_MAX);
268
269 bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, event), lpwwn_ptr,
270 role_str[role/2]);
271
272 aen_data.lport.vf_id = port->fabric->vf_id;
273 aen_data.lport.roles = role;
274 aen_data.lport.ppwwn =
275 bfa_fcs_port_get_pwwn(bfa_fcs_get_base_port(port->fcs));
276 aen_data.lport.lpwwn = lpwwn;
277}
278
279/* 239/*
280 * Send a LS reject 240 * Send a LS reject
281 */ 241 */
282static void 242static void
283bfa_fcs_port_send_ls_rjt(struct bfa_fcs_port_s *port, struct fchs_s *rx_fchs, 243bfa_fcs_lport_send_ls_rjt(struct bfa_fcs_lport_s *port, struct fchs_s *rx_fchs,
284 u8 reason_code, u8 reason_code_expl) 244 u8 reason_code, u8 reason_code_expl)
285{ 245{
286 struct fchs_s fchs; 246 struct fchs_s fchs;
287 struct bfa_fcxp_s *fcxp; 247 struct bfa_fcxp_s *fcxp;
288 struct bfa_rport_s *bfa_rport = NULL; 248 struct bfa_rport_s *bfa_rport = NULL;
289 int len; 249 int len;
290 250
251 bfa_trc(port->fcs, rx_fchs->d_id);
291 bfa_trc(port->fcs, rx_fchs->s_id); 252 bfa_trc(port->fcs, rx_fchs->s_id);
292 253
293 fcxp = bfa_fcs_fcxp_alloc(port->fcs); 254 fcxp = bfa_fcs_fcxp_alloc(port->fcs);
294 if (!fcxp) 255 if (!fcxp)
295 return; 256 return;
296 257
297 len = fc_ls_rjt_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rx_fchs->s_id, 258 len = fc_ls_rjt_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
298 bfa_fcs_port_get_fcid(port), rx_fchs->ox_id, 259 rx_fchs->s_id, bfa_fcs_lport_get_fcid(port),
299 reason_code, reason_code_expl); 260 rx_fchs->ox_id, reason_code, reason_code_expl);
300 261
301 bfa_fcxp_send(fcxp, bfa_rport, port->fabric->vf_id, port->lp_tag, 262 bfa_fcxp_send(fcxp, bfa_rport, port->fabric->vf_id, port->lp_tag,
302 BFA_FALSE, FC_CLASS_3, len, &fchs, NULL, NULL, 263 BFA_FALSE, FC_CLASS_3, len, &fchs, NULL, NULL,
303 FC_MAX_PDUSZ, 0); 264 FC_MAX_PDUSZ, 0);
304} 265}
305 266
306/** 267/*
307 * Process incoming plogi from a remote port. 268 * Process incoming plogi from a remote port.
308 */ 269 */
309static void 270static void
310bfa_fcs_port_plogi(struct bfa_fcs_port_s *port, struct fchs_s *rx_fchs, 271bfa_fcs_lport_plogi(struct bfa_fcs_lport_s *port,
311 struct fc_logi_s *plogi) 272 struct fchs_s *rx_fchs, struct fc_logi_s *plogi)
312{ 273{
313 struct bfa_fcs_rport_s *rport; 274 struct bfa_fcs_rport_s *rport;
314 275
@@ -328,86 +289,82 @@ bfa_fcs_port_plogi(struct bfa_fcs_port_s *port, struct fchs_s *rx_fchs,
328 /* 289 /*
329 * send a LS reject 290 * send a LS reject
330 */ 291 */
331 bfa_fcs_port_send_ls_rjt(port, rx_fchs, 292 bfa_fcs_lport_send_ls_rjt(port, rx_fchs,
332 FC_LS_RJT_RSN_PROTOCOL_ERROR, 293 FC_LS_RJT_RSN_PROTOCOL_ERROR,
333 FC_LS_RJT_EXP_SPARMS_ERR_OPTIONS); 294 FC_LS_RJT_EXP_SPARMS_ERR_OPTIONS);
334 return; 295 return;
335 } 296 }
336 297
337 /** 298 /*
338* Direct Attach P2P mode : verify address assigned by the r-port. 299 * Direct Attach P2P mode : verify address assigned by the r-port.
339 */ 300 */
340 if ((!bfa_fcs_fabric_is_switched(port->fabric)) 301 if ((!bfa_fcs_fabric_is_switched(port->fabric)) &&
341 && 302 (memcmp((void *)&bfa_fcs_lport_get_pwwn(port),
342 (memcmp 303 (void *)&plogi->port_name, sizeof(wwn_t)) < 0)) {
343 ((void *)&bfa_fcs_port_get_pwwn(port), (void *)&plogi->port_name,
344 sizeof(wwn_t)) < 0)) {
345 if (BFA_FCS_PID_IS_WKA(rx_fchs->d_id)) { 304 if (BFA_FCS_PID_IS_WKA(rx_fchs->d_id)) {
346 /* 305 /* Address assigned to us cannot be a WKA */
347 * Address assigned to us cannot be a WKA 306 bfa_fcs_lport_send_ls_rjt(port, rx_fchs,
348 */
349 bfa_fcs_port_send_ls_rjt(port, rx_fchs,
350 FC_LS_RJT_RSN_PROTOCOL_ERROR, 307 FC_LS_RJT_RSN_PROTOCOL_ERROR,
351 FC_LS_RJT_EXP_INVALID_NPORT_ID); 308 FC_LS_RJT_EXP_INVALID_NPORT_ID);
352 return; 309 return;
353 } 310 }
354 port->pid = rx_fchs->d_id; 311 port->pid = rx_fchs->d_id;
312 bfa_lps_set_n2n_pid(port->fabric->lps, rx_fchs->d_id);
355 } 313 }
356 314
357 /** 315 /*
358 * First, check if we know the device by pwwn. 316 * First, check if we know the device by pwwn.
359 */ 317 */
360 rport = bfa_fcs_port_get_rport_by_pwwn(port, plogi->port_name); 318 rport = bfa_fcs_lport_get_rport_by_pwwn(port, plogi->port_name);
361 if (rport) { 319 if (rport) {
362 /** 320 /*
363 * Direct Attach P2P mode: handle address assigned by the rport. 321 * Direct Attach P2P mode : handle address assigned by r-port.
364 */ 322 */
365 if ((!bfa_fcs_fabric_is_switched(port->fabric)) 323 if ((!bfa_fcs_fabric_is_switched(port->fabric)) &&
366 && 324 (memcmp((void *)&bfa_fcs_lport_get_pwwn(port),
367 (memcmp 325 (void *)&plogi->port_name, sizeof(wwn_t)) < 0)) {
368 ((void *)&bfa_fcs_port_get_pwwn(port), 326 port->pid = rx_fchs->d_id;
369 (void *)&plogi->port_name, sizeof(wwn_t)) < 0)) { 327 bfa_lps_set_n2n_pid(port->fabric->lps, rx_fchs->d_id);
370 port->pid = rx_fchs->d_id;
371 rport->pid = rx_fchs->s_id; 328 rport->pid = rx_fchs->s_id;
372 } 329 }
373 bfa_fcs_rport_plogi(rport, rx_fchs, plogi); 330 bfa_fcs_rport_plogi(rport, rx_fchs, plogi);
374 return; 331 return;
375 } 332 }
376 333
377 /** 334 /*
378 * Next, lookup rport by PID. 335 * Next, lookup rport by PID.
379 */ 336 */
380 rport = bfa_fcs_port_get_rport_by_pid(port, rx_fchs->s_id); 337 rport = bfa_fcs_lport_get_rport_by_pid(port, rx_fchs->s_id);
381 if (!rport) { 338 if (!rport) {
382 /** 339 /*
383 * Inbound PLOGI from a new device. 340 * Inbound PLOGI from a new device.
384 */ 341 */
385 bfa_fcs_rport_plogi_create(port, rx_fchs, plogi); 342 bfa_fcs_rport_plogi_create(port, rx_fchs, plogi);
386 return; 343 return;
387 } 344 }
388 345
389 /** 346 /*
390 * Rport is known only by PID. 347 * Rport is known only by PID.
391 */ 348 */
392 if (rport->pwwn) { 349 if (rport->pwwn) {
393 /** 350 /*
394 * This is a different device with the same pid. Old device 351 * This is a different device with the same pid. Old device
395 * disappeared. Send implicit LOGO to old device. 352 * disappeared. Send implicit LOGO to old device.
396 */ 353 */
397 bfa_assert(rport->pwwn != plogi->port_name); 354 WARN_ON(rport->pwwn == plogi->port_name);
398 bfa_fcs_rport_logo_imp(rport); 355 bfa_sm_send_event(rport, RPSM_EVENT_LOGO_IMP);
399 356
400 /** 357 /*
401 * Inbound PLOGI from a new device (with old PID). 358 * Inbound PLOGI from a new device (with old PID).
402 */ 359 */
403 bfa_fcs_rport_plogi_create(port, rx_fchs, plogi); 360 bfa_fcs_rport_plogi_create(port, rx_fchs, plogi);
404 return; 361 return;
405 } 362 }
406 363
407 /** 364 /*
408 * PLOGI crossing each other. 365 * PLOGI crossing each other.
409 */ 366 */
410 bfa_assert(rport->pwwn == WWN_NULL); 367 WARN_ON(rport->pwwn != WWN_NULL);
411 bfa_fcs_rport_plogi(rport, rx_fchs, plogi); 368 bfa_fcs_rport_plogi(rport, rx_fchs, plogi);
412} 369}
413 370
@@ -416,39 +373,40 @@ bfa_fcs_port_plogi(struct bfa_fcs_port_s *port, struct fchs_s *rx_fchs,
416 * Since it does not require a login, it is processed here. 373 * Since it does not require a login, it is processed here.
417 */ 374 */
418static void 375static void
419bfa_fcs_port_echo(struct bfa_fcs_port_s *port, struct fchs_s *rx_fchs, 376bfa_fcs_lport_echo(struct bfa_fcs_lport_s *port, struct fchs_s *rx_fchs,
420 struct fc_echo_s *echo, u16 rx_len) 377 struct fc_echo_s *echo, u16 rx_len)
421{ 378{
422 struct fchs_s fchs; 379 struct fchs_s fchs;
423 struct bfa_fcxp_s *fcxp; 380 struct bfa_fcxp_s *fcxp;
424 struct bfa_rport_s *bfa_rport = NULL; 381 struct bfa_rport_s *bfa_rport = NULL;
425 int len, pyld_len; 382 int len, pyld_len;
426 383
427 bfa_trc(port->fcs, rx_fchs->s_id); 384 bfa_trc(port->fcs, rx_fchs->s_id);
428 bfa_trc(port->fcs, rx_fchs->d_id); 385 bfa_trc(port->fcs, rx_fchs->d_id);
429 bfa_trc(port->fcs, rx_len);
430 386
431 fcxp = bfa_fcs_fcxp_alloc(port->fcs); 387 fcxp = bfa_fcs_fcxp_alloc(port->fcs);
432 if (!fcxp) 388 if (!fcxp)
433 return; 389 return;
434 390
435 len = fc_ls_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rx_fchs->s_id, 391 len = fc_ls_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
436 bfa_fcs_port_get_fcid(port), rx_fchs->ox_id); 392 rx_fchs->s_id, bfa_fcs_lport_get_fcid(port),
393 rx_fchs->ox_id);
437 394
438 /* 395 /*
439 * Copy the payload (if any) from the echo frame 396 * Copy the payload (if any) from the echo frame
440 */ 397 */
441 pyld_len = rx_len - sizeof(struct fchs_s); 398 pyld_len = rx_len - sizeof(struct fchs_s);
399 bfa_trc(port->fcs, rx_len);
442 bfa_trc(port->fcs, pyld_len); 400 bfa_trc(port->fcs, pyld_len);
443 401
444 if (pyld_len > len) 402 if (pyld_len > len)
445 memcpy(((u8 *) bfa_fcxp_get_reqbuf(fcxp)) + 403 memcpy(((u8 *) bfa_fcxp_get_reqbuf(fcxp)) +
446 sizeof(struct fc_echo_s), (echo + 1), 404 sizeof(struct fc_echo_s), (echo + 1),
447 (pyld_len - sizeof(struct fc_echo_s))); 405 (pyld_len - sizeof(struct fc_echo_s)));
448 406
449 bfa_fcxp_send(fcxp, bfa_rport, port->fabric->vf_id, port->lp_tag, 407 bfa_fcxp_send(fcxp, bfa_rport, port->fabric->vf_id, port->lp_tag,
450 BFA_FALSE, FC_CLASS_3, pyld_len, &fchs, NULL, NULL, 408 BFA_FALSE, FC_CLASS_3, pyld_len, &fchs, NULL, NULL,
451 FC_MAX_PDUSZ, 0); 409 FC_MAX_PDUSZ, 0);
452} 410}
453 411
454/* 412/*
@@ -456,16 +414,16 @@ bfa_fcs_port_echo(struct bfa_fcs_port_s *port, struct fchs_s *rx_fchs,
456 * Since it does not require a login, it is processed here. 414 * Since it does not require a login, it is processed here.
457 */ 415 */
458static void 416static void
459bfa_fcs_port_rnid(struct bfa_fcs_port_s *port, struct fchs_s *rx_fchs, 417bfa_fcs_lport_rnid(struct bfa_fcs_lport_s *port, struct fchs_s *rx_fchs,
460 struct fc_rnid_cmd_s *rnid, u16 rx_len) 418 struct fc_rnid_cmd_s *rnid, u16 rx_len)
461{ 419{
462 struct fc_rnid_common_id_data_s common_id_data; 420 struct fc_rnid_common_id_data_s common_id_data;
463 struct fc_rnid_general_topology_data_s gen_topo_data; 421 struct fc_rnid_general_topology_data_s gen_topo_data;
464 struct fchs_s fchs; 422 struct fchs_s fchs;
465 struct bfa_fcxp_s *fcxp; 423 struct bfa_fcxp_s *fcxp;
466 struct bfa_rport_s *bfa_rport = NULL; 424 struct bfa_rport_s *bfa_rport = NULL;
467 u16 len; 425 u16 len;
468 u32 data_format; 426 u32 data_format;
469 427
470 bfa_trc(port->fcs, rx_fchs->s_id); 428 bfa_trc(port->fcs, rx_fchs->s_id);
471 bfa_trc(port->fcs, rx_fchs->d_id); 429 bfa_trc(port->fcs, rx_fchs->d_id);
@@ -495,152 +453,165 @@ bfa_fcs_port_rnid(struct bfa_fcs_port_s *port, struct fchs_s *rx_fchs,
495 /* 453 /*
496 * Copy the Node Id Info 454 * Copy the Node Id Info
497 */ 455 */
498 common_id_data.port_name = bfa_fcs_port_get_pwwn(port); 456 common_id_data.port_name = bfa_fcs_lport_get_pwwn(port);
499 common_id_data.node_name = bfa_fcs_port_get_nwwn(port); 457 common_id_data.node_name = bfa_fcs_lport_get_nwwn(port);
500 458
501 len = fc_rnid_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rx_fchs->s_id, 459 len = fc_rnid_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
502 bfa_fcs_port_get_fcid(port), rx_fchs->ox_id, 460 rx_fchs->s_id, bfa_fcs_lport_get_fcid(port),
503 data_format, &common_id_data, &gen_topo_data); 461 rx_fchs->ox_id, data_format, &common_id_data,
462 &gen_topo_data);
504 463
505 bfa_fcxp_send(fcxp, bfa_rport, port->fabric->vf_id, port->lp_tag, 464 bfa_fcxp_send(fcxp, bfa_rport, port->fabric->vf_id, port->lp_tag,
506 BFA_FALSE, FC_CLASS_3, len, &fchs, NULL, NULL, 465 BFA_FALSE, FC_CLASS_3, len, &fchs, NULL, NULL,
507 FC_MAX_PDUSZ, 0); 466 FC_MAX_PDUSZ, 0);
508
509 return;
510} 467}
511 468
512/* 469/*
513 * Fill out General Topolpgy Discovery Data for RNID ELS. 470 * Fill out General Topolpgy Discovery Data for RNID ELS.
514 */ 471 */
515static void 472static void
516bfa_fs_port_get_gen_topo_data(struct bfa_fcs_port_s *port, 473bfa_fs_port_get_gen_topo_data(struct bfa_fcs_lport_s *port,
517 struct fc_rnid_general_topology_data_s *gen_topo_data) 474 struct fc_rnid_general_topology_data_s *gen_topo_data)
518{ 475{
519 476 memset(gen_topo_data, 0,
520 bfa_os_memset(gen_topo_data, 0,
521 sizeof(struct fc_rnid_general_topology_data_s)); 477 sizeof(struct fc_rnid_general_topology_data_s));
522 478
523 gen_topo_data->asso_type = bfa_os_htonl(RNID_ASSOCIATED_TYPE_HOST); 479 gen_topo_data->asso_type = cpu_to_be32(RNID_ASSOCIATED_TYPE_HOST);
524 gen_topo_data->phy_port_num = 0; /* @todo */ 480 gen_topo_data->phy_port_num = 0; /* @todo */
525 gen_topo_data->num_attached_nodes = bfa_os_htonl(1); 481 gen_topo_data->num_attached_nodes = cpu_to_be32(1);
526} 482}
527 483
528static void 484static void
529bfa_fcs_port_online_actions(struct bfa_fcs_port_s *port) 485bfa_fcs_lport_online_actions(struct bfa_fcs_lport_s *port)
530{ 486{
487 struct bfad_s *bfad = (struct bfad_s *)port->fcs->bfad;
488 char lpwwn_buf[BFA_STRING_32];
489
531 bfa_trc(port->fcs, port->fabric->oper_type); 490 bfa_trc(port->fcs, port->fabric->oper_type);
532 491
533 __port_action[port->fabric->fab_type].init(port); 492 __port_action[port->fabric->fab_type].init(port);
534 __port_action[port->fabric->fab_type].online(port); 493 __port_action[port->fabric->fab_type].online(port);
535 494
536 bfa_fcs_port_aen_post(port, BFA_LPORT_AEN_ONLINE); 495 wwn2str(lpwwn_buf, bfa_fcs_lport_get_pwwn(port));
537 bfa_fcb_port_online(port->fcs->bfad, port->port_cfg.roles, 496 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
538 port->fabric->vf_drv, (port->vport == NULL) ? 497 "Logical port online: WWN = %s Role = %s\n",
539 NULL : port->vport->vport_drv); 498 lpwwn_buf, "Initiator");
499
500 bfad->bfad_flags |= BFAD_PORT_ONLINE;
540} 501}
541 502
542static void 503static void
543bfa_fcs_port_offline_actions(struct bfa_fcs_port_s *port) 504bfa_fcs_lport_offline_actions(struct bfa_fcs_lport_s *port)
544{ 505{
545 struct list_head *qe, *qen; 506 struct list_head *qe, *qen;
546 struct bfa_fcs_rport_s *rport; 507 struct bfa_fcs_rport_s *rport;
508 struct bfad_s *bfad = (struct bfad_s *)port->fcs->bfad;
509 char lpwwn_buf[BFA_STRING_32];
547 510
548 bfa_trc(port->fcs, port->fabric->oper_type); 511 bfa_trc(port->fcs, port->fabric->oper_type);
549 512
550 __port_action[port->fabric->fab_type].offline(port); 513 __port_action[port->fabric->fab_type].offline(port);
551 514
552 if (bfa_fcs_fabric_is_online(port->fabric) == BFA_TRUE) 515 wwn2str(lpwwn_buf, bfa_fcs_lport_get_pwwn(port));
553 bfa_fcs_port_aen_post(port, BFA_LPORT_AEN_DISCONNECT); 516 if (bfa_sm_cmp_state(port->fabric,
517 bfa_fcs_fabric_sm_online) == BFA_TRUE)
518 BFA_LOG(KERN_ERR, bfad, bfa_log_level,
519 "Logical port lost fabric connectivity: WWN = %s Role = %s\n",
520 lpwwn_buf, "Initiator");
554 else 521 else
555 bfa_fcs_port_aen_post(port, BFA_LPORT_AEN_OFFLINE); 522 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
556 bfa_fcb_port_offline(port->fcs->bfad, port->port_cfg.roles, 523 "Logical port taken offline: WWN = %s Role = %s\n",
557 port->fabric->vf_drv, 524 lpwwn_buf, "Initiator");
558 (port->vport == NULL) ? NULL : port->vport->vport_drv);
559 525
560 list_for_each_safe(qe, qen, &port->rport_q) { 526 list_for_each_safe(qe, qen, &port->rport_q) {
561 rport = (struct bfa_fcs_rport_s *)qe; 527 rport = (struct bfa_fcs_rport_s *) qe;
562 bfa_fcs_rport_offline(rport); 528 bfa_sm_send_event(rport, RPSM_EVENT_LOGO_IMP);
563 } 529 }
564} 530}
565 531
566static void 532static void
567bfa_fcs_port_unknown_init(struct bfa_fcs_port_s *port) 533bfa_fcs_lport_unknown_init(struct bfa_fcs_lport_s *port)
568{ 534{
569 bfa_assert(0); 535 WARN_ON(1);
570} 536}
571 537
572static void 538static void
573bfa_fcs_port_unknown_online(struct bfa_fcs_port_s *port) 539bfa_fcs_lport_unknown_online(struct bfa_fcs_lport_s *port)
574{ 540{
575 bfa_assert(0); 541 WARN_ON(1);
576} 542}
577 543
578static void 544static void
579bfa_fcs_port_unknown_offline(struct bfa_fcs_port_s *port) 545bfa_fcs_lport_unknown_offline(struct bfa_fcs_lport_s *port)
580{ 546{
581 bfa_assert(0); 547 WARN_ON(1);
582} 548}
583 549
584static void 550static void
585bfa_fcs_port_deleted(struct bfa_fcs_port_s *port) 551bfa_fcs_lport_abts_acc(struct bfa_fcs_lport_s *port, struct fchs_s *rx_fchs)
586{ 552{
587 bfa_fcs_port_aen_post(port, BFA_LPORT_AEN_DELETE); 553 struct fchs_s fchs;
554 struct bfa_fcxp_s *fcxp;
555 int len;
588 556
589 /* 557 bfa_trc(port->fcs, rx_fchs->d_id);
590 * Base port will be deleted by the OS driver 558 bfa_trc(port->fcs, rx_fchs->s_id);
591 */
592 if (port->vport) {
593 bfa_fcb_port_delete(port->fcs->bfad, port->port_cfg.roles,
594 port->fabric->vf_drv,
595 port->vport ? port->vport->vport_drv : NULL);
596 bfa_fcs_vport_delete_comp(port->vport);
597 } else {
598 bfa_fcs_fabric_port_delete_comp(port->fabric);
599 }
600}
601 559
560 fcxp = bfa_fcs_fcxp_alloc(port->fcs);
561 if (!fcxp)
562 return;
602 563
564 len = fc_ba_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
565 rx_fchs->s_id, bfa_fcs_lport_get_fcid(port),
566 rx_fchs->ox_id, 0);
603 567
604/** 568 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag,
605 * fcs_lport_api BFA FCS port API 569 BFA_FALSE, FC_CLASS_3, len, &fchs, NULL, NULL,
606 */ 570 FC_MAX_PDUSZ, 0);
607/** 571}
608 * Module initialization 572static void
609 */ 573bfa_fcs_lport_deleted(struct bfa_fcs_lport_s *port)
610void
611bfa_fcs_port_modinit(struct bfa_fcs_s *fcs)
612{ 574{
575 struct bfad_s *bfad = (struct bfad_s *)port->fcs->bfad;
576 char lpwwn_buf[BFA_STRING_32];
613 577
614} 578 wwn2str(lpwwn_buf, bfa_fcs_lport_get_pwwn(port));
579 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
580 "Logical port deleted: WWN = %s Role = %s\n",
581 lpwwn_buf, "Initiator");
615 582
616/** 583 /* Base port will be deleted by the OS driver */
617 * Module cleanup 584 if (port->vport) {
618 */ 585 bfa_fcb_lport_delete(port->fcs->bfad, port->port_cfg.roles,
619void 586 port->fabric->vf_drv,
620bfa_fcs_port_modexit(struct bfa_fcs_s *fcs) 587 port->vport ? port->vport->vport_drv : NULL);
621{ 588 bfa_fcs_vport_delete_comp(port->vport);
622 bfa_fcs_modexit_comp(fcs); 589 } else {
590 bfa_wc_down(&port->fabric->wc);
591 }
623} 592}
624 593
625/** 594
626 * Unsolicited frame receive handling. 595/*
596 * Unsolicited frame receive handling.
627 */ 597 */
628void 598void
629bfa_fcs_port_uf_recv(struct bfa_fcs_port_s *lport, struct fchs_s *fchs, 599bfa_fcs_lport_uf_recv(struct bfa_fcs_lport_s *lport,
630 u16 len) 600 struct fchs_s *fchs, u16 len)
631{ 601{
632 u32 pid = fchs->s_id; 602 u32 pid = fchs->s_id;
633 struct bfa_fcs_rport_s *rport = NULL; 603 struct bfa_fcs_rport_s *rport = NULL;
634 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1); 604 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
635 605
636 bfa_stats(lport, uf_recvs); 606 bfa_stats(lport, uf_recvs);
607 bfa_trc(lport->fcs, fchs->type);
637 608
638 if (!bfa_fcs_port_is_online(lport)) { 609 if (!bfa_fcs_lport_is_online(lport)) {
639 bfa_stats(lport, uf_recv_drops); 610 bfa_stats(lport, uf_recv_drops);
640 return; 611 return;
641 } 612 }
642 613
643 /** 614 /*
644 * First, handle ELSs that donot require a login. 615 * First, handle ELSs that donot require a login.
645 */ 616 */
646 /* 617 /*
@@ -648,7 +619,7 @@ bfa_fcs_port_uf_recv(struct bfa_fcs_port_s *lport, struct fchs_s *fchs,
648 */ 619 */
649 if ((fchs->type == FC_TYPE_ELS) && 620 if ((fchs->type == FC_TYPE_ELS) &&
650 (els_cmd->els_code == FC_ELS_PLOGI)) { 621 (els_cmd->els_code == FC_ELS_PLOGI)) {
651 bfa_fcs_port_plogi(lport, fchs, (struct fc_logi_s *) els_cmd); 622 bfa_fcs_lport_plogi(lport, fchs, (struct fc_logi_s *) els_cmd);
652 return; 623 return;
653 } 624 }
654 625
@@ -656,8 +627,8 @@ bfa_fcs_port_uf_recv(struct bfa_fcs_port_s *lport, struct fchs_s *fchs,
656 * Handle ECHO separately. 627 * Handle ECHO separately.
657 */ 628 */
658 if ((fchs->type == FC_TYPE_ELS) && (els_cmd->els_code == FC_ELS_ECHO)) { 629 if ((fchs->type == FC_TYPE_ELS) && (els_cmd->els_code == FC_ELS_ECHO)) {
659 bfa_fcs_port_echo(lport, fchs, 630 bfa_fcs_lport_echo(lport, fchs,
660 (struct fc_echo_s *) els_cmd, len); 631 (struct fc_echo_s *)els_cmd, len);
661 return; 632 return;
662 } 633 }
663 634
@@ -665,15 +636,21 @@ bfa_fcs_port_uf_recv(struct bfa_fcs_port_s *lport, struct fchs_s *fchs,
665 * Handle RNID separately. 636 * Handle RNID separately.
666 */ 637 */
667 if ((fchs->type == FC_TYPE_ELS) && (els_cmd->els_code == FC_ELS_RNID)) { 638 if ((fchs->type == FC_TYPE_ELS) && (els_cmd->els_code == FC_ELS_RNID)) {
668 bfa_fcs_port_rnid(lport, fchs, 639 bfa_fcs_lport_rnid(lport, fchs,
669 (struct fc_rnid_cmd_s *) els_cmd, len); 640 (struct fc_rnid_cmd_s *) els_cmd, len);
670 return; 641 return;
671 } 642 }
672 643
673 /** 644 if (fchs->type == FC_TYPE_BLS) {
645 if ((fchs->routing == FC_RTG_BASIC_LINK) &&
646 (fchs->cat_info == FC_CAT_ABTS))
647 bfa_fcs_lport_abts_acc(lport, fchs);
648 return;
649 }
650 /*
674 * look for a matching remote port ID 651 * look for a matching remote port ID
675 */ 652 */
676 rport = bfa_fcs_port_get_rport_by_pid(lport, pid); 653 rport = bfa_fcs_lport_get_rport_by_pid(lport, pid);
677 if (rport) { 654 if (rport) {
678 bfa_trc(rport->fcs, fchs->s_id); 655 bfa_trc(rport->fcs, fchs->s_id);
679 bfa_trc(rport->fcs, fchs->d_id); 656 bfa_trc(rport->fcs, fchs->d_id);
@@ -683,56 +660,57 @@ bfa_fcs_port_uf_recv(struct bfa_fcs_port_s *lport, struct fchs_s *fchs,
683 return; 660 return;
684 } 661 }
685 662
686 /** 663 /*
687 * Only handles ELS frames for now. 664 * Only handles ELS frames for now.
688 */ 665 */
689 if (fchs->type != FC_TYPE_ELS) { 666 if (fchs->type != FC_TYPE_ELS) {
690 bfa_trc(lport->fcs, fchs->type); 667 bfa_trc(lport->fcs, fchs->s_id);
691 bfa_assert(0); 668 bfa_trc(lport->fcs, fchs->d_id);
669 /* ignore type FC_TYPE_FC_FSS */
670 if (fchs->type != FC_TYPE_FC_FSS)
671 bfa_sm_fault(lport->fcs, fchs->type);
692 return; 672 return;
693 } 673 }
694 674
695 bfa_trc(lport->fcs, els_cmd->els_code); 675 bfa_trc(lport->fcs, els_cmd->els_code);
696 if (els_cmd->els_code == FC_ELS_RSCN) { 676 if (els_cmd->els_code == FC_ELS_RSCN) {
697 bfa_fcs_port_scn_process_rscn(lport, fchs, len); 677 bfa_fcs_lport_scn_process_rscn(lport, fchs, len);
698 return; 678 return;
699 } 679 }
700 680
701 if (els_cmd->els_code == FC_ELS_LOGO) { 681 if (els_cmd->els_code == FC_ELS_LOGO) {
702 /** 682 /*
703 * @todo Handle LOGO frames received. 683 * @todo Handle LOGO frames received.
704 */ 684 */
705 bfa_trc(lport->fcs, els_cmd->els_code);
706 return; 685 return;
707 } 686 }
708 687
709 if (els_cmd->els_code == FC_ELS_PRLI) { 688 if (els_cmd->els_code == FC_ELS_PRLI) {
710 /** 689 /*
711 * @todo Handle PRLI frames received. 690 * @todo Handle PRLI frames received.
712 */ 691 */
713 bfa_trc(lport->fcs, els_cmd->els_code);
714 return; 692 return;
715 } 693 }
716 694
717 /** 695 /*
718 * Unhandled ELS frames. Send a LS_RJT. 696 * Unhandled ELS frames. Send a LS_RJT.
719 */ 697 */
720 bfa_fcs_port_send_ls_rjt(lport, fchs, FC_LS_RJT_RSN_CMD_NOT_SUPP, 698 bfa_fcs_lport_send_ls_rjt(lport, fchs, FC_LS_RJT_RSN_CMD_NOT_SUPP,
721 FC_LS_RJT_EXP_NO_ADDL_INFO); 699 FC_LS_RJT_EXP_NO_ADDL_INFO);
722 700
723} 701}
724 702
725/** 703/*
726 * PID based Lookup for a R-Port in the Port R-Port Queue 704 * PID based Lookup for a R-Port in the Port R-Port Queue
727 */ 705 */
728struct bfa_fcs_rport_s * 706struct bfa_fcs_rport_s *
729bfa_fcs_port_get_rport_by_pid(struct bfa_fcs_port_s *port, u32 pid) 707bfa_fcs_lport_get_rport_by_pid(struct bfa_fcs_lport_s *port, u32 pid)
730{ 708{
731 struct bfa_fcs_rport_s *rport; 709 struct bfa_fcs_rport_s *rport;
732 struct list_head *qe; 710 struct list_head *qe;
733 711
734 list_for_each(qe, &port->rport_q) { 712 list_for_each(qe, &port->rport_q) {
735 rport = (struct bfa_fcs_rport_s *)qe; 713 rport = (struct bfa_fcs_rport_s *) qe;
736 if (rport->pid == pid) 714 if (rport->pid == pid)
737 return rport; 715 return rport;
738 } 716 }
@@ -741,17 +719,17 @@ bfa_fcs_port_get_rport_by_pid(struct bfa_fcs_port_s *port, u32 pid)
741 return NULL; 719 return NULL;
742} 720}
743 721
744/** 722/*
745 * PWWN based Lookup for a R-Port in the Port R-Port Queue 723 * PWWN based Lookup for a R-Port in the Port R-Port Queue
746 */ 724 */
747struct bfa_fcs_rport_s * 725struct bfa_fcs_rport_s *
748bfa_fcs_port_get_rport_by_pwwn(struct bfa_fcs_port_s *port, wwn_t pwwn) 726bfa_fcs_lport_get_rport_by_pwwn(struct bfa_fcs_lport_s *port, wwn_t pwwn)
749{ 727{
750 struct bfa_fcs_rport_s *rport; 728 struct bfa_fcs_rport_s *rport;
751 struct list_head *qe; 729 struct list_head *qe;
752 730
753 list_for_each(qe, &port->rport_q) { 731 list_for_each(qe, &port->rport_q) {
754 rport = (struct bfa_fcs_rport_s *)qe; 732 rport = (struct bfa_fcs_rport_s *) qe;
755 if (wwn_is_equal(rport->pwwn, pwwn)) 733 if (wwn_is_equal(rport->pwwn, pwwn))
756 return rport; 734 return rport;
757 } 735 }
@@ -760,17 +738,17 @@ bfa_fcs_port_get_rport_by_pwwn(struct bfa_fcs_port_s *port, wwn_t pwwn)
760 return NULL; 738 return NULL;
761} 739}
762 740
763/** 741/*
764 * NWWN based Lookup for a R-Port in the Port R-Port Queue 742 * NWWN based Lookup for a R-Port in the Port R-Port Queue
765 */ 743 */
766struct bfa_fcs_rport_s * 744struct bfa_fcs_rport_s *
767bfa_fcs_port_get_rport_by_nwwn(struct bfa_fcs_port_s *port, wwn_t nwwn) 745bfa_fcs_lport_get_rport_by_nwwn(struct bfa_fcs_lport_s *port, wwn_t nwwn)
768{ 746{
769 struct bfa_fcs_rport_s *rport; 747 struct bfa_fcs_rport_s *rport;
770 struct list_head *qe; 748 struct list_head *qe;
771 749
772 list_for_each(qe, &port->rport_q) { 750 list_for_each(qe, &port->rport_q) {
773 rport = (struct bfa_fcs_rport_s *)qe; 751 rport = (struct bfa_fcs_rport_s *) qe;
774 if (wwn_is_equal(rport->nwwn, nwwn)) 752 if (wwn_is_equal(rport->nwwn, nwwn))
775 return rport; 753 return rport;
776 } 754 }
@@ -779,130 +757,130 @@ bfa_fcs_port_get_rport_by_nwwn(struct bfa_fcs_port_s *port, wwn_t nwwn)
779 return NULL; 757 return NULL;
780} 758}
781 759
782/** 760/*
783 * Called by rport module when new rports are discovered. 761 * Called by rport module when new rports are discovered.
784 */ 762 */
785void 763void
786bfa_fcs_port_add_rport(struct bfa_fcs_port_s *port, 764bfa_fcs_lport_add_rport(
787 struct bfa_fcs_rport_s *rport) 765 struct bfa_fcs_lport_s *port,
766 struct bfa_fcs_rport_s *rport)
788{ 767{
789 list_add_tail(&rport->qe, &port->rport_q); 768 list_add_tail(&rport->qe, &port->rport_q);
790 port->num_rports++; 769 port->num_rports++;
791} 770}
792 771
793/** 772/*
794 * Called by rport module to when rports are deleted. 773 * Called by rport module to when rports are deleted.
795 */ 774 */
796void 775void
797bfa_fcs_port_del_rport(struct bfa_fcs_port_s *port, 776bfa_fcs_lport_del_rport(
798 struct bfa_fcs_rport_s *rport) 777 struct bfa_fcs_lport_s *port,
778 struct bfa_fcs_rport_s *rport)
799{ 779{
800 bfa_assert(bfa_q_is_on_q(&port->rport_q, rport)); 780 WARN_ON(!bfa_q_is_on_q(&port->rport_q, rport));
801 list_del(&rport->qe); 781 list_del(&rport->qe);
802 port->num_rports--; 782 port->num_rports--;
803 783
804 bfa_sm_send_event(port, BFA_FCS_PORT_SM_DELRPORT); 784 bfa_sm_send_event(port, BFA_FCS_PORT_SM_DELRPORT);
805} 785}
806 786
807/** 787/*
808 * Called by fabric for base port when fabric login is complete. 788 * Called by fabric for base port when fabric login is complete.
809 * Called by vport for virtual ports when FDISC is complete. 789 * Called by vport for virtual ports when FDISC is complete.
810 */ 790 */
811void 791void
812bfa_fcs_port_online(struct bfa_fcs_port_s *port) 792bfa_fcs_lport_online(struct bfa_fcs_lport_s *port)
813{ 793{
814 bfa_sm_send_event(port, BFA_FCS_PORT_SM_ONLINE); 794 bfa_sm_send_event(port, BFA_FCS_PORT_SM_ONLINE);
815} 795}
816 796
817/** 797/*
818 * Called by fabric for base port when fabric goes offline. 798 * Called by fabric for base port when fabric goes offline.
819 * Called by vport for virtual ports when virtual port becomes offline. 799 * Called by vport for virtual ports when virtual port becomes offline.
820 */ 800 */
821void 801void
822bfa_fcs_port_offline(struct bfa_fcs_port_s *port) 802bfa_fcs_lport_offline(struct bfa_fcs_lport_s *port)
823{ 803{
824 bfa_sm_send_event(port, BFA_FCS_PORT_SM_OFFLINE); 804 bfa_sm_send_event(port, BFA_FCS_PORT_SM_OFFLINE);
825} 805}
826 806
827/** 807/*
828 * Called by fabric to delete base lport and associated resources. 808 * Called by fabric to delete base lport and associated resources.
829 * 809 *
830 * Called by vport to delete lport and associated resources. Should call 810 * Called by vport to delete lport and associated resources. Should call
831 * bfa_fcs_vport_delete_comp() for vports on completion. 811 * bfa_fcs_vport_delete_comp() for vports on completion.
832 */ 812 */
833void 813void
834bfa_fcs_port_delete(struct bfa_fcs_port_s *port) 814bfa_fcs_lport_delete(struct bfa_fcs_lport_s *port)
835{ 815{
836 bfa_sm_send_event(port, BFA_FCS_PORT_SM_DELETE); 816 bfa_sm_send_event(port, BFA_FCS_PORT_SM_DELETE);
837} 817}
838 818
839/** 819/*
840 * Called by fabric in private loop topology to process LIP event.
841 */
842void
843bfa_fcs_port_lip(struct bfa_fcs_port_s *port)
844{
845}
846
847/**
848 * Return TRUE if port is online, else return FALSE 820 * Return TRUE if port is online, else return FALSE
849 */ 821 */
850bfa_boolean_t 822bfa_boolean_t
851bfa_fcs_port_is_online(struct bfa_fcs_port_s *port) 823bfa_fcs_lport_is_online(struct bfa_fcs_lport_s *port)
852{ 824{
853 return bfa_sm_cmp_state(port, bfa_fcs_port_sm_online); 825 return bfa_sm_cmp_state(port, bfa_fcs_lport_sm_online);
854} 826}
855 827
856/** 828/*
857 * Attach time initialization of logical ports. 829 * Attach time initialization of logical ports.
858 */ 830 */
859void 831void
860bfa_fcs_lport_attach(struct bfa_fcs_port_s *lport, struct bfa_fcs_s *fcs, 832bfa_fcs_lport_attach(struct bfa_fcs_lport_s *lport, struct bfa_fcs_s *fcs,
861 uint16_t vf_id, struct bfa_fcs_vport_s *vport) 833 u16 vf_id, struct bfa_fcs_vport_s *vport)
862{ 834{
863 lport->fcs = fcs; 835 lport->fcs = fcs;
864 lport->fabric = bfa_fcs_vf_lookup(fcs, vf_id); 836 lport->fabric = bfa_fcs_vf_lookup(fcs, vf_id);
865 lport->vport = vport; 837 lport->vport = vport;
866 lport->lp_tag = (vport) ? bfa_lps_get_tag(vport->lps) : 838 lport->lp_tag = (vport) ? vport->lps->lp_tag :
867 bfa_lps_get_tag(lport->fabric->lps); 839 lport->fabric->lps->lp_tag;
868 840
869 INIT_LIST_HEAD(&lport->rport_q); 841 INIT_LIST_HEAD(&lport->rport_q);
870 lport->num_rports = 0; 842 lport->num_rports = 0;
871} 843}
872 844
873/** 845/*
874 * Logical port initialization of base or virtual port. 846 * Logical port initialization of base or virtual port.
875 * Called by fabric for base port or by vport for virtual ports. 847 * Called by fabric for base port or by vport for virtual ports.
876 */ 848 */
877 849
878void 850void
879bfa_fcs_lport_init(struct bfa_fcs_port_s *lport, 851bfa_fcs_lport_init(struct bfa_fcs_lport_s *lport,
880 struct bfa_port_cfg_s *port_cfg) 852 struct bfa_lport_cfg_s *port_cfg)
881{ 853{
882 struct bfa_fcs_vport_s *vport = lport->vport; 854 struct bfa_fcs_vport_s *vport = lport->vport;
855 struct bfad_s *bfad = (struct bfad_s *)lport->fcs->bfad;
856 char lpwwn_buf[BFA_STRING_32];
883 857
884 bfa_os_assign(lport->port_cfg, *port_cfg); 858 lport->port_cfg = *port_cfg;
885 859
886 lport->bfad_port = bfa_fcb_port_new(lport->fcs->bfad, lport, 860 lport->bfad_port = bfa_fcb_lport_new(lport->fcs->bfad, lport,
887 lport->port_cfg.roles, 861 lport->port_cfg.roles,
888 lport->fabric->vf_drv, 862 lport->fabric->vf_drv,
889 vport ? vport->vport_drv : NULL); 863 vport ? vport->vport_drv : NULL);
890 864
891 bfa_fcs_port_aen_post(lport, BFA_LPORT_AEN_NEW); 865 wwn2str(lpwwn_buf, bfa_fcs_lport_get_pwwn(lport));
866 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
867 "New logical port created: WWN = %s Role = %s\n",
868 lpwwn_buf, "Initiator");
892 869
893 bfa_sm_set_state(lport, bfa_fcs_port_sm_uninit); 870 bfa_sm_set_state(lport, bfa_fcs_lport_sm_uninit);
894 bfa_sm_send_event(lport, BFA_FCS_PORT_SM_CREATE); 871 bfa_sm_send_event(lport, BFA_FCS_PORT_SM_CREATE);
895} 872}
896 873
897/** 874/*
898 * fcs_lport_api 875 * fcs_lport_api
899 */ 876 */
900 877
901void 878void
902bfa_fcs_port_get_attr(struct bfa_fcs_port_s *port, 879bfa_fcs_lport_get_attr(
903 struct bfa_port_attr_s *port_attr) 880 struct bfa_fcs_lport_s *port,
881 struct bfa_lport_attr_s *port_attr)
904{ 882{
905 if (bfa_sm_cmp_state(port, bfa_fcs_port_sm_online)) 883 if (bfa_sm_cmp_state(port, bfa_fcs_lport_sm_online))
906 port_attr->pid = port->pid; 884 port_attr->pid = port->pid;
907 else 885 else
908 port_attr->pid = 0; 886 port_attr->pid = 0;
@@ -910,28 +888,4825 @@ bfa_fcs_port_get_attr(struct bfa_fcs_port_s *port,
910 port_attr->port_cfg = port->port_cfg; 888 port_attr->port_cfg = port->port_cfg;
911 889
912 if (port->fabric) { 890 if (port->fabric) {
913 port_attr->port_type = bfa_fcs_fabric_port_type(port->fabric); 891 port_attr->port_type = port->fabric->oper_type;
914 port_attr->loopback = bfa_fcs_fabric_is_loopback(port->fabric); 892 port_attr->loopback = bfa_sm_cmp_state(port->fabric,
893 bfa_fcs_fabric_sm_loopback);
915 port_attr->authfail = 894 port_attr->authfail =
916 bfa_fcs_fabric_is_auth_failed(port->fabric); 895 bfa_sm_cmp_state(port->fabric,
917 port_attr->fabric_name = bfa_fcs_port_get_fabric_name(port); 896 bfa_fcs_fabric_sm_auth_failed);
897 port_attr->fabric_name = bfa_fcs_lport_get_fabric_name(port);
918 memcpy(port_attr->fabric_ip_addr, 898 memcpy(port_attr->fabric_ip_addr,
919 bfa_fcs_port_get_fabric_ipaddr(port), 899 bfa_fcs_lport_get_fabric_ipaddr(port),
920 BFA_FCS_FABRIC_IPADDR_SZ); 900 BFA_FCS_FABRIC_IPADDR_SZ);
921 901
922 if (port->vport != NULL) { 902 if (port->vport != NULL) {
923 port_attr->port_type = BFA_PPORT_TYPE_VPORT; 903 port_attr->port_type = BFA_PORT_TYPE_VPORT;
924 port_attr->fpma_mac = 904 port_attr->fpma_mac =
925 bfa_lps_get_lp_mac(port->vport->lps); 905 port->vport->lps->lp_mac;
926 } else 906 } else {
927 port_attr->fpma_mac = 907 port_attr->fpma_mac =
928 bfa_lps_get_lp_mac(port->fabric->lps); 908 port->fabric->lps->lp_mac;
909 }
910 } else {
911 port_attr->port_type = BFA_PORT_TYPE_UNKNOWN;
912 port_attr->state = BFA_LPORT_UNINIT;
913 }
914}
915
916/*
917 * bfa_fcs_lport_fab port fab functions
918 */
919
920/*
921 * Called by port to initialize fabric services of the base port.
922 */
923static void
924bfa_fcs_lport_fab_init(struct bfa_fcs_lport_s *port)
925{
926 bfa_fcs_lport_ns_init(port);
927 bfa_fcs_lport_scn_init(port);
928 bfa_fcs_lport_ms_init(port);
929}
930
931/*
932 * Called by port to notify transition to online state.
933 */
934static void
935bfa_fcs_lport_fab_online(struct bfa_fcs_lport_s *port)
936{
937 bfa_fcs_lport_ns_online(port);
938 bfa_fcs_lport_scn_online(port);
939}
940
941/*
942 * Called by port to notify transition to offline state.
943 */
944static void
945bfa_fcs_lport_fab_offline(struct bfa_fcs_lport_s *port)
946{
947 bfa_fcs_lport_ns_offline(port);
948 bfa_fcs_lport_scn_offline(port);
949 bfa_fcs_lport_ms_offline(port);
950}
951
952/*
953 * bfa_fcs_lport_n2n functions
954 */
955
956/*
957 * Called by fcs/port to initialize N2N topology.
958 */
959static void
960bfa_fcs_lport_n2n_init(struct bfa_fcs_lport_s *port)
961{
962}
963
964/*
965 * Called by fcs/port to notify transition to online state.
966 */
967static void
968bfa_fcs_lport_n2n_online(struct bfa_fcs_lport_s *port)
969{
970 struct bfa_fcs_lport_n2n_s *n2n_port = &port->port_topo.pn2n;
971 struct bfa_lport_cfg_s *pcfg = &port->port_cfg;
972 struct bfa_fcs_rport_s *rport;
973
974 bfa_trc(port->fcs, pcfg->pwwn);
975
976 /*
977 * If our PWWN is > than that of the r-port, we have to initiate PLOGI
978 * and assign an Address. if not, we need to wait for its PLOGI.
979 *
980 * If our PWWN is < than that of the remote port, it will send a PLOGI
981 * with the PIDs assigned. The rport state machine take care of this
982 * incoming PLOGI.
983 */
984 if (memcmp
985 ((void *)&pcfg->pwwn, (void *)&n2n_port->rem_port_wwn,
986 sizeof(wwn_t)) > 0) {
987 port->pid = N2N_LOCAL_PID;
988 bfa_lps_set_n2n_pid(port->fabric->lps, N2N_LOCAL_PID);
989 /*
990 * First, check if we know the device by pwwn.
991 */
992 rport = bfa_fcs_lport_get_rport_by_pwwn(port,
993 n2n_port->rem_port_wwn);
994 if (rport) {
995 bfa_trc(port->fcs, rport->pid);
996 bfa_trc(port->fcs, rport->pwwn);
997 rport->pid = N2N_REMOTE_PID;
998 bfa_sm_send_event(rport, RPSM_EVENT_PLOGI_SEND);
999 return;
1000 }
1001
1002 /*
1003 * In n2n there can be only one rport. Delete the old one
1004 * whose pid should be zero, because it is offline.
1005 */
1006 if (port->num_rports > 0) {
1007 rport = bfa_fcs_lport_get_rport_by_pid(port, 0);
1008 WARN_ON(rport == NULL);
1009 if (rport) {
1010 bfa_trc(port->fcs, rport->pwwn);
1011 bfa_sm_send_event(rport, RPSM_EVENT_DELETE);
1012 }
1013 }
1014 bfa_fcs_rport_create(port, N2N_REMOTE_PID);
1015 }
1016}
1017
1018/*
1019 * Called by fcs/port to notify transition to offline state.
1020 */
1021static void
1022bfa_fcs_lport_n2n_offline(struct bfa_fcs_lport_s *port)
1023{
1024 struct bfa_fcs_lport_n2n_s *n2n_port = &port->port_topo.pn2n;
1025
1026 bfa_trc(port->fcs, port->pid);
1027 port->pid = 0;
1028 n2n_port->rem_port_wwn = 0;
1029 n2n_port->reply_oxid = 0;
1030}
1031
1032#define BFA_FCS_FDMI_CMD_MAX_RETRIES 2
1033
1034/*
1035 * forward declarations
1036 */
1037static void bfa_fcs_lport_fdmi_send_rhba(void *fdmi_cbarg,
1038 struct bfa_fcxp_s *fcxp_alloced);
1039static void bfa_fcs_lport_fdmi_send_rprt(void *fdmi_cbarg,
1040 struct bfa_fcxp_s *fcxp_alloced);
1041static void bfa_fcs_lport_fdmi_send_rpa(void *fdmi_cbarg,
1042 struct bfa_fcxp_s *fcxp_alloced);
1043static void bfa_fcs_lport_fdmi_rhba_response(void *fcsarg,
1044 struct bfa_fcxp_s *fcxp,
1045 void *cbarg,
1046 bfa_status_t req_status,
1047 u32 rsp_len,
1048 u32 resid_len,
1049 struct fchs_s *rsp_fchs);
1050static void bfa_fcs_lport_fdmi_rprt_response(void *fcsarg,
1051 struct bfa_fcxp_s *fcxp,
1052 void *cbarg,
1053 bfa_status_t req_status,
1054 u32 rsp_len,
1055 u32 resid_len,
1056 struct fchs_s *rsp_fchs);
1057static void bfa_fcs_lport_fdmi_rpa_response(void *fcsarg,
1058 struct bfa_fcxp_s *fcxp,
1059 void *cbarg,
1060 bfa_status_t req_status,
1061 u32 rsp_len,
1062 u32 resid_len,
1063 struct fchs_s *rsp_fchs);
1064static void bfa_fcs_lport_fdmi_timeout(void *arg);
1065static u16 bfa_fcs_lport_fdmi_build_rhba_pyld(struct bfa_fcs_lport_fdmi_s *fdmi,
1066 u8 *pyld);
1067static u16 bfa_fcs_lport_fdmi_build_rprt_pyld(struct bfa_fcs_lport_fdmi_s *fdmi,
1068 u8 *pyld);
1069static u16 bfa_fcs_lport_fdmi_build_rpa_pyld(struct bfa_fcs_lport_fdmi_s *fdmi,
1070 u8 *pyld);
1071static u16 bfa_fcs_lport_fdmi_build_portattr_block(struct bfa_fcs_lport_fdmi_s *
1072 fdmi, u8 *pyld);
1073static void bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi,
1074 struct bfa_fcs_fdmi_hba_attr_s *hba_attr);
1075static void bfa_fcs_fdmi_get_portattr(struct bfa_fcs_lport_fdmi_s *fdmi,
1076 struct bfa_fcs_fdmi_port_attr_s *port_attr);
1077/*
1078 * fcs_fdmi_sm FCS FDMI state machine
1079 */
1080
1081/*
1082 * FDMI State Machine events
1083 */
1084enum port_fdmi_event {
1085 FDMISM_EVENT_PORT_ONLINE = 1,
1086 FDMISM_EVENT_PORT_OFFLINE = 2,
1087 FDMISM_EVENT_RSP_OK = 4,
1088 FDMISM_EVENT_RSP_ERROR = 5,
1089 FDMISM_EVENT_TIMEOUT = 6,
1090 FDMISM_EVENT_RHBA_SENT = 7,
1091 FDMISM_EVENT_RPRT_SENT = 8,
1092 FDMISM_EVENT_RPA_SENT = 9,
1093};
1094
1095static void bfa_fcs_lport_fdmi_sm_offline(struct bfa_fcs_lport_fdmi_s *fdmi,
1096 enum port_fdmi_event event);
1097static void bfa_fcs_lport_fdmi_sm_sending_rhba(
1098 struct bfa_fcs_lport_fdmi_s *fdmi,
1099 enum port_fdmi_event event);
1100static void bfa_fcs_lport_fdmi_sm_rhba(struct bfa_fcs_lport_fdmi_s *fdmi,
1101 enum port_fdmi_event event);
1102static void bfa_fcs_lport_fdmi_sm_rhba_retry(
1103 struct bfa_fcs_lport_fdmi_s *fdmi,
1104 enum port_fdmi_event event);
1105static void bfa_fcs_lport_fdmi_sm_sending_rprt(
1106 struct bfa_fcs_lport_fdmi_s *fdmi,
1107 enum port_fdmi_event event);
1108static void bfa_fcs_lport_fdmi_sm_rprt(struct bfa_fcs_lport_fdmi_s *fdmi,
1109 enum port_fdmi_event event);
1110static void bfa_fcs_lport_fdmi_sm_rprt_retry(
1111 struct bfa_fcs_lport_fdmi_s *fdmi,
1112 enum port_fdmi_event event);
1113static void bfa_fcs_lport_fdmi_sm_sending_rpa(
1114 struct bfa_fcs_lport_fdmi_s *fdmi,
1115 enum port_fdmi_event event);
1116static void bfa_fcs_lport_fdmi_sm_rpa(struct bfa_fcs_lport_fdmi_s *fdmi,
1117 enum port_fdmi_event event);
1118static void bfa_fcs_lport_fdmi_sm_rpa_retry(
1119 struct bfa_fcs_lport_fdmi_s *fdmi,
1120 enum port_fdmi_event event);
1121static void bfa_fcs_lport_fdmi_sm_online(struct bfa_fcs_lport_fdmi_s *fdmi,
1122 enum port_fdmi_event event);
1123static void bfa_fcs_lport_fdmi_sm_disabled(
1124 struct bfa_fcs_lport_fdmi_s *fdmi,
1125 enum port_fdmi_event event);
1126/*
1127 * Start in offline state - awaiting MS to send start.
1128 */
1129static void
1130bfa_fcs_lport_fdmi_sm_offline(struct bfa_fcs_lport_fdmi_s *fdmi,
1131 enum port_fdmi_event event)
1132{
1133 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1134
1135 bfa_trc(port->fcs, port->port_cfg.pwwn);
1136 bfa_trc(port->fcs, event);
1137
1138 fdmi->retry_cnt = 0;
1139
1140 switch (event) {
1141 case FDMISM_EVENT_PORT_ONLINE:
1142 if (port->vport) {
1143 /*
1144 * For Vports, register a new port.
1145 */
1146 bfa_sm_set_state(fdmi,
1147 bfa_fcs_lport_fdmi_sm_sending_rprt);
1148 bfa_fcs_lport_fdmi_send_rprt(fdmi, NULL);
1149 } else {
1150 /*
1151 * For a base port, we should first register the HBA
1152 * attribute. The HBA attribute also contains the base
1153 * port registration.
1154 */
1155 bfa_sm_set_state(fdmi,
1156 bfa_fcs_lport_fdmi_sm_sending_rhba);
1157 bfa_fcs_lport_fdmi_send_rhba(fdmi, NULL);
1158 }
1159 break;
1160
1161 case FDMISM_EVENT_PORT_OFFLINE:
1162 break;
1163
1164 default:
1165 bfa_sm_fault(port->fcs, event);
1166 }
1167}
1168
1169static void
1170bfa_fcs_lport_fdmi_sm_sending_rhba(struct bfa_fcs_lport_fdmi_s *fdmi,
1171 enum port_fdmi_event event)
1172{
1173 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1174
1175 bfa_trc(port->fcs, port->port_cfg.pwwn);
1176 bfa_trc(port->fcs, event);
1177
1178 switch (event) {
1179 case FDMISM_EVENT_RHBA_SENT:
1180 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_rhba);
1181 break;
1182
1183 case FDMISM_EVENT_PORT_OFFLINE:
1184 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1185 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port),
1186 &fdmi->fcxp_wqe);
1187 break;
1188
1189 default:
1190 bfa_sm_fault(port->fcs, event);
1191 }
1192}
1193
1194static void
1195bfa_fcs_lport_fdmi_sm_rhba(struct bfa_fcs_lport_fdmi_s *fdmi,
1196 enum port_fdmi_event event)
1197{
1198 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1199
1200 bfa_trc(port->fcs, port->port_cfg.pwwn);
1201 bfa_trc(port->fcs, event);
1202
1203 switch (event) {
1204 case FDMISM_EVENT_RSP_ERROR:
1205 /*
1206 * if max retries have not been reached, start timer for a
1207 * delayed retry
1208 */
1209 if (fdmi->retry_cnt++ < BFA_FCS_FDMI_CMD_MAX_RETRIES) {
1210 bfa_sm_set_state(fdmi,
1211 bfa_fcs_lport_fdmi_sm_rhba_retry);
1212 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port),
1213 &fdmi->timer,
1214 bfa_fcs_lport_fdmi_timeout, fdmi,
1215 BFA_FCS_RETRY_TIMEOUT);
1216 } else {
1217 /*
1218 * set state to offline
1219 */
1220 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1221 }
1222 break;
1223
1224 case FDMISM_EVENT_RSP_OK:
1225 /*
1226 * Initiate Register Port Attributes
1227 */
1228 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_sending_rpa);
1229 fdmi->retry_cnt = 0;
1230 bfa_fcs_lport_fdmi_send_rpa(fdmi, NULL);
1231 break;
1232
1233 case FDMISM_EVENT_PORT_OFFLINE:
1234 bfa_fcxp_discard(fdmi->fcxp);
1235 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1236 break;
1237
1238 default:
1239 bfa_sm_fault(port->fcs, event);
1240 }
1241}
1242
1243static void
1244bfa_fcs_lport_fdmi_sm_rhba_retry(struct bfa_fcs_lport_fdmi_s *fdmi,
1245 enum port_fdmi_event event)
1246{
1247 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1248
1249 bfa_trc(port->fcs, port->port_cfg.pwwn);
1250 bfa_trc(port->fcs, event);
1251
1252 switch (event) {
1253 case FDMISM_EVENT_TIMEOUT:
1254 /*
1255 * Retry Timer Expired. Re-send
1256 */
1257 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_sending_rhba);
1258 bfa_fcs_lport_fdmi_send_rhba(fdmi, NULL);
1259 break;
1260
1261 case FDMISM_EVENT_PORT_OFFLINE:
1262 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1263 bfa_timer_stop(&fdmi->timer);
1264 break;
1265
1266 default:
1267 bfa_sm_fault(port->fcs, event);
1268 }
1269}
1270
1271/*
1272* RPRT : Register Port
1273 */
1274static void
1275bfa_fcs_lport_fdmi_sm_sending_rprt(struct bfa_fcs_lport_fdmi_s *fdmi,
1276 enum port_fdmi_event event)
1277{
1278 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1279
1280 bfa_trc(port->fcs, port->port_cfg.pwwn);
1281 bfa_trc(port->fcs, event);
1282
1283 switch (event) {
1284 case FDMISM_EVENT_RPRT_SENT:
1285 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_rprt);
1286 break;
1287
1288 case FDMISM_EVENT_PORT_OFFLINE:
1289 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1290 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port),
1291 &fdmi->fcxp_wqe);
1292 break;
1293
1294 default:
1295 bfa_sm_fault(port->fcs, event);
1296 }
1297}
1298
1299static void
1300bfa_fcs_lport_fdmi_sm_rprt(struct bfa_fcs_lport_fdmi_s *fdmi,
1301 enum port_fdmi_event event)
1302{
1303 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1304
1305 bfa_trc(port->fcs, port->port_cfg.pwwn);
1306 bfa_trc(port->fcs, event);
1307
1308 switch (event) {
1309 case FDMISM_EVENT_RSP_ERROR:
1310 /*
1311 * if max retries have not been reached, start timer for a
1312 * delayed retry
1313 */
1314 if (fdmi->retry_cnt++ < BFA_FCS_FDMI_CMD_MAX_RETRIES) {
1315 bfa_sm_set_state(fdmi,
1316 bfa_fcs_lport_fdmi_sm_rprt_retry);
1317 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port),
1318 &fdmi->timer,
1319 bfa_fcs_lport_fdmi_timeout, fdmi,
1320 BFA_FCS_RETRY_TIMEOUT);
1321
1322 } else {
1323 /*
1324 * set state to offline
1325 */
1326 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1327 fdmi->retry_cnt = 0;
1328 }
1329 break;
1330
1331 case FDMISM_EVENT_RSP_OK:
1332 fdmi->retry_cnt = 0;
1333 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_online);
1334 break;
1335
1336 case FDMISM_EVENT_PORT_OFFLINE:
1337 bfa_fcxp_discard(fdmi->fcxp);
1338 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1339 break;
1340
1341 default:
1342 bfa_sm_fault(port->fcs, event);
1343 }
1344}
1345
1346static void
1347bfa_fcs_lport_fdmi_sm_rprt_retry(struct bfa_fcs_lport_fdmi_s *fdmi,
1348 enum port_fdmi_event event)
1349{
1350 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1351
1352 bfa_trc(port->fcs, port->port_cfg.pwwn);
1353 bfa_trc(port->fcs, event);
1354
1355 switch (event) {
1356 case FDMISM_EVENT_TIMEOUT:
1357 /*
1358 * Retry Timer Expired. Re-send
1359 */
1360 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_sending_rprt);
1361 bfa_fcs_lport_fdmi_send_rprt(fdmi, NULL);
1362 break;
1363
1364 case FDMISM_EVENT_PORT_OFFLINE:
1365 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1366 bfa_timer_stop(&fdmi->timer);
1367 break;
1368
1369 default:
1370 bfa_sm_fault(port->fcs, event);
1371 }
1372}
1373
1374/*
1375 * Register Port Attributes
1376 */
1377static void
1378bfa_fcs_lport_fdmi_sm_sending_rpa(struct bfa_fcs_lport_fdmi_s *fdmi,
1379 enum port_fdmi_event event)
1380{
1381 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1382
1383 bfa_trc(port->fcs, port->port_cfg.pwwn);
1384 bfa_trc(port->fcs, event);
1385
1386 switch (event) {
1387 case FDMISM_EVENT_RPA_SENT:
1388 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_rpa);
1389 break;
1390
1391 case FDMISM_EVENT_PORT_OFFLINE:
1392 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1393 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port),
1394 &fdmi->fcxp_wqe);
1395 break;
1396
1397 default:
1398 bfa_sm_fault(port->fcs, event);
1399 }
1400}
1401
1402static void
1403bfa_fcs_lport_fdmi_sm_rpa(struct bfa_fcs_lport_fdmi_s *fdmi,
1404 enum port_fdmi_event event)
1405{
1406 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1407
1408 bfa_trc(port->fcs, port->port_cfg.pwwn);
1409 bfa_trc(port->fcs, event);
1410
1411 switch (event) {
1412 case FDMISM_EVENT_RSP_ERROR:
1413 /*
1414 * if max retries have not been reached, start timer for a
1415 * delayed retry
1416 */
1417 if (fdmi->retry_cnt++ < BFA_FCS_FDMI_CMD_MAX_RETRIES) {
1418 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_rpa_retry);
1419 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port),
1420 &fdmi->timer,
1421 bfa_fcs_lport_fdmi_timeout, fdmi,
1422 BFA_FCS_RETRY_TIMEOUT);
1423 } else {
1424 /*
1425 * set state to offline
1426 */
1427 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1428 fdmi->retry_cnt = 0;
1429 }
1430 break;
1431
1432 case FDMISM_EVENT_RSP_OK:
1433 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_online);
1434 fdmi->retry_cnt = 0;
1435 break;
1436
1437 case FDMISM_EVENT_PORT_OFFLINE:
1438 bfa_fcxp_discard(fdmi->fcxp);
1439 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1440 break;
1441
1442 default:
1443 bfa_sm_fault(port->fcs, event);
1444 }
1445}
1446
1447static void
1448bfa_fcs_lport_fdmi_sm_rpa_retry(struct bfa_fcs_lport_fdmi_s *fdmi,
1449 enum port_fdmi_event event)
1450{
1451 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1452
1453 bfa_trc(port->fcs, port->port_cfg.pwwn);
1454 bfa_trc(port->fcs, event);
1455
1456 switch (event) {
1457 case FDMISM_EVENT_TIMEOUT:
1458 /*
1459 * Retry Timer Expired. Re-send
1460 */
1461 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_sending_rpa);
1462 bfa_fcs_lport_fdmi_send_rpa(fdmi, NULL);
1463 break;
1464
1465 case FDMISM_EVENT_PORT_OFFLINE:
1466 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1467 bfa_timer_stop(&fdmi->timer);
1468 break;
1469
1470 default:
1471 bfa_sm_fault(port->fcs, event);
1472 }
1473}
1474
1475static void
1476bfa_fcs_lport_fdmi_sm_online(struct bfa_fcs_lport_fdmi_s *fdmi,
1477 enum port_fdmi_event event)
1478{
1479 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1480
1481 bfa_trc(port->fcs, port->port_cfg.pwwn);
1482 bfa_trc(port->fcs, event);
1483
1484 switch (event) {
1485 case FDMISM_EVENT_PORT_OFFLINE:
1486 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
1487 break;
1488
1489 default:
1490 bfa_sm_fault(port->fcs, event);
1491 }
1492}
1493/*
1494 * FDMI is disabled state.
1495 */
1496static void
1497bfa_fcs_lport_fdmi_sm_disabled(struct bfa_fcs_lport_fdmi_s *fdmi,
1498 enum port_fdmi_event event)
1499{
1500 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1501
1502 bfa_trc(port->fcs, port->port_cfg.pwwn);
1503 bfa_trc(port->fcs, event);
1504
1505 /* No op State. It can only be enabled at Driver Init. */
1506}
1507
1508/*
1509* RHBA : Register HBA Attributes.
1510 */
1511static void
1512bfa_fcs_lport_fdmi_send_rhba(void *fdmi_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1513{
1514 struct bfa_fcs_lport_fdmi_s *fdmi = fdmi_cbarg;
1515 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1516 struct fchs_s fchs;
1517 int len, attr_len;
1518 struct bfa_fcxp_s *fcxp;
1519 u8 *pyld;
1520
1521 bfa_trc(port->fcs, port->port_cfg.pwwn);
1522
1523 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
1524 if (!fcxp) {
1525 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &fdmi->fcxp_wqe,
1526 bfa_fcs_lport_fdmi_send_rhba, fdmi);
1527 return;
1528 }
1529 fdmi->fcxp = fcxp;
1530
1531 pyld = bfa_fcxp_get_reqbuf(fcxp);
1532 memset(pyld, 0, FC_MAX_PDUSZ);
1533
1534 len = fc_fdmi_reqhdr_build(&fchs, pyld, bfa_fcs_lport_get_fcid(port),
1535 FDMI_RHBA);
1536
1537 attr_len =
1538 bfa_fcs_lport_fdmi_build_rhba_pyld(fdmi,
1539 (u8 *) ((struct ct_hdr_s *) pyld
1540 + 1));
1541
1542 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1543 FC_CLASS_3, (len + attr_len), &fchs,
1544 bfa_fcs_lport_fdmi_rhba_response, (void *)fdmi,
1545 FC_MAX_PDUSZ, FC_FCCT_TOV);
1546
1547 bfa_sm_send_event(fdmi, FDMISM_EVENT_RHBA_SENT);
1548}
1549
1550static u16
1551bfa_fcs_lport_fdmi_build_rhba_pyld(struct bfa_fcs_lport_fdmi_s *fdmi, u8 *pyld)
1552{
1553 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1554 struct bfa_fcs_fdmi_hba_attr_s hba_attr;
1555 struct bfa_fcs_fdmi_hba_attr_s *fcs_hba_attr = &hba_attr;
1556 struct fdmi_rhba_s *rhba = (struct fdmi_rhba_s *) pyld;
1557 struct fdmi_attr_s *attr;
1558 u8 *curr_ptr;
1559 u16 len, count;
1560 u16 templen;
1561
1562 /*
1563 * get hba attributes
1564 */
1565 bfa_fcs_fdmi_get_hbaattr(fdmi, fcs_hba_attr);
1566
1567 rhba->hba_id = bfa_fcs_lport_get_pwwn(port);
1568 rhba->port_list.num_ports = cpu_to_be32(1);
1569 rhba->port_list.port_entry = bfa_fcs_lport_get_pwwn(port);
1570
1571 len = sizeof(rhba->hba_id) + sizeof(rhba->port_list);
1572
1573 count = 0;
1574 len += sizeof(rhba->hba_attr_blk.attr_count);
1575
1576 /*
1577 * fill out the invididual entries of the HBA attrib Block
1578 */
1579 curr_ptr = (u8 *) &rhba->hba_attr_blk.hba_attr;
1580
1581 /*
1582 * Node Name
1583 */
1584 attr = (struct fdmi_attr_s *) curr_ptr;
1585 attr->type = cpu_to_be16(FDMI_HBA_ATTRIB_NODENAME);
1586 templen = sizeof(wwn_t);
1587 memcpy(attr->value, &bfa_fcs_lport_get_nwwn(port), templen);
1588 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1589 len += templen;
1590 count++;
1591 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1592 sizeof(templen));
1593
1594 /*
1595 * Manufacturer
1596 */
1597 attr = (struct fdmi_attr_s *) curr_ptr;
1598 attr->type = cpu_to_be16(FDMI_HBA_ATTRIB_MANUFACTURER);
1599 templen = (u16) strlen(fcs_hba_attr->manufacturer);
1600 memcpy(attr->value, fcs_hba_attr->manufacturer, templen);
1601 templen = fc_roundup(templen, sizeof(u32));
1602 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1603 len += templen;
1604 count++;
1605 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1606 sizeof(templen));
1607
1608 /*
1609 * Serial Number
1610 */
1611 attr = (struct fdmi_attr_s *) curr_ptr;
1612 attr->type = cpu_to_be16(FDMI_HBA_ATTRIB_SERIALNUM);
1613 templen = (u16) strlen(fcs_hba_attr->serial_num);
1614 memcpy(attr->value, fcs_hba_attr->serial_num, templen);
1615 templen = fc_roundup(templen, sizeof(u32));
1616 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1617 len += templen;
1618 count++;
1619 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1620 sizeof(templen));
1621
1622 /*
1623 * Model
1624 */
1625 attr = (struct fdmi_attr_s *) curr_ptr;
1626 attr->type = cpu_to_be16(FDMI_HBA_ATTRIB_MODEL);
1627 templen = (u16) strlen(fcs_hba_attr->model);
1628 memcpy(attr->value, fcs_hba_attr->model, templen);
1629 templen = fc_roundup(templen, sizeof(u32));
1630 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1631 len += templen;
1632 count++;
1633 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1634 sizeof(templen));
1635
1636 /*
1637 * Model Desc
1638 */
1639 attr = (struct fdmi_attr_s *) curr_ptr;
1640 attr->type = cpu_to_be16(FDMI_HBA_ATTRIB_MODEL_DESC);
1641 templen = (u16) strlen(fcs_hba_attr->model_desc);
1642 memcpy(attr->value, fcs_hba_attr->model_desc, templen);
1643 templen = fc_roundup(templen, sizeof(u32));
1644 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1645 len += templen;
1646 count++;
1647 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1648 sizeof(templen));
1649
1650 /*
1651 * H/W Version
1652 */
1653 if (fcs_hba_attr->hw_version[0] != '\0') {
1654 attr = (struct fdmi_attr_s *) curr_ptr;
1655 attr->type = cpu_to_be16(FDMI_HBA_ATTRIB_HW_VERSION);
1656 templen = (u16) strlen(fcs_hba_attr->hw_version);
1657 memcpy(attr->value, fcs_hba_attr->hw_version, templen);
1658 templen = fc_roundup(templen, sizeof(u32));
1659 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1660 len += templen;
1661 count++;
1662 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1663 sizeof(templen));
1664 }
1665
1666 /*
1667 * Driver Version
1668 */
1669 attr = (struct fdmi_attr_s *) curr_ptr;
1670 attr->type = cpu_to_be16(FDMI_HBA_ATTRIB_DRIVER_VERSION);
1671 templen = (u16) strlen(fcs_hba_attr->driver_version);
1672 memcpy(attr->value, fcs_hba_attr->driver_version, templen);
1673 templen = fc_roundup(templen, sizeof(u32));
1674 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1675 len += templen;;
1676 count++;
1677 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1678 sizeof(templen));
1679
1680 /*
1681 * Option Rom Version
1682 */
1683 if (fcs_hba_attr->option_rom_ver[0] != '\0') {
1684 attr = (struct fdmi_attr_s *) curr_ptr;
1685 attr->type = cpu_to_be16(FDMI_HBA_ATTRIB_ROM_VERSION);
1686 templen = (u16) strlen(fcs_hba_attr->option_rom_ver);
1687 memcpy(attr->value, fcs_hba_attr->option_rom_ver, templen);
1688 templen = fc_roundup(templen, sizeof(u32));
1689 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1690 len += templen;
1691 count++;
1692 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1693 sizeof(templen));
1694 }
1695
1696 /*
1697 * f/w Version = driver version
1698 */
1699 attr = (struct fdmi_attr_s *) curr_ptr;
1700 attr->type = cpu_to_be16(FDMI_HBA_ATTRIB_FW_VERSION);
1701 templen = (u16) strlen(fcs_hba_attr->driver_version);
1702 memcpy(attr->value, fcs_hba_attr->driver_version, templen);
1703 templen = fc_roundup(templen, sizeof(u32));
1704 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1705 len += templen;
1706 count++;
1707 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1708 sizeof(templen));
1709
1710 /*
1711 * OS Name
1712 */
1713 if (fcs_hba_attr->os_name[0] != '\0') {
1714 attr = (struct fdmi_attr_s *) curr_ptr;
1715 attr->type = cpu_to_be16(FDMI_HBA_ATTRIB_OS_NAME);
1716 templen = (u16) strlen(fcs_hba_attr->os_name);
1717 memcpy(attr->value, fcs_hba_attr->os_name, templen);
1718 templen = fc_roundup(templen, sizeof(u32));
1719 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1720 len += templen;
1721 count++;
1722 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1723 sizeof(templen));
1724 }
1725
1726 /*
1727 * MAX_CT_PAYLOAD
1728 */
1729 attr = (struct fdmi_attr_s *) curr_ptr;
1730 attr->type = cpu_to_be16(FDMI_HBA_ATTRIB_MAX_CT);
1731 templen = sizeof(fcs_hba_attr->max_ct_pyld);
1732 memcpy(attr->value, &fcs_hba_attr->max_ct_pyld, templen);
1733 len += templen;
1734 count++;
1735 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1736 sizeof(templen));
1737
1738 /*
1739 * Update size of payload
1740 */
1741 len += ((sizeof(attr->type) + sizeof(attr->len)) * count);
1742
1743 rhba->hba_attr_blk.attr_count = cpu_to_be32(count);
1744 return len;
1745}
1746
1747static void
1748bfa_fcs_lport_fdmi_rhba_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
1749 void *cbarg, bfa_status_t req_status,
1750 u32 rsp_len, u32 resid_len,
1751 struct fchs_s *rsp_fchs)
1752{
1753 struct bfa_fcs_lport_fdmi_s *fdmi =
1754 (struct bfa_fcs_lport_fdmi_s *) cbarg;
1755 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1756 struct ct_hdr_s *cthdr = NULL;
1757
1758 bfa_trc(port->fcs, port->port_cfg.pwwn);
1759
1760 /*
1761 * Sanity Checks
1762 */
1763 if (req_status != BFA_STATUS_OK) {
1764 bfa_trc(port->fcs, req_status);
1765 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
1766 return;
1767 }
1768
1769 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
1770 cthdr->cmd_rsp_code = be16_to_cpu(cthdr->cmd_rsp_code);
1771
1772 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
1773 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_OK);
1774 return;
1775 }
1776
1777 bfa_trc(port->fcs, cthdr->reason_code);
1778 bfa_trc(port->fcs, cthdr->exp_code);
1779 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
1780}
1781
1782/*
1783* RPRT : Register Port
1784 */
1785static void
1786bfa_fcs_lport_fdmi_send_rprt(void *fdmi_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1787{
1788 struct bfa_fcs_lport_fdmi_s *fdmi = fdmi_cbarg;
1789 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1790 struct fchs_s fchs;
1791 u16 len, attr_len;
1792 struct bfa_fcxp_s *fcxp;
1793 u8 *pyld;
1794
1795 bfa_trc(port->fcs, port->port_cfg.pwwn);
1796
1797 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
1798 if (!fcxp) {
1799 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &fdmi->fcxp_wqe,
1800 bfa_fcs_lport_fdmi_send_rprt, fdmi);
1801 return;
1802 }
1803 fdmi->fcxp = fcxp;
1804
1805 pyld = bfa_fcxp_get_reqbuf(fcxp);
1806 memset(pyld, 0, FC_MAX_PDUSZ);
1807
1808 len = fc_fdmi_reqhdr_build(&fchs, pyld, bfa_fcs_lport_get_fcid(port),
1809 FDMI_RPRT);
1810
1811 attr_len =
1812 bfa_fcs_lport_fdmi_build_rprt_pyld(fdmi,
1813 (u8 *) ((struct ct_hdr_s *) pyld
1814 + 1));
1815
1816 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1817 FC_CLASS_3, len + attr_len, &fchs,
1818 bfa_fcs_lport_fdmi_rprt_response, (void *)fdmi,
1819 FC_MAX_PDUSZ, FC_FCCT_TOV);
1820
1821 bfa_sm_send_event(fdmi, FDMISM_EVENT_RPRT_SENT);
1822}
1823
1824/*
1825 * This routine builds Port Attribute Block that used in RPA, RPRT commands.
1826 */
1827static u16
1828bfa_fcs_lport_fdmi_build_portattr_block(struct bfa_fcs_lport_fdmi_s *fdmi,
1829 u8 *pyld)
1830{
1831 struct bfa_fcs_fdmi_port_attr_s fcs_port_attr;
1832 struct fdmi_port_attr_s *port_attrib = (struct fdmi_port_attr_s *) pyld;
1833 struct fdmi_attr_s *attr;
1834 u8 *curr_ptr;
1835 u16 len;
1836 u8 count = 0;
1837 u16 templen;
1838
1839 /*
1840 * get port attributes
1841 */
1842 bfa_fcs_fdmi_get_portattr(fdmi, &fcs_port_attr);
1843
1844 len = sizeof(port_attrib->attr_count);
1845
1846 /*
1847 * fill out the invididual entries
1848 */
1849 curr_ptr = (u8 *) &port_attrib->port_attr;
1850
1851 /*
1852 * FC4 Types
1853 */
1854 attr = (struct fdmi_attr_s *) curr_ptr;
1855 attr->type = cpu_to_be16(FDMI_PORT_ATTRIB_FC4_TYPES);
1856 templen = sizeof(fcs_port_attr.supp_fc4_types);
1857 memcpy(attr->value, fcs_port_attr.supp_fc4_types, templen);
1858 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1859 len += templen;
1860 ++count;
1861 attr->len =
1862 cpu_to_be16(templen + sizeof(attr->type) +
1863 sizeof(templen));
1864
1865 /*
1866 * Supported Speed
1867 */
1868 attr = (struct fdmi_attr_s *) curr_ptr;
1869 attr->type = cpu_to_be16(FDMI_PORT_ATTRIB_SUPP_SPEED);
1870 templen = sizeof(fcs_port_attr.supp_speed);
1871 memcpy(attr->value, &fcs_port_attr.supp_speed, templen);
1872 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1873 len += templen;
1874 ++count;
1875 attr->len =
1876 cpu_to_be16(templen + sizeof(attr->type) +
1877 sizeof(templen));
1878
1879 /*
1880 * current Port Speed
1881 */
1882 attr = (struct fdmi_attr_s *) curr_ptr;
1883 attr->type = cpu_to_be16(FDMI_PORT_ATTRIB_PORT_SPEED);
1884 templen = sizeof(fcs_port_attr.curr_speed);
1885 memcpy(attr->value, &fcs_port_attr.curr_speed, templen);
1886 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1887 len += templen;
1888 ++count;
1889 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1890 sizeof(templen));
1891
1892 /*
1893 * max frame size
1894 */
1895 attr = (struct fdmi_attr_s *) curr_ptr;
1896 attr->type = cpu_to_be16(FDMI_PORT_ATTRIB_FRAME_SIZE);
1897 templen = sizeof(fcs_port_attr.max_frm_size);
1898 memcpy(attr->value, &fcs_port_attr.max_frm_size, templen);
1899 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1900 len += templen;
1901 ++count;
1902 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1903 sizeof(templen));
1904
1905 /*
1906 * OS Device Name
1907 */
1908 if (fcs_port_attr.os_device_name[0] != '\0') {
1909 attr = (struct fdmi_attr_s *) curr_ptr;
1910 attr->type = cpu_to_be16(FDMI_PORT_ATTRIB_DEV_NAME);
1911 templen = (u16) strlen(fcs_port_attr.os_device_name);
1912 memcpy(attr->value, fcs_port_attr.os_device_name, templen);
1913 templen = fc_roundup(templen, sizeof(u32));
1914 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1915 len += templen;
1916 ++count;
1917 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1918 sizeof(templen));
1919 }
1920 /*
1921 * Host Name
1922 */
1923 if (fcs_port_attr.host_name[0] != '\0') {
1924 attr = (struct fdmi_attr_s *) curr_ptr;
1925 attr->type = cpu_to_be16(FDMI_PORT_ATTRIB_HOST_NAME);
1926 templen = (u16) strlen(fcs_port_attr.host_name);
1927 memcpy(attr->value, fcs_port_attr.host_name, templen);
1928 templen = fc_roundup(templen, sizeof(u32));
1929 curr_ptr += sizeof(attr->type) + sizeof(templen) + templen;
1930 len += templen;
1931 ++count;
1932 attr->len = cpu_to_be16(templen + sizeof(attr->type) +
1933 sizeof(templen));
1934 }
1935
1936 /*
1937 * Update size of payload
1938 */
1939 port_attrib->attr_count = cpu_to_be32(count);
1940 len += ((sizeof(attr->type) + sizeof(attr->len)) * count);
1941 return len;
1942}
1943
1944static u16
1945bfa_fcs_lport_fdmi_build_rprt_pyld(struct bfa_fcs_lport_fdmi_s *fdmi, u8 *pyld)
1946{
1947 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1948 struct fdmi_rprt_s *rprt = (struct fdmi_rprt_s *) pyld;
1949 u16 len;
1950
1951 rprt->hba_id = bfa_fcs_lport_get_pwwn(bfa_fcs_get_base_port(port->fcs));
1952 rprt->port_name = bfa_fcs_lport_get_pwwn(port);
1953
1954 len = bfa_fcs_lport_fdmi_build_portattr_block(fdmi,
1955 (u8 *) &rprt->port_attr_blk);
1956
1957 len += sizeof(rprt->hba_id) + sizeof(rprt->port_name);
1958
1959 return len;
1960}
1961
1962static void
1963bfa_fcs_lport_fdmi_rprt_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
1964 void *cbarg, bfa_status_t req_status,
1965 u32 rsp_len, u32 resid_len,
1966 struct fchs_s *rsp_fchs)
1967{
1968 struct bfa_fcs_lport_fdmi_s *fdmi =
1969 (struct bfa_fcs_lport_fdmi_s *) cbarg;
1970 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1971 struct ct_hdr_s *cthdr = NULL;
1972
1973 bfa_trc(port->fcs, port->port_cfg.pwwn);
1974
1975 /*
1976 * Sanity Checks
1977 */
1978 if (req_status != BFA_STATUS_OK) {
1979 bfa_trc(port->fcs, req_status);
1980 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
1981 return;
1982 }
1983
1984 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
1985 cthdr->cmd_rsp_code = be16_to_cpu(cthdr->cmd_rsp_code);
1986
1987 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
1988 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_OK);
1989 return;
1990 }
1991
1992 bfa_trc(port->fcs, cthdr->reason_code);
1993 bfa_trc(port->fcs, cthdr->exp_code);
1994 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
1995}
1996
1997/*
1998* RPA : Register Port Attributes.
1999 */
2000static void
2001bfa_fcs_lport_fdmi_send_rpa(void *fdmi_cbarg, struct bfa_fcxp_s *fcxp_alloced)
2002{
2003 struct bfa_fcs_lport_fdmi_s *fdmi = fdmi_cbarg;
2004 struct bfa_fcs_lport_s *port = fdmi->ms->port;
2005 struct fchs_s fchs;
2006 u16 len, attr_len;
2007 struct bfa_fcxp_s *fcxp;
2008 u8 *pyld;
2009
2010 bfa_trc(port->fcs, port->port_cfg.pwwn);
2011
2012 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
2013 if (!fcxp) {
2014 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &fdmi->fcxp_wqe,
2015 bfa_fcs_lport_fdmi_send_rpa, fdmi);
2016 return;
2017 }
2018 fdmi->fcxp = fcxp;
2019
2020 pyld = bfa_fcxp_get_reqbuf(fcxp);
2021 memset(pyld, 0, FC_MAX_PDUSZ);
2022
2023 len = fc_fdmi_reqhdr_build(&fchs, pyld, bfa_fcs_lport_get_fcid(port),
2024 FDMI_RPA);
2025
2026 attr_len = bfa_fcs_lport_fdmi_build_rpa_pyld(fdmi,
2027 (u8 *) ((struct ct_hdr_s *) pyld + 1));
2028
2029 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
2030 FC_CLASS_3, len + attr_len, &fchs,
2031 bfa_fcs_lport_fdmi_rpa_response, (void *)fdmi,
2032 FC_MAX_PDUSZ, FC_FCCT_TOV);
2033
2034 bfa_sm_send_event(fdmi, FDMISM_EVENT_RPA_SENT);
2035}
2036
2037static u16
2038bfa_fcs_lport_fdmi_build_rpa_pyld(struct bfa_fcs_lport_fdmi_s *fdmi, u8 *pyld)
2039{
2040 struct bfa_fcs_lport_s *port = fdmi->ms->port;
2041 struct fdmi_rpa_s *rpa = (struct fdmi_rpa_s *) pyld;
2042 u16 len;
2043
2044 rpa->port_name = bfa_fcs_lport_get_pwwn(port);
2045
2046 len = bfa_fcs_lport_fdmi_build_portattr_block(fdmi,
2047 (u8 *) &rpa->port_attr_blk);
2048
2049 len += sizeof(rpa->port_name);
2050
2051 return len;
2052}
2053
2054static void
2055bfa_fcs_lport_fdmi_rpa_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
2056 void *cbarg, bfa_status_t req_status, u32 rsp_len,
2057 u32 resid_len, struct fchs_s *rsp_fchs)
2058{
2059 struct bfa_fcs_lport_fdmi_s *fdmi =
2060 (struct bfa_fcs_lport_fdmi_s *) cbarg;
2061 struct bfa_fcs_lport_s *port = fdmi->ms->port;
2062 struct ct_hdr_s *cthdr = NULL;
2063
2064 bfa_trc(port->fcs, port->port_cfg.pwwn);
2065
2066 /*
2067 * Sanity Checks
2068 */
2069 if (req_status != BFA_STATUS_OK) {
2070 bfa_trc(port->fcs, req_status);
2071 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
2072 return;
2073 }
2074
2075 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
2076 cthdr->cmd_rsp_code = be16_to_cpu(cthdr->cmd_rsp_code);
2077
2078 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
2079 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_OK);
2080 return;
2081 }
2082
2083 bfa_trc(port->fcs, cthdr->reason_code);
2084 bfa_trc(port->fcs, cthdr->exp_code);
2085 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
2086}
2087
2088static void
2089bfa_fcs_lport_fdmi_timeout(void *arg)
2090{
2091 struct bfa_fcs_lport_fdmi_s *fdmi = (struct bfa_fcs_lport_fdmi_s *) arg;
2092
2093 bfa_sm_send_event(fdmi, FDMISM_EVENT_TIMEOUT);
2094}
2095
2096static void
2097bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi,
2098 struct bfa_fcs_fdmi_hba_attr_s *hba_attr)
2099{
2100 struct bfa_fcs_lport_s *port = fdmi->ms->port;
2101 struct bfa_fcs_driver_info_s *driver_info = &port->fcs->driver_info;
2102
2103 memset(hba_attr, 0, sizeof(struct bfa_fcs_fdmi_hba_attr_s));
2104
2105 bfa_ioc_get_adapter_manufacturer(&port->fcs->bfa->ioc,
2106 hba_attr->manufacturer);
2107 bfa_ioc_get_adapter_serial_num(&port->fcs->bfa->ioc,
2108 hba_attr->serial_num);
2109 bfa_ioc_get_adapter_model(&port->fcs->bfa->ioc,
2110 hba_attr->model);
2111 bfa_ioc_get_adapter_model(&port->fcs->bfa->ioc,
2112 hba_attr->model_desc);
2113 bfa_ioc_get_pci_chip_rev(&port->fcs->bfa->ioc,
2114 hba_attr->hw_version);
2115 bfa_ioc_get_adapter_optrom_ver(&port->fcs->bfa->ioc,
2116 hba_attr->option_rom_ver);
2117 bfa_ioc_get_adapter_fw_ver(&port->fcs->bfa->ioc,
2118 hba_attr->fw_version);
2119
2120 strncpy(hba_attr->driver_version, (char *)driver_info->version,
2121 sizeof(hba_attr->driver_version));
2122
2123 strncpy(hba_attr->os_name, driver_info->host_os_name,
2124 sizeof(hba_attr->os_name));
2125
2126 /*
2127 * If there is a patch level, append it
2128 * to the os name along with a separator
2129 */
2130 if (driver_info->host_os_patch[0] != '\0') {
2131 strncat(hba_attr->os_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
2132 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
2133 strncat(hba_attr->os_name, driver_info->host_os_patch,
2134 sizeof(driver_info->host_os_patch));
2135 }
2136
2137 hba_attr->max_ct_pyld = cpu_to_be32(FC_MAX_PDUSZ);
2138}
2139
2140static void
2141bfa_fcs_fdmi_get_portattr(struct bfa_fcs_lport_fdmi_s *fdmi,
2142 struct bfa_fcs_fdmi_port_attr_s *port_attr)
2143{
2144 struct bfa_fcs_lport_s *port = fdmi->ms->port;
2145 struct bfa_fcs_driver_info_s *driver_info = &port->fcs->driver_info;
2146 struct bfa_port_attr_s pport_attr;
2147
2148 memset(port_attr, 0, sizeof(struct bfa_fcs_fdmi_port_attr_s));
2149
2150 /*
2151 * get pport attributes from hal
2152 */
2153 bfa_fcport_get_attr(port->fcs->bfa, &pport_attr);
2154
2155 /*
2156 * get FC4 type Bitmask
2157 */
2158 fc_get_fc4type_bitmask(FC_TYPE_FCP, port_attr->supp_fc4_types);
2159
2160 /*
2161 * Supported Speeds
2162 */
2163 port_attr->supp_speed = cpu_to_be32(BFA_FCS_FDMI_SUPORTED_SPEEDS);
2164
2165 /*
2166 * Current Speed
2167 */
2168 port_attr->curr_speed = cpu_to_be32(pport_attr.speed);
2169
2170 /*
2171 * Max PDU Size.
2172 */
2173 port_attr->max_frm_size = cpu_to_be32(FC_MAX_PDUSZ);
2174
2175 /*
2176 * OS device Name
2177 */
2178 strncpy(port_attr->os_device_name, (char *)driver_info->os_device_name,
2179 sizeof(port_attr->os_device_name));
2180
2181 /*
2182 * Host name
2183 */
2184 strncpy(port_attr->host_name, (char *)driver_info->host_machine_name,
2185 sizeof(port_attr->host_name));
2186
2187}
2188
2189
2190void
2191bfa_fcs_lport_fdmi_init(struct bfa_fcs_lport_ms_s *ms)
2192{
2193 struct bfa_fcs_lport_fdmi_s *fdmi = &ms->fdmi;
2194
2195 fdmi->ms = ms;
2196 if (ms->port->fcs->fdmi_enabled)
2197 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_offline);
2198 else
2199 bfa_sm_set_state(fdmi, bfa_fcs_lport_fdmi_sm_disabled);
2200}
2201
2202void
2203bfa_fcs_lport_fdmi_offline(struct bfa_fcs_lport_ms_s *ms)
2204{
2205 struct bfa_fcs_lport_fdmi_s *fdmi = &ms->fdmi;
2206
2207 fdmi->ms = ms;
2208 bfa_sm_send_event(fdmi, FDMISM_EVENT_PORT_OFFLINE);
2209}
2210
2211void
2212bfa_fcs_lport_fdmi_online(struct bfa_fcs_lport_ms_s *ms)
2213{
2214 struct bfa_fcs_lport_fdmi_s *fdmi = &ms->fdmi;
2215
2216 fdmi->ms = ms;
2217 bfa_sm_send_event(fdmi, FDMISM_EVENT_PORT_ONLINE);
2218}
2219
2220#define BFA_FCS_MS_CMD_MAX_RETRIES 2
2221
2222/*
2223 * forward declarations
2224 */
2225static void bfa_fcs_lport_ms_send_plogi(void *ms_cbarg,
2226 struct bfa_fcxp_s *fcxp_alloced);
2227static void bfa_fcs_lport_ms_timeout(void *arg);
2228static void bfa_fcs_lport_ms_plogi_response(void *fcsarg,
2229 struct bfa_fcxp_s *fcxp,
2230 void *cbarg,
2231 bfa_status_t req_status,
2232 u32 rsp_len,
2233 u32 resid_len,
2234 struct fchs_s *rsp_fchs);
2235
2236static void bfa_fcs_lport_ms_send_gmal(void *ms_cbarg,
2237 struct bfa_fcxp_s *fcxp_alloced);
2238static void bfa_fcs_lport_ms_gmal_response(void *fcsarg,
2239 struct bfa_fcxp_s *fcxp,
2240 void *cbarg,
2241 bfa_status_t req_status,
2242 u32 rsp_len,
2243 u32 resid_len,
2244 struct fchs_s *rsp_fchs);
2245static void bfa_fcs_lport_ms_send_gfn(void *ms_cbarg,
2246 struct bfa_fcxp_s *fcxp_alloced);
2247static void bfa_fcs_lport_ms_gfn_response(void *fcsarg,
2248 struct bfa_fcxp_s *fcxp,
2249 void *cbarg,
2250 bfa_status_t req_status,
2251 u32 rsp_len,
2252 u32 resid_len,
2253 struct fchs_s *rsp_fchs);
2254/*
2255 * fcs_ms_sm FCS MS state machine
2256 */
2257
2258/*
2259 * MS State Machine events
2260 */
2261enum port_ms_event {
2262 MSSM_EVENT_PORT_ONLINE = 1,
2263 MSSM_EVENT_PORT_OFFLINE = 2,
2264 MSSM_EVENT_RSP_OK = 3,
2265 MSSM_EVENT_RSP_ERROR = 4,
2266 MSSM_EVENT_TIMEOUT = 5,
2267 MSSM_EVENT_FCXP_SENT = 6,
2268 MSSM_EVENT_PORT_FABRIC_RSCN = 7
2269};
2270
2271static void bfa_fcs_lport_ms_sm_offline(struct bfa_fcs_lport_ms_s *ms,
2272 enum port_ms_event event);
2273static void bfa_fcs_lport_ms_sm_plogi_sending(struct bfa_fcs_lport_ms_s *ms,
2274 enum port_ms_event event);
2275static void bfa_fcs_lport_ms_sm_plogi(struct bfa_fcs_lport_ms_s *ms,
2276 enum port_ms_event event);
2277static void bfa_fcs_lport_ms_sm_plogi_retry(struct bfa_fcs_lport_ms_s *ms,
2278 enum port_ms_event event);
2279static void bfa_fcs_lport_ms_sm_gmal_sending(struct bfa_fcs_lport_ms_s *ms,
2280 enum port_ms_event event);
2281static void bfa_fcs_lport_ms_sm_gmal(struct bfa_fcs_lport_ms_s *ms,
2282 enum port_ms_event event);
2283static void bfa_fcs_lport_ms_sm_gmal_retry(struct bfa_fcs_lport_ms_s *ms,
2284 enum port_ms_event event);
2285static void bfa_fcs_lport_ms_sm_gfn_sending(struct bfa_fcs_lport_ms_s *ms,
2286 enum port_ms_event event);
2287static void bfa_fcs_lport_ms_sm_gfn(struct bfa_fcs_lport_ms_s *ms,
2288 enum port_ms_event event);
2289static void bfa_fcs_lport_ms_sm_gfn_retry(struct bfa_fcs_lport_ms_s *ms,
2290 enum port_ms_event event);
2291static void bfa_fcs_lport_ms_sm_online(struct bfa_fcs_lport_ms_s *ms,
2292 enum port_ms_event event);
2293/*
2294 * Start in offline state - awaiting NS to send start.
2295 */
2296static void
2297bfa_fcs_lport_ms_sm_offline(struct bfa_fcs_lport_ms_s *ms,
2298 enum port_ms_event event)
2299{
2300 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
2301 bfa_trc(ms->port->fcs, event);
2302
2303 switch (event) {
2304 case MSSM_EVENT_PORT_ONLINE:
2305 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_plogi_sending);
2306 bfa_fcs_lport_ms_send_plogi(ms, NULL);
2307 break;
2308
2309 case MSSM_EVENT_PORT_OFFLINE:
2310 break;
2311
2312 default:
2313 bfa_sm_fault(ms->port->fcs, event);
2314 }
2315}
2316
2317static void
2318bfa_fcs_lport_ms_sm_plogi_sending(struct bfa_fcs_lport_ms_s *ms,
2319 enum port_ms_event event)
2320{
2321 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
2322 bfa_trc(ms->port->fcs, event);
2323
2324 switch (event) {
2325 case MSSM_EVENT_FCXP_SENT:
2326 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_plogi);
2327 break;
2328
2329 case MSSM_EVENT_PORT_OFFLINE:
2330 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_offline);
2331 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms->port),
2332 &ms->fcxp_wqe);
2333 break;
2334
2335 default:
2336 bfa_sm_fault(ms->port->fcs, event);
2337 }
2338}
2339
2340static void
2341bfa_fcs_lport_ms_sm_plogi(struct bfa_fcs_lport_ms_s *ms,
2342 enum port_ms_event event)
2343{
2344 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
2345 bfa_trc(ms->port->fcs, event);
2346
2347 switch (event) {
2348 case MSSM_EVENT_RSP_ERROR:
2349 /*
2350 * Start timer for a delayed retry
2351 */
2352 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_plogi_retry);
2353 ms->port->stats.ms_retries++;
2354 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms->port),
2355 &ms->timer, bfa_fcs_lport_ms_timeout, ms,
2356 BFA_FCS_RETRY_TIMEOUT);
2357 break;
2358
2359 case MSSM_EVENT_RSP_OK:
2360 /*
2361 * since plogi is done, now invoke MS related sub-modules
2362 */
2363 bfa_fcs_lport_fdmi_online(ms);
2364
2365 /*
2366 * if this is a Vport, go to online state.
2367 */
2368 if (ms->port->vport) {
2369 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_online);
2370 break;
2371 }
2372
2373 /*
2374 * For a base port we need to get the
2375 * switch's IP address.
2376 */
2377 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_gmal_sending);
2378 bfa_fcs_lport_ms_send_gmal(ms, NULL);
2379 break;
2380
2381 case MSSM_EVENT_PORT_OFFLINE:
2382 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_offline);
2383 bfa_fcxp_discard(ms->fcxp);
2384 break;
2385
2386 default:
2387 bfa_sm_fault(ms->port->fcs, event);
2388 }
2389}
2390
2391static void
2392bfa_fcs_lport_ms_sm_plogi_retry(struct bfa_fcs_lport_ms_s *ms,
2393 enum port_ms_event event)
2394{
2395 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
2396 bfa_trc(ms->port->fcs, event);
2397
2398 switch (event) {
2399 case MSSM_EVENT_TIMEOUT:
2400 /*
2401 * Retry Timer Expired. Re-send
2402 */
2403 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_plogi_sending);
2404 bfa_fcs_lport_ms_send_plogi(ms, NULL);
2405 break;
2406
2407 case MSSM_EVENT_PORT_OFFLINE:
2408 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_offline);
2409 bfa_timer_stop(&ms->timer);
2410 break;
2411
2412 default:
2413 bfa_sm_fault(ms->port->fcs, event);
2414 }
2415}
2416
2417static void
2418bfa_fcs_lport_ms_sm_online(struct bfa_fcs_lport_ms_s *ms,
2419 enum port_ms_event event)
2420{
2421 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
2422 bfa_trc(ms->port->fcs, event);
2423
2424 switch (event) {
2425 case MSSM_EVENT_PORT_OFFLINE:
2426 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_offline);
2427 break;
2428
2429 case MSSM_EVENT_PORT_FABRIC_RSCN:
2430 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_gfn_sending);
2431 ms->retry_cnt = 0;
2432 bfa_fcs_lport_ms_send_gfn(ms, NULL);
2433 break;
2434
2435 default:
2436 bfa_sm_fault(ms->port->fcs, event);
2437 }
2438}
2439
2440static void
2441bfa_fcs_lport_ms_sm_gmal_sending(struct bfa_fcs_lport_ms_s *ms,
2442 enum port_ms_event event)
2443{
2444 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
2445 bfa_trc(ms->port->fcs, event);
2446
2447 switch (event) {
2448 case MSSM_EVENT_FCXP_SENT:
2449 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_gmal);
2450 break;
2451
2452 case MSSM_EVENT_PORT_OFFLINE:
2453 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_offline);
2454 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms->port),
2455 &ms->fcxp_wqe);
2456 break;
2457
2458 default:
2459 bfa_sm_fault(ms->port->fcs, event);
2460 }
2461}
2462
2463static void
2464bfa_fcs_lport_ms_sm_gmal(struct bfa_fcs_lport_ms_s *ms,
2465 enum port_ms_event event)
2466{
2467 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
2468 bfa_trc(ms->port->fcs, event);
2469
2470 switch (event) {
2471 case MSSM_EVENT_RSP_ERROR:
2472 /*
2473 * Start timer for a delayed retry
2474 */
2475 if (ms->retry_cnt++ < BFA_FCS_MS_CMD_MAX_RETRIES) {
2476 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_gmal_retry);
2477 ms->port->stats.ms_retries++;
2478 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms->port),
2479 &ms->timer, bfa_fcs_lport_ms_timeout, ms,
2480 BFA_FCS_RETRY_TIMEOUT);
2481 } else {
2482 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_gfn_sending);
2483 bfa_fcs_lport_ms_send_gfn(ms, NULL);
2484 ms->retry_cnt = 0;
2485 }
2486 break;
2487
2488 case MSSM_EVENT_RSP_OK:
2489 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_gfn_sending);
2490 bfa_fcs_lport_ms_send_gfn(ms, NULL);
2491 break;
2492
2493 case MSSM_EVENT_PORT_OFFLINE:
2494 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_offline);
2495 bfa_fcxp_discard(ms->fcxp);
2496 break;
2497
2498 default:
2499 bfa_sm_fault(ms->port->fcs, event);
2500 }
2501}
2502
2503static void
2504bfa_fcs_lport_ms_sm_gmal_retry(struct bfa_fcs_lport_ms_s *ms,
2505 enum port_ms_event event)
2506{
2507 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
2508 bfa_trc(ms->port->fcs, event);
2509
2510 switch (event) {
2511 case MSSM_EVENT_TIMEOUT:
2512 /*
2513 * Retry Timer Expired. Re-send
2514 */
2515 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_gmal_sending);
2516 bfa_fcs_lport_ms_send_gmal(ms, NULL);
2517 break;
2518
2519 case MSSM_EVENT_PORT_OFFLINE:
2520 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_offline);
2521 bfa_timer_stop(&ms->timer);
2522 break;
2523
2524 default:
2525 bfa_sm_fault(ms->port->fcs, event);
2526 }
2527}
2528/*
2529 * ms_pvt MS local functions
2530 */
2531
2532static void
2533bfa_fcs_lport_ms_send_gmal(void *ms_cbarg, struct bfa_fcxp_s *fcxp_alloced)
2534{
2535 struct bfa_fcs_lport_ms_s *ms = ms_cbarg;
2536 bfa_fcs_lport_t *port = ms->port;
2537 struct fchs_s fchs;
2538 int len;
2539 struct bfa_fcxp_s *fcxp;
2540
2541 bfa_trc(port->fcs, port->pid);
2542
2543 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
2544 if (!fcxp) {
2545 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ms->fcxp_wqe,
2546 bfa_fcs_lport_ms_send_gmal, ms);
2547 return;
2548 }
2549 ms->fcxp = fcxp;
2550
2551 len = fc_gmal_req_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
2552 bfa_fcs_lport_get_fcid(port),
2553 port->fabric->lps->pr_nwwn);
2554
2555 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
2556 FC_CLASS_3, len, &fchs,
2557 bfa_fcs_lport_ms_gmal_response, (void *)ms,
2558 FC_MAX_PDUSZ, FC_FCCT_TOV);
2559
2560 bfa_sm_send_event(ms, MSSM_EVENT_FCXP_SENT);
2561}
2562
2563static void
2564bfa_fcs_lport_ms_gmal_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
2565 void *cbarg, bfa_status_t req_status,
2566 u32 rsp_len, u32 resid_len,
2567 struct fchs_s *rsp_fchs)
2568{
2569 struct bfa_fcs_lport_ms_s *ms = (struct bfa_fcs_lport_ms_s *) cbarg;
2570 bfa_fcs_lport_t *port = ms->port;
2571 struct ct_hdr_s *cthdr = NULL;
2572 struct fcgs_gmal_resp_s *gmal_resp;
2573 struct fcgs_gmal_entry_s *gmal_entry;
2574 u32 num_entries;
2575 u8 *rsp_str;
2576
2577 bfa_trc(port->fcs, req_status);
2578 bfa_trc(port->fcs, port->port_cfg.pwwn);
2579
2580 /*
2581 * Sanity Checks
2582 */
2583 if (req_status != BFA_STATUS_OK) {
2584 bfa_trc(port->fcs, req_status);
2585 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
2586 return;
2587 }
2588
2589 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
2590 cthdr->cmd_rsp_code = be16_to_cpu(cthdr->cmd_rsp_code);
2591
2592 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
2593 gmal_resp = (struct fcgs_gmal_resp_s *)(cthdr + 1);
2594
2595 num_entries = be32_to_cpu(gmal_resp->ms_len);
2596 if (num_entries == 0) {
2597 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
2598 return;
2599 }
2600 /*
2601 * The response could contain multiple Entries.
2602 * Entries for SNMP interface, etc.
2603 * We look for the entry with a telnet prefix.
2604 * First "http://" entry refers to IP addr
2605 */
2606
2607 gmal_entry = (struct fcgs_gmal_entry_s *)gmal_resp->ms_ma;
2608 while (num_entries > 0) {
2609 if (strncmp(gmal_entry->prefix,
2610 CT_GMAL_RESP_PREFIX_HTTP,
2611 sizeof(gmal_entry->prefix)) == 0) {
2612
2613 /*
2614 * if the IP address is terminating with a '/',
2615 * remove it.
2616 * Byte 0 consists of the length of the string.
2617 */
2618 rsp_str = &(gmal_entry->prefix[0]);
2619 if (rsp_str[gmal_entry->len-1] == '/')
2620 rsp_str[gmal_entry->len-1] = 0;
2621
2622 /* copy IP Address to fabric */
2623 strncpy(bfa_fcs_lport_get_fabric_ipaddr(port),
2624 gmal_entry->ip_addr,
2625 BFA_FCS_FABRIC_IPADDR_SZ);
2626 break;
2627 } else {
2628 --num_entries;
2629 ++gmal_entry;
2630 }
2631 }
2632
2633 bfa_sm_send_event(ms, MSSM_EVENT_RSP_OK);
2634 return;
2635 }
2636
2637 bfa_trc(port->fcs, cthdr->reason_code);
2638 bfa_trc(port->fcs, cthdr->exp_code);
2639 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
2640}
2641
2642static void
2643bfa_fcs_lport_ms_sm_gfn_sending(struct bfa_fcs_lport_ms_s *ms,
2644 enum port_ms_event event)
2645{
2646 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
2647 bfa_trc(ms->port->fcs, event);
2648
2649 switch (event) {
2650 case MSSM_EVENT_FCXP_SENT:
2651 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_gfn);
2652 break;
2653
2654 case MSSM_EVENT_PORT_OFFLINE:
2655 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_offline);
2656 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms->port),
2657 &ms->fcxp_wqe);
2658 break;
2659
2660 default:
2661 bfa_sm_fault(ms->port->fcs, event);
2662 }
2663}
2664
2665static void
2666bfa_fcs_lport_ms_sm_gfn(struct bfa_fcs_lport_ms_s *ms,
2667 enum port_ms_event event)
2668{
2669 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
2670 bfa_trc(ms->port->fcs, event);
2671
2672 switch (event) {
2673 case MSSM_EVENT_RSP_ERROR:
2674 /*
2675 * Start timer for a delayed retry
2676 */
2677 if (ms->retry_cnt++ < BFA_FCS_MS_CMD_MAX_RETRIES) {
2678 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_gfn_retry);
2679 ms->port->stats.ms_retries++;
2680 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms->port),
2681 &ms->timer, bfa_fcs_lport_ms_timeout, ms,
2682 BFA_FCS_RETRY_TIMEOUT);
2683 } else {
2684 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_online);
2685 ms->retry_cnt = 0;
2686 }
2687 break;
2688
2689 case MSSM_EVENT_RSP_OK:
2690 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_online);
2691 break;
2692
2693 case MSSM_EVENT_PORT_OFFLINE:
2694 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_offline);
2695 bfa_fcxp_discard(ms->fcxp);
2696 break;
2697
2698 default:
2699 bfa_sm_fault(ms->port->fcs, event);
2700 }
2701}
2702
2703static void
2704bfa_fcs_lport_ms_sm_gfn_retry(struct bfa_fcs_lport_ms_s *ms,
2705 enum port_ms_event event)
2706{
2707 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
2708 bfa_trc(ms->port->fcs, event);
2709
2710 switch (event) {
2711 case MSSM_EVENT_TIMEOUT:
2712 /*
2713 * Retry Timer Expired. Re-send
2714 */
2715 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_gfn_sending);
2716 bfa_fcs_lport_ms_send_gfn(ms, NULL);
2717 break;
2718
2719 case MSSM_EVENT_PORT_OFFLINE:
2720 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_offline);
2721 bfa_timer_stop(&ms->timer);
2722 break;
2723
2724 default:
2725 bfa_sm_fault(ms->port->fcs, event);
2726 }
2727}
2728/*
2729 * ms_pvt MS local functions
2730 */
2731
2732static void
2733bfa_fcs_lport_ms_send_gfn(void *ms_cbarg, struct bfa_fcxp_s *fcxp_alloced)
2734{
2735 struct bfa_fcs_lport_ms_s *ms = ms_cbarg;
2736 bfa_fcs_lport_t *port = ms->port;
2737 struct fchs_s fchs;
2738 int len;
2739 struct bfa_fcxp_s *fcxp;
2740
2741 bfa_trc(port->fcs, port->pid);
2742
2743 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
2744 if (!fcxp) {
2745 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ms->fcxp_wqe,
2746 bfa_fcs_lport_ms_send_gfn, ms);
2747 return;
2748 }
2749 ms->fcxp = fcxp;
2750
2751 len = fc_gfn_req_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
2752 bfa_fcs_lport_get_fcid(port),
2753 port->fabric->lps->pr_nwwn);
2754
2755 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
2756 FC_CLASS_3, len, &fchs,
2757 bfa_fcs_lport_ms_gfn_response, (void *)ms,
2758 FC_MAX_PDUSZ, FC_FCCT_TOV);
2759
2760 bfa_sm_send_event(ms, MSSM_EVENT_FCXP_SENT);
2761}
2762
2763static void
2764bfa_fcs_lport_ms_gfn_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
2765 void *cbarg, bfa_status_t req_status, u32 rsp_len,
2766 u32 resid_len, struct fchs_s *rsp_fchs)
2767{
2768 struct bfa_fcs_lport_ms_s *ms = (struct bfa_fcs_lport_ms_s *) cbarg;
2769 bfa_fcs_lport_t *port = ms->port;
2770 struct ct_hdr_s *cthdr = NULL;
2771 wwn_t *gfn_resp;
2772
2773 bfa_trc(port->fcs, req_status);
2774 bfa_trc(port->fcs, port->port_cfg.pwwn);
2775
2776 /*
2777 * Sanity Checks
2778 */
2779 if (req_status != BFA_STATUS_OK) {
2780 bfa_trc(port->fcs, req_status);
2781 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
2782 return;
2783 }
2784
2785 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
2786 cthdr->cmd_rsp_code = be16_to_cpu(cthdr->cmd_rsp_code);
2787
2788 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
2789 gfn_resp = (wwn_t *)(cthdr + 1);
2790 /* check if it has actually changed */
2791 if ((memcmp((void *)&bfa_fcs_lport_get_fabric_name(port),
2792 gfn_resp, sizeof(wwn_t)) != 0)) {
2793 bfa_fcs_fabric_set_fabric_name(port->fabric, *gfn_resp);
2794 }
2795 bfa_sm_send_event(ms, MSSM_EVENT_RSP_OK);
2796 return;
2797 }
2798
2799 bfa_trc(port->fcs, cthdr->reason_code);
2800 bfa_trc(port->fcs, cthdr->exp_code);
2801 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
2802}
2803
2804/*
2805 * ms_pvt MS local functions
2806 */
2807
2808static void
2809bfa_fcs_lport_ms_send_plogi(void *ms_cbarg, struct bfa_fcxp_s *fcxp_alloced)
2810{
2811 struct bfa_fcs_lport_ms_s *ms = ms_cbarg;
2812 struct bfa_fcs_lport_s *port = ms->port;
2813 struct fchs_s fchs;
2814 int len;
2815 struct bfa_fcxp_s *fcxp;
2816
2817 bfa_trc(port->fcs, port->pid);
2818
2819 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
2820 if (!fcxp) {
2821 port->stats.ms_plogi_alloc_wait++;
2822 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ms->fcxp_wqe,
2823 bfa_fcs_lport_ms_send_plogi, ms);
2824 return;
2825 }
2826 ms->fcxp = fcxp;
2827
2828 len = fc_plogi_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
2829 bfa_hton3b(FC_MGMT_SERVER),
2830 bfa_fcs_lport_get_fcid(port), 0,
2831 port->port_cfg.pwwn, port->port_cfg.nwwn,
2832 bfa_fcport_get_maxfrsize(port->fcs->bfa));
2833
2834 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
2835 FC_CLASS_3, len, &fchs,
2836 bfa_fcs_lport_ms_plogi_response, (void *)ms,
2837 FC_MAX_PDUSZ, FC_ELS_TOV);
2838
2839 port->stats.ms_plogi_sent++;
2840 bfa_sm_send_event(ms, MSSM_EVENT_FCXP_SENT);
2841}
2842
2843static void
2844bfa_fcs_lport_ms_plogi_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
2845 void *cbarg, bfa_status_t req_status,
2846 u32 rsp_len, u32 resid_len, struct fchs_s *rsp_fchs)
2847{
2848 struct bfa_fcs_lport_ms_s *ms = (struct bfa_fcs_lport_ms_s *) cbarg;
2849 struct bfa_fcs_lport_s *port = ms->port;
2850 struct fc_els_cmd_s *els_cmd;
2851 struct fc_ls_rjt_s *ls_rjt;
2852
2853 bfa_trc(port->fcs, req_status);
2854 bfa_trc(port->fcs, port->port_cfg.pwwn);
2855
2856 /*
2857 * Sanity Checks
2858 */
2859 if (req_status != BFA_STATUS_OK) {
2860 port->stats.ms_plogi_rsp_err++;
2861 bfa_trc(port->fcs, req_status);
2862 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
2863 return;
2864 }
2865
2866 els_cmd = (struct fc_els_cmd_s *) BFA_FCXP_RSP_PLD(fcxp);
2867
2868 switch (els_cmd->els_code) {
2869
2870 case FC_ELS_ACC:
2871 if (rsp_len < sizeof(struct fc_logi_s)) {
2872 bfa_trc(port->fcs, rsp_len);
2873 port->stats.ms_plogi_acc_err++;
2874 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
2875 break;
2876 }
2877 port->stats.ms_plogi_accepts++;
2878 bfa_sm_send_event(ms, MSSM_EVENT_RSP_OK);
2879 break;
2880
2881 case FC_ELS_LS_RJT:
2882 ls_rjt = (struct fc_ls_rjt_s *) BFA_FCXP_RSP_PLD(fcxp);
2883
2884 bfa_trc(port->fcs, ls_rjt->reason_code);
2885 bfa_trc(port->fcs, ls_rjt->reason_code_expl);
2886
2887 port->stats.ms_rejects++;
2888 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
2889 break;
2890
2891 default:
2892 port->stats.ms_plogi_unknown_rsp++;
2893 bfa_trc(port->fcs, els_cmd->els_code);
2894 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
2895 }
2896}
2897
2898static void
2899bfa_fcs_lport_ms_timeout(void *arg)
2900{
2901 struct bfa_fcs_lport_ms_s *ms = (struct bfa_fcs_lport_ms_s *) arg;
2902
2903 ms->port->stats.ms_timeouts++;
2904 bfa_sm_send_event(ms, MSSM_EVENT_TIMEOUT);
2905}
2906
2907
2908void
2909bfa_fcs_lport_ms_init(struct bfa_fcs_lport_s *port)
2910{
2911 struct bfa_fcs_lport_ms_s *ms = BFA_FCS_GET_MS_FROM_PORT(port);
2912
2913 ms->port = port;
2914 bfa_sm_set_state(ms, bfa_fcs_lport_ms_sm_offline);
2915
2916 /*
2917 * Invoke init routines of sub modules.
2918 */
2919 bfa_fcs_lport_fdmi_init(ms);
2920}
2921
2922void
2923bfa_fcs_lport_ms_offline(struct bfa_fcs_lport_s *port)
2924{
2925 struct bfa_fcs_lport_ms_s *ms = BFA_FCS_GET_MS_FROM_PORT(port);
2926
2927 ms->port = port;
2928 bfa_sm_send_event(ms, MSSM_EVENT_PORT_OFFLINE);
2929 bfa_fcs_lport_fdmi_offline(ms);
2930}
2931
2932void
2933bfa_fcs_lport_ms_online(struct bfa_fcs_lport_s *port)
2934{
2935 struct bfa_fcs_lport_ms_s *ms = BFA_FCS_GET_MS_FROM_PORT(port);
2936
2937 ms->port = port;
2938 bfa_sm_send_event(ms, MSSM_EVENT_PORT_ONLINE);
2939}
2940void
2941bfa_fcs_lport_ms_fabric_rscn(struct bfa_fcs_lport_s *port)
2942{
2943 struct bfa_fcs_lport_ms_s *ms = BFA_FCS_GET_MS_FROM_PORT(port);
2944
2945 /* todo. Handle this only when in Online state */
2946 if (bfa_sm_cmp_state(ms, bfa_fcs_lport_ms_sm_online))
2947 bfa_sm_send_event(ms, MSSM_EVENT_PORT_FABRIC_RSCN);
2948}
2949
2950/*
2951 * @page ns_sm_info VPORT NS State Machine
2952 *
2953 * @section ns_sm_interactions VPORT NS State Machine Interactions
2954 *
2955 * @section ns_sm VPORT NS State Machine
2956 * img ns_sm.jpg
2957 */
2958
2959/*
2960 * forward declarations
2961 */
2962static void bfa_fcs_lport_ns_send_plogi(void *ns_cbarg,
2963 struct bfa_fcxp_s *fcxp_alloced);
2964static void bfa_fcs_lport_ns_send_rspn_id(void *ns_cbarg,
2965 struct bfa_fcxp_s *fcxp_alloced);
2966static void bfa_fcs_lport_ns_send_rft_id(void *ns_cbarg,
2967 struct bfa_fcxp_s *fcxp_alloced);
2968static void bfa_fcs_lport_ns_send_rff_id(void *ns_cbarg,
2969 struct bfa_fcxp_s *fcxp_alloced);
2970static void bfa_fcs_lport_ns_send_gid_ft(void *ns_cbarg,
2971 struct bfa_fcxp_s *fcxp_alloced);
2972static void bfa_fcs_lport_ns_timeout(void *arg);
2973static void bfa_fcs_lport_ns_plogi_response(void *fcsarg,
2974 struct bfa_fcxp_s *fcxp,
2975 void *cbarg,
2976 bfa_status_t req_status,
2977 u32 rsp_len,
2978 u32 resid_len,
2979 struct fchs_s *rsp_fchs);
2980static void bfa_fcs_lport_ns_rspn_id_response(void *fcsarg,
2981 struct bfa_fcxp_s *fcxp,
2982 void *cbarg,
2983 bfa_status_t req_status,
2984 u32 rsp_len,
2985 u32 resid_len,
2986 struct fchs_s *rsp_fchs);
2987static void bfa_fcs_lport_ns_rft_id_response(void *fcsarg,
2988 struct bfa_fcxp_s *fcxp,
2989 void *cbarg,
2990 bfa_status_t req_status,
2991 u32 rsp_len,
2992 u32 resid_len,
2993 struct fchs_s *rsp_fchs);
2994static void bfa_fcs_lport_ns_rff_id_response(void *fcsarg,
2995 struct bfa_fcxp_s *fcxp,
2996 void *cbarg,
2997 bfa_status_t req_status,
2998 u32 rsp_len,
2999 u32 resid_len,
3000 struct fchs_s *rsp_fchs);
3001static void bfa_fcs_lport_ns_gid_ft_response(void *fcsarg,
3002 struct bfa_fcxp_s *fcxp,
3003 void *cbarg,
3004 bfa_status_t req_status,
3005 u32 rsp_len,
3006 u32 resid_len,
3007 struct fchs_s *rsp_fchs);
3008static void bfa_fcs_lport_ns_process_gidft_pids(
3009 struct bfa_fcs_lport_s *port,
3010 u32 *pid_buf, u32 n_pids);
3011
3012static void bfa_fcs_lport_ns_boot_target_disc(bfa_fcs_lport_t *port);
3013/*
3014 * fcs_ns_sm FCS nameserver interface state machine
3015 */
3016
3017/*
3018 * VPort NS State Machine events
3019 */
3020enum vport_ns_event {
3021 NSSM_EVENT_PORT_ONLINE = 1,
3022 NSSM_EVENT_PORT_OFFLINE = 2,
3023 NSSM_EVENT_PLOGI_SENT = 3,
3024 NSSM_EVENT_RSP_OK = 4,
3025 NSSM_EVENT_RSP_ERROR = 5,
3026 NSSM_EVENT_TIMEOUT = 6,
3027 NSSM_EVENT_NS_QUERY = 7,
3028 NSSM_EVENT_RSPNID_SENT = 8,
3029 NSSM_EVENT_RFTID_SENT = 9,
3030 NSSM_EVENT_RFFID_SENT = 10,
3031 NSSM_EVENT_GIDFT_SENT = 11,
3032};
3033
3034static void bfa_fcs_lport_ns_sm_offline(struct bfa_fcs_lport_ns_s *ns,
3035 enum vport_ns_event event);
3036static void bfa_fcs_lport_ns_sm_plogi_sending(struct bfa_fcs_lport_ns_s *ns,
3037 enum vport_ns_event event);
3038static void bfa_fcs_lport_ns_sm_plogi(struct bfa_fcs_lport_ns_s *ns,
3039 enum vport_ns_event event);
3040static void bfa_fcs_lport_ns_sm_plogi_retry(struct bfa_fcs_lport_ns_s *ns,
3041 enum vport_ns_event event);
3042static void bfa_fcs_lport_ns_sm_sending_rspn_id(
3043 struct bfa_fcs_lport_ns_s *ns,
3044 enum vport_ns_event event);
3045static void bfa_fcs_lport_ns_sm_rspn_id(struct bfa_fcs_lport_ns_s *ns,
3046 enum vport_ns_event event);
3047static void bfa_fcs_lport_ns_sm_rspn_id_retry(struct bfa_fcs_lport_ns_s *ns,
3048 enum vport_ns_event event);
3049static void bfa_fcs_lport_ns_sm_sending_rft_id(
3050 struct bfa_fcs_lport_ns_s *ns,
3051 enum vport_ns_event event);
3052static void bfa_fcs_lport_ns_sm_rft_id_retry(struct bfa_fcs_lport_ns_s *ns,
3053 enum vport_ns_event event);
3054static void bfa_fcs_lport_ns_sm_rft_id(struct bfa_fcs_lport_ns_s *ns,
3055 enum vport_ns_event event);
3056static void bfa_fcs_lport_ns_sm_sending_rff_id(
3057 struct bfa_fcs_lport_ns_s *ns,
3058 enum vport_ns_event event);
3059static void bfa_fcs_lport_ns_sm_rff_id_retry(struct bfa_fcs_lport_ns_s *ns,
3060 enum vport_ns_event event);
3061static void bfa_fcs_lport_ns_sm_rff_id(struct bfa_fcs_lport_ns_s *ns,
3062 enum vport_ns_event event);
3063static void bfa_fcs_lport_ns_sm_sending_gid_ft(
3064 struct bfa_fcs_lport_ns_s *ns,
3065 enum vport_ns_event event);
3066static void bfa_fcs_lport_ns_sm_gid_ft(struct bfa_fcs_lport_ns_s *ns,
3067 enum vport_ns_event event);
3068static void bfa_fcs_lport_ns_sm_gid_ft_retry(struct bfa_fcs_lport_ns_s *ns,
3069 enum vport_ns_event event);
3070static void bfa_fcs_lport_ns_sm_online(struct bfa_fcs_lport_ns_s *ns,
3071 enum vport_ns_event event);
3072/*
3073 * Start in offline state - awaiting linkup
3074 */
3075static void
3076bfa_fcs_lport_ns_sm_offline(struct bfa_fcs_lport_ns_s *ns,
3077 enum vport_ns_event event)
3078{
3079 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3080 bfa_trc(ns->port->fcs, event);
3081
3082 switch (event) {
3083 case NSSM_EVENT_PORT_ONLINE:
3084 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_plogi_sending);
3085 bfa_fcs_lport_ns_send_plogi(ns, NULL);
3086 break;
3087
3088 case NSSM_EVENT_PORT_OFFLINE:
3089 break;
3090
3091 default:
3092 bfa_sm_fault(ns->port->fcs, event);
3093 }
3094}
3095
3096static void
3097bfa_fcs_lport_ns_sm_plogi_sending(struct bfa_fcs_lport_ns_s *ns,
3098 enum vport_ns_event event)
3099{
3100 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3101 bfa_trc(ns->port->fcs, event);
3102
3103 switch (event) {
3104 case NSSM_EVENT_PLOGI_SENT:
3105 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_plogi);
3106 break;
3107
3108 case NSSM_EVENT_PORT_OFFLINE:
3109 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3110 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
3111 &ns->fcxp_wqe);
3112 break;
3113
3114 default:
3115 bfa_sm_fault(ns->port->fcs, event);
3116 }
3117}
3118
3119static void
3120bfa_fcs_lport_ns_sm_plogi(struct bfa_fcs_lport_ns_s *ns,
3121 enum vport_ns_event event)
3122{
3123 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3124 bfa_trc(ns->port->fcs, event);
3125
3126 switch (event) {
3127 case NSSM_EVENT_RSP_ERROR:
3128 /*
3129 * Start timer for a delayed retry
3130 */
3131 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_plogi_retry);
3132 ns->port->stats.ns_retries++;
3133 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
3134 &ns->timer, bfa_fcs_lport_ns_timeout, ns,
3135 BFA_FCS_RETRY_TIMEOUT);
3136 break;
3137
3138 case NSSM_EVENT_RSP_OK:
3139 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rspn_id);
3140 bfa_fcs_lport_ns_send_rspn_id(ns, NULL);
3141 break;
3142
3143 case NSSM_EVENT_PORT_OFFLINE:
3144 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3145 bfa_fcxp_discard(ns->fcxp);
3146 break;
3147
3148 default:
3149 bfa_sm_fault(ns->port->fcs, event);
3150 }
3151}
3152
3153static void
3154bfa_fcs_lport_ns_sm_plogi_retry(struct bfa_fcs_lport_ns_s *ns,
3155 enum vport_ns_event event)
3156{
3157 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3158 bfa_trc(ns->port->fcs, event);
3159
3160 switch (event) {
3161 case NSSM_EVENT_TIMEOUT:
3162 /*
3163 * Retry Timer Expired. Re-send
3164 */
3165 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_plogi_sending);
3166 bfa_fcs_lport_ns_send_plogi(ns, NULL);
3167 break;
3168
3169 case NSSM_EVENT_PORT_OFFLINE:
3170 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3171 bfa_timer_stop(&ns->timer);
3172 break;
3173
3174 default:
3175 bfa_sm_fault(ns->port->fcs, event);
3176 }
3177}
3178
3179static void
3180bfa_fcs_lport_ns_sm_sending_rspn_id(struct bfa_fcs_lport_ns_s *ns,
3181 enum vport_ns_event event)
3182{
3183 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3184 bfa_trc(ns->port->fcs, event);
3185
3186 switch (event) {
3187 case NSSM_EVENT_RSPNID_SENT:
3188 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rspn_id);
3189 break;
3190
3191 case NSSM_EVENT_PORT_OFFLINE:
3192 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3193 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
3194 &ns->fcxp_wqe);
3195 break;
3196
3197 default:
3198 bfa_sm_fault(ns->port->fcs, event);
3199 }
3200}
3201
3202static void
3203bfa_fcs_lport_ns_sm_rspn_id(struct bfa_fcs_lport_ns_s *ns,
3204 enum vport_ns_event event)
3205{
3206 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3207 bfa_trc(ns->port->fcs, event);
3208
3209 switch (event) {
3210 case NSSM_EVENT_RSP_ERROR:
3211 /*
3212 * Start timer for a delayed retry
3213 */
3214 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rspn_id_retry);
3215 ns->port->stats.ns_retries++;
3216 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
3217 &ns->timer, bfa_fcs_lport_ns_timeout, ns,
3218 BFA_FCS_RETRY_TIMEOUT);
3219 break;
3220
3221 case NSSM_EVENT_RSP_OK:
3222 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rft_id);
3223 bfa_fcs_lport_ns_send_rft_id(ns, NULL);
3224 break;
3225
3226 case NSSM_EVENT_PORT_OFFLINE:
3227 bfa_fcxp_discard(ns->fcxp);
3228 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3229 break;
3230
3231 default:
3232 bfa_sm_fault(ns->port->fcs, event);
3233 }
3234}
3235
3236static void
3237bfa_fcs_lport_ns_sm_rspn_id_retry(struct bfa_fcs_lport_ns_s *ns,
3238 enum vport_ns_event event)
3239{
3240 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3241 bfa_trc(ns->port->fcs, event);
3242
3243 switch (event) {
3244 case NSSM_EVENT_TIMEOUT:
3245 /*
3246 * Retry Timer Expired. Re-send
3247 */
3248 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rspn_id);
3249 bfa_fcs_lport_ns_send_rspn_id(ns, NULL);
3250 break;
3251
3252 case NSSM_EVENT_PORT_OFFLINE:
3253 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3254 bfa_timer_stop(&ns->timer);
3255 break;
3256
3257 default:
3258 bfa_sm_fault(ns->port->fcs, event);
3259 }
3260}
3261
3262static void
3263bfa_fcs_lport_ns_sm_sending_rft_id(struct bfa_fcs_lport_ns_s *ns,
3264 enum vport_ns_event event)
3265{
3266 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3267 bfa_trc(ns->port->fcs, event);
3268
3269 switch (event) {
3270 case NSSM_EVENT_RFTID_SENT:
3271 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rft_id);
3272 break;
3273
3274 case NSSM_EVENT_PORT_OFFLINE:
3275 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3276 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
3277 &ns->fcxp_wqe);
3278 break;
3279
3280 default:
3281 bfa_sm_fault(ns->port->fcs, event);
3282 }
3283}
3284
3285static void
3286bfa_fcs_lport_ns_sm_rft_id(struct bfa_fcs_lport_ns_s *ns,
3287 enum vport_ns_event event)
3288{
3289 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3290 bfa_trc(ns->port->fcs, event);
3291
3292 switch (event) {
3293 case NSSM_EVENT_RSP_OK:
3294 /* Now move to register FC4 Features */
3295 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rff_id);
3296 bfa_fcs_lport_ns_send_rff_id(ns, NULL);
3297 break;
929 3298
3299 case NSSM_EVENT_RSP_ERROR:
3300 /*
3301 * Start timer for a delayed retry
3302 */
3303 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rft_id_retry);
3304 ns->port->stats.ns_retries++;
3305 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
3306 &ns->timer, bfa_fcs_lport_ns_timeout, ns,
3307 BFA_FCS_RETRY_TIMEOUT);
3308 break;
3309
3310 case NSSM_EVENT_PORT_OFFLINE:
3311 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3312 bfa_fcxp_discard(ns->fcxp);
3313 break;
3314
3315 default:
3316 bfa_sm_fault(ns->port->fcs, event);
3317 }
3318}
3319
3320static void
3321bfa_fcs_lport_ns_sm_rft_id_retry(struct bfa_fcs_lport_ns_s *ns,
3322 enum vport_ns_event event)
3323{
3324 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3325 bfa_trc(ns->port->fcs, event);
3326
3327 switch (event) {
3328 case NSSM_EVENT_TIMEOUT:
3329 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rft_id);
3330 bfa_fcs_lport_ns_send_rft_id(ns, NULL);
3331 break;
3332
3333 case NSSM_EVENT_PORT_OFFLINE:
3334 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3335 bfa_timer_stop(&ns->timer);
3336 break;
3337
3338 default:
3339 bfa_sm_fault(ns->port->fcs, event);
3340 }
3341}
3342
3343static void
3344bfa_fcs_lport_ns_sm_sending_rff_id(struct bfa_fcs_lport_ns_s *ns,
3345 enum vport_ns_event event)
3346{
3347 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3348 bfa_trc(ns->port->fcs, event);
3349
3350 switch (event) {
3351 case NSSM_EVENT_RFFID_SENT:
3352 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rff_id);
3353 break;
3354
3355 case NSSM_EVENT_PORT_OFFLINE:
3356 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3357 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
3358 &ns->fcxp_wqe);
3359 break;
3360
3361 default:
3362 bfa_sm_fault(ns->port->fcs, event);
3363 }
3364}
3365
3366static void
3367bfa_fcs_lport_ns_sm_rff_id(struct bfa_fcs_lport_ns_s *ns,
3368 enum vport_ns_event event)
3369{
3370 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3371 bfa_trc(ns->port->fcs, event);
3372
3373 switch (event) {
3374 case NSSM_EVENT_RSP_OK:
3375
3376 /*
3377 * If min cfg mode is enabled, we donot initiate rport
3378 * discovery with the fabric. Instead, we will retrieve the
3379 * boot targets from HAL/FW.
3380 */
3381 if (__fcs_min_cfg(ns->port->fcs)) {
3382 bfa_fcs_lport_ns_boot_target_disc(ns->port);
3383 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_online);
3384 return;
3385 }
3386
3387 /*
3388 * If the port role is Initiator Mode issue NS query.
3389 * If it is Target Mode, skip this and go to online.
3390 */
3391 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns->port)) {
3392 bfa_sm_set_state(ns,
3393 bfa_fcs_lport_ns_sm_sending_gid_ft);
3394 bfa_fcs_lport_ns_send_gid_ft(ns, NULL);
3395 }
3396 /*
3397 * kick off mgmt srvr state machine
3398 */
3399 bfa_fcs_lport_ms_online(ns->port);
3400 break;
3401
3402 case NSSM_EVENT_RSP_ERROR:
3403 /*
3404 * Start timer for a delayed retry
3405 */
3406 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_rff_id_retry);
3407 ns->port->stats.ns_retries++;
3408 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
3409 &ns->timer, bfa_fcs_lport_ns_timeout, ns,
3410 BFA_FCS_RETRY_TIMEOUT);
3411 break;
3412
3413 case NSSM_EVENT_PORT_OFFLINE:
3414 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3415 bfa_fcxp_discard(ns->fcxp);
3416 break;
3417
3418 default:
3419 bfa_sm_fault(ns->port->fcs, event);
3420 }
3421}
3422
3423static void
3424bfa_fcs_lport_ns_sm_rff_id_retry(struct bfa_fcs_lport_ns_s *ns,
3425 enum vport_ns_event event)
3426{
3427 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3428 bfa_trc(ns->port->fcs, event);
3429
3430 switch (event) {
3431 case NSSM_EVENT_TIMEOUT:
3432 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_rff_id);
3433 bfa_fcs_lport_ns_send_rff_id(ns, NULL);
3434 break;
3435
3436 case NSSM_EVENT_PORT_OFFLINE:
3437 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3438 bfa_timer_stop(&ns->timer);
3439 break;
3440
3441 default:
3442 bfa_sm_fault(ns->port->fcs, event);
3443 }
3444}
3445static void
3446bfa_fcs_lport_ns_sm_sending_gid_ft(struct bfa_fcs_lport_ns_s *ns,
3447 enum vport_ns_event event)
3448{
3449 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3450 bfa_trc(ns->port->fcs, event);
3451
3452 switch (event) {
3453 case NSSM_EVENT_GIDFT_SENT:
3454 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_gid_ft);
3455 break;
3456
3457 case NSSM_EVENT_PORT_OFFLINE:
3458 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3459 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
3460 &ns->fcxp_wqe);
3461 break;
3462
3463 default:
3464 bfa_sm_fault(ns->port->fcs, event);
3465 }
3466}
3467
3468static void
3469bfa_fcs_lport_ns_sm_gid_ft(struct bfa_fcs_lport_ns_s *ns,
3470 enum vport_ns_event event)
3471{
3472 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3473 bfa_trc(ns->port->fcs, event);
3474
3475 switch (event) {
3476 case NSSM_EVENT_RSP_OK:
3477 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_online);
3478 break;
3479
3480 case NSSM_EVENT_RSP_ERROR:
3481 /*
3482 * TBD: for certain reject codes, we don't need to retry
3483 */
3484 /*
3485 * Start timer for a delayed retry
3486 */
3487 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_gid_ft_retry);
3488 ns->port->stats.ns_retries++;
3489 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
3490 &ns->timer, bfa_fcs_lport_ns_timeout, ns,
3491 BFA_FCS_RETRY_TIMEOUT);
3492 break;
3493
3494 case NSSM_EVENT_PORT_OFFLINE:
3495 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3496 bfa_fcxp_discard(ns->fcxp);
3497 break;
3498
3499 case NSSM_EVENT_NS_QUERY:
3500 break;
3501
3502 default:
3503 bfa_sm_fault(ns->port->fcs, event);
3504 }
3505}
3506
3507static void
3508bfa_fcs_lport_ns_sm_gid_ft_retry(struct bfa_fcs_lport_ns_s *ns,
3509 enum vport_ns_event event)
3510{
3511 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3512 bfa_trc(ns->port->fcs, event);
3513
3514 switch (event) {
3515 case NSSM_EVENT_TIMEOUT:
3516 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_sending_gid_ft);
3517 bfa_fcs_lport_ns_send_gid_ft(ns, NULL);
3518 break;
3519
3520 case NSSM_EVENT_PORT_OFFLINE:
3521 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3522 bfa_timer_stop(&ns->timer);
3523 break;
3524
3525 default:
3526 bfa_sm_fault(ns->port->fcs, event);
3527 }
3528}
3529
3530static void
3531bfa_fcs_lport_ns_sm_online(struct bfa_fcs_lport_ns_s *ns,
3532 enum vport_ns_event event)
3533{
3534 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
3535 bfa_trc(ns->port->fcs, event);
3536
3537 switch (event) {
3538 case NSSM_EVENT_PORT_OFFLINE:
3539 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
3540 break;
3541
3542 case NSSM_EVENT_NS_QUERY:
3543 /*
3544 * If the port role is Initiator Mode issue NS query.
3545 * If it is Target Mode, skip this and go to online.
3546 */
3547 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns->port)) {
3548 bfa_sm_set_state(ns,
3549 bfa_fcs_lport_ns_sm_sending_gid_ft);
3550 bfa_fcs_lport_ns_send_gid_ft(ns, NULL);
3551 };
3552 break;
3553
3554 default:
3555 bfa_sm_fault(ns->port->fcs, event);
3556 }
3557}
3558
3559
3560
3561/*
3562 * ns_pvt Nameserver local functions
3563 */
3564
3565static void
3566bfa_fcs_lport_ns_send_plogi(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
3567{
3568 struct bfa_fcs_lport_ns_s *ns = ns_cbarg;
3569 struct bfa_fcs_lport_s *port = ns->port;
3570 struct fchs_s fchs;
3571 int len;
3572 struct bfa_fcxp_s *fcxp;
3573
3574 bfa_trc(port->fcs, port->pid);
3575
3576fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
3577 if (!fcxp) {
3578 port->stats.ns_plogi_alloc_wait++;
3579 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe,
3580 bfa_fcs_lport_ns_send_plogi, ns);
3581 return;
3582 }
3583 ns->fcxp = fcxp;
3584
3585 len = fc_plogi_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
3586 bfa_hton3b(FC_NAME_SERVER),
3587 bfa_fcs_lport_get_fcid(port), 0,
3588 port->port_cfg.pwwn, port->port_cfg.nwwn,
3589 bfa_fcport_get_maxfrsize(port->fcs->bfa));
3590
3591 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
3592 FC_CLASS_3, len, &fchs,
3593 bfa_fcs_lport_ns_plogi_response, (void *)ns,
3594 FC_MAX_PDUSZ, FC_ELS_TOV);
3595 port->stats.ns_plogi_sent++;
3596
3597 bfa_sm_send_event(ns, NSSM_EVENT_PLOGI_SENT);
3598}
3599
3600static void
3601bfa_fcs_lport_ns_plogi_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
3602 void *cbarg, bfa_status_t req_status, u32 rsp_len,
3603 u32 resid_len, struct fchs_s *rsp_fchs)
3604{
3605 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg;
3606 struct bfa_fcs_lport_s *port = ns->port;
3607 /* struct fc_logi_s *plogi_resp; */
3608 struct fc_els_cmd_s *els_cmd;
3609 struct fc_ls_rjt_s *ls_rjt;
3610
3611 bfa_trc(port->fcs, req_status);
3612 bfa_trc(port->fcs, port->port_cfg.pwwn);
3613
3614 /*
3615 * Sanity Checks
3616 */
3617 if (req_status != BFA_STATUS_OK) {
3618 bfa_trc(port->fcs, req_status);
3619 port->stats.ns_plogi_rsp_err++;
3620 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
3621 return;
3622 }
3623
3624 els_cmd = (struct fc_els_cmd_s *) BFA_FCXP_RSP_PLD(fcxp);
3625
3626 switch (els_cmd->els_code) {
3627
3628 case FC_ELS_ACC:
3629 if (rsp_len < sizeof(struct fc_logi_s)) {
3630 bfa_trc(port->fcs, rsp_len);
3631 port->stats.ns_plogi_acc_err++;
3632 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
3633 break;
3634 }
3635 port->stats.ns_plogi_accepts++;
3636 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
3637 break;
3638
3639 case FC_ELS_LS_RJT:
3640 ls_rjt = (struct fc_ls_rjt_s *) BFA_FCXP_RSP_PLD(fcxp);
3641
3642 bfa_trc(port->fcs, ls_rjt->reason_code);
3643 bfa_trc(port->fcs, ls_rjt->reason_code_expl);
3644
3645 port->stats.ns_rejects++;
3646
3647 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
3648 break;
3649
3650 default:
3651 port->stats.ns_plogi_unknown_rsp++;
3652 bfa_trc(port->fcs, els_cmd->els_code);
3653 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
3654 }
3655}
3656
3657/*
3658 * Register the symbolic port name.
3659 */
3660static void
3661bfa_fcs_lport_ns_send_rspn_id(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
3662{
3663 struct bfa_fcs_lport_ns_s *ns = ns_cbarg;
3664 struct bfa_fcs_lport_s *port = ns->port;
3665 struct fchs_s fchs;
3666 int len;
3667 struct bfa_fcxp_s *fcxp;
3668 u8 symbl[256];
3669 u8 *psymbl = &symbl[0];
3670
3671 memset(symbl, 0, sizeof(symbl));
3672
3673 bfa_trc(port->fcs, port->port_cfg.pwwn);
3674
3675 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
3676 if (!fcxp) {
3677 port->stats.ns_rspnid_alloc_wait++;
3678 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe,
3679 bfa_fcs_lport_ns_send_rspn_id, ns);
3680 return;
3681 }
3682 ns->fcxp = fcxp;
3683
3684 /*
3685 * for V-Port, form a Port Symbolic Name
3686 */
3687 if (port->vport) {
3688 /*
3689 * For Vports, we append the vport's port symbolic name
3690 * to that of the base port.
3691 */
3692
3693 strncpy((char *)psymbl,
3694 (char *) &
3695 (bfa_fcs_lport_get_psym_name
3696 (bfa_fcs_get_base_port(port->fcs))),
3697 strlen((char *) &
3698 bfa_fcs_lport_get_psym_name(bfa_fcs_get_base_port
3699 (port->fcs))));
3700
3701 /* Ensure we have a null terminating string. */
3702 ((char *)psymbl)[strlen((char *) &
3703 bfa_fcs_lport_get_psym_name(bfa_fcs_get_base_port
3704 (port->fcs)))] = 0;
3705 strncat((char *)psymbl,
3706 (char *) &(bfa_fcs_lport_get_psym_name(port)),
3707 strlen((char *) &bfa_fcs_lport_get_psym_name(port)));
3708 } else {
3709 psymbl = (u8 *) &(bfa_fcs_lport_get_psym_name(port));
3710 }
3711
3712 len = fc_rspnid_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
3713 bfa_fcs_lport_get_fcid(port), 0, psymbl);
3714
3715 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
3716 FC_CLASS_3, len, &fchs,
3717 bfa_fcs_lport_ns_rspn_id_response, (void *)ns,
3718 FC_MAX_PDUSZ, FC_FCCT_TOV);
3719
3720 port->stats.ns_rspnid_sent++;
3721
3722 bfa_sm_send_event(ns, NSSM_EVENT_RSPNID_SENT);
3723}
3724
3725static void
3726bfa_fcs_lport_ns_rspn_id_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
3727 void *cbarg, bfa_status_t req_status,
3728 u32 rsp_len, u32 resid_len,
3729 struct fchs_s *rsp_fchs)
3730{
3731 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg;
3732 struct bfa_fcs_lport_s *port = ns->port;
3733 struct ct_hdr_s *cthdr = NULL;
3734
3735 bfa_trc(port->fcs, port->port_cfg.pwwn);
3736
3737 /*
3738 * Sanity Checks
3739 */
3740 if (req_status != BFA_STATUS_OK) {
3741 bfa_trc(port->fcs, req_status);
3742 port->stats.ns_rspnid_rsp_err++;
3743 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
3744 return;
3745 }
3746
3747 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
3748 cthdr->cmd_rsp_code = be16_to_cpu(cthdr->cmd_rsp_code);
3749
3750 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
3751 port->stats.ns_rspnid_accepts++;
3752 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
3753 return;
3754 }
3755
3756 port->stats.ns_rspnid_rejects++;
3757 bfa_trc(port->fcs, cthdr->reason_code);
3758 bfa_trc(port->fcs, cthdr->exp_code);
3759 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
3760}
3761
3762/*
3763 * Register FC4-Types
3764 */
3765static void
3766bfa_fcs_lport_ns_send_rft_id(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
3767{
3768 struct bfa_fcs_lport_ns_s *ns = ns_cbarg;
3769 struct bfa_fcs_lport_s *port = ns->port;
3770 struct fchs_s fchs;
3771 int len;
3772 struct bfa_fcxp_s *fcxp;
3773
3774 bfa_trc(port->fcs, port->port_cfg.pwwn);
3775
3776 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
3777 if (!fcxp) {
3778 port->stats.ns_rftid_alloc_wait++;
3779 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe,
3780 bfa_fcs_lport_ns_send_rft_id, ns);
3781 return;
3782 }
3783 ns->fcxp = fcxp;
3784
3785 len = fc_rftid_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
3786 bfa_fcs_lport_get_fcid(port), 0, port->port_cfg.roles);
3787
3788 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
3789 FC_CLASS_3, len, &fchs,
3790 bfa_fcs_lport_ns_rft_id_response, (void *)ns,
3791 FC_MAX_PDUSZ, FC_FCCT_TOV);
3792
3793 port->stats.ns_rftid_sent++;
3794 bfa_sm_send_event(ns, NSSM_EVENT_RFTID_SENT);
3795}
3796
3797static void
3798bfa_fcs_lport_ns_rft_id_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
3799 void *cbarg, bfa_status_t req_status,
3800 u32 rsp_len, u32 resid_len,
3801 struct fchs_s *rsp_fchs)
3802{
3803 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg;
3804 struct bfa_fcs_lport_s *port = ns->port;
3805 struct ct_hdr_s *cthdr = NULL;
3806
3807 bfa_trc(port->fcs, port->port_cfg.pwwn);
3808
3809 /*
3810 * Sanity Checks
3811 */
3812 if (req_status != BFA_STATUS_OK) {
3813 bfa_trc(port->fcs, req_status);
3814 port->stats.ns_rftid_rsp_err++;
3815 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
3816 return;
3817 }
3818
3819 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
3820 cthdr->cmd_rsp_code = be16_to_cpu(cthdr->cmd_rsp_code);
3821
3822 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
3823 port->stats.ns_rftid_accepts++;
3824 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
3825 return;
3826 }
3827
3828 port->stats.ns_rftid_rejects++;
3829 bfa_trc(port->fcs, cthdr->reason_code);
3830 bfa_trc(port->fcs, cthdr->exp_code);
3831 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
3832}
3833
3834/*
3835 * Register FC4-Features : Should be done after RFT_ID
3836 */
3837static void
3838bfa_fcs_lport_ns_send_rff_id(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
3839{
3840 struct bfa_fcs_lport_ns_s *ns = ns_cbarg;
3841 struct bfa_fcs_lport_s *port = ns->port;
3842 struct fchs_s fchs;
3843 int len;
3844 struct bfa_fcxp_s *fcxp;
3845 u8 fc4_ftrs = 0;
3846
3847 bfa_trc(port->fcs, port->port_cfg.pwwn);
3848
3849 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
3850 if (!fcxp) {
3851 port->stats.ns_rffid_alloc_wait++;
3852 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe,
3853 bfa_fcs_lport_ns_send_rff_id, ns);
3854 return;
3855 }
3856 ns->fcxp = fcxp;
3857
3858 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns->port))
3859 fc4_ftrs = FC_GS_FCP_FC4_FEATURE_INITIATOR;
3860
3861 len = fc_rffid_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
3862 bfa_fcs_lport_get_fcid(port), 0,
3863 FC_TYPE_FCP, fc4_ftrs);
3864
3865 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
3866 FC_CLASS_3, len, &fchs,
3867 bfa_fcs_lport_ns_rff_id_response, (void *)ns,
3868 FC_MAX_PDUSZ, FC_FCCT_TOV);
3869
3870 port->stats.ns_rffid_sent++;
3871 bfa_sm_send_event(ns, NSSM_EVENT_RFFID_SENT);
3872}
3873
3874static void
3875bfa_fcs_lport_ns_rff_id_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
3876 void *cbarg, bfa_status_t req_status,
3877 u32 rsp_len, u32 resid_len,
3878 struct fchs_s *rsp_fchs)
3879{
3880 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg;
3881 struct bfa_fcs_lport_s *port = ns->port;
3882 struct ct_hdr_s *cthdr = NULL;
3883
3884 bfa_trc(port->fcs, port->port_cfg.pwwn);
3885
3886 /*
3887 * Sanity Checks
3888 */
3889 if (req_status != BFA_STATUS_OK) {
3890 bfa_trc(port->fcs, req_status);
3891 port->stats.ns_rffid_rsp_err++;
3892 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
3893 return;
3894 }
3895
3896 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
3897 cthdr->cmd_rsp_code = be16_to_cpu(cthdr->cmd_rsp_code);
3898
3899 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
3900 port->stats.ns_rffid_accepts++;
3901 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
3902 return;
3903 }
3904
3905 port->stats.ns_rffid_rejects++;
3906 bfa_trc(port->fcs, cthdr->reason_code);
3907 bfa_trc(port->fcs, cthdr->exp_code);
3908
3909 if (cthdr->reason_code == CT_RSN_NOT_SUPP) {
3910 /* if this command is not supported, we don't retry */
3911 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
3912 } else
3913 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
3914}
3915/*
3916 * Query Fabric for FC4-Types Devices.
3917 *
3918* TBD : Need to use a local (FCS private) response buffer, since the response
3919 * can be larger than 2K.
3920 */
3921static void
3922bfa_fcs_lport_ns_send_gid_ft(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
3923{
3924 struct bfa_fcs_lport_ns_s *ns = ns_cbarg;
3925 struct bfa_fcs_lport_s *port = ns->port;
3926 struct fchs_s fchs;
3927 int len;
3928 struct bfa_fcxp_s *fcxp;
3929
3930 bfa_trc(port->fcs, port->pid);
3931
3932 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
3933 if (!fcxp) {
3934 port->stats.ns_gidft_alloc_wait++;
3935 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe,
3936 bfa_fcs_lport_ns_send_gid_ft, ns);
3937 return;
3938 }
3939 ns->fcxp = fcxp;
3940
3941 /*
3942 * This query is only initiated for FCP initiator mode.
3943 */
3944 len = fc_gid_ft_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
3945 ns->port->pid, FC_TYPE_FCP);
3946
3947 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
3948 FC_CLASS_3, len, &fchs,
3949 bfa_fcs_lport_ns_gid_ft_response, (void *)ns,
3950 bfa_fcxp_get_maxrsp(port->fcs->bfa), FC_FCCT_TOV);
3951
3952 port->stats.ns_gidft_sent++;
3953
3954 bfa_sm_send_event(ns, NSSM_EVENT_GIDFT_SENT);
3955}
3956
3957static void
3958bfa_fcs_lport_ns_gid_ft_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
3959 void *cbarg, bfa_status_t req_status,
3960 u32 rsp_len, u32 resid_len,
3961 struct fchs_s *rsp_fchs)
3962{
3963 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) cbarg;
3964 struct bfa_fcs_lport_s *port = ns->port;
3965 struct ct_hdr_s *cthdr = NULL;
3966 u32 n_pids;
3967
3968 bfa_trc(port->fcs, port->port_cfg.pwwn);
3969
3970 /*
3971 * Sanity Checks
3972 */
3973 if (req_status != BFA_STATUS_OK) {
3974 bfa_trc(port->fcs, req_status);
3975 port->stats.ns_gidft_rsp_err++;
3976 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
3977 return;
3978 }
3979
3980 if (resid_len != 0) {
3981 /*
3982 * TBD : we will need to allocate a larger buffer & retry the
3983 * command
3984 */
3985 bfa_trc(port->fcs, rsp_len);
3986 bfa_trc(port->fcs, resid_len);
3987 return;
3988 }
3989
3990 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
3991 cthdr->cmd_rsp_code = be16_to_cpu(cthdr->cmd_rsp_code);
3992
3993 switch (cthdr->cmd_rsp_code) {
3994
3995 case CT_RSP_ACCEPT:
3996
3997 port->stats.ns_gidft_accepts++;
3998 n_pids = (fc_get_ctresp_pyld_len(rsp_len) / sizeof(u32));
3999 bfa_trc(port->fcs, n_pids);
4000 bfa_fcs_lport_ns_process_gidft_pids(port,
4001 (u32 *) (cthdr + 1),
4002 n_pids);
4003 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
4004 break;
4005
4006 case CT_RSP_REJECT:
4007
4008 /*
4009 * Check the reason code & explanation.
4010 * There may not have been any FC4 devices in the fabric
4011 */
4012 port->stats.ns_gidft_rejects++;
4013 bfa_trc(port->fcs, cthdr->reason_code);
4014 bfa_trc(port->fcs, cthdr->exp_code);
4015
4016 if ((cthdr->reason_code == CT_RSN_UNABLE_TO_PERF)
4017 && (cthdr->exp_code == CT_NS_EXP_FT_NOT_REG)) {
4018
4019 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
4020 } else {
4021 /*
4022 * for all other errors, retry
4023 */
4024 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
4025 }
4026 break;
4027
4028 default:
4029 port->stats.ns_gidft_unknown_rsp++;
4030 bfa_trc(port->fcs, cthdr->cmd_rsp_code);
4031 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
4032 }
4033}
4034
4035/*
4036 * This routine will be called by bfa_timer on timer timeouts.
4037 *
4038 * param[in] port - pointer to bfa_fcs_lport_t.
4039 *
4040 * return
4041 * void
4042 *
4043 * Special Considerations:
4044 *
4045 * note
4046 */
4047static void
4048bfa_fcs_lport_ns_timeout(void *arg)
4049{
4050 struct bfa_fcs_lport_ns_s *ns = (struct bfa_fcs_lport_ns_s *) arg;
4051
4052 ns->port->stats.ns_timeouts++;
4053 bfa_sm_send_event(ns, NSSM_EVENT_TIMEOUT);
4054}
4055
4056/*
4057 * Process the PID list in GID_FT response
4058 */
4059static void
4060bfa_fcs_lport_ns_process_gidft_pids(struct bfa_fcs_lport_s *port, u32 *pid_buf,
4061 u32 n_pids)
4062{
4063 struct fcgs_gidft_resp_s *gidft_entry;
4064 struct bfa_fcs_rport_s *rport;
4065 u32 ii;
4066
4067 for (ii = 0; ii < n_pids; ii++) {
4068 gidft_entry = (struct fcgs_gidft_resp_s *) &pid_buf[ii];
4069
4070 if (gidft_entry->pid == port->pid)
4071 continue;
4072
4073 /*
4074 * Check if this rport already exists
4075 */
4076 rport = bfa_fcs_lport_get_rport_by_pid(port, gidft_entry->pid);
4077 if (rport == NULL) {
4078 /*
4079 * this is a new device. create rport
4080 */
4081 rport = bfa_fcs_rport_create(port, gidft_entry->pid);
4082 } else {
4083 /*
4084 * this rport already exists
4085 */
4086 bfa_fcs_rport_scn(rport);
4087 }
4088
4089 bfa_trc(port->fcs, gidft_entry->pid);
4090
4091 /*
4092 * if the last entry bit is set, bail out.
4093 */
4094 if (gidft_entry->last)
4095 return;
4096 }
4097}
4098
4099/*
4100 * fcs_ns_public FCS nameserver public interfaces
4101 */
4102
4103/*
4104 * Functions called by port/fab.
4105 * These will send relevant Events to the ns state machine.
4106 */
4107void
4108bfa_fcs_lport_ns_init(struct bfa_fcs_lport_s *port)
4109{
4110 struct bfa_fcs_lport_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port);
4111
4112 ns->port = port;
4113 bfa_sm_set_state(ns, bfa_fcs_lport_ns_sm_offline);
4114}
4115
4116void
4117bfa_fcs_lport_ns_offline(struct bfa_fcs_lport_s *port)
4118{
4119 struct bfa_fcs_lport_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port);
4120
4121 ns->port = port;
4122 bfa_sm_send_event(ns, NSSM_EVENT_PORT_OFFLINE);
4123}
4124
4125void
4126bfa_fcs_lport_ns_online(struct bfa_fcs_lport_s *port)
4127{
4128 struct bfa_fcs_lport_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port);
4129
4130 ns->port = port;
4131 bfa_sm_send_event(ns, NSSM_EVENT_PORT_ONLINE);
4132}
4133
4134void
4135bfa_fcs_lport_ns_query(struct bfa_fcs_lport_s *port)
4136{
4137 struct bfa_fcs_lport_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port);
4138
4139 bfa_trc(port->fcs, port->pid);
4140 bfa_sm_send_event(ns, NSSM_EVENT_NS_QUERY);
4141}
4142
4143static void
4144bfa_fcs_lport_ns_boot_target_disc(bfa_fcs_lport_t *port)
4145{
4146
4147 struct bfa_fcs_rport_s *rport;
4148 u8 nwwns;
4149 wwn_t wwns[BFA_PREBOOT_BOOTLUN_MAX];
4150 int ii;
4151
4152 bfa_iocfc_get_bootwwns(port->fcs->bfa, &nwwns, wwns);
4153
4154 for (ii = 0 ; ii < nwwns; ++ii) {
4155 rport = bfa_fcs_rport_create_by_wwn(port, wwns[ii]);
4156 WARN_ON(!rport);
4157 }
4158}
4159
4160/*
4161 * FCS SCN
4162 */
4163
4164#define FC_QOS_RSCN_EVENT 0x0c
4165#define FC_FABRIC_NAME_RSCN_EVENT 0x0d
4166
4167/*
4168 * forward declarations
4169 */
4170static void bfa_fcs_lport_scn_send_scr(void *scn_cbarg,
4171 struct bfa_fcxp_s *fcxp_alloced);
4172static void bfa_fcs_lport_scn_scr_response(void *fcsarg,
4173 struct bfa_fcxp_s *fcxp,
4174 void *cbarg,
4175 bfa_status_t req_status,
4176 u32 rsp_len,
4177 u32 resid_len,
4178 struct fchs_s *rsp_fchs);
4179static void bfa_fcs_lport_scn_send_ls_acc(struct bfa_fcs_lport_s *port,
4180 struct fchs_s *rx_fchs);
4181static void bfa_fcs_lport_scn_timeout(void *arg);
4182
4183/*
4184 * fcs_scm_sm FCS SCN state machine
4185 */
4186
4187/*
4188 * VPort SCN State Machine events
4189 */
4190enum port_scn_event {
4191 SCNSM_EVENT_PORT_ONLINE = 1,
4192 SCNSM_EVENT_PORT_OFFLINE = 2,
4193 SCNSM_EVENT_RSP_OK = 3,
4194 SCNSM_EVENT_RSP_ERROR = 4,
4195 SCNSM_EVENT_TIMEOUT = 5,
4196 SCNSM_EVENT_SCR_SENT = 6,
4197};
4198
4199static void bfa_fcs_lport_scn_sm_offline(struct bfa_fcs_lport_scn_s *scn,
4200 enum port_scn_event event);
4201static void bfa_fcs_lport_scn_sm_sending_scr(
4202 struct bfa_fcs_lport_scn_s *scn,
4203 enum port_scn_event event);
4204static void bfa_fcs_lport_scn_sm_scr(struct bfa_fcs_lport_scn_s *scn,
4205 enum port_scn_event event);
4206static void bfa_fcs_lport_scn_sm_scr_retry(struct bfa_fcs_lport_scn_s *scn,
4207 enum port_scn_event event);
4208static void bfa_fcs_lport_scn_sm_online(struct bfa_fcs_lport_scn_s *scn,
4209 enum port_scn_event event);
4210
4211/*
4212 * Starting state - awaiting link up.
4213 */
4214static void
4215bfa_fcs_lport_scn_sm_offline(struct bfa_fcs_lport_scn_s *scn,
4216 enum port_scn_event event)
4217{
4218 switch (event) {
4219 case SCNSM_EVENT_PORT_ONLINE:
4220 bfa_sm_set_state(scn, bfa_fcs_lport_scn_sm_sending_scr);
4221 bfa_fcs_lport_scn_send_scr(scn, NULL);
4222 break;
4223
4224 case SCNSM_EVENT_PORT_OFFLINE:
4225 break;
4226
4227 default:
4228 bfa_sm_fault(scn->port->fcs, event);
4229 }
4230}
4231
4232static void
4233bfa_fcs_lport_scn_sm_sending_scr(struct bfa_fcs_lport_scn_s *scn,
4234 enum port_scn_event event)
4235{
4236 switch (event) {
4237 case SCNSM_EVENT_SCR_SENT:
4238 bfa_sm_set_state(scn, bfa_fcs_lport_scn_sm_scr);
4239 break;
4240
4241 case SCNSM_EVENT_PORT_OFFLINE:
4242 bfa_sm_set_state(scn, bfa_fcs_lport_scn_sm_offline);
4243 bfa_fcxp_walloc_cancel(scn->port->fcs->bfa, &scn->fcxp_wqe);
4244 break;
4245
4246 default:
4247 bfa_sm_fault(scn->port->fcs, event);
4248 }
4249}
4250
4251static void
4252bfa_fcs_lport_scn_sm_scr(struct bfa_fcs_lport_scn_s *scn,
4253 enum port_scn_event event)
4254{
4255 struct bfa_fcs_lport_s *port = scn->port;
4256
4257 switch (event) {
4258 case SCNSM_EVENT_RSP_OK:
4259 bfa_sm_set_state(scn, bfa_fcs_lport_scn_sm_online);
4260 break;
4261
4262 case SCNSM_EVENT_RSP_ERROR:
4263 bfa_sm_set_state(scn, bfa_fcs_lport_scn_sm_scr_retry);
4264 bfa_timer_start(port->fcs->bfa, &scn->timer,
4265 bfa_fcs_lport_scn_timeout, scn,
4266 BFA_FCS_RETRY_TIMEOUT);
4267 break;
4268
4269 case SCNSM_EVENT_PORT_OFFLINE:
4270 bfa_sm_set_state(scn, bfa_fcs_lport_scn_sm_offline);
4271 bfa_fcxp_discard(scn->fcxp);
4272 break;
4273
4274 default:
4275 bfa_sm_fault(port->fcs, event);
4276 }
4277}
4278
4279static void
4280bfa_fcs_lport_scn_sm_scr_retry(struct bfa_fcs_lport_scn_s *scn,
4281 enum port_scn_event event)
4282{
4283 switch (event) {
4284 case SCNSM_EVENT_TIMEOUT:
4285 bfa_sm_set_state(scn, bfa_fcs_lport_scn_sm_sending_scr);
4286 bfa_fcs_lport_scn_send_scr(scn, NULL);
4287 break;
4288
4289 case SCNSM_EVENT_PORT_OFFLINE:
4290 bfa_sm_set_state(scn, bfa_fcs_lport_scn_sm_offline);
4291 bfa_timer_stop(&scn->timer);
4292 break;
4293
4294 default:
4295 bfa_sm_fault(scn->port->fcs, event);
4296 }
4297}
4298
4299static void
4300bfa_fcs_lport_scn_sm_online(struct bfa_fcs_lport_scn_s *scn,
4301 enum port_scn_event event)
4302{
4303 switch (event) {
4304 case SCNSM_EVENT_PORT_OFFLINE:
4305 bfa_sm_set_state(scn, bfa_fcs_lport_scn_sm_offline);
4306 break;
4307
4308 default:
4309 bfa_sm_fault(scn->port->fcs, event);
4310 }
4311}
4312
4313
4314
4315/*
4316 * fcs_scn_private FCS SCN private functions
4317 */
4318
4319/*
4320 * This routine will be called to send a SCR command.
4321 */
4322static void
4323bfa_fcs_lport_scn_send_scr(void *scn_cbarg, struct bfa_fcxp_s *fcxp_alloced)
4324{
4325 struct bfa_fcs_lport_scn_s *scn = scn_cbarg;
4326 struct bfa_fcs_lport_s *port = scn->port;
4327 struct fchs_s fchs;
4328 int len;
4329 struct bfa_fcxp_s *fcxp;
4330
4331 bfa_trc(port->fcs, port->pid);
4332 bfa_trc(port->fcs, port->port_cfg.pwwn);
4333
4334 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
4335 if (!fcxp) {
4336 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &scn->fcxp_wqe,
4337 bfa_fcs_lport_scn_send_scr, scn);
4338 return;
4339 }
4340 scn->fcxp = fcxp;
4341
4342 /* Handle VU registrations for Base port only */
4343 if ((!port->vport) && bfa_ioc_get_fcmode(&port->fcs->bfa->ioc)) {
4344 len = fc_scr_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
4345 port->fabric->lps->brcd_switch,
4346 port->pid, 0);
930 } else { 4347 } else {
931 port_attr->port_type = BFA_PPORT_TYPE_UNKNOWN; 4348 len = fc_scr_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
932 port_attr->state = BFA_PORT_UNINIT; 4349 BFA_FALSE,
4350 port->pid, 0);
4351 }
4352
4353 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
4354 FC_CLASS_3, len, &fchs,
4355 bfa_fcs_lport_scn_scr_response,
4356 (void *)scn, FC_MAX_PDUSZ, FC_ELS_TOV);
4357
4358 bfa_sm_send_event(scn, SCNSM_EVENT_SCR_SENT);
4359}
4360
4361static void
4362bfa_fcs_lport_scn_scr_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
4363 void *cbarg, bfa_status_t req_status, u32 rsp_len,
4364 u32 resid_len, struct fchs_s *rsp_fchs)
4365{
4366 struct bfa_fcs_lport_scn_s *scn = (struct bfa_fcs_lport_scn_s *) cbarg;
4367 struct bfa_fcs_lport_s *port = scn->port;
4368 struct fc_els_cmd_s *els_cmd;
4369 struct fc_ls_rjt_s *ls_rjt;
4370
4371 bfa_trc(port->fcs, port->port_cfg.pwwn);
4372
4373 /*
4374 * Sanity Checks
4375 */
4376 if (req_status != BFA_STATUS_OK) {
4377 bfa_trc(port->fcs, req_status);
4378 bfa_sm_send_event(scn, SCNSM_EVENT_RSP_ERROR);
4379 return;
4380 }
4381
4382 els_cmd = (struct fc_els_cmd_s *) BFA_FCXP_RSP_PLD(fcxp);
4383
4384 switch (els_cmd->els_code) {
4385
4386 case FC_ELS_ACC:
4387 bfa_sm_send_event(scn, SCNSM_EVENT_RSP_OK);
4388 break;
4389
4390 case FC_ELS_LS_RJT:
4391
4392 ls_rjt = (struct fc_ls_rjt_s *) BFA_FCXP_RSP_PLD(fcxp);
4393
4394 bfa_trc(port->fcs, ls_rjt->reason_code);
4395 bfa_trc(port->fcs, ls_rjt->reason_code_expl);
4396
4397 bfa_sm_send_event(scn, SCNSM_EVENT_RSP_ERROR);
4398 break;
4399
4400 default:
4401 bfa_sm_send_event(scn, SCNSM_EVENT_RSP_ERROR);
933 } 4402 }
4403}
4404
4405/*
4406 * Send a LS Accept
4407 */
4408static void
4409bfa_fcs_lport_scn_send_ls_acc(struct bfa_fcs_lport_s *port,
4410 struct fchs_s *rx_fchs)
4411{
4412 struct fchs_s fchs;
4413 struct bfa_fcxp_s *fcxp;
4414 struct bfa_rport_s *bfa_rport = NULL;
4415 int len;
4416
4417 bfa_trc(port->fcs, rx_fchs->s_id);
4418
4419 fcxp = bfa_fcs_fcxp_alloc(port->fcs);
4420 if (!fcxp)
4421 return;
4422
4423 len = fc_ls_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
4424 rx_fchs->s_id, bfa_fcs_lport_get_fcid(port),
4425 rx_fchs->ox_id);
934 4426
4427 bfa_fcxp_send(fcxp, bfa_rport, port->fabric->vf_id, port->lp_tag,
4428 BFA_FALSE, FC_CLASS_3, len, &fchs, NULL, NULL,
4429 FC_MAX_PDUSZ, 0);
935} 4430}
936 4431
4432/*
4433 * This routine will be called by bfa_timer on timer timeouts.
4434 *
4435 * param[in] vport - pointer to bfa_fcs_lport_t.
4436 * param[out] vport_status - pointer to return vport status in
4437 *
4438 * return
4439 * void
4440 *
4441 * Special Considerations:
4442 *
4443 * note
4444 */
4445static void
4446bfa_fcs_lport_scn_timeout(void *arg)
4447{
4448 struct bfa_fcs_lport_scn_s *scn = (struct bfa_fcs_lport_scn_s *) arg;
4449
4450 bfa_sm_send_event(scn, SCNSM_EVENT_TIMEOUT);
4451}
937 4452
4453
4454
4455/*
4456 * fcs_scn_public FCS state change notification public interfaces
4457 */
4458
4459/*
4460 * Functions called by port/fab
4461 */
4462void
4463bfa_fcs_lport_scn_init(struct bfa_fcs_lport_s *port)
4464{
4465 struct bfa_fcs_lport_scn_s *scn = BFA_FCS_GET_SCN_FROM_PORT(port);
4466
4467 scn->port = port;
4468 bfa_sm_set_state(scn, bfa_fcs_lport_scn_sm_offline);
4469}
4470
4471void
4472bfa_fcs_lport_scn_offline(struct bfa_fcs_lport_s *port)
4473{
4474 struct bfa_fcs_lport_scn_s *scn = BFA_FCS_GET_SCN_FROM_PORT(port);
4475
4476 scn->port = port;
4477 bfa_sm_send_event(scn, SCNSM_EVENT_PORT_OFFLINE);
4478}
4479
4480void
4481bfa_fcs_lport_scn_online(struct bfa_fcs_lport_s *port)
4482{
4483 struct bfa_fcs_lport_scn_s *scn = BFA_FCS_GET_SCN_FROM_PORT(port);
4484
4485 scn->port = port;
4486 bfa_sm_send_event(scn, SCNSM_EVENT_PORT_ONLINE);
4487}
4488
4489static void
4490bfa_fcs_lport_scn_portid_rscn(struct bfa_fcs_lport_s *port, u32 rpid)
4491{
4492 struct bfa_fcs_rport_s *rport;
4493
4494 bfa_trc(port->fcs, rpid);
4495
4496 /*
4497 * If this is an unknown device, then it just came online.
4498 * Otherwise let rport handle the RSCN event.
4499 */
4500 rport = bfa_fcs_lport_get_rport_by_pid(port, rpid);
4501 if (rport == NULL) {
4502 /*
4503 * If min cfg mode is enabled, we donot need to
4504 * discover any new rports.
4505 */
4506 if (!__fcs_min_cfg(port->fcs))
4507 rport = bfa_fcs_rport_create(port, rpid);
4508 } else
4509 bfa_fcs_rport_scn(rport);
4510}
4511
4512/*
4513 * rscn format based PID comparison
4514 */
4515#define __fc_pid_match(__c0, __c1, __fmt) \
4516 (((__fmt) == FC_RSCN_FORMAT_FABRIC) || \
4517 (((__fmt) == FC_RSCN_FORMAT_DOMAIN) && \
4518 ((__c0)[0] == (__c1)[0])) || \
4519 (((__fmt) == FC_RSCN_FORMAT_AREA) && \
4520 ((__c0)[0] == (__c1)[0]) && \
4521 ((__c0)[1] == (__c1)[1])))
4522
4523static void
4524bfa_fcs_lport_scn_multiport_rscn(struct bfa_fcs_lport_s *port,
4525 enum fc_rscn_format format,
4526 u32 rscn_pid)
4527{
4528 struct bfa_fcs_rport_s *rport;
4529 struct list_head *qe, *qe_next;
4530 u8 *c0, *c1;
4531
4532 bfa_trc(port->fcs, format);
4533 bfa_trc(port->fcs, rscn_pid);
4534
4535 c0 = (u8 *) &rscn_pid;
4536
4537 list_for_each_safe(qe, qe_next, &port->rport_q) {
4538 rport = (struct bfa_fcs_rport_s *) qe;
4539 c1 = (u8 *) &rport->pid;
4540 if (__fc_pid_match(c0, c1, format))
4541 bfa_fcs_rport_scn(rport);
4542 }
4543}
4544
4545
4546void
4547bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s *port,
4548 struct fchs_s *fchs, u32 len)
4549{
4550 struct fc_rscn_pl_s *rscn = (struct fc_rscn_pl_s *) (fchs + 1);
4551 int num_entries;
4552 u32 rscn_pid;
4553 bfa_boolean_t nsquery = BFA_FALSE, found;
4554 int i = 0, j;
4555
4556 num_entries =
4557 (be16_to_cpu(rscn->payldlen) -
4558 sizeof(u32)) / sizeof(rscn->event[0]);
4559
4560 bfa_trc(port->fcs, num_entries);
4561
4562 port->stats.num_rscn++;
4563
4564 bfa_fcs_lport_scn_send_ls_acc(port, fchs);
4565
4566 for (i = 0; i < num_entries; i++) {
4567 rscn_pid = rscn->event[i].portid;
4568
4569 bfa_trc(port->fcs, rscn->event[i].format);
4570 bfa_trc(port->fcs, rscn_pid);
4571
4572 /* check for duplicate entries in the list */
4573 found = BFA_FALSE;
4574 for (j = 0; j < i; j++) {
4575 if (rscn->event[j].portid == rscn_pid) {
4576 found = BFA_TRUE;
4577 break;
4578 }
4579 }
4580
4581 /* if found in down the list, pid has been already processed */
4582 if (found) {
4583 bfa_trc(port->fcs, rscn_pid);
4584 continue;
4585 }
4586
4587 switch (rscn->event[i].format) {
4588 case FC_RSCN_FORMAT_PORTID:
4589 if (rscn->event[i].qualifier == FC_QOS_RSCN_EVENT) {
4590 /*
4591 * Ignore this event.
4592 * f/w would have processed it
4593 */
4594 bfa_trc(port->fcs, rscn_pid);
4595 } else {
4596 port->stats.num_portid_rscn++;
4597 bfa_fcs_lport_scn_portid_rscn(port, rscn_pid);
4598 }
4599 break;
4600
4601 case FC_RSCN_FORMAT_FABRIC:
4602 if (rscn->event[i].qualifier ==
4603 FC_FABRIC_NAME_RSCN_EVENT) {
4604 bfa_fcs_lport_ms_fabric_rscn(port);
4605 break;
4606 }
4607 /* !!!!!!!!! Fall Through !!!!!!!!!!!!! */
4608
4609 case FC_RSCN_FORMAT_AREA:
4610 case FC_RSCN_FORMAT_DOMAIN:
4611 nsquery = BFA_TRUE;
4612 bfa_fcs_lport_scn_multiport_rscn(port,
4613 rscn->event[i].format,
4614 rscn_pid);
4615 break;
4616
4617
4618 default:
4619 WARN_ON(1);
4620 nsquery = BFA_TRUE;
4621 }
4622 }
4623
4624 /*
4625 * If any of area, domain or fabric RSCN is received, do a fresh
4626 * discovery to find new devices.
4627 */
4628 if (nsquery)
4629 bfa_fcs_lport_ns_query(port);
4630}
4631
4632/*
4633 * BFA FCS port
4634 */
4635/*
4636 * fcs_port_api BFA FCS port API
4637 */
4638struct bfa_fcs_lport_s *
4639bfa_fcs_get_base_port(struct bfa_fcs_s *fcs)
4640{
4641 return &fcs->fabric.bport;
4642}
4643
4644wwn_t
4645bfa_fcs_lport_get_rport(struct bfa_fcs_lport_s *port, wwn_t wwn, int index,
4646 int nrports, bfa_boolean_t bwwn)
4647{
4648 struct list_head *qh, *qe;
4649 struct bfa_fcs_rport_s *rport = NULL;
4650 int i;
4651 struct bfa_fcs_s *fcs;
4652
4653 if (port == NULL || nrports == 0)
4654 return (wwn_t) 0;
4655
4656 fcs = port->fcs;
4657 bfa_trc(fcs, (u32) nrports);
4658
4659 i = 0;
4660 qh = &port->rport_q;
4661 qe = bfa_q_first(qh);
4662
4663 while ((qe != qh) && (i < nrports)) {
4664 rport = (struct bfa_fcs_rport_s *) qe;
4665 if (bfa_ntoh3b(rport->pid) > 0xFFF000) {
4666 qe = bfa_q_next(qe);
4667 bfa_trc(fcs, (u32) rport->pwwn);
4668 bfa_trc(fcs, rport->pid);
4669 bfa_trc(fcs, i);
4670 continue;
4671 }
4672
4673 if (bwwn) {
4674 if (!memcmp(&wwn, &rport->pwwn, 8))
4675 break;
4676 } else {
4677 if (i == index)
4678 break;
4679 }
4680
4681 i++;
4682 qe = bfa_q_next(qe);
4683 }
4684
4685 bfa_trc(fcs, i);
4686 if (rport)
4687 return rport->pwwn;
4688 else
4689 return (wwn_t) 0;
4690}
4691
4692void
4693bfa_fcs_lport_get_rports(struct bfa_fcs_lport_s *port,
4694 wwn_t rport_wwns[], int *nrports)
4695{
4696 struct list_head *qh, *qe;
4697 struct bfa_fcs_rport_s *rport = NULL;
4698 int i;
4699 struct bfa_fcs_s *fcs;
4700
4701 if (port == NULL || rport_wwns == NULL || *nrports == 0)
4702 return;
4703
4704 fcs = port->fcs;
4705 bfa_trc(fcs, (u32) *nrports);
4706
4707 i = 0;
4708 qh = &port->rport_q;
4709 qe = bfa_q_first(qh);
4710
4711 while ((qe != qh) && (i < *nrports)) {
4712 rport = (struct bfa_fcs_rport_s *) qe;
4713 if (bfa_ntoh3b(rport->pid) > 0xFFF000) {
4714 qe = bfa_q_next(qe);
4715 bfa_trc(fcs, (u32) rport->pwwn);
4716 bfa_trc(fcs, rport->pid);
4717 bfa_trc(fcs, i);
4718 continue;
4719 }
4720
4721 rport_wwns[i] = rport->pwwn;
4722
4723 i++;
4724 qe = bfa_q_next(qe);
4725 }
4726
4727 bfa_trc(fcs, i);
4728 *nrports = i;
4729}
4730
4731/*
4732 * Iterate's through all the rport's in the given port to
4733 * determine the maximum operating speed.
4734 *
4735 * !!!! To be used in TRL Functionality only !!!!
4736 */
4737bfa_port_speed_t
4738bfa_fcs_lport_get_rport_max_speed(bfa_fcs_lport_t *port)
4739{
4740 struct list_head *qh, *qe;
4741 struct bfa_fcs_rport_s *rport = NULL;
4742 struct bfa_fcs_s *fcs;
4743 bfa_port_speed_t max_speed = 0;
4744 struct bfa_port_attr_s port_attr;
4745 bfa_port_speed_t port_speed, rport_speed;
4746 bfa_boolean_t trl_enabled = bfa_fcport_is_ratelim(port->fcs->bfa);
4747
4748
4749 if (port == NULL)
4750 return 0;
4751
4752 fcs = port->fcs;
4753
4754 /* Get Physical port's current speed */
4755 bfa_fcport_get_attr(port->fcs->bfa, &port_attr);
4756 port_speed = port_attr.speed;
4757 bfa_trc(fcs, port_speed);
4758
4759 qh = &port->rport_q;
4760 qe = bfa_q_first(qh);
4761
4762 while (qe != qh) {
4763 rport = (struct bfa_fcs_rport_s *) qe;
4764 if ((bfa_ntoh3b(rport->pid) > 0xFFF000) ||
4765 (bfa_fcs_rport_get_state(rport) ==
4766 BFA_RPORT_OFFLINE)) {
4767 qe = bfa_q_next(qe);
4768 continue;
4769 }
4770
4771 rport_speed = rport->rpf.rpsc_speed;
4772 if ((trl_enabled) && (rport_speed ==
4773 BFA_PORT_SPEED_UNKNOWN)) {
4774 /* Use default ratelim speed setting */
4775 rport_speed =
4776 bfa_fcport_get_ratelim_speed(port->fcs->bfa);
4777 }
4778
4779 if ((rport_speed == BFA_PORT_SPEED_8GBPS) ||
4780 (rport_speed > port_speed)) {
4781 max_speed = rport_speed;
4782 break;
4783 } else if (rport_speed > max_speed) {
4784 max_speed = rport_speed;
4785 }
4786
4787 qe = bfa_q_next(qe);
4788 }
4789
4790 bfa_trc(fcs, max_speed);
4791 return max_speed;
4792}
4793
4794struct bfa_fcs_lport_s *
4795bfa_fcs_lookup_port(struct bfa_fcs_s *fcs, u16 vf_id, wwn_t lpwwn)
4796{
4797 struct bfa_fcs_vport_s *vport;
4798 bfa_fcs_vf_t *vf;
4799
4800 WARN_ON(fcs == NULL);
4801
4802 vf = bfa_fcs_vf_lookup(fcs, vf_id);
4803 if (vf == NULL) {
4804 bfa_trc(fcs, vf_id);
4805 return NULL;
4806 }
4807
4808 if (!lpwwn || (vf->bport.port_cfg.pwwn == lpwwn))
4809 return &vf->bport;
4810
4811 vport = bfa_fcs_fabric_vport_lookup(vf, lpwwn);
4812 if (vport)
4813 return &vport->lport;
4814
4815 return NULL;
4816}
4817
4818/*
4819 * API corresponding to NPIV_VPORT_GETINFO.
4820 */
4821void
4822bfa_fcs_lport_get_info(struct bfa_fcs_lport_s *port,
4823 struct bfa_lport_info_s *port_info)
4824{
4825
4826 bfa_trc(port->fcs, port->fabric->fabric_name);
4827
4828 if (port->vport == NULL) {
4829 /*
4830 * This is a Physical port
4831 */
4832 port_info->port_type = BFA_LPORT_TYPE_PHYSICAL;
4833
4834 /*
4835 * @todo : need to fix the state & reason
4836 */
4837 port_info->port_state = 0;
4838 port_info->offline_reason = 0;
4839
4840 port_info->port_wwn = bfa_fcs_lport_get_pwwn(port);
4841 port_info->node_wwn = bfa_fcs_lport_get_nwwn(port);
4842
4843 port_info->max_vports_supp =
4844 bfa_lps_get_max_vport(port->fcs->bfa);
4845 port_info->num_vports_inuse =
4846 port->fabric->num_vports;
4847 port_info->max_rports_supp = BFA_FCS_MAX_RPORTS_SUPP;
4848 port_info->num_rports_inuse = port->num_rports;
4849 } else {
4850 /*
4851 * This is a virtual port
4852 */
4853 port_info->port_type = BFA_LPORT_TYPE_VIRTUAL;
4854
4855 /*
4856 * @todo : need to fix the state & reason
4857 */
4858 port_info->port_state = 0;
4859 port_info->offline_reason = 0;
4860
4861 port_info->port_wwn = bfa_fcs_lport_get_pwwn(port);
4862 port_info->node_wwn = bfa_fcs_lport_get_nwwn(port);
4863 }
4864}
4865
4866void
4867bfa_fcs_lport_get_stats(struct bfa_fcs_lport_s *fcs_port,
4868 struct bfa_lport_stats_s *port_stats)
4869{
4870 *port_stats = fcs_port->stats;
4871}
4872
4873void
4874bfa_fcs_lport_clear_stats(struct bfa_fcs_lport_s *fcs_port)
4875{
4876 memset(&fcs_port->stats, 0, sizeof(struct bfa_lport_stats_s));
4877}
4878
4879/*
4880 * FCS virtual port state machine
4881 */
4882
4883#define __vport_fcs(__vp) ((__vp)->lport.fcs)
4884#define __vport_pwwn(__vp) ((__vp)->lport.port_cfg.pwwn)
4885#define __vport_nwwn(__vp) ((__vp)->lport.port_cfg.nwwn)
4886#define __vport_bfa(__vp) ((__vp)->lport.fcs->bfa)
4887#define __vport_fcid(__vp) ((__vp)->lport.pid)
4888#define __vport_fabric(__vp) ((__vp)->lport.fabric)
4889#define __vport_vfid(__vp) ((__vp)->lport.fabric->vf_id)
4890
4891#define BFA_FCS_VPORT_MAX_RETRIES 5
4892/*
4893 * Forward declarations
4894 */
4895static void bfa_fcs_vport_do_fdisc(struct bfa_fcs_vport_s *vport);
4896static void bfa_fcs_vport_timeout(void *vport_arg);
4897static void bfa_fcs_vport_do_logo(struct bfa_fcs_vport_s *vport);
4898static void bfa_fcs_vport_free(struct bfa_fcs_vport_s *vport);
4899
4900/*
4901 * fcs_vport_sm FCS virtual port state machine
4902 */
4903
4904/*
4905 * VPort State Machine events
4906 */
4907enum bfa_fcs_vport_event {
4908 BFA_FCS_VPORT_SM_CREATE = 1, /* vport create event */
4909 BFA_FCS_VPORT_SM_DELETE = 2, /* vport delete event */
4910 BFA_FCS_VPORT_SM_START = 3, /* vport start request */
4911 BFA_FCS_VPORT_SM_STOP = 4, /* stop: unsupported */
4912 BFA_FCS_VPORT_SM_ONLINE = 5, /* fabric online */
4913 BFA_FCS_VPORT_SM_OFFLINE = 6, /* fabric offline event */
4914 BFA_FCS_VPORT_SM_FRMSENT = 7, /* fdisc/logo sent events */
4915 BFA_FCS_VPORT_SM_RSP_OK = 8, /* good response */
4916 BFA_FCS_VPORT_SM_RSP_ERROR = 9, /* error/bad response */
4917 BFA_FCS_VPORT_SM_TIMEOUT = 10, /* delay timer event */
4918 BFA_FCS_VPORT_SM_DELCOMP = 11, /* lport delete completion */
4919 BFA_FCS_VPORT_SM_RSP_DUP_WWN = 12, /* Dup wnn error*/
4920 BFA_FCS_VPORT_SM_RSP_FAILED = 13, /* non-retryable failure */
4921};
4922
4923static void bfa_fcs_vport_sm_uninit(struct bfa_fcs_vport_s *vport,
4924 enum bfa_fcs_vport_event event);
4925static void bfa_fcs_vport_sm_created(struct bfa_fcs_vport_s *vport,
4926 enum bfa_fcs_vport_event event);
4927static void bfa_fcs_vport_sm_offline(struct bfa_fcs_vport_s *vport,
4928 enum bfa_fcs_vport_event event);
4929static void bfa_fcs_vport_sm_fdisc(struct bfa_fcs_vport_s *vport,
4930 enum bfa_fcs_vport_event event);
4931static void bfa_fcs_vport_sm_fdisc_retry(struct bfa_fcs_vport_s *vport,
4932 enum bfa_fcs_vport_event event);
4933static void bfa_fcs_vport_sm_online(struct bfa_fcs_vport_s *vport,
4934 enum bfa_fcs_vport_event event);
4935static void bfa_fcs_vport_sm_deleting(struct bfa_fcs_vport_s *vport,
4936 enum bfa_fcs_vport_event event);
4937static void bfa_fcs_vport_sm_cleanup(struct bfa_fcs_vport_s *vport,
4938 enum bfa_fcs_vport_event event);
4939static void bfa_fcs_vport_sm_logo(struct bfa_fcs_vport_s *vport,
4940 enum bfa_fcs_vport_event event);
4941static void bfa_fcs_vport_sm_error(struct bfa_fcs_vport_s *vport,
4942 enum bfa_fcs_vport_event event);
4943
4944static struct bfa_sm_table_s vport_sm_table[] = {
4945 {BFA_SM(bfa_fcs_vport_sm_uninit), BFA_FCS_VPORT_UNINIT},
4946 {BFA_SM(bfa_fcs_vport_sm_created), BFA_FCS_VPORT_CREATED},
4947 {BFA_SM(bfa_fcs_vport_sm_offline), BFA_FCS_VPORT_OFFLINE},
4948 {BFA_SM(bfa_fcs_vport_sm_fdisc), BFA_FCS_VPORT_FDISC},
4949 {BFA_SM(bfa_fcs_vport_sm_fdisc_retry), BFA_FCS_VPORT_FDISC_RETRY},
4950 {BFA_SM(bfa_fcs_vport_sm_online), BFA_FCS_VPORT_ONLINE},
4951 {BFA_SM(bfa_fcs_vport_sm_deleting), BFA_FCS_VPORT_DELETING},
4952 {BFA_SM(bfa_fcs_vport_sm_cleanup), BFA_FCS_VPORT_CLEANUP},
4953 {BFA_SM(bfa_fcs_vport_sm_logo), BFA_FCS_VPORT_LOGO},
4954 {BFA_SM(bfa_fcs_vport_sm_error), BFA_FCS_VPORT_ERROR}
4955};
4956
4957/*
4958 * Beginning state.
4959 */
4960static void
4961bfa_fcs_vport_sm_uninit(struct bfa_fcs_vport_s *vport,
4962 enum bfa_fcs_vport_event event)
4963{
4964 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
4965 bfa_trc(__vport_fcs(vport), event);
4966
4967 switch (event) {
4968 case BFA_FCS_VPORT_SM_CREATE:
4969 bfa_sm_set_state(vport, bfa_fcs_vport_sm_created);
4970 bfa_fcs_fabric_addvport(__vport_fabric(vport), vport);
4971 break;
4972
4973 default:
4974 bfa_sm_fault(__vport_fcs(vport), event);
4975 }
4976}
4977
4978/*
4979 * Created state - a start event is required to start up the state machine.
4980 */
4981static void
4982bfa_fcs_vport_sm_created(struct bfa_fcs_vport_s *vport,
4983 enum bfa_fcs_vport_event event)
4984{
4985 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
4986 bfa_trc(__vport_fcs(vport), event);
4987
4988 switch (event) {
4989 case BFA_FCS_VPORT_SM_START:
4990 if (bfa_sm_cmp_state(__vport_fabric(vport),
4991 bfa_fcs_fabric_sm_online)
4992 && bfa_fcs_fabric_npiv_capable(__vport_fabric(vport))) {
4993 bfa_sm_set_state(vport, bfa_fcs_vport_sm_fdisc);
4994 bfa_fcs_vport_do_fdisc(vport);
4995 } else {
4996 /*
4997 * Fabric is offline or not NPIV capable, stay in
4998 * offline state.
4999 */
5000 vport->vport_stats.fab_no_npiv++;
5001 bfa_sm_set_state(vport, bfa_fcs_vport_sm_offline);
5002 }
5003 break;
5004
5005 case BFA_FCS_VPORT_SM_DELETE:
5006 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
5007 bfa_fcs_lport_delete(&vport->lport);
5008 break;
5009
5010 case BFA_FCS_VPORT_SM_ONLINE:
5011 case BFA_FCS_VPORT_SM_OFFLINE:
5012 /*
5013 * Ignore ONLINE/OFFLINE events from fabric
5014 * till vport is started.
5015 */
5016 break;
5017
5018 default:
5019 bfa_sm_fault(__vport_fcs(vport), event);
5020 }
5021}
5022
5023/*
5024 * Offline state - awaiting ONLINE event from fabric SM.
5025 */
5026static void
5027bfa_fcs_vport_sm_offline(struct bfa_fcs_vport_s *vport,
5028 enum bfa_fcs_vport_event event)
5029{
5030 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
5031 bfa_trc(__vport_fcs(vport), event);
5032
5033 switch (event) {
5034 case BFA_FCS_VPORT_SM_DELETE:
5035 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
5036 bfa_fcs_lport_delete(&vport->lport);
5037 break;
5038
5039 case BFA_FCS_VPORT_SM_ONLINE:
5040 bfa_sm_set_state(vport, bfa_fcs_vport_sm_fdisc);
5041 vport->fdisc_retries = 0;
5042 bfa_fcs_vport_do_fdisc(vport);
5043 break;
5044
5045 case BFA_FCS_VPORT_SM_OFFLINE:
5046 /*
5047 * This can happen if the vport couldn't be initialzied
5048 * due the fact that the npiv was not enabled on the switch.
5049 * In that case we will put the vport in offline state.
5050 * However, the link can go down and cause the this event to
5051 * be sent when we are already offline. Ignore it.
5052 */
5053 break;
5054
5055 default:
5056 bfa_sm_fault(__vport_fcs(vport), event);
5057 }
5058}
5059
5060
5061/*
5062 * FDISC is sent and awaiting reply from fabric.
5063 */
5064static void
5065bfa_fcs_vport_sm_fdisc(struct bfa_fcs_vport_s *vport,
5066 enum bfa_fcs_vport_event event)
5067{
5068 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
5069 bfa_trc(__vport_fcs(vport), event);
5070
5071 switch (event) {
5072 case BFA_FCS_VPORT_SM_DELETE:
5073 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
5074 bfa_sm_send_event(vport->lps, BFA_LPS_SM_OFFLINE);
5075 bfa_fcs_lport_delete(&vport->lport);
5076 break;
5077
5078 case BFA_FCS_VPORT_SM_OFFLINE:
5079 bfa_sm_set_state(vport, bfa_fcs_vport_sm_offline);
5080 bfa_sm_send_event(vport->lps, BFA_LPS_SM_OFFLINE);
5081 break;
5082
5083 case BFA_FCS_VPORT_SM_RSP_OK:
5084 bfa_sm_set_state(vport, bfa_fcs_vport_sm_online);
5085 bfa_fcs_lport_online(&vport->lport);
5086 break;
5087
5088 case BFA_FCS_VPORT_SM_RSP_ERROR:
5089 bfa_sm_set_state(vport, bfa_fcs_vport_sm_fdisc_retry);
5090 bfa_timer_start(__vport_bfa(vport), &vport->timer,
5091 bfa_fcs_vport_timeout, vport,
5092 BFA_FCS_RETRY_TIMEOUT);
5093 break;
5094
5095 case BFA_FCS_VPORT_SM_RSP_FAILED:
5096 bfa_sm_set_state(vport, bfa_fcs_vport_sm_offline);
5097 break;
5098
5099 case BFA_FCS_VPORT_SM_RSP_DUP_WWN:
5100 bfa_sm_set_state(vport, bfa_fcs_vport_sm_error);
5101 break;
5102
5103 default:
5104 bfa_sm_fault(__vport_fcs(vport), event);
5105 }
5106}
5107
5108/*
5109 * FDISC attempt failed - a timer is active to retry FDISC.
5110 */
5111static void
5112bfa_fcs_vport_sm_fdisc_retry(struct bfa_fcs_vport_s *vport,
5113 enum bfa_fcs_vport_event event)
5114{
5115 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
5116 bfa_trc(__vport_fcs(vport), event);
5117
5118 switch (event) {
5119 case BFA_FCS_VPORT_SM_DELETE:
5120 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
5121 bfa_timer_stop(&vport->timer);
5122 bfa_fcs_lport_delete(&vport->lport);
5123 break;
5124
5125 case BFA_FCS_VPORT_SM_OFFLINE:
5126 bfa_sm_set_state(vport, bfa_fcs_vport_sm_offline);
5127 bfa_timer_stop(&vport->timer);
5128 break;
5129
5130 case BFA_FCS_VPORT_SM_TIMEOUT:
5131 bfa_sm_set_state(vport, bfa_fcs_vport_sm_fdisc);
5132 vport->vport_stats.fdisc_retries++;
5133 vport->fdisc_retries++;
5134 bfa_fcs_vport_do_fdisc(vport);
5135 break;
5136
5137 default:
5138 bfa_sm_fault(__vport_fcs(vport), event);
5139 }
5140}
5141
5142/*
5143 * Vport is online (FDISC is complete).
5144 */
5145static void
5146bfa_fcs_vport_sm_online(struct bfa_fcs_vport_s *vport,
5147 enum bfa_fcs_vport_event event)
5148{
5149 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
5150 bfa_trc(__vport_fcs(vport), event);
5151
5152 switch (event) {
5153 case BFA_FCS_VPORT_SM_DELETE:
5154 bfa_sm_set_state(vport, bfa_fcs_vport_sm_deleting);
5155 bfa_fcs_lport_delete(&vport->lport);
5156 break;
5157
5158 case BFA_FCS_VPORT_SM_OFFLINE:
5159 bfa_sm_set_state(vport, bfa_fcs_vport_sm_offline);
5160 bfa_sm_send_event(vport->lps, BFA_LPS_SM_OFFLINE);
5161 bfa_fcs_lport_offline(&vport->lport);
5162 break;
5163
5164 default:
5165 bfa_sm_fault(__vport_fcs(vport), event);
5166 }
5167}
5168
5169/*
5170 * Vport is being deleted - awaiting lport delete completion to send
5171 * LOGO to fabric.
5172 */
5173static void
5174bfa_fcs_vport_sm_deleting(struct bfa_fcs_vport_s *vport,
5175 enum bfa_fcs_vport_event event)
5176{
5177 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
5178 bfa_trc(__vport_fcs(vport), event);
5179
5180 switch (event) {
5181 case BFA_FCS_VPORT_SM_DELETE:
5182 break;
5183
5184 case BFA_FCS_VPORT_SM_DELCOMP:
5185 bfa_sm_set_state(vport, bfa_fcs_vport_sm_logo);
5186 bfa_fcs_vport_do_logo(vport);
5187 break;
5188
5189 case BFA_FCS_VPORT_SM_OFFLINE:
5190 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
5191 break;
5192
5193 default:
5194 bfa_sm_fault(__vport_fcs(vport), event);
5195 }
5196}
5197
5198/*
5199 * Error State.
5200 * This state will be set when the Vport Creation fails due
5201 * to errors like Dup WWN. In this state only operation allowed
5202 * is a Vport Delete.
5203 */
5204static void
5205bfa_fcs_vport_sm_error(struct bfa_fcs_vport_s *vport,
5206 enum bfa_fcs_vport_event event)
5207{
5208 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
5209 bfa_trc(__vport_fcs(vport), event);
5210
5211 switch (event) {
5212 case BFA_FCS_VPORT_SM_DELETE:
5213 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
5214 bfa_fcs_lport_delete(&vport->lport);
5215 break;
5216
5217 default:
5218 bfa_trc(__vport_fcs(vport), event);
5219 }
5220}
5221
5222/*
5223 * Lport cleanup is in progress since vport is being deleted. Fabric is
5224 * offline, so no LOGO is needed to complete vport deletion.
5225 */
5226static void
5227bfa_fcs_vport_sm_cleanup(struct bfa_fcs_vport_s *vport,
5228 enum bfa_fcs_vport_event event)
5229{
5230 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
5231 bfa_trc(__vport_fcs(vport), event);
5232
5233 switch (event) {
5234 case BFA_FCS_VPORT_SM_DELCOMP:
5235 bfa_sm_set_state(vport, bfa_fcs_vport_sm_uninit);
5236 bfa_fcs_vport_free(vport);
5237 break;
5238
5239 case BFA_FCS_VPORT_SM_DELETE:
5240 break;
5241
5242 default:
5243 bfa_sm_fault(__vport_fcs(vport), event);
5244 }
5245}
5246
5247/*
5248 * LOGO is sent to fabric. Vport delete is in progress. Lport delete cleanup
5249 * is done.
5250 */
5251static void
5252bfa_fcs_vport_sm_logo(struct bfa_fcs_vport_s *vport,
5253 enum bfa_fcs_vport_event event)
5254{
5255 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
5256 bfa_trc(__vport_fcs(vport), event);
5257
5258 switch (event) {
5259 case BFA_FCS_VPORT_SM_OFFLINE:
5260 bfa_sm_send_event(vport->lps, BFA_LPS_SM_OFFLINE);
5261 /*
5262 * !!! fall through !!!
5263 */
5264
5265 case BFA_FCS_VPORT_SM_RSP_OK:
5266 case BFA_FCS_VPORT_SM_RSP_ERROR:
5267 bfa_sm_set_state(vport, bfa_fcs_vport_sm_uninit);
5268 bfa_fcs_vport_free(vport);
5269 break;
5270
5271 case BFA_FCS_VPORT_SM_DELETE:
5272 break;
5273
5274 default:
5275 bfa_sm_fault(__vport_fcs(vport), event);
5276 }
5277}
5278
5279
5280
5281/*
5282 * fcs_vport_private FCS virtual port private functions
5283 */
5284/*
5285 * This routine will be called to send a FDISC command.
5286 */
5287static void
5288bfa_fcs_vport_do_fdisc(struct bfa_fcs_vport_s *vport)
5289{
5290 bfa_lps_fdisc(vport->lps, vport,
5291 bfa_fcport_get_maxfrsize(__vport_bfa(vport)),
5292 __vport_pwwn(vport), __vport_nwwn(vport));
5293 vport->vport_stats.fdisc_sent++;
5294}
5295
5296static void
5297bfa_fcs_vport_fdisc_rejected(struct bfa_fcs_vport_s *vport)
5298{
5299 u8 lsrjt_rsn = vport->lps->lsrjt_rsn;
5300 u8 lsrjt_expl = vport->lps->lsrjt_expl;
5301
5302 bfa_trc(__vport_fcs(vport), lsrjt_rsn);
5303 bfa_trc(__vport_fcs(vport), lsrjt_expl);
5304
5305 /* For certain reason codes, we don't want to retry. */
5306 switch (vport->lps->lsrjt_expl) {
5307 case FC_LS_RJT_EXP_INV_PORT_NAME: /* by brocade */
5308 case FC_LS_RJT_EXP_INVALID_NPORT_ID: /* by Cisco */
5309 if (vport->fdisc_retries < BFA_FCS_VPORT_MAX_RETRIES)
5310 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
5311 else
5312 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_DUP_WWN);
5313 break;
5314
5315 case FC_LS_RJT_EXP_INSUFF_RES:
5316 /*
5317 * This means max logins per port/switch setting on the
5318 * switch was exceeded.
5319 */
5320 if (vport->fdisc_retries < BFA_FCS_VPORT_MAX_RETRIES)
5321 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
5322 else
5323 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_FAILED);
5324 break;
5325
5326 default:
5327 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
5328 }
5329}
5330
5331/*
5332 * Called to send a logout to the fabric. Used when a V-Port is
5333 * deleted/stopped.
5334 */
5335static void
5336bfa_fcs_vport_do_logo(struct bfa_fcs_vport_s *vport)
5337{
5338 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
5339
5340 vport->vport_stats.logo_sent++;
5341 bfa_lps_fdisclogo(vport->lps);
5342}
5343
5344
5345/*
5346 * This routine will be called by bfa_timer on timer timeouts.
5347 *
5348 * param[in] vport - pointer to bfa_fcs_vport_t.
5349 * param[out] vport_status - pointer to return vport status in
5350 *
5351 * return
5352 * void
5353 *
5354 * Special Considerations:
5355 *
5356 * note
5357 */
5358static void
5359bfa_fcs_vport_timeout(void *vport_arg)
5360{
5361 struct bfa_fcs_vport_s *vport = (struct bfa_fcs_vport_s *) vport_arg;
5362
5363 vport->vport_stats.fdisc_timeouts++;
5364 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_TIMEOUT);
5365}
5366
5367static void
5368bfa_fcs_vport_free(struct bfa_fcs_vport_s *vport)
5369{
5370 struct bfad_vport_s *vport_drv =
5371 (struct bfad_vport_s *)vport->vport_drv;
5372
5373 bfa_fcs_fabric_delvport(__vport_fabric(vport), vport);
5374
5375 if (vport_drv->comp_del)
5376 complete(vport_drv->comp_del);
5377
5378 bfa_lps_delete(vport->lps);
5379}
5380
5381
5382
5383/*
5384 * fcs_vport_public FCS virtual port public interfaces
5385 */
5386
5387/*
5388 * Online notification from fabric SM.
5389 */
5390void
5391bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport)
5392{
5393 vport->vport_stats.fab_online++;
5394 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_ONLINE);
5395}
5396
5397/*
5398 * Offline notification from fabric SM.
5399 */
5400void
5401bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport)
5402{
5403 vport->vport_stats.fab_offline++;
5404 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_OFFLINE);
5405}
5406
5407/*
5408 * Cleanup notification from fabric SM on link timer expiry.
5409 */
5410void
5411bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s *vport)
5412{
5413 vport->vport_stats.fab_cleanup++;
5414}
5415/*
5416 * delete notification from fabric SM. To be invoked from within FCS.
5417 */
5418void
5419bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s *vport)
5420{
5421 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_DELETE);
5422}
5423
5424/*
5425 * Delete completion callback from associated lport
5426 */
5427void
5428bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport)
5429{
5430 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_DELCOMP);
5431}
5432
5433
5434
5435/*
5436 * fcs_vport_api Virtual port API
5437 */
5438
5439/*
5440 * Use this function to instantiate a new FCS vport object. This
5441 * function will not trigger any HW initialization process (which will be
5442 * done in vport_start() call)
5443 *
5444 * param[in] vport - pointer to bfa_fcs_vport_t. This space
5445 * needs to be allocated by the driver.
5446 * param[in] fcs - FCS instance
5447 * param[in] vport_cfg - vport configuration
5448 * param[in] vf_id - VF_ID if vport is created within a VF.
5449 * FC_VF_ID_NULL to specify base fabric.
5450 * param[in] vport_drv - Opaque handle back to the driver's vport
5451 * structure
5452 *
5453 * retval BFA_STATUS_OK - on success.
5454 * retval BFA_STATUS_FAILED - on failure.
5455 */
5456bfa_status_t
5457bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport, struct bfa_fcs_s *fcs,
5458 u16 vf_id, struct bfa_lport_cfg_s *vport_cfg,
5459 struct bfad_vport_s *vport_drv)
5460{
5461 if (vport_cfg->pwwn == 0)
5462 return BFA_STATUS_INVALID_WWN;
5463
5464 if (bfa_fcs_lport_get_pwwn(&fcs->fabric.bport) == vport_cfg->pwwn)
5465 return BFA_STATUS_VPORT_WWN_BP;
5466
5467 if (bfa_fcs_vport_lookup(fcs, vf_id, vport_cfg->pwwn) != NULL)
5468 return BFA_STATUS_VPORT_EXISTS;
5469
5470 if (fcs->fabric.num_vports ==
5471 bfa_lps_get_max_vport(fcs->bfa))
5472 return BFA_STATUS_VPORT_MAX;
5473
5474 vport->lps = bfa_lps_alloc(fcs->bfa);
5475 if (!vport->lps)
5476 return BFA_STATUS_VPORT_MAX;
5477
5478 vport->vport_drv = vport_drv;
5479 vport_cfg->preboot_vp = BFA_FALSE;
5480
5481 bfa_sm_set_state(vport, bfa_fcs_vport_sm_uninit);
5482 bfa_fcs_lport_attach(&vport->lport, fcs, vf_id, vport);
5483 bfa_fcs_lport_init(&vport->lport, vport_cfg);
5484 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_CREATE);
5485
5486 return BFA_STATUS_OK;
5487}
5488
5489/*
5490 * Use this function to instantiate a new FCS PBC vport object. This
5491 * function will not trigger any HW initialization process (which will be
5492 * done in vport_start() call)
5493 *
5494 * param[in] vport - pointer to bfa_fcs_vport_t. This space
5495 * needs to be allocated by the driver.
5496 * param[in] fcs - FCS instance
5497 * param[in] vport_cfg - vport configuration
5498 * param[in] vf_id - VF_ID if vport is created within a VF.
5499 * FC_VF_ID_NULL to specify base fabric.
5500 * param[in] vport_drv - Opaque handle back to the driver's vport
5501 * structure
5502 *
5503 * retval BFA_STATUS_OK - on success.
5504 * retval BFA_STATUS_FAILED - on failure.
5505 */
5506bfa_status_t
5507bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s *vport, struct bfa_fcs_s *fcs,
5508 u16 vf_id, struct bfa_lport_cfg_s *vport_cfg,
5509 struct bfad_vport_s *vport_drv)
5510{
5511 bfa_status_t rc;
5512
5513 rc = bfa_fcs_vport_create(vport, fcs, vf_id, vport_cfg, vport_drv);
5514 vport->lport.port_cfg.preboot_vp = BFA_TRUE;
5515
5516 return rc;
5517}
5518
5519/*
5520 * Use this function to findout if this is a pbc vport or not.
5521 *
5522 * @param[in] vport - pointer to bfa_fcs_vport_t.
5523 *
5524 * @returns None
5525 */
5526bfa_boolean_t
5527bfa_fcs_is_pbc_vport(struct bfa_fcs_vport_s *vport)
5528{
5529
5530 if (vport && (vport->lport.port_cfg.preboot_vp == BFA_TRUE))
5531 return BFA_TRUE;
5532 else
5533 return BFA_FALSE;
5534
5535}
5536
5537/*
5538 * Use this function initialize the vport.
5539 *
5540 * @param[in] vport - pointer to bfa_fcs_vport_t.
5541 *
5542 * @returns None
5543 */
5544bfa_status_t
5545bfa_fcs_vport_start(struct bfa_fcs_vport_s *vport)
5546{
5547 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_START);
5548
5549 return BFA_STATUS_OK;
5550}
5551
5552/*
5553 * Use this function quiese the vport object. This function will return
5554 * immediately, when the vport is actually stopped, the
5555 * bfa_drv_vport_stop_cb() will be called.
5556 *
5557 * param[in] vport - pointer to bfa_fcs_vport_t.
5558 *
5559 * return None
5560 */
5561bfa_status_t
5562bfa_fcs_vport_stop(struct bfa_fcs_vport_s *vport)
5563{
5564 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_STOP);
5565
5566 return BFA_STATUS_OK;
5567}
5568
5569/*
5570 * Use this function to delete a vport object. Fabric object should
5571 * be stopped before this function call.
5572 *
5573 * !!!!!!! Donot invoke this from within FCS !!!!!!!
5574 *
5575 * param[in] vport - pointer to bfa_fcs_vport_t.
5576 *
5577 * return None
5578 */
5579bfa_status_t
5580bfa_fcs_vport_delete(struct bfa_fcs_vport_s *vport)
5581{
5582
5583 if (vport->lport.port_cfg.preboot_vp)
5584 return BFA_STATUS_PBC;
5585
5586 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_DELETE);
5587
5588 return BFA_STATUS_OK;
5589}
5590
5591/*
5592 * Use this function to get vport's current status info.
5593 *
5594 * param[in] vport pointer to bfa_fcs_vport_t.
5595 * param[out] attr pointer to return vport attributes
5596 *
5597 * return None
5598 */
5599void
5600bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport,
5601 struct bfa_vport_attr_s *attr)
5602{
5603 if (vport == NULL || attr == NULL)
5604 return;
5605
5606 memset(attr, 0, sizeof(struct bfa_vport_attr_s));
5607
5608 bfa_fcs_lport_get_attr(&vport->lport, &attr->port_attr);
5609 attr->vport_state = bfa_sm_to_state(vport_sm_table, vport->sm);
5610}
5611
5612
5613/*
5614 * Lookup a virtual port. Excludes base port from lookup.
5615 */
5616struct bfa_fcs_vport_s *
5617bfa_fcs_vport_lookup(struct bfa_fcs_s *fcs, u16 vf_id, wwn_t vpwwn)
5618{
5619 struct bfa_fcs_vport_s *vport;
5620 struct bfa_fcs_fabric_s *fabric;
5621
5622 bfa_trc(fcs, vf_id);
5623 bfa_trc(fcs, vpwwn);
5624
5625 fabric = bfa_fcs_vf_lookup(fcs, vf_id);
5626 if (!fabric) {
5627 bfa_trc(fcs, vf_id);
5628 return NULL;
5629 }
5630
5631 vport = bfa_fcs_fabric_vport_lookup(fabric, vpwwn);
5632 return vport;
5633}
5634
5635/*
5636 * FDISC Response
5637 */
5638void
5639bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status)
5640{
5641 struct bfa_fcs_vport_s *vport = uarg;
5642
5643 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
5644 bfa_trc(__vport_fcs(vport), status);
5645
5646 switch (status) {
5647 case BFA_STATUS_OK:
5648 /*
5649 * Initialize the V-Port fields
5650 */
5651 __vport_fcid(vport) = vport->lps->lp_pid;
5652 vport->vport_stats.fdisc_accepts++;
5653 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_OK);
5654 break;
5655
5656 case BFA_STATUS_INVALID_MAC:
5657 /* Only for CNA */
5658 vport->vport_stats.fdisc_acc_bad++;
5659 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
5660
5661 break;
5662
5663 case BFA_STATUS_EPROTOCOL:
5664 switch (vport->lps->ext_status) {
5665 case BFA_EPROTO_BAD_ACCEPT:
5666 vport->vport_stats.fdisc_acc_bad++;
5667 break;
5668
5669 case BFA_EPROTO_UNKNOWN_RSP:
5670 vport->vport_stats.fdisc_unknown_rsp++;
5671 break;
5672
5673 default:
5674 break;
5675 }
5676
5677 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
5678 break;
5679
5680 case BFA_STATUS_FABRIC_RJT:
5681 vport->vport_stats.fdisc_rejects++;
5682 bfa_fcs_vport_fdisc_rejected(vport);
5683 break;
5684
5685 default:
5686 vport->vport_stats.fdisc_rsp_err++;
5687 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
5688 }
5689}
5690
5691/*
5692 * LOGO response
5693 */
5694void
5695bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg)
5696{
5697 struct bfa_fcs_vport_s *vport = uarg;
5698 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_OK);
5699}
5700
5701/*
5702 * Received clear virtual link
5703 */
5704void
5705bfa_cb_lps_cvl_event(void *bfad, void *uarg)
5706{
5707 struct bfa_fcs_vport_s *vport = uarg;
5708
5709 /* Send an Offline followed by an ONLINE */
5710 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_OFFLINE);
5711 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_ONLINE);
5712}
diff --git a/drivers/scsi/bfa/bfa_fcs_port.c b/drivers/scsi/bfa/bfa_fcs_port.c
deleted file mode 100644
index 3c27788cd527..000000000000
--- a/drivers/scsi/bfa/bfa_fcs_port.c
+++ /dev/null
@@ -1,61 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcs_pport.c BFA FCS PPORT ( physical port)
20 */
21
22#include <fcs/bfa_fcs.h>
23#include <bfa_svc.h>
24#include <fcs/bfa_fcs_fabric.h>
25#include "fcs_trcmod.h"
26#include "fcs.h"
27#include "fcs_fabric.h"
28#include "fcs_port.h"
29
30BFA_TRC_FILE(FCS, PPORT);
31
32static void
33bfa_fcs_pport_event_handler(void *cbarg, bfa_pport_event_t event)
34{
35 struct bfa_fcs_s *fcs = cbarg;
36
37 bfa_trc(fcs, event);
38
39 switch (event) {
40 case BFA_PPORT_LINKUP:
41 bfa_fcs_fabric_link_up(&fcs->fabric);
42 break;
43
44 case BFA_PPORT_LINKDOWN:
45 bfa_fcs_fabric_link_down(&fcs->fabric);
46 break;
47
48 case BFA_PPORT_TRUNK_LINKDOWN:
49 bfa_assert(0);
50 break;
51
52 default:
53 bfa_assert(0);
54 }
55}
56
57void
58bfa_fcs_pport_attach(struct bfa_fcs_s *fcs)
59{
60 bfa_fcport_event_register(fcs->bfa, bfa_fcs_pport_event_handler, fcs);
61}
diff --git a/drivers/scsi/bfa/rport.c b/drivers/scsi/bfa/bfa_fcs_rport.c
index 9b4c2c9a644b..caaee6f06937 100644
--- a/drivers/scsi/bfa/rport.c
+++ b/drivers/scsi/bfa/bfa_fcs_rport.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,155 +15,113 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18/** 18/*
19 * rport.c Remote port implementation. 19 * rport.c Remote port implementation.
20 */ 20 */
21 21
22#include <linux/slab.h> 22#include "bfad_drv.h"
23#include <bfa.h> 23#include "bfa_fcs.h"
24#include <bfa_svc.h> 24#include "bfa_fcbuild.h"
25#include "fcbuild.h"
26#include "fcs_vport.h"
27#include "fcs_lport.h"
28#include "fcs_rport.h"
29#include "fcs_fcpim.h"
30#include "fcs_fcptm.h"
31#include "fcs_trcmod.h"
32#include "fcs_fcxp.h"
33#include "fcs.h"
34#include <fcb/bfa_fcb_rport.h>
35#include <aen/bfa_aen_rport.h>
36 25
37BFA_TRC_FILE(FCS, RPORT); 26BFA_TRC_FILE(FCS, RPORT);
38 27
39/* In millisecs */ 28static u32
40static u32 bfa_fcs_rport_del_timeout = 29bfa_fcs_rport_del_timeout = BFA_FCS_RPORT_DEF_DEL_TIMEOUT * 1000;
41 BFA_FCS_RPORT_DEF_DEL_TIMEOUT * 1000; 30 /* In millisecs */
42
43/* 31/*
44 * forward declarations 32 * forward declarations
45 */ 33 */
46static struct bfa_fcs_rport_s *bfa_fcs_rport_alloc(struct bfa_fcs_port_s *port, 34static struct bfa_fcs_rport_s *bfa_fcs_rport_alloc(
47 wwn_t pwwn, u32 rpid); 35 struct bfa_fcs_lport_s *port, wwn_t pwwn, u32 rpid);
48static void bfa_fcs_rport_free(struct bfa_fcs_rport_s *rport); 36static void bfa_fcs_rport_free(struct bfa_fcs_rport_s *rport);
49static void bfa_fcs_rport_hal_online(struct bfa_fcs_rport_s *rport); 37static void bfa_fcs_rport_hal_online(struct bfa_fcs_rport_s *rport);
50static void bfa_fcs_rport_online_action(struct bfa_fcs_rport_s *rport); 38static void bfa_fcs_rport_online_action(struct bfa_fcs_rport_s *rport);
51static void bfa_fcs_rport_offline_action(struct bfa_fcs_rport_s *rport); 39static void bfa_fcs_rport_offline_action(struct bfa_fcs_rport_s *rport);
52static void bfa_fcs_rport_update(struct bfa_fcs_rport_s *rport, 40static void bfa_fcs_rport_update(struct bfa_fcs_rport_s *rport,
53 struct fc_logi_s *plogi); 41 struct fc_logi_s *plogi);
54static void bfa_fcs_rport_fc4_pause(struct bfa_fcs_rport_s *rport); 42static void bfa_fcs_rport_timeout(void *arg);
55static void bfa_fcs_rport_fc4_resume(struct bfa_fcs_rport_s *rport); 43static void bfa_fcs_rport_send_plogi(void *rport_cbarg,
56static void bfa_fcs_rport_timeout(void *arg);
57static void bfa_fcs_rport_send_plogi(void *rport_cbarg,
58 struct bfa_fcxp_s *fcxp_alloced); 44 struct bfa_fcxp_s *fcxp_alloced);
59static void bfa_fcs_rport_send_plogiacc(void *rport_cbarg, 45static void bfa_fcs_rport_send_plogiacc(void *rport_cbarg,
60 struct bfa_fcxp_s *fcxp_alloced); 46 struct bfa_fcxp_s *fcxp_alloced);
61static void bfa_fcs_rport_plogi_response(void *fcsarg, 47static void bfa_fcs_rport_plogi_response(void *fcsarg,
62 struct bfa_fcxp_s *fcxp, 48 struct bfa_fcxp_s *fcxp, void *cbarg,
63 void *cbarg, 49 bfa_status_t req_status, u32 rsp_len,
64 bfa_status_t req_status, 50 u32 resid_len, struct fchs_s *rsp_fchs);
65 u32 rsp_len, 51static void bfa_fcs_rport_send_adisc(void *rport_cbarg,
66 u32 resid_len,
67 struct fchs_s *rsp_fchs);
68static void bfa_fcs_rport_send_adisc(void *rport_cbarg,
69 struct bfa_fcxp_s *fcxp_alloced); 52 struct bfa_fcxp_s *fcxp_alloced);
70static void bfa_fcs_rport_adisc_response(void *fcsarg, 53static void bfa_fcs_rport_adisc_response(void *fcsarg,
71 struct bfa_fcxp_s *fcxp, 54 struct bfa_fcxp_s *fcxp, void *cbarg,
72 void *cbarg, 55 bfa_status_t req_status, u32 rsp_len,
73 bfa_status_t req_status, 56 u32 resid_len, struct fchs_s *rsp_fchs);
74 u32 rsp_len, 57static void bfa_fcs_rport_send_nsdisc(void *rport_cbarg,
75 u32 resid_len,
76 struct fchs_s *rsp_fchs);
77static void bfa_fcs_rport_send_gidpn(void *rport_cbarg,
78 struct bfa_fcxp_s *fcxp_alloced); 58 struct bfa_fcxp_s *fcxp_alloced);
79static void bfa_fcs_rport_gidpn_response(void *fcsarg, 59static void bfa_fcs_rport_gidpn_response(void *fcsarg,
80 struct bfa_fcxp_s *fcxp, 60 struct bfa_fcxp_s *fcxp, void *cbarg,
81 void *cbarg, 61 bfa_status_t req_status, u32 rsp_len,
82 bfa_status_t req_status, 62 u32 resid_len, struct fchs_s *rsp_fchs);
83 u32 rsp_len, 63static void bfa_fcs_rport_gpnid_response(void *fcsarg,
84 u32 resid_len, 64 struct bfa_fcxp_s *fcxp, void *cbarg,
85 struct fchs_s *rsp_fchs); 65 bfa_status_t req_status, u32 rsp_len,
86static void bfa_fcs_rport_send_logo(void *rport_cbarg, 66 u32 resid_len, struct fchs_s *rsp_fchs);
67static void bfa_fcs_rport_send_logo(void *rport_cbarg,
87 struct bfa_fcxp_s *fcxp_alloced); 68 struct bfa_fcxp_s *fcxp_alloced);
88static void bfa_fcs_rport_send_logo_acc(void *rport_cbarg); 69static void bfa_fcs_rport_send_logo_acc(void *rport_cbarg);
89static void bfa_fcs_rport_process_prli(struct bfa_fcs_rport_s *rport, 70static void bfa_fcs_rport_process_prli(struct bfa_fcs_rport_s *rport,
90 struct fchs_s *rx_fchs, u16 len); 71 struct fchs_s *rx_fchs, u16 len);
91static void bfa_fcs_rport_send_ls_rjt(struct bfa_fcs_rport_s *rport, 72static void bfa_fcs_rport_send_ls_rjt(struct bfa_fcs_rport_s *rport,
92 struct fchs_s *rx_fchs, u8 reason_code, 73 struct fchs_s *rx_fchs, u8 reason_code,
93 u8 reason_code_expl); 74 u8 reason_code_expl);
94static void bfa_fcs_rport_process_adisc(struct bfa_fcs_rport_s *rport, 75static void bfa_fcs_rport_process_adisc(struct bfa_fcs_rport_s *rport,
95 struct fchs_s *rx_fchs, u16 len); 76 struct fchs_s *rx_fchs, u16 len);
96static void bfa_fcs_rport_send_prlo_acc(struct bfa_fcs_rport_s *rport); 77static void bfa_fcs_rport_send_prlo_acc(struct bfa_fcs_rport_s *rport);
97/** 78
98 * fcs_rport_sm FCS rport state machine events 79static void bfa_fcs_rport_sm_uninit(struct bfa_fcs_rport_s *rport,
99 */
100
101enum rport_event {
102 RPSM_EVENT_PLOGI_SEND = 1, /* new rport; start with PLOGI */
103 RPSM_EVENT_PLOGI_RCVD = 2, /* Inbound PLOGI from remote port */
104 RPSM_EVENT_PLOGI_COMP = 3, /* PLOGI completed to rport */
105 RPSM_EVENT_LOGO_RCVD = 4, /* LOGO from remote device */
106 RPSM_EVENT_LOGO_IMP = 5, /* implicit logo for SLER */
107 RPSM_EVENT_FCXP_SENT = 6, /* Frame from has been sent */
108 RPSM_EVENT_DELETE = 7, /* RPORT delete request */
109 RPSM_EVENT_SCN = 8, /* state change notification */
110 RPSM_EVENT_ACCEPTED = 9,/* Good response from remote device */
111 RPSM_EVENT_FAILED = 10, /* Request to rport failed. */
112 RPSM_EVENT_TIMEOUT = 11, /* Rport SM timeout event */
113 RPSM_EVENT_HCB_ONLINE = 12, /* BFA rport online callback */
114 RPSM_EVENT_HCB_OFFLINE = 13, /* BFA rport offline callback */
115 RPSM_EVENT_FC4_OFFLINE = 14, /* FC-4 offline complete */
116 RPSM_EVENT_ADDRESS_CHANGE = 15, /* Rport's PID has changed */
117 RPSM_EVENT_ADDRESS_DISC = 16, /* Need to Discover rport's PID */
118 RPSM_EVENT_PRLO_RCVD = 17, /* PRLO from remote device */
119};
120
121static void bfa_fcs_rport_sm_uninit(struct bfa_fcs_rport_s *rport,
122 enum rport_event event); 80 enum rport_event event);
123static void bfa_fcs_rport_sm_plogi_sending(struct bfa_fcs_rport_s *rport, 81static void bfa_fcs_rport_sm_plogi_sending(struct bfa_fcs_rport_s *rport,
124 enum rport_event event); 82 enum rport_event event);
125static void bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s *rport, 83static void bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s *rport,
126 enum rport_event event); 84 enum rport_event event);
127static void bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s *rport, 85static void bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s *rport,
128 enum rport_event event); 86 enum rport_event event);
129static void bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s *rport, 87static void bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s *rport,
130 enum rport_event event); 88 enum rport_event event);
131static void bfa_fcs_rport_sm_hal_online(struct bfa_fcs_rport_s *rport, 89static void bfa_fcs_rport_sm_hal_online(struct bfa_fcs_rport_s *rport,
132 enum rport_event event); 90 enum rport_event event);
133static void bfa_fcs_rport_sm_online(struct bfa_fcs_rport_s *rport, 91static void bfa_fcs_rport_sm_online(struct bfa_fcs_rport_s *rport,
134 enum rport_event event); 92 enum rport_event event);
135static void bfa_fcs_rport_sm_nsquery_sending(struct bfa_fcs_rport_s *rport, 93static void bfa_fcs_rport_sm_nsquery_sending(struct bfa_fcs_rport_s *rport,
136 enum rport_event event); 94 enum rport_event event);
137static void bfa_fcs_rport_sm_nsquery(struct bfa_fcs_rport_s *rport, 95static void bfa_fcs_rport_sm_nsquery(struct bfa_fcs_rport_s *rport,
138 enum rport_event event); 96 enum rport_event event);
139static void bfa_fcs_rport_sm_adisc_sending(struct bfa_fcs_rport_s *rport, 97static void bfa_fcs_rport_sm_adisc_sending(struct bfa_fcs_rport_s *rport,
140 enum rport_event event); 98 enum rport_event event);
141static void bfa_fcs_rport_sm_adisc(struct bfa_fcs_rport_s *rport, 99static void bfa_fcs_rport_sm_adisc(struct bfa_fcs_rport_s *rport,
142 enum rport_event event); 100 enum rport_event event);
143static void bfa_fcs_rport_sm_fc4_logorcv(struct bfa_fcs_rport_s *rport, 101static void bfa_fcs_rport_sm_fc4_logorcv(struct bfa_fcs_rport_s *rport,
144 enum rport_event event); 102 enum rport_event event);
145static void bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s *rport, 103static void bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s *rport,
146 enum rport_event event); 104 enum rport_event event);
147static void bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s *rport, 105static void bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s *rport,
148 enum rport_event event); 106 enum rport_event event);
149static void bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s *rport, 107static void bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s *rport,
150 enum rport_event event); 108 enum rport_event event);
151static void bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s *rport, 109static void bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s *rport,
152 enum rport_event event); 110 enum rport_event event);
153static void bfa_fcs_rport_sm_hcb_logosend(struct bfa_fcs_rport_s *rport, 111static void bfa_fcs_rport_sm_hcb_logosend(struct bfa_fcs_rport_s *rport,
154 enum rport_event event); 112 enum rport_event event);
155static void bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s *rport, 113static void bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s *rport,
156 enum rport_event event); 114 enum rport_event event);
157static void bfa_fcs_rport_sm_offline(struct bfa_fcs_rport_s *rport, 115static void bfa_fcs_rport_sm_offline(struct bfa_fcs_rport_s *rport,
158 enum rport_event event); 116 enum rport_event event);
159static void bfa_fcs_rport_sm_nsdisc_sending(struct bfa_fcs_rport_s *rport, 117static void bfa_fcs_rport_sm_nsdisc_sending(struct bfa_fcs_rport_s *rport,
118 enum rport_event event);
119static void bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s *rport,
120 enum rport_event event);
121static void bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s *rport,
122 enum rport_event event);
123static void bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s *rport,
160 enum rport_event event); 124 enum rport_event event);
161static void bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s *rport,
162 enum rport_event event);
163static void bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s *rport,
164 enum rport_event event);
165static void bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s *rport,
166 enum rport_event event);
167 125
168static struct bfa_sm_table_s rport_sm_table[] = { 126static struct bfa_sm_table_s rport_sm_table[] = {
169 {BFA_SM(bfa_fcs_rport_sm_uninit), BFA_RPORT_UNINIT}, 127 {BFA_SM(bfa_fcs_rport_sm_uninit), BFA_RPORT_UNINIT},
@@ -190,8 +148,8 @@ static struct bfa_sm_table_s rport_sm_table[] = {
190 {BFA_SM(bfa_fcs_rport_sm_nsdisc_sent), BFA_RPORT_NSDISC}, 148 {BFA_SM(bfa_fcs_rport_sm_nsdisc_sent), BFA_RPORT_NSDISC},
191}; 149};
192 150
193/** 151/*
194 * Beginning state. 152 * Beginning state.
195 */ 153 */
196static void 154static void
197bfa_fcs_rport_sm_uninit(struct bfa_fcs_rport_s *rport, enum rport_event event) 155bfa_fcs_rport_sm_uninit(struct bfa_fcs_rport_s *rport, enum rport_event event)
@@ -221,20 +179,19 @@ bfa_fcs_rport_sm_uninit(struct bfa_fcs_rport_s *rport, enum rport_event event)
221 case RPSM_EVENT_ADDRESS_DISC: 179 case RPSM_EVENT_ADDRESS_DISC:
222 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending); 180 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending);
223 rport->ns_retries = 0; 181 rport->ns_retries = 0;
224 bfa_fcs_rport_send_gidpn(rport, NULL); 182 bfa_fcs_rport_send_nsdisc(rport, NULL);
225 break; 183 break;
226
227 default: 184 default:
228 bfa_sm_fault(rport->fcs, event); 185 bfa_sm_fault(rport->fcs, event);
229 } 186 }
230} 187}
231 188
232/** 189/*
233 * PLOGI is being sent. 190 * PLOGI is being sent.
234 */ 191 */
235static void 192static void
236bfa_fcs_rport_sm_plogi_sending(struct bfa_fcs_rport_s *rport, 193bfa_fcs_rport_sm_plogi_sending(struct bfa_fcs_rport_s *rport,
237 enum rport_event event) 194 enum rport_event event)
238{ 195{
239 bfa_trc(rport->fcs, rport->pwwn); 196 bfa_trc(rport->fcs, rport->pwwn);
240 bfa_trc(rport->fcs, rport->pid); 197 bfa_trc(rport->fcs, rport->pid);
@@ -258,10 +215,12 @@ bfa_fcs_rport_sm_plogi_sending(struct bfa_fcs_rport_s *rport,
258 break; 215 break;
259 216
260 case RPSM_EVENT_ADDRESS_CHANGE: 217 case RPSM_EVENT_ADDRESS_CHANGE:
218 case RPSM_EVENT_SCN:
219 /* query the NS */
261 bfa_fcxp_walloc_cancel(rport->fcs->bfa, &rport->fcxp_wqe); 220 bfa_fcxp_walloc_cancel(rport->fcs->bfa, &rport->fcxp_wqe);
262 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending); 221 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending);
263 rport->ns_retries = 0; 222 rport->ns_retries = 0;
264 bfa_fcs_rport_send_gidpn(rport, NULL); 223 bfa_fcs_rport_send_nsdisc(rport, NULL);
265 break; 224 break;
266 225
267 case RPSM_EVENT_LOGO_IMP: 226 case RPSM_EVENT_LOGO_IMP:
@@ -273,20 +232,18 @@ bfa_fcs_rport_sm_plogi_sending(struct bfa_fcs_rport_s *rport,
273 bfa_fcs_rport_del_timeout); 232 bfa_fcs_rport_del_timeout);
274 break; 233 break;
275 234
276 case RPSM_EVENT_SCN:
277 break;
278 235
279 default: 236 default:
280 bfa_sm_fault(rport->fcs, event); 237 bfa_sm_fault(rport->fcs, event);
281 } 238 }
282} 239}
283 240
284/** 241/*
285 * PLOGI is being sent. 242 * PLOGI is being sent.
286 */ 243 */
287static void 244static void
288bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s *rport, 245bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s *rport,
289 enum rport_event event) 246 enum rport_event event)
290{ 247{
291 bfa_trc(rport->fcs, rport->pwwn); 248 bfa_trc(rport->fcs, rport->pwwn);
292 bfa_trc(rport->fcs, rport->pid); 249 bfa_trc(rport->fcs, rport->pid);
@@ -304,8 +261,9 @@ bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s *rport,
304 bfa_fcs_rport_free(rport); 261 bfa_fcs_rport_free(rport);
305 break; 262 break;
306 263
264 case RPSM_EVENT_PLOGI_RCVD:
307 case RPSM_EVENT_SCN: 265 case RPSM_EVENT_SCN:
308 /** 266 /*
309 * Ignore, SCN is possibly online notification. 267 * Ignore, SCN is possibly online notification.
310 */ 268 */
311 break; 269 break;
@@ -314,7 +272,7 @@ bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s *rport,
314 bfa_fcxp_walloc_cancel(rport->fcs->bfa, &rport->fcxp_wqe); 272 bfa_fcxp_walloc_cancel(rport->fcs->bfa, &rport->fcxp_wqe);
315 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending); 273 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending);
316 rport->ns_retries = 0; 274 rport->ns_retries = 0;
317 bfa_fcs_rport_send_gidpn(rport, NULL); 275 bfa_fcs_rport_send_nsdisc(rport, NULL);
318 break; 276 break;
319 277
320 case RPSM_EVENT_LOGO_IMP: 278 case RPSM_EVENT_LOGO_IMP:
@@ -327,7 +285,7 @@ bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s *rport,
327 break; 285 break;
328 286
329 case RPSM_EVENT_HCB_OFFLINE: 287 case RPSM_EVENT_HCB_OFFLINE:
330 /** 288 /*
331 * Ignore BFA callback, on a PLOGI receive we call bfa offline. 289 * Ignore BFA callback, on a PLOGI receive we call bfa offline.
332 */ 290 */
333 break; 291 break;
@@ -337,8 +295,8 @@ bfa_fcs_rport_sm_plogiacc_sending(struct bfa_fcs_rport_s *rport,
337 } 295 }
338} 296}
339 297
340/** 298/*
341 * PLOGI is sent. 299 * PLOGI is sent.
342 */ 300 */
343static void 301static void
344bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s *rport, 302bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s *rport,
@@ -349,24 +307,9 @@ bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s *rport,
349 bfa_trc(rport->fcs, event); 307 bfa_trc(rport->fcs, event);
350 308
351 switch (event) { 309 switch (event) {
352 case RPSM_EVENT_SCN:
353 bfa_timer_stop(&rport->timer);
354 /*
355 * !! fall through !!
356 */
357
358 case RPSM_EVENT_TIMEOUT: 310 case RPSM_EVENT_TIMEOUT:
359 if (rport->plogi_retries < BFA_FCS_RPORT_MAX_RETRIES) { 311 bfa_sm_set_state(rport, bfa_fcs_rport_sm_plogi_sending);
360 rport->plogi_retries++; 312 bfa_fcs_rport_send_plogi(rport, NULL);
361 bfa_sm_set_state(rport, bfa_fcs_rport_sm_plogi_sending);
362 bfa_fcs_rport_send_plogi(rport, NULL);
363 } else {
364 rport->pid = 0;
365 bfa_sm_set_state(rport, bfa_fcs_rport_sm_offline);
366 bfa_timer_start(rport->fcs->bfa, &rport->timer,
367 bfa_fcs_rport_timeout, rport,
368 bfa_fcs_rport_del_timeout);
369 }
370 break; 313 break;
371 314
372 case RPSM_EVENT_DELETE: 315 case RPSM_EVENT_DELETE:
@@ -386,10 +329,11 @@ bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s *rport,
386 break; 329 break;
387 330
388 case RPSM_EVENT_ADDRESS_CHANGE: 331 case RPSM_EVENT_ADDRESS_CHANGE:
332 case RPSM_EVENT_SCN:
389 bfa_timer_stop(&rport->timer); 333 bfa_timer_stop(&rport->timer);
390 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending); 334 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending);
391 rport->ns_retries = 0; 335 rport->ns_retries = 0;
392 bfa_fcs_rport_send_gidpn(rport, NULL); 336 bfa_fcs_rport_send_nsdisc(rport, NULL);
393 break; 337 break;
394 338
395 case RPSM_EVENT_LOGO_IMP: 339 case RPSM_EVENT_LOGO_IMP:
@@ -412,8 +356,8 @@ bfa_fcs_rport_sm_plogi_retry(struct bfa_fcs_rport_s *rport,
412 } 356 }
413} 357}
414 358
415/** 359/*
416 * PLOGI is sent. 360 * PLOGI is sent.
417 */ 361 */
418static void 362static void
419bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s *rport, enum rport_event event) 363bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s *rport, enum rport_event event)
@@ -443,10 +387,28 @@ bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s *rport, enum rport_event event)
443 * !! fall through !! 387 * !! fall through !!
444 */ 388 */
445 case RPSM_EVENT_FAILED: 389 case RPSM_EVENT_FAILED:
390 if (rport->plogi_retries < BFA_FCS_RPORT_MAX_RETRIES) {
391 rport->plogi_retries++;
392 bfa_sm_set_state(rport, bfa_fcs_rport_sm_plogi_retry);
393 bfa_timer_start(rport->fcs->bfa, &rport->timer,
394 bfa_fcs_rport_timeout, rport,
395 BFA_FCS_RETRY_TIMEOUT);
396 } else {
397 bfa_stats(rport->port, rport_del_max_plogi_retry);
398 rport->pid = 0;
399 bfa_sm_set_state(rport, bfa_fcs_rport_sm_offline);
400 bfa_timer_start(rport->fcs->bfa, &rport->timer,
401 bfa_fcs_rport_timeout, rport,
402 bfa_fcs_rport_del_timeout);
403 }
404 break;
405
406 case RPSM_EVENT_PLOGI_RETRY:
407 rport->plogi_retries = 0;
446 bfa_sm_set_state(rport, bfa_fcs_rport_sm_plogi_retry); 408 bfa_sm_set_state(rport, bfa_fcs_rport_sm_plogi_retry);
447 bfa_timer_start(rport->fcs->bfa, &rport->timer, 409 bfa_timer_start(rport->fcs->bfa, &rport->timer,
448 bfa_fcs_rport_timeout, rport, 410 bfa_fcs_rport_timeout, rport,
449 BFA_FCS_RETRY_TIMEOUT); 411 (FC_RA_TOV * 1000));
450 break; 412 break;
451 413
452 case RPSM_EVENT_LOGO_IMP: 414 case RPSM_EVENT_LOGO_IMP:
@@ -459,10 +421,11 @@ bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s *rport, enum rport_event event)
459 break; 421 break;
460 422
461 case RPSM_EVENT_ADDRESS_CHANGE: 423 case RPSM_EVENT_ADDRESS_CHANGE:
424 case RPSM_EVENT_SCN:
462 bfa_fcxp_discard(rport->fcxp); 425 bfa_fcxp_discard(rport->fcxp);
463 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending); 426 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending);
464 rport->ns_retries = 0; 427 rport->ns_retries = 0;
465 bfa_fcs_rport_send_gidpn(rport, NULL); 428 bfa_fcs_rport_send_nsdisc(rport, NULL);
466 break; 429 break;
467 430
468 case RPSM_EVENT_PLOGI_RCVD: 431 case RPSM_EVENT_PLOGI_RCVD:
@@ -471,12 +434,6 @@ bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s *rport, enum rport_event event)
471 bfa_fcs_rport_send_plogiacc(rport, NULL); 434 bfa_fcs_rport_send_plogiacc(rport, NULL);
472 break; 435 break;
473 436
474 case RPSM_EVENT_SCN:
475 /**
476 * Ignore SCN - wait for PLOGI response.
477 */
478 break;
479
480 case RPSM_EVENT_DELETE: 437 case RPSM_EVENT_DELETE:
481 bfa_sm_set_state(rport, bfa_fcs_rport_sm_uninit); 438 bfa_sm_set_state(rport, bfa_fcs_rport_sm_uninit);
482 bfa_fcxp_discard(rport->fcxp); 439 bfa_fcxp_discard(rport->fcxp);
@@ -494,9 +451,9 @@ bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s *rport, enum rport_event event)
494 } 451 }
495} 452}
496 453
497/** 454/*
498 * PLOGI is complete. Awaiting BFA rport online callback. FC-4s 455 * PLOGI is complete. Awaiting BFA rport online callback. FC-4s
499 * are offline. 456 * are offline.
500 */ 457 */
501static void 458static void
502bfa_fcs_rport_sm_hal_online(struct bfa_fcs_rport_s *rport, 459bfa_fcs_rport_sm_hal_online(struct bfa_fcs_rport_s *rport,
@@ -517,28 +474,28 @@ bfa_fcs_rport_sm_hal_online(struct bfa_fcs_rport_s *rport,
517 474
518 case RPSM_EVENT_LOGO_RCVD: 475 case RPSM_EVENT_LOGO_RCVD:
519 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_logorcv); 476 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_logorcv);
520 bfa_rport_offline(rport->bfa_rport); 477 bfa_sm_send_event(rport->bfa_rport, BFA_RPORT_SM_OFFLINE);
521 break; 478 break;
522 479
523 case RPSM_EVENT_LOGO_IMP: 480 case RPSM_EVENT_LOGO_IMP:
524 case RPSM_EVENT_ADDRESS_CHANGE: 481 case RPSM_EVENT_ADDRESS_CHANGE:
525 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_offline); 482 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_offline);
526 bfa_rport_offline(rport->bfa_rport); 483 bfa_sm_send_event(rport->bfa_rport, BFA_RPORT_SM_OFFLINE);
527 break; 484 break;
528 485
529 case RPSM_EVENT_PLOGI_RCVD: 486 case RPSM_EVENT_PLOGI_RCVD:
530 bfa_sm_set_state(rport, bfa_fcs_rport_sm_plogiacc_sending); 487 bfa_sm_set_state(rport, bfa_fcs_rport_sm_plogiacc_sending);
531 bfa_rport_offline(rport->bfa_rport); 488 bfa_sm_send_event(rport->bfa_rport, BFA_RPORT_SM_OFFLINE);
532 bfa_fcs_rport_send_plogiacc(rport, NULL); 489 bfa_fcs_rport_send_plogiacc(rport, NULL);
533 break; 490 break;
534 491
535 case RPSM_EVENT_DELETE: 492 case RPSM_EVENT_DELETE:
536 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_logosend); 493 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_logosend);
537 bfa_rport_offline(rport->bfa_rport); 494 bfa_sm_send_event(rport->bfa_rport, BFA_RPORT_SM_OFFLINE);
538 break; 495 break;
539 496
540 case RPSM_EVENT_SCN: 497 case RPSM_EVENT_SCN:
541 /** 498 /*
542 * @todo 499 * @todo
543 * Ignore SCN - PLOGI just completed, FC-4 login should detect 500 * Ignore SCN - PLOGI just completed, FC-4 login should detect
544 * device failures. 501 * device failures.
@@ -550,8 +507,8 @@ bfa_fcs_rport_sm_hal_online(struct bfa_fcs_rport_s *rport,
550 } 507 }
551} 508}
552 509
553/** 510/*
554 * Rport is ONLINE. FC-4s active. 511 * Rport is ONLINE. FC-4s active.
555 */ 512 */
556static void 513static void
557bfa_fcs_rport_sm_online(struct bfa_fcs_rport_s *rport, enum rport_event event) 514bfa_fcs_rport_sm_online(struct bfa_fcs_rport_s *rport, enum rport_event event)
@@ -562,18 +519,11 @@ bfa_fcs_rport_sm_online(struct bfa_fcs_rport_s *rport, enum rport_event event)
562 519
563 switch (event) { 520 switch (event) {
564 case RPSM_EVENT_SCN: 521 case RPSM_EVENT_SCN:
565 /**
566 * Pause FC-4 activity till rport is authenticated.
567 * In switched fabrics, check presence of device in nameserver
568 * first.
569 */
570 bfa_fcs_rport_fc4_pause(rport);
571
572 if (bfa_fcs_fabric_is_switched(rport->port->fabric)) { 522 if (bfa_fcs_fabric_is_switched(rport->port->fabric)) {
573 bfa_sm_set_state(rport, 523 bfa_sm_set_state(rport,
574 bfa_fcs_rport_sm_nsquery_sending); 524 bfa_fcs_rport_sm_nsquery_sending);
575 rport->ns_retries = 0; 525 rport->ns_retries = 0;
576 bfa_fcs_rport_send_gidpn(rport, NULL); 526 bfa_fcs_rport_send_nsdisc(rport, NULL);
577 } else { 527 } else {
578 bfa_sm_set_state(rport, bfa_fcs_rport_sm_adisc_sending); 528 bfa_sm_set_state(rport, bfa_fcs_rport_sm_adisc_sending);
579 bfa_fcs_rport_send_adisc(rport, NULL); 529 bfa_fcs_rport_send_adisc(rport, NULL);
@@ -606,13 +556,13 @@ bfa_fcs_rport_sm_online(struct bfa_fcs_rport_s *rport, enum rport_event event)
606 } 556 }
607} 557}
608 558
609/** 559/*
610 * An SCN event is received in ONLINE state. NS query is being sent 560 * An SCN event is received in ONLINE state. NS query is being sent
611 * prior to ADISC authentication with rport. FC-4s are paused. 561 * prior to ADISC authentication with rport. FC-4s are paused.
612 */ 562 */
613static void 563static void
614bfa_fcs_rport_sm_nsquery_sending(struct bfa_fcs_rport_s *rport, 564bfa_fcs_rport_sm_nsquery_sending(struct bfa_fcs_rport_s *rport,
615 enum rport_event event) 565 enum rport_event event)
616{ 566{
617 bfa_trc(rport->fcs, rport->pwwn); 567 bfa_trc(rport->fcs, rport->pwwn);
618 bfa_trc(rport->fcs, rport->pid); 568 bfa_trc(rport->fcs, rport->pid);
@@ -630,7 +580,7 @@ bfa_fcs_rport_sm_nsquery_sending(struct bfa_fcs_rport_s *rport,
630 break; 580 break;
631 581
632 case RPSM_EVENT_SCN: 582 case RPSM_EVENT_SCN:
633 /** 583 /*
634 * ignore SCN, wait for response to query itself 584 * ignore SCN, wait for response to query itself
635 */ 585 */
636 break; 586 break;
@@ -664,9 +614,9 @@ bfa_fcs_rport_sm_nsquery_sending(struct bfa_fcs_rport_s *rport,
664 } 614 }
665} 615}
666 616
667/** 617/*
668 * An SCN event is received in ONLINE state. NS query is sent to rport. 618 * An SCN event is received in ONLINE state. NS query is sent to rport.
669 * FC-4s are paused. 619 * FC-4s are paused.
670 */ 620 */
671static void 621static void
672bfa_fcs_rport_sm_nsquery(struct bfa_fcs_rport_s *rport, enum rport_event event) 622bfa_fcs_rport_sm_nsquery(struct bfa_fcs_rport_s *rport, enum rport_event event)
@@ -686,7 +636,7 @@ bfa_fcs_rport_sm_nsquery(struct bfa_fcs_rport_s *rport, enum rport_event event)
686 if (rport->ns_retries < BFA_FCS_RPORT_MAX_RETRIES) { 636 if (rport->ns_retries < BFA_FCS_RPORT_MAX_RETRIES) {
687 bfa_sm_set_state(rport, 637 bfa_sm_set_state(rport,
688 bfa_fcs_rport_sm_nsquery_sending); 638 bfa_fcs_rport_sm_nsquery_sending);
689 bfa_fcs_rport_send_gidpn(rport, NULL); 639 bfa_fcs_rport_send_nsdisc(rport, NULL);
690 } else { 640 } else {
691 bfa_sm_set_state(rport, bfa_fcs_rport_sm_fc4_offline); 641 bfa_sm_set_state(rport, bfa_fcs_rport_sm_fc4_offline);
692 bfa_fcs_rport_offline_action(rport); 642 bfa_fcs_rport_offline_action(rport);
@@ -723,13 +673,13 @@ bfa_fcs_rport_sm_nsquery(struct bfa_fcs_rport_s *rport, enum rport_event event)
723 } 673 }
724} 674}
725 675
726/** 676/*
727 * An SCN event is received in ONLINE state. ADISC is being sent for 677 * An SCN event is received in ONLINE state. ADISC is being sent for
728 * authenticating with rport. FC-4s are paused. 678 * authenticating with rport. FC-4s are paused.
729 */ 679 */
730static void 680static void
731bfa_fcs_rport_sm_adisc_sending(struct bfa_fcs_rport_s *rport, 681bfa_fcs_rport_sm_adisc_sending(struct bfa_fcs_rport_s *rport,
732 enum rport_event event) 682 enum rport_event event)
733{ 683{
734 bfa_trc(rport->fcs, rport->pwwn); 684 bfa_trc(rport->fcs, rport->pwwn);
735 bfa_trc(rport->fcs, rport->pid); 685 bfa_trc(rport->fcs, rport->pid);
@@ -774,9 +724,9 @@ bfa_fcs_rport_sm_adisc_sending(struct bfa_fcs_rport_s *rport,
774 } 724 }
775} 725}
776 726
777/** 727/*
778 * An SCN event is received in ONLINE state. ADISC is to rport. 728 * An SCN event is received in ONLINE state. ADISC is to rport.
779 * FC-4s are paused. 729 * FC-4s are paused.
780 */ 730 */
781static void 731static void
782bfa_fcs_rport_sm_adisc(struct bfa_fcs_rport_s *rport, enum rport_event event) 732bfa_fcs_rport_sm_adisc(struct bfa_fcs_rport_s *rport, enum rport_event event)
@@ -788,11 +738,10 @@ bfa_fcs_rport_sm_adisc(struct bfa_fcs_rport_s *rport, enum rport_event event)
788 switch (event) { 738 switch (event) {
789 case RPSM_EVENT_ACCEPTED: 739 case RPSM_EVENT_ACCEPTED:
790 bfa_sm_set_state(rport, bfa_fcs_rport_sm_online); 740 bfa_sm_set_state(rport, bfa_fcs_rport_sm_online);
791 bfa_fcs_rport_fc4_resume(rport);
792 break; 741 break;
793 742
794 case RPSM_EVENT_PLOGI_RCVD: 743 case RPSM_EVENT_PLOGI_RCVD:
795 /** 744 /*
796 * Too complex to cleanup FC-4 & rport and then acc to PLOGI. 745 * Too complex to cleanup FC-4 & rport and then acc to PLOGI.
797 * At least go offline when a PLOGI is received. 746 * At least go offline when a PLOGI is received.
798 */ 747 */
@@ -814,7 +763,7 @@ bfa_fcs_rport_sm_adisc(struct bfa_fcs_rport_s *rport, enum rport_event event)
814 break; 763 break;
815 764
816 case RPSM_EVENT_SCN: 765 case RPSM_EVENT_SCN:
817 /** 766 /*
818 * already processing RSCN 767 * already processing RSCN
819 */ 768 */
820 break; 769 break;
@@ -837,8 +786,8 @@ bfa_fcs_rport_sm_adisc(struct bfa_fcs_rport_s *rport, enum rport_event event)
837 } 786 }
838} 787}
839 788
840/** 789/*
841 * Rport has sent LOGO. Awaiting FC-4 offline completion callback. 790 * Rport has sent LOGO. Awaiting FC-4 offline completion callback.
842 */ 791 */
843static void 792static void
844bfa_fcs_rport_sm_fc4_logorcv(struct bfa_fcs_rport_s *rport, 793bfa_fcs_rport_sm_fc4_logorcv(struct bfa_fcs_rport_s *rport,
@@ -851,7 +800,7 @@ bfa_fcs_rport_sm_fc4_logorcv(struct bfa_fcs_rport_s *rport,
851 switch (event) { 800 switch (event) {
852 case RPSM_EVENT_FC4_OFFLINE: 801 case RPSM_EVENT_FC4_OFFLINE:
853 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_logorcv); 802 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_logorcv);
854 bfa_rport_offline(rport->bfa_rport); 803 bfa_sm_send_event(rport->bfa_rport, BFA_RPORT_SM_OFFLINE);
855 break; 804 break;
856 805
857 case RPSM_EVENT_DELETE: 806 case RPSM_EVENT_DELETE:
@@ -868,13 +817,13 @@ bfa_fcs_rport_sm_fc4_logorcv(struct bfa_fcs_rport_s *rport,
868 } 817 }
869} 818}
870 819
871/** 820/*
872 * LOGO needs to be sent to rport. Awaiting FC-4 offline completion 821 * LOGO needs to be sent to rport. Awaiting FC-4 offline completion
873 * callback. 822 * callback.
874 */ 823 */
875static void 824static void
876bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s *rport, 825bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s *rport,
877 enum rport_event event) 826 enum rport_event event)
878{ 827{
879 bfa_trc(rport->fcs, rport->pwwn); 828 bfa_trc(rport->fcs, rport->pwwn);
880 bfa_trc(rport->fcs, rport->pid); 829 bfa_trc(rport->fcs, rport->pid);
@@ -883,7 +832,7 @@ bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s *rport,
883 switch (event) { 832 switch (event) {
884 case RPSM_EVENT_FC4_OFFLINE: 833 case RPSM_EVENT_FC4_OFFLINE:
885 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_logosend); 834 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_logosend);
886 bfa_rport_offline(rport->bfa_rport); 835 bfa_sm_send_event(rport->bfa_rport, BFA_RPORT_SM_OFFLINE);
887 break; 836 break;
888 837
889 default: 838 default:
@@ -891,8 +840,8 @@ bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s *rport,
891 } 840 }
892} 841}
893 842
894/** 843/*
895 * Rport is going offline. Awaiting FC-4 offline completion callback. 844 * Rport is going offline. Awaiting FC-4 offline completion callback.
896 */ 845 */
897static void 846static void
898bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s *rport, 847bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s *rport,
@@ -905,7 +854,7 @@ bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s *rport,
905 switch (event) { 854 switch (event) {
906 case RPSM_EVENT_FC4_OFFLINE: 855 case RPSM_EVENT_FC4_OFFLINE:
907 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_offline); 856 bfa_sm_set_state(rport, bfa_fcs_rport_sm_hcb_offline);
908 bfa_rport_offline(rport->bfa_rport); 857 bfa_sm_send_event(rport->bfa_rport, BFA_RPORT_SM_OFFLINE);
909 break; 858 break;
910 859
911 case RPSM_EVENT_SCN: 860 case RPSM_EVENT_SCN:
@@ -913,7 +862,7 @@ bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s *rport,
913 case RPSM_EVENT_LOGO_RCVD: 862 case RPSM_EVENT_LOGO_RCVD:
914 case RPSM_EVENT_PRLO_RCVD: 863 case RPSM_EVENT_PRLO_RCVD:
915 case RPSM_EVENT_ADDRESS_CHANGE: 864 case RPSM_EVENT_ADDRESS_CHANGE:
916 /** 865 /*
917 * rport is already going offline. 866 * rport is already going offline.
918 * SCN - ignore and wait till transitioning to offline state 867 * SCN - ignore and wait till transitioning to offline state
919 */ 868 */
@@ -928,13 +877,13 @@ bfa_fcs_rport_sm_fc4_offline(struct bfa_fcs_rport_s *rport,
928 } 877 }
929} 878}
930 879
931/** 880/*
932 * Rport is offline. FC-4s are offline. Awaiting BFA rport offline 881 * Rport is offline. FC-4s are offline. Awaiting BFA rport offline
933 * callback. 882 * callback.
934 */ 883 */
935static void 884static void
936bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s *rport, 885bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s *rport,
937 enum rport_event event) 886 enum rport_event event)
938{ 887{
939 bfa_trc(rport->fcs, rport->pwwn); 888 bfa_trc(rport->fcs, rport->pwwn);
940 bfa_trc(rport->fcs, rport->pid); 889 bfa_trc(rport->fcs, rport->pid);
@@ -943,12 +892,12 @@ bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s *rport,
943 switch (event) { 892 switch (event) {
944 case RPSM_EVENT_HCB_OFFLINE: 893 case RPSM_EVENT_HCB_OFFLINE:
945 case RPSM_EVENT_ADDRESS_CHANGE: 894 case RPSM_EVENT_ADDRESS_CHANGE:
946 if (bfa_fcs_port_is_online(rport->port)) { 895 if (bfa_fcs_lport_is_online(rport->port)) {
947 if (bfa_fcs_fabric_is_switched(rport->port->fabric)) { 896 if (bfa_fcs_fabric_is_switched(rport->port->fabric)) {
948 bfa_sm_set_state(rport, 897 bfa_sm_set_state(rport,
949 bfa_fcs_rport_sm_nsdisc_sending); 898 bfa_fcs_rport_sm_nsdisc_sending);
950 rport->ns_retries = 0; 899 rport->ns_retries = 0;
951 bfa_fcs_rport_send_gidpn(rport, NULL); 900 bfa_fcs_rport_send_nsdisc(rport, NULL);
952 } else { 901 } else {
953 bfa_sm_set_state(rport, 902 bfa_sm_set_state(rport,
954 bfa_fcs_rport_sm_plogi_sending); 903 bfa_fcs_rport_sm_plogi_sending);
@@ -972,7 +921,7 @@ bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s *rport,
972 case RPSM_EVENT_SCN: 921 case RPSM_EVENT_SCN:
973 case RPSM_EVENT_LOGO_RCVD: 922 case RPSM_EVENT_LOGO_RCVD:
974 case RPSM_EVENT_PRLO_RCVD: 923 case RPSM_EVENT_PRLO_RCVD:
975 /** 924 /*
976 * Ignore, already offline. 925 * Ignore, already offline.
977 */ 926 */
978 break; 927 break;
@@ -982,9 +931,9 @@ bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s *rport,
982 } 931 }
983} 932}
984 933
985/** 934/*
986 * Rport is offline. FC-4s are offline. Awaiting BFA rport offline 935 * Rport is offline. FC-4s are offline. Awaiting BFA rport offline
987 * callback to send LOGO accept. 936 * callback to send LOGO accept.
988 */ 937 */
989static void 938static void
990bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s *rport, 939bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s *rport,
@@ -1001,21 +950,21 @@ bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s *rport,
1001 bfa_fcs_rport_send_prlo_acc(rport); 950 bfa_fcs_rport_send_prlo_acc(rport);
1002 if (rport->pid && (rport->prlo == BFA_FALSE)) 951 if (rport->pid && (rport->prlo == BFA_FALSE))
1003 bfa_fcs_rport_send_logo_acc(rport); 952 bfa_fcs_rport_send_logo_acc(rport);
1004
1005 /* 953 /*
1006 * If the lport is online and if the rport is not a well known 954 * If the lport is online and if the rport is not a well
1007 * address port, we try to re-discover the r-port. 955 * known address port,
956 * we try to re-discover the r-port.
1008 */ 957 */
1009 if (bfa_fcs_port_is_online(rport->port) 958 if (bfa_fcs_lport_is_online(rport->port) &&
1010 && (!BFA_FCS_PID_IS_WKA(rport->pid))) { 959 (!BFA_FCS_PID_IS_WKA(rport->pid))) {
1011 bfa_sm_set_state(rport, 960 bfa_sm_set_state(rport,
1012 bfa_fcs_rport_sm_nsdisc_sending); 961 bfa_fcs_rport_sm_nsdisc_sending);
1013 rport->ns_retries = 0; 962 rport->ns_retries = 0;
1014 bfa_fcs_rport_send_gidpn(rport, NULL); 963 bfa_fcs_rport_send_nsdisc(rport, NULL);
1015 } else { 964 } else {
1016 /* 965 /*
1017 * if it is not a well known address, reset the pid to 966 * if it is not a well known address, reset the
1018 * 967 * pid to 0.
1019 */ 968 */
1020 if (!BFA_FCS_PID_IS_WKA(rport->pid)) 969 if (!BFA_FCS_PID_IS_WKA(rport->pid))
1021 rport->pid = 0; 970 rport->pid = 0;
@@ -1036,7 +985,7 @@ bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s *rport,
1036 985
1037 case RPSM_EVENT_LOGO_RCVD: 986 case RPSM_EVENT_LOGO_RCVD:
1038 case RPSM_EVENT_PRLO_RCVD: 987 case RPSM_EVENT_PRLO_RCVD:
1039 /** 988 /*
1040 * Ignore - already processing a LOGO. 989 * Ignore - already processing a LOGO.
1041 */ 990 */
1042 break; 991 break;
@@ -1046,13 +995,14 @@ bfa_fcs_rport_sm_hcb_logorcv(struct bfa_fcs_rport_s *rport,
1046 } 995 }
1047} 996}
1048 997
1049/** 998/*
1050 * Rport is being deleted. FC-4s are offline. Awaiting BFA rport offline 999 * Rport is being deleted. FC-4s are offline.
1051 * callback to send LOGO. 1000 * Awaiting BFA rport offline
1001 * callback to send LOGO.
1052 */ 1002 */
1053static void 1003static void
1054bfa_fcs_rport_sm_hcb_logosend(struct bfa_fcs_rport_s *rport, 1004bfa_fcs_rport_sm_hcb_logosend(struct bfa_fcs_rport_s *rport,
1055 enum rport_event event) 1005 enum rport_event event)
1056{ 1006{
1057 bfa_trc(rport->fcs, rport->pwwn); 1007 bfa_trc(rport->fcs, rport->pwwn);
1058 bfa_trc(rport->fcs, rport->pid); 1008 bfa_trc(rport->fcs, rport->pid);
@@ -1074,12 +1024,12 @@ bfa_fcs_rport_sm_hcb_logosend(struct bfa_fcs_rport_s *rport,
1074 } 1024 }
1075} 1025}
1076 1026
1077/** 1027/*
1078 * Rport is being deleted. FC-4s are offline. LOGO is being sent. 1028 * Rport is being deleted. FC-4s are offline. LOGO is being sent.
1079 */ 1029 */
1080static void 1030static void
1081bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s *rport, 1031bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s *rport,
1082 enum rport_event event) 1032 enum rport_event event)
1083{ 1033{
1084 bfa_trc(rport->fcs, rport->pwwn); 1034 bfa_trc(rport->fcs, rport->pwwn);
1085 bfa_trc(rport->fcs, rport->pid); 1035 bfa_trc(rport->fcs, rport->pid);
@@ -1087,9 +1037,7 @@ bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s *rport,
1087 1037
1088 switch (event) { 1038 switch (event) {
1089 case RPSM_EVENT_FCXP_SENT: 1039 case RPSM_EVENT_FCXP_SENT:
1090 /* 1040 /* Once LOGO is sent, we donot wait for the response */
1091 * Once LOGO is sent, we donot wait for the response
1092 */
1093 bfa_sm_set_state(rport, bfa_fcs_rport_sm_uninit); 1041 bfa_sm_set_state(rport, bfa_fcs_rport_sm_uninit);
1094 bfa_fcs_rport_free(rport); 1042 bfa_fcs_rport_free(rport);
1095 break; 1043 break;
@@ -1110,9 +1058,9 @@ bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s *rport,
1110 } 1058 }
1111} 1059}
1112 1060
1113/** 1061/*
1114 * Rport is offline. FC-4s are offline. BFA rport is offline. 1062 * Rport is offline. FC-4s are offline. BFA rport is offline.
1115 * Timer active to delete stale rport. 1063 * Timer active to delete stale rport.
1116 */ 1064 */
1117static void 1065static void
1118bfa_fcs_rport_sm_offline(struct bfa_fcs_rport_s *rport, enum rport_event event) 1066bfa_fcs_rport_sm_offline(struct bfa_fcs_rport_s *rport, enum rport_event event)
@@ -1132,7 +1080,7 @@ bfa_fcs_rport_sm_offline(struct bfa_fcs_rport_s *rport, enum rport_event event)
1132 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending); 1080 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending);
1133 bfa_timer_stop(&rport->timer); 1081 bfa_timer_stop(&rport->timer);
1134 rport->ns_retries = 0; 1082 rport->ns_retries = 0;
1135 bfa_fcs_rport_send_gidpn(rport, NULL); 1083 bfa_fcs_rport_send_nsdisc(rport, NULL);
1136 break; 1084 break;
1137 1085
1138 case RPSM_EVENT_DELETE: 1086 case RPSM_EVENT_DELETE:
@@ -1170,12 +1118,12 @@ bfa_fcs_rport_sm_offline(struct bfa_fcs_rport_s *rport, enum rport_event event)
1170 } 1118 }
1171} 1119}
1172 1120
1173/** 1121/*
1174 * Rport address has changed. Nameserver discovery request is being sent. 1122 * Rport address has changed. Nameserver discovery request is being sent.
1175 */ 1123 */
1176static void 1124static void
1177bfa_fcs_rport_sm_nsdisc_sending(struct bfa_fcs_rport_s *rport, 1125bfa_fcs_rport_sm_nsdisc_sending(struct bfa_fcs_rport_s *rport,
1178 enum rport_event event) 1126 enum rport_event event)
1179{ 1127{
1180 bfa_trc(rport->fcs, rport->pwwn); 1128 bfa_trc(rport->fcs, rport->pwwn);
1181 bfa_trc(rport->fcs, rport->pid); 1129 bfa_trc(rport->fcs, rport->pid);
@@ -1205,7 +1153,7 @@ bfa_fcs_rport_sm_nsdisc_sending(struct bfa_fcs_rport_s *rport,
1205 break; 1153 break;
1206 1154
1207 case RPSM_EVENT_ADDRESS_CHANGE: 1155 case RPSM_EVENT_ADDRESS_CHANGE:
1208 rport->ns_retries = 0; /* reset the retry count */ 1156 rport->ns_retries = 0; /* reset the retry count */
1209 break; 1157 break;
1210 1158
1211 case RPSM_EVENT_LOGO_IMP: 1159 case RPSM_EVENT_LOGO_IMP:
@@ -1227,12 +1175,12 @@ bfa_fcs_rport_sm_nsdisc_sending(struct bfa_fcs_rport_s *rport,
1227 } 1175 }
1228} 1176}
1229 1177
1230/** 1178/*
1231 * Nameserver discovery failed. Waiting for timeout to retry. 1179 * Nameserver discovery failed. Waiting for timeout to retry.
1232 */ 1180 */
1233static void 1181static void
1234bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s *rport, 1182bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s *rport,
1235 enum rport_event event) 1183 enum rport_event event)
1236{ 1184{
1237 bfa_trc(rport->fcs, rport->pwwn); 1185 bfa_trc(rport->fcs, rport->pwwn);
1238 bfa_trc(rport->fcs, rport->pid); 1186 bfa_trc(rport->fcs, rport->pid);
@@ -1241,7 +1189,7 @@ bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s *rport,
1241 switch (event) { 1189 switch (event) {
1242 case RPSM_EVENT_TIMEOUT: 1190 case RPSM_EVENT_TIMEOUT:
1243 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending); 1191 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending);
1244 bfa_fcs_rport_send_gidpn(rport, NULL); 1192 bfa_fcs_rport_send_nsdisc(rport, NULL);
1245 break; 1193 break;
1246 1194
1247 case RPSM_EVENT_SCN: 1195 case RPSM_EVENT_SCN:
@@ -1249,7 +1197,7 @@ bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s *rport,
1249 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending); 1197 bfa_sm_set_state(rport, bfa_fcs_rport_sm_nsdisc_sending);
1250 bfa_timer_stop(&rport->timer); 1198 bfa_timer_stop(&rport->timer);
1251 rport->ns_retries = 0; 1199 rport->ns_retries = 0;
1252 bfa_fcs_rport_send_gidpn(rport, NULL); 1200 bfa_fcs_rport_send_nsdisc(rport, NULL);
1253 break; 1201 break;
1254 1202
1255 case RPSM_EVENT_DELETE: 1203 case RPSM_EVENT_DELETE:
@@ -1276,7 +1224,6 @@ bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s *rport,
1276 case RPSM_EVENT_LOGO_RCVD: 1224 case RPSM_EVENT_LOGO_RCVD:
1277 bfa_fcs_rport_send_logo_acc(rport); 1225 bfa_fcs_rport_send_logo_acc(rport);
1278 break; 1226 break;
1279
1280 case RPSM_EVENT_PRLO_RCVD: 1227 case RPSM_EVENT_PRLO_RCVD:
1281 bfa_fcs_rport_send_prlo_acc(rport); 1228 bfa_fcs_rport_send_prlo_acc(rport);
1282 break; 1229 break;
@@ -1292,8 +1239,8 @@ bfa_fcs_rport_sm_nsdisc_retry(struct bfa_fcs_rport_s *rport,
1292 } 1239 }
1293} 1240}
1294 1241
1295/** 1242/*
1296 * Rport address has changed. Nameserver discovery request is sent. 1243 * Rport address has changed. Nameserver discovery request is sent.
1297 */ 1244 */
1298static void 1245static void
1299bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s *rport, 1246bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s *rport,
@@ -1311,9 +1258,9 @@ bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s *rport,
1311 bfa_fcs_rport_send_plogi(rport, NULL); 1258 bfa_fcs_rport_send_plogi(rport, NULL);
1312 } else { 1259 } else {
1313 bfa_sm_set_state(rport, 1260 bfa_sm_set_state(rport,
1314 bfa_fcs_rport_sm_nsdisc_sending); 1261 bfa_fcs_rport_sm_nsdisc_sending);
1315 rport->ns_retries = 0; 1262 rport->ns_retries = 0;
1316 bfa_fcs_rport_send_gidpn(rport, NULL); 1263 bfa_fcs_rport_send_nsdisc(rport, NULL);
1317 } 1264 }
1318 break; 1265 break;
1319 1266
@@ -1321,8 +1268,8 @@ bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s *rport,
1321 rport->ns_retries++; 1268 rport->ns_retries++;
1322 if (rport->ns_retries < BFA_FCS_RPORT_MAX_RETRIES) { 1269 if (rport->ns_retries < BFA_FCS_RPORT_MAX_RETRIES) {
1323 bfa_sm_set_state(rport, 1270 bfa_sm_set_state(rport,
1324 bfa_fcs_rport_sm_nsdisc_sending); 1271 bfa_fcs_rport_sm_nsdisc_sending);
1325 bfa_fcs_rport_send_gidpn(rport, NULL); 1272 bfa_fcs_rport_send_nsdisc(rport, NULL);
1326 } else { 1273 } else {
1327 rport->pid = 0; 1274 rport->pid = 0;
1328 bfa_sm_set_state(rport, bfa_fcs_rport_sm_offline); 1275 bfa_sm_set_state(rport, bfa_fcs_rport_sm_offline);
@@ -1353,18 +1300,18 @@ bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s *rport,
1353 bfa_fcs_rport_del_timeout); 1300 bfa_fcs_rport_del_timeout);
1354 break; 1301 break;
1355 1302
1303
1356 case RPSM_EVENT_PRLO_RCVD: 1304 case RPSM_EVENT_PRLO_RCVD:
1357 bfa_fcs_rport_send_prlo_acc(rport); 1305 bfa_fcs_rport_send_prlo_acc(rport);
1358 break; 1306 break;
1359
1360 case RPSM_EVENT_SCN: 1307 case RPSM_EVENT_SCN:
1361 /** 1308 /*
1362 * ignore, wait for NS query response 1309 * ignore, wait for NS query response
1363 */ 1310 */
1364 break; 1311 break;
1365 1312
1366 case RPSM_EVENT_LOGO_RCVD: 1313 case RPSM_EVENT_LOGO_RCVD:
1367 /** 1314 /*
1368 * Not logged-in yet. Accept LOGO. 1315 * Not logged-in yet. Accept LOGO.
1369 */ 1316 */
1370 bfa_fcs_rport_send_logo_acc(rport); 1317 bfa_fcs_rport_send_logo_acc(rport);
@@ -1383,7 +1330,7 @@ bfa_fcs_rport_sm_nsdisc_sent(struct bfa_fcs_rport_s *rport,
1383 1330
1384 1331
1385 1332
1386/** 1333/*
1387 * fcs_rport_private FCS RPORT provate functions 1334 * fcs_rport_private FCS RPORT provate functions
1388 */ 1335 */
1389 1336
@@ -1391,29 +1338,29 @@ static void
1391bfa_fcs_rport_send_plogi(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced) 1338bfa_fcs_rport_send_plogi(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1392{ 1339{
1393 struct bfa_fcs_rport_s *rport = rport_cbarg; 1340 struct bfa_fcs_rport_s *rport = rport_cbarg;
1394 struct bfa_fcs_port_s *port = rport->port; 1341 struct bfa_fcs_lport_s *port = rport->port;
1395 struct fchs_s fchs; 1342 struct fchs_s fchs;
1396 int len; 1343 int len;
1397 struct bfa_fcxp_s *fcxp; 1344 struct bfa_fcxp_s *fcxp;
1398 1345
1399 bfa_trc(rport->fcs, rport->pwwn); 1346 bfa_trc(rport->fcs, rport->pwwn);
1400 1347
1401 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs); 1348 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
1402 if (!fcxp) { 1349 if (!fcxp) {
1403 bfa_fcxp_alloc_wait(port->fcs->bfa, &rport->fcxp_wqe, 1350 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &rport->fcxp_wqe,
1404 bfa_fcs_rport_send_plogi, rport); 1351 bfa_fcs_rport_send_plogi, rport);
1405 return; 1352 return;
1406 } 1353 }
1407 rport->fcxp = fcxp; 1354 rport->fcxp = fcxp;
1408 1355
1409 len = fc_plogi_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid, 1356 len = fc_plogi_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid,
1410 bfa_fcs_port_get_fcid(port), 0, 1357 bfa_fcs_lport_get_fcid(port), 0,
1411 port->port_cfg.pwwn, port->port_cfg.nwwn, 1358 port->port_cfg.pwwn, port->port_cfg.nwwn,
1412 bfa_fcport_get_maxfrsize(port->fcs->bfa)); 1359 bfa_fcport_get_maxfrsize(port->fcs->bfa));
1413 1360
1414 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, 1361 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1415 FC_CLASS_3, len, &fchs, bfa_fcs_rport_plogi_response, 1362 FC_CLASS_3, len, &fchs, bfa_fcs_rport_plogi_response,
1416 (void *)rport, FC_MAX_PDUSZ, FC_ELS_TOV); 1363 (void *)rport, FC_MAX_PDUSZ, FC_ELS_TOV);
1417 1364
1418 rport->stats.plogis++; 1365 rport->stats.plogis++;
1419 bfa_sm_send_event(rport, RPSM_EVENT_FCXP_SENT); 1366 bfa_sm_send_event(rport, RPSM_EVENT_FCXP_SENT);
@@ -1421,14 +1368,14 @@ bfa_fcs_rport_send_plogi(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1421 1368
1422static void 1369static void
1423bfa_fcs_rport_plogi_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg, 1370bfa_fcs_rport_plogi_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1424 bfa_status_t req_status, u32 rsp_len, 1371 bfa_status_t req_status, u32 rsp_len,
1425 u32 resid_len, struct fchs_s *rsp_fchs) 1372 u32 resid_len, struct fchs_s *rsp_fchs)
1426{ 1373{
1427 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *)cbarg; 1374 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *) cbarg;
1428 struct fc_logi_s *plogi_rsp; 1375 struct fc_logi_s *plogi_rsp;
1429 struct fc_ls_rjt_s *ls_rjt; 1376 struct fc_ls_rjt_s *ls_rjt;
1430 struct bfa_fcs_rport_s *twin; 1377 struct bfa_fcs_rport_s *twin;
1431 struct list_head *qe; 1378 struct list_head *qe;
1432 1379
1433 bfa_trc(rport->fcs, rport->pwwn); 1380 bfa_trc(rport->fcs, rport->pwwn);
1434 1381
@@ -1444,7 +1391,7 @@ bfa_fcs_rport_plogi_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1444 1391
1445 plogi_rsp = (struct fc_logi_s *) BFA_FCXP_RSP_PLD(fcxp); 1392 plogi_rsp = (struct fc_logi_s *) BFA_FCXP_RSP_PLD(fcxp);
1446 1393
1447 /** 1394 /*
1448 * Check for failure first. 1395 * Check for failure first.
1449 */ 1396 */
1450 if (plogi_rsp->els_cmd.els_code != FC_ELS_ACC) { 1397 if (plogi_rsp->els_cmd.els_code != FC_ELS_ACC) {
@@ -1453,35 +1400,42 @@ bfa_fcs_rport_plogi_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1453 bfa_trc(rport->fcs, ls_rjt->reason_code); 1400 bfa_trc(rport->fcs, ls_rjt->reason_code);
1454 bfa_trc(rport->fcs, ls_rjt->reason_code_expl); 1401 bfa_trc(rport->fcs, ls_rjt->reason_code_expl);
1455 1402
1403 if ((ls_rjt->reason_code == FC_LS_RJT_RSN_UNABLE_TO_PERF_CMD) &&
1404 (ls_rjt->reason_code_expl == FC_LS_RJT_EXP_INSUFF_RES)) {
1405 rport->stats.rjt_insuff_res++;
1406 bfa_sm_send_event(rport, RPSM_EVENT_PLOGI_RETRY);
1407 return;
1408 }
1409
1456 rport->stats.plogi_rejects++; 1410 rport->stats.plogi_rejects++;
1457 bfa_sm_send_event(rport, RPSM_EVENT_FAILED); 1411 bfa_sm_send_event(rport, RPSM_EVENT_FAILED);
1458 return; 1412 return;
1459 } 1413 }
1460 1414
1461 /** 1415 /*
1462 * PLOGI is complete. Make sure this device is not one of the known 1416 * PLOGI is complete. Make sure this device is not one of the known
1463 * device with a new FC port address. 1417 * device with a new FC port address.
1464 */ 1418 */
1465 list_for_each(qe, &rport->port->rport_q) { 1419 list_for_each(qe, &rport->port->rport_q) {
1466 twin = (struct bfa_fcs_rport_s *)qe; 1420 twin = (struct bfa_fcs_rport_s *) qe;
1467 if (twin == rport) 1421 if (twin == rport)
1468 continue; 1422 continue;
1469 if (!rport->pwwn && (plogi_rsp->port_name == twin->pwwn)) { 1423 if (!rport->pwwn && (plogi_rsp->port_name == twin->pwwn)) {
1470 bfa_trc(rport->fcs, twin->pid); 1424 bfa_trc(rport->fcs, twin->pid);
1471 bfa_trc(rport->fcs, rport->pid); 1425 bfa_trc(rport->fcs, rport->pid);
1472 1426
1473 /* 1427 /* Update plogi stats in twin */
1474 * Update plogi stats in twin 1428 twin->stats.plogis += rport->stats.plogis;
1475 */ 1429 twin->stats.plogi_rejects +=
1476 twin->stats.plogis += rport->stats.plogis; 1430 rport->stats.plogi_rejects;
1477 twin->stats.plogi_rejects += rport->stats.plogi_rejects; 1431 twin->stats.plogi_timeouts +=
1478 twin->stats.plogi_timeouts += 1432 rport->stats.plogi_timeouts;
1479 rport->stats.plogi_timeouts; 1433 twin->stats.plogi_failed +=
1480 twin->stats.plogi_failed += rport->stats.plogi_failed; 1434 rport->stats.plogi_failed;
1481 twin->stats.plogi_rcvd += rport->stats.plogi_rcvd; 1435 twin->stats.plogi_rcvd += rport->stats.plogi_rcvd;
1482 twin->stats.plogi_accs++; 1436 twin->stats.plogi_accs++;
1483 1437
1484 bfa_fcs_rport_delete(rport); 1438 bfa_sm_send_event(rport, RPSM_EVENT_DELETE);
1485 1439
1486 bfa_fcs_rport_update(twin, plogi_rsp); 1440 bfa_fcs_rport_update(twin, plogi_rsp);
1487 twin->pid = rsp_fchs->s_id; 1441 twin->pid = rsp_fchs->s_id;
@@ -1490,7 +1444,7 @@ bfa_fcs_rport_plogi_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1490 } 1444 }
1491 } 1445 }
1492 1446
1493 /** 1447 /*
1494 * Normal login path -- no evil twins. 1448 * Normal login path -- no evil twins.
1495 */ 1449 */
1496 rport->stats.plogi_accs++; 1450 rport->stats.plogi_accs++;
@@ -1502,9 +1456,9 @@ static void
1502bfa_fcs_rport_send_plogiacc(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced) 1456bfa_fcs_rport_send_plogiacc(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1503{ 1457{
1504 struct bfa_fcs_rport_s *rport = rport_cbarg; 1458 struct bfa_fcs_rport_s *rport = rport_cbarg;
1505 struct bfa_fcs_port_s *port = rport->port; 1459 struct bfa_fcs_lport_s *port = rport->port;
1506 struct fchs_s fchs; 1460 struct fchs_s fchs;
1507 int len; 1461 int len;
1508 struct bfa_fcxp_s *fcxp; 1462 struct bfa_fcxp_s *fcxp;
1509 1463
1510 bfa_trc(rport->fcs, rport->pwwn); 1464 bfa_trc(rport->fcs, rport->pwwn);
@@ -1512,19 +1466,20 @@ bfa_fcs_rport_send_plogiacc(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1512 1466
1513 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs); 1467 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
1514 if (!fcxp) { 1468 if (!fcxp) {
1515 bfa_fcxp_alloc_wait(port->fcs->bfa, &rport->fcxp_wqe, 1469 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &rport->fcxp_wqe,
1516 bfa_fcs_rport_send_plogiacc, rport); 1470 bfa_fcs_rport_send_plogiacc, rport);
1517 return; 1471 return;
1518 } 1472 }
1519 rport->fcxp = fcxp; 1473 rport->fcxp = fcxp;
1520 1474
1521 len = fc_plogi_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid, 1475 len = fc_plogi_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
1522 bfa_fcs_port_get_fcid(port), rport->reply_oxid, 1476 rport->pid, bfa_fcs_lport_get_fcid(port),
1523 port->port_cfg.pwwn, port->port_cfg.nwwn, 1477 rport->reply_oxid, port->port_cfg.pwwn,
1478 port->port_cfg.nwwn,
1524 bfa_fcport_get_maxfrsize(port->fcs->bfa)); 1479 bfa_fcport_get_maxfrsize(port->fcs->bfa));
1525 1480
1526 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, 1481 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1527 FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0); 1482 FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0);
1528 1483
1529 bfa_sm_send_event(rport, RPSM_EVENT_FCXP_SENT); 1484 bfa_sm_send_event(rport, RPSM_EVENT_FCXP_SENT);
1530} 1485}
@@ -1533,28 +1488,28 @@ static void
1533bfa_fcs_rport_send_adisc(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced) 1488bfa_fcs_rport_send_adisc(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1534{ 1489{
1535 struct bfa_fcs_rport_s *rport = rport_cbarg; 1490 struct bfa_fcs_rport_s *rport = rport_cbarg;
1536 struct bfa_fcs_port_s *port = rport->port; 1491 struct bfa_fcs_lport_s *port = rport->port;
1537 struct fchs_s fchs; 1492 struct fchs_s fchs;
1538 int len; 1493 int len;
1539 struct bfa_fcxp_s *fcxp; 1494 struct bfa_fcxp_s *fcxp;
1540 1495
1541 bfa_trc(rport->fcs, rport->pwwn); 1496 bfa_trc(rport->fcs, rport->pwwn);
1542 1497
1543 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs); 1498 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
1544 if (!fcxp) { 1499 if (!fcxp) {
1545 bfa_fcxp_alloc_wait(port->fcs->bfa, &rport->fcxp_wqe, 1500 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &rport->fcxp_wqe,
1546 bfa_fcs_rport_send_adisc, rport); 1501 bfa_fcs_rport_send_adisc, rport);
1547 return; 1502 return;
1548 } 1503 }
1549 rport->fcxp = fcxp; 1504 rport->fcxp = fcxp;
1550 1505
1551 len = fc_adisc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid, 1506 len = fc_adisc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid,
1552 bfa_fcs_port_get_fcid(port), 0, 1507 bfa_fcs_lport_get_fcid(port), 0,
1553 port->port_cfg.pwwn, port->port_cfg.nwwn); 1508 port->port_cfg.pwwn, port->port_cfg.nwwn);
1554 1509
1555 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, 1510 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1556 FC_CLASS_3, len, &fchs, bfa_fcs_rport_adisc_response, 1511 FC_CLASS_3, len, &fchs, bfa_fcs_rport_adisc_response,
1557 rport, FC_MAX_PDUSZ, FC_ELS_TOV); 1512 rport, FC_MAX_PDUSZ, FC_ELS_TOV);
1558 1513
1559 rport->stats.adisc_sent++; 1514 rport->stats.adisc_sent++;
1560 bfa_sm_send_event(rport, RPSM_EVENT_FCXP_SENT); 1515 bfa_sm_send_event(rport, RPSM_EVENT_FCXP_SENT);
@@ -1562,12 +1517,12 @@ bfa_fcs_rport_send_adisc(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1562 1517
1563static void 1518static void
1564bfa_fcs_rport_adisc_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg, 1519bfa_fcs_rport_adisc_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1565 bfa_status_t req_status, u32 rsp_len, 1520 bfa_status_t req_status, u32 rsp_len,
1566 u32 resid_len, struct fchs_s *rsp_fchs) 1521 u32 resid_len, struct fchs_s *rsp_fchs)
1567{ 1522{
1568 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *)cbarg; 1523 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *) cbarg;
1569 void *pld = bfa_fcxp_get_rspbuf(fcxp); 1524 void *pld = bfa_fcxp_get_rspbuf(fcxp);
1570 struct fc_ls_rjt_s *ls_rjt; 1525 struct fc_ls_rjt_s *ls_rjt;
1571 1526
1572 if (req_status != BFA_STATUS_OK) { 1527 if (req_status != BFA_STATUS_OK) {
1573 bfa_trc(rport->fcs, req_status); 1528 bfa_trc(rport->fcs, req_status);
@@ -1577,7 +1532,7 @@ bfa_fcs_rport_adisc_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1577 } 1532 }
1578 1533
1579 if (fc_adisc_rsp_parse((struct fc_adisc_s *)pld, rsp_len, rport->pwwn, 1534 if (fc_adisc_rsp_parse((struct fc_adisc_s *)pld, rsp_len, rport->pwwn,
1580 rport->nwwn) == FC_PARSE_OK) { 1535 rport->nwwn) == FC_PARSE_OK) {
1581 rport->stats.adisc_accs++; 1536 rport->stats.adisc_accs++;
1582 bfa_sm_send_event(rport, RPSM_EVENT_ACCEPTED); 1537 bfa_sm_send_event(rport, RPSM_EVENT_ACCEPTED);
1583 return; 1538 return;
@@ -1592,70 +1547,74 @@ bfa_fcs_rport_adisc_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1592} 1547}
1593 1548
1594static void 1549static void
1595bfa_fcs_rport_send_gidpn(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced) 1550bfa_fcs_rport_send_nsdisc(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1596{ 1551{
1597 struct bfa_fcs_rport_s *rport = rport_cbarg; 1552 struct bfa_fcs_rport_s *rport = rport_cbarg;
1598 struct bfa_fcs_port_s *port = rport->port; 1553 struct bfa_fcs_lport_s *port = rport->port;
1599 struct fchs_s fchs; 1554 struct fchs_s fchs;
1600 struct bfa_fcxp_s *fcxp; 1555 struct bfa_fcxp_s *fcxp;
1601 int len; 1556 int len;
1557 bfa_cb_fcxp_send_t cbfn;
1602 1558
1603 bfa_trc(rport->fcs, rport->pid); 1559 bfa_trc(rport->fcs, rport->pid);
1604 1560
1605 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs); 1561 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
1606 if (!fcxp) { 1562 if (!fcxp) {
1607 bfa_fcxp_alloc_wait(port->fcs->bfa, &rport->fcxp_wqe, 1563 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &rport->fcxp_wqe,
1608 bfa_fcs_rport_send_gidpn, rport); 1564 bfa_fcs_rport_send_nsdisc, rport);
1609 return; 1565 return;
1610 } 1566 }
1611 rport->fcxp = fcxp; 1567 rport->fcxp = fcxp;
1612 1568
1613 len = fc_gidpn_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), 1569 if (rport->pwwn) {
1614 bfa_fcs_port_get_fcid(port), 0, rport->pwwn); 1570 len = fc_gidpn_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
1571 bfa_fcs_lport_get_fcid(port), 0, rport->pwwn);
1572 cbfn = bfa_fcs_rport_gidpn_response;
1573 } else {
1574 len = fc_gpnid_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
1575 bfa_fcs_lport_get_fcid(port), 0, rport->pid);
1576 cbfn = bfa_fcs_rport_gpnid_response;
1577 }
1615 1578
1616 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, 1579 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1617 FC_CLASS_3, len, &fchs, bfa_fcs_rport_gidpn_response, 1580 FC_CLASS_3, len, &fchs, cbfn,
1618 (void *)rport, FC_MAX_PDUSZ, FC_FCCT_TOV); 1581 (void *)rport, FC_MAX_PDUSZ, FC_FCCT_TOV);
1619 1582
1620 bfa_sm_send_event(rport, RPSM_EVENT_FCXP_SENT); 1583 bfa_sm_send_event(rport, RPSM_EVENT_FCXP_SENT);
1621} 1584}
1622 1585
1623static void 1586static void
1624bfa_fcs_rport_gidpn_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg, 1587bfa_fcs_rport_gidpn_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1625 bfa_status_t req_status, u32 rsp_len, 1588 bfa_status_t req_status, u32 rsp_len,
1626 u32 resid_len, struct fchs_s *rsp_fchs) 1589 u32 resid_len, struct fchs_s *rsp_fchs)
1627{ 1590{
1628 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *)cbarg; 1591 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *) cbarg;
1629 struct bfa_fcs_rport_s *twin; 1592 struct ct_hdr_s *cthdr;
1630 struct list_head *qe;
1631 struct ct_hdr_s *cthdr;
1632 struct fcgs_gidpn_resp_s *gidpn_rsp; 1593 struct fcgs_gidpn_resp_s *gidpn_rsp;
1594 struct bfa_fcs_rport_s *twin;
1595 struct list_head *qe;
1633 1596
1634 bfa_trc(rport->fcs, rport->pwwn); 1597 bfa_trc(rport->fcs, rport->pwwn);
1635 1598
1636 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp); 1599 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
1637 cthdr->cmd_rsp_code = bfa_os_ntohs(cthdr->cmd_rsp_code); 1600 cthdr->cmd_rsp_code = be16_to_cpu(cthdr->cmd_rsp_code);
1638 1601
1639 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) { 1602 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
1640 /* 1603 /* Check if the pid is the same as before. */
1641 * Check if the pid is the same as before.
1642 */
1643 gidpn_rsp = (struct fcgs_gidpn_resp_s *) (cthdr + 1); 1604 gidpn_rsp = (struct fcgs_gidpn_resp_s *) (cthdr + 1);
1644 1605
1645 if (gidpn_rsp->dap == rport->pid) { 1606 if (gidpn_rsp->dap == rport->pid) {
1646 /* 1607 /* Device is online */
1647 * Device is online
1648 */
1649 bfa_sm_send_event(rport, RPSM_EVENT_ACCEPTED); 1608 bfa_sm_send_event(rport, RPSM_EVENT_ACCEPTED);
1650 } else { 1609 } else {
1651 /* 1610 /*
1652 * Device's PID has changed. We need to cleanup and 1611 * Device's PID has changed. We need to cleanup
1653 * re-login. If there is another device with the the 1612 * and re-login. If there is another device with
1654 * newly discovered pid, send an scn notice so that its 1613 * the the newly discovered pid, send an scn notice
1655 * new pid can be discovered. 1614 * so that its new pid can be discovered.
1656 */ 1615 */
1657 list_for_each(qe, &rport->port->rport_q) { 1616 list_for_each(qe, &rport->port->rport_q) {
1658 twin = (struct bfa_fcs_rport_s *)qe; 1617 twin = (struct bfa_fcs_rport_s *) qe;
1659 if (twin == rport) 1618 if (twin == rport)
1660 continue; 1619 continue;
1661 if (gidpn_rsp->dap == twin->pid) { 1620 if (gidpn_rsp->dap == twin->pid) {
@@ -1664,7 +1623,7 @@ bfa_fcs_rport_gidpn_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1664 1623
1665 twin->pid = 0; 1624 twin->pid = 0;
1666 bfa_sm_send_event(twin, 1625 bfa_sm_send_event(twin,
1667 RPSM_EVENT_ADDRESS_CHANGE); 1626 RPSM_EVENT_ADDRESS_CHANGE);
1668 } 1627 }
1669 } 1628 }
1670 rport->pid = gidpn_rsp->dap; 1629 rport->pid = gidpn_rsp->dap;
@@ -1697,17 +1656,59 @@ bfa_fcs_rport_gidpn_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1697 } 1656 }
1698} 1657}
1699 1658
1700/** 1659static void
1701 * Called to send a logout to the rport. 1660bfa_fcs_rport_gpnid_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1661 bfa_status_t req_status, u32 rsp_len,
1662 u32 resid_len, struct fchs_s *rsp_fchs)
1663{
1664 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *) cbarg;
1665 struct ct_hdr_s *cthdr;
1666
1667 bfa_trc(rport->fcs, rport->pwwn);
1668
1669 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
1670 cthdr->cmd_rsp_code = be16_to_cpu(cthdr->cmd_rsp_code);
1671
1672 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
1673 bfa_sm_send_event(rport, RPSM_EVENT_ACCEPTED);
1674 return;
1675 }
1676
1677 /*
1678 * Reject Response
1679 */
1680 switch (cthdr->reason_code) {
1681 case CT_RSN_LOGICAL_BUSY:
1682 /*
1683 * Need to retry
1684 */
1685 bfa_sm_send_event(rport, RPSM_EVENT_TIMEOUT);
1686 break;
1687
1688 case CT_RSN_UNABLE_TO_PERF:
1689 /*
1690 * device doesn't exist : Start timer to cleanup this later.
1691 */
1692 bfa_sm_send_event(rport, RPSM_EVENT_FAILED);
1693 break;
1694
1695 default:
1696 bfa_sm_send_event(rport, RPSM_EVENT_FAILED);
1697 break;
1698 }
1699}
1700
1701/*
1702 * Called to send a logout to the rport.
1702 */ 1703 */
1703static void 1704static void
1704bfa_fcs_rport_send_logo(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced) 1705bfa_fcs_rport_send_logo(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1705{ 1706{
1706 struct bfa_fcs_rport_s *rport = rport_cbarg; 1707 struct bfa_fcs_rport_s *rport = rport_cbarg;
1707 struct bfa_fcs_port_s *port; 1708 struct bfa_fcs_lport_s *port;
1708 struct fchs_s fchs; 1709 struct fchs_s fchs;
1709 struct bfa_fcxp_s *fcxp; 1710 struct bfa_fcxp_s *fcxp;
1710 u16 len; 1711 u16 len;
1711 1712
1712 bfa_trc(rport->fcs, rport->pid); 1713 bfa_trc(rport->fcs, rport->pid);
1713 1714
@@ -1715,36 +1716,36 @@ bfa_fcs_rport_send_logo(void *rport_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1715 1716
1716 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs); 1717 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
1717 if (!fcxp) { 1718 if (!fcxp) {
1718 bfa_fcxp_alloc_wait(port->fcs->bfa, &rport->fcxp_wqe, 1719 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &rport->fcxp_wqe,
1719 bfa_fcs_rport_send_logo, rport); 1720 bfa_fcs_rport_send_logo, rport);
1720 return; 1721 return;
1721 } 1722 }
1722 rport->fcxp = fcxp; 1723 rport->fcxp = fcxp;
1723 1724
1724 len = fc_logo_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid, 1725 len = fc_logo_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid,
1725 bfa_fcs_port_get_fcid(port), 0, 1726 bfa_fcs_lport_get_fcid(port), 0,
1726 bfa_fcs_port_get_pwwn(port)); 1727 bfa_fcs_lport_get_pwwn(port));
1727 1728
1728 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, 1729 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1729 FC_CLASS_3, len, &fchs, NULL, rport, FC_MAX_PDUSZ, 1730 FC_CLASS_3, len, &fchs, NULL,
1730 FC_ELS_TOV); 1731 rport, FC_MAX_PDUSZ, FC_ELS_TOV);
1731 1732
1732 rport->stats.logos++; 1733 rport->stats.logos++;
1733 bfa_fcxp_discard(rport->fcxp); 1734 bfa_fcxp_discard(rport->fcxp);
1734 bfa_sm_send_event(rport, RPSM_EVENT_FCXP_SENT); 1735 bfa_sm_send_event(rport, RPSM_EVENT_FCXP_SENT);
1735} 1736}
1736 1737
1737/** 1738/*
1738 * Send ACC for a LOGO received. 1739 * Send ACC for a LOGO received.
1739 */ 1740 */
1740static void 1741static void
1741bfa_fcs_rport_send_logo_acc(void *rport_cbarg) 1742bfa_fcs_rport_send_logo_acc(void *rport_cbarg)
1742{ 1743{
1743 struct bfa_fcs_rport_s *rport = rport_cbarg; 1744 struct bfa_fcs_rport_s *rport = rport_cbarg;
1744 struct bfa_fcs_port_s *port; 1745 struct bfa_fcs_lport_s *port;
1745 struct fchs_s fchs; 1746 struct fchs_s fchs;
1746 struct bfa_fcxp_s *fcxp; 1747 struct bfa_fcxp_s *fcxp;
1747 u16 len; 1748 u16 len;
1748 1749
1749 bfa_trc(rport->fcs, rport->pid); 1750 bfa_trc(rport->fcs, rport->pid);
1750 1751
@@ -1755,32 +1756,35 @@ bfa_fcs_rport_send_logo_acc(void *rport_cbarg)
1755 return; 1756 return;
1756 1757
1757 rport->stats.logo_rcvd++; 1758 rport->stats.logo_rcvd++;
1758 len = fc_logo_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid, 1759 len = fc_logo_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
1759 bfa_fcs_port_get_fcid(port), rport->reply_oxid); 1760 rport->pid, bfa_fcs_lport_get_fcid(port),
1761 rport->reply_oxid);
1760 1762
1761 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, 1763 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1762 FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0); 1764 FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0);
1763} 1765}
1764 1766
1765/** 1767/*
1766 * This routine will be called by bfa_timer on timer timeouts. 1768 * brief
1769 * This routine will be called by bfa_timer on timer timeouts.
1767 * 1770 *
1768 * param[in] rport - pointer to bfa_fcs_port_ns_t. 1771 * param[in] rport - pointer to bfa_fcs_lport_ns_t.
1769 * param[out] rport_status - pointer to return vport status in 1772 * param[out] rport_status - pointer to return vport status in
1770 * 1773 *
1771 * return 1774 * return
1772 * void 1775 * void
1773 * 1776 *
1774* Special Considerations: 1777 * Special Considerations:
1775 * 1778 *
1776 * note 1779 * note
1777 */ 1780 */
1778static void 1781static void
1779bfa_fcs_rport_timeout(void *arg) 1782bfa_fcs_rport_timeout(void *arg)
1780{ 1783{
1781 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *)arg; 1784 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *) arg;
1782 1785
1783 rport->stats.plogi_timeouts++; 1786 rport->stats.plogi_timeouts++;
1787 bfa_stats(rport->port, rport_plogi_timeouts);
1784 bfa_sm_send_event(rport, RPSM_EVENT_TIMEOUT); 1788 bfa_sm_send_event(rport, RPSM_EVENT_TIMEOUT);
1785} 1789}
1786 1790
@@ -1789,50 +1793,45 @@ bfa_fcs_rport_process_prli(struct bfa_fcs_rport_s *rport,
1789 struct fchs_s *rx_fchs, u16 len) 1793 struct fchs_s *rx_fchs, u16 len)
1790{ 1794{
1791 struct bfa_fcxp_s *fcxp; 1795 struct bfa_fcxp_s *fcxp;
1792 struct fchs_s fchs; 1796 struct fchs_s fchs;
1793 struct bfa_fcs_port_s *port = rport->port; 1797 struct bfa_fcs_lport_s *port = rport->port;
1794 struct fc_prli_s *prli; 1798 struct fc_prli_s *prli;
1795 1799
1796 bfa_trc(port->fcs, rx_fchs->s_id); 1800 bfa_trc(port->fcs, rx_fchs->s_id);
1797 bfa_trc(port->fcs, rx_fchs->d_id); 1801 bfa_trc(port->fcs, rx_fchs->d_id);
1798 1802
1799 rport->stats.prli_rcvd++; 1803 rport->stats.prli_rcvd++;
1800 1804
1801 if (BFA_FCS_VPORT_IS_TARGET_MODE(port)) {
1802 /*
1803 * Target Mode : Let the fcptm handle it
1804 */
1805 bfa_fcs_tin_rx_prli(rport->tin, rx_fchs, len);
1806 return;
1807 }
1808
1809 /* 1805 /*
1810 * We are either in Initiator or ipfc Mode 1806 * We are in Initiator Mode
1811 */ 1807 */
1812 prli = (struct fc_prli_s *) (rx_fchs + 1); 1808 prli = (struct fc_prli_s *) (rx_fchs + 1);
1813 1809
1814 if (prli->parampage.servparams.initiator) { 1810 if (prli->parampage.servparams.target) {
1815 bfa_trc(rport->fcs, prli->parampage.type);
1816 rport->scsi_function = BFA_RPORT_INITIATOR;
1817 bfa_fcs_itnim_is_initiator(rport->itnim);
1818 } else {
1819 /* 1811 /*
1820 * @todo: PRLI from a target ? 1812 * PRLI from a target ?
1813 * Send the Acc.
1814 * PRLI sent by us will be used to transition the IT nexus,
1815 * once the response is received from the target.
1821 */ 1816 */
1822 bfa_trc(port->fcs, rx_fchs->s_id); 1817 bfa_trc(port->fcs, rx_fchs->s_id);
1823 rport->scsi_function = BFA_RPORT_TARGET; 1818 rport->scsi_function = BFA_RPORT_TARGET;
1819 } else {
1820 bfa_trc(rport->fcs, prli->parampage.type);
1821 rport->scsi_function = BFA_RPORT_INITIATOR;
1822 bfa_fcs_itnim_is_initiator(rport->itnim);
1824 } 1823 }
1825 1824
1826 fcxp = bfa_fcs_fcxp_alloc(port->fcs); 1825 fcxp = bfa_fcs_fcxp_alloc(port->fcs);
1827 if (!fcxp) 1826 if (!fcxp)
1828 return; 1827 return;
1829 1828
1830 len = fc_prli_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rx_fchs->s_id, 1829 len = fc_prli_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
1831 bfa_fcs_port_get_fcid(port), rx_fchs->ox_id, 1830 rx_fchs->s_id, bfa_fcs_lport_get_fcid(port),
1832 port->port_cfg.roles); 1831 rx_fchs->ox_id, port->port_cfg.roles);
1833 1832
1834 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, 1833 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1835 FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0); 1834 FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0);
1836} 1835}
1837 1836
1838static void 1837static void
@@ -1840,10 +1839,10 @@ bfa_fcs_rport_process_rpsc(struct bfa_fcs_rport_s *rport,
1840 struct fchs_s *rx_fchs, u16 len) 1839 struct fchs_s *rx_fchs, u16 len)
1841{ 1840{
1842 struct bfa_fcxp_s *fcxp; 1841 struct bfa_fcxp_s *fcxp;
1843 struct fchs_s fchs; 1842 struct fchs_s fchs;
1844 struct bfa_fcs_port_s *port = rport->port; 1843 struct bfa_fcs_lport_s *port = rport->port;
1845 struct fc_rpsc_speed_info_s speeds; 1844 struct fc_rpsc_speed_info_s speeds;
1846 struct bfa_pport_attr_s pport_attr; 1845 struct bfa_port_attr_s pport_attr;
1847 1846
1848 bfa_trc(port->fcs, rx_fchs->s_id); 1847 bfa_trc(port->fcs, rx_fchs->s_id);
1849 bfa_trc(port->fcs, rx_fchs->d_id); 1848 bfa_trc(port->fcs, rx_fchs->d_id);
@@ -1864,12 +1863,12 @@ bfa_fcs_rport_process_rpsc(struct bfa_fcs_rport_s *rport,
1864 if (!fcxp) 1863 if (!fcxp)
1865 return; 1864 return;
1866 1865
1867 len = fc_rpsc_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rx_fchs->s_id, 1866 len = fc_rpsc_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
1868 bfa_fcs_port_get_fcid(port), rx_fchs->ox_id, 1867 rx_fchs->s_id, bfa_fcs_lport_get_fcid(port),
1869 &speeds); 1868 rx_fchs->ox_id, &speeds);
1870 1869
1871 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, 1870 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1872 FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0); 1871 FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0);
1873} 1872}
1874 1873
1875static void 1874static void
@@ -1877,28 +1876,20 @@ bfa_fcs_rport_process_adisc(struct bfa_fcs_rport_s *rport,
1877 struct fchs_s *rx_fchs, u16 len) 1876 struct fchs_s *rx_fchs, u16 len)
1878{ 1877{
1879 struct bfa_fcxp_s *fcxp; 1878 struct bfa_fcxp_s *fcxp;
1880 struct fchs_s fchs; 1879 struct fchs_s fchs;
1881 struct bfa_fcs_port_s *port = rport->port; 1880 struct bfa_fcs_lport_s *port = rport->port;
1882 struct fc_adisc_s *adisc; 1881 struct fc_adisc_s *adisc;
1883 1882
1884 bfa_trc(port->fcs, rx_fchs->s_id); 1883 bfa_trc(port->fcs, rx_fchs->s_id);
1885 bfa_trc(port->fcs, rx_fchs->d_id); 1884 bfa_trc(port->fcs, rx_fchs->d_id);
1886 1885
1887 rport->stats.adisc_rcvd++; 1886 rport->stats.adisc_rcvd++;
1888 1887
1889 if (BFA_FCS_VPORT_IS_TARGET_MODE(port)) {
1890 /*
1891 * @todo : Target Mode handling
1892 */
1893 bfa_trc(port->fcs, rx_fchs->d_id);
1894 bfa_assert(0);
1895 return;
1896 }
1897
1898 adisc = (struct fc_adisc_s *) (rx_fchs + 1); 1888 adisc = (struct fc_adisc_s *) (rx_fchs + 1);
1899 1889
1900 /* 1890 /*
1901 * Accept if the itnim for this rport is online. Else reject the ADISC 1891 * Accept if the itnim for this rport is online.
1892 * Else reject the ADISC.
1902 */ 1893 */
1903 if (bfa_fcs_itnim_get_online_state(rport->itnim) == BFA_STATUS_OK) { 1894 if (bfa_fcs_itnim_get_online_state(rport->itnim) == BFA_STATUS_OK) {
1904 1895
@@ -1907,27 +1898,25 @@ bfa_fcs_rport_process_adisc(struct bfa_fcs_rport_s *rport,
1907 return; 1898 return;
1908 1899
1909 len = fc_adisc_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), 1900 len = fc_adisc_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
1910 rx_fchs->s_id, 1901 rx_fchs->s_id, bfa_fcs_lport_get_fcid(port),
1911 bfa_fcs_port_get_fcid(port), 1902 rx_fchs->ox_id, port->port_cfg.pwwn,
1912 rx_fchs->ox_id, port->port_cfg.pwwn, 1903 port->port_cfg.nwwn);
1913 port->port_cfg.nwwn);
1914 1904
1915 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, 1905 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag,
1916 BFA_FALSE, FC_CLASS_3, len, &fchs, NULL, NULL, 1906 BFA_FALSE, FC_CLASS_3, len, &fchs, NULL, NULL,
1917 FC_MAX_PDUSZ, 0); 1907 FC_MAX_PDUSZ, 0);
1918 } else { 1908 } else {
1919 rport->stats.adisc_rejected++; 1909 rport->stats.adisc_rejected++;
1920 bfa_fcs_rport_send_ls_rjt(rport, rx_fchs, 1910 bfa_fcs_rport_send_ls_rjt(rport, rx_fchs,
1921 FC_LS_RJT_RSN_UNABLE_TO_PERF_CMD, 1911 FC_LS_RJT_RSN_UNABLE_TO_PERF_CMD,
1922 FC_LS_RJT_EXP_LOGIN_REQUIRED); 1912 FC_LS_RJT_EXP_LOGIN_REQUIRED);
1923 } 1913 }
1924
1925} 1914}
1926 1915
1927static void 1916static void
1928bfa_fcs_rport_hal_online(struct bfa_fcs_rport_s *rport) 1917bfa_fcs_rport_hal_online(struct bfa_fcs_rport_s *rport)
1929{ 1918{
1930 struct bfa_fcs_port_s *port = rport->port; 1919 struct bfa_fcs_lport_s *port = rport->port;
1931 struct bfa_rport_info_s rport_info; 1920 struct bfa_rport_info_s rport_info;
1932 1921
1933 rport_info.pid = rport->pid; 1922 rport_info.pid = rport->pid;
@@ -1941,38 +1930,18 @@ bfa_fcs_rport_hal_online(struct bfa_fcs_rport_s *rport)
1941 bfa_rport_online(rport->bfa_rport, &rport_info); 1930 bfa_rport_online(rport->bfa_rport, &rport_info);
1942} 1931}
1943 1932
1944static void
1945bfa_fcs_rport_fc4_pause(struct bfa_fcs_rport_s *rport)
1946{
1947 if (bfa_fcs_port_is_initiator(rport->port))
1948 bfa_fcs_itnim_pause(rport->itnim);
1949
1950 if (bfa_fcs_port_is_target(rport->port))
1951 bfa_fcs_tin_pause(rport->tin);
1952}
1953
1954static void
1955bfa_fcs_rport_fc4_resume(struct bfa_fcs_rport_s *rport)
1956{
1957 if (bfa_fcs_port_is_initiator(rport->port))
1958 bfa_fcs_itnim_resume(rport->itnim);
1959
1960 if (bfa_fcs_port_is_target(rport->port))
1961 bfa_fcs_tin_resume(rport->tin);
1962}
1963
1964static struct bfa_fcs_rport_s * 1933static struct bfa_fcs_rport_s *
1965bfa_fcs_rport_alloc(struct bfa_fcs_port_s *port, wwn_t pwwn, u32 rpid) 1934bfa_fcs_rport_alloc(struct bfa_fcs_lport_s *port, wwn_t pwwn, u32 rpid)
1966{ 1935{
1967 struct bfa_fcs_s *fcs = port->fcs; 1936 struct bfa_fcs_s *fcs = port->fcs;
1968 struct bfa_fcs_rport_s *rport; 1937 struct bfa_fcs_rport_s *rport;
1969 struct bfad_rport_s *rport_drv; 1938 struct bfad_rport_s *rport_drv;
1970 1939
1971 /** 1940 /*
1972 * allocate rport 1941 * allocate rport
1973 */ 1942 */
1974 if (bfa_fcb_rport_alloc(fcs->bfad, &rport, &rport_drv) 1943 if (bfa_fcb_rport_alloc(fcs->bfad, &rport, &rport_drv)
1975 != BFA_STATUS_OK) { 1944 != BFA_STATUS_OK) {
1976 bfa_trc(fcs, rpid); 1945 bfa_trc(fcs, rpid);
1977 return NULL; 1946 return NULL;
1978 } 1947 }
@@ -1986,7 +1955,7 @@ bfa_fcs_rport_alloc(struct bfa_fcs_port_s *port, wwn_t pwwn, u32 rpid)
1986 rport->pid = rpid; 1955 rport->pid = rpid;
1987 rport->pwwn = pwwn; 1956 rport->pwwn = pwwn;
1988 1957
1989 /** 1958 /*
1990 * allocate BFA rport 1959 * allocate BFA rport
1991 */ 1960 */
1992 rport->bfa_rport = bfa_rport_create(port->fcs->bfa, rport); 1961 rport->bfa_rport = bfa_rport_create(port->fcs->bfa, rport);
@@ -1996,39 +1965,27 @@ bfa_fcs_rport_alloc(struct bfa_fcs_port_s *port, wwn_t pwwn, u32 rpid)
1996 return NULL; 1965 return NULL;
1997 } 1966 }
1998 1967
1999 /** 1968 /*
2000 * allocate FC-4s 1969 * allocate FC-4s
2001 */ 1970 */
2002 bfa_assert(bfa_fcs_port_is_initiator(port) ^ 1971 WARN_ON(!bfa_fcs_lport_is_initiator(port));
2003 bfa_fcs_port_is_target(port));
2004 1972
2005 if (bfa_fcs_port_is_initiator(port)) { 1973 if (bfa_fcs_lport_is_initiator(port)) {
2006 rport->itnim = bfa_fcs_itnim_create(rport); 1974 rport->itnim = bfa_fcs_itnim_create(rport);
2007 if (!rport->itnim) { 1975 if (!rport->itnim) {
2008 bfa_trc(fcs, rpid); 1976 bfa_trc(fcs, rpid);
2009 bfa_rport_delete(rport->bfa_rport); 1977 bfa_sm_send_event(rport->bfa_rport,
1978 BFA_RPORT_SM_DELETE);
2010 kfree(rport_drv); 1979 kfree(rport_drv);
2011 return NULL; 1980 return NULL;
2012 } 1981 }
2013 } 1982 }
2014 1983
2015 if (bfa_fcs_port_is_target(port)) { 1984 bfa_fcs_lport_add_rport(port, rport);
2016 rport->tin = bfa_fcs_tin_create(rport);
2017 if (!rport->tin) {
2018 bfa_trc(fcs, rpid);
2019 bfa_rport_delete(rport->bfa_rport);
2020 kfree(rport_drv);
2021 return NULL;
2022 }
2023 }
2024
2025 bfa_fcs_port_add_rport(port, rport);
2026 1985
2027 bfa_sm_set_state(rport, bfa_fcs_rport_sm_uninit); 1986 bfa_sm_set_state(rport, bfa_fcs_rport_sm_uninit);
2028 1987
2029 /* 1988 /* Initialize the Rport Features(RPF) Sub Module */
2030 * Initialize the Rport Features(RPF) Sub Module
2031 */
2032 if (!BFA_FCS_PID_IS_WKA(rport->pid)) 1989 if (!BFA_FCS_PID_IS_WKA(rport->pid))
2033 bfa_fcs_rpf_init(rport); 1990 bfa_fcs_rpf_init(rport);
2034 1991
@@ -2039,139 +1996,96 @@ bfa_fcs_rport_alloc(struct bfa_fcs_port_s *port, wwn_t pwwn, u32 rpid)
2039static void 1996static void
2040bfa_fcs_rport_free(struct bfa_fcs_rport_s *rport) 1997bfa_fcs_rport_free(struct bfa_fcs_rport_s *rport)
2041{ 1998{
2042 struct bfa_fcs_port_s *port = rport->port; 1999 struct bfa_fcs_lport_s *port = rport->port;
2043 2000
2044 /** 2001 /*
2045 * - delete FC-4s 2002 * - delete FC-4s
2046 * - delete BFA rport 2003 * - delete BFA rport
2047 * - remove from queue of rports 2004 * - remove from queue of rports
2048 */ 2005 */
2049 if (bfa_fcs_port_is_initiator(port)) 2006 if (bfa_fcs_lport_is_initiator(port)) {
2050 bfa_fcs_itnim_delete(rport->itnim); 2007 bfa_fcs_itnim_delete(rport->itnim);
2051 2008 if (rport->pid != 0 && !BFA_FCS_PID_IS_WKA(rport->pid))
2052 if (bfa_fcs_port_is_target(port)) 2009 bfa_fcs_rpf_rport_offline(rport);
2053 bfa_fcs_tin_delete(rport->tin);
2054
2055 bfa_rport_delete(rport->bfa_rport);
2056 bfa_fcs_port_del_rport(port, rport);
2057 kfree(rport->rp_drv);
2058}
2059
2060static void
2061bfa_fcs_rport_aen_post(struct bfa_fcs_rport_s *rport,
2062 enum bfa_rport_aen_event event,
2063 struct bfa_rport_aen_data_s *data)
2064{
2065 union bfa_aen_data_u aen_data;
2066 struct bfa_log_mod_s *logmod = rport->fcs->logm;
2067 wwn_t lpwwn = bfa_fcs_port_get_pwwn(rport->port);
2068 wwn_t rpwwn = rport->pwwn;
2069 char lpwwn_ptr[BFA_STRING_32];
2070 char rpwwn_ptr[BFA_STRING_32];
2071 char *prio_str[] = { "unknown", "high", "medium", "low" };
2072
2073 wwn2str(lpwwn_ptr, lpwwn);
2074 wwn2str(rpwwn_ptr, rpwwn);
2075
2076 switch (event) {
2077 case BFA_RPORT_AEN_ONLINE:
2078 case BFA_RPORT_AEN_OFFLINE:
2079 case BFA_RPORT_AEN_DISCONNECT:
2080 bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_RPORT, event),
2081 rpwwn_ptr, lpwwn_ptr);
2082 break;
2083 case BFA_RPORT_AEN_QOS_PRIO:
2084 aen_data.rport.priv.qos = data->priv.qos;
2085 bfa_log(logmod, BFA_AEN_RPORT_QOS_PRIO,
2086 prio_str[aen_data.rport.priv.qos.qos_priority],
2087 rpwwn_ptr, lpwwn_ptr);
2088 break;
2089 case BFA_RPORT_AEN_QOS_FLOWID:
2090 aen_data.rport.priv.qos = data->priv.qos;
2091 bfa_log(logmod, BFA_AEN_RPORT_QOS_FLOWID,
2092 aen_data.rport.priv.qos.qos_flow_id, rpwwn_ptr,
2093 lpwwn_ptr);
2094 break;
2095 default:
2096 break;
2097 } 2010 }
2098 2011
2099 aen_data.rport.vf_id = rport->port->fabric->vf_id; 2012 bfa_sm_send_event(rport->bfa_rport, BFA_RPORT_SM_DELETE);
2100 aen_data.rport.ppwwn = 2013 bfa_fcs_lport_del_rport(port, rport);
2101 bfa_fcs_port_get_pwwn(bfa_fcs_get_base_port(rport->fcs)); 2014 kfree(rport->rp_drv);
2102 aen_data.rport.lpwwn = lpwwn;
2103 aen_data.rport.rpwwn = rpwwn;
2104} 2015}
2105 2016
2106static void 2017static void
2107bfa_fcs_rport_online_action(struct bfa_fcs_rport_s *rport) 2018bfa_fcs_rport_online_action(struct bfa_fcs_rport_s *rport)
2108{ 2019{
2109 struct bfa_fcs_port_s *port = rport->port; 2020 struct bfa_fcs_lport_s *port = rport->port;
2021 struct bfad_s *bfad = (struct bfad_s *)port->fcs->bfad;
2022 char lpwwn_buf[BFA_STRING_32];
2023 char rpwwn_buf[BFA_STRING_32];
2110 2024
2111 rport->stats.onlines++; 2025 rport->stats.onlines++;
2112 2026
2113 if (bfa_fcs_port_is_initiator(port)) { 2027 if (bfa_fcs_lport_is_initiator(port)) {
2114 bfa_fcs_itnim_rport_online(rport->itnim); 2028 bfa_fcs_itnim_rport_online(rport->itnim);
2115 if (!BFA_FCS_PID_IS_WKA(rport->pid)) 2029 if (!BFA_FCS_PID_IS_WKA(rport->pid))
2116 bfa_fcs_rpf_rport_online(rport); 2030 bfa_fcs_rpf_rport_online(rport);
2117 }; 2031 };
2118 2032
2119 if (bfa_fcs_port_is_target(port)) 2033 wwn2str(lpwwn_buf, bfa_fcs_lport_get_pwwn(port));
2120 bfa_fcs_tin_rport_online(rport->tin); 2034 wwn2str(rpwwn_buf, rport->pwwn);
2121
2122 /*
2123 * Don't post events for well known addresses
2124 */
2125 if (!BFA_FCS_PID_IS_WKA(rport->pid)) 2035 if (!BFA_FCS_PID_IS_WKA(rport->pid))
2126 bfa_fcs_rport_aen_post(rport, BFA_RPORT_AEN_ONLINE, NULL); 2036 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2037 "Remote port (WWN = %s) online for logical port (WWN = %s)\n",
2038 rpwwn_buf, lpwwn_buf);
2127} 2039}
2128 2040
2129static void 2041static void
2130bfa_fcs_rport_offline_action(struct bfa_fcs_rport_s *rport) 2042bfa_fcs_rport_offline_action(struct bfa_fcs_rport_s *rport)
2131{ 2043{
2132 struct bfa_fcs_port_s *port = rport->port; 2044 struct bfa_fcs_lport_s *port = rport->port;
2045 struct bfad_s *bfad = (struct bfad_s *)port->fcs->bfad;
2046 char lpwwn_buf[BFA_STRING_32];
2047 char rpwwn_buf[BFA_STRING_32];
2133 2048
2134 rport->stats.offlines++; 2049 rport->stats.offlines++;
2135 2050
2136 /* 2051 wwn2str(lpwwn_buf, bfa_fcs_lport_get_pwwn(port));
2137 * Don't post events for well known addresses 2052 wwn2str(rpwwn_buf, rport->pwwn);
2138 */
2139 if (!BFA_FCS_PID_IS_WKA(rport->pid)) { 2053 if (!BFA_FCS_PID_IS_WKA(rport->pid)) {
2140 if (bfa_fcs_port_is_online(rport->port) == BFA_TRUE) { 2054 if (bfa_fcs_lport_is_online(rport->port) == BFA_TRUE)
2141 bfa_fcs_rport_aen_post(rport, BFA_RPORT_AEN_DISCONNECT, 2055 BFA_LOG(KERN_ERR, bfad, bfa_log_level,
2142 NULL); 2056 "Remote port (WWN = %s) connectivity lost for "
2143 } else { 2057 "logical port (WWN = %s)\n",
2144 bfa_fcs_rport_aen_post(rport, BFA_RPORT_AEN_OFFLINE, 2058 rpwwn_buf, lpwwn_buf);
2145 NULL); 2059 else
2146 } 2060 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2061 "Remote port (WWN = %s) offlined by "
2062 "logical port (WWN = %s)\n",
2063 rpwwn_buf, lpwwn_buf);
2147 } 2064 }
2148 2065
2149 if (bfa_fcs_port_is_initiator(port)) { 2066 if (bfa_fcs_lport_is_initiator(port)) {
2150 bfa_fcs_itnim_rport_offline(rport->itnim); 2067 bfa_fcs_itnim_rport_offline(rport->itnim);
2151 if (!BFA_FCS_PID_IS_WKA(rport->pid)) 2068 if (!BFA_FCS_PID_IS_WKA(rport->pid))
2152 bfa_fcs_rpf_rport_offline(rport); 2069 bfa_fcs_rpf_rport_offline(rport);
2153 } 2070 }
2154
2155 if (bfa_fcs_port_is_target(port))
2156 bfa_fcs_tin_rport_offline(rport->tin);
2157} 2071}
2158 2072
2159/** 2073/*
2160 * Update rport parameters from PLOGI or PLOGI accept. 2074 * Update rport parameters from PLOGI or PLOGI accept.
2161 */ 2075 */
2162static void 2076static void
2163bfa_fcs_rport_update(struct bfa_fcs_rport_s *rport, struct fc_logi_s *plogi) 2077bfa_fcs_rport_update(struct bfa_fcs_rport_s *rport, struct fc_logi_s *plogi)
2164{ 2078{
2165 struct bfa_fcs_port_s *port = rport->port; 2079 bfa_fcs_lport_t *port = rport->port;
2166 2080
2167 /** 2081 /*
2168 * - port name 2082 * - port name
2169 * - node name 2083 * - node name
2170 */ 2084 */
2171 rport->pwwn = plogi->port_name; 2085 rport->pwwn = plogi->port_name;
2172 rport->nwwn = plogi->node_name; 2086 rport->nwwn = plogi->node_name;
2173 2087
2174 /** 2088 /*
2175 * - class of service 2089 * - class of service
2176 */ 2090 */
2177 rport->fc_cos = 0; 2091 rport->fc_cos = 0;
@@ -2181,37 +2095,38 @@ bfa_fcs_rport_update(struct bfa_fcs_rport_s *rport, struct fc_logi_s *plogi)
2181 if (plogi->class2.class_valid) 2095 if (plogi->class2.class_valid)
2182 rport->fc_cos |= FC_CLASS_2; 2096 rport->fc_cos |= FC_CLASS_2;
2183 2097
2184 /** 2098 /*
2185 * - CISC 2099 * - CISC
2186 * - MAX receive frame size 2100 * - MAX receive frame size
2187 */ 2101 */
2188 rport->cisc = plogi->csp.cisc; 2102 rport->cisc = plogi->csp.cisc;
2189 rport->maxfrsize = bfa_os_ntohs(plogi->class3.rxsz); 2103 rport->maxfrsize = be16_to_cpu(plogi->class3.rxsz);
2190 2104
2191 bfa_trc(port->fcs, bfa_os_ntohs(plogi->csp.bbcred)); 2105 bfa_trc(port->fcs, be16_to_cpu(plogi->csp.bbcred));
2192 bfa_trc(port->fcs, port->fabric->bb_credit); 2106 bfa_trc(port->fcs, port->fabric->bb_credit);
2193 /** 2107 /*
2194 * Direct Attach P2P mode : 2108 * Direct Attach P2P mode :
2195 * This is to handle a bug (233476) in IBM targets in Direct Attach 2109 * This is to handle a bug (233476) in IBM targets in Direct Attach
2196 * Mode. Basically, in FLOGI Accept the target would have erroneously 2110 * Mode. Basically, in FLOGI Accept the target would have
2197 * set the BB Credit to the value used in the FLOGI sent by the HBA. 2111 * erroneously set the BB Credit to the value used in the FLOGI
2198 * It uses the correct value (its own BB credit) in PLOGI. 2112 * sent by the HBA. It uses the correct value (its own BB credit)
2113 * in PLOGI.
2199 */ 2114 */
2200 if ((!bfa_fcs_fabric_is_switched(port->fabric)) 2115 if ((!bfa_fcs_fabric_is_switched(port->fabric)) &&
2201 && (bfa_os_ntohs(plogi->csp.bbcred) < port->fabric->bb_credit)) { 2116 (be16_to_cpu(plogi->csp.bbcred) < port->fabric->bb_credit)) {
2202 2117
2203 bfa_trc(port->fcs, bfa_os_ntohs(plogi->csp.bbcred)); 2118 bfa_trc(port->fcs, be16_to_cpu(plogi->csp.bbcred));
2204 bfa_trc(port->fcs, port->fabric->bb_credit); 2119 bfa_trc(port->fcs, port->fabric->bb_credit);
2205 2120
2206 port->fabric->bb_credit = bfa_os_ntohs(plogi->csp.bbcred); 2121 port->fabric->bb_credit = be16_to_cpu(plogi->csp.bbcred);
2207 bfa_fcport_set_tx_bbcredit(port->fcs->bfa, 2122 bfa_fcport_set_tx_bbcredit(port->fcs->bfa,
2208 port->fabric->bb_credit); 2123 port->fabric->bb_credit);
2209 } 2124 }
2210 2125
2211} 2126}
2212 2127
2213/** 2128/*
2214 * Called to handle LOGO received from an existing remote port. 2129 * Called to handle LOGO received from an existing remote port.
2215 */ 2130 */
2216static void 2131static void
2217bfa_fcs_rport_process_logo(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs) 2132bfa_fcs_rport_process_logo(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs)
@@ -2226,13 +2141,13 @@ bfa_fcs_rport_process_logo(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs)
2226 2141
2227 2142
2228 2143
2229/** 2144/*
2230 * fcs_rport_public FCS rport public interfaces 2145 * fcs_rport_public FCS rport public interfaces
2231 */ 2146 */
2232 2147
2233/** 2148/*
2234 * Called by bport/vport to create a remote port instance for a discovered 2149 * Called by bport/vport to create a remote port instance for a discovered
2235 * remote device. 2150 * remote device.
2236 * 2151 *
2237 * @param[in] port - base port or vport 2152 * @param[in] port - base port or vport
2238 * @param[in] rpid - remote port ID 2153 * @param[in] rpid - remote port ID
@@ -2240,7 +2155,7 @@ bfa_fcs_rport_process_logo(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs)
2240 * @return None 2155 * @return None
2241 */ 2156 */
2242struct bfa_fcs_rport_s * 2157struct bfa_fcs_rport_s *
2243bfa_fcs_rport_create(struct bfa_fcs_port_s *port, u32 rpid) 2158bfa_fcs_rport_create(struct bfa_fcs_lport_s *port, u32 rpid)
2244{ 2159{
2245 struct bfa_fcs_rport_s *rport; 2160 struct bfa_fcs_rport_s *rport;
2246 2161
@@ -2253,7 +2168,7 @@ bfa_fcs_rport_create(struct bfa_fcs_port_s *port, u32 rpid)
2253 return rport; 2168 return rport;
2254} 2169}
2255 2170
2256/** 2171/*
2257 * Called to create a rport for which only the wwn is known. 2172 * Called to create a rport for which only the wwn is known.
2258 * 2173 *
2259 * @param[in] port - base port 2174 * @param[in] port - base port
@@ -2262,10 +2177,9 @@ bfa_fcs_rport_create(struct bfa_fcs_port_s *port, u32 rpid)
2262 * @return None 2177 * @return None
2263 */ 2178 */
2264struct bfa_fcs_rport_s * 2179struct bfa_fcs_rport_s *
2265bfa_fcs_rport_create_by_wwn(struct bfa_fcs_port_s *port, wwn_t rpwwn) 2180bfa_fcs_rport_create_by_wwn(struct bfa_fcs_lport_s *port, wwn_t rpwwn)
2266{ 2181{
2267 struct bfa_fcs_rport_s *rport; 2182 struct bfa_fcs_rport_s *rport;
2268
2269 bfa_trc(port->fcs, rpwwn); 2183 bfa_trc(port->fcs, rpwwn);
2270 rport = bfa_fcs_rport_alloc(port, rpwwn, 0); 2184 rport = bfa_fcs_rport_alloc(port, rpwwn, 0);
2271 if (!rport) 2185 if (!rport)
@@ -2274,8 +2188,7 @@ bfa_fcs_rport_create_by_wwn(struct bfa_fcs_port_s *port, wwn_t rpwwn)
2274 bfa_sm_send_event(rport, RPSM_EVENT_ADDRESS_DISC); 2188 bfa_sm_send_event(rport, RPSM_EVENT_ADDRESS_DISC);
2275 return rport; 2189 return rport;
2276} 2190}
2277 2191/*
2278/**
2279 * Called by bport in private loop topology to indicate that a 2192 * Called by bport in private loop topology to indicate that a
2280 * rport has been discovered and plogi has been completed. 2193 * rport has been discovered and plogi has been completed.
2281 * 2194 *
@@ -2283,8 +2196,8 @@ bfa_fcs_rport_create_by_wwn(struct bfa_fcs_port_s *port, wwn_t rpwwn)
2283 * @param[in] rpid - remote port ID 2196 * @param[in] rpid - remote port ID
2284 */ 2197 */
2285void 2198void
2286bfa_fcs_rport_start(struct bfa_fcs_port_s *port, struct fchs_s *fchs, 2199bfa_fcs_rport_start(struct bfa_fcs_lport_s *port, struct fchs_s *fchs,
2287 struct fc_logi_s *plogi) 2200 struct fc_logi_s *plogi)
2288{ 2201{
2289 struct bfa_fcs_rport_s *rport; 2202 struct bfa_fcs_rport_s *rport;
2290 2203
@@ -2297,13 +2210,13 @@ bfa_fcs_rport_start(struct bfa_fcs_port_s *port, struct fchs_s *fchs,
2297 bfa_sm_send_event(rport, RPSM_EVENT_PLOGI_COMP); 2210 bfa_sm_send_event(rport, RPSM_EVENT_PLOGI_COMP);
2298} 2211}
2299 2212
2300/** 2213/*
2301 * Called by bport/vport to handle PLOGI received from a new remote port. 2214 * Called by bport/vport to handle PLOGI received from a new remote port.
2302 * If an existing rport does a plogi, it will be handled separately. 2215 * If an existing rport does a plogi, it will be handled separately.
2303 */ 2216 */
2304void 2217void
2305bfa_fcs_rport_plogi_create(struct bfa_fcs_port_s *port, struct fchs_s *fchs, 2218bfa_fcs_rport_plogi_create(struct bfa_fcs_lport_s *port, struct fchs_s *fchs,
2306 struct fc_logi_s *plogi) 2219 struct fc_logi_s *plogi)
2307{ 2220{
2308 struct bfa_fcs_rport_s *rport; 2221 struct bfa_fcs_rport_s *rport;
2309 2222
@@ -2323,9 +2236,9 @@ bfa_fcs_rport_plogi_create(struct bfa_fcs_port_s *port, struct fchs_s *fchs,
2323static int 2236static int
2324wwn_compare(wwn_t wwn1, wwn_t wwn2) 2237wwn_compare(wwn_t wwn1, wwn_t wwn2)
2325{ 2238{
2326 u8 *b1 = (u8 *) &wwn1; 2239 u8 *b1 = (u8 *) &wwn1;
2327 u8 *b2 = (u8 *) &wwn2; 2240 u8 *b2 = (u8 *) &wwn2;
2328 int i; 2241 int i;
2329 2242
2330 for (i = 0; i < sizeof(wwn_t); i++) { 2243 for (i = 0; i < sizeof(wwn_t); i++) {
2331 if (b1[i] < b2[i]) 2244 if (b1[i] < b2[i])
@@ -2336,15 +2249,15 @@ wwn_compare(wwn_t wwn1, wwn_t wwn2)
2336 return 0; 2249 return 0;
2337} 2250}
2338 2251
2339/** 2252/*
2340 * Called by bport/vport to handle PLOGI received from an existing 2253 * Called by bport/vport to handle PLOGI received from an existing
2341 * remote port. 2254 * remote port.
2342 */ 2255 */
2343void 2256void
2344bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *rx_fchs, 2257bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *rx_fchs,
2345 struct fc_logi_s *plogi) 2258 struct fc_logi_s *plogi)
2346{ 2259{
2347 /** 2260 /*
2348 * @todo Handle P2P and initiator-initiator. 2261 * @todo Handle P2P and initiator-initiator.
2349 */ 2262 */
2350 2263
@@ -2353,16 +2266,16 @@ bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *rx_fchs,
2353 rport->reply_oxid = rx_fchs->ox_id; 2266 rport->reply_oxid = rx_fchs->ox_id;
2354 bfa_trc(rport->fcs, rport->reply_oxid); 2267 bfa_trc(rport->fcs, rport->reply_oxid);
2355 2268
2356 /** 2269 /*
2357 * In Switched fabric topology, 2270 * In Switched fabric topology,
2358 * PLOGI to each other. If our pwwn is smaller, ignore it, 2271 * PLOGI to each other. If our pwwn is smaller, ignore it,
2359 * if it is not a well known address. 2272 * if it is not a well known address.
2360 * If the link topology is N2N, 2273 * If the link topology is N2N,
2361 * this Plogi should be accepted. 2274 * this Plogi should be accepted.
2362 */ 2275 */
2363 if ((wwn_compare(rport->port->port_cfg.pwwn, rport->pwwn) == -1) 2276 if ((wwn_compare(rport->port->port_cfg.pwwn, rport->pwwn) == -1) &&
2364 && (bfa_fcs_fabric_is_switched(rport->port->fabric)) 2277 (bfa_fcs_fabric_is_switched(rport->port->fabric)) &&
2365 && (!BFA_FCS_PID_IS_WKA(rport->pid))) { 2278 (!BFA_FCS_PID_IS_WKA(rport->pid))) {
2366 bfa_trc(rport->fcs, rport->pid); 2279 bfa_trc(rport->fcs, rport->pid);
2367 return; 2280 return;
2368 } 2281 }
@@ -2371,179 +2284,120 @@ bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *rx_fchs,
2371 bfa_sm_send_event(rport, RPSM_EVENT_PLOGI_RCVD); 2284 bfa_sm_send_event(rport, RPSM_EVENT_PLOGI_RCVD);
2372} 2285}
2373 2286
2374/**
2375 * Called by bport/vport to delete a remote port instance.
2376 *
2377* Rport delete is called under the following conditions:
2378 * - vport is deleted
2379 * - vf is deleted
2380 * - explicit request from OS to delete rport (vmware)
2381 */
2382void
2383bfa_fcs_rport_delete(struct bfa_fcs_rport_s *rport)
2384{
2385 bfa_sm_send_event(rport, RPSM_EVENT_DELETE);
2386}
2387
2388/**
2389 * Called by bport/vport to when a target goes offline.
2390 *
2391 */
2392void
2393bfa_fcs_rport_offline(struct bfa_fcs_rport_s *rport)
2394{
2395 bfa_sm_send_event(rport, RPSM_EVENT_LOGO_IMP);
2396}
2397
2398/**
2399 * Called by bport in n2n when a target (attached port) becomes online.
2400 *
2401 */
2402void
2403bfa_fcs_rport_online(struct bfa_fcs_rport_s *rport)
2404{
2405 bfa_sm_send_event(rport, RPSM_EVENT_PLOGI_SEND);
2406}
2407 2287
2408/** 2288/*
2409 * Called by bport/vport to notify SCN for the remote port 2289 * Called by bport/vport to notify SCN for the remote port
2410 */ 2290 */
2411void 2291void
2412bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport) 2292bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport)
2413{ 2293{
2414
2415 rport->stats.rscns++; 2294 rport->stats.rscns++;
2416 bfa_sm_send_event(rport, RPSM_EVENT_SCN); 2295 bfa_sm_send_event(rport, RPSM_EVENT_SCN);
2417} 2296}
2418 2297
2419/**
2420 * Called by fcpim to notify that the ITN cleanup is done.
2421 */
2422void
2423bfa_fcs_rport_itnim_ack(struct bfa_fcs_rport_s *rport)
2424{
2425 bfa_sm_send_event(rport, RPSM_EVENT_FC4_OFFLINE);
2426}
2427
2428/**
2429 * Called by fcptm to notify that the ITN cleanup is done.
2430 */
2431void
2432bfa_fcs_rport_tin_ack(struct bfa_fcs_rport_s *rport)
2433{
2434 bfa_sm_send_event(rport, RPSM_EVENT_FC4_OFFLINE);
2435}
2436 2298
2437/** 2299/*
2438 * This routine BFA callback for bfa_rport_online() call. 2300 * brief
2301 * This routine BFA callback for bfa_rport_online() call.
2439 * 2302 *
2440 * param[in] cb_arg - rport struct. 2303 * param[in] cb_arg - rport struct.
2441 * 2304 *
2442 * return 2305 * return
2443 * void 2306 * void
2444 * 2307 *
2445* Special Considerations: 2308 * Special Considerations:
2446 * 2309 *
2447 * note 2310 * note
2448 */ 2311 */
2449void 2312void
2450bfa_cb_rport_online(void *cbarg) 2313bfa_cb_rport_online(void *cbarg)
2451{ 2314{
2452 2315
2453 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *)cbarg; 2316 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *) cbarg;
2454 2317
2455 bfa_trc(rport->fcs, rport->pwwn); 2318 bfa_trc(rport->fcs, rport->pwwn);
2456 bfa_sm_send_event(rport, RPSM_EVENT_HCB_ONLINE); 2319 bfa_sm_send_event(rport, RPSM_EVENT_HCB_ONLINE);
2457} 2320}
2458 2321
2459/** 2322/*
2460 * This routine BFA callback for bfa_rport_offline() call. 2323 * brief
2324 * This routine BFA callback for bfa_rport_offline() call.
2461 * 2325 *
2462 * param[in] rport - 2326 * param[in] rport -
2463 * 2327 *
2464 * return 2328 * return
2465 * void 2329 * void
2466 * 2330 *
2467 * Special Considerations: 2331 * Special Considerations:
2468 * 2332 *
2469 * note 2333 * note
2470 */ 2334 */
2471void 2335void
2472bfa_cb_rport_offline(void *cbarg) 2336bfa_cb_rport_offline(void *cbarg)
2473{ 2337{
2474 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *)cbarg; 2338 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *) cbarg;
2475 2339
2476 bfa_trc(rport->fcs, rport->pwwn); 2340 bfa_trc(rport->fcs, rport->pwwn);
2477 bfa_sm_send_event(rport, RPSM_EVENT_HCB_OFFLINE); 2341 bfa_sm_send_event(rport, RPSM_EVENT_HCB_OFFLINE);
2478} 2342}
2479 2343
2480/** 2344/*
2481 * This routine is a static BFA callback when there is a QoS flow_id 2345 * brief
2482 * change notification 2346 * This routine is a static BFA callback when there is a QoS flow_id
2347 * change notification
2483 * 2348 *
2484 * @param[in] rport - 2349 * param[in] rport -
2485 * 2350 *
2486 * @return void 2351 * return
2352 * void
2487 * 2353 *
2488 * Special Considerations: 2354 * Special Considerations:
2489 * 2355 *
2490 * @note 2356 * note
2491 */ 2357 */
2492void 2358void
2493bfa_cb_rport_qos_scn_flowid(void *cbarg, 2359bfa_cb_rport_qos_scn_flowid(void *cbarg,
2494 struct bfa_rport_qos_attr_s old_qos_attr, 2360 struct bfa_rport_qos_attr_s old_qos_attr,
2495 struct bfa_rport_qos_attr_s new_qos_attr) 2361 struct bfa_rport_qos_attr_s new_qos_attr)
2496{ 2362{
2497 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *)cbarg; 2363 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *) cbarg;
2498 struct bfa_rport_aen_data_s aen_data;
2499 2364
2500 bfa_trc(rport->fcs, rport->pwwn); 2365 bfa_trc(rport->fcs, rport->pwwn);
2501 aen_data.priv.qos = new_qos_attr;
2502 bfa_fcs_rport_aen_post(rport, BFA_RPORT_AEN_QOS_FLOWID, &aen_data);
2503} 2366}
2504 2367
2505/** 2368/*
2506 * This routine is a static BFA callback when there is a QoS priority 2369 * brief
2507 * change notification 2370 * This routine is a static BFA callback when there is a QoS priority
2371 * change notification
2508 * 2372 *
2509 * @param[in] rport - 2373 * param[in] rport -
2510 * 2374 *
2511 * @return void 2375 * return
2376 * void
2512 * 2377 *
2513 * Special Considerations: 2378 * Special Considerations:
2514 * 2379 *
2515 * @note 2380 * note
2516 */ 2381 */
2517void 2382void
2518bfa_cb_rport_qos_scn_prio(void *cbarg, struct bfa_rport_qos_attr_s old_qos_attr, 2383bfa_cb_rport_qos_scn_prio(void *cbarg,
2519 struct bfa_rport_qos_attr_s new_qos_attr) 2384 struct bfa_rport_qos_attr_s old_qos_attr,
2385 struct bfa_rport_qos_attr_s new_qos_attr)
2520{ 2386{
2521 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *)cbarg; 2387 struct bfa_fcs_rport_s *rport = (struct bfa_fcs_rport_s *) cbarg;
2522 struct bfa_rport_aen_data_s aen_data;
2523 2388
2524 bfa_trc(rport->fcs, rport->pwwn); 2389 bfa_trc(rport->fcs, rport->pwwn);
2525 aen_data.priv.qos = new_qos_attr;
2526 bfa_fcs_rport_aen_post(rport, BFA_RPORT_AEN_QOS_PRIO, &aen_data);
2527}
2528
2529/**
2530 * Called to process any unsolicted frames from this remote port
2531 */
2532void
2533bfa_fcs_rport_logo_imp(struct bfa_fcs_rport_s *rport)
2534{
2535 bfa_sm_send_event(rport, RPSM_EVENT_LOGO_IMP);
2536} 2390}
2537 2391
2538/** 2392/*
2539 * Called to process any unsolicted frames from this remote port 2393 * Called to process any unsolicted frames from this remote port
2540 */ 2394 */
2541void 2395void
2542bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs, 2396bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport,
2543 u16 len) 2397 struct fchs_s *fchs, u16 len)
2544{ 2398{
2545 struct bfa_fcs_port_s *port = rport->port; 2399 struct bfa_fcs_lport_s *port = rport->port;
2546 struct fc_els_cmd_s *els_cmd; 2400 struct fc_els_cmd_s *els_cmd;
2547 2401
2548 bfa_trc(rport->fcs, fchs->s_id); 2402 bfa_trc(rport->fcs, fchs->s_id);
2549 bfa_trc(rport->fcs, fchs->d_id); 2403 bfa_trc(rport->fcs, fchs->d_id);
@@ -2558,30 +2412,33 @@ bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs,
2558 2412
2559 switch (els_cmd->els_code) { 2413 switch (els_cmd->els_code) {
2560 case FC_ELS_LOGO: 2414 case FC_ELS_LOGO:
2415 bfa_stats(port, plogi_rcvd);
2561 bfa_fcs_rport_process_logo(rport, fchs); 2416 bfa_fcs_rport_process_logo(rport, fchs);
2562 break; 2417 break;
2563 2418
2564 case FC_ELS_ADISC: 2419 case FC_ELS_ADISC:
2420 bfa_stats(port, adisc_rcvd);
2565 bfa_fcs_rport_process_adisc(rport, fchs, len); 2421 bfa_fcs_rport_process_adisc(rport, fchs, len);
2566 break; 2422 break;
2567 2423
2568 case FC_ELS_PRLO: 2424 case FC_ELS_PRLO:
2569 if (bfa_fcs_port_is_initiator(port)) 2425 bfa_stats(port, prlo_rcvd);
2426 if (bfa_fcs_lport_is_initiator(port))
2570 bfa_fcs_fcpim_uf_recv(rport->itnim, fchs, len); 2427 bfa_fcs_fcpim_uf_recv(rport->itnim, fchs, len);
2571
2572 if (bfa_fcs_port_is_target(port))
2573 bfa_fcs_fcptm_uf_recv(rport->tin, fchs, len);
2574 break; 2428 break;
2575 2429
2576 case FC_ELS_PRLI: 2430 case FC_ELS_PRLI:
2431 bfa_stats(port, prli_rcvd);
2577 bfa_fcs_rport_process_prli(rport, fchs, len); 2432 bfa_fcs_rport_process_prli(rport, fchs, len);
2578 break; 2433 break;
2579 2434
2580 case FC_ELS_RPSC: 2435 case FC_ELS_RPSC:
2436 bfa_stats(port, rpsc_rcvd);
2581 bfa_fcs_rport_process_rpsc(rport, fchs, len); 2437 bfa_fcs_rport_process_rpsc(rport, fchs, len);
2582 break; 2438 break;
2583 2439
2584 default: 2440 default:
2441 bfa_stats(port, un_handled_els_rcvd);
2585 bfa_fcs_rport_send_ls_rjt(rport, fchs, 2442 bfa_fcs_rport_send_ls_rjt(rport, fchs,
2586 FC_LS_RJT_RSN_CMD_NOT_SUPP, 2443 FC_LS_RJT_RSN_CMD_NOT_SUPP,
2587 FC_LS_RJT_EXP_NO_ADDL_INFO); 2444 FC_LS_RJT_EXP_NO_ADDL_INFO);
@@ -2589,28 +2446,27 @@ bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs,
2589 } 2446 }
2590} 2447}
2591 2448
2592/* Send best case acc to prlo */ 2449/* send best case acc to prlo */
2593static void 2450static void
2594bfa_fcs_rport_send_prlo_acc(struct bfa_fcs_rport_s *rport) 2451bfa_fcs_rport_send_prlo_acc(struct bfa_fcs_rport_s *rport)
2595{ 2452{
2596 struct bfa_fcs_port_s *port = rport->port; 2453 struct bfa_fcs_lport_s *port = rport->port;
2597 struct fchs_s fchs; 2454 struct fchs_s fchs;
2598 struct bfa_fcxp_s *fcxp; 2455 struct bfa_fcxp_s *fcxp;
2599 int len; 2456 int len;
2600 2457
2601 bfa_trc(rport->fcs, rport->pid); 2458 bfa_trc(rport->fcs, rport->pid);
2602 2459
2603 fcxp = bfa_fcs_fcxp_alloc(port->fcs); 2460 fcxp = bfa_fcs_fcxp_alloc(port->fcs);
2604 if (!fcxp) 2461 if (!fcxp)
2605 return; 2462 return;
2606
2607 len = fc_prlo_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), 2463 len = fc_prlo_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
2608 rport->pid, bfa_fcs_port_get_fcid(port), 2464 rport->pid, bfa_fcs_lport_get_fcid(port),
2609 rport->reply_oxid, 0); 2465 rport->reply_oxid, 0);
2610 2466
2611 bfa_fcxp_send(fcxp, rport->bfa_rport, port->fabric->vf_id, 2467 bfa_fcxp_send(fcxp, rport->bfa_rport, port->fabric->vf_id,
2612 port->lp_tag, BFA_FALSE, FC_CLASS_3, len, &fchs, 2468 port->lp_tag, BFA_FALSE, FC_CLASS_3, len, &fchs,
2613 NULL, NULL, FC_MAX_PDUSZ, 0); 2469 NULL, NULL, FC_MAX_PDUSZ, 0);
2614} 2470}
2615 2471
2616/* 2472/*
@@ -2620,10 +2476,10 @@ static void
2620bfa_fcs_rport_send_ls_rjt(struct bfa_fcs_rport_s *rport, struct fchs_s *rx_fchs, 2476bfa_fcs_rport_send_ls_rjt(struct bfa_fcs_rport_s *rport, struct fchs_s *rx_fchs,
2621 u8 reason_code, u8 reason_code_expl) 2477 u8 reason_code, u8 reason_code_expl)
2622{ 2478{
2623 struct bfa_fcs_port_s *port = rport->port; 2479 struct bfa_fcs_lport_s *port = rport->port;
2624 struct fchs_s fchs; 2480 struct fchs_s fchs;
2625 struct bfa_fcxp_s *fcxp; 2481 struct bfa_fcxp_s *fcxp;
2626 int len; 2482 int len;
2627 2483
2628 bfa_trc(rport->fcs, rx_fchs->s_id); 2484 bfa_trc(rport->fcs, rx_fchs->s_id);
2629 2485
@@ -2631,15 +2487,16 @@ bfa_fcs_rport_send_ls_rjt(struct bfa_fcs_rport_s *rport, struct fchs_s *rx_fchs,
2631 if (!fcxp) 2487 if (!fcxp)
2632 return; 2488 return;
2633 2489
2634 len = fc_ls_rjt_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rx_fchs->s_id, 2490 len = fc_ls_rjt_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
2635 bfa_fcs_port_get_fcid(port), rx_fchs->ox_id, 2491 rx_fchs->s_id, bfa_fcs_lport_get_fcid(port),
2636 reason_code, reason_code_expl); 2492 rx_fchs->ox_id, reason_code, reason_code_expl);
2637 2493
2638 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE, 2494 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag,
2639 FC_CLASS_3, len, &fchs, NULL, NULL, FC_MAX_PDUSZ, 0); 2495 BFA_FALSE, FC_CLASS_3, len, &fchs, NULL, NULL,
2496 FC_MAX_PDUSZ, 0);
2640} 2497}
2641 2498
2642/** 2499/*
2643 * Return state of rport. 2500 * Return state of rport.
2644 */ 2501 */
2645int 2502int
@@ -2648,25 +2505,24 @@ bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport)
2648 return bfa_sm_to_state(rport_sm_table, rport->sm); 2505 return bfa_sm_to_state(rport_sm_table, rport->sm);
2649} 2506}
2650 2507
2651/** 2508
2652 * Called by the Driver to set rport delete/ageout timeout 2509/*
2510 * brief
2511 * Called by the Driver to set rport delete/ageout timeout
2653 * 2512 *
2654 * param[in] rport timeout value in seconds. 2513 * param[in] rport timeout value in seconds.
2655 * 2514 *
2656 * return None 2515 * return None
2657 */ 2516 */
2658void 2517void
2659bfa_fcs_rport_set_del_timeout(u8 rport_tmo) 2518bfa_fcs_rport_set_del_timeout(u8 rport_tmo)
2660{ 2519{
2661 /* 2520 /* convert to Millisecs */
2662 * convert to Millisecs
2663 */
2664 if (rport_tmo > 0) 2521 if (rport_tmo > 0)
2665 bfa_fcs_rport_del_timeout = rport_tmo * 1000; 2522 bfa_fcs_rport_del_timeout = rport_tmo * 1000;
2666} 2523}
2667
2668void 2524void
2669bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, uint16_t ox_id) 2525bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, __be16 ox_id)
2670{ 2526{
2671 bfa_trc(rport->fcs, rport->pid); 2527 bfa_trc(rport->fcs, rport->pid);
2672 2528
@@ -2674,3 +2530,401 @@ bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, uint16_t ox_id)
2674 rport->reply_oxid = ox_id; 2530 rport->reply_oxid = ox_id;
2675 bfa_sm_send_event(rport, RPSM_EVENT_PRLO_RCVD); 2531 bfa_sm_send_event(rport, RPSM_EVENT_PRLO_RCVD);
2676} 2532}
2533
2534
2535
2536/*
2537 * Remote port implementation.
2538 */
2539
2540/*
2541 * fcs_rport_api FCS rport API.
2542 */
2543
2544struct bfa_fcs_rport_s *
2545bfa_fcs_rport_lookup(struct bfa_fcs_lport_s *port, wwn_t rpwwn)
2546{
2547 struct bfa_fcs_rport_s *rport;
2548
2549 rport = bfa_fcs_lport_get_rport_by_pwwn(port, rpwwn);
2550 if (rport == NULL) {
2551 /*
2552 * TBD Error handling
2553 */
2554 }
2555
2556 return rport;
2557}
2558
2559struct bfa_fcs_rport_s *
2560bfa_fcs_rport_lookup_by_nwwn(struct bfa_fcs_lport_s *port, wwn_t rnwwn)
2561{
2562 struct bfa_fcs_rport_s *rport;
2563
2564 rport = bfa_fcs_lport_get_rport_by_nwwn(port, rnwwn);
2565 if (rport == NULL) {
2566 /*
2567 * TBD Error handling
2568 */
2569 }
2570
2571 return rport;
2572}
2573
2574/*
2575 * Remote port features (RPF) implementation.
2576 */
2577
2578#define BFA_FCS_RPF_RETRIES (3)
2579#define BFA_FCS_RPF_RETRY_TIMEOUT (1000) /* 1 sec (In millisecs) */
2580
2581static void bfa_fcs_rpf_send_rpsc2(void *rport_cbarg,
2582 struct bfa_fcxp_s *fcxp_alloced);
2583static void bfa_fcs_rpf_rpsc2_response(void *fcsarg,
2584 struct bfa_fcxp_s *fcxp,
2585 void *cbarg,
2586 bfa_status_t req_status,
2587 u32 rsp_len,
2588 u32 resid_len,
2589 struct fchs_s *rsp_fchs);
2590
2591static void bfa_fcs_rpf_timeout(void *arg);
2592
2593/*
2594 * fcs_rport_ftrs_sm FCS rport state machine events
2595 */
2596
2597enum rpf_event {
2598 RPFSM_EVENT_RPORT_OFFLINE = 1, /* Rport offline */
2599 RPFSM_EVENT_RPORT_ONLINE = 2, /* Rport online */
2600 RPFSM_EVENT_FCXP_SENT = 3, /* Frame from has been sent */
2601 RPFSM_EVENT_TIMEOUT = 4, /* Rport SM timeout event */
2602 RPFSM_EVENT_RPSC_COMP = 5,
2603 RPFSM_EVENT_RPSC_FAIL = 6,
2604 RPFSM_EVENT_RPSC_ERROR = 7,
2605};
2606
2607static void bfa_fcs_rpf_sm_uninit(struct bfa_fcs_rpf_s *rpf,
2608 enum rpf_event event);
2609static void bfa_fcs_rpf_sm_rpsc_sending(struct bfa_fcs_rpf_s *rpf,
2610 enum rpf_event event);
2611static void bfa_fcs_rpf_sm_rpsc(struct bfa_fcs_rpf_s *rpf,
2612 enum rpf_event event);
2613static void bfa_fcs_rpf_sm_rpsc_retry(struct bfa_fcs_rpf_s *rpf,
2614 enum rpf_event event);
2615static void bfa_fcs_rpf_sm_offline(struct bfa_fcs_rpf_s *rpf,
2616 enum rpf_event event);
2617static void bfa_fcs_rpf_sm_online(struct bfa_fcs_rpf_s *rpf,
2618 enum rpf_event event);
2619
2620static void
2621bfa_fcs_rpf_sm_uninit(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
2622{
2623 struct bfa_fcs_rport_s *rport = rpf->rport;
2624 struct bfa_fcs_fabric_s *fabric = &rport->fcs->fabric;
2625
2626 bfa_trc(rport->fcs, rport->pwwn);
2627 bfa_trc(rport->fcs, rport->pid);
2628 bfa_trc(rport->fcs, event);
2629
2630 switch (event) {
2631 case RPFSM_EVENT_RPORT_ONLINE:
2632 /* Send RPSC2 to a Brocade fabric only. */
2633 if ((!BFA_FCS_PID_IS_WKA(rport->pid)) &&
2634 ((rport->port->fabric->lps->brcd_switch) ||
2635 (bfa_fcs_fabric_get_switch_oui(fabric) ==
2636 BFA_FCS_BRCD_SWITCH_OUI))) {
2637 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_rpsc_sending);
2638 rpf->rpsc_retries = 0;
2639 bfa_fcs_rpf_send_rpsc2(rpf, NULL);
2640 }
2641 break;
2642
2643 case RPFSM_EVENT_RPORT_OFFLINE:
2644 break;
2645
2646 default:
2647 bfa_sm_fault(rport->fcs, event);
2648 }
2649}
2650
2651static void
2652bfa_fcs_rpf_sm_rpsc_sending(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
2653{
2654 struct bfa_fcs_rport_s *rport = rpf->rport;
2655
2656 bfa_trc(rport->fcs, event);
2657
2658 switch (event) {
2659 case RPFSM_EVENT_FCXP_SENT:
2660 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_rpsc);
2661 break;
2662
2663 case RPFSM_EVENT_RPORT_OFFLINE:
2664 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_offline);
2665 bfa_fcxp_walloc_cancel(rport->fcs->bfa, &rpf->fcxp_wqe);
2666 rpf->rpsc_retries = 0;
2667 break;
2668
2669 default:
2670 bfa_sm_fault(rport->fcs, event);
2671 }
2672}
2673
2674static void
2675bfa_fcs_rpf_sm_rpsc(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
2676{
2677 struct bfa_fcs_rport_s *rport = rpf->rport;
2678
2679 bfa_trc(rport->fcs, rport->pid);
2680 bfa_trc(rport->fcs, event);
2681
2682 switch (event) {
2683 case RPFSM_EVENT_RPSC_COMP:
2684 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_online);
2685 /* Update speed info in f/w via BFA */
2686 if (rpf->rpsc_speed != BFA_PORT_SPEED_UNKNOWN)
2687 bfa_rport_speed(rport->bfa_rport, rpf->rpsc_speed);
2688 else if (rpf->assigned_speed != BFA_PORT_SPEED_UNKNOWN)
2689 bfa_rport_speed(rport->bfa_rport, rpf->assigned_speed);
2690 break;
2691
2692 case RPFSM_EVENT_RPSC_FAIL:
2693 /* RPSC not supported by rport */
2694 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_online);
2695 break;
2696
2697 case RPFSM_EVENT_RPSC_ERROR:
2698 /* need to retry...delayed a bit. */
2699 if (rpf->rpsc_retries++ < BFA_FCS_RPF_RETRIES) {
2700 bfa_timer_start(rport->fcs->bfa, &rpf->timer,
2701 bfa_fcs_rpf_timeout, rpf,
2702 BFA_FCS_RPF_RETRY_TIMEOUT);
2703 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_rpsc_retry);
2704 } else {
2705 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_online);
2706 }
2707 break;
2708
2709 case RPFSM_EVENT_RPORT_OFFLINE:
2710 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_offline);
2711 bfa_fcxp_discard(rpf->fcxp);
2712 rpf->rpsc_retries = 0;
2713 break;
2714
2715 default:
2716 bfa_sm_fault(rport->fcs, event);
2717 }
2718}
2719
2720static void
2721bfa_fcs_rpf_sm_rpsc_retry(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
2722{
2723 struct bfa_fcs_rport_s *rport = rpf->rport;
2724
2725 bfa_trc(rport->fcs, rport->pid);
2726 bfa_trc(rport->fcs, event);
2727
2728 switch (event) {
2729 case RPFSM_EVENT_TIMEOUT:
2730 /* re-send the RPSC */
2731 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_rpsc_sending);
2732 bfa_fcs_rpf_send_rpsc2(rpf, NULL);
2733 break;
2734
2735 case RPFSM_EVENT_RPORT_OFFLINE:
2736 bfa_timer_stop(&rpf->timer);
2737 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_offline);
2738 rpf->rpsc_retries = 0;
2739 break;
2740
2741 default:
2742 bfa_sm_fault(rport->fcs, event);
2743 }
2744}
2745
2746static void
2747bfa_fcs_rpf_sm_online(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
2748{
2749 struct bfa_fcs_rport_s *rport = rpf->rport;
2750
2751 bfa_trc(rport->fcs, rport->pwwn);
2752 bfa_trc(rport->fcs, rport->pid);
2753 bfa_trc(rport->fcs, event);
2754
2755 switch (event) {
2756 case RPFSM_EVENT_RPORT_OFFLINE:
2757 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_offline);
2758 rpf->rpsc_retries = 0;
2759 break;
2760
2761 default:
2762 bfa_sm_fault(rport->fcs, event);
2763 }
2764}
2765
2766static void
2767bfa_fcs_rpf_sm_offline(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
2768{
2769 struct bfa_fcs_rport_s *rport = rpf->rport;
2770
2771 bfa_trc(rport->fcs, rport->pwwn);
2772 bfa_trc(rport->fcs, rport->pid);
2773 bfa_trc(rport->fcs, event);
2774
2775 switch (event) {
2776 case RPFSM_EVENT_RPORT_ONLINE:
2777 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_rpsc_sending);
2778 bfa_fcs_rpf_send_rpsc2(rpf, NULL);
2779 break;
2780
2781 case RPFSM_EVENT_RPORT_OFFLINE:
2782 break;
2783
2784 default:
2785 bfa_sm_fault(rport->fcs, event);
2786 }
2787}
2788/*
2789 * Called when Rport is created.
2790 */
2791void
2792bfa_fcs_rpf_init(struct bfa_fcs_rport_s *rport)
2793{
2794 struct bfa_fcs_rpf_s *rpf = &rport->rpf;
2795
2796 bfa_trc(rport->fcs, rport->pid);
2797 rpf->rport = rport;
2798
2799 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_uninit);
2800}
2801
2802/*
2803 * Called when Rport becomes online
2804 */
2805void
2806bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s *rport)
2807{
2808 bfa_trc(rport->fcs, rport->pid);
2809
2810 if (__fcs_min_cfg(rport->port->fcs))
2811 return;
2812
2813 if (bfa_fcs_fabric_is_switched(rport->port->fabric))
2814 bfa_sm_send_event(&rport->rpf, RPFSM_EVENT_RPORT_ONLINE);
2815}
2816
2817/*
2818 * Called when Rport becomes offline
2819 */
2820void
2821bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport)
2822{
2823 bfa_trc(rport->fcs, rport->pid);
2824
2825 if (__fcs_min_cfg(rport->port->fcs))
2826 return;
2827
2828 rport->rpf.rpsc_speed = 0;
2829 bfa_sm_send_event(&rport->rpf, RPFSM_EVENT_RPORT_OFFLINE);
2830}
2831
2832static void
2833bfa_fcs_rpf_timeout(void *arg)
2834{
2835 struct bfa_fcs_rpf_s *rpf = (struct bfa_fcs_rpf_s *) arg;
2836 struct bfa_fcs_rport_s *rport = rpf->rport;
2837
2838 bfa_trc(rport->fcs, rport->pid);
2839 bfa_sm_send_event(rpf, RPFSM_EVENT_TIMEOUT);
2840}
2841
2842static void
2843bfa_fcs_rpf_send_rpsc2(void *rpf_cbarg, struct bfa_fcxp_s *fcxp_alloced)
2844{
2845 struct bfa_fcs_rpf_s *rpf = (struct bfa_fcs_rpf_s *)rpf_cbarg;
2846 struct bfa_fcs_rport_s *rport = rpf->rport;
2847 struct bfa_fcs_lport_s *port = rport->port;
2848 struct fchs_s fchs;
2849 int len;
2850 struct bfa_fcxp_s *fcxp;
2851
2852 bfa_trc(rport->fcs, rport->pwwn);
2853
2854 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
2855 if (!fcxp) {
2856 bfa_fcs_fcxp_alloc_wait(port->fcs->bfa, &rpf->fcxp_wqe,
2857 bfa_fcs_rpf_send_rpsc2, rpf);
2858 return;
2859 }
2860 rpf->fcxp = fcxp;
2861
2862 len = fc_rpsc2_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid,
2863 bfa_fcs_lport_get_fcid(port), &rport->pid, 1);
2864
2865 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
2866 FC_CLASS_3, len, &fchs, bfa_fcs_rpf_rpsc2_response,
2867 rpf, FC_MAX_PDUSZ, FC_ELS_TOV);
2868 rport->stats.rpsc_sent++;
2869 bfa_sm_send_event(rpf, RPFSM_EVENT_FCXP_SENT);
2870
2871}
2872
2873static void
2874bfa_fcs_rpf_rpsc2_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
2875 bfa_status_t req_status, u32 rsp_len,
2876 u32 resid_len, struct fchs_s *rsp_fchs)
2877{
2878 struct bfa_fcs_rpf_s *rpf = (struct bfa_fcs_rpf_s *) cbarg;
2879 struct bfa_fcs_rport_s *rport = rpf->rport;
2880 struct fc_ls_rjt_s *ls_rjt;
2881 struct fc_rpsc2_acc_s *rpsc2_acc;
2882 u16 num_ents;
2883
2884 bfa_trc(rport->fcs, req_status);
2885
2886 if (req_status != BFA_STATUS_OK) {
2887 bfa_trc(rport->fcs, req_status);
2888 if (req_status == BFA_STATUS_ETIMER)
2889 rport->stats.rpsc_failed++;
2890 bfa_sm_send_event(rpf, RPFSM_EVENT_RPSC_ERROR);
2891 return;
2892 }
2893
2894 rpsc2_acc = (struct fc_rpsc2_acc_s *) BFA_FCXP_RSP_PLD(fcxp);
2895 if (rpsc2_acc->els_cmd == FC_ELS_ACC) {
2896 rport->stats.rpsc_accs++;
2897 num_ents = be16_to_cpu(rpsc2_acc->num_pids);
2898 bfa_trc(rport->fcs, num_ents);
2899 if (num_ents > 0) {
2900 WARN_ON(rpsc2_acc->port_info[0].pid == rport->pid);
2901 bfa_trc(rport->fcs,
2902 be16_to_cpu(rpsc2_acc->port_info[0].pid));
2903 bfa_trc(rport->fcs,
2904 be16_to_cpu(rpsc2_acc->port_info[0].speed));
2905 bfa_trc(rport->fcs,
2906 be16_to_cpu(rpsc2_acc->port_info[0].index));
2907 bfa_trc(rport->fcs,
2908 rpsc2_acc->port_info[0].type);
2909
2910 if (rpsc2_acc->port_info[0].speed == 0) {
2911 bfa_sm_send_event(rpf, RPFSM_EVENT_RPSC_ERROR);
2912 return;
2913 }
2914
2915 rpf->rpsc_speed = fc_rpsc_operspeed_to_bfa_speed(
2916 be16_to_cpu(rpsc2_acc->port_info[0].speed));
2917
2918 bfa_sm_send_event(rpf, RPFSM_EVENT_RPSC_COMP);
2919 }
2920 } else {
2921 ls_rjt = (struct fc_ls_rjt_s *) BFA_FCXP_RSP_PLD(fcxp);
2922 bfa_trc(rport->fcs, ls_rjt->reason_code);
2923 bfa_trc(rport->fcs, ls_rjt->reason_code_expl);
2924 rport->stats.rpsc_rejects++;
2925 if (ls_rjt->reason_code == FC_LS_RJT_RSN_CMD_NOT_SUPP)
2926 bfa_sm_send_event(rpf, RPFSM_EVENT_RPSC_FAIL);
2927 else
2928 bfa_sm_send_event(rpf, RPFSM_EVENT_RPSC_ERROR);
2929 }
2930}
diff --git a/drivers/scsi/bfa/bfa_fcs_uf.c b/drivers/scsi/bfa/bfa_fcs_uf.c
deleted file mode 100644
index 3d57d48bbae4..000000000000
--- a/drivers/scsi/bfa/bfa_fcs_uf.c
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcs_uf.c BFA FCS UF ( Unsolicited Frames)
20 */
21
22#include <fcs/bfa_fcs.h>
23#include <bfa_svc.h>
24#include <fcs/bfa_fcs_fabric.h>
25#include "fcs.h"
26#include "fcs_trcmod.h"
27#include "fcs_fabric.h"
28#include "fcs_uf.h"
29
30BFA_TRC_FILE(FCS, UF);
31
32/**
33 * BFA callback for unsolicited frame receive handler.
34 *
35 * @param[in] cbarg callback arg for receive handler
36 * @param[in] uf unsolicited frame descriptor
37 *
38 * @return None
39 */
40static void
41bfa_fcs_uf_recv(void *cbarg, struct bfa_uf_s *uf)
42{
43 struct bfa_fcs_s *fcs = (struct bfa_fcs_s *) cbarg;
44 struct fchs_s *fchs = bfa_uf_get_frmbuf(uf);
45 u16 len = bfa_uf_get_frmlen(uf);
46 struct fc_vft_s *vft;
47 struct bfa_fcs_fabric_s *fabric;
48
49 /**
50 * check for VFT header
51 */
52 if (fchs->routing == FC_RTG_EXT_HDR &&
53 fchs->cat_info == FC_CAT_VFT_HDR) {
54 bfa_stats(fcs, uf.tagged);
55 vft = bfa_uf_get_frmbuf(uf);
56 if (fcs->port_vfid == vft->vf_id)
57 fabric = &fcs->fabric;
58 else
59 fabric = bfa_fcs_vf_lookup(fcs, (u16) vft->vf_id);
60
61 /**
62 * drop frame if vfid is unknown
63 */
64 if (!fabric) {
65 bfa_assert(0);
66 bfa_stats(fcs, uf.vfid_unknown);
67 bfa_uf_free(uf);
68 return;
69 }
70
71 /**
72 * skip vft header
73 */
74 fchs = (struct fchs_s *) (vft + 1);
75 len -= sizeof(struct fc_vft_s);
76
77 bfa_trc(fcs, vft->vf_id);
78 } else {
79 bfa_stats(fcs, uf.untagged);
80 fabric = &fcs->fabric;
81 }
82
83 bfa_trc(fcs, ((u32 *) fchs)[0]);
84 bfa_trc(fcs, ((u32 *) fchs)[1]);
85 bfa_trc(fcs, ((u32 *) fchs)[2]);
86 bfa_trc(fcs, ((u32 *) fchs)[3]);
87 bfa_trc(fcs, ((u32 *) fchs)[4]);
88 bfa_trc(fcs, ((u32 *) fchs)[5]);
89 bfa_trc(fcs, len);
90
91 bfa_fcs_fabric_uf_recv(fabric, fchs, len);
92 bfa_uf_free(uf);
93}
94
95void
96bfa_fcs_uf_attach(struct bfa_fcs_s *fcs)
97{
98 bfa_uf_recv_register(fcs->bfa, bfa_fcs_uf_recv, fcs);
99}
diff --git a/drivers/scsi/bfa/bfa_fcxp.c b/drivers/scsi/bfa/bfa_fcxp.c
deleted file mode 100644
index 8258f88bfee6..000000000000
--- a/drivers/scsi/bfa/bfa_fcxp.c
+++ /dev/null
@@ -1,774 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
19#include <bfi/bfi_uf.h>
20#include <cs/bfa_debug.h>
21
22BFA_TRC_FILE(HAL, FCXP);
23BFA_MODULE(fcxp);
24
25/**
26 * forward declarations
27 */
28static void __bfa_fcxp_send_cbfn(void *cbarg, bfa_boolean_t complete);
29static void hal_fcxp_rx_plog(struct bfa_s *bfa, struct bfa_fcxp_s *fcxp,
30 struct bfi_fcxp_send_rsp_s *fcxp_rsp);
31static void hal_fcxp_tx_plog(struct bfa_s *bfa, u32 reqlen,
32 struct bfa_fcxp_s *fcxp, struct fchs_s *fchs);
33static void bfa_fcxp_qresume(void *cbarg);
34static void bfa_fcxp_queue(struct bfa_fcxp_s *fcxp,
35 struct bfi_fcxp_send_req_s *send_req);
36
37/**
38 * fcxp_pvt BFA FCXP private functions
39 */
40
41static void
42claim_fcxp_req_rsp_mem(struct bfa_fcxp_mod_s *mod, struct bfa_meminfo_s *mi)
43{
44 u8 *dm_kva = NULL;
45 u64 dm_pa;
46 u32 buf_pool_sz;
47
48 dm_kva = bfa_meminfo_dma_virt(mi);
49 dm_pa = bfa_meminfo_dma_phys(mi);
50
51 buf_pool_sz = mod->req_pld_sz * mod->num_fcxps;
52
53 /*
54 * Initialize the fcxp req payload list
55 */
56 mod->req_pld_list_kva = dm_kva;
57 mod->req_pld_list_pa = dm_pa;
58 dm_kva += buf_pool_sz;
59 dm_pa += buf_pool_sz;
60 bfa_os_memset(mod->req_pld_list_kva, 0, buf_pool_sz);
61
62 /*
63 * Initialize the fcxp rsp payload list
64 */
65 buf_pool_sz = mod->rsp_pld_sz * mod->num_fcxps;
66 mod->rsp_pld_list_kva = dm_kva;
67 mod->rsp_pld_list_pa = dm_pa;
68 dm_kva += buf_pool_sz;
69 dm_pa += buf_pool_sz;
70 bfa_os_memset(mod->rsp_pld_list_kva, 0, buf_pool_sz);
71
72 bfa_meminfo_dma_virt(mi) = dm_kva;
73 bfa_meminfo_dma_phys(mi) = dm_pa;
74}
75
76static void
77claim_fcxps_mem(struct bfa_fcxp_mod_s *mod, struct bfa_meminfo_s *mi)
78{
79 u16 i;
80 struct bfa_fcxp_s *fcxp;
81
82 fcxp = (struct bfa_fcxp_s *) bfa_meminfo_kva(mi);
83 bfa_os_memset(fcxp, 0, sizeof(struct bfa_fcxp_s) * mod->num_fcxps);
84
85 INIT_LIST_HEAD(&mod->fcxp_free_q);
86 INIT_LIST_HEAD(&mod->fcxp_active_q);
87
88 mod->fcxp_list = fcxp;
89
90 for (i = 0; i < mod->num_fcxps; i++) {
91 fcxp->fcxp_mod = mod;
92 fcxp->fcxp_tag = i;
93
94 list_add_tail(&fcxp->qe, &mod->fcxp_free_q);
95 bfa_reqq_winit(&fcxp->reqq_wqe, bfa_fcxp_qresume, fcxp);
96 fcxp->reqq_waiting = BFA_FALSE;
97
98 fcxp = fcxp + 1;
99 }
100
101 bfa_meminfo_kva(mi) = (void *)fcxp;
102}
103
104static void
105bfa_fcxp_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len,
106 u32 *dm_len)
107{
108 u16 num_fcxp_reqs = cfg->fwcfg.num_fcxp_reqs;
109
110 if (num_fcxp_reqs == 0)
111 return;
112
113 /*
114 * Account for req/rsp payload
115 */
116 *dm_len += BFA_FCXP_MAX_IBUF_SZ * num_fcxp_reqs;
117 if (cfg->drvcfg.min_cfg)
118 *dm_len += BFA_FCXP_MAX_IBUF_SZ * num_fcxp_reqs;
119 else
120 *dm_len += BFA_FCXP_MAX_LBUF_SZ * num_fcxp_reqs;
121
122 /*
123 * Account for fcxp structs
124 */
125 *ndm_len += sizeof(struct bfa_fcxp_s) * num_fcxp_reqs;
126}
127
128static void
129bfa_fcxp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
130 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
131{
132 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
133
134 bfa_os_memset(mod, 0, sizeof(struct bfa_fcxp_mod_s));
135 mod->bfa = bfa;
136 mod->num_fcxps = cfg->fwcfg.num_fcxp_reqs;
137
138 /**
139 * Initialize FCXP request and response payload sizes.
140 */
141 mod->req_pld_sz = mod->rsp_pld_sz = BFA_FCXP_MAX_IBUF_SZ;
142 if (!cfg->drvcfg.min_cfg)
143 mod->rsp_pld_sz = BFA_FCXP_MAX_LBUF_SZ;
144
145 INIT_LIST_HEAD(&mod->wait_q);
146
147 claim_fcxp_req_rsp_mem(mod, meminfo);
148 claim_fcxps_mem(mod, meminfo);
149}
150
151static void
152bfa_fcxp_detach(struct bfa_s *bfa)
153{
154}
155
156static void
157bfa_fcxp_start(struct bfa_s *bfa)
158{
159}
160
161static void
162bfa_fcxp_stop(struct bfa_s *bfa)
163{
164}
165
166static void
167bfa_fcxp_iocdisable(struct bfa_s *bfa)
168{
169 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
170 struct bfa_fcxp_s *fcxp;
171 struct list_head *qe, *qen;
172
173 list_for_each_safe(qe, qen, &mod->fcxp_active_q) {
174 fcxp = (struct bfa_fcxp_s *) qe;
175 if (fcxp->caller == NULL) {
176 fcxp->send_cbfn(fcxp->caller, fcxp, fcxp->send_cbarg,
177 BFA_STATUS_IOC_FAILURE, 0, 0, NULL);
178 bfa_fcxp_free(fcxp);
179 } else {
180 fcxp->rsp_status = BFA_STATUS_IOC_FAILURE;
181 bfa_cb_queue(bfa, &fcxp->hcb_qe,
182 __bfa_fcxp_send_cbfn, fcxp);
183 }
184 }
185}
186
187static struct bfa_fcxp_s *
188bfa_fcxp_get(struct bfa_fcxp_mod_s *fm)
189{
190 struct bfa_fcxp_s *fcxp;
191
192 bfa_q_deq(&fm->fcxp_free_q, &fcxp);
193
194 if (fcxp)
195 list_add_tail(&fcxp->qe, &fm->fcxp_active_q);
196
197 return fcxp;
198}
199
200static void
201bfa_fcxp_put(struct bfa_fcxp_s *fcxp)
202{
203 struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
204 struct bfa_fcxp_wqe_s *wqe;
205
206 bfa_q_deq(&mod->wait_q, &wqe);
207 if (wqe) {
208 bfa_trc(mod->bfa, fcxp->fcxp_tag);
209 wqe->alloc_cbfn(wqe->alloc_cbarg, fcxp);
210 return;
211 }
212
213 bfa_assert(bfa_q_is_on_q(&mod->fcxp_active_q, fcxp));
214 list_del(&fcxp->qe);
215 list_add_tail(&fcxp->qe, &mod->fcxp_free_q);
216}
217
218static void
219bfa_fcxp_null_comp(void *bfad_fcxp, struct bfa_fcxp_s *fcxp, void *cbarg,
220 bfa_status_t req_status, u32 rsp_len,
221 u32 resid_len, struct fchs_s *rsp_fchs)
222{
223 /* discarded fcxp completion */
224}
225
226static void
227__bfa_fcxp_send_cbfn(void *cbarg, bfa_boolean_t complete)
228{
229 struct bfa_fcxp_s *fcxp = cbarg;
230
231 if (complete) {
232 fcxp->send_cbfn(fcxp->caller, fcxp, fcxp->send_cbarg,
233 fcxp->rsp_status, fcxp->rsp_len,
234 fcxp->residue_len, &fcxp->rsp_fchs);
235 } else {
236 bfa_fcxp_free(fcxp);
237 }
238}
239
240static void
241hal_fcxp_send_comp(struct bfa_s *bfa, struct bfi_fcxp_send_rsp_s *fcxp_rsp)
242{
243 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
244 struct bfa_fcxp_s *fcxp;
245 u16 fcxp_tag = bfa_os_ntohs(fcxp_rsp->fcxp_tag);
246
247 bfa_trc(bfa, fcxp_tag);
248
249 fcxp_rsp->rsp_len = bfa_os_ntohl(fcxp_rsp->rsp_len);
250
251 /**
252 * @todo f/w should not set residue to non-0 when everything
253 * is received.
254 */
255 if (fcxp_rsp->req_status == BFA_STATUS_OK)
256 fcxp_rsp->residue_len = 0;
257 else
258 fcxp_rsp->residue_len = bfa_os_ntohl(fcxp_rsp->residue_len);
259
260 fcxp = BFA_FCXP_FROM_TAG(mod, fcxp_tag);
261
262 bfa_assert(fcxp->send_cbfn != NULL);
263
264 hal_fcxp_rx_plog(mod->bfa, fcxp, fcxp_rsp);
265
266 if (fcxp->send_cbfn != NULL) {
267 if (fcxp->caller == NULL) {
268 bfa_trc(mod->bfa, fcxp->fcxp_tag);
269
270 fcxp->send_cbfn(fcxp->caller, fcxp, fcxp->send_cbarg,
271 fcxp_rsp->req_status, fcxp_rsp->rsp_len,
272 fcxp_rsp->residue_len, &fcxp_rsp->fchs);
273 /*
274 * fcxp automatically freed on return from the callback
275 */
276 bfa_fcxp_free(fcxp);
277 } else {
278 bfa_trc(mod->bfa, fcxp->fcxp_tag);
279 fcxp->rsp_status = fcxp_rsp->req_status;
280 fcxp->rsp_len = fcxp_rsp->rsp_len;
281 fcxp->residue_len = fcxp_rsp->residue_len;
282 fcxp->rsp_fchs = fcxp_rsp->fchs;
283
284 bfa_cb_queue(bfa, &fcxp->hcb_qe,
285 __bfa_fcxp_send_cbfn, fcxp);
286 }
287 } else {
288 bfa_trc(bfa, fcxp_tag);
289 }
290}
291
292static void
293hal_fcxp_set_local_sges(struct bfi_sge_s *sge, u32 reqlen, u64 req_pa)
294{
295 union bfi_addr_u sga_zero = { {0} };
296
297 sge->sg_len = reqlen;
298 sge->flags = BFI_SGE_DATA_LAST;
299 bfa_dma_addr_set(sge[0].sga, req_pa);
300 bfa_sge_to_be(sge);
301 sge++;
302
303 sge->sga = sga_zero;
304 sge->sg_len = reqlen;
305 sge->flags = BFI_SGE_PGDLEN;
306 bfa_sge_to_be(sge);
307}
308
309static void
310hal_fcxp_tx_plog(struct bfa_s *bfa, u32 reqlen, struct bfa_fcxp_s *fcxp,
311 struct fchs_s *fchs)
312{
313 /*
314 * TODO: TX ox_id
315 */
316 if (reqlen > 0) {
317 if (fcxp->use_ireqbuf) {
318 u32 pld_w0 =
319 *((u32 *) BFA_FCXP_REQ_PLD(fcxp));
320
321 bfa_plog_fchdr_and_pl(bfa->plog, BFA_PL_MID_HAL_FCXP,
322 BFA_PL_EID_TX,
323 reqlen + sizeof(struct fchs_s), fchs, pld_w0);
324 } else {
325 bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP,
326 BFA_PL_EID_TX, reqlen + sizeof(struct fchs_s),
327 fchs);
328 }
329 } else {
330 bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP, BFA_PL_EID_TX,
331 reqlen + sizeof(struct fchs_s), fchs);
332 }
333}
334
335static void
336hal_fcxp_rx_plog(struct bfa_s *bfa, struct bfa_fcxp_s *fcxp,
337 struct bfi_fcxp_send_rsp_s *fcxp_rsp)
338{
339 if (fcxp_rsp->rsp_len > 0) {
340 if (fcxp->use_irspbuf) {
341 u32 pld_w0 =
342 *((u32 *) BFA_FCXP_RSP_PLD(fcxp));
343
344 bfa_plog_fchdr_and_pl(bfa->plog, BFA_PL_MID_HAL_FCXP,
345 BFA_PL_EID_RX,
346 (u16) fcxp_rsp->rsp_len,
347 &fcxp_rsp->fchs, pld_w0);
348 } else {
349 bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP,
350 BFA_PL_EID_RX,
351 (u16) fcxp_rsp->rsp_len,
352 &fcxp_rsp->fchs);
353 }
354 } else {
355 bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP, BFA_PL_EID_RX,
356 (u16) fcxp_rsp->rsp_len, &fcxp_rsp->fchs);
357 }
358}
359
360/**
361 * Handler to resume sending fcxp when space in available in cpe queue.
362 */
363static void
364bfa_fcxp_qresume(void *cbarg)
365{
366 struct bfa_fcxp_s *fcxp = cbarg;
367 struct bfa_s *bfa = fcxp->fcxp_mod->bfa;
368 struct bfi_fcxp_send_req_s *send_req;
369
370 fcxp->reqq_waiting = BFA_FALSE;
371 send_req = bfa_reqq_next(bfa, BFA_REQQ_FCXP);
372 bfa_fcxp_queue(fcxp, send_req);
373}
374
375/**
376 * Queue fcxp send request to foimrware.
377 */
378static void
379bfa_fcxp_queue(struct bfa_fcxp_s *fcxp, struct bfi_fcxp_send_req_s *send_req)
380{
381 struct bfa_s *bfa = fcxp->fcxp_mod->bfa;
382 struct bfa_fcxp_req_info_s *reqi = &fcxp->req_info;
383 struct bfa_fcxp_rsp_info_s *rspi = &fcxp->rsp_info;
384 struct bfa_rport_s *rport = reqi->bfa_rport;
385
386 bfi_h2i_set(send_req->mh, BFI_MC_FCXP, BFI_FCXP_H2I_SEND_REQ,
387 bfa_lpuid(bfa));
388
389 send_req->fcxp_tag = bfa_os_htons(fcxp->fcxp_tag);
390 if (rport) {
391 send_req->rport_fw_hndl = rport->fw_handle;
392 send_req->max_frmsz = bfa_os_htons(rport->rport_info.max_frmsz);
393 if (send_req->max_frmsz == 0)
394 send_req->max_frmsz = bfa_os_htons(FC_MAX_PDUSZ);
395 } else {
396 send_req->rport_fw_hndl = 0;
397 send_req->max_frmsz = bfa_os_htons(FC_MAX_PDUSZ);
398 }
399
400 send_req->vf_id = bfa_os_htons(reqi->vf_id);
401 send_req->lp_tag = reqi->lp_tag;
402 send_req->class = reqi->class;
403 send_req->rsp_timeout = rspi->rsp_timeout;
404 send_req->cts = reqi->cts;
405 send_req->fchs = reqi->fchs;
406
407 send_req->req_len = bfa_os_htonl(reqi->req_tot_len);
408 send_req->rsp_maxlen = bfa_os_htonl(rspi->rsp_maxlen);
409
410 /*
411 * setup req sgles
412 */
413 if (fcxp->use_ireqbuf == 1) {
414 hal_fcxp_set_local_sges(send_req->req_sge, reqi->req_tot_len,
415 BFA_FCXP_REQ_PLD_PA(fcxp));
416 } else {
417 if (fcxp->nreq_sgles > 0) {
418 bfa_assert(fcxp->nreq_sgles == 1);
419 hal_fcxp_set_local_sges(send_req->req_sge,
420 reqi->req_tot_len,
421 fcxp->req_sga_cbfn(fcxp->caller,
422 0));
423 } else {
424 bfa_assert(reqi->req_tot_len == 0);
425 hal_fcxp_set_local_sges(send_req->rsp_sge, 0, 0);
426 }
427 }
428
429 /*
430 * setup rsp sgles
431 */
432 if (fcxp->use_irspbuf == 1) {
433 bfa_assert(rspi->rsp_maxlen <= BFA_FCXP_MAX_LBUF_SZ);
434
435 hal_fcxp_set_local_sges(send_req->rsp_sge, rspi->rsp_maxlen,
436 BFA_FCXP_RSP_PLD_PA(fcxp));
437
438 } else {
439 if (fcxp->nrsp_sgles > 0) {
440 bfa_assert(fcxp->nrsp_sgles == 1);
441 hal_fcxp_set_local_sges(send_req->rsp_sge,
442 rspi->rsp_maxlen,
443 fcxp->rsp_sga_cbfn(fcxp->caller,
444 0));
445 } else {
446 bfa_assert(rspi->rsp_maxlen == 0);
447 hal_fcxp_set_local_sges(send_req->rsp_sge, 0, 0);
448 }
449 }
450
451 hal_fcxp_tx_plog(bfa, reqi->req_tot_len, fcxp, &reqi->fchs);
452
453 bfa_reqq_produce(bfa, BFA_REQQ_FCXP);
454
455 bfa_trc(bfa, bfa_reqq_pi(bfa, BFA_REQQ_FCXP));
456 bfa_trc(bfa, bfa_reqq_ci(bfa, BFA_REQQ_FCXP));
457}
458
459
460/**
461 * hal_fcxp_api BFA FCXP API
462 */
463
464/**
465 * Allocate an FCXP instance to send a response or to send a request
466 * that has a response. Request/response buffers are allocated by caller.
467 *
468 * @param[in] bfa BFA bfa instance
469 * @param[in] nreq_sgles Number of SG elements required for request
470 * buffer. 0, if fcxp internal buffers are used.
471 * Use bfa_fcxp_get_reqbuf() to get the
472 * internal req buffer.
473 * @param[in] req_sgles SG elements describing request buffer. Will be
474 * copied in by BFA and hence can be freed on
475 * return from this function.
476 * @param[in] get_req_sga function ptr to be called to get a request SG
477 * Address (given the sge index).
478 * @param[in] get_req_sglen function ptr to be called to get a request SG
479 * len (given the sge index).
480 * @param[in] get_rsp_sga function ptr to be called to get a response SG
481 * Address (given the sge index).
482 * @param[in] get_rsp_sglen function ptr to be called to get a response SG
483 * len (given the sge index).
484 *
485 * @return FCXP instance. NULL on failure.
486 */
487struct bfa_fcxp_s *
488bfa_fcxp_alloc(void *caller, struct bfa_s *bfa, int nreq_sgles,
489 int nrsp_sgles, bfa_fcxp_get_sgaddr_t req_sga_cbfn,
490 bfa_fcxp_get_sglen_t req_sglen_cbfn,
491 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn,
492 bfa_fcxp_get_sglen_t rsp_sglen_cbfn)
493{
494 struct bfa_fcxp_s *fcxp = NULL;
495 u32 nreq_sgpg, nrsp_sgpg;
496
497 bfa_assert(bfa != NULL);
498
499 fcxp = bfa_fcxp_get(BFA_FCXP_MOD(bfa));
500 if (fcxp == NULL)
501 return NULL;
502
503 bfa_trc(bfa, fcxp->fcxp_tag);
504
505 fcxp->caller = caller;
506
507 if (nreq_sgles == 0) {
508 fcxp->use_ireqbuf = 1;
509 } else {
510 bfa_assert(req_sga_cbfn != NULL);
511 bfa_assert(req_sglen_cbfn != NULL);
512
513 fcxp->use_ireqbuf = 0;
514 fcxp->req_sga_cbfn = req_sga_cbfn;
515 fcxp->req_sglen_cbfn = req_sglen_cbfn;
516
517 fcxp->nreq_sgles = nreq_sgles;
518
519 /*
520 * alloc required sgpgs
521 */
522 if (nreq_sgles > BFI_SGE_INLINE) {
523 nreq_sgpg = BFA_SGPG_NPAGE(nreq_sgles);
524
525 if (bfa_sgpg_malloc(bfa, &fcxp->req_sgpg_q, nreq_sgpg)
526 != BFA_STATUS_OK) {
527 /*
528 * TODO
529 */
530 }
531 }
532 }
533
534 if (nrsp_sgles == 0) {
535 fcxp->use_irspbuf = 1;
536 } else {
537 bfa_assert(rsp_sga_cbfn != NULL);
538 bfa_assert(rsp_sglen_cbfn != NULL);
539
540 fcxp->use_irspbuf = 0;
541 fcxp->rsp_sga_cbfn = rsp_sga_cbfn;
542 fcxp->rsp_sglen_cbfn = rsp_sglen_cbfn;
543
544 fcxp->nrsp_sgles = nrsp_sgles;
545 /*
546 * alloc required sgpgs
547 */
548 if (nrsp_sgles > BFI_SGE_INLINE) {
549 nrsp_sgpg = BFA_SGPG_NPAGE(nreq_sgles);
550
551 if (bfa_sgpg_malloc
552 (bfa, &fcxp->rsp_sgpg_q, nrsp_sgpg)
553 != BFA_STATUS_OK) {
554 /* bfa_sgpg_wait(bfa, &fcxp->rsp_sgpg_wqe,
555 nrsp_sgpg); */
556 /*
557 * TODO
558 */
559 }
560 }
561 }
562
563 return fcxp;
564}
565
566/**
567 * Get the internal request buffer pointer
568 *
569 * @param[in] fcxp BFA fcxp pointer
570 *
571 * @return pointer to the internal request buffer
572 */
573void *
574bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp)
575{
576 struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
577 void *reqbuf;
578
579 bfa_assert(fcxp->use_ireqbuf == 1);
580 reqbuf = ((u8 *)mod->req_pld_list_kva) +
581 fcxp->fcxp_tag * mod->req_pld_sz;
582 return reqbuf;
583}
584
585u32
586bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp)
587{
588 struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
589
590 return mod->req_pld_sz;
591}
592
593/**
594 * Get the internal response buffer pointer
595 *
596 * @param[in] fcxp BFA fcxp pointer
597 *
598 * @return pointer to the internal request buffer
599 */
600void *
601bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp)
602{
603 struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
604 void *rspbuf;
605
606 bfa_assert(fcxp->use_irspbuf == 1);
607
608 rspbuf = ((u8 *)mod->rsp_pld_list_kva) +
609 fcxp->fcxp_tag * mod->rsp_pld_sz;
610 return rspbuf;
611}
612
613/**
614 * Free the BFA FCXP
615 *
616 * @param[in] fcxp BFA fcxp pointer
617 *
618 * @return void
619 */
620void
621bfa_fcxp_free(struct bfa_fcxp_s *fcxp)
622{
623 struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
624
625 bfa_assert(fcxp != NULL);
626 bfa_trc(mod->bfa, fcxp->fcxp_tag);
627 bfa_fcxp_put(fcxp);
628}
629
630/**
631 * Send a FCXP request
632 *
633 * @param[in] fcxp BFA fcxp pointer
634 * @param[in] rport BFA rport pointer. Could be left NULL for WKA rports
635 * @param[in] vf_id virtual Fabric ID
636 * @param[in] lp_tag lport tag
637 * @param[in] cts use Continous sequence
638 * @param[in] cos fc Class of Service
639 * @param[in] reqlen request length, does not include FCHS length
640 * @param[in] fchs fc Header Pointer. The header content will be copied
641 * in by BFA.
642 *
643 * @param[in] cbfn call back function to be called on receiving
644 * the response
645 * @param[in] cbarg arg for cbfn
646 * @param[in] rsp_timeout
647 * response timeout
648 *
649 * @return bfa_status_t
650 */
651void
652bfa_fcxp_send(struct bfa_fcxp_s *fcxp, struct bfa_rport_s *rport,
653 u16 vf_id, u8 lp_tag, bfa_boolean_t cts, enum fc_cos cos,
654 u32 reqlen, struct fchs_s *fchs, bfa_cb_fcxp_send_t cbfn,
655 void *cbarg, u32 rsp_maxlen, u8 rsp_timeout)
656{
657 struct bfa_s *bfa = fcxp->fcxp_mod->bfa;
658 struct bfa_fcxp_req_info_s *reqi = &fcxp->req_info;
659 struct bfa_fcxp_rsp_info_s *rspi = &fcxp->rsp_info;
660 struct bfi_fcxp_send_req_s *send_req;
661
662 bfa_trc(bfa, fcxp->fcxp_tag);
663
664 /**
665 * setup request/response info
666 */
667 reqi->bfa_rport = rport;
668 reqi->vf_id = vf_id;
669 reqi->lp_tag = lp_tag;
670 reqi->class = cos;
671 rspi->rsp_timeout = rsp_timeout;
672 reqi->cts = cts;
673 reqi->fchs = *fchs;
674 reqi->req_tot_len = reqlen;
675 rspi->rsp_maxlen = rsp_maxlen;
676 fcxp->send_cbfn = cbfn ? cbfn : bfa_fcxp_null_comp;
677 fcxp->send_cbarg = cbarg;
678
679 /**
680 * If no room in CPE queue, wait for space in request queue
681 */
682 send_req = bfa_reqq_next(bfa, BFA_REQQ_FCXP);
683 if (!send_req) {
684 bfa_trc(bfa, fcxp->fcxp_tag);
685 fcxp->reqq_waiting = BFA_TRUE;
686 bfa_reqq_wait(bfa, BFA_REQQ_FCXP, &fcxp->reqq_wqe);
687 return;
688 }
689
690 bfa_fcxp_queue(fcxp, send_req);
691}
692
693/**
694 * Abort a BFA FCXP
695 *
696 * @param[in] fcxp BFA fcxp pointer
697 *
698 * @return void
699 */
700bfa_status_t
701bfa_fcxp_abort(struct bfa_fcxp_s *fcxp)
702{
703 bfa_assert(0);
704 return BFA_STATUS_OK;
705}
706
707void
708bfa_fcxp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
709 bfa_fcxp_alloc_cbfn_t alloc_cbfn, void *alloc_cbarg)
710{
711 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
712
713 bfa_assert(list_empty(&mod->fcxp_free_q));
714
715 wqe->alloc_cbfn = alloc_cbfn;
716 wqe->alloc_cbarg = alloc_cbarg;
717 list_add_tail(&wqe->qe, &mod->wait_q);
718}
719
720void
721bfa_fcxp_walloc_cancel(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe)
722{
723 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
724
725 bfa_assert(bfa_q_is_on_q(&mod->wait_q, wqe));
726 list_del(&wqe->qe);
727}
728
729void
730bfa_fcxp_discard(struct bfa_fcxp_s *fcxp)
731{
732 /**
733 * If waiting for room in request queue, cancel reqq wait
734 * and free fcxp.
735 */
736 if (fcxp->reqq_waiting) {
737 fcxp->reqq_waiting = BFA_FALSE;
738 bfa_reqq_wcancel(&fcxp->reqq_wqe);
739 bfa_fcxp_free(fcxp);
740 return;
741 }
742
743 fcxp->send_cbfn = bfa_fcxp_null_comp;
744}
745
746
747
748/**
749 * hal_fcxp_public BFA FCXP public functions
750 */
751
752void
753bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
754{
755 switch (msg->mhdr.msg_id) {
756 case BFI_FCXP_I2H_SEND_RSP:
757 hal_fcxp_send_comp(bfa, (struct bfi_fcxp_send_rsp_s *) msg);
758 break;
759
760 default:
761 bfa_trc(bfa, msg->mhdr.msg_id);
762 bfa_assert(0);
763 }
764}
765
766u32
767bfa_fcxp_get_maxrsp(struct bfa_s *bfa)
768{
769 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
770
771 return mod->rsp_pld_sz;
772}
773
774
diff --git a/drivers/scsi/bfa/bfa_fcxp_priv.h b/drivers/scsi/bfa/bfa_fcxp_priv.h
deleted file mode 100644
index 4cda49397da0..000000000000
--- a/drivers/scsi/bfa/bfa_fcxp_priv.h
+++ /dev/null
@@ -1,138 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_FCXP_PRIV_H__
19#define __BFA_FCXP_PRIV_H__
20
21#include <cs/bfa_sm.h>
22#include <protocol/fc.h>
23#include <bfa_svc.h>
24#include <bfi/bfi_fcxp.h>
25
26#define BFA_FCXP_MIN (1)
27#define BFA_FCXP_MAX_IBUF_SZ (2 * 1024 + 256)
28#define BFA_FCXP_MAX_LBUF_SZ (4 * 1024 + 256)
29
30struct bfa_fcxp_mod_s {
31 struct bfa_s *bfa; /* backpointer to BFA */
32 struct bfa_fcxp_s *fcxp_list; /* array of FCXPs */
33 u16 num_fcxps; /* max num FCXP requests */
34 struct list_head fcxp_free_q; /* free FCXPs */
35 struct list_head fcxp_active_q; /* active FCXPs */
36 void *req_pld_list_kva; /* list of FCXP req pld */
37 u64 req_pld_list_pa; /* list of FCXP req pld */
38 void *rsp_pld_list_kva; /* list of FCXP resp pld */
39 u64 rsp_pld_list_pa; /* list of FCXP resp pld */
40 struct list_head wait_q; /* wait queue for free fcxp */
41 u32 req_pld_sz;
42 u32 rsp_pld_sz;
43};
44
45#define BFA_FCXP_MOD(__bfa) (&(__bfa)->modules.fcxp_mod)
46#define BFA_FCXP_FROM_TAG(__mod, __tag) (&(__mod)->fcxp_list[__tag])
47
48typedef void (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp,
49 void *cb_arg, bfa_status_t req_status,
50 u32 rsp_len, u32 resid_len,
51 struct fchs_s *rsp_fchs);
52
53/**
54 * Information needed for a FCXP request
55 */
56struct bfa_fcxp_req_info_s {
57 struct bfa_rport_s *bfa_rport; /* Pointer to the bfa rport that was
58 *returned from bfa_rport_create().
59 *This could be left NULL for WKA or for
60 *FCXP interactions before the rport
61 *nexus is established
62 */
63 struct fchs_s fchs; /* request FC header structure */
64 u8 cts; /* continous sequence */
65 u8 class; /* FC class for the request/response */
66 u16 max_frmsz; /* max send frame size */
67 u16 vf_id; /* vsan tag if applicable */
68 u8 lp_tag; /* lport tag */
69 u32 req_tot_len; /* request payload total length */
70};
71
72struct bfa_fcxp_rsp_info_s {
73 struct fchs_s rsp_fchs; /* Response frame's FC header will
74 * be *sent back in this field */
75 u8 rsp_timeout; /* timeout in seconds, 0-no response
76 */
77 u8 rsvd2[3];
78 u32 rsp_maxlen; /* max response length expected */
79};
80
81struct bfa_fcxp_s {
82 struct list_head qe; /* fcxp queue element */
83 bfa_sm_t sm; /* state machine */
84 void *caller; /* driver or fcs */
85 struct bfa_fcxp_mod_s *fcxp_mod;
86 /* back pointer to fcxp mod */
87 u16 fcxp_tag; /* internal tag */
88 struct bfa_fcxp_req_info_s req_info;
89 /* request info */
90 struct bfa_fcxp_rsp_info_s rsp_info;
91 /* response info */
92 u8 use_ireqbuf; /* use internal req buf */
93 u8 use_irspbuf; /* use internal rsp buf */
94 u32 nreq_sgles; /* num request SGLEs */
95 u32 nrsp_sgles; /* num response SGLEs */
96 struct list_head req_sgpg_q; /* SG pages for request buf */
97 struct list_head req_sgpg_wqe; /* wait queue for req SG page */
98 struct list_head rsp_sgpg_q; /* SG pages for response buf */
99 struct list_head rsp_sgpg_wqe; /* wait queue for rsp SG page */
100
101 bfa_fcxp_get_sgaddr_t req_sga_cbfn;
102 /* SG elem addr user function */
103 bfa_fcxp_get_sglen_t req_sglen_cbfn;
104 /* SG elem len user function */
105 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
106 /* SG elem addr user function */
107 bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
108 /* SG elem len user function */
109 bfa_cb_fcxp_send_t send_cbfn; /* send completion callback */
110 void *send_cbarg; /* callback arg */
111 struct bfa_sge_s req_sge[BFA_FCXP_MAX_SGES];
112 /* req SG elems */
113 struct bfa_sge_s rsp_sge[BFA_FCXP_MAX_SGES];
114 /* rsp SG elems */
115 u8 rsp_status; /* comp: rsp status */
116 u32 rsp_len; /* comp: actual response len */
117 u32 residue_len; /* comp: residual rsp length */
118 struct fchs_s rsp_fchs; /* comp: response fchs */
119 struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
120 struct bfa_reqq_wait_s reqq_wqe;
121 bfa_boolean_t reqq_waiting;
122};
123
124#define BFA_FCXP_REQ_PLD(_fcxp) (bfa_fcxp_get_reqbuf(_fcxp))
125
126#define BFA_FCXP_RSP_FCHS(_fcxp) (&((_fcxp)->rsp_info.fchs))
127#define BFA_FCXP_RSP_PLD(_fcxp) (bfa_fcxp_get_rspbuf(_fcxp))
128
129#define BFA_FCXP_REQ_PLD_PA(_fcxp) \
130 ((_fcxp)->fcxp_mod->req_pld_list_pa + \
131 ((_fcxp)->fcxp_mod->req_pld_sz * (_fcxp)->fcxp_tag))
132
133#define BFA_FCXP_RSP_PLD_PA(_fcxp) \
134 ((_fcxp)->fcxp_mod->rsp_pld_list_pa + \
135 ((_fcxp)->fcxp_mod->rsp_pld_sz * (_fcxp)->fcxp_tag))
136
137void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
138#endif /* __BFA_FCXP_PRIV_H__ */
diff --git a/drivers/scsi/bfa/bfa_fwimg_priv.h b/drivers/scsi/bfa/bfa_fwimg_priv.h
deleted file mode 100644
index d33e19e54395..000000000000
--- a/drivers/scsi/bfa/bfa_fwimg_priv.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_FWIMG_PRIV_H__
19#define __BFA_FWIMG_PRIV_H__
20
21#define BFI_FLASH_CHUNK_SZ 256 /* Flash chunk size */
22#define BFI_FLASH_CHUNK_SZ_WORDS (BFI_FLASH_CHUNK_SZ/sizeof(u32))
23
24/**
25 * BFI FW image type
26 */
27enum {
28 BFI_IMAGE_CB_FC,
29 BFI_IMAGE_CT_FC,
30 BFI_IMAGE_CT_CNA,
31 BFI_IMAGE_MAX,
32};
33
34extern u32 *bfi_image_get_chunk(int type, uint32_t off);
35extern u32 bfi_image_get_size(int type);
36extern u32 bfi_image_ct_fc_size;
37extern u32 bfi_image_ct_cna_size;
38extern u32 bfi_image_cb_fc_size;
39extern u32 *bfi_image_ct_fc;
40extern u32 *bfi_image_ct_cna;
41extern u32 *bfi_image_cb_fc;
42
43
44#endif /* __BFA_FWIMG_PRIV_H__ */
diff --git a/drivers/scsi/bfa/bfa_hw_cb.c b/drivers/scsi/bfa/bfa_hw_cb.c
index edfd729445cf..977e681ec803 100644
--- a/drivers/scsi/bfa/bfa_hw_cb.c
+++ b/drivers/scsi/bfa/bfa_hw_cb.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,15 +15,16 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#include <bfa_priv.h> 18#include "bfad_drv.h"
19#include <bfi/bfi_cbreg.h> 19#include "bfa_modules.h"
20#include "bfi_cbreg.h"
20 21
21void 22void
22bfa_hwcb_reginit(struct bfa_s *bfa) 23bfa_hwcb_reginit(struct bfa_s *bfa)
23{ 24{
24 struct bfa_iocfc_regs_s *bfa_regs = &bfa->iocfc.bfa_regs; 25 struct bfa_iocfc_regs_s *bfa_regs = &bfa->iocfc.bfa_regs;
25 bfa_os_addr_t kva = bfa_ioc_bar0(&bfa->ioc); 26 void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
26 int i, q, fn = bfa_ioc_pcifn(&bfa->ioc); 27 int i, q, fn = bfa_ioc_pcifn(&bfa->ioc);
27 28
28 if (fn == 0) { 29 if (fn == 0) {
29 bfa_regs->intr_status = (kva + HOSTFN0_INT_STATUS); 30 bfa_regs->intr_status = (kva + HOSTFN0_INT_STATUS);
@@ -60,8 +61,8 @@ bfa_hwcb_reqq_ack(struct bfa_s *bfa, int reqq)
60static void 61static void
61bfa_hwcb_reqq_ack_msix(struct bfa_s *bfa, int reqq) 62bfa_hwcb_reqq_ack_msix(struct bfa_s *bfa, int reqq)
62{ 63{
63 bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, 64 writel(__HFN_INT_CPE_Q0 << CPE_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), reqq),
64 __HFN_INT_CPE_Q0 << CPE_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), reqq)); 65 bfa->iocfc.bfa_regs.intr_status);
65} 66}
66 67
67void 68void
@@ -72,8 +73,8 @@ bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq)
72static void 73static void
73bfa_hwcb_rspq_ack_msix(struct bfa_s *bfa, int rspq) 74bfa_hwcb_rspq_ack_msix(struct bfa_s *bfa, int rspq)
74{ 75{
75 bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, 76 writel(__HFN_INT_RME_Q0 << RME_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), rspq),
76 __HFN_INT_RME_Q0 << RME_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), rspq)); 77 bfa->iocfc.bfa_regs.intr_status);
77} 78}
78 79
79void 80void
@@ -102,7 +103,7 @@ bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *msix_vecs_bmap,
102 *num_vecs = __HFN_NUMINTS; 103 *num_vecs = __HFN_NUMINTS;
103} 104}
104 105
105/** 106/*
106 * No special setup required for crossbow -- vector assignments are implicit. 107 * No special setup required for crossbow -- vector assignments are implicit.
107 */ 108 */
108void 109void
@@ -110,7 +111,7 @@ bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs)
110{ 111{
111 int i; 112 int i;
112 113
113 bfa_assert((nvecs == 1) || (nvecs == __HFN_NUMINTS)); 114 WARN_ON((nvecs != 1) && (nvecs != __HFN_NUMINTS));
114 115
115 bfa->msix.nvecs = nvecs; 116 bfa->msix.nvecs = nvecs;
116 if (nvecs == 1) { 117 if (nvecs == 1) {
@@ -129,7 +130,7 @@ bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs)
129 bfa->msix.handler[i] = bfa_msix_lpu_err; 130 bfa->msix.handler[i] = bfa_msix_lpu_err;
130} 131}
131 132
132/** 133/*
133 * Crossbow -- dummy, interrupts are masked 134 * Crossbow -- dummy, interrupts are masked
134 */ 135 */
135void 136void
@@ -142,7 +143,7 @@ bfa_hwcb_msix_uninstall(struct bfa_s *bfa)
142{ 143{
143} 144}
144 145
145/** 146/*
146 * No special enable/disable -- vector assignments are implicit. 147 * No special enable/disable -- vector assignments are implicit.
147 */ 148 */
148void 149void
diff --git a/drivers/scsi/bfa/bfa_hw_ct.c b/drivers/scsi/bfa/bfa_hw_ct.c
index a357fb3066fd..21018d98a07b 100644
--- a/drivers/scsi/bfa/bfa_hw_ct.c
+++ b/drivers/scsi/bfa/bfa_hw_ct.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,9 +15,9 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#include <bfa_priv.h> 18#include "bfad_drv.h"
19#include <bfi/bfi_ctreg.h> 19#include "bfa_modules.h"
20#include <bfa_ioc.h> 20#include "bfi_ctreg.h"
21 21
22BFA_TRC_FILE(HAL, IOCFC_CT); 22BFA_TRC_FILE(HAL, IOCFC_CT);
23 23
@@ -32,15 +32,15 @@ static void
32bfa_hwct_msix_lpu_err_set(struct bfa_s *bfa, bfa_boolean_t msix, int vec) 32bfa_hwct_msix_lpu_err_set(struct bfa_s *bfa, bfa_boolean_t msix, int vec)
33{ 33{
34 int fn = bfa_ioc_pcifn(&bfa->ioc); 34 int fn = bfa_ioc_pcifn(&bfa->ioc);
35 bfa_os_addr_t kva = bfa_ioc_bar0(&bfa->ioc); 35 void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
36 36
37 if (msix) 37 if (msix)
38 bfa_reg_write(kva + __ct_msix_err_vec_reg[fn], vec); 38 writel(vec, kva + __ct_msix_err_vec_reg[fn]);
39 else 39 else
40 bfa_reg_write(kva + __ct_msix_err_vec_reg[fn], 0); 40 writel(0, kva + __ct_msix_err_vec_reg[fn]);
41} 41}
42 42
43/** 43/*
44 * Dummy interrupt handler for handling spurious interrupt during chip-reinit. 44 * Dummy interrupt handler for handling spurious interrupt during chip-reinit.
45 */ 45 */
46static void 46static void
@@ -52,8 +52,8 @@ void
52bfa_hwct_reginit(struct bfa_s *bfa) 52bfa_hwct_reginit(struct bfa_s *bfa)
53{ 53{
54 struct bfa_iocfc_regs_s *bfa_regs = &bfa->iocfc.bfa_regs; 54 struct bfa_iocfc_regs_s *bfa_regs = &bfa->iocfc.bfa_regs;
55 bfa_os_addr_t kva = bfa_ioc_bar0(&bfa->ioc); 55 void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
56 int i, q, fn = bfa_ioc_pcifn(&bfa->ioc); 56 int i, q, fn = bfa_ioc_pcifn(&bfa->ioc);
57 57
58 if (fn == 0) { 58 if (fn == 0) {
59 bfa_regs->intr_status = (kva + HOSTFN0_INT_STATUS); 59 bfa_regs->intr_status = (kva + HOSTFN0_INT_STATUS);
@@ -87,10 +87,10 @@ bfa_hwct_reginit(struct bfa_s *bfa)
87void 87void
88bfa_hwct_reqq_ack(struct bfa_s *bfa, int reqq) 88bfa_hwct_reqq_ack(struct bfa_s *bfa, int reqq)
89{ 89{
90 u32 r32; 90 u32 r32;
91 91
92 r32 = bfa_reg_read(bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq]); 92 r32 = readl(bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq]);
93 bfa_reg_write(bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq], r32); 93 writel(r32, bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq]);
94} 94}
95 95
96void 96void
@@ -98,8 +98,8 @@ bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq)
98{ 98{
99 u32 r32; 99 u32 r32;
100 100
101 r32 = bfa_reg_read(bfa->iocfc.bfa_regs.rme_q_ctrl[rspq]); 101 r32 = readl(bfa->iocfc.bfa_regs.rme_q_ctrl[rspq]);
102 bfa_reg_write(bfa->iocfc.bfa_regs.rme_q_ctrl[rspq], r32); 102 writel(r32, bfa->iocfc.bfa_regs.rme_q_ctrl[rspq]);
103} 103}
104 104
105void 105void
@@ -111,13 +111,13 @@ bfa_hwct_msix_getvecs(struct bfa_s *bfa, u32 *msix_vecs_bmap,
111 *num_vecs = BFA_MSIX_CT_MAX; 111 *num_vecs = BFA_MSIX_CT_MAX;
112} 112}
113 113
114/** 114/*
115 * Setup MSI-X vector for catapult 115 * Setup MSI-X vector for catapult
116 */ 116 */
117void 117void
118bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs) 118bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs)
119{ 119{
120 bfa_assert((nvecs == 1) || (nvecs == BFA_MSIX_CT_MAX)); 120 WARN_ON((nvecs != 1) && (nvecs != BFA_MSIX_CT_MAX));
121 bfa_trc(bfa, nvecs); 121 bfa_trc(bfa, nvecs);
122 122
123 bfa->msix.nvecs = nvecs; 123 bfa->msix.nvecs = nvecs;
@@ -144,7 +144,7 @@ bfa_hwct_msix_install(struct bfa_s *bfa)
144 for (; i <= BFA_MSIX_RME_Q3; i++) 144 for (; i <= BFA_MSIX_RME_Q3; i++)
145 bfa->msix.handler[i] = bfa_msix_rspq; 145 bfa->msix.handler[i] = bfa_msix_rspq;
146 146
147 bfa_assert(i == BFA_MSIX_LPU_ERR); 147 WARN_ON(i != BFA_MSIX_LPU_ERR);
148 bfa->msix.handler[BFA_MSIX_LPU_ERR] = bfa_msix_lpu_err; 148 bfa->msix.handler[BFA_MSIX_LPU_ERR] = bfa_msix_lpu_err;
149} 149}
150 150
@@ -157,7 +157,7 @@ bfa_hwct_msix_uninstall(struct bfa_s *bfa)
157 bfa->msix.handler[i] = bfa_hwct_msix_dummy; 157 bfa->msix.handler[i] = bfa_hwct_msix_dummy;
158} 158}
159 159
160/** 160/*
161 * Enable MSI-X vectors 161 * Enable MSI-X vectors
162 */ 162 */
163void 163void
diff --git a/drivers/scsi/bfa/bfa_intr.c b/drivers/scsi/bfa/bfa_intr.c
deleted file mode 100644
index 493678889b24..000000000000
--- a/drivers/scsi/bfa/bfa_intr.c
+++ /dev/null
@@ -1,270 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
18#include <bfi/bfi_ctreg.h>
19#include <bfa_port_priv.h>
20#include <bfa_intr_priv.h>
21#include <cs/bfa_debug.h>
22
23BFA_TRC_FILE(HAL, INTR);
24
25static void
26bfa_msix_errint(struct bfa_s *bfa, u32 intr)
27{
28 bfa_ioc_error_isr(&bfa->ioc);
29}
30
31static void
32bfa_msix_lpu(struct bfa_s *bfa)
33{
34 bfa_ioc_mbox_isr(&bfa->ioc);
35}
36
37static void
38bfa_reqq_resume(struct bfa_s *bfa, int qid)
39{
40 struct list_head *waitq, *qe, *qen;
41 struct bfa_reqq_wait_s *wqe;
42
43 waitq = bfa_reqq(bfa, qid);
44 list_for_each_safe(qe, qen, waitq) {
45 /**
46 * Callback only as long as there is room in request queue
47 */
48 if (bfa_reqq_full(bfa, qid))
49 break;
50
51 list_del(qe);
52 wqe = (struct bfa_reqq_wait_s *) qe;
53 wqe->qresume(wqe->cbarg);
54 }
55}
56
57void
58bfa_msix_all(struct bfa_s *bfa, int vec)
59{
60 bfa_intx(bfa);
61}
62
63/**
64 * hal_intr_api
65 */
66bfa_boolean_t
67bfa_intx(struct bfa_s *bfa)
68{
69 u32 intr, qintr;
70 int queue;
71
72 intr = bfa_reg_read(bfa->iocfc.bfa_regs.intr_status);
73 if (!intr)
74 return BFA_FALSE;
75
76 /**
77 * RME completion queue interrupt
78 */
79 qintr = intr & __HFN_INT_RME_MASK;
80 bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, qintr);
81
82 for (queue = 0; queue < BFI_IOC_MAX_CQS_ASIC; queue++) {
83 if (intr & (__HFN_INT_RME_Q0 << queue))
84 bfa_msix_rspq(bfa, queue & (BFI_IOC_MAX_CQS - 1));
85 }
86 intr &= ~qintr;
87 if (!intr)
88 return BFA_TRUE;
89
90 /**
91 * CPE completion queue interrupt
92 */
93 qintr = intr & __HFN_INT_CPE_MASK;
94 bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, qintr);
95
96 for (queue = 0; queue < BFI_IOC_MAX_CQS_ASIC; queue++) {
97 if (intr & (__HFN_INT_CPE_Q0 << queue))
98 bfa_msix_reqq(bfa, queue & (BFI_IOC_MAX_CQS - 1));
99 }
100 intr &= ~qintr;
101 if (!intr)
102 return BFA_TRUE;
103
104 bfa_msix_lpu_err(bfa, intr);
105
106 return BFA_TRUE;
107}
108
109void
110bfa_isr_enable(struct bfa_s *bfa)
111{
112 u32 intr_unmask;
113 int pci_func = bfa_ioc_pcifn(&bfa->ioc);
114
115 bfa_trc(bfa, pci_func);
116
117 bfa_msix_install(bfa);
118 intr_unmask = (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 |
119 __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS |
120 __HFN_INT_LL_HALT);
121
122 if (pci_func == 0)
123 intr_unmask |= (__HFN_INT_CPE_Q0 | __HFN_INT_CPE_Q1 |
124 __HFN_INT_CPE_Q2 | __HFN_INT_CPE_Q3 |
125 __HFN_INT_RME_Q0 | __HFN_INT_RME_Q1 |
126 __HFN_INT_RME_Q2 | __HFN_INT_RME_Q3 |
127 __HFN_INT_MBOX_LPU0);
128 else
129 intr_unmask |= (__HFN_INT_CPE_Q4 | __HFN_INT_CPE_Q5 |
130 __HFN_INT_CPE_Q6 | __HFN_INT_CPE_Q7 |
131 __HFN_INT_RME_Q4 | __HFN_INT_RME_Q5 |
132 __HFN_INT_RME_Q6 | __HFN_INT_RME_Q7 |
133 __HFN_INT_MBOX_LPU1);
134
135 bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, intr_unmask);
136 bfa_reg_write(bfa->iocfc.bfa_regs.intr_mask, ~intr_unmask);
137 bfa->iocfc.intr_mask = ~intr_unmask;
138 bfa_isr_mode_set(bfa, bfa->msix.nvecs != 0);
139}
140
141void
142bfa_isr_disable(struct bfa_s *bfa)
143{
144 bfa_isr_mode_set(bfa, BFA_FALSE);
145 bfa_reg_write(bfa->iocfc.bfa_regs.intr_mask, -1L);
146 bfa_msix_uninstall(bfa);
147}
148
149void
150bfa_msix_reqq(struct bfa_s *bfa, int qid)
151{
152 struct list_head *waitq;
153
154 qid &= (BFI_IOC_MAX_CQS - 1);
155
156 bfa->iocfc.hwif.hw_reqq_ack(bfa, qid);
157
158 /**
159 * Resume any pending requests in the corresponding reqq.
160 */
161 waitq = bfa_reqq(bfa, qid);
162 if (!list_empty(waitq))
163 bfa_reqq_resume(bfa, qid);
164}
165
166void
167bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m)
168{
169 bfa_trc(bfa, m->mhdr.msg_class);
170 bfa_trc(bfa, m->mhdr.msg_id);
171 bfa_trc(bfa, m->mhdr.mtag.i2htok);
172 bfa_assert(0);
173 bfa_trc_stop(bfa->trcmod);
174}
175
176void
177bfa_msix_rspq(struct bfa_s *bfa, int qid)
178{
179 struct bfi_msg_s *m;
180 u32 pi, ci;
181 struct list_head *waitq;
182
183 bfa_trc_fp(bfa, qid);
184
185 qid &= (BFI_IOC_MAX_CQS - 1);
186
187 bfa->iocfc.hwif.hw_rspq_ack(bfa, qid);
188
189 ci = bfa_rspq_ci(bfa, qid);
190 pi = bfa_rspq_pi(bfa, qid);
191
192 bfa_trc_fp(bfa, ci);
193 bfa_trc_fp(bfa, pi);
194
195 if (bfa->rme_process) {
196 while (ci != pi) {
197 m = bfa_rspq_elem(bfa, qid, ci);
198 bfa_assert_fp(m->mhdr.msg_class < BFI_MC_MAX);
199
200 bfa_isrs[m->mhdr.msg_class] (bfa, m);
201
202 CQ_INCR(ci, bfa->iocfc.cfg.drvcfg.num_rspq_elems);
203 }
204 }
205
206 /**
207 * update CI
208 */
209 bfa_rspq_ci(bfa, qid) = pi;
210 bfa_reg_write(bfa->iocfc.bfa_regs.rme_q_ci[qid], pi);
211 bfa_os_mmiowb();
212
213 /**
214 * Resume any pending requests in the corresponding reqq.
215 */
216 waitq = bfa_reqq(bfa, qid);
217 if (!list_empty(waitq))
218 bfa_reqq_resume(bfa, qid);
219}
220
221void
222bfa_msix_lpu_err(struct bfa_s *bfa, int vec)
223{
224 u32 intr, curr_value;
225
226 intr = bfa_reg_read(bfa->iocfc.bfa_regs.intr_status);
227
228 if (intr & (__HFN_INT_MBOX_LPU0 | __HFN_INT_MBOX_LPU1))
229 bfa_msix_lpu(bfa);
230
231 intr &= (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 |
232 __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS | __HFN_INT_LL_HALT);
233
234 if (intr) {
235 if (intr & __HFN_INT_LL_HALT) {
236 /**
237 * If LL_HALT bit is set then FW Init Halt LL Port
238 * Register needs to be cleared as well so Interrupt
239 * Status Register will be cleared.
240 */
241 curr_value = bfa_reg_read(bfa->ioc.ioc_regs.ll_halt);
242 curr_value &= ~__FW_INIT_HALT_P;
243 bfa_reg_write(bfa->ioc.ioc_regs.ll_halt, curr_value);
244 }
245
246 if (intr & __HFN_INT_ERR_PSS) {
247 /**
248 * ERR_PSS bit needs to be cleared as well in case
249 * interrups are shared so driver's interrupt handler is
250 * still called eventhough it is already masked out.
251 */
252 curr_value = bfa_reg_read(
253 bfa->ioc.ioc_regs.pss_err_status_reg);
254 curr_value &= __PSS_ERR_STATUS_SET;
255 bfa_reg_write(bfa->ioc.ioc_regs.pss_err_status_reg,
256 curr_value);
257 }
258
259 bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, intr);
260 bfa_msix_errint(bfa, intr);
261 }
262}
263
264void
265bfa_isr_bind(enum bfi_mclass mc, bfa_isr_func_t isr_func)
266{
267 bfa_isrs[mc] = isr_func;
268}
269
270
diff --git a/drivers/scsi/bfa/bfa_intr_priv.h b/drivers/scsi/bfa/bfa_intr_priv.h
deleted file mode 100644
index 5fc301cf4d1b..000000000000
--- a/drivers/scsi/bfa/bfa_intr_priv.h
+++ /dev/null
@@ -1,117 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_INTR_PRIV_H__
19#define __BFA_INTR_PRIV_H__
20
21/**
22 * Message handler
23 */
24typedef void (*bfa_isr_func_t) (struct bfa_s *bfa, struct bfi_msg_s *m);
25void bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m);
26void bfa_isr_bind(enum bfi_mclass mc, bfa_isr_func_t isr_func);
27
28
29#define bfa_reqq_pi(__bfa, __reqq) ((__bfa)->iocfc.req_cq_pi[__reqq])
30#define bfa_reqq_ci(__bfa, __reqq) \
31 (*(u32 *)((__bfa)->iocfc.req_cq_shadow_ci[__reqq].kva))
32
33#define bfa_reqq_full(__bfa, __reqq) \
34 (((bfa_reqq_pi(__bfa, __reqq) + 1) & \
35 ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1)) == \
36 bfa_reqq_ci(__bfa, __reqq))
37
38#define bfa_reqq_next(__bfa, __reqq) \
39 (bfa_reqq_full(__bfa, __reqq) ? NULL : \
40 ((void *)((struct bfi_msg_s *)((__bfa)->iocfc.req_cq_ba[__reqq].kva) \
41 + bfa_reqq_pi((__bfa), (__reqq)))))
42
43#define bfa_reqq_produce(__bfa, __reqq) do { \
44 (__bfa)->iocfc.req_cq_pi[__reqq]++; \
45 (__bfa)->iocfc.req_cq_pi[__reqq] &= \
46 ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1); \
47 bfa_reg_write((__bfa)->iocfc.bfa_regs.cpe_q_pi[__reqq], \
48 (__bfa)->iocfc.req_cq_pi[__reqq]); \
49 bfa_os_mmiowb(); \
50} while (0)
51
52#define bfa_rspq_pi(__bfa, __rspq) \
53 (*(u32 *)((__bfa)->iocfc.rsp_cq_shadow_pi[__rspq].kva))
54
55#define bfa_rspq_ci(__bfa, __rspq) ((__bfa)->iocfc.rsp_cq_ci[__rspq])
56#define bfa_rspq_elem(__bfa, __rspq, __ci) \
57 (&((struct bfi_msg_s *)((__bfa)->iocfc.rsp_cq_ba[__rspq].kva))[__ci])
58
59#define CQ_INCR(__index, __size) do { \
60 (__index)++; \
61 (__index) &= ((__size) - 1); \
62} while (0)
63
64/**
65 * Queue element to wait for room in request queue. FIFO order is
66 * maintained when fullfilling requests.
67 */
68struct bfa_reqq_wait_s {
69 struct list_head qe;
70 void (*qresume) (void *cbarg);
71 void *cbarg;
72};
73
74/**
75 * Circular queue usage assignments
76 */
77enum {
78 BFA_REQQ_IOC = 0, /* all low-priority IOC msgs */
79 BFA_REQQ_FCXP = 0, /* all FCXP messages */
80 BFA_REQQ_LPS = 0, /* all lport service msgs */
81 BFA_REQQ_PORT = 0, /* all port messages */
82 BFA_REQQ_FLASH = 0, /* for flash module */
83 BFA_REQQ_DIAG = 0, /* for diag module */
84 BFA_REQQ_RPORT = 0, /* all port messages */
85 BFA_REQQ_SBOOT = 0, /* all san boot messages */
86 BFA_REQQ_QOS_LO = 1, /* all low priority IO */
87 BFA_REQQ_QOS_MD = 2, /* all medium priority IO */
88 BFA_REQQ_QOS_HI = 3, /* all high priority IO */
89};
90
91static inline void
92bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
93 void *cbarg)
94{
95 wqe->qresume = qresume;
96 wqe->cbarg = cbarg;
97}
98
99#define bfa_reqq(__bfa, __reqq) (&(__bfa)->reqq_waitq[__reqq])
100
101/**
102 * static inline void
103 * bfa_reqq_wait(struct bfa_s *bfa, int reqq, struct bfa_reqq_wait_s *wqe)
104 */
105#define bfa_reqq_wait(__bfa, __reqq, __wqe) do { \
106 \
107 struct list_head *waitq = bfa_reqq(__bfa, __reqq); \
108 \
109 bfa_assert(((__reqq) < BFI_IOC_MAX_CQS)); \
110 bfa_assert((__wqe)->qresume && (__wqe)->cbarg); \
111 \
112 list_add_tail(&(__wqe)->qe, waitq); \
113} while (0)
114
115#define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe)
116
117#endif /* __BFA_INTR_PRIV_H__ */
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index 8e78f20110a5..6c7e0339dda4 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,140 +15,256 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#include <bfa.h> 18#include "bfad_drv.h"
19#include <bfa_ioc.h> 19#include "bfa_ioc.h"
20#include <bfa_fwimg_priv.h> 20#include "bfi_ctreg.h"
21#include <cna/bfa_cna_trcmod.h> 21#include "bfa_defs.h"
22#include <cs/bfa_debug.h> 22#include "bfa_defs_svc.h"
23#include <bfi/bfi_ioc.h>
24#include <bfi/bfi_ctreg.h>
25#include <aen/bfa_aen_ioc.h>
26#include <aen/bfa_aen.h>
27#include <log/bfa_log_hal.h>
28#include <defs/bfa_defs_pci.h>
29 23
30BFA_TRC_FILE(CNA, IOC); 24BFA_TRC_FILE(CNA, IOC);
31 25
32/** 26/*
33 * IOC local definitions 27 * IOC local definitions
34 */ 28 */
35#define BFA_IOC_TOV 2000 /* msecs */ 29#define BFA_IOC_TOV 3000 /* msecs */
36#define BFA_IOC_HWSEM_TOV 500 /* msecs */ 30#define BFA_IOC_HWSEM_TOV 500 /* msecs */
37#define BFA_IOC_HB_TOV 500 /* msecs */ 31#define BFA_IOC_HB_TOV 500 /* msecs */
38#define BFA_IOC_HWINIT_MAX 2 32#define BFA_IOC_HWINIT_MAX 5
39#define BFA_IOC_FWIMG_MINSZ (16 * 1024) 33#define BFA_IOC_TOV_RECOVER BFA_IOC_HB_TOV
40#define BFA_IOC_TOV_RECOVER BFA_IOC_HB_TOV
41 34
42#define bfa_ioc_timer_start(__ioc) \ 35#define bfa_ioc_timer_start(__ioc) \
43 bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->ioc_timer, \ 36 bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->ioc_timer, \
44 bfa_ioc_timeout, (__ioc), BFA_IOC_TOV) 37 bfa_ioc_timeout, (__ioc), BFA_IOC_TOV)
45#define bfa_ioc_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->ioc_timer) 38#define bfa_ioc_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->ioc_timer)
46 39
47#define BFA_DBG_FWTRC_ENTS (BFI_IOC_TRC_ENTS) 40#define bfa_hb_timer_start(__ioc) \
48#define BFA_DBG_FWTRC_LEN \ 41 bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->hb_timer, \
49 (BFA_DBG_FWTRC_ENTS * sizeof(struct bfa_trc_s) + \ 42 bfa_ioc_hb_check, (__ioc), BFA_IOC_HB_TOV)
50 (sizeof(struct bfa_trc_mod_s) - \ 43#define bfa_hb_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->hb_timer)
51 BFA_TRC_MAX * sizeof(struct bfa_trc_s))) 44
52#define BFA_DBG_FWTRC_OFF(_fn) (BFI_IOC_TRC_OFF + BFA_DBG_FWTRC_LEN * (_fn)) 45#define BFA_DBG_FWTRC_OFF(_fn) (BFI_IOC_TRC_OFF + BFA_DBG_FWTRC_LEN * (_fn))
53 46
54/** 47/*
55 * Asic specific macros : see bfa_hw_cb.c and bfa_hw_ct.c for details. 48 * Asic specific macros : see bfa_hw_cb.c and bfa_hw_ct.c for details.
56 */ 49 */
57 50
58#define bfa_ioc_firmware_lock(__ioc) \ 51#define bfa_ioc_firmware_lock(__ioc) \
59 ((__ioc)->ioc_hwif->ioc_firmware_lock(__ioc)) 52 ((__ioc)->ioc_hwif->ioc_firmware_lock(__ioc))
60#define bfa_ioc_firmware_unlock(__ioc) \ 53#define bfa_ioc_firmware_unlock(__ioc) \
61 ((__ioc)->ioc_hwif->ioc_firmware_unlock(__ioc)) 54 ((__ioc)->ioc_hwif->ioc_firmware_unlock(__ioc))
62#define bfa_ioc_reg_init(__ioc) ((__ioc)->ioc_hwif->ioc_reg_init(__ioc)) 55#define bfa_ioc_reg_init(__ioc) ((__ioc)->ioc_hwif->ioc_reg_init(__ioc))
63#define bfa_ioc_map_port(__ioc) ((__ioc)->ioc_hwif->ioc_map_port(__ioc)) 56#define bfa_ioc_map_port(__ioc) ((__ioc)->ioc_hwif->ioc_map_port(__ioc))
64#define bfa_ioc_notify_hbfail(__ioc) \ 57#define bfa_ioc_notify_fail(__ioc) \
65 ((__ioc)->ioc_hwif->ioc_notify_hbfail(__ioc)) 58 ((__ioc)->ioc_hwif->ioc_notify_fail(__ioc))
66#define bfa_ioc_is_optrom(__ioc) \ 59#define bfa_ioc_sync_start(__ioc) \
67 (bfi_image_get_size(BFA_IOC_FWIMG_TYPE(__ioc)) < BFA_IOC_FWIMG_MINSZ) 60 ((__ioc)->ioc_hwif->ioc_sync_start(__ioc))
68 61#define bfa_ioc_sync_join(__ioc) \
69bfa_boolean_t bfa_auto_recover = BFA_TRUE; 62 ((__ioc)->ioc_hwif->ioc_sync_join(__ioc))
63#define bfa_ioc_sync_leave(__ioc) \
64 ((__ioc)->ioc_hwif->ioc_sync_leave(__ioc))
65#define bfa_ioc_sync_ack(__ioc) \
66 ((__ioc)->ioc_hwif->ioc_sync_ack(__ioc))
67#define bfa_ioc_sync_complete(__ioc) \
68 ((__ioc)->ioc_hwif->ioc_sync_complete(__ioc))
69
70#define bfa_ioc_mbox_cmd_pending(__ioc) \
71 (!list_empty(&((__ioc)->mbox_mod.cmd_q)) || \
72 readl((__ioc)->ioc_regs.hfn_mbox_cmd))
73
74bfa_boolean_t bfa_auto_recover = BFA_TRUE;
70 75
71/* 76/*
72 * forward declarations 77 * forward declarations
73 */ 78 */
74static void bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc); 79static void bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc);
75static void bfa_ioc_hw_sem_get_cancel(struct bfa_ioc_s *ioc); 80static void bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force);
76static void bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force); 81static void bfa_ioc_timeout(void *ioc);
77static void bfa_ioc_timeout(void *ioc); 82static void bfa_ioc_send_enable(struct bfa_ioc_s *ioc);
78static void bfa_ioc_send_enable(struct bfa_ioc_s *ioc); 83static void bfa_ioc_send_disable(struct bfa_ioc_s *ioc);
79static void bfa_ioc_send_disable(struct bfa_ioc_s *ioc); 84static void bfa_ioc_send_getattr(struct bfa_ioc_s *ioc);
80static void bfa_ioc_send_getattr(struct bfa_ioc_s *ioc); 85static void bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc);
81static void bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc); 86static void bfa_ioc_mbox_poll(struct bfa_ioc_s *ioc);
82static void bfa_ioc_hb_stop(struct bfa_ioc_s *ioc); 87static void bfa_ioc_mbox_hbfail(struct bfa_ioc_s *ioc);
83static void bfa_ioc_reset(struct bfa_ioc_s *ioc, bfa_boolean_t force); 88static void bfa_ioc_recover(struct bfa_ioc_s *ioc);
84static void bfa_ioc_mbox_poll(struct bfa_ioc_s *ioc); 89static void bfa_ioc_check_attr_wwns(struct bfa_ioc_s *ioc);
85static void bfa_ioc_mbox_hbfail(struct bfa_ioc_s *ioc); 90static void bfa_ioc_disable_comp(struct bfa_ioc_s *ioc);
86static void bfa_ioc_recover(struct bfa_ioc_s *ioc); 91static void bfa_ioc_lpu_stop(struct bfa_ioc_s *ioc);
87static void bfa_ioc_check_attr_wwns(struct bfa_ioc_s *ioc); 92static void bfa_ioc_debug_save_ftrc(struct bfa_ioc_s *ioc);
88static void bfa_ioc_disable_comp(struct bfa_ioc_s *ioc); 93static void bfa_ioc_fail_notify(struct bfa_ioc_s *ioc);
89static void bfa_ioc_lpu_stop(struct bfa_ioc_s *ioc); 94static void bfa_ioc_pf_fwmismatch(struct bfa_ioc_s *ioc);
90 95
91/** 96
92 * bfa_ioc_sm 97/*
93 */ 98 * IOC state machine definitions/declarations
94
95/**
96 * IOC state machine events
97 */ 99 */
98enum ioc_event { 100enum ioc_event {
99 IOC_E_ENABLE = 1, /* IOC enable request */ 101 IOC_E_RESET = 1, /* IOC reset request */
100 IOC_E_DISABLE = 2, /* IOC disable request */ 102 IOC_E_ENABLE = 2, /* IOC enable request */
101 IOC_E_TIMEOUT = 3, /* f/w response timeout */ 103 IOC_E_DISABLE = 3, /* IOC disable request */
102 IOC_E_FWREADY = 4, /* f/w initialization done */ 104 IOC_E_DETACH = 4, /* driver detach cleanup */
103 IOC_E_FWRSP_GETATTR = 5, /* IOC get attribute response */ 105 IOC_E_ENABLED = 5, /* f/w enabled */
104 IOC_E_FWRSP_ENABLE = 6, /* enable f/w response */ 106 IOC_E_FWRSP_GETATTR = 6, /* IOC get attribute response */
105 IOC_E_FWRSP_DISABLE = 7, /* disable f/w response */ 107 IOC_E_DISABLED = 7, /* f/w disabled */
106 IOC_E_HBFAIL = 8, /* heartbeat failure */ 108 IOC_E_INITFAILED = 8, /* failure notice by iocpf sm */
107 IOC_E_HWERROR = 9, /* hardware error interrupt */ 109 IOC_E_PFFAILED = 9, /* failure notice by iocpf sm */
108 IOC_E_SEMLOCKED = 10, /* h/w semaphore is locked */ 110 IOC_E_HBFAIL = 10, /* heartbeat failure */
109 IOC_E_DETACH = 11, /* driver detach cleanup */ 111 IOC_E_HWERROR = 11, /* hardware error interrupt */
112 IOC_E_TIMEOUT = 12, /* timeout */
110}; 113};
111 114
115bfa_fsm_state_decl(bfa_ioc, uninit, struct bfa_ioc_s, enum ioc_event);
112bfa_fsm_state_decl(bfa_ioc, reset, struct bfa_ioc_s, enum ioc_event); 116bfa_fsm_state_decl(bfa_ioc, reset, struct bfa_ioc_s, enum ioc_event);
113bfa_fsm_state_decl(bfa_ioc, fwcheck, struct bfa_ioc_s, enum ioc_event);
114bfa_fsm_state_decl(bfa_ioc, mismatch, struct bfa_ioc_s, enum ioc_event);
115bfa_fsm_state_decl(bfa_ioc, semwait, struct bfa_ioc_s, enum ioc_event);
116bfa_fsm_state_decl(bfa_ioc, hwinit, struct bfa_ioc_s, enum ioc_event);
117bfa_fsm_state_decl(bfa_ioc, enabling, struct bfa_ioc_s, enum ioc_event); 117bfa_fsm_state_decl(bfa_ioc, enabling, struct bfa_ioc_s, enum ioc_event);
118bfa_fsm_state_decl(bfa_ioc, getattr, struct bfa_ioc_s, enum ioc_event); 118bfa_fsm_state_decl(bfa_ioc, getattr, struct bfa_ioc_s, enum ioc_event);
119bfa_fsm_state_decl(bfa_ioc, op, struct bfa_ioc_s, enum ioc_event); 119bfa_fsm_state_decl(bfa_ioc, op, struct bfa_ioc_s, enum ioc_event);
120bfa_fsm_state_decl(bfa_ioc, initfail, struct bfa_ioc_s, enum ioc_event); 120bfa_fsm_state_decl(bfa_ioc, fail_retry, struct bfa_ioc_s, enum ioc_event);
121bfa_fsm_state_decl(bfa_ioc, hbfail, struct bfa_ioc_s, enum ioc_event); 121bfa_fsm_state_decl(bfa_ioc, fail, struct bfa_ioc_s, enum ioc_event);
122bfa_fsm_state_decl(bfa_ioc, disabling, struct bfa_ioc_s, enum ioc_event); 122bfa_fsm_state_decl(bfa_ioc, disabling, struct bfa_ioc_s, enum ioc_event);
123bfa_fsm_state_decl(bfa_ioc, disabled, struct bfa_ioc_s, enum ioc_event); 123bfa_fsm_state_decl(bfa_ioc, disabled, struct bfa_ioc_s, enum ioc_event);
124 124
125static struct bfa_sm_table_s ioc_sm_table[] = { 125static struct bfa_sm_table_s ioc_sm_table[] = {
126 {BFA_SM(bfa_ioc_sm_uninit), BFA_IOC_UNINIT},
126 {BFA_SM(bfa_ioc_sm_reset), BFA_IOC_RESET}, 127 {BFA_SM(bfa_ioc_sm_reset), BFA_IOC_RESET},
127 {BFA_SM(bfa_ioc_sm_fwcheck), BFA_IOC_FWMISMATCH}, 128 {BFA_SM(bfa_ioc_sm_enabling), BFA_IOC_ENABLING},
128 {BFA_SM(bfa_ioc_sm_mismatch), BFA_IOC_FWMISMATCH},
129 {BFA_SM(bfa_ioc_sm_semwait), BFA_IOC_SEMWAIT},
130 {BFA_SM(bfa_ioc_sm_hwinit), BFA_IOC_HWINIT},
131 {BFA_SM(bfa_ioc_sm_enabling), BFA_IOC_HWINIT},
132 {BFA_SM(bfa_ioc_sm_getattr), BFA_IOC_GETATTR}, 129 {BFA_SM(bfa_ioc_sm_getattr), BFA_IOC_GETATTR},
133 {BFA_SM(bfa_ioc_sm_op), BFA_IOC_OPERATIONAL}, 130 {BFA_SM(bfa_ioc_sm_op), BFA_IOC_OPERATIONAL},
134 {BFA_SM(bfa_ioc_sm_initfail), BFA_IOC_INITFAIL}, 131 {BFA_SM(bfa_ioc_sm_fail_retry), BFA_IOC_INITFAIL},
135 {BFA_SM(bfa_ioc_sm_hbfail), BFA_IOC_HBFAIL}, 132 {BFA_SM(bfa_ioc_sm_fail), BFA_IOC_FAIL},
136 {BFA_SM(bfa_ioc_sm_disabling), BFA_IOC_DISABLING}, 133 {BFA_SM(bfa_ioc_sm_disabling), BFA_IOC_DISABLING},
137 {BFA_SM(bfa_ioc_sm_disabled), BFA_IOC_DISABLED}, 134 {BFA_SM(bfa_ioc_sm_disabled), BFA_IOC_DISABLED},
138}; 135};
139 136
140/** 137/*
138 * IOCPF state machine definitions/declarations
139 */
140
141#define bfa_iocpf_timer_start(__ioc) \
142 bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->ioc_timer, \
143 bfa_iocpf_timeout, (__ioc), BFA_IOC_TOV)
144#define bfa_iocpf_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->ioc_timer)
145
146#define bfa_iocpf_recovery_timer_start(__ioc) \
147 bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->ioc_timer, \
148 bfa_iocpf_timeout, (__ioc), BFA_IOC_TOV_RECOVER)
149
150#define bfa_sem_timer_start(__ioc) \
151 bfa_timer_begin((__ioc)->timer_mod, &(__ioc)->sem_timer, \
152 bfa_iocpf_sem_timeout, (__ioc), BFA_IOC_HWSEM_TOV)
153#define bfa_sem_timer_stop(__ioc) bfa_timer_stop(&(__ioc)->sem_timer)
154
155/*
156 * Forward declareations for iocpf state machine
157 */
158static void bfa_iocpf_timeout(void *ioc_arg);
159static void bfa_iocpf_sem_timeout(void *ioc_arg);
160
161/*
162 * IOCPF state machine events
163 */
164enum iocpf_event {
165 IOCPF_E_ENABLE = 1, /* IOCPF enable request */
166 IOCPF_E_DISABLE = 2, /* IOCPF disable request */
167 IOCPF_E_STOP = 3, /* stop on driver detach */
168 IOCPF_E_FWREADY = 4, /* f/w initialization done */
169 IOCPF_E_FWRSP_ENABLE = 5, /* enable f/w response */
170 IOCPF_E_FWRSP_DISABLE = 6, /* disable f/w response */
171 IOCPF_E_FAIL = 7, /* failure notice by ioc sm */
172 IOCPF_E_INITFAIL = 8, /* init fail notice by ioc sm */
173 IOCPF_E_GETATTRFAIL = 9, /* init fail notice by ioc sm */
174 IOCPF_E_SEMLOCKED = 10, /* h/w semaphore is locked */
175 IOCPF_E_TIMEOUT = 11, /* f/w response timeout */
176};
177
178/*
179 * IOCPF states
180 */
181enum bfa_iocpf_state {
182 BFA_IOCPF_RESET = 1, /* IOC is in reset state */
183 BFA_IOCPF_SEMWAIT = 2, /* Waiting for IOC h/w semaphore */
184 BFA_IOCPF_HWINIT = 3, /* IOC h/w is being initialized */
185 BFA_IOCPF_READY = 4, /* IOCPF is initialized */
186 BFA_IOCPF_INITFAIL = 5, /* IOCPF failed */
187 BFA_IOCPF_FAIL = 6, /* IOCPF failed */
188 BFA_IOCPF_DISABLING = 7, /* IOCPF is being disabled */
189 BFA_IOCPF_DISABLED = 8, /* IOCPF is disabled */
190 BFA_IOCPF_FWMISMATCH = 9, /* IOC f/w different from drivers */
191};
192
193bfa_fsm_state_decl(bfa_iocpf, reset, struct bfa_iocpf_s, enum iocpf_event);
194bfa_fsm_state_decl(bfa_iocpf, fwcheck, struct bfa_iocpf_s, enum iocpf_event);
195bfa_fsm_state_decl(bfa_iocpf, mismatch, struct bfa_iocpf_s, enum iocpf_event);
196bfa_fsm_state_decl(bfa_iocpf, semwait, struct bfa_iocpf_s, enum iocpf_event);
197bfa_fsm_state_decl(bfa_iocpf, hwinit, struct bfa_iocpf_s, enum iocpf_event);
198bfa_fsm_state_decl(bfa_iocpf, enabling, struct bfa_iocpf_s, enum iocpf_event);
199bfa_fsm_state_decl(bfa_iocpf, ready, struct bfa_iocpf_s, enum iocpf_event);
200bfa_fsm_state_decl(bfa_iocpf, initfail_sync, struct bfa_iocpf_s,
201 enum iocpf_event);
202bfa_fsm_state_decl(bfa_iocpf, initfail, struct bfa_iocpf_s, enum iocpf_event);
203bfa_fsm_state_decl(bfa_iocpf, fail_sync, struct bfa_iocpf_s, enum iocpf_event);
204bfa_fsm_state_decl(bfa_iocpf, fail, struct bfa_iocpf_s, enum iocpf_event);
205bfa_fsm_state_decl(bfa_iocpf, disabling, struct bfa_iocpf_s, enum iocpf_event);
206bfa_fsm_state_decl(bfa_iocpf, disabling_sync, struct bfa_iocpf_s,
207 enum iocpf_event);
208bfa_fsm_state_decl(bfa_iocpf, disabled, struct bfa_iocpf_s, enum iocpf_event);
209
210static struct bfa_sm_table_s iocpf_sm_table[] = {
211 {BFA_SM(bfa_iocpf_sm_reset), BFA_IOCPF_RESET},
212 {BFA_SM(bfa_iocpf_sm_fwcheck), BFA_IOCPF_FWMISMATCH},
213 {BFA_SM(bfa_iocpf_sm_mismatch), BFA_IOCPF_FWMISMATCH},
214 {BFA_SM(bfa_iocpf_sm_semwait), BFA_IOCPF_SEMWAIT},
215 {BFA_SM(bfa_iocpf_sm_hwinit), BFA_IOCPF_HWINIT},
216 {BFA_SM(bfa_iocpf_sm_enabling), BFA_IOCPF_HWINIT},
217 {BFA_SM(bfa_iocpf_sm_ready), BFA_IOCPF_READY},
218 {BFA_SM(bfa_iocpf_sm_initfail_sync), BFA_IOCPF_INITFAIL},
219 {BFA_SM(bfa_iocpf_sm_initfail), BFA_IOCPF_INITFAIL},
220 {BFA_SM(bfa_iocpf_sm_fail_sync), BFA_IOCPF_FAIL},
221 {BFA_SM(bfa_iocpf_sm_fail), BFA_IOCPF_FAIL},
222 {BFA_SM(bfa_iocpf_sm_disabling), BFA_IOCPF_DISABLING},
223 {BFA_SM(bfa_iocpf_sm_disabling_sync), BFA_IOCPF_DISABLING},
224 {BFA_SM(bfa_iocpf_sm_disabled), BFA_IOCPF_DISABLED},
225};
226
227/*
228 * IOC State Machine
229 */
230
231/*
232 * Beginning state. IOC uninit state.
233 */
234
235static void
236bfa_ioc_sm_uninit_entry(struct bfa_ioc_s *ioc)
237{
238}
239
240/*
241 * IOC is in uninit state.
242 */
243static void
244bfa_ioc_sm_uninit(struct bfa_ioc_s *ioc, enum ioc_event event)
245{
246 bfa_trc(ioc, event);
247
248 switch (event) {
249 case IOC_E_RESET:
250 bfa_fsm_set_state(ioc, bfa_ioc_sm_reset);
251 break;
252
253 default:
254 bfa_sm_fault(ioc, event);
255 }
256}
257/*
141 * Reset entry actions -- initialize state machine 258 * Reset entry actions -- initialize state machine
142 */ 259 */
143static void 260static void
144bfa_ioc_sm_reset_entry(struct bfa_ioc_s *ioc) 261bfa_ioc_sm_reset_entry(struct bfa_ioc_s *ioc)
145{ 262{
146 ioc->retry_count = 0; 263 bfa_fsm_set_state(&ioc->iocpf, bfa_iocpf_sm_reset);
147 ioc->auto_recover = bfa_auto_recover;
148} 264}
149 265
150/** 266/*
151 * Beginning state. IOC is in reset state. 267 * IOC is in reset state.
152 */ 268 */
153static void 269static void
154bfa_ioc_sm_reset(struct bfa_ioc_s *ioc, enum ioc_event event) 270bfa_ioc_sm_reset(struct bfa_ioc_s *ioc, enum ioc_event event)
@@ -157,7 +273,7 @@ bfa_ioc_sm_reset(struct bfa_ioc_s *ioc, enum ioc_event event)
157 273
158 switch (event) { 274 switch (event) {
159 case IOC_E_ENABLE: 275 case IOC_E_ENABLE:
160 bfa_fsm_set_state(ioc, bfa_ioc_sm_fwcheck); 276 bfa_fsm_set_state(ioc, bfa_ioc_sm_enabling);
161 break; 277 break;
162 278
163 case IOC_E_DISABLE: 279 case IOC_E_DISABLE:
@@ -165,6 +281,7 @@ bfa_ioc_sm_reset(struct bfa_ioc_s *ioc, enum ioc_event event)
165 break; 281 break;
166 282
167 case IOC_E_DETACH: 283 case IOC_E_DETACH:
284 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
168 break; 285 break;
169 286
170 default: 287 default:
@@ -172,46 +289,46 @@ bfa_ioc_sm_reset(struct bfa_ioc_s *ioc, enum ioc_event event)
172 } 289 }
173} 290}
174 291
175/** 292
176 * Semaphore should be acquired for version check.
177 */
178static void 293static void
179bfa_ioc_sm_fwcheck_entry(struct bfa_ioc_s *ioc) 294bfa_ioc_sm_enabling_entry(struct bfa_ioc_s *ioc)
180{ 295{
181 bfa_ioc_hw_sem_get(ioc); 296 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_ENABLE);
182} 297}
183 298
184/** 299/*
185 * Awaiting h/w semaphore to continue with version check. 300 * Host IOC function is being enabled, awaiting response from firmware.
301 * Semaphore is acquired.
186 */ 302 */
187static void 303static void
188bfa_ioc_sm_fwcheck(struct bfa_ioc_s *ioc, enum ioc_event event) 304bfa_ioc_sm_enabling(struct bfa_ioc_s *ioc, enum ioc_event event)
189{ 305{
190 bfa_trc(ioc, event); 306 bfa_trc(ioc, event);
191 307
192 switch (event) { 308 switch (event) {
193 case IOC_E_SEMLOCKED: 309 case IOC_E_ENABLED:
194 if (bfa_ioc_firmware_lock(ioc)) { 310 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr);
195 ioc->retry_count = 0; 311 break;
196 bfa_fsm_set_state(ioc, bfa_ioc_sm_hwinit); 312
197 } else { 313 case IOC_E_PFFAILED:
198 bfa_ioc_hw_sem_release(ioc); 314 /* !!! fall through !!! */
199 bfa_fsm_set_state(ioc, bfa_ioc_sm_mismatch); 315 case IOC_E_HWERROR:
200 } 316 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
317 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry);
318 if (event != IOC_E_PFFAILED)
319 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_INITFAIL);
201 break; 320 break;
202 321
203 case IOC_E_DISABLE: 322 case IOC_E_DISABLE:
204 bfa_ioc_disable_comp(ioc); 323 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
205 /* 324 break;
206 * fall through
207 */
208 325
209 case IOC_E_DETACH: 326 case IOC_E_DETACH:
210 bfa_ioc_hw_sem_get_cancel(ioc); 327 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
211 bfa_fsm_set_state(ioc, bfa_ioc_sm_reset); 328 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
212 break; 329 break;
213 330
214 case IOC_E_FWREADY: 331 case IOC_E_ENABLE:
215 break; 332 break;
216 333
217 default: 334 default:
@@ -219,48 +336,47 @@ bfa_ioc_sm_fwcheck(struct bfa_ioc_s *ioc, enum ioc_event event)
219 } 336 }
220} 337}
221 338
222/** 339
223 * Notify enable completion callback and generate mismatch AEN.
224 */
225static void 340static void
226bfa_ioc_sm_mismatch_entry(struct bfa_ioc_s *ioc) 341bfa_ioc_sm_getattr_entry(struct bfa_ioc_s *ioc)
227{ 342{
228 /**
229 * Provide enable completion callback and AEN notification only once.
230 */
231 if (ioc->retry_count == 0) {
232 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
233 bfa_ioc_aen_post(ioc, BFA_IOC_AEN_FWMISMATCH);
234 }
235 ioc->retry_count++;
236 bfa_ioc_timer_start(ioc); 343 bfa_ioc_timer_start(ioc);
344 bfa_ioc_send_getattr(ioc);
237} 345}
238 346
239/** 347/*
240 * Awaiting firmware version match. 348 * IOC configuration in progress. Timer is active.
241 */ 349 */
242static void 350static void
243bfa_ioc_sm_mismatch(struct bfa_ioc_s *ioc, enum ioc_event event) 351bfa_ioc_sm_getattr(struct bfa_ioc_s *ioc, enum ioc_event event)
244{ 352{
245 bfa_trc(ioc, event); 353 bfa_trc(ioc, event);
246 354
247 switch (event) { 355 switch (event) {
356 case IOC_E_FWRSP_GETATTR:
357 bfa_ioc_timer_stop(ioc);
358 bfa_ioc_check_attr_wwns(ioc);
359 bfa_fsm_set_state(ioc, bfa_ioc_sm_op);
360 break;
361
362 break;
363 case IOC_E_PFFAILED:
364 case IOC_E_HWERROR:
365 bfa_ioc_timer_stop(ioc);
366 /* !!! fall through !!! */
248 case IOC_E_TIMEOUT: 367 case IOC_E_TIMEOUT:
249 bfa_fsm_set_state(ioc, bfa_ioc_sm_fwcheck); 368 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
369 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry);
370 if (event != IOC_E_PFFAILED)
371 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_GETATTRFAIL);
250 break; 372 break;
251 373
252 case IOC_E_DISABLE: 374 case IOC_E_DISABLE:
253 bfa_ioc_disable_comp(ioc);
254 /*
255 * fall through
256 */
257
258 case IOC_E_DETACH:
259 bfa_ioc_timer_stop(ioc); 375 bfa_ioc_timer_stop(ioc);
260 bfa_fsm_set_state(ioc, bfa_ioc_sm_reset); 376 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
261 break; 377 break;
262 378
263 case IOC_E_FWREADY: 379 case IOC_E_ENABLE:
264 break; 380 break;
265 381
266 default: 382 default:
@@ -268,32 +384,45 @@ bfa_ioc_sm_mismatch(struct bfa_ioc_s *ioc, enum ioc_event event)
268 } 384 }
269} 385}
270 386
271/** 387
272 * Request for semaphore.
273 */
274static void 388static void
275bfa_ioc_sm_semwait_entry(struct bfa_ioc_s *ioc) 389bfa_ioc_sm_op_entry(struct bfa_ioc_s *ioc)
276{ 390{
277 bfa_ioc_hw_sem_get(ioc); 391 struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
392
393 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_OK);
394 bfa_ioc_hb_monitor(ioc);
395 BFA_LOG(KERN_INFO, bfad, bfa_log_level, "IOC enabled\n");
278} 396}
279 397
280/**
281 * Awaiting semaphore for h/w initialzation.
282 */
283static void 398static void
284bfa_ioc_sm_semwait(struct bfa_ioc_s *ioc, enum ioc_event event) 399bfa_ioc_sm_op(struct bfa_ioc_s *ioc, enum ioc_event event)
285{ 400{
286 bfa_trc(ioc, event); 401 bfa_trc(ioc, event);
287 402
288 switch (event) { 403 switch (event) {
289 case IOC_E_SEMLOCKED: 404 case IOC_E_ENABLE:
290 ioc->retry_count = 0;
291 bfa_fsm_set_state(ioc, bfa_ioc_sm_hwinit);
292 break; 405 break;
293 406
294 case IOC_E_DISABLE: 407 case IOC_E_DISABLE:
295 bfa_ioc_hw_sem_get_cancel(ioc); 408 bfa_hb_timer_stop(ioc);
296 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled); 409 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
410 break;
411
412 case IOC_E_PFFAILED:
413 case IOC_E_HWERROR:
414 bfa_hb_timer_stop(ioc);
415 /* !!! fall through !!! */
416 case IOC_E_HBFAIL:
417 bfa_ioc_fail_notify(ioc);
418
419 if (ioc->iocpf.auto_recover)
420 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail_retry);
421 else
422 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail);
423
424 if (event != IOC_E_PFFAILED)
425 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FAIL);
297 break; 426 break;
298 427
299 default: 428 default:
@@ -303,49 +432,66 @@ bfa_ioc_sm_semwait(struct bfa_ioc_s *ioc, enum ioc_event event)
303 432
304 433
305static void 434static void
306bfa_ioc_sm_hwinit_entry(struct bfa_ioc_s *ioc) 435bfa_ioc_sm_disabling_entry(struct bfa_ioc_s *ioc)
307{ 436{
308 bfa_ioc_timer_start(ioc); 437 struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
309 bfa_ioc_reset(ioc, BFA_FALSE); 438 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_DISABLE);
439 BFA_LOG(KERN_INFO, bfad, bfa_log_level, "IOC disabled\n");
310} 440}
311 441
312/** 442/*
313 * Hardware is being initialized. Interrupts are enabled. 443 * IOC is being disabled
314 * Holding hardware semaphore lock.
315 */ 444 */
316static void 445static void
317bfa_ioc_sm_hwinit(struct bfa_ioc_s *ioc, enum ioc_event event) 446bfa_ioc_sm_disabling(struct bfa_ioc_s *ioc, enum ioc_event event)
318{ 447{
319 bfa_trc(ioc, event); 448 bfa_trc(ioc, event);
320 449
321 switch (event) { 450 switch (event) {
322 case IOC_E_FWREADY: 451 case IOC_E_DISABLED:
323 bfa_ioc_timer_stop(ioc); 452 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled);
324 bfa_fsm_set_state(ioc, bfa_ioc_sm_enabling);
325 break; 453 break;
326 454
327 case IOC_E_HWERROR: 455 case IOC_E_HWERROR:
328 bfa_ioc_timer_stop(ioc);
329 /* 456 /*
330 * fall through 457 * No state change. Will move to disabled state
458 * after iocpf sm completes failure processing and
459 * moves to disabled state.
331 */ 460 */
461 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FAIL);
462 break;
332 463
333 case IOC_E_TIMEOUT: 464 default:
334 ioc->retry_count++; 465 bfa_sm_fault(ioc, event);
335 if (ioc->retry_count < BFA_IOC_HWINIT_MAX) { 466 }
336 bfa_ioc_timer_start(ioc); 467}
337 bfa_ioc_reset(ioc, BFA_TRUE); 468
338 break; 469/*
339 } 470 * IOC disable completion entry.
471 */
472static void
473bfa_ioc_sm_disabled_entry(struct bfa_ioc_s *ioc)
474{
475 bfa_ioc_disable_comp(ioc);
476}
340 477
341 bfa_ioc_hw_sem_release(ioc); 478static void
342 bfa_fsm_set_state(ioc, bfa_ioc_sm_initfail); 479bfa_ioc_sm_disabled(struct bfa_ioc_s *ioc, enum ioc_event event)
480{
481 bfa_trc(ioc, event);
482
483 switch (event) {
484 case IOC_E_ENABLE:
485 bfa_fsm_set_state(ioc, bfa_ioc_sm_enabling);
343 break; 486 break;
344 487
345 case IOC_E_DISABLE: 488 case IOC_E_DISABLE:
346 bfa_ioc_hw_sem_release(ioc); 489 ioc->cbfn->disable_cbfn(ioc->bfa);
347 bfa_ioc_timer_stop(ioc); 490 break;
348 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled); 491
492 case IOC_E_DETACH:
493 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
494 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
349 break; 495 break;
350 496
351 default: 497 default:
@@ -355,55 +501,48 @@ bfa_ioc_sm_hwinit(struct bfa_ioc_s *ioc, enum ioc_event event)
355 501
356 502
357static void 503static void
358bfa_ioc_sm_enabling_entry(struct bfa_ioc_s *ioc) 504bfa_ioc_sm_fail_retry_entry(struct bfa_ioc_s *ioc)
359{ 505{
360 bfa_ioc_timer_start(ioc); 506 bfa_trc(ioc, 0);
361 bfa_ioc_send_enable(ioc);
362} 507}
363 508
364/** 509/*
365 * Host IOC function is being enabled, awaiting response from firmware. 510 * Hardware initialization retry.
366 * Semaphore is acquired.
367 */ 511 */
368static void 512static void
369bfa_ioc_sm_enabling(struct bfa_ioc_s *ioc, enum ioc_event event) 513bfa_ioc_sm_fail_retry(struct bfa_ioc_s *ioc, enum ioc_event event)
370{ 514{
371 bfa_trc(ioc, event); 515 bfa_trc(ioc, event);
372 516
373 switch (event) { 517 switch (event) {
374 case IOC_E_FWRSP_ENABLE: 518 case IOC_E_ENABLED:
375 bfa_ioc_timer_stop(ioc);
376 bfa_ioc_hw_sem_release(ioc);
377 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr); 519 bfa_fsm_set_state(ioc, bfa_ioc_sm_getattr);
378 break; 520 break;
379 521
522 case IOC_E_PFFAILED:
380 case IOC_E_HWERROR: 523 case IOC_E_HWERROR:
381 bfa_ioc_timer_stop(ioc);
382 /* 524 /*
383 * fall through 525 * Initialization retry failed.
384 */ 526 */
527 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
528 if (event != IOC_E_PFFAILED)
529 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_INITFAIL);
530 break;
385 531
386 case IOC_E_TIMEOUT: 532 case IOC_E_INITFAILED:
387 ioc->retry_count++; 533 bfa_fsm_set_state(ioc, bfa_ioc_sm_fail);
388 if (ioc->retry_count < BFA_IOC_HWINIT_MAX) { 534 break;
389 bfa_reg_write(ioc->ioc_regs.ioc_fwstate,
390 BFI_IOC_UNINIT);
391 bfa_fsm_set_state(ioc, bfa_ioc_sm_hwinit);
392 break;
393 }
394 535
395 bfa_ioc_hw_sem_release(ioc); 536 case IOC_E_ENABLE:
396 bfa_fsm_set_state(ioc, bfa_ioc_sm_initfail);
397 break; 537 break;
398 538
399 case IOC_E_DISABLE: 539 case IOC_E_DISABLE:
400 bfa_ioc_timer_stop(ioc); 540 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
401 bfa_ioc_hw_sem_release(ioc);
402 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled);
403 break; 541 break;
404 542
405 case IOC_E_FWREADY: 543 case IOC_E_DETACH:
406 bfa_ioc_send_enable(ioc); 544 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
545 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
407 break; 546 break;
408 547
409 default: 548 default:
@@ -413,40 +552,74 @@ bfa_ioc_sm_enabling(struct bfa_ioc_s *ioc, enum ioc_event event)
413 552
414 553
415static void 554static void
416bfa_ioc_sm_getattr_entry(struct bfa_ioc_s *ioc) 555bfa_ioc_sm_fail_entry(struct bfa_ioc_s *ioc)
417{ 556{
418 bfa_ioc_timer_start(ioc); 557 bfa_trc(ioc, 0);
419 bfa_ioc_send_getattr(ioc);
420} 558}
421 559
422/** 560/*
423 * IOC configuration in progress. Timer is active. 561 * IOC failure.
424 */ 562 */
425static void 563static void
426bfa_ioc_sm_getattr(struct bfa_ioc_s *ioc, enum ioc_event event) 564bfa_ioc_sm_fail(struct bfa_ioc_s *ioc, enum ioc_event event)
427{ 565{
428 bfa_trc(ioc, event); 566 bfa_trc(ioc, event);
429 567
430 switch (event) { 568 switch (event) {
431 case IOC_E_FWRSP_GETATTR: 569
432 bfa_ioc_timer_stop(ioc); 570 case IOC_E_ENABLE:
433 bfa_ioc_check_attr_wwns(ioc); 571 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
434 bfa_fsm_set_state(ioc, bfa_ioc_sm_op); 572 break;
573
574 case IOC_E_DISABLE:
575 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);
576 break;
577
578 case IOC_E_DETACH:
579 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
580 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_STOP);
435 break; 581 break;
436 582
437 case IOC_E_HWERROR: 583 case IOC_E_HWERROR:
438 bfa_ioc_timer_stop(ioc);
439 /* 584 /*
440 * fall through 585 * HB failure notification, ignore.
441 */ 586 */
587 break;
588 default:
589 bfa_sm_fault(ioc, event);
590 }
591}
442 592
443 case IOC_E_TIMEOUT: 593/*
444 bfa_fsm_set_state(ioc, bfa_ioc_sm_initfail); 594 * IOCPF State Machine
595 */
596
597/*
598 * Reset entry actions -- initialize state machine
599 */
600static void
601bfa_iocpf_sm_reset_entry(struct bfa_iocpf_s *iocpf)
602{
603 iocpf->retry_count = 0;
604 iocpf->auto_recover = bfa_auto_recover;
605}
606
607/*
608 * Beginning state. IOC is in reset state.
609 */
610static void
611bfa_iocpf_sm_reset(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
612{
613 struct bfa_ioc_s *ioc = iocpf->ioc;
614
615 bfa_trc(ioc, event);
616
617 switch (event) {
618 case IOCPF_E_ENABLE:
619 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fwcheck);
445 break; 620 break;
446 621
447 case IOC_E_DISABLE: 622 case IOCPF_E_STOP:
448 bfa_ioc_timer_stop(ioc);
449 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled);
450 break; 623 break;
451 624
452 default: 625 default:
@@ -454,42 +627,241 @@ bfa_ioc_sm_getattr(struct bfa_ioc_s *ioc, enum ioc_event event)
454 } 627 }
455} 628}
456 629
630/*
631 * Semaphore should be acquired for version check.
632 */
633static void
634bfa_iocpf_sm_fwcheck_entry(struct bfa_iocpf_s *iocpf)
635{
636 bfa_ioc_hw_sem_get(iocpf->ioc);
637}
457 638
639/*
640 * Awaiting h/w semaphore to continue with version check.
641 */
458static void 642static void
459bfa_ioc_sm_op_entry(struct bfa_ioc_s *ioc) 643bfa_iocpf_sm_fwcheck(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
460{ 644{
461 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_OK); 645 struct bfa_ioc_s *ioc = iocpf->ioc;
462 bfa_ioc_hb_monitor(ioc); 646
463 bfa_ioc_aen_post(ioc, BFA_IOC_AEN_ENABLE); 647 bfa_trc(ioc, event);
648
649 switch (event) {
650 case IOCPF_E_SEMLOCKED:
651 if (bfa_ioc_firmware_lock(ioc)) {
652 if (bfa_ioc_sync_start(ioc)) {
653 iocpf->retry_count = 0;
654 bfa_ioc_sync_join(ioc);
655 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
656 } else {
657 bfa_ioc_firmware_unlock(ioc);
658 writel(1, ioc->ioc_regs.ioc_sem_reg);
659 bfa_sem_timer_start(ioc);
660 }
661 } else {
662 writel(1, ioc->ioc_regs.ioc_sem_reg);
663 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_mismatch);
664 }
665 break;
666
667 case IOCPF_E_DISABLE:
668 bfa_sem_timer_stop(ioc);
669 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
670 bfa_fsm_send_event(ioc, IOC_E_DISABLED);
671 break;
672
673 case IOCPF_E_STOP:
674 bfa_sem_timer_stop(ioc);
675 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
676 break;
677
678 default:
679 bfa_sm_fault(ioc, event);
680 }
464} 681}
465 682
683/*
684 * Notify enable completion callback.
685 */
466static void 686static void
467bfa_ioc_sm_op(struct bfa_ioc_s *ioc, enum ioc_event event) 687bfa_iocpf_sm_mismatch_entry(struct bfa_iocpf_s *iocpf)
688{
689 /*
690 * Call only the first time sm enters fwmismatch state.
691 */
692 if (iocpf->retry_count == 0)
693 bfa_ioc_pf_fwmismatch(iocpf->ioc);
694
695 iocpf->retry_count++;
696 bfa_iocpf_timer_start(iocpf->ioc);
697}
698
699/*
700 * Awaiting firmware version match.
701 */
702static void
703bfa_iocpf_sm_mismatch(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
468{ 704{
705 struct bfa_ioc_s *ioc = iocpf->ioc;
706
469 bfa_trc(ioc, event); 707 bfa_trc(ioc, event);
470 708
471 switch (event) { 709 switch (event) {
472 case IOC_E_ENABLE: 710 case IOCPF_E_TIMEOUT:
711 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fwcheck);
473 break; 712 break;
474 713
475 case IOC_E_DISABLE: 714 case IOCPF_E_DISABLE:
476 bfa_ioc_hb_stop(ioc); 715 bfa_iocpf_timer_stop(ioc);
477 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabling); 716 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
717 bfa_fsm_send_event(ioc, IOC_E_DISABLED);
478 break; 718 break;
479 719
480 case IOC_E_HWERROR: 720 case IOCPF_E_STOP:
481 case IOC_E_FWREADY: 721 bfa_iocpf_timer_stop(ioc);
482 /** 722 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
483 * Hard error or IOC recovery by other function. 723 break;
484 * Treat it same as heartbeat failure. 724
725 default:
726 bfa_sm_fault(ioc, event);
727 }
728}
729
730/*
731 * Request for semaphore.
732 */
733static void
734bfa_iocpf_sm_semwait_entry(struct bfa_iocpf_s *iocpf)
735{
736 bfa_ioc_hw_sem_get(iocpf->ioc);
737}
738
739/*
740 * Awaiting semaphore for h/w initialzation.
741 */
742static void
743bfa_iocpf_sm_semwait(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
744{
745 struct bfa_ioc_s *ioc = iocpf->ioc;
746
747 bfa_trc(ioc, event);
748
749 switch (event) {
750 case IOCPF_E_SEMLOCKED:
751 if (bfa_ioc_sync_complete(ioc)) {
752 bfa_ioc_sync_join(ioc);
753 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
754 } else {
755 writel(1, ioc->ioc_regs.ioc_sem_reg);
756 bfa_sem_timer_start(ioc);
757 }
758 break;
759
760 case IOCPF_E_DISABLE:
761 bfa_sem_timer_stop(ioc);
762 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
763 break;
764
765 default:
766 bfa_sm_fault(ioc, event);
767 }
768}
769
770static void
771bfa_iocpf_sm_hwinit_entry(struct bfa_iocpf_s *iocpf)
772{
773 bfa_iocpf_timer_start(iocpf->ioc);
774 bfa_ioc_hwinit(iocpf->ioc, BFA_FALSE);
775}
776
777/*
778 * Hardware is being initialized. Interrupts are enabled.
779 * Holding hardware semaphore lock.
780 */
781static void
782bfa_iocpf_sm_hwinit(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
783{
784 struct bfa_ioc_s *ioc = iocpf->ioc;
785
786 bfa_trc(ioc, event);
787
788 switch (event) {
789 case IOCPF_E_FWREADY:
790 bfa_iocpf_timer_stop(ioc);
791 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_enabling);
792 break;
793
794 case IOCPF_E_INITFAIL:
795 bfa_iocpf_timer_stop(ioc);
796 /*
797 * !!! fall through !!!
485 */ 798 */
486 bfa_ioc_hb_stop(ioc); 799
800 case IOCPF_E_TIMEOUT:
801 writel(1, ioc->ioc_regs.ioc_sem_reg);
802 if (event == IOCPF_E_TIMEOUT)
803 bfa_fsm_send_event(ioc, IOC_E_PFFAILED);
804 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
805 break;
806
807 case IOCPF_E_DISABLE:
808 bfa_iocpf_timer_stop(ioc);
809 bfa_ioc_sync_leave(ioc);
810 writel(1, ioc->ioc_regs.ioc_sem_reg);
811 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
812 break;
813
814 default:
815 bfa_sm_fault(ioc, event);
816 }
817}
818
819static void
820bfa_iocpf_sm_enabling_entry(struct bfa_iocpf_s *iocpf)
821{
822 bfa_iocpf_timer_start(iocpf->ioc);
823 bfa_ioc_send_enable(iocpf->ioc);
824}
825
826/*
827 * Host IOC function is being enabled, awaiting response from firmware.
828 * Semaphore is acquired.
829 */
830static void
831bfa_iocpf_sm_enabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
832{
833 struct bfa_ioc_s *ioc = iocpf->ioc;
834
835 bfa_trc(ioc, event);
836
837 switch (event) {
838 case IOCPF_E_FWRSP_ENABLE:
839 bfa_iocpf_timer_stop(ioc);
840 writel(1, ioc->ioc_regs.ioc_sem_reg);
841 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_ready);
842 break;
843
844 case IOCPF_E_INITFAIL:
845 bfa_iocpf_timer_stop(ioc);
487 /* 846 /*
488 * !!! fall through !!! 847 * !!! fall through !!!
489 */ 848 */
490 849
491 case IOC_E_HBFAIL: 850 case IOCPF_E_TIMEOUT:
492 bfa_fsm_set_state(ioc, bfa_ioc_sm_hbfail); 851 writel(1, ioc->ioc_regs.ioc_sem_reg);
852 if (event == IOCPF_E_TIMEOUT)
853 bfa_fsm_send_event(ioc, IOC_E_PFFAILED);
854 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
855 break;
856
857 case IOCPF_E_DISABLE:
858 bfa_iocpf_timer_stop(ioc);
859 writel(1, ioc->ioc_regs.ioc_sem_reg);
860 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling);
861 break;
862
863 case IOCPF_E_FWREADY:
864 bfa_ioc_send_enable(ioc);
493 break; 865 break;
494 866
495 default: 867 default:
@@ -497,38 +869,83 @@ bfa_ioc_sm_op(struct bfa_ioc_s *ioc, enum ioc_event event)
497 } 869 }
498} 870}
499 871
872static void
873bfa_iocpf_sm_ready_entry(struct bfa_iocpf_s *iocpf)
874{
875 bfa_fsm_send_event(iocpf->ioc, IOC_E_ENABLED);
876}
500 877
501static void 878static void
502bfa_ioc_sm_disabling_entry(struct bfa_ioc_s *ioc) 879bfa_iocpf_sm_ready(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
503{ 880{
504 bfa_ioc_aen_post(ioc, BFA_IOC_AEN_DISABLE); 881 struct bfa_ioc_s *ioc = iocpf->ioc;
505 bfa_ioc_timer_start(ioc); 882
506 bfa_ioc_send_disable(ioc); 883 bfa_trc(ioc, event);
884
885 switch (event) {
886 case IOCPF_E_DISABLE:
887 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling);
888 break;
889
890 case IOCPF_E_GETATTRFAIL:
891 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
892 break;
893
894 case IOCPF_E_FAIL:
895 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail_sync);
896 break;
897
898 case IOCPF_E_FWREADY:
899 if (bfa_ioc_is_operational(ioc)) {
900 bfa_fsm_send_event(ioc, IOC_E_PFFAILED);
901 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail_sync);
902 } else {
903 bfa_fsm_send_event(ioc, IOC_E_PFFAILED);
904 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
905 }
906 break;
907
908 default:
909 bfa_sm_fault(ioc, event);
910 }
507} 911}
508 912
509/** 913static void
914bfa_iocpf_sm_disabling_entry(struct bfa_iocpf_s *iocpf)
915{
916 bfa_iocpf_timer_start(iocpf->ioc);
917 bfa_ioc_send_disable(iocpf->ioc);
918}
919
920/*
510 * IOC is being disabled 921 * IOC is being disabled
511 */ 922 */
512static void 923static void
513bfa_ioc_sm_disabling(struct bfa_ioc_s *ioc, enum ioc_event event) 924bfa_iocpf_sm_disabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
514{ 925{
926 struct bfa_ioc_s *ioc = iocpf->ioc;
927
515 bfa_trc(ioc, event); 928 bfa_trc(ioc, event);
516 929
517 switch (event) { 930 switch (event) {
518 case IOC_E_FWRSP_DISABLE: 931 case IOCPF_E_FWRSP_DISABLE:
519 bfa_ioc_timer_stop(ioc); 932 case IOCPF_E_FWREADY:
520 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled); 933 bfa_iocpf_timer_stop(ioc);
934 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
521 break; 935 break;
522 936
523 case IOC_E_HWERROR: 937 case IOCPF_E_FAIL:
524 bfa_ioc_timer_stop(ioc); 938 bfa_iocpf_timer_stop(ioc);
525 /* 939 /*
526 * !!! fall through !!! 940 * !!! fall through !!!
527 */ 941 */
528 942
529 case IOC_E_TIMEOUT: 943 case IOCPF_E_TIMEOUT:
530 bfa_reg_write(ioc->ioc_regs.ioc_fwstate, BFI_IOC_FAIL); 944 writel(BFI_IOC_FAIL, ioc->ioc_regs.ioc_fwstate);
531 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled); 945 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
946 break;
947
948 case IOCPF_E_FWRSP_ENABLE:
532 break; 949 break;
533 950
534 default: 951 default:
@@ -536,35 +953,62 @@ bfa_ioc_sm_disabling(struct bfa_ioc_s *ioc, enum ioc_event event)
536 } 953 }
537} 954}
538 955
539/**
540 * IOC disable completion entry.
541 */
542static void 956static void
543bfa_ioc_sm_disabled_entry(struct bfa_ioc_s *ioc) 957bfa_iocpf_sm_disabling_sync_entry(struct bfa_iocpf_s *iocpf)
544{ 958{
545 bfa_ioc_disable_comp(ioc); 959 bfa_ioc_hw_sem_get(iocpf->ioc);
546} 960}
547 961
962/*
963 * IOC hb ack request is being removed.
964 */
548static void 965static void
549bfa_ioc_sm_disabled(struct bfa_ioc_s *ioc, enum ioc_event event) 966bfa_iocpf_sm_disabling_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
550{ 967{
968 struct bfa_ioc_s *ioc = iocpf->ioc;
969
551 bfa_trc(ioc, event); 970 bfa_trc(ioc, event);
552 971
553 switch (event) { 972 switch (event) {
554 case IOC_E_ENABLE: 973 case IOCPF_E_SEMLOCKED:
555 bfa_fsm_set_state(ioc, bfa_ioc_sm_semwait); 974 bfa_ioc_sync_leave(ioc);
975 writel(1, ioc->ioc_regs.ioc_sem_reg);
976 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
556 break; 977 break;
557 978
558 case IOC_E_DISABLE: 979 case IOCPF_E_FAIL:
559 ioc->cbfn->disable_cbfn(ioc->bfa);
560 break; 980 break;
561 981
562 case IOC_E_FWREADY: 982 default:
983 bfa_sm_fault(ioc, event);
984 }
985}
986
987/*
988 * IOC disable completion entry.
989 */
990static void
991bfa_iocpf_sm_disabled_entry(struct bfa_iocpf_s *iocpf)
992{
993 bfa_fsm_send_event(iocpf->ioc, IOC_E_DISABLED);
994}
995
996static void
997bfa_iocpf_sm_disabled(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
998{
999 struct bfa_ioc_s *ioc = iocpf->ioc;
1000
1001 bfa_trc(ioc, event);
1002
1003 switch (event) {
1004 case IOCPF_E_ENABLE:
1005 iocpf->retry_count = 0;
1006 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait);
563 break; 1007 break;
564 1008
565 case IOC_E_DETACH: 1009 case IOCPF_E_STOP:
566 bfa_ioc_firmware_unlock(ioc); 1010 bfa_ioc_firmware_unlock(ioc);
567 bfa_fsm_set_state(ioc, bfa_ioc_sm_reset); 1011 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
568 break; 1012 break;
569 1013
570 default: 1014 default:
@@ -572,36 +1016,53 @@ bfa_ioc_sm_disabled(struct bfa_ioc_s *ioc, enum ioc_event event)
572 } 1016 }
573} 1017}
574 1018
575
576static void 1019static void
577bfa_ioc_sm_initfail_entry(struct bfa_ioc_s *ioc) 1020bfa_iocpf_sm_initfail_sync_entry(struct bfa_iocpf_s *iocpf)
578{ 1021{
579 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); 1022 bfa_ioc_hw_sem_get(iocpf->ioc);
580 bfa_ioc_timer_start(ioc);
581} 1023}
582 1024
583/** 1025/*
584 * Hardware initialization failed. 1026 * Hardware initialization failed.
585 */ 1027 */
586static void 1028static void
587bfa_ioc_sm_initfail(struct bfa_ioc_s *ioc, enum ioc_event event) 1029bfa_iocpf_sm_initfail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
588{ 1030{
1031 struct bfa_ioc_s *ioc = iocpf->ioc;
1032
589 bfa_trc(ioc, event); 1033 bfa_trc(ioc, event);
590 1034
591 switch (event) { 1035 switch (event) {
592 case IOC_E_DISABLE: 1036 case IOCPF_E_SEMLOCKED:
593 bfa_ioc_timer_stop(ioc); 1037 bfa_ioc_notify_fail(ioc);
594 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled); 1038 bfa_ioc_sync_ack(ioc);
1039 iocpf->retry_count++;
1040 if (iocpf->retry_count >= BFA_IOC_HWINIT_MAX) {
1041 bfa_ioc_sync_leave(ioc);
1042 writel(1, ioc->ioc_regs.ioc_sem_reg);
1043 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail);
1044 } else {
1045 if (bfa_ioc_sync_complete(ioc))
1046 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
1047 else {
1048 writel(1, ioc->ioc_regs.ioc_sem_reg);
1049 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait);
1050 }
1051 }
595 break; 1052 break;
596 1053
597 case IOC_E_DETACH: 1054 case IOCPF_E_DISABLE:
598 bfa_ioc_timer_stop(ioc); 1055 bfa_sem_timer_stop(ioc);
1056 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
1057 break;
1058
1059 case IOCPF_E_STOP:
1060 bfa_sem_timer_stop(ioc);
599 bfa_ioc_firmware_unlock(ioc); 1061 bfa_ioc_firmware_unlock(ioc);
600 bfa_fsm_set_state(ioc, bfa_ioc_sm_reset); 1062 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
601 break; 1063 break;
602 1064
603 case IOC_E_TIMEOUT: 1065 case IOCPF_E_FAIL:
604 bfa_fsm_set_state(ioc, bfa_ioc_sm_semwait);
605 break; 1066 break;
606 1067
607 default: 1068 default:
@@ -609,82 +1070,110 @@ bfa_ioc_sm_initfail(struct bfa_ioc_s *ioc, enum ioc_event event)
609 } 1070 }
610} 1071}
611 1072
1073static void
1074bfa_iocpf_sm_initfail_entry(struct bfa_iocpf_s *iocpf)
1075{
1076 bfa_fsm_send_event(iocpf->ioc, IOC_E_INITFAILED);
1077}
612 1078
1079/*
1080 * Hardware initialization failed.
1081 */
613static void 1082static void
614bfa_ioc_sm_hbfail_entry(struct bfa_ioc_s *ioc) 1083bfa_iocpf_sm_initfail(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
615{ 1084{
616 struct list_head *qe; 1085 struct bfa_ioc_s *ioc = iocpf->ioc;
617 struct bfa_ioc_hbfail_notify_s *notify;
618 1086
619 /** 1087 bfa_trc(ioc, event);
620 * Mark IOC as failed in hardware and stop firmware.
621 */
622 bfa_ioc_lpu_stop(ioc);
623 bfa_reg_write(ioc->ioc_regs.ioc_fwstate, BFI_IOC_FAIL);
624 1088
625 /** 1089 switch (event) {
626 * Notify other functions on HB failure. 1090 case IOCPF_E_DISABLE:
627 */ 1091 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
628 bfa_ioc_notify_hbfail(ioc); 1092 break;
629 1093
630 /** 1094 case IOCPF_E_STOP:
631 * Notify driver and common modules registered for notification. 1095 bfa_ioc_firmware_unlock(ioc);
632 */ 1096 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_reset);
633 ioc->cbfn->hbfail_cbfn(ioc->bfa); 1097 break;
634 list_for_each(qe, &ioc->hb_notify_q) { 1098
635 notify = (struct bfa_ioc_hbfail_notify_s *)qe; 1099 default:
636 notify->cbfn(notify->cbarg); 1100 bfa_sm_fault(ioc, event);
637 } 1101 }
1102}
638 1103
639 /** 1104static void
640 * Flush any queued up mailbox requests. 1105bfa_iocpf_sm_fail_sync_entry(struct bfa_iocpf_s *iocpf)
1106{
1107 /*
1108 * Mark IOC as failed in hardware and stop firmware.
641 */ 1109 */
642 bfa_ioc_mbox_hbfail(ioc); 1110 bfa_ioc_lpu_stop(iocpf->ioc);
643 bfa_ioc_aen_post(ioc, BFA_IOC_AEN_HBFAIL);
644 1111
645 /** 1112 /*
646 * Trigger auto-recovery after a delay. 1113 * Flush any queued up mailbox requests.
647 */ 1114 */
648 if (ioc->auto_recover) { 1115 bfa_ioc_mbox_hbfail(iocpf->ioc);
649 bfa_timer_begin(ioc->timer_mod, &ioc->ioc_timer, 1116
650 bfa_ioc_timeout, ioc, BFA_IOC_TOV_RECOVER); 1117 bfa_ioc_hw_sem_get(iocpf->ioc);
651 }
652} 1118}
653 1119
654/**
655 * IOC heartbeat failure.
656 */
657static void 1120static void
658bfa_ioc_sm_hbfail(struct bfa_ioc_s *ioc, enum ioc_event event) 1121bfa_iocpf_sm_fail_sync(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
659{ 1122{
1123 struct bfa_ioc_s *ioc = iocpf->ioc;
1124
660 bfa_trc(ioc, event); 1125 bfa_trc(ioc, event);
661 1126
662 switch (event) { 1127 switch (event) {
663 1128 case IOCPF_E_SEMLOCKED:
664 case IOC_E_ENABLE: 1129 iocpf->retry_count = 0;
665 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE); 1130 bfa_ioc_sync_ack(ioc);
1131 bfa_ioc_notify_fail(ioc);
1132 if (!iocpf->auto_recover) {
1133 bfa_ioc_sync_leave(ioc);
1134 writel(1, ioc->ioc_regs.ioc_sem_reg);
1135 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail);
1136 } else {
1137 if (bfa_ioc_sync_complete(ioc))
1138 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
1139 else {
1140 writel(1, ioc->ioc_regs.ioc_sem_reg);
1141 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_semwait);
1142 }
1143 }
666 break; 1144 break;
667 1145
668 case IOC_E_DISABLE: 1146 case IOCPF_E_DISABLE:
669 if (ioc->auto_recover) 1147 bfa_sem_timer_stop(ioc);
670 bfa_ioc_timer_stop(ioc); 1148 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
671 bfa_fsm_set_state(ioc, bfa_ioc_sm_disabled);
672 break; 1149 break;
673 1150
674 case IOC_E_TIMEOUT: 1151 case IOCPF_E_FAIL:
675 bfa_fsm_set_state(ioc, bfa_ioc_sm_semwait);
676 break; 1152 break;
677 1153
678 case IOC_E_FWREADY: 1154 default:
679 /** 1155 bfa_sm_fault(ioc, event);
680 * Recovery is already initiated by other function. 1156 }
681 */ 1157}
682 break;
683 1158
684 case IOC_E_HWERROR: 1159static void
685 /* 1160bfa_iocpf_sm_fail_entry(struct bfa_iocpf_s *iocpf)
686 * HB failure notification, ignore. 1161{
687 */ 1162}
1163
1164/*
1165 * IOC is in failed state.
1166 */
1167static void
1168bfa_iocpf_sm_fail(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
1169{
1170 struct bfa_ioc_s *ioc = iocpf->ioc;
1171
1172 bfa_trc(ioc, event);
1173
1174 switch (event) {
1175 case IOCPF_E_DISABLE:
1176 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabled);
688 break; 1177 break;
689 1178
690 default: 1179 default:
@@ -692,193 +1181,169 @@ bfa_ioc_sm_hbfail(struct bfa_ioc_s *ioc, enum ioc_event event)
692 } 1181 }
693} 1182}
694 1183
695 1184/*
696 1185 * BFA IOC private functions
697/**
698 * bfa_ioc_pvt BFA IOC private functions
699 */ 1186 */
700 1187
701static void 1188static void
702bfa_ioc_disable_comp(struct bfa_ioc_s *ioc) 1189bfa_ioc_disable_comp(struct bfa_ioc_s *ioc)
703{ 1190{
704 struct list_head *qe; 1191 struct list_head *qe;
705 struct bfa_ioc_hbfail_notify_s *notify; 1192 struct bfa_ioc_hbfail_notify_s *notify;
706 1193
707 ioc->cbfn->disable_cbfn(ioc->bfa); 1194 ioc->cbfn->disable_cbfn(ioc->bfa);
708 1195
709 /** 1196 /*
710 * Notify common modules registered for notification. 1197 * Notify common modules registered for notification.
711 */ 1198 */
712 list_for_each(qe, &ioc->hb_notify_q) { 1199 list_for_each(qe, &ioc->hb_notify_q) {
713 notify = (struct bfa_ioc_hbfail_notify_s *)qe; 1200 notify = (struct bfa_ioc_hbfail_notify_s *) qe;
714 notify->cbfn(notify->cbarg); 1201 notify->cbfn(notify->cbarg);
715 } 1202 }
716} 1203}
717 1204
718void
719bfa_ioc_sem_timeout(void *ioc_arg)
720{
721 struct bfa_ioc_s *ioc = (struct bfa_ioc_s *)ioc_arg;
722
723 bfa_ioc_hw_sem_get(ioc);
724}
725
726bfa_boolean_t 1205bfa_boolean_t
727bfa_ioc_sem_get(bfa_os_addr_t sem_reg) 1206bfa_ioc_sem_get(void __iomem *sem_reg)
728{ 1207{
729 u32 r32; 1208 u32 r32;
730 int cnt = 0; 1209 int cnt = 0;
731#define BFA_SEM_SPINCNT 3000 1210#define BFA_SEM_SPINCNT 3000
732 1211
733 r32 = bfa_reg_read(sem_reg); 1212 r32 = readl(sem_reg);
734 1213
735 while (r32 && (cnt < BFA_SEM_SPINCNT)) { 1214 while (r32 && (cnt < BFA_SEM_SPINCNT)) {
736 cnt++; 1215 cnt++;
737 bfa_os_udelay(2); 1216 udelay(2);
738 r32 = bfa_reg_read(sem_reg); 1217 r32 = readl(sem_reg);
739 } 1218 }
740 1219
741 if (r32 == 0) 1220 if (r32 == 0)
742 return BFA_TRUE; 1221 return BFA_TRUE;
743 1222
744 bfa_assert(cnt < BFA_SEM_SPINCNT); 1223 WARN_ON(cnt >= BFA_SEM_SPINCNT);
745 return BFA_FALSE; 1224 return BFA_FALSE;
746} 1225}
747 1226
748void
749bfa_ioc_sem_release(bfa_os_addr_t sem_reg)
750{
751 bfa_reg_write(sem_reg, 1);
752}
753
754static void 1227static void
755bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc) 1228bfa_ioc_hw_sem_get(struct bfa_ioc_s *ioc)
756{ 1229{
757 u32 r32; 1230 u32 r32;
758 1231
759 /** 1232 /*
760 * First read to the semaphore register will return 0, subsequent reads 1233 * First read to the semaphore register will return 0, subsequent reads
761 * will return 1. Semaphore is released by writing 1 to the register 1234 * will return 1. Semaphore is released by writing 1 to the register
762 */ 1235 */
763 r32 = bfa_reg_read(ioc->ioc_regs.ioc_sem_reg); 1236 r32 = readl(ioc->ioc_regs.ioc_sem_reg);
764 if (r32 == 0) { 1237 if (r32 == 0) {
765 bfa_fsm_send_event(ioc, IOC_E_SEMLOCKED); 1238 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_SEMLOCKED);
766 return; 1239 return;
767 } 1240 }
768 1241
769 bfa_timer_begin(ioc->timer_mod, &ioc->sem_timer, bfa_ioc_sem_timeout, 1242 bfa_sem_timer_start(ioc);
770 ioc, BFA_IOC_HWSEM_TOV);
771}
772
773void
774bfa_ioc_hw_sem_release(struct bfa_ioc_s *ioc)
775{
776 bfa_reg_write(ioc->ioc_regs.ioc_sem_reg, 1);
777}
778
779static void
780bfa_ioc_hw_sem_get_cancel(struct bfa_ioc_s *ioc)
781{
782 bfa_timer_stop(&ioc->sem_timer);
783} 1243}
784 1244
785/** 1245/*
786 * Initialize LPU local memory (aka secondary memory / SRAM) 1246 * Initialize LPU local memory (aka secondary memory / SRAM)
787 */ 1247 */
788static void 1248static void
789bfa_ioc_lmem_init(struct bfa_ioc_s *ioc) 1249bfa_ioc_lmem_init(struct bfa_ioc_s *ioc)
790{ 1250{
791 u32 pss_ctl; 1251 u32 pss_ctl;
792 int i; 1252 int i;
793#define PSS_LMEM_INIT_TIME 10000 1253#define PSS_LMEM_INIT_TIME 10000
794 1254
795 pss_ctl = bfa_reg_read(ioc->ioc_regs.pss_ctl_reg); 1255 pss_ctl = readl(ioc->ioc_regs.pss_ctl_reg);
796 pss_ctl &= ~__PSS_LMEM_RESET; 1256 pss_ctl &= ~__PSS_LMEM_RESET;
797 pss_ctl |= __PSS_LMEM_INIT_EN; 1257 pss_ctl |= __PSS_LMEM_INIT_EN;
798 pss_ctl |= __PSS_I2C_CLK_DIV(3UL); /* i2c workaround 12.5khz clock */
799 bfa_reg_write(ioc->ioc_regs.pss_ctl_reg, pss_ctl);
800 1258
801 /** 1259 /*
1260 * i2c workaround 12.5khz clock
1261 */
1262 pss_ctl |= __PSS_I2C_CLK_DIV(3UL);
1263 writel(pss_ctl, ioc->ioc_regs.pss_ctl_reg);
1264
1265 /*
802 * wait for memory initialization to be complete 1266 * wait for memory initialization to be complete
803 */ 1267 */
804 i = 0; 1268 i = 0;
805 do { 1269 do {
806 pss_ctl = bfa_reg_read(ioc->ioc_regs.pss_ctl_reg); 1270 pss_ctl = readl(ioc->ioc_regs.pss_ctl_reg);
807 i++; 1271 i++;
808 } while (!(pss_ctl & __PSS_LMEM_INIT_DONE) && (i < PSS_LMEM_INIT_TIME)); 1272 } while (!(pss_ctl & __PSS_LMEM_INIT_DONE) && (i < PSS_LMEM_INIT_TIME));
809 1273
810 /** 1274 /*
811 * If memory initialization is not successful, IOC timeout will catch 1275 * If memory initialization is not successful, IOC timeout will catch
812 * such failures. 1276 * such failures.
813 */ 1277 */
814 bfa_assert(pss_ctl & __PSS_LMEM_INIT_DONE); 1278 WARN_ON(!(pss_ctl & __PSS_LMEM_INIT_DONE));
815 bfa_trc(ioc, pss_ctl); 1279 bfa_trc(ioc, pss_ctl);
816 1280
817 pss_ctl &= ~(__PSS_LMEM_INIT_DONE | __PSS_LMEM_INIT_EN); 1281 pss_ctl &= ~(__PSS_LMEM_INIT_DONE | __PSS_LMEM_INIT_EN);
818 bfa_reg_write(ioc->ioc_regs.pss_ctl_reg, pss_ctl); 1282 writel(pss_ctl, ioc->ioc_regs.pss_ctl_reg);
819} 1283}
820 1284
821static void 1285static void
822bfa_ioc_lpu_start(struct bfa_ioc_s *ioc) 1286bfa_ioc_lpu_start(struct bfa_ioc_s *ioc)
823{ 1287{
824 u32 pss_ctl; 1288 u32 pss_ctl;
825 1289
826 /** 1290 /*
827 * Take processor out of reset. 1291 * Take processor out of reset.
828 */ 1292 */
829 pss_ctl = bfa_reg_read(ioc->ioc_regs.pss_ctl_reg); 1293 pss_ctl = readl(ioc->ioc_regs.pss_ctl_reg);
830 pss_ctl &= ~__PSS_LPU0_RESET; 1294 pss_ctl &= ~__PSS_LPU0_RESET;
831 1295
832 bfa_reg_write(ioc->ioc_regs.pss_ctl_reg, pss_ctl); 1296 writel(pss_ctl, ioc->ioc_regs.pss_ctl_reg);
833} 1297}
834 1298
835static void 1299static void
836bfa_ioc_lpu_stop(struct bfa_ioc_s *ioc) 1300bfa_ioc_lpu_stop(struct bfa_ioc_s *ioc)
837{ 1301{
838 u32 pss_ctl; 1302 u32 pss_ctl;
839 1303
840 /** 1304 /*
841 * Put processors in reset. 1305 * Put processors in reset.
842 */ 1306 */
843 pss_ctl = bfa_reg_read(ioc->ioc_regs.pss_ctl_reg); 1307 pss_ctl = readl(ioc->ioc_regs.pss_ctl_reg);
844 pss_ctl |= (__PSS_LPU0_RESET | __PSS_LPU1_RESET); 1308 pss_ctl |= (__PSS_LPU0_RESET | __PSS_LPU1_RESET);
845 1309
846 bfa_reg_write(ioc->ioc_regs.pss_ctl_reg, pss_ctl); 1310 writel(pss_ctl, ioc->ioc_regs.pss_ctl_reg);
847} 1311}
848 1312
849/** 1313/*
850 * Get driver and firmware versions. 1314 * Get driver and firmware versions.
851 */ 1315 */
852void 1316void
853bfa_ioc_fwver_get(struct bfa_ioc_s *ioc, struct bfi_ioc_image_hdr_s *fwhdr) 1317bfa_ioc_fwver_get(struct bfa_ioc_s *ioc, struct bfi_ioc_image_hdr_s *fwhdr)
854{ 1318{
855 u32 pgnum, pgoff; 1319 u32 pgnum, pgoff;
856 u32 loff = 0; 1320 u32 loff = 0;
857 int i; 1321 int i;
858 u32 *fwsig = (u32 *) fwhdr; 1322 u32 *fwsig = (u32 *) fwhdr;
859 1323
860 pgnum = bfa_ioc_smem_pgnum(ioc, loff); 1324 pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, loff);
861 pgoff = bfa_ioc_smem_pgoff(ioc, loff); 1325 pgoff = PSS_SMEM_PGOFF(loff);
862 bfa_reg_write(ioc->ioc_regs.host_page_num_fn, pgnum); 1326 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
863 1327
864 for (i = 0; i < (sizeof(struct bfi_ioc_image_hdr_s) / sizeof(u32)); 1328 for (i = 0; i < (sizeof(struct bfi_ioc_image_hdr_s) / sizeof(u32));
865 i++) { 1329 i++) {
866 fwsig[i] = bfa_mem_read(ioc->ioc_regs.smem_page_start, loff); 1330 fwsig[i] =
1331 bfa_mem_read(ioc->ioc_regs.smem_page_start, loff);
867 loff += sizeof(u32); 1332 loff += sizeof(u32);
868 } 1333 }
869} 1334}
870 1335
871/** 1336/*
872 * Returns TRUE if same. 1337 * Returns TRUE if same.
873 */ 1338 */
874bfa_boolean_t 1339bfa_boolean_t
875bfa_ioc_fwver_cmp(struct bfa_ioc_s *ioc, struct bfi_ioc_image_hdr_s *fwhdr) 1340bfa_ioc_fwver_cmp(struct bfa_ioc_s *ioc, struct bfi_ioc_image_hdr_s *fwhdr)
876{ 1341{
877 struct bfi_ioc_image_hdr_s *drv_fwhdr; 1342 struct bfi_ioc_image_hdr_s *drv_fwhdr;
878 int i; 1343 int i;
879 1344
880 drv_fwhdr = (struct bfi_ioc_image_hdr_s *) 1345 drv_fwhdr = (struct bfi_ioc_image_hdr_s *)
881 bfi_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), 0); 1346 bfa_cb_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), 0);
882 1347
883 for (i = 0; i < BFI_IOC_MD5SUM_SZ; i++) { 1348 for (i = 0; i < BFI_IOC_MD5SUM_SZ; i++) {
884 if (fwhdr->md5sum[i] != drv_fwhdr->md5sum[i]) { 1349 if (fwhdr->md5sum[i] != drv_fwhdr->md5sum[i]) {
@@ -893,25 +1358,18 @@ bfa_ioc_fwver_cmp(struct bfa_ioc_s *ioc, struct bfi_ioc_image_hdr_s *fwhdr)
893 return BFA_TRUE; 1358 return BFA_TRUE;
894} 1359}
895 1360
896/** 1361/*
897 * Return true if current running version is valid. Firmware signature and 1362 * Return true if current running version is valid. Firmware signature and
898 * execution context (driver/bios) must match. 1363 * execution context (driver/bios) must match.
899 */ 1364 */
900static bfa_boolean_t 1365static bfa_boolean_t
901bfa_ioc_fwver_valid(struct bfa_ioc_s *ioc) 1366bfa_ioc_fwver_valid(struct bfa_ioc_s *ioc, u32 boot_env)
902{ 1367{
903 struct bfi_ioc_image_hdr_s fwhdr, *drv_fwhdr; 1368 struct bfi_ioc_image_hdr_s fwhdr, *drv_fwhdr;
904 1369
905 /**
906 * If bios/efi boot (flash based) -- return true
907 */
908 if (bfa_ioc_is_optrom(ioc))
909 return BFA_TRUE;
910
911 bfa_ioc_fwver_get(ioc, &fwhdr); 1370 bfa_ioc_fwver_get(ioc, &fwhdr);
912 drv_fwhdr = (struct bfi_ioc_image_hdr_s *) 1371 drv_fwhdr = (struct bfi_ioc_image_hdr_s *)
913 bfi_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), 0); 1372 bfa_cb_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), 0);
914
915 1373
916 if (fwhdr.signature != drv_fwhdr->signature) { 1374 if (fwhdr.signature != drv_fwhdr->signature) {
917 bfa_trc(ioc, fwhdr.signature); 1375 bfa_trc(ioc, fwhdr.signature);
@@ -919,64 +1377,67 @@ bfa_ioc_fwver_valid(struct bfa_ioc_s *ioc)
919 return BFA_FALSE; 1377 return BFA_FALSE;
920 } 1378 }
921 1379
922 if (fwhdr.exec != drv_fwhdr->exec) { 1380 if (swab32(fwhdr.param) != boot_env) {
923 bfa_trc(ioc, fwhdr.exec); 1381 bfa_trc(ioc, fwhdr.param);
924 bfa_trc(ioc, drv_fwhdr->exec); 1382 bfa_trc(ioc, boot_env);
925 return BFA_FALSE; 1383 return BFA_FALSE;
926 } 1384 }
927 1385
928 return bfa_ioc_fwver_cmp(ioc, &fwhdr); 1386 return bfa_ioc_fwver_cmp(ioc, &fwhdr);
929} 1387}
930 1388
931/** 1389/*
932 * Conditionally flush any pending message from firmware at start. 1390 * Conditionally flush any pending message from firmware at start.
933 */ 1391 */
934static void 1392static void
935bfa_ioc_msgflush(struct bfa_ioc_s *ioc) 1393bfa_ioc_msgflush(struct bfa_ioc_s *ioc)
936{ 1394{
937 u32 r32; 1395 u32 r32;
938 1396
939 r32 = bfa_reg_read(ioc->ioc_regs.lpu_mbox_cmd); 1397 r32 = readl(ioc->ioc_regs.lpu_mbox_cmd);
940 if (r32) 1398 if (r32)
941 bfa_reg_write(ioc->ioc_regs.lpu_mbox_cmd, 1); 1399 writel(1, ioc->ioc_regs.lpu_mbox_cmd);
942} 1400}
943 1401
944
945static void 1402static void
946bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force) 1403bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force)
947{ 1404{
948 enum bfi_ioc_state ioc_fwstate; 1405 enum bfi_ioc_state ioc_fwstate;
949 bfa_boolean_t fwvalid; 1406 bfa_boolean_t fwvalid;
1407 u32 boot_type;
1408 u32 boot_env;
950 1409
951 ioc_fwstate = bfa_reg_read(ioc->ioc_regs.ioc_fwstate); 1410 ioc_fwstate = readl(ioc->ioc_regs.ioc_fwstate);
952 1411
953 if (force) 1412 if (force)
954 ioc_fwstate = BFI_IOC_UNINIT; 1413 ioc_fwstate = BFI_IOC_UNINIT;
955 1414
956 bfa_trc(ioc, ioc_fwstate); 1415 bfa_trc(ioc, ioc_fwstate);
957 1416
958 /** 1417 boot_type = BFI_BOOT_TYPE_NORMAL;
1418 boot_env = BFI_BOOT_LOADER_OS;
1419
1420 /*
959 * check if firmware is valid 1421 * check if firmware is valid
960 */ 1422 */
961 fwvalid = (ioc_fwstate == BFI_IOC_UNINIT) ? 1423 fwvalid = (ioc_fwstate == BFI_IOC_UNINIT) ?
962 BFA_FALSE : bfa_ioc_fwver_valid(ioc); 1424 BFA_FALSE : bfa_ioc_fwver_valid(ioc, boot_env);
963 1425
964 if (!fwvalid) { 1426 if (!fwvalid) {
965 bfa_ioc_boot(ioc, BFI_BOOT_TYPE_NORMAL, ioc->pcidev.device_id); 1427 bfa_ioc_boot(ioc, boot_type, boot_env);
966 return; 1428 return;
967 } 1429 }
968 1430
969 /** 1431 /*
970 * If hardware initialization is in progress (initialized by other IOC), 1432 * If hardware initialization is in progress (initialized by other IOC),
971 * just wait for an initialization completion interrupt. 1433 * just wait for an initialization completion interrupt.
972 */ 1434 */
973 if (ioc_fwstate == BFI_IOC_INITING) { 1435 if (ioc_fwstate == BFI_IOC_INITING) {
974 bfa_trc(ioc, ioc_fwstate);
975 ioc->cbfn->reset_cbfn(ioc->bfa); 1436 ioc->cbfn->reset_cbfn(ioc->bfa);
976 return; 1437 return;
977 } 1438 }
978 1439
979 /** 1440 /*
980 * If IOC function is disabled and firmware version is same, 1441 * If IOC function is disabled and firmware version is same,
981 * just re-enable IOC. 1442 * just re-enable IOC.
982 * 1443 *
@@ -984,30 +1445,28 @@ bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force)
984 * convergence, IOC will be in operational state when 2nd driver 1445 * convergence, IOC will be in operational state when 2nd driver
985 * is loaded. 1446 * is loaded.
986 */ 1447 */
987 if (ioc_fwstate == BFI_IOC_DISABLED || 1448 if (ioc_fwstate == BFI_IOC_DISABLED || ioc_fwstate == BFI_IOC_OP) {
988 (!bfa_ioc_is_optrom(ioc) && ioc_fwstate == BFI_IOC_OP)) {
989 bfa_trc(ioc, ioc_fwstate);
990 1449
991 /** 1450 /*
992 * When using MSI-X any pending firmware ready event should 1451 * When using MSI-X any pending firmware ready event should
993 * be flushed. Otherwise MSI-X interrupts are not delivered. 1452 * be flushed. Otherwise MSI-X interrupts are not delivered.
994 */ 1453 */
995 bfa_ioc_msgflush(ioc); 1454 bfa_ioc_msgflush(ioc);
996 ioc->cbfn->reset_cbfn(ioc->bfa); 1455 ioc->cbfn->reset_cbfn(ioc->bfa);
997 bfa_fsm_send_event(ioc, IOC_E_FWREADY); 1456 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_FWREADY);
998 return; 1457 return;
999 } 1458 }
1000 1459
1001 /** 1460 /*
1002 * Initialize the h/w for any other states. 1461 * Initialize the h/w for any other states.
1003 */ 1462 */
1004 bfa_ioc_boot(ioc, BFI_BOOT_TYPE_NORMAL, ioc->pcidev.device_id); 1463 bfa_ioc_boot(ioc, boot_type, boot_env);
1005} 1464}
1006 1465
1007static void 1466static void
1008bfa_ioc_timeout(void *ioc_arg) 1467bfa_ioc_timeout(void *ioc_arg)
1009{ 1468{
1010 struct bfa_ioc_s *ioc = (struct bfa_ioc_s *)ioc_arg; 1469 struct bfa_ioc_s *ioc = (struct bfa_ioc_s *) ioc_arg;
1011 1470
1012 bfa_trc(ioc, 0); 1471 bfa_trc(ioc, 0);
1013 bfa_fsm_send_event(ioc, IOC_E_TIMEOUT); 1472 bfa_fsm_send_event(ioc, IOC_E_TIMEOUT);
@@ -1016,39 +1475,42 @@ bfa_ioc_timeout(void *ioc_arg)
1016void 1475void
1017bfa_ioc_mbox_send(struct bfa_ioc_s *ioc, void *ioc_msg, int len) 1476bfa_ioc_mbox_send(struct bfa_ioc_s *ioc, void *ioc_msg, int len)
1018{ 1477{
1019 u32 *msgp = (u32 *) ioc_msg; 1478 u32 *msgp = (u32 *) ioc_msg;
1020 u32 i; 1479 u32 i;
1021 1480
1022 bfa_trc(ioc, msgp[0]); 1481 bfa_trc(ioc, msgp[0]);
1023 bfa_trc(ioc, len); 1482 bfa_trc(ioc, len);
1024 1483
1025 bfa_assert(len <= BFI_IOC_MSGLEN_MAX); 1484 WARN_ON(len > BFI_IOC_MSGLEN_MAX);
1026 1485
1027 /* 1486 /*
1028 * first write msg to mailbox registers 1487 * first write msg to mailbox registers
1029 */ 1488 */
1030 for (i = 0; i < len / sizeof(u32); i++) 1489 for (i = 0; i < len / sizeof(u32); i++)
1031 bfa_reg_write(ioc->ioc_regs.hfn_mbox + i * sizeof(u32), 1490 writel(cpu_to_le32(msgp[i]),
1032 bfa_os_wtole(msgp[i])); 1491 ioc->ioc_regs.hfn_mbox + i * sizeof(u32));
1033 1492
1034 for (; i < BFI_IOC_MSGLEN_MAX / sizeof(u32); i++) 1493 for (; i < BFI_IOC_MSGLEN_MAX / sizeof(u32); i++)
1035 bfa_reg_write(ioc->ioc_regs.hfn_mbox + i * sizeof(u32), 0); 1494 writel(0, ioc->ioc_regs.hfn_mbox + i * sizeof(u32));
1036 1495
1037 /* 1496 /*
1038 * write 1 to mailbox CMD to trigger LPU event 1497 * write 1 to mailbox CMD to trigger LPU event
1039 */ 1498 */
1040 bfa_reg_write(ioc->ioc_regs.hfn_mbox_cmd, 1); 1499 writel(1, ioc->ioc_regs.hfn_mbox_cmd);
1041 (void)bfa_reg_read(ioc->ioc_regs.hfn_mbox_cmd); 1500 (void) readl(ioc->ioc_regs.hfn_mbox_cmd);
1042} 1501}
1043 1502
1044static void 1503static void
1045bfa_ioc_send_enable(struct bfa_ioc_s *ioc) 1504bfa_ioc_send_enable(struct bfa_ioc_s *ioc)
1046{ 1505{
1047 struct bfi_ioc_ctrl_req_s enable_req; 1506 struct bfi_ioc_ctrl_req_s enable_req;
1507 struct timeval tv;
1048 1508
1049 bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ, 1509 bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ,
1050 bfa_ioc_portid(ioc)); 1510 bfa_ioc_portid(ioc));
1051 enable_req.ioc_class = ioc->ioc_mc; 1511 enable_req.ioc_class = ioc->ioc_mc;
1512 do_gettimeofday(&tv);
1513 enable_req.tv_sec = be32_to_cpu(tv.tv_sec);
1052 bfa_ioc_mbox_send(ioc, &enable_req, sizeof(struct bfi_ioc_ctrl_req_s)); 1514 bfa_ioc_mbox_send(ioc, &enable_req, sizeof(struct bfi_ioc_ctrl_req_s));
1053} 1515}
1054 1516
@@ -1065,7 +1527,7 @@ bfa_ioc_send_disable(struct bfa_ioc_s *ioc)
1065static void 1527static void
1066bfa_ioc_send_getattr(struct bfa_ioc_s *ioc) 1528bfa_ioc_send_getattr(struct bfa_ioc_s *ioc)
1067{ 1529{
1068 struct bfi_ioc_getattr_req_s attr_req; 1530 struct bfi_ioc_getattr_req_s attr_req;
1069 1531
1070 bfi_h2i_set(attr_req.mh, BFI_MC_IOC, BFI_IOC_H2I_GETATTR_REQ, 1532 bfi_h2i_set(attr_req.mh, BFI_MC_IOC, BFI_IOC_H2I_GETATTR_REQ,
1071 bfa_ioc_portid(ioc)); 1533 bfa_ioc_portid(ioc));
@@ -1077,12 +1539,10 @@ static void
1077bfa_ioc_hb_check(void *cbarg) 1539bfa_ioc_hb_check(void *cbarg)
1078{ 1540{
1079 struct bfa_ioc_s *ioc = cbarg; 1541 struct bfa_ioc_s *ioc = cbarg;
1080 u32 hb_count; 1542 u32 hb_count;
1081 1543
1082 hb_count = bfa_reg_read(ioc->ioc_regs.heartbeat); 1544 hb_count = readl(ioc->ioc_regs.heartbeat);
1083 if (ioc->hb_count == hb_count) { 1545 if (ioc->hb_count == hb_count) {
1084 bfa_log(ioc->logm, BFA_LOG_HAL_HEARTBEAT_FAILURE,
1085 hb_count);
1086 bfa_ioc_recover(ioc); 1546 bfa_ioc_recover(ioc);
1087 return; 1547 return;
1088 } else { 1548 } else {
@@ -1090,65 +1550,51 @@ bfa_ioc_hb_check(void *cbarg)
1090 } 1550 }
1091 1551
1092 bfa_ioc_mbox_poll(ioc); 1552 bfa_ioc_mbox_poll(ioc);
1093 bfa_timer_begin(ioc->timer_mod, &ioc->ioc_timer, bfa_ioc_hb_check, 1553 bfa_hb_timer_start(ioc);
1094 ioc, BFA_IOC_HB_TOV);
1095} 1554}
1096 1555
1097static void 1556static void
1098bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc) 1557bfa_ioc_hb_monitor(struct bfa_ioc_s *ioc)
1099{ 1558{
1100 ioc->hb_count = bfa_reg_read(ioc->ioc_regs.heartbeat); 1559 ioc->hb_count = readl(ioc->ioc_regs.heartbeat);
1101 bfa_timer_begin(ioc->timer_mod, &ioc->ioc_timer, bfa_ioc_hb_check, ioc, 1560 bfa_hb_timer_start(ioc);
1102 BFA_IOC_HB_TOV);
1103} 1561}
1104 1562
1105static void 1563/*
1106bfa_ioc_hb_stop(struct bfa_ioc_s *ioc) 1564 * Initiate a full firmware download.
1107{
1108 bfa_timer_stop(&ioc->ioc_timer);
1109}
1110
1111/**
1112 * Initiate a full firmware download.
1113 */ 1565 */
1114static void 1566static void
1115bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type, 1567bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type,
1116 u32 boot_param) 1568 u32 boot_env)
1117{ 1569{
1118 u32 *fwimg; 1570 u32 *fwimg;
1119 u32 pgnum, pgoff; 1571 u32 pgnum, pgoff;
1120 u32 loff = 0; 1572 u32 loff = 0;
1121 u32 chunkno = 0; 1573 u32 chunkno = 0;
1122 u32 i; 1574 u32 i;
1123 1575
1124 /** 1576 /*
1125 * Initialize LMEM first before code download 1577 * Initialize LMEM first before code download
1126 */ 1578 */
1127 bfa_ioc_lmem_init(ioc); 1579 bfa_ioc_lmem_init(ioc);
1128 1580
1129 /** 1581 bfa_trc(ioc, bfa_cb_image_get_size(BFA_IOC_FWIMG_TYPE(ioc)));
1130 * Flash based firmware boot 1582 fwimg = bfa_cb_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), chunkno);
1131 */
1132 bfa_trc(ioc, bfi_image_get_size(BFA_IOC_FWIMG_TYPE(ioc)));
1133 if (bfa_ioc_is_optrom(ioc))
1134 boot_type = BFI_BOOT_TYPE_FLASH;
1135 fwimg = bfi_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), chunkno);
1136
1137 1583
1138 pgnum = bfa_ioc_smem_pgnum(ioc, loff); 1584 pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, loff);
1139 pgoff = bfa_ioc_smem_pgoff(ioc, loff); 1585 pgoff = PSS_SMEM_PGOFF(loff);
1140 1586
1141 bfa_reg_write(ioc->ioc_regs.host_page_num_fn, pgnum); 1587 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1142 1588
1143 for (i = 0; i < bfi_image_get_size(BFA_IOC_FWIMG_TYPE(ioc)); i++) { 1589 for (i = 0; i < bfa_cb_image_get_size(BFA_IOC_FWIMG_TYPE(ioc)); i++) {
1144 1590
1145 if (BFA_IOC_FLASH_CHUNK_NO(i) != chunkno) { 1591 if (BFA_IOC_FLASH_CHUNK_NO(i) != chunkno) {
1146 chunkno = BFA_IOC_FLASH_CHUNK_NO(i); 1592 chunkno = BFA_IOC_FLASH_CHUNK_NO(i);
1147 fwimg = bfi_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), 1593 fwimg = bfa_cb_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc),
1148 BFA_IOC_FLASH_CHUNK_ADDR(chunkno)); 1594 BFA_IOC_FLASH_CHUNK_ADDR(chunkno));
1149 } 1595 }
1150 1596
1151 /** 1597 /*
1152 * write smem 1598 * write smem
1153 */ 1599 */
1154 bfa_mem_write(ioc->ioc_regs.smem_page_start, loff, 1600 bfa_mem_write(ioc->ioc_regs.smem_page_start, loff,
@@ -1156,57 +1602,52 @@ bfa_ioc_download_fw(struct bfa_ioc_s *ioc, u32 boot_type,
1156 1602
1157 loff += sizeof(u32); 1603 loff += sizeof(u32);
1158 1604
1159 /** 1605 /*
1160 * handle page offset wrap around 1606 * handle page offset wrap around
1161 */ 1607 */
1162 loff = PSS_SMEM_PGOFF(loff); 1608 loff = PSS_SMEM_PGOFF(loff);
1163 if (loff == 0) { 1609 if (loff == 0) {
1164 pgnum++; 1610 pgnum++;
1165 bfa_reg_write(ioc->ioc_regs.host_page_num_fn, pgnum); 1611 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1166 } 1612 }
1167 } 1613 }
1168 1614
1169 bfa_reg_write(ioc->ioc_regs.host_page_num_fn, 1615 writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0),
1170 bfa_ioc_smem_pgnum(ioc, 0)); 1616 ioc->ioc_regs.host_page_num_fn);
1171 1617
1172 /* 1618 /*
1173 * Set boot type and boot param at the end. 1619 * Set boot type and boot param at the end.
1174 */ 1620 */
1175 bfa_mem_write(ioc->ioc_regs.smem_page_start, BFI_BOOT_TYPE_OFF, 1621 bfa_mem_write(ioc->ioc_regs.smem_page_start, BFI_BOOT_TYPE_OFF,
1176 bfa_os_swap32(boot_type)); 1622 swab32(boot_type));
1177 bfa_mem_write(ioc->ioc_regs.smem_page_start, BFI_BOOT_PARAM_OFF, 1623 bfa_mem_write(ioc->ioc_regs.smem_page_start, BFI_BOOT_LOADER_OFF,
1178 bfa_os_swap32(boot_param)); 1624 swab32(boot_env));
1179} 1625}
1180 1626
1181static void
1182bfa_ioc_reset(struct bfa_ioc_s *ioc, bfa_boolean_t force)
1183{
1184 bfa_ioc_hwinit(ioc, force);
1185}
1186 1627
1187/** 1628/*
1188 * Update BFA configuration from firmware configuration. 1629 * Update BFA configuration from firmware configuration.
1189 */ 1630 */
1190static void 1631static void
1191bfa_ioc_getattr_reply(struct bfa_ioc_s *ioc) 1632bfa_ioc_getattr_reply(struct bfa_ioc_s *ioc)
1192{ 1633{
1193 struct bfi_ioc_attr_s *attr = ioc->attr; 1634 struct bfi_ioc_attr_s *attr = ioc->attr;
1194 1635
1195 attr->adapter_prop = bfa_os_ntohl(attr->adapter_prop); 1636 attr->adapter_prop = be32_to_cpu(attr->adapter_prop);
1196 attr->card_type = bfa_os_ntohl(attr->card_type); 1637 attr->card_type = be32_to_cpu(attr->card_type);
1197 attr->maxfrsize = bfa_os_ntohs(attr->maxfrsize); 1638 attr->maxfrsize = be16_to_cpu(attr->maxfrsize);
1198 1639
1199 bfa_fsm_send_event(ioc, IOC_E_FWRSP_GETATTR); 1640 bfa_fsm_send_event(ioc, IOC_E_FWRSP_GETATTR);
1200} 1641}
1201 1642
1202/** 1643/*
1203 * Attach time initialization of mbox logic. 1644 * Attach time initialization of mbox logic.
1204 */ 1645 */
1205static void 1646static void
1206bfa_ioc_mbox_attach(struct bfa_ioc_s *ioc) 1647bfa_ioc_mbox_attach(struct bfa_ioc_s *ioc)
1207{ 1648{
1208 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod; 1649 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
1209 int mc; 1650 int mc;
1210 1651
1211 INIT_LIST_HEAD(&mod->cmd_q); 1652 INIT_LIST_HEAD(&mod->cmd_q);
1212 for (mc = 0; mc < BFI_MC_MAX; mc++) { 1653 for (mc = 0; mc < BFI_MC_MAX; mc++) {
@@ -1215,90 +1656,256 @@ bfa_ioc_mbox_attach(struct bfa_ioc_s *ioc)
1215 } 1656 }
1216} 1657}
1217 1658
1218/** 1659/*
1219 * Mbox poll timer -- restarts any pending mailbox requests. 1660 * Mbox poll timer -- restarts any pending mailbox requests.
1220 */ 1661 */
1221static void 1662static void
1222bfa_ioc_mbox_poll(struct bfa_ioc_s *ioc) 1663bfa_ioc_mbox_poll(struct bfa_ioc_s *ioc)
1223{ 1664{
1224 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod; 1665 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
1225 struct bfa_mbox_cmd_s *cmd; 1666 struct bfa_mbox_cmd_s *cmd;
1226 u32 stat; 1667 u32 stat;
1227 1668
1228 /** 1669 /*
1229 * If no command pending, do nothing 1670 * If no command pending, do nothing
1230 */ 1671 */
1231 if (list_empty(&mod->cmd_q)) 1672 if (list_empty(&mod->cmd_q))
1232 return; 1673 return;
1233 1674
1234 /** 1675 /*
1235 * If previous command is not yet fetched by firmware, do nothing 1676 * If previous command is not yet fetched by firmware, do nothing
1236 */ 1677 */
1237 stat = bfa_reg_read(ioc->ioc_regs.hfn_mbox_cmd); 1678 stat = readl(ioc->ioc_regs.hfn_mbox_cmd);
1238 if (stat) 1679 if (stat)
1239 return; 1680 return;
1240 1681
1241 /** 1682 /*
1242 * Enqueue command to firmware. 1683 * Enqueue command to firmware.
1243 */ 1684 */
1244 bfa_q_deq(&mod->cmd_q, &cmd); 1685 bfa_q_deq(&mod->cmd_q, &cmd);
1245 bfa_ioc_mbox_send(ioc, cmd->msg, sizeof(cmd->msg)); 1686 bfa_ioc_mbox_send(ioc, cmd->msg, sizeof(cmd->msg));
1246} 1687}
1247 1688
1248/** 1689/*
1249 * Cleanup any pending requests. 1690 * Cleanup any pending requests.
1250 */ 1691 */
1251static void 1692static void
1252bfa_ioc_mbox_hbfail(struct bfa_ioc_s *ioc) 1693bfa_ioc_mbox_hbfail(struct bfa_ioc_s *ioc)
1253{ 1694{
1254 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod; 1695 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
1255 struct bfa_mbox_cmd_s *cmd; 1696 struct bfa_mbox_cmd_s *cmd;
1256 1697
1257 while (!list_empty(&mod->cmd_q)) 1698 while (!list_empty(&mod->cmd_q))
1258 bfa_q_deq(&mod->cmd_q, &cmd); 1699 bfa_q_deq(&mod->cmd_q, &cmd);
1259} 1700}
1260 1701
1261/** 1702/*
1262 * bfa_ioc_public 1703 * Read data from SMEM to host through PCI memmap
1704 *
1705 * @param[in] ioc memory for IOC
1706 * @param[in] tbuf app memory to store data from smem
1707 * @param[in] soff smem offset
1708 * @param[in] sz size of smem in bytes
1263 */ 1709 */
1710static bfa_status_t
1711bfa_ioc_smem_read(struct bfa_ioc_s *ioc, void *tbuf, u32 soff, u32 sz)
1712{
1713 u32 pgnum, loff;
1714 __be32 r32;
1715 int i, len;
1716 u32 *buf = tbuf;
1717
1718 pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, soff);
1719 loff = PSS_SMEM_PGOFF(soff);
1720 bfa_trc(ioc, pgnum);
1721 bfa_trc(ioc, loff);
1722 bfa_trc(ioc, sz);
1723
1724 /*
1725 * Hold semaphore to serialize pll init and fwtrc.
1726 */
1727 if (BFA_FALSE == bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg)) {
1728 bfa_trc(ioc, 0);
1729 return BFA_STATUS_FAILED;
1730 }
1731
1732 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1733
1734 len = sz/sizeof(u32);
1735 bfa_trc(ioc, len);
1736 for (i = 0; i < len; i++) {
1737 r32 = bfa_mem_read(ioc->ioc_regs.smem_page_start, loff);
1738 buf[i] = be32_to_cpu(r32);
1739 loff += sizeof(u32);
1740
1741 /*
1742 * handle page offset wrap around
1743 */
1744 loff = PSS_SMEM_PGOFF(loff);
1745 if (loff == 0) {
1746 pgnum++;
1747 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1748 }
1749 }
1750 writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0),
1751 ioc->ioc_regs.host_page_num_fn);
1752 /*
1753 * release semaphore.
1754 */
1755 writel(1, ioc->ioc_regs.ioc_init_sem_reg);
1756
1757 bfa_trc(ioc, pgnum);
1758 return BFA_STATUS_OK;
1759}
1760
1761/*
1762 * Clear SMEM data from host through PCI memmap
1763 *
1764 * @param[in] ioc memory for IOC
1765 * @param[in] soff smem offset
1766 * @param[in] sz size of smem in bytes
1767 */
1768static bfa_status_t
1769bfa_ioc_smem_clr(struct bfa_ioc_s *ioc, u32 soff, u32 sz)
1770{
1771 int i, len;
1772 u32 pgnum, loff;
1773
1774 pgnum = PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, soff);
1775 loff = PSS_SMEM_PGOFF(soff);
1776 bfa_trc(ioc, pgnum);
1777 bfa_trc(ioc, loff);
1778 bfa_trc(ioc, sz);
1779
1780 /*
1781 * Hold semaphore to serialize pll init and fwtrc.
1782 */
1783 if (BFA_FALSE == bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg)) {
1784 bfa_trc(ioc, 0);
1785 return BFA_STATUS_FAILED;
1786 }
1787
1788 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1789
1790 len = sz/sizeof(u32); /* len in words */
1791 bfa_trc(ioc, len);
1792 for (i = 0; i < len; i++) {
1793 bfa_mem_write(ioc->ioc_regs.smem_page_start, loff, 0);
1794 loff += sizeof(u32);
1795
1796 /*
1797 * handle page offset wrap around
1798 */
1799 loff = PSS_SMEM_PGOFF(loff);
1800 if (loff == 0) {
1801 pgnum++;
1802 writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1803 }
1804 }
1805 writel(PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, 0),
1806 ioc->ioc_regs.host_page_num_fn);
1807
1808 /*
1809 * release semaphore.
1810 */
1811 writel(1, ioc->ioc_regs.ioc_init_sem_reg);
1812 bfa_trc(ioc, pgnum);
1813 return BFA_STATUS_OK;
1814}
1815
1816static void
1817bfa_ioc_fail_notify(struct bfa_ioc_s *ioc)
1818{
1819 struct list_head *qe;
1820 struct bfa_ioc_hbfail_notify_s *notify;
1821 struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
1822
1823 /*
1824 * Notify driver and common modules registered for notification.
1825 */
1826 ioc->cbfn->hbfail_cbfn(ioc->bfa);
1827 list_for_each(qe, &ioc->hb_notify_q) {
1828 notify = (struct bfa_ioc_hbfail_notify_s *) qe;
1829 notify->cbfn(notify->cbarg);
1830 }
1831
1832 bfa_ioc_debug_save_ftrc(ioc);
1833
1834 BFA_LOG(KERN_CRIT, bfad, bfa_log_level,
1835 "Heart Beat of IOC has failed\n");
1836
1837}
1838
1839static void
1840bfa_ioc_pf_fwmismatch(struct bfa_ioc_s *ioc)
1841{
1842 struct bfad_s *bfad = (struct bfad_s *)ioc->bfa->bfad;
1843 /*
1844 * Provide enable completion callback.
1845 */
1846 ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
1847 BFA_LOG(KERN_WARNING, bfad, bfa_log_level,
1848 "Running firmware version is incompatible "
1849 "with the driver version\n");
1850}
1851
1852bfa_status_t
1853bfa_ioc_pll_init(struct bfa_ioc_s *ioc)
1854{
1855
1856 /*
1857 * Hold semaphore so that nobody can access the chip during init.
1858 */
1859 bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg);
1860
1861 bfa_ioc_pll_init_asic(ioc);
1862
1863 ioc->pllinit = BFA_TRUE;
1864 /*
1865 * release semaphore.
1866 */
1867 writel(1, ioc->ioc_regs.ioc_init_sem_reg);
1868
1869 return BFA_STATUS_OK;
1870}
1264 1871
1265/** 1872/*
1266 * Interface used by diag module to do firmware boot with memory test 1873 * Interface used by diag module to do firmware boot with memory test
1267 * as the entry vector. 1874 * as the entry vector.
1268 */ 1875 */
1269void 1876void
1270bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type, u32 boot_param) 1877bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type, u32 boot_env)
1271{ 1878{
1272 bfa_os_addr_t rb; 1879 void __iomem *rb;
1273 1880
1274 bfa_ioc_stats(ioc, ioc_boots); 1881 bfa_ioc_stats(ioc, ioc_boots);
1275 1882
1276 if (bfa_ioc_pll_init(ioc) != BFA_STATUS_OK) 1883 if (bfa_ioc_pll_init(ioc) != BFA_STATUS_OK)
1277 return; 1884 return;
1278 1885
1279 /** 1886 /*
1280 * Initialize IOC state of all functions on a chip reset. 1887 * Initialize IOC state of all functions on a chip reset.
1281 */ 1888 */
1282 rb = ioc->pcidev.pci_bar_kva; 1889 rb = ioc->pcidev.pci_bar_kva;
1283 if (boot_param == BFI_BOOT_TYPE_MEMTEST) { 1890 if (boot_type == BFI_BOOT_TYPE_MEMTEST) {
1284 bfa_reg_write((rb + BFA_IOC0_STATE_REG), BFI_IOC_MEMTEST); 1891 writel(BFI_IOC_MEMTEST, (rb + BFA_IOC0_STATE_REG));
1285 bfa_reg_write((rb + BFA_IOC1_STATE_REG), BFI_IOC_MEMTEST); 1892 writel(BFI_IOC_MEMTEST, (rb + BFA_IOC1_STATE_REG));
1286 } else { 1893 } else {
1287 bfa_reg_write((rb + BFA_IOC0_STATE_REG), BFI_IOC_INITING); 1894 writel(BFI_IOC_INITING, (rb + BFA_IOC0_STATE_REG));
1288 bfa_reg_write((rb + BFA_IOC1_STATE_REG), BFI_IOC_INITING); 1895 writel(BFI_IOC_INITING, (rb + BFA_IOC1_STATE_REG));
1289 } 1896 }
1290 1897
1291 bfa_ioc_msgflush(ioc); 1898 bfa_ioc_msgflush(ioc);
1292 bfa_ioc_download_fw(ioc, boot_type, boot_param); 1899 bfa_ioc_download_fw(ioc, boot_type, boot_env);
1293 1900
1294 /** 1901 /*
1295 * Enable interrupts just before starting LPU 1902 * Enable interrupts just before starting LPU
1296 */ 1903 */
1297 ioc->cbfn->reset_cbfn(ioc->bfa); 1904 ioc->cbfn->reset_cbfn(ioc->bfa);
1298 bfa_ioc_lpu_start(ioc); 1905 bfa_ioc_lpu_start(ioc);
1299} 1906}
1300 1907
1301/** 1908/*
1302 * Enable/disable IOC failure auto recovery. 1909 * Enable/disable IOC failure auto recovery.
1303 */ 1910 */
1304void 1911void
@@ -1308,42 +1915,54 @@ bfa_ioc_auto_recover(bfa_boolean_t auto_recover)
1308} 1915}
1309 1916
1310 1917
1918
1311bfa_boolean_t 1919bfa_boolean_t
1312bfa_ioc_is_operational(struct bfa_ioc_s *ioc) 1920bfa_ioc_is_operational(struct bfa_ioc_s *ioc)
1313{ 1921{
1314 return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_op); 1922 return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_op);
1315} 1923}
1316 1924
1925bfa_boolean_t
1926bfa_ioc_is_initialized(struct bfa_ioc_s *ioc)
1927{
1928 u32 r32 = readl(ioc->ioc_regs.ioc_fwstate);
1929
1930 return ((r32 != BFI_IOC_UNINIT) &&
1931 (r32 != BFI_IOC_INITING) &&
1932 (r32 != BFI_IOC_MEMTEST));
1933}
1934
1317void 1935void
1318bfa_ioc_msgget(struct bfa_ioc_s *ioc, void *mbmsg) 1936bfa_ioc_msgget(struct bfa_ioc_s *ioc, void *mbmsg)
1319{ 1937{
1320 u32 *msgp = mbmsg; 1938 __be32 *msgp = mbmsg;
1321 u32 r32; 1939 u32 r32;
1322 int i; 1940 int i;
1323 1941
1324 /** 1942 /*
1325 * read the MBOX msg 1943 * read the MBOX msg
1326 */ 1944 */
1327 for (i = 0; i < (sizeof(union bfi_ioc_i2h_msg_u) / sizeof(u32)); 1945 for (i = 0; i < (sizeof(union bfi_ioc_i2h_msg_u) / sizeof(u32));
1328 i++) { 1946 i++) {
1329 r32 = bfa_reg_read(ioc->ioc_regs.lpu_mbox + 1947 r32 = readl(ioc->ioc_regs.lpu_mbox +
1330 i * sizeof(u32)); 1948 i * sizeof(u32));
1331 msgp[i] = bfa_os_htonl(r32); 1949 msgp[i] = cpu_to_be32(r32);
1332 } 1950 }
1333 1951
1334 /** 1952 /*
1335 * turn off mailbox interrupt by clearing mailbox status 1953 * turn off mailbox interrupt by clearing mailbox status
1336 */ 1954 */
1337 bfa_reg_write(ioc->ioc_regs.lpu_mbox_cmd, 1); 1955 writel(1, ioc->ioc_regs.lpu_mbox_cmd);
1338 bfa_reg_read(ioc->ioc_regs.lpu_mbox_cmd); 1956 readl(ioc->ioc_regs.lpu_mbox_cmd);
1339} 1957}
1340 1958
1341void 1959void
1342bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *m) 1960bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *m)
1343{ 1961{
1344 union bfi_ioc_i2h_msg_u *msg; 1962 union bfi_ioc_i2h_msg_u *msg;
1963 struct bfa_iocpf_s *iocpf = &ioc->iocpf;
1345 1964
1346 msg = (union bfi_ioc_i2h_msg_u *)m; 1965 msg = (union bfi_ioc_i2h_msg_u *) m;
1347 1966
1348 bfa_ioc_stats(ioc, ioc_isrs); 1967 bfa_ioc_stats(ioc, ioc_isrs);
1349 1968
@@ -1352,15 +1971,15 @@ bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *m)
1352 break; 1971 break;
1353 1972
1354 case BFI_IOC_I2H_READY_EVENT: 1973 case BFI_IOC_I2H_READY_EVENT:
1355 bfa_fsm_send_event(ioc, IOC_E_FWREADY); 1974 bfa_fsm_send_event(iocpf, IOCPF_E_FWREADY);
1356 break; 1975 break;
1357 1976
1358 case BFI_IOC_I2H_ENABLE_REPLY: 1977 case BFI_IOC_I2H_ENABLE_REPLY:
1359 bfa_fsm_send_event(ioc, IOC_E_FWRSP_ENABLE); 1978 bfa_fsm_send_event(iocpf, IOCPF_E_FWRSP_ENABLE);
1360 break; 1979 break;
1361 1980
1362 case BFI_IOC_I2H_DISABLE_REPLY: 1981 case BFI_IOC_I2H_DISABLE_REPLY:
1363 bfa_fsm_send_event(ioc, IOC_E_FWRSP_DISABLE); 1982 bfa_fsm_send_event(iocpf, IOCPF_E_FWRSP_DISABLE);
1364 break; 1983 break;
1365 1984
1366 case BFI_IOC_I2H_GETATTR_REPLY: 1985 case BFI_IOC_I2H_GETATTR_REPLY:
@@ -1369,41 +1988,36 @@ bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *m)
1369 1988
1370 default: 1989 default:
1371 bfa_trc(ioc, msg->mh.msg_id); 1990 bfa_trc(ioc, msg->mh.msg_id);
1372 bfa_assert(0); 1991 WARN_ON(1);
1373 } 1992 }
1374} 1993}
1375 1994
1376/** 1995/*
1377 * IOC attach time initialization and setup. 1996 * IOC attach time initialization and setup.
1378 * 1997 *
1379 * @param[in] ioc memory for IOC 1998 * @param[in] ioc memory for IOC
1380 * @param[in] bfa driver instance structure 1999 * @param[in] bfa driver instance structure
1381 * @param[in] trcmod kernel trace module
1382 * @param[in] aen kernel aen event module
1383 * @param[in] logm kernel logging module
1384 */ 2000 */
1385void 2001void
1386bfa_ioc_attach(struct bfa_ioc_s *ioc, void *bfa, struct bfa_ioc_cbfn_s *cbfn, 2002bfa_ioc_attach(struct bfa_ioc_s *ioc, void *bfa, struct bfa_ioc_cbfn_s *cbfn,
1387 struct bfa_timer_mod_s *timer_mod, struct bfa_trc_mod_s *trcmod, 2003 struct bfa_timer_mod_s *timer_mod)
1388 struct bfa_aen_s *aen, struct bfa_log_mod_s *logm) 2004{
1389{ 2005 ioc->bfa = bfa;
1390 ioc->bfa = bfa; 2006 ioc->cbfn = cbfn;
1391 ioc->cbfn = cbfn; 2007 ioc->timer_mod = timer_mod;
1392 ioc->timer_mod = timer_mod; 2008 ioc->fcmode = BFA_FALSE;
1393 ioc->trcmod = trcmod; 2009 ioc->pllinit = BFA_FALSE;
1394 ioc->aen = aen;
1395 ioc->logm = logm;
1396 ioc->fcmode = BFA_FALSE;
1397 ioc->pllinit = BFA_FALSE;
1398 ioc->dbg_fwsave_once = BFA_TRUE; 2010 ioc->dbg_fwsave_once = BFA_TRUE;
2011 ioc->iocpf.ioc = ioc;
1399 2012
1400 bfa_ioc_mbox_attach(ioc); 2013 bfa_ioc_mbox_attach(ioc);
1401 INIT_LIST_HEAD(&ioc->hb_notify_q); 2014 INIT_LIST_HEAD(&ioc->hb_notify_q);
1402 2015
1403 bfa_fsm_set_state(ioc, bfa_ioc_sm_reset); 2016 bfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);
2017 bfa_fsm_send_event(ioc, IOC_E_RESET);
1404} 2018}
1405 2019
1406/** 2020/*
1407 * Driver detach time IOC cleanup. 2021 * Driver detach time IOC cleanup.
1408 */ 2022 */
1409void 2023void
@@ -1412,7 +2026,7 @@ bfa_ioc_detach(struct bfa_ioc_s *ioc)
1412 bfa_fsm_send_event(ioc, IOC_E_DETACH); 2026 bfa_fsm_send_event(ioc, IOC_E_DETACH);
1413} 2027}
1414 2028
1415/** 2029/*
1416 * Setup IOC PCI properties. 2030 * Setup IOC PCI properties.
1417 * 2031 *
1418 * @param[in] pcidev PCI device information for this IOC 2032 * @param[in] pcidev PCI device information for this IOC
@@ -1421,12 +2035,12 @@ void
1421bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct bfa_pcidev_s *pcidev, 2035bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct bfa_pcidev_s *pcidev,
1422 enum bfi_mclass mc) 2036 enum bfi_mclass mc)
1423{ 2037{
1424 ioc->ioc_mc = mc; 2038 ioc->ioc_mc = mc;
1425 ioc->pcidev = *pcidev; 2039 ioc->pcidev = *pcidev;
1426 ioc->ctdev = bfa_asic_id_ct(ioc->pcidev.device_id); 2040 ioc->ctdev = bfa_asic_id_ct(ioc->pcidev.device_id);
1427 ioc->cna = ioc->ctdev && !ioc->fcmode; 2041 ioc->cna = ioc->ctdev && !ioc->fcmode;
1428 2042
1429 /** 2043 /*
1430 * Set asic specific interfaces. See bfa_ioc_cb.c and bfa_ioc_ct.c 2044 * Set asic specific interfaces. See bfa_ioc_cb.c and bfa_ioc_ct.c
1431 */ 2045 */
1432 if (ioc->ctdev) 2046 if (ioc->ctdev)
@@ -1438,30 +2052,21 @@ bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct bfa_pcidev_s *pcidev,
1438 bfa_ioc_reg_init(ioc); 2052 bfa_ioc_reg_init(ioc);
1439} 2053}
1440 2054
1441/** 2055/*
1442 * Initialize IOC dma memory 2056 * Initialize IOC dma memory
1443 * 2057 *
1444 * @param[in] dm_kva kernel virtual address of IOC dma memory 2058 * @param[in] dm_kva kernel virtual address of IOC dma memory
1445 * @param[in] dm_pa physical address of IOC dma memory 2059 * @param[in] dm_pa physical address of IOC dma memory
1446 */ 2060 */
1447void 2061void
1448bfa_ioc_mem_claim(struct bfa_ioc_s *ioc, u8 *dm_kva, u64 dm_pa) 2062bfa_ioc_mem_claim(struct bfa_ioc_s *ioc, u8 *dm_kva, u64 dm_pa)
1449{ 2063{
1450 /** 2064 /*
1451 * dma memory for firmware attribute 2065 * dma memory for firmware attribute
1452 */ 2066 */
1453 ioc->attr_dma.kva = dm_kva; 2067 ioc->attr_dma.kva = dm_kva;
1454 ioc->attr_dma.pa = dm_pa; 2068 ioc->attr_dma.pa = dm_pa;
1455 ioc->attr = (struct bfi_ioc_attr_s *)dm_kva; 2069 ioc->attr = (struct bfi_ioc_attr_s *) dm_kva;
1456}
1457
1458/**
1459 * Return size of dma memory required.
1460 */
1461u32
1462bfa_ioc_meminfo(void)
1463{
1464 return BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ);
1465} 2070}
1466 2071
1467void 2072void
@@ -1480,43 +2085,19 @@ bfa_ioc_disable(struct bfa_ioc_s *ioc)
1480 bfa_fsm_send_event(ioc, IOC_E_DISABLE); 2085 bfa_fsm_send_event(ioc, IOC_E_DISABLE);
1481} 2086}
1482 2087
1483/**
1484 * Returns memory required for saving firmware trace in case of crash.
1485 * Driver must call this interface to allocate memory required for
1486 * automatic saving of firmware trace. Driver should call
1487 * bfa_ioc_debug_memclaim() right after bfa_ioc_attach() to setup this
1488 * trace memory.
1489 */
1490int
1491bfa_ioc_debug_trcsz(bfa_boolean_t auto_recover)
1492{
1493return (auto_recover) ? BFA_DBG_FWTRC_LEN : 0;
1494}
1495 2088
1496/** 2089/*
1497 * Initialize memory for saving firmware trace. Driver must initialize 2090 * Initialize memory for saving firmware trace. Driver must initialize
1498 * trace memory before call bfa_ioc_enable(). 2091 * trace memory before call bfa_ioc_enable().
1499 */ 2092 */
1500void 2093void
1501bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave) 2094bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave)
1502{ 2095{
1503 ioc->dbg_fwsave = dbg_fwsave; 2096 ioc->dbg_fwsave = dbg_fwsave;
1504 ioc->dbg_fwsave_len = bfa_ioc_debug_trcsz(ioc->auto_recover); 2097 ioc->dbg_fwsave_len = (ioc->iocpf.auto_recover) ? BFA_DBG_FWTRC_LEN : 0;
1505}
1506
1507u32
1508bfa_ioc_smem_pgnum(struct bfa_ioc_s *ioc, u32 fmaddr)
1509{
1510 return PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, fmaddr);
1511} 2098}
1512 2099
1513u32 2100/*
1514bfa_ioc_smem_pgoff(struct bfa_ioc_s *ioc, u32 fmaddr)
1515{
1516 return PSS_SMEM_PGOFF(fmaddr);
1517}
1518
1519/**
1520 * Register mailbox message handler functions 2101 * Register mailbox message handler functions
1521 * 2102 *
1522 * @param[in] ioc IOC instance 2103 * @param[in] ioc IOC instance
@@ -1525,27 +2106,27 @@ bfa_ioc_smem_pgoff(struct bfa_ioc_s *ioc, u32 fmaddr)
1525void 2106void
1526bfa_ioc_mbox_register(struct bfa_ioc_s *ioc, bfa_ioc_mbox_mcfunc_t *mcfuncs) 2107bfa_ioc_mbox_register(struct bfa_ioc_s *ioc, bfa_ioc_mbox_mcfunc_t *mcfuncs)
1527{ 2108{
1528 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod; 2109 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
1529 int mc; 2110 int mc;
1530 2111
1531 for (mc = 0; mc < BFI_MC_MAX; mc++) 2112 for (mc = 0; mc < BFI_MC_MAX; mc++)
1532 mod->mbhdlr[mc].cbfn = mcfuncs[mc]; 2113 mod->mbhdlr[mc].cbfn = mcfuncs[mc];
1533} 2114}
1534 2115
1535/** 2116/*
1536 * Register mailbox message handler function, to be called by common modules 2117 * Register mailbox message handler function, to be called by common modules
1537 */ 2118 */
1538void 2119void
1539bfa_ioc_mbox_regisr(struct bfa_ioc_s *ioc, enum bfi_mclass mc, 2120bfa_ioc_mbox_regisr(struct bfa_ioc_s *ioc, enum bfi_mclass mc,
1540 bfa_ioc_mbox_mcfunc_t cbfn, void *cbarg) 2121 bfa_ioc_mbox_mcfunc_t cbfn, void *cbarg)
1541{ 2122{
1542 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod; 2123 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
1543 2124
1544 mod->mbhdlr[mc].cbfn = cbfn; 2125 mod->mbhdlr[mc].cbfn = cbfn;
1545 mod->mbhdlr[mc].cbarg = cbarg; 2126 mod->mbhdlr[mc].cbarg = cbarg;
1546} 2127}
1547 2128
1548/** 2129/*
1549 * Queue a mailbox command request to firmware. Waits if mailbox is busy. 2130 * Queue a mailbox command request to firmware. Waits if mailbox is busy.
1550 * Responsibility of caller to serialize 2131 * Responsibility of caller to serialize
1551 * 2132 *
@@ -1555,10 +2136,10 @@ bfa_ioc_mbox_regisr(struct bfa_ioc_s *ioc, enum bfi_mclass mc,
1555void 2136void
1556bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd) 2137bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd)
1557{ 2138{
1558 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod; 2139 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
1559 u32 stat; 2140 u32 stat;
1560 2141
1561 /** 2142 /*
1562 * If a previous command is pending, queue new command 2143 * If a previous command is pending, queue new command
1563 */ 2144 */
1564 if (!list_empty(&mod->cmd_q)) { 2145 if (!list_empty(&mod->cmd_q)) {
@@ -1566,34 +2147,34 @@ bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd)
1566 return; 2147 return;
1567 } 2148 }
1568 2149
1569 /** 2150 /*
1570 * If mailbox is busy, queue command for poll timer 2151 * If mailbox is busy, queue command for poll timer
1571 */ 2152 */
1572 stat = bfa_reg_read(ioc->ioc_regs.hfn_mbox_cmd); 2153 stat = readl(ioc->ioc_regs.hfn_mbox_cmd);
1573 if (stat) { 2154 if (stat) {
1574 list_add_tail(&cmd->qe, &mod->cmd_q); 2155 list_add_tail(&cmd->qe, &mod->cmd_q);
1575 return; 2156 return;
1576 } 2157 }
1577 2158
1578 /** 2159 /*
1579 * mailbox is free -- queue command to firmware 2160 * mailbox is free -- queue command to firmware
1580 */ 2161 */
1581 bfa_ioc_mbox_send(ioc, cmd->msg, sizeof(cmd->msg)); 2162 bfa_ioc_mbox_send(ioc, cmd->msg, sizeof(cmd->msg));
1582} 2163}
1583 2164
1584/** 2165/*
1585 * Handle mailbox interrupts 2166 * Handle mailbox interrupts
1586 */ 2167 */
1587void 2168void
1588bfa_ioc_mbox_isr(struct bfa_ioc_s *ioc) 2169bfa_ioc_mbox_isr(struct bfa_ioc_s *ioc)
1589{ 2170{
1590 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod; 2171 struct bfa_ioc_mbox_mod_s *mod = &ioc->mbox_mod;
1591 struct bfi_mbmsg_s m; 2172 struct bfi_mbmsg_s m;
1592 int mc; 2173 int mc;
1593 2174
1594 bfa_ioc_msgget(ioc, &m); 2175 bfa_ioc_msgget(ioc, &m);
1595 2176
1596 /** 2177 /*
1597 * Treat IOC message class as special. 2178 * Treat IOC message class as special.
1598 */ 2179 */
1599 mc = m.mh.msg_class; 2180 mc = m.mh.msg_class;
@@ -1621,27 +2202,25 @@ bfa_ioc_set_fcmode(struct bfa_ioc_s *ioc)
1621 ioc->port_id = bfa_ioc_pcifn(ioc); 2202 ioc->port_id = bfa_ioc_pcifn(ioc);
1622} 2203}
1623 2204
1624#ifndef BFA_BIOS_BUILD 2205/*
1625
1626/**
1627 * return true if IOC is disabled 2206 * return true if IOC is disabled
1628 */ 2207 */
1629bfa_boolean_t 2208bfa_boolean_t
1630bfa_ioc_is_disabled(struct bfa_ioc_s *ioc) 2209bfa_ioc_is_disabled(struct bfa_ioc_s *ioc)
1631{ 2210{
1632 return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabling) 2211 return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabling) ||
1633 || bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabled); 2212 bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabled);
1634} 2213}
1635 2214
1636/** 2215/*
1637 * return true if IOC firmware is different. 2216 * return true if IOC firmware is different.
1638 */ 2217 */
1639bfa_boolean_t 2218bfa_boolean_t
1640bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc) 2219bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc)
1641{ 2220{
1642 return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_reset) 2221 return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_reset) ||
1643 || bfa_fsm_cmp_state(ioc, bfa_ioc_sm_fwcheck) 2222 bfa_fsm_cmp_state(&ioc->iocpf, bfa_iocpf_sm_fwcheck) ||
1644 || bfa_fsm_cmp_state(ioc, bfa_ioc_sm_mismatch); 2223 bfa_fsm_cmp_state(&ioc->iocpf, bfa_iocpf_sm_mismatch);
1645} 2224}
1646 2225
1647#define bfa_ioc_state_disabled(__sm) \ 2226#define bfa_ioc_state_disabled(__sm) \
@@ -1652,39 +2231,40 @@ bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc)
1652 ((__sm) == BFI_IOC_FAIL) || \ 2231 ((__sm) == BFI_IOC_FAIL) || \
1653 ((__sm) == BFI_IOC_CFG_DISABLED)) 2232 ((__sm) == BFI_IOC_CFG_DISABLED))
1654 2233
1655/** 2234/*
1656 * Check if adapter is disabled -- both IOCs should be in a disabled 2235 * Check if adapter is disabled -- both IOCs should be in a disabled
1657 * state. 2236 * state.
1658 */ 2237 */
1659bfa_boolean_t 2238bfa_boolean_t
1660bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc) 2239bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc)
1661{ 2240{
1662 u32 ioc_state; 2241 u32 ioc_state;
1663 bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; 2242 void __iomem *rb = ioc->pcidev.pci_bar_kva;
1664 2243
1665 if (!bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabled)) 2244 if (!bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabled))
1666 return BFA_FALSE; 2245 return BFA_FALSE;
1667 2246
1668 ioc_state = bfa_reg_read(rb + BFA_IOC0_STATE_REG); 2247 ioc_state = readl(rb + BFA_IOC0_STATE_REG);
1669 if (!bfa_ioc_state_disabled(ioc_state)) 2248 if (!bfa_ioc_state_disabled(ioc_state))
1670 return BFA_FALSE; 2249 return BFA_FALSE;
1671 2250
1672 ioc_state = bfa_reg_read(rb + BFA_IOC1_STATE_REG); 2251 if (ioc->pcidev.device_id != BFA_PCI_DEVICE_ID_FC_8G1P) {
1673 if (!bfa_ioc_state_disabled(ioc_state)) 2252 ioc_state = readl(rb + BFA_IOC1_STATE_REG);
1674 return BFA_FALSE; 2253 if (!bfa_ioc_state_disabled(ioc_state))
2254 return BFA_FALSE;
2255 }
1675 2256
1676 return BFA_TRUE; 2257 return BFA_TRUE;
1677} 2258}
1678 2259
1679/** 2260/*
1680 * Add to IOC heartbeat failure notification queue. To be used by common 2261 * Reset IOC fwstate registers.
1681 * modules such as
1682 */ 2262 */
1683void 2263void
1684bfa_ioc_hbfail_register(struct bfa_ioc_s *ioc, 2264bfa_ioc_reset_fwstate(struct bfa_ioc_s *ioc)
1685 struct bfa_ioc_hbfail_notify_s *notify)
1686{ 2265{
1687 list_add_tail(&notify->qe, &ioc->hb_notify_q); 2266 writel(BFI_IOC_UNINIT, ioc->ioc_regs.ioc_fwstate);
2267 writel(BFI_IOC_UNINIT, ioc->ioc_regs.alt_ioc_fwstate);
1688} 2268}
1689 2269
1690#define BFA_MFG_NAME "Brocade" 2270#define BFA_MFG_NAME "Brocade"
@@ -1692,7 +2272,7 @@ void
1692bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc, 2272bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
1693 struct bfa_adapter_attr_s *ad_attr) 2273 struct bfa_adapter_attr_s *ad_attr)
1694{ 2274{
1695 struct bfi_ioc_attr_s *ioc_attr; 2275 struct bfi_ioc_attr_s *ioc_attr;
1696 2276
1697 ioc_attr = ioc->attr; 2277 ioc_attr = ioc->attr;
1698 2278
@@ -1700,7 +2280,7 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
1700 bfa_ioc_get_adapter_fw_ver(ioc, ad_attr->fw_ver); 2280 bfa_ioc_get_adapter_fw_ver(ioc, ad_attr->fw_ver);
1701 bfa_ioc_get_adapter_optrom_ver(ioc, ad_attr->optrom_ver); 2281 bfa_ioc_get_adapter_optrom_ver(ioc, ad_attr->optrom_ver);
1702 bfa_ioc_get_adapter_manufacturer(ioc, ad_attr->manufacturer); 2282 bfa_ioc_get_adapter_manufacturer(ioc, ad_attr->manufacturer);
1703 bfa_os_memcpy(&ad_attr->vpd, &ioc_attr->vpd, 2283 memcpy(&ad_attr->vpd, &ioc_attr->vpd,
1704 sizeof(struct bfa_mfg_vpd_s)); 2284 sizeof(struct bfa_mfg_vpd_s));
1705 2285
1706 ad_attr->nports = bfa_ioc_get_nports(ioc); 2286 ad_attr->nports = bfa_ioc_get_nports(ioc);
@@ -1718,8 +2298,8 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
1718 else 2298 else
1719 ad_attr->prototype = 0; 2299 ad_attr->prototype = 0;
1720 2300
1721 ad_attr->pwwn = bfa_ioc_get_pwwn(ioc); 2301 ad_attr->pwwn = ioc->attr->pwwn;
1722 ad_attr->mac = bfa_ioc_get_mac(ioc); 2302 ad_attr->mac = bfa_ioc_get_mac(ioc);
1723 2303
1724 ad_attr->pcie_gen = ioc_attr->pcie_gen; 2304 ad_attr->pcie_gen = ioc_attr->pcie_gen;
1725 ad_attr->pcie_lanes = ioc_attr->pcie_lanes; 2305 ad_attr->pcie_lanes = ioc_attr->pcie_lanes;
@@ -1729,6 +2309,8 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
1729 bfa_ioc_get_pci_chip_rev(ioc, ad_attr->hw_ver); 2309 bfa_ioc_get_pci_chip_rev(ioc, ad_attr->hw_ver);
1730 2310
1731 ad_attr->cna_capable = ioc->cna; 2311 ad_attr->cna_capable = ioc->cna;
2312 ad_attr->trunk_capable = (ad_attr->nports > 1) && !ioc->cna &&
2313 !ad_attr->is_mezz;
1732} 2314}
1733 2315
1734enum bfa_ioc_type_e 2316enum bfa_ioc_type_e
@@ -1741,7 +2323,7 @@ bfa_ioc_get_type(struct bfa_ioc_s *ioc)
1741 else if (ioc->ioc_mc == BFI_MC_LL) 2323 else if (ioc->ioc_mc == BFI_MC_LL)
1742 return BFA_IOC_TYPE_LL; 2324 return BFA_IOC_TYPE_LL;
1743 else { 2325 else {
1744 bfa_assert(ioc->ioc_mc == BFI_MC_LL); 2326 WARN_ON(ioc->ioc_mc != BFI_MC_LL);
1745 return BFA_IOC_TYPE_LL; 2327 return BFA_IOC_TYPE_LL;
1746 } 2328 }
1747} 2329}
@@ -1749,8 +2331,8 @@ bfa_ioc_get_type(struct bfa_ioc_s *ioc)
1749void 2331void
1750bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num) 2332bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num)
1751{ 2333{
1752 bfa_os_memset((void *)serial_num, 0, BFA_ADAPTER_SERIAL_NUM_LEN); 2334 memset((void *)serial_num, 0, BFA_ADAPTER_SERIAL_NUM_LEN);
1753 bfa_os_memcpy((void *)serial_num, 2335 memcpy((void *)serial_num,
1754 (void *)ioc->attr->brcd_serialnum, 2336 (void *)ioc->attr->brcd_serialnum,
1755 BFA_ADAPTER_SERIAL_NUM_LEN); 2337 BFA_ADAPTER_SERIAL_NUM_LEN);
1756} 2338}
@@ -1758,16 +2340,16 @@ bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num)
1758void 2340void
1759bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver) 2341bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver)
1760{ 2342{
1761 bfa_os_memset((void *)fw_ver, 0, BFA_VERSION_LEN); 2343 memset((void *)fw_ver, 0, BFA_VERSION_LEN);
1762 bfa_os_memcpy(fw_ver, ioc->attr->fw_version, BFA_VERSION_LEN); 2344 memcpy(fw_ver, ioc->attr->fw_version, BFA_VERSION_LEN);
1763} 2345}
1764 2346
1765void 2347void
1766bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev) 2348bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev)
1767{ 2349{
1768 bfa_assert(chip_rev); 2350 WARN_ON(!chip_rev);
1769 2351
1770 bfa_os_memset((void *)chip_rev, 0, BFA_IOC_CHIP_REV_LEN); 2352 memset((void *)chip_rev, 0, BFA_IOC_CHIP_REV_LEN);
1771 2353
1772 chip_rev[0] = 'R'; 2354 chip_rev[0] = 'R';
1773 chip_rev[1] = 'e'; 2355 chip_rev[1] = 'e';
@@ -1780,45 +2362,79 @@ bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev)
1780void 2362void
1781bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc_s *ioc, char *optrom_ver) 2363bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc_s *ioc, char *optrom_ver)
1782{ 2364{
1783 bfa_os_memset((void *)optrom_ver, 0, BFA_VERSION_LEN); 2365 memset((void *)optrom_ver, 0, BFA_VERSION_LEN);
1784 bfa_os_memcpy(optrom_ver, ioc->attr->optrom_version, 2366 memcpy(optrom_ver, ioc->attr->optrom_version,
1785 BFA_VERSION_LEN); 2367 BFA_VERSION_LEN);
1786} 2368}
1787 2369
1788void 2370void
1789bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer) 2371bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer)
1790{ 2372{
1791 bfa_os_memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN); 2373 memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN);
1792 bfa_os_memcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN); 2374 memcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN);
1793} 2375}
1794 2376
1795void 2377void
1796bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model) 2378bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model)
1797{ 2379{
1798 struct bfi_ioc_attr_s *ioc_attr; 2380 struct bfi_ioc_attr_s *ioc_attr;
1799 2381
1800 bfa_assert(model); 2382 WARN_ON(!model);
1801 bfa_os_memset((void *)model, 0, BFA_ADAPTER_MODEL_NAME_LEN); 2383 memset((void *)model, 0, BFA_ADAPTER_MODEL_NAME_LEN);
1802 2384
1803 ioc_attr = ioc->attr; 2385 ioc_attr = ioc->attr;
1804 2386
1805 /** 2387 /*
1806 * model name 2388 * model name
1807 */ 2389 */
1808 snprintf(model, BFA_ADAPTER_MODEL_NAME_LEN, "%s-%u", 2390 snprintf(model, BFA_ADAPTER_MODEL_NAME_LEN, "%s-%u",
1809 BFA_MFG_NAME, ioc_attr->card_type); 2391 BFA_MFG_NAME, ioc_attr->card_type);
1810} 2392}
1811 2393
1812enum bfa_ioc_state 2394enum bfa_ioc_state
1813bfa_ioc_get_state(struct bfa_ioc_s *ioc) 2395bfa_ioc_get_state(struct bfa_ioc_s *ioc)
1814{ 2396{
1815 return bfa_sm_to_state(ioc_sm_table, ioc->fsm); 2397 enum bfa_iocpf_state iocpf_st;
2398 enum bfa_ioc_state ioc_st = bfa_sm_to_state(ioc_sm_table, ioc->fsm);
2399
2400 if (ioc_st == BFA_IOC_ENABLING ||
2401 ioc_st == BFA_IOC_FAIL || ioc_st == BFA_IOC_INITFAIL) {
2402
2403 iocpf_st = bfa_sm_to_state(iocpf_sm_table, ioc->iocpf.fsm);
2404
2405 switch (iocpf_st) {
2406 case BFA_IOCPF_SEMWAIT:
2407 ioc_st = BFA_IOC_SEMWAIT;
2408 break;
2409
2410 case BFA_IOCPF_HWINIT:
2411 ioc_st = BFA_IOC_HWINIT;
2412 break;
2413
2414 case BFA_IOCPF_FWMISMATCH:
2415 ioc_st = BFA_IOC_FWMISMATCH;
2416 break;
2417
2418 case BFA_IOCPF_FAIL:
2419 ioc_st = BFA_IOC_FAIL;
2420 break;
2421
2422 case BFA_IOCPF_INITFAIL:
2423 ioc_st = BFA_IOC_INITFAIL;
2424 break;
2425
2426 default:
2427 break;
2428 }
2429 }
2430
2431 return ioc_st;
1816} 2432}
1817 2433
1818void 2434void
1819bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr) 2435bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr)
1820{ 2436{
1821 bfa_os_memset((void *)ioc_attr, 0, sizeof(struct bfa_ioc_attr_s)); 2437 memset((void *)ioc_attr, 0, sizeof(struct bfa_ioc_attr_s));
1822 2438
1823 ioc_attr->state = bfa_ioc_get_state(ioc); 2439 ioc_attr->state = bfa_ioc_get_state(ioc);
1824 ioc_attr->port_id = ioc->port_id; 2440 ioc_attr->port_id = ioc->port_id;
@@ -1832,60 +2448,31 @@ bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr)
1832 bfa_ioc_get_pci_chip_rev(ioc, ioc_attr->pci_attr.chip_rev); 2448 bfa_ioc_get_pci_chip_rev(ioc, ioc_attr->pci_attr.chip_rev);
1833} 2449}
1834 2450
1835/**
1836 * bfa_wwn_public
1837 */
1838wwn_t
1839bfa_ioc_get_pwwn(struct bfa_ioc_s *ioc)
1840{
1841 return ioc->attr->pwwn;
1842}
1843
1844wwn_t
1845bfa_ioc_get_nwwn(struct bfa_ioc_s *ioc)
1846{
1847 return ioc->attr->nwwn;
1848}
1849
1850u64
1851bfa_ioc_get_adid(struct bfa_ioc_s *ioc)
1852{
1853 return ioc->attr->mfg_pwwn;
1854}
1855
1856mac_t 2451mac_t
1857bfa_ioc_get_mac(struct bfa_ioc_s *ioc) 2452bfa_ioc_get_mac(struct bfa_ioc_s *ioc)
1858{ 2453{
1859 /* 2454 /*
1860 * Currently mfg mac is used as FCoE enode mac (not configured by PBC) 2455 * Check the IOC type and return the appropriate MAC
1861 */ 2456 */
1862 if (bfa_ioc_get_type(ioc) == BFA_IOC_TYPE_FCoE) 2457 if (bfa_ioc_get_type(ioc) == BFA_IOC_TYPE_FCoE)
1863 return bfa_ioc_get_mfg_mac(ioc); 2458 return ioc->attr->fcoe_mac;
1864 else 2459 else
1865 return ioc->attr->mac; 2460 return ioc->attr->mac;
1866} 2461}
1867 2462
1868wwn_t
1869bfa_ioc_get_mfg_pwwn(struct bfa_ioc_s *ioc)
1870{
1871 return ioc->attr->mfg_pwwn;
1872}
1873
1874wwn_t
1875bfa_ioc_get_mfg_nwwn(struct bfa_ioc_s *ioc)
1876{
1877 return ioc->attr->mfg_nwwn;
1878}
1879
1880mac_t 2463mac_t
1881bfa_ioc_get_mfg_mac(struct bfa_ioc_s *ioc) 2464bfa_ioc_get_mfg_mac(struct bfa_ioc_s *ioc)
1882{ 2465{
1883 mac_t mac; 2466 mac_t m;
1884 2467
1885 mac = ioc->attr->mfg_mac; 2468 m = ioc->attr->mfg_mac;
1886 mac.mac[MAC_ADDRLEN - 1] += bfa_ioc_pcifn(ioc); 2469 if (bfa_mfg_is_old_wwn_mac_model(ioc->attr->card_type))
2470 m.mac[MAC_ADDRLEN - 1] += bfa_ioc_pcifn(ioc);
2471 else
2472 bfa_mfg_increment_wwn_mac(&(m.mac[MAC_ADDRLEN-3]),
2473 bfa_ioc_pcifn(ioc));
1887 2474
1888 return mac; 2475 return m;
1889} 2476}
1890 2477
1891bfa_boolean_t 2478bfa_boolean_t
@@ -1894,47 +2481,13 @@ bfa_ioc_get_fcmode(struct bfa_ioc_s *ioc)
1894 return ioc->fcmode || !bfa_asic_id_ct(ioc->pcidev.device_id); 2481 return ioc->fcmode || !bfa_asic_id_ct(ioc->pcidev.device_id);
1895} 2482}
1896 2483
1897/** 2484/*
1898 * Send AEN notification
1899 */
1900void
1901bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event)
1902{
1903 union bfa_aen_data_u aen_data;
1904 struct bfa_log_mod_s *logmod = ioc->logm;
1905 s32 inst_num = 0;
1906 enum bfa_ioc_type_e ioc_type;
1907
1908 bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, event), inst_num);
1909
1910 memset(&aen_data.ioc.pwwn, 0, sizeof(aen_data.ioc.pwwn));
1911 memset(&aen_data.ioc.mac, 0, sizeof(aen_data.ioc.mac));
1912 ioc_type = bfa_ioc_get_type(ioc);
1913 switch (ioc_type) {
1914 case BFA_IOC_TYPE_FC:
1915 aen_data.ioc.pwwn = bfa_ioc_get_pwwn(ioc);
1916 break;
1917 case BFA_IOC_TYPE_FCoE:
1918 aen_data.ioc.pwwn = bfa_ioc_get_pwwn(ioc);
1919 aen_data.ioc.mac = bfa_ioc_get_mac(ioc);
1920 break;
1921 case BFA_IOC_TYPE_LL:
1922 aen_data.ioc.mac = bfa_ioc_get_mac(ioc);
1923 break;
1924 default:
1925 bfa_assert(ioc_type == BFA_IOC_TYPE_FC);
1926 break;
1927 }
1928 aen_data.ioc.ioc_type = ioc_type;
1929}
1930
1931/**
1932 * Retrieve saved firmware trace from a prior IOC failure. 2485 * Retrieve saved firmware trace from a prior IOC failure.
1933 */ 2486 */
1934bfa_status_t 2487bfa_status_t
1935bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata, int *trclen) 2488bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata, int *trclen)
1936{ 2489{
1937 int tlen; 2490 int tlen;
1938 2491
1939 if (ioc->dbg_fwsave_len == 0) 2492 if (ioc->dbg_fwsave_len == 0)
1940 return BFA_STATUS_ENOFSAVE; 2493 return BFA_STATUS_ENOFSAVE;
@@ -1943,104 +2496,182 @@ bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata, int *trclen)
1943 if (tlen > ioc->dbg_fwsave_len) 2496 if (tlen > ioc->dbg_fwsave_len)
1944 tlen = ioc->dbg_fwsave_len; 2497 tlen = ioc->dbg_fwsave_len;
1945 2498
1946 bfa_os_memcpy(trcdata, ioc->dbg_fwsave, tlen); 2499 memcpy(trcdata, ioc->dbg_fwsave, tlen);
1947 *trclen = tlen; 2500 *trclen = tlen;
1948 return BFA_STATUS_OK; 2501 return BFA_STATUS_OK;
1949} 2502}
1950 2503
1951/**
1952 * Clear saved firmware trace
1953 */
1954void
1955bfa_ioc_debug_fwsave_clear(struct bfa_ioc_s *ioc)
1956{
1957 ioc->dbg_fwsave_once = BFA_TRUE;
1958}
1959 2504
1960/** 2505/*
1961 * Retrieve saved firmware trace from a prior IOC failure. 2506 * Retrieve saved firmware trace from a prior IOC failure.
1962 */ 2507 */
1963bfa_status_t 2508bfa_status_t
1964bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata, int *trclen) 2509bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata, int *trclen)
1965{ 2510{
1966 u32 pgnum; 2511 u32 loff = BFA_DBG_FWTRC_OFF(bfa_ioc_portid(ioc));
1967 u32 loff = BFA_DBG_FWTRC_OFF(bfa_ioc_portid(ioc)); 2512 int tlen;
1968 int i, tlen; 2513 bfa_status_t status;
1969 u32 *tbuf = trcdata, r32;
1970 2514
1971 bfa_trc(ioc, *trclen); 2515 bfa_trc(ioc, *trclen);
1972 2516
1973 pgnum = bfa_ioc_smem_pgnum(ioc, loff);
1974 loff = bfa_ioc_smem_pgoff(ioc, loff);
1975
1976 /*
1977 * Hold semaphore to serialize pll init and fwtrc.
1978 */
1979 if (BFA_FALSE == bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg))
1980 return BFA_STATUS_FAILED;
1981
1982 bfa_reg_write(ioc->ioc_regs.host_page_num_fn, pgnum);
1983
1984 tlen = *trclen; 2517 tlen = *trclen;
1985 if (tlen > BFA_DBG_FWTRC_LEN) 2518 if (tlen > BFA_DBG_FWTRC_LEN)
1986 tlen = BFA_DBG_FWTRC_LEN; 2519 tlen = BFA_DBG_FWTRC_LEN;
1987 tlen /= sizeof(u32);
1988 2520
1989 bfa_trc(ioc, tlen); 2521 status = bfa_ioc_smem_read(ioc, trcdata, loff, tlen);
2522 *trclen = tlen;
2523 return status;
2524}
1990 2525
1991 for (i = 0; i < tlen; i++) { 2526static void
1992 r32 = bfa_mem_read(ioc->ioc_regs.smem_page_start, loff); 2527bfa_ioc_send_fwsync(struct bfa_ioc_s *ioc)
1993 tbuf[i] = bfa_os_ntohl(r32); 2528{
1994 loff += sizeof(u32); 2529 struct bfa_mbox_cmd_s cmd;
2530 struct bfi_ioc_ctrl_req_s *req = (struct bfi_ioc_ctrl_req_s *) cmd.msg;
1995 2531
1996 /** 2532 bfi_h2i_set(req->mh, BFI_MC_IOC, BFI_IOC_H2I_DBG_SYNC,
1997 * handle page offset wrap around 2533 bfa_ioc_portid(ioc));
1998 */ 2534 req->ioc_class = ioc->ioc_mc;
1999 loff = PSS_SMEM_PGOFF(loff); 2535 bfa_ioc_mbox_queue(ioc, &cmd);
2000 if (loff == 0) { 2536}
2001 pgnum++; 2537
2002 bfa_reg_write(ioc->ioc_regs.host_page_num_fn, pgnum); 2538static void
2003 } 2539bfa_ioc_fwsync(struct bfa_ioc_s *ioc)
2540{
2541 u32 fwsync_iter = 1000;
2542
2543 bfa_ioc_send_fwsync(ioc);
2544
2545 /*
2546 * After sending a fw sync mbox command wait for it to
2547 * take effect. We will not wait for a response because
2548 * 1. fw_sync mbox cmd doesn't have a response.
2549 * 2. Even if we implement that, interrupts might not
2550 * be enabled when we call this function.
2551 * So, just keep checking if any mbox cmd is pending, and
2552 * after waiting for a reasonable amount of time, go ahead.
2553 * It is possible that fw has crashed and the mbox command
2554 * is never acknowledged.
2555 */
2556 while (bfa_ioc_mbox_cmd_pending(ioc) && fwsync_iter > 0)
2557 fwsync_iter--;
2558}
2559
2560/*
2561 * Dump firmware smem
2562 */
2563bfa_status_t
2564bfa_ioc_debug_fwcore(struct bfa_ioc_s *ioc, void *buf,
2565 u32 *offset, int *buflen)
2566{
2567 u32 loff;
2568 int dlen;
2569 bfa_status_t status;
2570 u32 smem_len = BFA_IOC_FW_SMEM_SIZE(ioc);
2571
2572 if (*offset >= smem_len) {
2573 *offset = *buflen = 0;
2574 return BFA_STATUS_EINVAL;
2004 } 2575 }
2005 bfa_reg_write(ioc->ioc_regs.host_page_num_fn, 2576
2006 bfa_ioc_smem_pgnum(ioc, 0)); 2577 loff = *offset;
2578 dlen = *buflen;
2007 2579
2008 /* 2580 /*
2009 * release semaphore. 2581 * First smem read, sync smem before proceeding
2582 * No need to sync before reading every chunk.
2010 */ 2583 */
2011 bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg); 2584 if (loff == 0)
2585 bfa_ioc_fwsync(ioc);
2012 2586
2013 bfa_trc(ioc, pgnum); 2587 if ((loff + dlen) >= smem_len)
2588 dlen = smem_len - loff;
2014 2589
2015 *trclen = tlen * sizeof(u32); 2590 status = bfa_ioc_smem_read(ioc, buf, loff, dlen);
2016 return BFA_STATUS_OK; 2591
2592 if (status != BFA_STATUS_OK) {
2593 *offset = *buflen = 0;
2594 return status;
2595 }
2596
2597 *offset += dlen;
2598
2599 if (*offset >= smem_len)
2600 *offset = 0;
2601
2602 *buflen = dlen;
2603
2604 return status;
2017} 2605}
2018 2606
2019/** 2607/*
2020 * Save firmware trace if configured. 2608 * Firmware statistics
2021 */ 2609 */
2022static void 2610bfa_status_t
2023bfa_ioc_debug_save(struct bfa_ioc_s *ioc) 2611bfa_ioc_fw_stats_get(struct bfa_ioc_s *ioc, void *stats)
2024{ 2612{
2025 int tlen; 2613 u32 loff = BFI_IOC_FWSTATS_OFF + \
2614 BFI_IOC_FWSTATS_SZ * (bfa_ioc_portid(ioc));
2615 int tlen;
2616 bfa_status_t status;
2026 2617
2027 if (ioc->dbg_fwsave_len) { 2618 if (ioc->stats_busy) {
2028 tlen = ioc->dbg_fwsave_len; 2619 bfa_trc(ioc, ioc->stats_busy);
2029 bfa_ioc_debug_fwtrc(ioc, ioc->dbg_fwsave, &tlen); 2620 return BFA_STATUS_DEVBUSY;
2030 } 2621 }
2622 ioc->stats_busy = BFA_TRUE;
2623
2624 tlen = sizeof(struct bfa_fw_stats_s);
2625 status = bfa_ioc_smem_read(ioc, stats, loff, tlen);
2626
2627 ioc->stats_busy = BFA_FALSE;
2628 return status;
2031} 2629}
2032 2630
2033/** 2631bfa_status_t
2034 * Firmware failure detected. Start recovery actions. 2632bfa_ioc_fw_stats_clear(struct bfa_ioc_s *ioc)
2633{
2634 u32 loff = BFI_IOC_FWSTATS_OFF + \
2635 BFI_IOC_FWSTATS_SZ * (bfa_ioc_portid(ioc));
2636 int tlen;
2637 bfa_status_t status;
2638
2639 if (ioc->stats_busy) {
2640 bfa_trc(ioc, ioc->stats_busy);
2641 return BFA_STATUS_DEVBUSY;
2642 }
2643 ioc->stats_busy = BFA_TRUE;
2644
2645 tlen = sizeof(struct bfa_fw_stats_s);
2646 status = bfa_ioc_smem_clr(ioc, loff, tlen);
2647
2648 ioc->stats_busy = BFA_FALSE;
2649 return status;
2650}
2651
2652/*
2653 * Save firmware trace if configured.
2035 */ 2654 */
2036static void 2655static void
2037bfa_ioc_recover(struct bfa_ioc_s *ioc) 2656bfa_ioc_debug_save_ftrc(struct bfa_ioc_s *ioc)
2038{ 2657{
2658 int tlen;
2659
2039 if (ioc->dbg_fwsave_once) { 2660 if (ioc->dbg_fwsave_once) {
2040 ioc->dbg_fwsave_once = BFA_FALSE; 2661 ioc->dbg_fwsave_once = BFA_FALSE;
2041 bfa_ioc_debug_save(ioc); 2662 if (ioc->dbg_fwsave_len) {
2663 tlen = ioc->dbg_fwsave_len;
2664 bfa_ioc_debug_fwtrc(ioc, ioc->dbg_fwsave, &tlen);
2665 }
2042 } 2666 }
2667}
2043 2668
2669/*
2670 * Firmware failure detected. Start recovery actions.
2671 */
2672static void
2673bfa_ioc_recover(struct bfa_ioc_s *ioc)
2674{
2044 bfa_ioc_stats(ioc, ioc_hbfails); 2675 bfa_ioc_stats(ioc, ioc_hbfails);
2045 bfa_fsm_send_event(ioc, IOC_E_HBFAIL); 2676 bfa_fsm_send_event(ioc, IOC_E_HBFAIL);
2046} 2677}
@@ -2050,11 +2681,92 @@ bfa_ioc_check_attr_wwns(struct bfa_ioc_s *ioc)
2050{ 2681{
2051 if (bfa_ioc_get_type(ioc) == BFA_IOC_TYPE_LL) 2682 if (bfa_ioc_get_type(ioc) == BFA_IOC_TYPE_LL)
2052 return; 2683 return;
2684}
2053 2685
2054 if (ioc->attr->nwwn == 0) 2686/*
2055 bfa_ioc_aen_post(ioc, BFA_IOC_AEN_INVALID_NWWN); 2687 * BFA IOC PF private functions
2056 if (ioc->attr->pwwn == 0) 2688 */
2057 bfa_ioc_aen_post(ioc, BFA_IOC_AEN_INVALID_PWWN); 2689static void
2690bfa_iocpf_timeout(void *ioc_arg)
2691{
2692 struct bfa_ioc_s *ioc = (struct bfa_ioc_s *) ioc_arg;
2693
2694 bfa_trc(ioc, 0);
2695 bfa_fsm_send_event(&ioc->iocpf, IOCPF_E_TIMEOUT);
2696}
2697
2698static void
2699bfa_iocpf_sem_timeout(void *ioc_arg)
2700{
2701 struct bfa_ioc_s *ioc = (struct bfa_ioc_s *) ioc_arg;
2702
2703 bfa_ioc_hw_sem_get(ioc);
2058} 2704}
2059 2705
2060#endif 2706/*
2707 * bfa timer function
2708 */
2709void
2710bfa_timer_beat(struct bfa_timer_mod_s *mod)
2711{
2712 struct list_head *qh = &mod->timer_q;
2713 struct list_head *qe, *qe_next;
2714 struct bfa_timer_s *elem;
2715 struct list_head timedout_q;
2716
2717 INIT_LIST_HEAD(&timedout_q);
2718
2719 qe = bfa_q_next(qh);
2720
2721 while (qe != qh) {
2722 qe_next = bfa_q_next(qe);
2723
2724 elem = (struct bfa_timer_s *) qe;
2725 if (elem->timeout <= BFA_TIMER_FREQ) {
2726 elem->timeout = 0;
2727 list_del(&elem->qe);
2728 list_add_tail(&elem->qe, &timedout_q);
2729 } else {
2730 elem->timeout -= BFA_TIMER_FREQ;
2731 }
2732
2733 qe = qe_next; /* go to next elem */
2734 }
2735
2736 /*
2737 * Pop all the timeout entries
2738 */
2739 while (!list_empty(&timedout_q)) {
2740 bfa_q_deq(&timedout_q, &elem);
2741 elem->timercb(elem->arg);
2742 }
2743}
2744
2745/*
2746 * Should be called with lock protection
2747 */
2748void
2749bfa_timer_begin(struct bfa_timer_mod_s *mod, struct bfa_timer_s *timer,
2750 void (*timercb) (void *), void *arg, unsigned int timeout)
2751{
2752
2753 WARN_ON(timercb == NULL);
2754 WARN_ON(bfa_q_is_on_q(&mod->timer_q, timer));
2755
2756 timer->timeout = timeout;
2757 timer->timercb = timercb;
2758 timer->arg = arg;
2759
2760 list_add_tail(&timer->qe, &mod->timer_q);
2761}
2762
2763/*
2764 * Should be called with lock protection
2765 */
2766void
2767bfa_timer_stop(struct bfa_timer_s *timer)
2768{
2769 WARN_ON(list_empty(&timer->qe));
2770
2771 list_del(&timer->qe);
2772}
diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
index cae05b251c99..c85182a704fb 100644
--- a/drivers/scsi/bfa/bfa_ioc.h
+++ b/drivers/scsi/bfa/bfa_ioc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -18,34 +18,99 @@
18#ifndef __BFA_IOC_H__ 18#ifndef __BFA_IOC_H__
19#define __BFA_IOC_H__ 19#define __BFA_IOC_H__
20 20
21#include <cs/bfa_sm.h> 21#include "bfad_drv.h"
22#include <bfi/bfi.h> 22#include "bfa_cs.h"
23#include <bfi/bfi_ioc.h> 23#include "bfi.h"
24#include <bfi/bfi_boot.h>
25#include <bfa_timer.h>
26 24
27/** 25#define BFA_DBG_FWTRC_ENTS (BFI_IOC_TRC_ENTS)
26#define BFA_DBG_FWTRC_LEN \
27 (BFA_DBG_FWTRC_ENTS * sizeof(struct bfa_trc_s) + \
28 (sizeof(struct bfa_trc_mod_s) - \
29 BFA_TRC_MAX * sizeof(struct bfa_trc_s)))
30/*
31 * BFA timer declarations
32 */
33typedef void (*bfa_timer_cbfn_t)(void *);
34
35/*
36 * BFA timer data structure
37 */
38struct bfa_timer_s {
39 struct list_head qe;
40 bfa_timer_cbfn_t timercb;
41 void *arg;
42 int timeout; /* in millisecs */
43};
44
45/*
46 * Timer module structure
47 */
48struct bfa_timer_mod_s {
49 struct list_head timer_q;
50};
51
52#define BFA_TIMER_FREQ 200 /* specified in millisecs */
53
54void bfa_timer_beat(struct bfa_timer_mod_s *mod);
55void bfa_timer_begin(struct bfa_timer_mod_s *mod, struct bfa_timer_s *timer,
56 bfa_timer_cbfn_t timercb, void *arg,
57 unsigned int timeout);
58void bfa_timer_stop(struct bfa_timer_s *timer);
59
60/*
61 * Generic Scatter Gather Element used by driver
62 */
63struct bfa_sge_s {
64 u32 sg_len;
65 void *sg_addr;
66};
67
68#define bfa_sge_word_swap(__sge) do { \
69 ((u32 *)(__sge))[0] = swab32(((u32 *)(__sge))[0]); \
70 ((u32 *)(__sge))[1] = swab32(((u32 *)(__sge))[1]); \
71 ((u32 *)(__sge))[2] = swab32(((u32 *)(__sge))[2]); \
72} while (0)
73
74#define bfa_swap_words(_x) ( \
75 ((_x) << 32) | ((_x) >> 32))
76
77#ifdef __BIG_ENDIAN
78#define bfa_sge_to_be(_x)
79#define bfa_sge_to_le(_x) bfa_sge_word_swap(_x)
80#define bfa_sgaddr_le(_x) bfa_swap_words(_x)
81#else
82#define bfa_sge_to_be(_x) bfa_sge_word_swap(_x)
83#define bfa_sge_to_le(_x)
84#define bfa_sgaddr_le(_x) (_x)
85#endif
86
87/*
28 * PCI device information required by IOC 88 * PCI device information required by IOC
29 */ 89 */
30struct bfa_pcidev_s { 90struct bfa_pcidev_s {
31 int pci_slot; 91 int pci_slot;
32 u8 pci_func; 92 u8 pci_func;
33 u16 device_id; 93 u16 device_id;
34 bfa_os_addr_t pci_bar_kva; 94 void __iomem *pci_bar_kva;
35}; 95};
36 96
37/** 97/*
38 * Structure used to remember the DMA-able memory block's KVA and Physical 98 * Structure used to remember the DMA-able memory block's KVA and Physical
39 * Address 99 * Address
40 */ 100 */
41struct bfa_dma_s { 101struct bfa_dma_s {
42 void *kva; /*! Kernel virtual address */ 102 void *kva; /* ! Kernel virtual address */
43 u64 pa; /*! Physical address */ 103 u64 pa; /* ! Physical address */
44}; 104};
45 105
46#define BFA_DMA_ALIGN_SZ 256 106#define BFA_DMA_ALIGN_SZ 256
47#define BFA_ROUNDUP(_l, _s) (((_l) + ((_s) - 1)) & ~((_s) - 1)) 107#define BFA_ROUNDUP(_l, _s) (((_l) + ((_s) - 1)) & ~((_s) - 1))
48 108
109/*
110 * smem size for Crossbow and Catapult
111 */
112#define BFI_SMEM_CB_SIZE 0x200000U /* ! 2MB for crossbow */
113#define BFI_SMEM_CT_SIZE 0x280000U /* ! 2.5MB for catapult */
49 114
50 115
51#define bfa_dma_addr_set(dma_addr, pa) \ 116#define bfa_dma_addr_set(dma_addr, pa) \
@@ -54,8 +119,8 @@ struct bfa_dma_s {
54static inline void 119static inline void
55__bfa_dma_addr_set(union bfi_addr_u *dma_addr, u64 pa) 120__bfa_dma_addr_set(union bfi_addr_u *dma_addr, u64 pa)
56{ 121{
57 dma_addr->a32.addr_lo = (u32) pa; 122 dma_addr->a32.addr_lo = (__be32) pa;
58 dma_addr->a32.addr_hi = (u32) (bfa_os_u32(pa)); 123 dma_addr->a32.addr_hi = (__be32) (pa >> 32);
59} 124}
60 125
61 126
@@ -64,61 +129,62 @@ __bfa_dma_addr_set(union bfi_addr_u *dma_addr, u64 pa)
64static inline void 129static inline void
65__bfa_dma_be_addr_set(union bfi_addr_u *dma_addr, u64 pa) 130__bfa_dma_be_addr_set(union bfi_addr_u *dma_addr, u64 pa)
66{ 131{
67 dma_addr->a32.addr_lo = (u32) bfa_os_htonl(pa); 132 dma_addr->a32.addr_lo = cpu_to_be32(pa);
68 dma_addr->a32.addr_hi = (u32) bfa_os_htonl(bfa_os_u32(pa)); 133 dma_addr->a32.addr_hi = cpu_to_be32(pa >> 32);
69} 134}
70 135
71struct bfa_ioc_regs_s { 136struct bfa_ioc_regs_s {
72 bfa_os_addr_t hfn_mbox_cmd; 137 void __iomem *hfn_mbox_cmd;
73 bfa_os_addr_t hfn_mbox; 138 void __iomem *hfn_mbox;
74 bfa_os_addr_t lpu_mbox_cmd; 139 void __iomem *lpu_mbox_cmd;
75 bfa_os_addr_t lpu_mbox; 140 void __iomem *lpu_mbox;
76 bfa_os_addr_t pss_ctl_reg; 141 void __iomem *pss_ctl_reg;
77 bfa_os_addr_t pss_err_status_reg; 142 void __iomem *pss_err_status_reg;
78 bfa_os_addr_t app_pll_fast_ctl_reg; 143 void __iomem *app_pll_fast_ctl_reg;
79 bfa_os_addr_t app_pll_slow_ctl_reg; 144 void __iomem *app_pll_slow_ctl_reg;
80 bfa_os_addr_t ioc_sem_reg; 145 void __iomem *ioc_sem_reg;
81 bfa_os_addr_t ioc_usage_sem_reg; 146 void __iomem *ioc_usage_sem_reg;
82 bfa_os_addr_t ioc_init_sem_reg; 147 void __iomem *ioc_init_sem_reg;
83 bfa_os_addr_t ioc_usage_reg; 148 void __iomem *ioc_usage_reg;
84 bfa_os_addr_t host_page_num_fn; 149 void __iomem *host_page_num_fn;
85 bfa_os_addr_t heartbeat; 150 void __iomem *heartbeat;
86 bfa_os_addr_t ioc_fwstate; 151 void __iomem *ioc_fwstate;
87 bfa_os_addr_t ll_halt; 152 void __iomem *alt_ioc_fwstate;
88 bfa_os_addr_t err_set; 153 void __iomem *ll_halt;
89 bfa_os_addr_t shirq_isr_next; 154 void __iomem *alt_ll_halt;
90 bfa_os_addr_t shirq_msk_next; 155 void __iomem *err_set;
91 bfa_os_addr_t smem_page_start; 156 void __iomem *ioc_fail_sync;
157 void __iomem *shirq_isr_next;
158 void __iomem *shirq_msk_next;
159 void __iomem *smem_page_start;
92 u32 smem_pg0; 160 u32 smem_pg0;
93}; 161};
94 162
95#define bfa_reg_read(_raddr) bfa_os_reg_read(_raddr) 163#define bfa_mem_read(_raddr, _off) swab32(readl(((_raddr) + (_off))))
96#define bfa_reg_write(_raddr, _val) bfa_os_reg_write(_raddr, _val)
97#define bfa_mem_read(_raddr, _off) bfa_os_mem_read(_raddr, _off)
98#define bfa_mem_write(_raddr, _off, _val) \ 164#define bfa_mem_write(_raddr, _off, _val) \
99 bfa_os_mem_write(_raddr, _off, _val) 165 writel(swab32((_val)), ((_raddr) + (_off)))
100/** 166/*
101 * IOC Mailbox structures 167 * IOC Mailbox structures
102 */ 168 */
103struct bfa_mbox_cmd_s { 169struct bfa_mbox_cmd_s {
104 struct list_head qe; 170 struct list_head qe;
105 u32 msg[BFI_IOC_MSGSZ]; 171 u32 msg[BFI_IOC_MSGSZ];
106}; 172};
107 173
108/** 174/*
109 * IOC mailbox module 175 * IOC mailbox module
110 */ 176 */
111typedef void (*bfa_ioc_mbox_mcfunc_t)(void *cbarg, struct bfi_mbmsg_s *m); 177typedef void (*bfa_ioc_mbox_mcfunc_t)(void *cbarg, struct bfi_mbmsg_s *m);
112struct bfa_ioc_mbox_mod_s { 178struct bfa_ioc_mbox_mod_s {
113 struct list_head cmd_q; /* pending mbox queue */ 179 struct list_head cmd_q; /* pending mbox queue */
114 int nmclass; /* number of handlers */ 180 int nmclass; /* number of handlers */
115 struct { 181 struct {
116 bfa_ioc_mbox_mcfunc_t cbfn; /* message handlers */ 182 bfa_ioc_mbox_mcfunc_t cbfn; /* message handlers */
117 void *cbarg; 183 void *cbarg;
118 } mbhdlr[BFI_MC_MAX]; 184 } mbhdlr[BFI_MC_MAX];
119}; 185};
120 186
121/** 187/*
122 * IOC callback function interfaces 188 * IOC callback function interfaces
123 */ 189 */
124typedef void (*bfa_ioc_enable_cbfn_t)(void *bfa, enum bfa_status status); 190typedef void (*bfa_ioc_enable_cbfn_t)(void *bfa, enum bfa_status status);
@@ -132,7 +198,7 @@ struct bfa_ioc_cbfn_s {
132 bfa_ioc_reset_cbfn_t reset_cbfn; 198 bfa_ioc_reset_cbfn_t reset_cbfn;
133}; 199};
134 200
135/** 201/*
136 * Heartbeat failure notification queue element. 202 * Heartbeat failure notification queue element.
137 */ 203 */
138struct bfa_ioc_hbfail_notify_s { 204struct bfa_ioc_hbfail_notify_s {
@@ -141,7 +207,7 @@ struct bfa_ioc_hbfail_notify_s {
141 void *cbarg; 207 void *cbarg;
142}; 208};
143 209
144/** 210/*
145 * Initialize a heartbeat failure notification structure 211 * Initialize a heartbeat failure notification structure
146 */ 212 */
147#define bfa_ioc_hbfail_init(__notify, __cbfn, __cbarg) do { \ 213#define bfa_ioc_hbfail_init(__notify, __cbfn, __cbarg) do { \
@@ -149,49 +215,59 @@ struct bfa_ioc_hbfail_notify_s {
149 (__notify)->cbarg = (__cbarg); \ 215 (__notify)->cbarg = (__cbarg); \
150} while (0) 216} while (0)
151 217
218struct bfa_iocpf_s {
219 bfa_fsm_t fsm;
220 struct bfa_ioc_s *ioc;
221 u32 retry_count;
222 bfa_boolean_t auto_recover;
223};
224
152struct bfa_ioc_s { 225struct bfa_ioc_s {
153 bfa_fsm_t fsm; 226 bfa_fsm_t fsm;
154 struct bfa_s *bfa; 227 struct bfa_s *bfa;
155 struct bfa_pcidev_s pcidev; 228 struct bfa_pcidev_s pcidev;
156 struct bfa_timer_mod_s *timer_mod; 229 struct bfa_timer_mod_s *timer_mod;
157 struct bfa_timer_s ioc_timer; 230 struct bfa_timer_s ioc_timer;
158 struct bfa_timer_s sem_timer; 231 struct bfa_timer_s sem_timer;
232 struct bfa_timer_s hb_timer;
159 u32 hb_count; 233 u32 hb_count;
160 u32 retry_count;
161 struct list_head hb_notify_q; 234 struct list_head hb_notify_q;
162 void *dbg_fwsave; 235 void *dbg_fwsave;
163 int dbg_fwsave_len; 236 int dbg_fwsave_len;
164 bfa_boolean_t dbg_fwsave_once; 237 bfa_boolean_t dbg_fwsave_once;
165 enum bfi_mclass ioc_mc; 238 enum bfi_mclass ioc_mc;
166 struct bfa_ioc_regs_s ioc_regs; 239 struct bfa_ioc_regs_s ioc_regs;
167 struct bfa_trc_mod_s *trcmod; 240 struct bfa_trc_mod_s *trcmod;
168 struct bfa_aen_s *aen;
169 struct bfa_log_mod_s *logm;
170 struct bfa_ioc_drv_stats_s stats; 241 struct bfa_ioc_drv_stats_s stats;
171 bfa_boolean_t auto_recover;
172 bfa_boolean_t fcmode; 242 bfa_boolean_t fcmode;
173 bfa_boolean_t ctdev; 243 bfa_boolean_t ctdev;
174 bfa_boolean_t cna; 244 bfa_boolean_t cna;
175 bfa_boolean_t pllinit; 245 bfa_boolean_t pllinit;
246 bfa_boolean_t stats_busy; /* outstanding stats */
176 u8 port_id; 247 u8 port_id;
177
178 struct bfa_dma_s attr_dma; 248 struct bfa_dma_s attr_dma;
179 struct bfi_ioc_attr_s *attr; 249 struct bfi_ioc_attr_s *attr;
180 struct bfa_ioc_cbfn_s *cbfn; 250 struct bfa_ioc_cbfn_s *cbfn;
181 struct bfa_ioc_mbox_mod_s mbox_mod; 251 struct bfa_ioc_mbox_mod_s mbox_mod;
182 struct bfa_ioc_hwif_s *ioc_hwif; 252 struct bfa_ioc_hwif_s *ioc_hwif;
253 struct bfa_iocpf_s iocpf;
183}; 254};
184 255
185struct bfa_ioc_hwif_s { 256struct bfa_ioc_hwif_s {
186 bfa_status_t (*ioc_pll_init) (struct bfa_ioc_s *ioc); 257 bfa_status_t (*ioc_pll_init) (void __iomem *rb, bfa_boolean_t fcmode);
187 bfa_boolean_t (*ioc_firmware_lock) (struct bfa_ioc_s *ioc); 258 bfa_boolean_t (*ioc_firmware_lock) (struct bfa_ioc_s *ioc);
188 void (*ioc_firmware_unlock) (struct bfa_ioc_s *ioc); 259 void (*ioc_firmware_unlock) (struct bfa_ioc_s *ioc);
189 void (*ioc_reg_init) (struct bfa_ioc_s *ioc); 260 void (*ioc_reg_init) (struct bfa_ioc_s *ioc);
190 void (*ioc_map_port) (struct bfa_ioc_s *ioc); 261 void (*ioc_map_port) (struct bfa_ioc_s *ioc);
191 void (*ioc_isr_mode_set) (struct bfa_ioc_s *ioc, 262 void (*ioc_isr_mode_set) (struct bfa_ioc_s *ioc,
192 bfa_boolean_t msix); 263 bfa_boolean_t msix);
193 void (*ioc_notify_hbfail) (struct bfa_ioc_s *ioc); 264 void (*ioc_notify_fail) (struct bfa_ioc_s *ioc);
194 void (*ioc_ownership_reset) (struct bfa_ioc_s *ioc); 265 void (*ioc_ownership_reset) (struct bfa_ioc_s *ioc);
266 bfa_boolean_t (*ioc_sync_start) (struct bfa_ioc_s *ioc);
267 void (*ioc_sync_join) (struct bfa_ioc_s *ioc);
268 void (*ioc_sync_leave) (struct bfa_ioc_s *ioc);
269 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
270 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
195}; 271};
196 272
197#define bfa_ioc_pcifn(__ioc) ((__ioc)->pcidev.pci_func) 273#define bfa_ioc_pcifn(__ioc) ((__ioc)->pcidev.pci_func)
@@ -201,26 +277,27 @@ struct bfa_ioc_hwif_s {
201#define bfa_ioc_fetch_stats(__ioc, __stats) \ 277#define bfa_ioc_fetch_stats(__ioc, __stats) \
202 (((__stats)->drv_stats) = (__ioc)->stats) 278 (((__stats)->drv_stats) = (__ioc)->stats)
203#define bfa_ioc_clr_stats(__ioc) \ 279#define bfa_ioc_clr_stats(__ioc) \
204 bfa_os_memset(&(__ioc)->stats, 0, sizeof((__ioc)->stats)) 280 memset(&(__ioc)->stats, 0, sizeof((__ioc)->stats))
205#define bfa_ioc_maxfrsize(__ioc) ((__ioc)->attr->maxfrsize) 281#define bfa_ioc_maxfrsize(__ioc) ((__ioc)->attr->maxfrsize)
206#define bfa_ioc_rx_bbcredit(__ioc) ((__ioc)->attr->rx_bbcredit) 282#define bfa_ioc_rx_bbcredit(__ioc) ((__ioc)->attr->rx_bbcredit)
207#define bfa_ioc_speed_sup(__ioc) \ 283#define bfa_ioc_speed_sup(__ioc) \
208 BFI_ADAPTER_GETP(SPEED, (__ioc)->attr->adapter_prop) 284 BFI_ADAPTER_GETP(SPEED, (__ioc)->attr->adapter_prop)
209#define bfa_ioc_get_nports(__ioc) \ 285#define bfa_ioc_get_nports(__ioc) \
210 BFI_ADAPTER_GETP(NPORTS, (__ioc)->attr->adapter_prop) 286 BFI_ADAPTER_GETP(NPORTS, (__ioc)->attr->adapter_prop)
211 287
212#define bfa_ioc_stats(_ioc, _stats) ((_ioc)->stats._stats++) 288#define bfa_ioc_stats(_ioc, _stats) ((_ioc)->stats._stats++)
213#define BFA_IOC_FWIMG_MINSZ (16 * 1024) 289#define BFA_IOC_FWIMG_MINSZ (16 * 1024)
214#define BFA_IOC_FWIMG_TYPE(__ioc) \ 290#define BFA_IOC_FWIMG_TYPE(__ioc) \
215 (((__ioc)->ctdev) ? \ 291 (((__ioc)->ctdev) ? \
216 (((__ioc)->fcmode) ? BFI_IMAGE_CT_FC : BFI_IMAGE_CT_CNA) : \ 292 (((__ioc)->fcmode) ? BFI_IMAGE_CT_FC : BFI_IMAGE_CT_CNA) : \
217 BFI_IMAGE_CB_FC) 293 BFI_IMAGE_CB_FC)
218 294#define BFA_IOC_FW_SMEM_SIZE(__ioc) \
219#define BFA_IOC_FLASH_CHUNK_NO(off) (off / BFI_FLASH_CHUNK_SZ_WORDS) 295 (((__ioc)->ctdev) ? BFI_SMEM_CT_SIZE : BFI_SMEM_CB_SIZE)
220#define BFA_IOC_FLASH_OFFSET_IN_CHUNK(off) (off % BFI_FLASH_CHUNK_SZ_WORDS) 296#define BFA_IOC_FLASH_CHUNK_NO(off) (off / BFI_FLASH_CHUNK_SZ_WORDS)
297#define BFA_IOC_FLASH_OFFSET_IN_CHUNK(off) (off % BFI_FLASH_CHUNK_SZ_WORDS)
221#define BFA_IOC_FLASH_CHUNK_ADDR(chunkno) (chunkno * BFI_FLASH_CHUNK_SZ_WORDS) 298#define BFA_IOC_FLASH_CHUNK_ADDR(chunkno) (chunkno * BFI_FLASH_CHUNK_SZ_WORDS)
222 299
223/** 300/*
224 * IOC mailbox interface 301 * IOC mailbox interface
225 */ 302 */
226void bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd); 303void bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd);
@@ -232,83 +309,147 @@ void bfa_ioc_msgget(struct bfa_ioc_s *ioc, void *mbmsg);
232void bfa_ioc_mbox_regisr(struct bfa_ioc_s *ioc, enum bfi_mclass mc, 309void bfa_ioc_mbox_regisr(struct bfa_ioc_s *ioc, enum bfi_mclass mc,
233 bfa_ioc_mbox_mcfunc_t cbfn, void *cbarg); 310 bfa_ioc_mbox_mcfunc_t cbfn, void *cbarg);
234 311
235/** 312/*
236 * IOC interfaces 313 * IOC interfaces
237 */ 314 */
238#define bfa_ioc_pll_init(__ioc) ((__ioc)->ioc_hwif->ioc_pll_init(__ioc)) 315
239#define bfa_ioc_isr_mode_set(__ioc, __msix) \ 316#define bfa_ioc_pll_init_asic(__ioc) \
317 ((__ioc)->ioc_hwif->ioc_pll_init((__ioc)->pcidev.pci_bar_kva, \
318 (__ioc)->fcmode))
319
320bfa_status_t bfa_ioc_pll_init(struct bfa_ioc_s *ioc);
321bfa_status_t bfa_ioc_cb_pll_init(void __iomem *rb, bfa_boolean_t fcmode);
322bfa_boolean_t bfa_ioc_ct_pll_init_complete(void __iomem *rb);
323bfa_status_t bfa_ioc_ct_pll_init(void __iomem *rb, bfa_boolean_t fcmode);
324
325#define bfa_ioc_isr_mode_set(__ioc, __msix) \
240 ((__ioc)->ioc_hwif->ioc_isr_mode_set(__ioc, __msix)) 326 ((__ioc)->ioc_hwif->ioc_isr_mode_set(__ioc, __msix))
241#define bfa_ioc_ownership_reset(__ioc) \ 327#define bfa_ioc_ownership_reset(__ioc) \
242 ((__ioc)->ioc_hwif->ioc_ownership_reset(__ioc)) 328 ((__ioc)->ioc_hwif->ioc_ownership_reset(__ioc))
243 329
330
244void bfa_ioc_set_ct_hwif(struct bfa_ioc_s *ioc); 331void bfa_ioc_set_ct_hwif(struct bfa_ioc_s *ioc);
245void bfa_ioc_set_cb_hwif(struct bfa_ioc_s *ioc); 332void bfa_ioc_set_cb_hwif(struct bfa_ioc_s *ioc);
333
246void bfa_ioc_attach(struct bfa_ioc_s *ioc, void *bfa, 334void bfa_ioc_attach(struct bfa_ioc_s *ioc, void *bfa,
247 struct bfa_ioc_cbfn_s *cbfn, struct bfa_timer_mod_s *timer_mod, 335 struct bfa_ioc_cbfn_s *cbfn, struct bfa_timer_mod_s *timer_mod);
248 struct bfa_trc_mod_s *trcmod, 336void bfa_ioc_auto_recover(bfa_boolean_t auto_recover);
249 struct bfa_aen_s *aen, struct bfa_log_mod_s *logm);
250void bfa_ioc_detach(struct bfa_ioc_s *ioc); 337void bfa_ioc_detach(struct bfa_ioc_s *ioc);
251void bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct bfa_pcidev_s *pcidev, 338void bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct bfa_pcidev_s *pcidev,
252 enum bfi_mclass mc); 339 enum bfi_mclass mc);
253u32 bfa_ioc_meminfo(void);
254void bfa_ioc_mem_claim(struct bfa_ioc_s *ioc, u8 *dm_kva, u64 dm_pa); 340void bfa_ioc_mem_claim(struct bfa_ioc_s *ioc, u8 *dm_kva, u64 dm_pa);
255void bfa_ioc_enable(struct bfa_ioc_s *ioc); 341void bfa_ioc_enable(struct bfa_ioc_s *ioc);
256void bfa_ioc_disable(struct bfa_ioc_s *ioc); 342void bfa_ioc_disable(struct bfa_ioc_s *ioc);
257bfa_boolean_t bfa_ioc_intx_claim(struct bfa_ioc_s *ioc); 343bfa_boolean_t bfa_ioc_intx_claim(struct bfa_ioc_s *ioc);
258 344
259void bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type, u32 boot_param); 345void bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type,
346 u32 boot_param);
260void bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *msg); 347void bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *msg);
261void bfa_ioc_error_isr(struct bfa_ioc_s *ioc); 348void bfa_ioc_error_isr(struct bfa_ioc_s *ioc);
262bfa_boolean_t bfa_ioc_is_operational(struct bfa_ioc_s *ioc); 349bfa_boolean_t bfa_ioc_is_operational(struct bfa_ioc_s *ioc);
350bfa_boolean_t bfa_ioc_is_initialized(struct bfa_ioc_s *ioc);
263bfa_boolean_t bfa_ioc_is_disabled(struct bfa_ioc_s *ioc); 351bfa_boolean_t bfa_ioc_is_disabled(struct bfa_ioc_s *ioc);
264bfa_boolean_t bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc); 352bfa_boolean_t bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc);
265bfa_boolean_t bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc); 353bfa_boolean_t bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc);
266void bfa_ioc_cfg_complete(struct bfa_ioc_s *ioc); 354void bfa_ioc_reset_fwstate(struct bfa_ioc_s *ioc);
267enum bfa_ioc_type_e bfa_ioc_get_type(struct bfa_ioc_s *ioc); 355enum bfa_ioc_type_e bfa_ioc_get_type(struct bfa_ioc_s *ioc);
268void bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num); 356void bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num);
269void bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver); 357void bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver);
270void bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc_s *ioc, char *optrom_ver); 358void bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc_s *ioc, char *optrom_ver);
271void bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model); 359void bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model);
272void bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, 360void bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc,
273 char *manufacturer); 361 char *manufacturer);
274void bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev); 362void bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev);
275enum bfa_ioc_state bfa_ioc_get_state(struct bfa_ioc_s *ioc); 363enum bfa_ioc_state bfa_ioc_get_state(struct bfa_ioc_s *ioc);
276 364
277void bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr); 365void bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr);
278void bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc, 366void bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
279 struct bfa_adapter_attr_s *ad_attr); 367 struct bfa_adapter_attr_s *ad_attr);
280int bfa_ioc_debug_trcsz(bfa_boolean_t auto_recover);
281void bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave); 368void bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave);
282bfa_status_t bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata, 369bfa_status_t bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata,
283 int *trclen); 370 int *trclen);
284void bfa_ioc_debug_fwsave_clear(struct bfa_ioc_s *ioc);
285bfa_status_t bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata, 371bfa_status_t bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata,
286 int *trclen); 372 int *trclen);
287u32 bfa_ioc_smem_pgnum(struct bfa_ioc_s *ioc, u32 fmaddr); 373bfa_status_t bfa_ioc_debug_fwcore(struct bfa_ioc_s *ioc, void *buf,
288u32 bfa_ioc_smem_pgoff(struct bfa_ioc_s *ioc, u32 fmaddr); 374 u32 *offset, int *buflen);
289void bfa_ioc_set_fcmode(struct bfa_ioc_s *ioc); 375void bfa_ioc_set_fcmode(struct bfa_ioc_s *ioc);
290bfa_boolean_t bfa_ioc_get_fcmode(struct bfa_ioc_s *ioc); 376bfa_boolean_t bfa_ioc_get_fcmode(struct bfa_ioc_s *ioc);
291void bfa_ioc_hbfail_register(struct bfa_ioc_s *ioc, 377bfa_boolean_t bfa_ioc_sem_get(void __iomem *sem_reg);
292 struct bfa_ioc_hbfail_notify_s *notify);
293bfa_boolean_t bfa_ioc_sem_get(bfa_os_addr_t sem_reg);
294void bfa_ioc_sem_release(bfa_os_addr_t sem_reg);
295void bfa_ioc_hw_sem_release(struct bfa_ioc_s *ioc);
296void bfa_ioc_fwver_get(struct bfa_ioc_s *ioc, 378void bfa_ioc_fwver_get(struct bfa_ioc_s *ioc,
297 struct bfi_ioc_image_hdr_s *fwhdr); 379 struct bfi_ioc_image_hdr_s *fwhdr);
298bfa_boolean_t bfa_ioc_fwver_cmp(struct bfa_ioc_s *ioc, 380bfa_boolean_t bfa_ioc_fwver_cmp(struct bfa_ioc_s *ioc,
299 struct bfi_ioc_image_hdr_s *fwhdr); 381 struct bfi_ioc_image_hdr_s *fwhdr);
300void bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event); 382bfa_status_t bfa_ioc_fw_stats_get(struct bfa_ioc_s *ioc, void *stats);
383bfa_status_t bfa_ioc_fw_stats_clear(struct bfa_ioc_s *ioc);
301 384
302/* 385/*
303 * bfa mfg wwn API functions 386 * bfa mfg wwn API functions
304 */ 387 */
305wwn_t bfa_ioc_get_pwwn(struct bfa_ioc_s *ioc);
306wwn_t bfa_ioc_get_nwwn(struct bfa_ioc_s *ioc);
307mac_t bfa_ioc_get_mac(struct bfa_ioc_s *ioc); 388mac_t bfa_ioc_get_mac(struct bfa_ioc_s *ioc);
308wwn_t bfa_ioc_get_mfg_pwwn(struct bfa_ioc_s *ioc);
309wwn_t bfa_ioc_get_mfg_nwwn(struct bfa_ioc_s *ioc);
310mac_t bfa_ioc_get_mfg_mac(struct bfa_ioc_s *ioc); 389mac_t bfa_ioc_get_mfg_mac(struct bfa_ioc_s *ioc);
311u64 bfa_ioc_get_adid(struct bfa_ioc_s *ioc);
312 390
313#endif /* __BFA_IOC_H__ */ 391/*
392 * F/W Image Size & Chunk
393 */
394extern u32 bfi_image_ct_fc_size;
395extern u32 bfi_image_ct_cna_size;
396extern u32 bfi_image_cb_fc_size;
397extern u32 *bfi_image_ct_fc;
398extern u32 *bfi_image_ct_cna;
399extern u32 *bfi_image_cb_fc;
314 400
401static inline u32 *
402bfi_image_ct_fc_get_chunk(u32 off)
403{ return (u32 *)(bfi_image_ct_fc + off); }
404
405static inline u32 *
406bfi_image_ct_cna_get_chunk(u32 off)
407{ return (u32 *)(bfi_image_ct_cna + off); }
408
409static inline u32 *
410bfi_image_cb_fc_get_chunk(u32 off)
411{ return (u32 *)(bfi_image_cb_fc + off); }
412
413static inline u32*
414bfa_cb_image_get_chunk(int type, u32 off)
415{
416 switch (type) {
417 case BFI_IMAGE_CT_FC:
418 return bfi_image_ct_fc_get_chunk(off); break;
419 case BFI_IMAGE_CT_CNA:
420 return bfi_image_ct_cna_get_chunk(off); break;
421 case BFI_IMAGE_CB_FC:
422 return bfi_image_cb_fc_get_chunk(off); break;
423 default: return NULL;
424 }
425}
426
427static inline u32
428bfa_cb_image_get_size(int type)
429{
430 switch (type) {
431 case BFI_IMAGE_CT_FC:
432 return bfi_image_ct_fc_size; break;
433 case BFI_IMAGE_CT_CNA:
434 return bfi_image_ct_cna_size; break;
435 case BFI_IMAGE_CB_FC:
436 return bfi_image_cb_fc_size; break;
437 default: return 0;
438 }
439}
440
441/*
442 * CNA TRCMOD declaration
443 */
444/*
445 * !!! Only append to the enums defined here to avoid any versioning
446 * !!! needed between trace utility and driver version
447 */
448enum {
449 BFA_TRC_CNA_PORT = 1,
450 BFA_TRC_CNA_IOC = 2,
451 BFA_TRC_CNA_IOC_CB = 3,
452 BFA_TRC_CNA_IOC_CT = 4,
453};
454
455#endif /* __BFA_IOC_H__ */
diff --git a/drivers/scsi/bfa/bfa_ioc_cb.c b/drivers/scsi/bfa/bfa_ioc_cb.c
index 324bdde7ea2e..89ae4c8f95a2 100644
--- a/drivers/scsi/bfa/bfa_ioc_cb.c
+++ b/drivers/scsi/bfa/bfa_ioc_cb.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,33 +15,32 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#include <bfa.h> 18#include "bfad_drv.h"
19#include <bfa_ioc.h> 19#include "bfa_ioc.h"
20#include <bfa_fwimg_priv.h> 20#include "bfi_cbreg.h"
21#include <cna/bfa_cna_trcmod.h> 21#include "bfa_defs.h"
22#include <cs/bfa_debug.h>
23#include <bfi/bfi_ioc.h>
24#include <bfi/bfi_cbreg.h>
25#include <log/bfa_log_hal.h>
26#include <defs/bfa_defs_pci.h>
27 22
28BFA_TRC_FILE(CNA, IOC_CB); 23BFA_TRC_FILE(CNA, IOC_CB);
29 24
30/* 25/*
31 * forward declarations 26 * forward declarations
32 */ 27 */
33static bfa_status_t bfa_ioc_cb_pll_init(struct bfa_ioc_s *ioc);
34static bfa_boolean_t bfa_ioc_cb_firmware_lock(struct bfa_ioc_s *ioc); 28static bfa_boolean_t bfa_ioc_cb_firmware_lock(struct bfa_ioc_s *ioc);
35static void bfa_ioc_cb_firmware_unlock(struct bfa_ioc_s *ioc); 29static void bfa_ioc_cb_firmware_unlock(struct bfa_ioc_s *ioc);
36static void bfa_ioc_cb_reg_init(struct bfa_ioc_s *ioc); 30static void bfa_ioc_cb_reg_init(struct bfa_ioc_s *ioc);
37static void bfa_ioc_cb_map_port(struct bfa_ioc_s *ioc); 31static void bfa_ioc_cb_map_port(struct bfa_ioc_s *ioc);
38static void bfa_ioc_cb_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix); 32static void bfa_ioc_cb_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix);
39static void bfa_ioc_cb_notify_hbfail(struct bfa_ioc_s *ioc); 33static void bfa_ioc_cb_notify_fail(struct bfa_ioc_s *ioc);
40static void bfa_ioc_cb_ownership_reset(struct bfa_ioc_s *ioc); 34static void bfa_ioc_cb_ownership_reset(struct bfa_ioc_s *ioc);
35static bfa_boolean_t bfa_ioc_cb_sync_start(struct bfa_ioc_s *ioc);
36static void bfa_ioc_cb_sync_join(struct bfa_ioc_s *ioc);
37static void bfa_ioc_cb_sync_leave(struct bfa_ioc_s *ioc);
38static void bfa_ioc_cb_sync_ack(struct bfa_ioc_s *ioc);
39static bfa_boolean_t bfa_ioc_cb_sync_complete(struct bfa_ioc_s *ioc);
41 40
42struct bfa_ioc_hwif_s hwif_cb; 41static struct bfa_ioc_hwif_s hwif_cb;
43 42
44/** 43/*
45 * Called from bfa_ioc_attach() to map asic specific calls. 44 * Called from bfa_ioc_attach() to map asic specific calls.
46 */ 45 */
47void 46void
@@ -53,18 +52,38 @@ bfa_ioc_set_cb_hwif(struct bfa_ioc_s *ioc)
53 hwif_cb.ioc_reg_init = bfa_ioc_cb_reg_init; 52 hwif_cb.ioc_reg_init = bfa_ioc_cb_reg_init;
54 hwif_cb.ioc_map_port = bfa_ioc_cb_map_port; 53 hwif_cb.ioc_map_port = bfa_ioc_cb_map_port;
55 hwif_cb.ioc_isr_mode_set = bfa_ioc_cb_isr_mode_set; 54 hwif_cb.ioc_isr_mode_set = bfa_ioc_cb_isr_mode_set;
56 hwif_cb.ioc_notify_hbfail = bfa_ioc_cb_notify_hbfail; 55 hwif_cb.ioc_notify_fail = bfa_ioc_cb_notify_fail;
57 hwif_cb.ioc_ownership_reset = bfa_ioc_cb_ownership_reset; 56 hwif_cb.ioc_ownership_reset = bfa_ioc_cb_ownership_reset;
57 hwif_cb.ioc_sync_start = bfa_ioc_cb_sync_start;
58 hwif_cb.ioc_sync_join = bfa_ioc_cb_sync_join;
59 hwif_cb.ioc_sync_leave = bfa_ioc_cb_sync_leave;
60 hwif_cb.ioc_sync_ack = bfa_ioc_cb_sync_ack;
61 hwif_cb.ioc_sync_complete = bfa_ioc_cb_sync_complete;
58 62
59 ioc->ioc_hwif = &hwif_cb; 63 ioc->ioc_hwif = &hwif_cb;
60} 64}
61 65
62/** 66/*
63 * Return true if firmware of current driver matches the running firmware. 67 * Return true if firmware of current driver matches the running firmware.
64 */ 68 */
65static bfa_boolean_t 69static bfa_boolean_t
66bfa_ioc_cb_firmware_lock(struct bfa_ioc_s *ioc) 70bfa_ioc_cb_firmware_lock(struct bfa_ioc_s *ioc)
67{ 71{
72 struct bfi_ioc_image_hdr_s fwhdr;
73 uint32_t fwstate = readl(ioc->ioc_regs.ioc_fwstate);
74
75 if (fwstate == BFI_IOC_UNINIT)
76 return BFA_TRUE;
77
78 bfa_ioc_fwver_get(ioc, &fwhdr);
79
80 if (swab32(fwhdr.exec) == BFI_BOOT_TYPE_NORMAL)
81 return BFA_TRUE;
82
83 bfa_trc(ioc, fwstate);
84 bfa_trc(ioc, fwhdr.exec);
85 writel(BFI_IOC_UNINIT, ioc->ioc_regs.ioc_fwstate);
86
68 return BFA_TRUE; 87 return BFA_TRUE;
69} 88}
70 89
@@ -73,17 +92,17 @@ bfa_ioc_cb_firmware_unlock(struct bfa_ioc_s *ioc)
73{ 92{
74} 93}
75 94
76/** 95/*
77 * Notify other functions on HB failure. 96 * Notify other functions on HB failure.
78 */ 97 */
79static void 98static void
80bfa_ioc_cb_notify_hbfail(struct bfa_ioc_s *ioc) 99bfa_ioc_cb_notify_fail(struct bfa_ioc_s *ioc)
81{ 100{
82 bfa_reg_write(ioc->ioc_regs.err_set, __PSS_ERR_STATUS_SET); 101 writel(__PSS_ERR_STATUS_SET, ioc->ioc_regs.err_set);
83 bfa_reg_read(ioc->ioc_regs.err_set); 102 readl(ioc->ioc_regs.err_set);
84} 103}
85 104
86/** 105/*
87 * Host to LPU mailbox message addresses 106 * Host to LPU mailbox message addresses
88 */ 107 */
89static struct { u32 hfn_mbox, lpu_mbox, hfn_pgn; } iocreg_fnreg[] = { 108static struct { u32 hfn_mbox, lpu_mbox, hfn_pgn; } iocreg_fnreg[] = {
@@ -91,10 +110,11 @@ static struct { u32 hfn_mbox, lpu_mbox, hfn_pgn; } iocreg_fnreg[] = {
91 { HOSTFN1_LPU_MBOX0_8, LPU_HOSTFN1_MBOX0_8, HOST_PAGE_NUM_FN1 } 110 { HOSTFN1_LPU_MBOX0_8, LPU_HOSTFN1_MBOX0_8, HOST_PAGE_NUM_FN1 }
92}; 111};
93 112
94/** 113/*
95 * Host <-> LPU mailbox command/status registers 114 * Host <-> LPU mailbox command/status registers
96 */ 115 */
97static struct { u32 hfn, lpu; } iocreg_mbcmd[] = { 116static struct { u32 hfn, lpu; } iocreg_mbcmd[] = {
117
98 { HOSTFN0_LPU0_CMD_STAT, LPU0_HOSTFN0_CMD_STAT }, 118 { HOSTFN0_LPU0_CMD_STAT, LPU0_HOSTFN0_CMD_STAT },
99 { HOSTFN1_LPU1_CMD_STAT, LPU1_HOSTFN1_CMD_STAT } 119 { HOSTFN1_LPU1_CMD_STAT, LPU1_HOSTFN1_CMD_STAT }
100}; 120};
@@ -102,7 +122,7 @@ static struct { u32 hfn, lpu; } iocreg_mbcmd[] = {
102static void 122static void
103bfa_ioc_cb_reg_init(struct bfa_ioc_s *ioc) 123bfa_ioc_cb_reg_init(struct bfa_ioc_s *ioc)
104{ 124{
105 bfa_os_addr_t rb; 125 void __iomem *rb;
106 int pcifn = bfa_ioc_pcifn(ioc); 126 int pcifn = bfa_ioc_pcifn(ioc);
107 127
108 rb = bfa_ioc_bar0(ioc); 128 rb = bfa_ioc_bar0(ioc);
@@ -114,12 +134,14 @@ bfa_ioc_cb_reg_init(struct bfa_ioc_s *ioc)
114 if (ioc->port_id == 0) { 134 if (ioc->port_id == 0) {
115 ioc->ioc_regs.heartbeat = rb + BFA_IOC0_HBEAT_REG; 135 ioc->ioc_regs.heartbeat = rb + BFA_IOC0_HBEAT_REG;
116 ioc->ioc_regs.ioc_fwstate = rb + BFA_IOC0_STATE_REG; 136 ioc->ioc_regs.ioc_fwstate = rb + BFA_IOC0_STATE_REG;
137 ioc->ioc_regs.alt_ioc_fwstate = rb + BFA_IOC1_STATE_REG;
117 } else { 138 } else {
118 ioc->ioc_regs.heartbeat = (rb + BFA_IOC1_HBEAT_REG); 139 ioc->ioc_regs.heartbeat = (rb + BFA_IOC1_HBEAT_REG);
119 ioc->ioc_regs.ioc_fwstate = (rb + BFA_IOC1_STATE_REG); 140 ioc->ioc_regs.ioc_fwstate = (rb + BFA_IOC1_STATE_REG);
141 ioc->ioc_regs.alt_ioc_fwstate = (rb + BFA_IOC0_STATE_REG);
120 } 142 }
121 143
122 /** 144 /*
123 * Host <-> LPU mailbox command/status registers 145 * Host <-> LPU mailbox command/status registers
124 */ 146 */
125 ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd[pcifn].hfn; 147 ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd[pcifn].hfn;
@@ -139,7 +161,7 @@ bfa_ioc_cb_reg_init(struct bfa_ioc_s *ioc)
139 ioc->ioc_regs.ioc_sem_reg = (rb + HOST_SEM0_REG); 161 ioc->ioc_regs.ioc_sem_reg = (rb + HOST_SEM0_REG);
140 ioc->ioc_regs.ioc_init_sem_reg = (rb + HOST_SEM2_REG); 162 ioc->ioc_regs.ioc_init_sem_reg = (rb + HOST_SEM2_REG);
141 163
142 /** 164 /*
143 * sram memory access 165 * sram memory access
144 */ 166 */
145 ioc->ioc_regs.smem_page_start = (rb + PSS_SMEM_PAGE_START); 167 ioc->ioc_regs.smem_page_start = (rb + PSS_SMEM_PAGE_START);
@@ -151,20 +173,22 @@ bfa_ioc_cb_reg_init(struct bfa_ioc_s *ioc)
151 ioc->ioc_regs.err_set = (rb + ERR_SET_REG); 173 ioc->ioc_regs.err_set = (rb + ERR_SET_REG);
152} 174}
153 175
154/** 176/*
155 * Initialize IOC to port mapping. 177 * Initialize IOC to port mapping.
156 */ 178 */
179
157static void 180static void
158bfa_ioc_cb_map_port(struct bfa_ioc_s *ioc) 181bfa_ioc_cb_map_port(struct bfa_ioc_s *ioc)
159{ 182{
160 /** 183 /*
161 * For crossbow, port id is same as pci function. 184 * For crossbow, port id is same as pci function.
162 */ 185 */
163 ioc->port_id = bfa_ioc_pcifn(ioc); 186 ioc->port_id = bfa_ioc_pcifn(ioc);
187
164 bfa_trc(ioc, ioc->port_id); 188 bfa_trc(ioc, ioc->port_id);
165} 189}
166 190
167/** 191/*
168 * Set interrupt mode for a function: INTX or MSIX 192 * Set interrupt mode for a function: INTX or MSIX
169 */ 193 */
170static void 194static void
@@ -172,76 +196,16 @@ bfa_ioc_cb_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix)
172{ 196{
173} 197}
174 198
175static bfa_status_t 199/*
176bfa_ioc_cb_pll_init(struct bfa_ioc_s *ioc) 200 * Synchronized IOC failure processing routines
201 */
202static bfa_boolean_t
203bfa_ioc_cb_sync_start(struct bfa_ioc_s *ioc)
177{ 204{
178 bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; 205 return bfa_ioc_cb_sync_complete(ioc);
179 u32 pll_sclk, pll_fclk;
180
181 /*
182 * Hold semaphore so that nobody can access the chip during init.
183 */
184 bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg);
185
186 pll_sclk = __APP_PLL_212_ENABLE | __APP_PLL_212_LRESETN |
187 __APP_PLL_212_P0_1(3U) |
188 __APP_PLL_212_JITLMT0_1(3U) |
189 __APP_PLL_212_CNTLMT0_1(3U);
190 pll_fclk = __APP_PLL_400_ENABLE | __APP_PLL_400_LRESETN |
191 __APP_PLL_400_RSEL200500 | __APP_PLL_400_P0_1(3U) |
192 __APP_PLL_400_JITLMT0_1(3U) |
193 __APP_PLL_400_CNTLMT0_1(3U);
194
195 bfa_reg_write((rb + BFA_IOC0_STATE_REG), BFI_IOC_UNINIT);
196 bfa_reg_write((rb + BFA_IOC1_STATE_REG), BFI_IOC_UNINIT);
197
198 bfa_reg_write((rb + HOSTFN0_INT_MSK), 0xffffffffU);
199 bfa_reg_write((rb + HOSTFN1_INT_MSK), 0xffffffffU);
200 bfa_reg_write((rb + HOSTFN0_INT_STATUS), 0xffffffffU);
201 bfa_reg_write((rb + HOSTFN1_INT_STATUS), 0xffffffffU);
202 bfa_reg_write((rb + HOSTFN0_INT_MSK), 0xffffffffU);
203 bfa_reg_write((rb + HOSTFN1_INT_MSK), 0xffffffffU);
204
205 bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg,
206 __APP_PLL_212_LOGIC_SOFT_RESET);
207 bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg,
208 __APP_PLL_212_BYPASS |
209 __APP_PLL_212_LOGIC_SOFT_RESET);
210 bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg,
211 __APP_PLL_400_LOGIC_SOFT_RESET);
212 bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg,
213 __APP_PLL_400_BYPASS |
214 __APP_PLL_400_LOGIC_SOFT_RESET);
215 bfa_os_udelay(2);
216 bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg,
217 __APP_PLL_212_LOGIC_SOFT_RESET);
218 bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg,
219 __APP_PLL_400_LOGIC_SOFT_RESET);
220
221 bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg,
222 pll_sclk | __APP_PLL_212_LOGIC_SOFT_RESET);
223 bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg,
224 pll_fclk | __APP_PLL_400_LOGIC_SOFT_RESET);
225
226 /**
227 * Wait for PLLs to lock.
228 */
229 bfa_os_udelay(2000);
230 bfa_reg_write((rb + HOSTFN0_INT_STATUS), 0xffffffffU);
231 bfa_reg_write((rb + HOSTFN1_INT_STATUS), 0xffffffffU);
232
233 bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, pll_sclk);
234 bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, pll_fclk);
235
236 /*
237 * release semaphore.
238 */
239 bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg);
240
241 return BFA_STATUS_OK;
242} 206}
243 207
244/** 208/*
245 * Cleanup hw semaphore and usecnt registers 209 * Cleanup hw semaphore and usecnt registers
246 */ 210 */
247static void 211static void
@@ -253,6 +217,112 @@ bfa_ioc_cb_ownership_reset(struct bfa_ioc_s *ioc)
253 * before we clear it. If it is not locked, writing 1 217 * before we clear it. If it is not locked, writing 1
254 * will lock it instead of clearing it. 218 * will lock it instead of clearing it.
255 */ 219 */
256 bfa_reg_read(ioc->ioc_regs.ioc_sem_reg); 220 readl(ioc->ioc_regs.ioc_sem_reg);
257 bfa_ioc_hw_sem_release(ioc); 221 writel(1, ioc->ioc_regs.ioc_sem_reg);
222}
223
224/*
225 * Synchronized IOC failure processing routines
226 */
227static void
228bfa_ioc_cb_sync_join(struct bfa_ioc_s *ioc)
229{
230}
231
232static void
233bfa_ioc_cb_sync_leave(struct bfa_ioc_s *ioc)
234{
235}
236
237static void
238bfa_ioc_cb_sync_ack(struct bfa_ioc_s *ioc)
239{
240 writel(BFI_IOC_FAIL, ioc->ioc_regs.ioc_fwstate);
241}
242
243static bfa_boolean_t
244bfa_ioc_cb_sync_complete(struct bfa_ioc_s *ioc)
245{
246 uint32_t fwstate, alt_fwstate;
247 fwstate = readl(ioc->ioc_regs.ioc_fwstate);
248
249 /*
250 * At this point, this IOC is hoding the hw sem in the
251 * start path (fwcheck) OR in the disable/enable path
252 * OR to check if the other IOC has acknowledged failure.
253 *
254 * So, this IOC can be in UNINIT, INITING, DISABLED, FAIL
255 * or in MEMTEST states. In a normal scenario, this IOC
256 * can not be in OP state when this function is called.
257 *
258 * However, this IOC could still be in OP state when
259 * the OS driver is starting up, if the OptROM code has
260 * left it in that state.
261 *
262 * If we had marked this IOC's fwstate as BFI_IOC_FAIL
263 * in the failure case and now, if the fwstate is not
264 * BFI_IOC_FAIL it implies that the other PCI fn have
265 * reinitialized the ASIC or this IOC got disabled, so
266 * return TRUE.
267 */
268 if (fwstate == BFI_IOC_UNINIT ||
269 fwstate == BFI_IOC_INITING ||
270 fwstate == BFI_IOC_DISABLED ||
271 fwstate == BFI_IOC_MEMTEST ||
272 fwstate == BFI_IOC_OP)
273 return BFA_TRUE;
274 else {
275 alt_fwstate = readl(ioc->ioc_regs.alt_ioc_fwstate);
276 if (alt_fwstate == BFI_IOC_FAIL ||
277 alt_fwstate == BFI_IOC_DISABLED ||
278 alt_fwstate == BFI_IOC_UNINIT ||
279 alt_fwstate == BFI_IOC_INITING ||
280 alt_fwstate == BFI_IOC_MEMTEST)
281 return BFA_TRUE;
282 else
283 return BFA_FALSE;
284 }
285}
286
287bfa_status_t
288bfa_ioc_cb_pll_init(void __iomem *rb, bfa_boolean_t fcmode)
289{
290 u32 pll_sclk, pll_fclk;
291
292 pll_sclk = __APP_PLL_212_ENABLE | __APP_PLL_212_LRESETN |
293 __APP_PLL_212_P0_1(3U) |
294 __APP_PLL_212_JITLMT0_1(3U) |
295 __APP_PLL_212_CNTLMT0_1(3U);
296 pll_fclk = __APP_PLL_400_ENABLE | __APP_PLL_400_LRESETN |
297 __APP_PLL_400_RSEL200500 | __APP_PLL_400_P0_1(3U) |
298 __APP_PLL_400_JITLMT0_1(3U) |
299 __APP_PLL_400_CNTLMT0_1(3U);
300 writel(BFI_IOC_UNINIT, (rb + BFA_IOC0_STATE_REG));
301 writel(BFI_IOC_UNINIT, (rb + BFA_IOC1_STATE_REG));
302 writel(0xffffffffU, (rb + HOSTFN0_INT_MSK));
303 writel(0xffffffffU, (rb + HOSTFN1_INT_MSK));
304 writel(0xffffffffU, (rb + HOSTFN0_INT_STATUS));
305 writel(0xffffffffU, (rb + HOSTFN1_INT_STATUS));
306 writel(0xffffffffU, (rb + HOSTFN0_INT_MSK));
307 writel(0xffffffffU, (rb + HOSTFN1_INT_MSK));
308 writel(__APP_PLL_212_LOGIC_SOFT_RESET, rb + APP_PLL_212_CTL_REG);
309 writel(__APP_PLL_212_BYPASS | __APP_PLL_212_LOGIC_SOFT_RESET,
310 rb + APP_PLL_212_CTL_REG);
311 writel(__APP_PLL_400_LOGIC_SOFT_RESET, rb + APP_PLL_400_CTL_REG);
312 writel(__APP_PLL_400_BYPASS | __APP_PLL_400_LOGIC_SOFT_RESET,
313 rb + APP_PLL_400_CTL_REG);
314 udelay(2);
315 writel(__APP_PLL_212_LOGIC_SOFT_RESET, rb + APP_PLL_212_CTL_REG);
316 writel(__APP_PLL_400_LOGIC_SOFT_RESET, rb + APP_PLL_400_CTL_REG);
317 writel(pll_sclk | __APP_PLL_212_LOGIC_SOFT_RESET,
318 rb + APP_PLL_212_CTL_REG);
319 writel(pll_fclk | __APP_PLL_400_LOGIC_SOFT_RESET,
320 rb + APP_PLL_400_CTL_REG);
321 udelay(2000);
322 writel(0xffffffffU, (rb + HOSTFN0_INT_STATUS));
323 writel(0xffffffffU, (rb + HOSTFN1_INT_STATUS));
324 writel(pll_sclk, (rb + APP_PLL_212_CTL_REG));
325 writel(pll_fclk, (rb + APP_PLL_400_CTL_REG));
326
327 return BFA_STATUS_OK;
258} 328}
diff --git a/drivers/scsi/bfa/bfa_ioc_ct.c b/drivers/scsi/bfa/bfa_ioc_ct.c
index 68f027da001e..93612520f0d2 100644
--- a/drivers/scsi/bfa/bfa_ioc_ct.c
+++ b/drivers/scsi/bfa/bfa_ioc_ct.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,33 +15,41 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#include <bfa.h> 18#include "bfad_drv.h"
19#include <bfa_ioc.h> 19#include "bfa_ioc.h"
20#include <bfa_fwimg_priv.h> 20#include "bfi_ctreg.h"
21#include <cna/bfa_cna_trcmod.h> 21#include "bfa_defs.h"
22#include <cs/bfa_debug.h>
23#include <bfi/bfi_ioc.h>
24#include <bfi/bfi_ctreg.h>
25#include <log/bfa_log_hal.h>
26#include <defs/bfa_defs_pci.h>
27 22
28BFA_TRC_FILE(CNA, IOC_CT); 23BFA_TRC_FILE(CNA, IOC_CT);
29 24
25#define bfa_ioc_ct_sync_pos(__ioc) \
26 ((uint32_t) (1 << bfa_ioc_pcifn(__ioc)))
27#define BFA_IOC_SYNC_REQD_SH 16
28#define bfa_ioc_ct_get_sync_ackd(__val) (__val & 0x0000ffff)
29#define bfa_ioc_ct_clear_sync_ackd(__val) (__val & 0xffff0000)
30#define bfa_ioc_ct_get_sync_reqd(__val) (__val >> BFA_IOC_SYNC_REQD_SH)
31#define bfa_ioc_ct_sync_reqd_pos(__ioc) \
32 (bfa_ioc_ct_sync_pos(__ioc) << BFA_IOC_SYNC_REQD_SH)
33
30/* 34/*
31 * forward declarations 35 * forward declarations
32 */ 36 */
33static bfa_status_t bfa_ioc_ct_pll_init(struct bfa_ioc_s *ioc);
34static bfa_boolean_t bfa_ioc_ct_firmware_lock(struct bfa_ioc_s *ioc); 37static bfa_boolean_t bfa_ioc_ct_firmware_lock(struct bfa_ioc_s *ioc);
35static void bfa_ioc_ct_firmware_unlock(struct bfa_ioc_s *ioc); 38static void bfa_ioc_ct_firmware_unlock(struct bfa_ioc_s *ioc);
36static void bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc); 39static void bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc);
37static void bfa_ioc_ct_map_port(struct bfa_ioc_s *ioc); 40static void bfa_ioc_ct_map_port(struct bfa_ioc_s *ioc);
38static void bfa_ioc_ct_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix); 41static void bfa_ioc_ct_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix);
39static void bfa_ioc_ct_notify_hbfail(struct bfa_ioc_s *ioc); 42static void bfa_ioc_ct_notify_fail(struct bfa_ioc_s *ioc);
40static void bfa_ioc_ct_ownership_reset(struct bfa_ioc_s *ioc); 43static void bfa_ioc_ct_ownership_reset(struct bfa_ioc_s *ioc);
44static bfa_boolean_t bfa_ioc_ct_sync_start(struct bfa_ioc_s *ioc);
45static void bfa_ioc_ct_sync_join(struct bfa_ioc_s *ioc);
46static void bfa_ioc_ct_sync_leave(struct bfa_ioc_s *ioc);
47static void bfa_ioc_ct_sync_ack(struct bfa_ioc_s *ioc);
48static bfa_boolean_t bfa_ioc_ct_sync_complete(struct bfa_ioc_s *ioc);
41 49
42struct bfa_ioc_hwif_s hwif_ct; 50static struct bfa_ioc_hwif_s hwif_ct;
43 51
44/** 52/*
45 * Called from bfa_ioc_attach() to map asic specific calls. 53 * Called from bfa_ioc_attach() to map asic specific calls.
46 */ 54 */
47void 55void
@@ -53,13 +61,18 @@ bfa_ioc_set_ct_hwif(struct bfa_ioc_s *ioc)
53 hwif_ct.ioc_reg_init = bfa_ioc_ct_reg_init; 61 hwif_ct.ioc_reg_init = bfa_ioc_ct_reg_init;
54 hwif_ct.ioc_map_port = bfa_ioc_ct_map_port; 62 hwif_ct.ioc_map_port = bfa_ioc_ct_map_port;
55 hwif_ct.ioc_isr_mode_set = bfa_ioc_ct_isr_mode_set; 63 hwif_ct.ioc_isr_mode_set = bfa_ioc_ct_isr_mode_set;
56 hwif_ct.ioc_notify_hbfail = bfa_ioc_ct_notify_hbfail; 64 hwif_ct.ioc_notify_fail = bfa_ioc_ct_notify_fail;
57 hwif_ct.ioc_ownership_reset = bfa_ioc_ct_ownership_reset; 65 hwif_ct.ioc_ownership_reset = bfa_ioc_ct_ownership_reset;
66 hwif_ct.ioc_sync_start = bfa_ioc_ct_sync_start;
67 hwif_ct.ioc_sync_join = bfa_ioc_ct_sync_join;
68 hwif_ct.ioc_sync_leave = bfa_ioc_ct_sync_leave;
69 hwif_ct.ioc_sync_ack = bfa_ioc_ct_sync_ack;
70 hwif_ct.ioc_sync_complete = bfa_ioc_ct_sync_complete;
58 71
59 ioc->ioc_hwif = &hwif_ct; 72 ioc->ioc_hwif = &hwif_ct;
60} 73}
61 74
62/** 75/*
63 * Return true if firmware of current driver matches the running firmware. 76 * Return true if firmware of current driver matches the running firmware.
64 */ 77 */
65static bfa_boolean_t 78static bfa_boolean_t
@@ -69,55 +82,57 @@ bfa_ioc_ct_firmware_lock(struct bfa_ioc_s *ioc)
69 u32 usecnt; 82 u32 usecnt;
70 struct bfi_ioc_image_hdr_s fwhdr; 83 struct bfi_ioc_image_hdr_s fwhdr;
71 84
72 /** 85 /*
73 * Firmware match check is relevant only for CNA. 86 * Firmware match check is relevant only for CNA.
74 */ 87 */
75 if (!ioc->cna) 88 if (!ioc->cna)
76 return BFA_TRUE; 89 return BFA_TRUE;
77 90
78 /** 91 /*
79 * If bios boot (flash based) -- do not increment usage count 92 * If bios boot (flash based) -- do not increment usage count
80 */ 93 */
81 if (bfi_image_get_size(BFA_IOC_FWIMG_TYPE(ioc)) < BFA_IOC_FWIMG_MINSZ) 94 if (bfa_cb_image_get_size(BFA_IOC_FWIMG_TYPE(ioc)) <
95 BFA_IOC_FWIMG_MINSZ)
82 return BFA_TRUE; 96 return BFA_TRUE;
83 97
84 bfa_ioc_sem_get(ioc->ioc_regs.ioc_usage_sem_reg); 98 bfa_ioc_sem_get(ioc->ioc_regs.ioc_usage_sem_reg);
85 usecnt = bfa_reg_read(ioc->ioc_regs.ioc_usage_reg); 99 usecnt = readl(ioc->ioc_regs.ioc_usage_reg);
86 100
87 /** 101 /*
88 * If usage count is 0, always return TRUE. 102 * If usage count is 0, always return TRUE.
89 */ 103 */
90 if (usecnt == 0) { 104 if (usecnt == 0) {
91 bfa_reg_write(ioc->ioc_regs.ioc_usage_reg, 1); 105 writel(1, ioc->ioc_regs.ioc_usage_reg);
92 bfa_ioc_sem_release(ioc->ioc_regs.ioc_usage_sem_reg); 106 writel(1, ioc->ioc_regs.ioc_usage_sem_reg);
107 writel(0, ioc->ioc_regs.ioc_fail_sync);
93 bfa_trc(ioc, usecnt); 108 bfa_trc(ioc, usecnt);
94 return BFA_TRUE; 109 return BFA_TRUE;
95 } 110 }
96 111
97 ioc_fwstate = bfa_reg_read(ioc->ioc_regs.ioc_fwstate); 112 ioc_fwstate = readl(ioc->ioc_regs.ioc_fwstate);
98 bfa_trc(ioc, ioc_fwstate); 113 bfa_trc(ioc, ioc_fwstate);
99 114
100 /** 115 /*
101 * Use count cannot be non-zero and chip in uninitialized state. 116 * Use count cannot be non-zero and chip in uninitialized state.
102 */ 117 */
103 bfa_assert(ioc_fwstate != BFI_IOC_UNINIT); 118 WARN_ON(ioc_fwstate == BFI_IOC_UNINIT);
104 119
105 /** 120 /*
106 * Check if another driver with a different firmware is active 121 * Check if another driver with a different firmware is active
107 */ 122 */
108 bfa_ioc_fwver_get(ioc, &fwhdr); 123 bfa_ioc_fwver_get(ioc, &fwhdr);
109 if (!bfa_ioc_fwver_cmp(ioc, &fwhdr)) { 124 if (!bfa_ioc_fwver_cmp(ioc, &fwhdr)) {
110 bfa_ioc_sem_release(ioc->ioc_regs.ioc_usage_sem_reg); 125 writel(1, ioc->ioc_regs.ioc_usage_sem_reg);
111 bfa_trc(ioc, usecnt); 126 bfa_trc(ioc, usecnt);
112 return BFA_FALSE; 127 return BFA_FALSE;
113 } 128 }
114 129
115 /** 130 /*
116 * Same firmware version. Increment the reference count. 131 * Same firmware version. Increment the reference count.
117 */ 132 */
118 usecnt++; 133 usecnt++;
119 bfa_reg_write(ioc->ioc_regs.ioc_usage_reg, usecnt); 134 writel(usecnt, ioc->ioc_regs.ioc_usage_reg);
120 bfa_ioc_sem_release(ioc->ioc_regs.ioc_usage_sem_reg); 135 writel(1, ioc->ioc_regs.ioc_usage_sem_reg);
121 bfa_trc(ioc, usecnt); 136 bfa_trc(ioc, usecnt);
122 return BFA_TRUE; 137 return BFA_TRUE;
123} 138}
@@ -127,49 +142,52 @@ bfa_ioc_ct_firmware_unlock(struct bfa_ioc_s *ioc)
127{ 142{
128 u32 usecnt; 143 u32 usecnt;
129 144
130 /** 145 /*
131 * Firmware lock is relevant only for CNA. 146 * Firmware lock is relevant only for CNA.
132 */ 147 */
133 if (!ioc->cna) 148 if (!ioc->cna)
134 return; 149 return;
135 150
136 /** 151 /*
137 * If bios boot (flash based) -- do not decrement usage count 152 * If bios boot (flash based) -- do not decrement usage count
138 */ 153 */
139 if (bfi_image_get_size(BFA_IOC_FWIMG_TYPE(ioc)) < BFA_IOC_FWIMG_MINSZ) 154 if (bfa_cb_image_get_size(BFA_IOC_FWIMG_TYPE(ioc)) <
155 BFA_IOC_FWIMG_MINSZ)
140 return; 156 return;
141 157
142 /** 158 /*
143 * decrement usage count 159 * decrement usage count
144 */ 160 */
145 bfa_ioc_sem_get(ioc->ioc_regs.ioc_usage_sem_reg); 161 bfa_ioc_sem_get(ioc->ioc_regs.ioc_usage_sem_reg);
146 usecnt = bfa_reg_read(ioc->ioc_regs.ioc_usage_reg); 162 usecnt = readl(ioc->ioc_regs.ioc_usage_reg);
147 bfa_assert(usecnt > 0); 163 WARN_ON(usecnt <= 0);
148 164
149 usecnt--; 165 usecnt--;
150 bfa_reg_write(ioc->ioc_regs.ioc_usage_reg, usecnt); 166 writel(usecnt, ioc->ioc_regs.ioc_usage_reg);
151 bfa_trc(ioc, usecnt); 167 bfa_trc(ioc, usecnt);
152 168
153 bfa_ioc_sem_release(ioc->ioc_regs.ioc_usage_sem_reg); 169 writel(1, ioc->ioc_regs.ioc_usage_sem_reg);
154} 170}
155 171
156/** 172/*
157 * Notify other functions on HB failure. 173 * Notify other functions on HB failure.
158 */ 174 */
159static void 175static void
160bfa_ioc_ct_notify_hbfail(struct bfa_ioc_s *ioc) 176bfa_ioc_ct_notify_fail(struct bfa_ioc_s *ioc)
161{ 177{
162 if (ioc->cna) { 178 if (ioc->cna) {
163 bfa_reg_write(ioc->ioc_regs.ll_halt, __FW_INIT_HALT_P); 179 writel(__FW_INIT_HALT_P, ioc->ioc_regs.ll_halt);
180 writel(__FW_INIT_HALT_P, ioc->ioc_regs.alt_ll_halt);
164 /* Wait for halt to take effect */ 181 /* Wait for halt to take effect */
165 bfa_reg_read(ioc->ioc_regs.ll_halt); 182 readl(ioc->ioc_regs.ll_halt);
183 readl(ioc->ioc_regs.alt_ll_halt);
166 } else { 184 } else {
167 bfa_reg_write(ioc->ioc_regs.err_set, __PSS_ERR_STATUS_SET); 185 writel(__PSS_ERR_STATUS_SET, ioc->ioc_regs.err_set);
168 bfa_reg_read(ioc->ioc_regs.err_set); 186 readl(ioc->ioc_regs.err_set);
169 } 187 }
170} 188}
171 189
172/** 190/*
173 * Host to LPU mailbox message addresses 191 * Host to LPU mailbox message addresses
174 */ 192 */
175static struct { u32 hfn_mbox, lpu_mbox, hfn_pgn; } iocreg_fnreg[] = { 193static struct { u32 hfn_mbox, lpu_mbox, hfn_pgn; } iocreg_fnreg[] = {
@@ -179,7 +197,7 @@ static struct { u32 hfn_mbox, lpu_mbox, hfn_pgn; } iocreg_fnreg[] = {
179 { HOSTFN3_LPU_MBOX0_8, LPU_HOSTFN3_MBOX0_8, HOST_PAGE_NUM_FN3 } 197 { HOSTFN3_LPU_MBOX0_8, LPU_HOSTFN3_MBOX0_8, HOST_PAGE_NUM_FN3 }
180}; 198};
181 199
182/** 200/*
183 * Host <-> LPU mailbox command/status registers - port 0 201 * Host <-> LPU mailbox command/status registers - port 0
184 */ 202 */
185static struct { u32 hfn, lpu; } iocreg_mbcmd_p0[] = { 203static struct { u32 hfn, lpu; } iocreg_mbcmd_p0[] = {
@@ -189,7 +207,7 @@ static struct { u32 hfn, lpu; } iocreg_mbcmd_p0[] = {
189 { HOSTFN3_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN3_MBOX0_CMD_STAT } 207 { HOSTFN3_LPU0_MBOX0_CMD_STAT, LPU0_HOSTFN3_MBOX0_CMD_STAT }
190}; 208};
191 209
192/** 210/*
193 * Host <-> LPU mailbox command/status registers - port 1 211 * Host <-> LPU mailbox command/status registers - port 1
194 */ 212 */
195static struct { u32 hfn, lpu; } iocreg_mbcmd_p1[] = { 213static struct { u32 hfn, lpu; } iocreg_mbcmd_p1[] = {
@@ -202,7 +220,7 @@ static struct { u32 hfn, lpu; } iocreg_mbcmd_p1[] = {
202static void 220static void
203bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc) 221bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc)
204{ 222{
205 bfa_os_addr_t rb; 223 void __iomem *rb;
206 int pcifn = bfa_ioc_pcifn(ioc); 224 int pcifn = bfa_ioc_pcifn(ioc);
207 225
208 rb = bfa_ioc_bar0(ioc); 226 rb = bfa_ioc_bar0(ioc);
@@ -214,15 +232,19 @@ bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc)
214 if (ioc->port_id == 0) { 232 if (ioc->port_id == 0) {
215 ioc->ioc_regs.heartbeat = rb + BFA_IOC0_HBEAT_REG; 233 ioc->ioc_regs.heartbeat = rb + BFA_IOC0_HBEAT_REG;
216 ioc->ioc_regs.ioc_fwstate = rb + BFA_IOC0_STATE_REG; 234 ioc->ioc_regs.ioc_fwstate = rb + BFA_IOC0_STATE_REG;
235 ioc->ioc_regs.alt_ioc_fwstate = rb + BFA_IOC1_STATE_REG;
217 ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd_p0[pcifn].hfn; 236 ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd_p0[pcifn].hfn;
218 ioc->ioc_regs.lpu_mbox_cmd = rb + iocreg_mbcmd_p0[pcifn].lpu; 237 ioc->ioc_regs.lpu_mbox_cmd = rb + iocreg_mbcmd_p0[pcifn].lpu;
219 ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P0; 238 ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P0;
239 ioc->ioc_regs.alt_ll_halt = rb + FW_INIT_HALT_P1;
220 } else { 240 } else {
221 ioc->ioc_regs.heartbeat = (rb + BFA_IOC1_HBEAT_REG); 241 ioc->ioc_regs.heartbeat = (rb + BFA_IOC1_HBEAT_REG);
222 ioc->ioc_regs.ioc_fwstate = (rb + BFA_IOC1_STATE_REG); 242 ioc->ioc_regs.ioc_fwstate = (rb + BFA_IOC1_STATE_REG);
243 ioc->ioc_regs.alt_ioc_fwstate = rb + BFA_IOC0_STATE_REG;
223 ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd_p1[pcifn].hfn; 244 ioc->ioc_regs.hfn_mbox_cmd = rb + iocreg_mbcmd_p1[pcifn].hfn;
224 ioc->ioc_regs.lpu_mbox_cmd = rb + iocreg_mbcmd_p1[pcifn].lpu; 245 ioc->ioc_regs.lpu_mbox_cmd = rb + iocreg_mbcmd_p1[pcifn].lpu;
225 ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P1; 246 ioc->ioc_regs.ll_halt = rb + FW_INIT_HALT_P1;
247 ioc->ioc_regs.alt_ll_halt = rb + FW_INIT_HALT_P0;
226 } 248 }
227 249
228 /* 250 /*
@@ -240,8 +262,9 @@ bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc)
240 ioc->ioc_regs.ioc_usage_sem_reg = (rb + HOST_SEM1_REG); 262 ioc->ioc_regs.ioc_usage_sem_reg = (rb + HOST_SEM1_REG);
241 ioc->ioc_regs.ioc_init_sem_reg = (rb + HOST_SEM2_REG); 263 ioc->ioc_regs.ioc_init_sem_reg = (rb + HOST_SEM2_REG);
242 ioc->ioc_regs.ioc_usage_reg = (rb + BFA_FW_USE_COUNT); 264 ioc->ioc_regs.ioc_usage_reg = (rb + BFA_FW_USE_COUNT);
265 ioc->ioc_regs.ioc_fail_sync = (rb + BFA_IOC_FAIL_SYNC);
243 266
244 /** 267 /*
245 * sram memory access 268 * sram memory access
246 */ 269 */
247 ioc->ioc_regs.smem_page_start = (rb + PSS_SMEM_PAGE_START); 270 ioc->ioc_regs.smem_page_start = (rb + PSS_SMEM_PAGE_START);
@@ -253,7 +276,7 @@ bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc)
253 ioc->ioc_regs.err_set = (rb + ERR_SET_REG); 276 ioc->ioc_regs.err_set = (rb + ERR_SET_REG);
254} 277}
255 278
256/** 279/*
257 * Initialize IOC to port mapping. 280 * Initialize IOC to port mapping.
258 */ 281 */
259 282
@@ -261,13 +284,13 @@ bfa_ioc_ct_reg_init(struct bfa_ioc_s *ioc)
261static void 284static void
262bfa_ioc_ct_map_port(struct bfa_ioc_s *ioc) 285bfa_ioc_ct_map_port(struct bfa_ioc_s *ioc)
263{ 286{
264 bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; 287 void __iomem *rb = ioc->pcidev.pci_bar_kva;
265 u32 r32; 288 u32 r32;
266 289
267 /** 290 /*
268 * For catapult, base port id on personality register and IOC type 291 * For catapult, base port id on personality register and IOC type
269 */ 292 */
270 r32 = bfa_reg_read(rb + FNC_PERS_REG); 293 r32 = readl(rb + FNC_PERS_REG);
271 r32 >>= FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc)); 294 r32 >>= FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc));
272 ioc->port_id = (r32 & __F0_PORT_MAP_MK) >> __F0_PORT_MAP_SH; 295 ioc->port_id = (r32 & __F0_PORT_MAP_MK) >> __F0_PORT_MAP_SH;
273 296
@@ -275,22 +298,22 @@ bfa_ioc_ct_map_port(struct bfa_ioc_s *ioc)
275 bfa_trc(ioc, ioc->port_id); 298 bfa_trc(ioc, ioc->port_id);
276} 299}
277 300
278/** 301/*
279 * Set interrupt mode for a function: INTX or MSIX 302 * Set interrupt mode for a function: INTX or MSIX
280 */ 303 */
281static void 304static void
282bfa_ioc_ct_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix) 305bfa_ioc_ct_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix)
283{ 306{
284 bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; 307 void __iomem *rb = ioc->pcidev.pci_bar_kva;
285 u32 r32, mode; 308 u32 r32, mode;
286 309
287 r32 = bfa_reg_read(rb + FNC_PERS_REG); 310 r32 = readl(rb + FNC_PERS_REG);
288 bfa_trc(ioc, r32); 311 bfa_trc(ioc, r32);
289 312
290 mode = (r32 >> FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc))) & 313 mode = (r32 >> FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc))) &
291 __F0_INTX_STATUS; 314 __F0_INTX_STATUS;
292 315
293 /** 316 /*
294 * If already in desired mode, do not change anything 317 * If already in desired mode, do not change anything
295 */ 318 */
296 if (!msix && mode) 319 if (!msix && mode)
@@ -305,132 +328,199 @@ bfa_ioc_ct_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t msix)
305 r32 |= (mode << FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc))); 328 r32 |= (mode << FNC_PERS_FN_SHIFT(bfa_ioc_pcifn(ioc)));
306 bfa_trc(ioc, r32); 329 bfa_trc(ioc, r32);
307 330
308 bfa_reg_write(rb + FNC_PERS_REG, r32); 331 writel(r32, rb + FNC_PERS_REG);
309} 332}
310 333
311static bfa_status_t 334/*
312bfa_ioc_ct_pll_init(struct bfa_ioc_s *ioc) 335 * Cleanup hw semaphore and usecnt registers
336 */
337static void
338bfa_ioc_ct_ownership_reset(struct bfa_ioc_s *ioc)
313{ 339{
314 bfa_os_addr_t rb = ioc->pcidev.pci_bar_kva; 340
315 u32 pll_sclk, pll_fclk, r32; 341 if (ioc->cna) {
342 bfa_ioc_sem_get(ioc->ioc_regs.ioc_usage_sem_reg);
343 writel(0, ioc->ioc_regs.ioc_usage_reg);
344 writel(1, ioc->ioc_regs.ioc_usage_sem_reg);
345 }
316 346
317 /* 347 /*
318 * Hold semaphore so that nobody can access the chip during init. 348 * Read the hw sem reg to make sure that it is locked
349 * before we clear it. If it is not locked, writing 1
350 * will lock it instead of clearing it.
319 */ 351 */
320 bfa_ioc_sem_get(ioc->ioc_regs.ioc_init_sem_reg); 352 readl(ioc->ioc_regs.ioc_sem_reg);
353 writel(1, ioc->ioc_regs.ioc_sem_reg);
354}
321 355
322 pll_sclk = __APP_PLL_312_LRESETN | __APP_PLL_312_ENARST | 356static bfa_boolean_t
323 __APP_PLL_312_RSEL200500 | __APP_PLL_312_P0_1(3U) | 357bfa_ioc_ct_sync_start(struct bfa_ioc_s *ioc)
324 __APP_PLL_312_JITLMT0_1(3U) | 358{
325 __APP_PLL_312_CNTLMT0_1(1U); 359 uint32_t r32 = readl(ioc->ioc_regs.ioc_fail_sync);
326 pll_fclk = __APP_PLL_425_LRESETN | __APP_PLL_425_ENARST | 360 uint32_t sync_reqd = bfa_ioc_ct_get_sync_reqd(r32);
327 __APP_PLL_425_RSEL200500 | __APP_PLL_425_P0_1(3U) |
328 __APP_PLL_425_JITLMT0_1(3U) |
329 __APP_PLL_425_CNTLMT0_1(1U);
330 361
331 /** 362 /*
332 * For catapult, choose operational mode FC/FCoE 363 * Driver load time. If the sync required bit for this PCI fn
364 * is set, it is due to an unclean exit by the driver for this
365 * PCI fn in the previous incarnation. Whoever comes here first
366 * should clean it up, no matter which PCI fn.
333 */ 367 */
334 if (ioc->fcmode) {
335 bfa_reg_write((rb + OP_MODE), 0);
336 bfa_reg_write((rb + ETH_MAC_SER_REG),
337 __APP_EMS_CMLCKSEL |
338 __APP_EMS_REFCKBUFEN2 |
339 __APP_EMS_CHANNEL_SEL);
340 } else {
341 ioc->pllinit = BFA_TRUE;
342 bfa_reg_write((rb + OP_MODE), __GLOBAL_FCOE_MODE);
343 bfa_reg_write((rb + ETH_MAC_SER_REG),
344 __APP_EMS_REFCKBUFEN1);
345 }
346 368
347 bfa_reg_write((rb + BFA_IOC0_STATE_REG), BFI_IOC_UNINIT); 369 if (sync_reqd & bfa_ioc_ct_sync_pos(ioc)) {
348 bfa_reg_write((rb + BFA_IOC1_STATE_REG), BFI_IOC_UNINIT); 370 writel(0, ioc->ioc_regs.ioc_fail_sync);
349 371 writel(1, ioc->ioc_regs.ioc_usage_reg);
350 bfa_reg_write((rb + HOSTFN0_INT_MSK), 0xffffffffU); 372 writel(BFI_IOC_UNINIT, ioc->ioc_regs.ioc_fwstate);
351 bfa_reg_write((rb + HOSTFN1_INT_MSK), 0xffffffffU); 373 writel(BFI_IOC_UNINIT, ioc->ioc_regs.alt_ioc_fwstate);
352 bfa_reg_write((rb + HOSTFN0_INT_STATUS), 0xffffffffU); 374 return BFA_TRUE;
353 bfa_reg_write((rb + HOSTFN1_INT_STATUS), 0xffffffffU);
354 bfa_reg_write((rb + HOSTFN0_INT_MSK), 0xffffffffU);
355 bfa_reg_write((rb + HOSTFN1_INT_MSK), 0xffffffffU);
356
357 bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, pll_sclk |
358 __APP_PLL_312_LOGIC_SOFT_RESET);
359 bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, pll_fclk |
360 __APP_PLL_425_LOGIC_SOFT_RESET);
361 bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, pll_sclk |
362 __APP_PLL_312_LOGIC_SOFT_RESET | __APP_PLL_312_ENABLE);
363 bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, pll_fclk |
364 __APP_PLL_425_LOGIC_SOFT_RESET | __APP_PLL_425_ENABLE);
365
366 /**
367 * Wait for PLLs to lock.
368 */
369 bfa_reg_read(rb + HOSTFN0_INT_MSK);
370 bfa_os_udelay(2000);
371 bfa_reg_write((rb + HOSTFN0_INT_STATUS), 0xffffffffU);
372 bfa_reg_write((rb + HOSTFN1_INT_STATUS), 0xffffffffU);
373
374 bfa_reg_write(ioc->ioc_regs.app_pll_slow_ctl_reg, pll_sclk |
375 __APP_PLL_312_ENABLE);
376 bfa_reg_write(ioc->ioc_regs.app_pll_fast_ctl_reg, pll_fclk |
377 __APP_PLL_425_ENABLE);
378
379 /**
380 * PSS memory reset is asserted at power-on-reset. Need to clear
381 * this before running EDRAM BISTR
382 */
383 if (ioc->cna) {
384 bfa_reg_write((rb + PMM_1T_RESET_REG_P0), __PMM_1T_RESET_P);
385 bfa_reg_write((rb + PMM_1T_RESET_REG_P1), __PMM_1T_RESET_P);
386 } 375 }
387 376
388 r32 = bfa_reg_read((rb + PSS_CTL_REG)); 377 return bfa_ioc_ct_sync_complete(ioc);
389 r32 &= ~__PSS_LMEM_RESET; 378}
390 bfa_reg_write((rb + PSS_CTL_REG), r32);
391 bfa_os_udelay(1000);
392 379
393 if (ioc->cna) { 380/*
394 bfa_reg_write((rb + PMM_1T_RESET_REG_P0), 0); 381 * Synchronized IOC failure processing routines
395 bfa_reg_write((rb + PMM_1T_RESET_REG_P1), 0); 382 */
396 } 383static void
384bfa_ioc_ct_sync_join(struct bfa_ioc_s *ioc)
385{
386 uint32_t r32 = readl(ioc->ioc_regs.ioc_fail_sync);
387 uint32_t sync_pos = bfa_ioc_ct_sync_reqd_pos(ioc);
397 388
398 bfa_reg_write((rb + MBIST_CTL_REG), __EDRAM_BISTR_START); 389 writel((r32 | sync_pos), ioc->ioc_regs.ioc_fail_sync);
399 bfa_os_udelay(1000); 390}
400 r32 = bfa_reg_read((rb + MBIST_STAT_REG)); 391
401 bfa_trc(ioc, r32); 392static void
393bfa_ioc_ct_sync_leave(struct bfa_ioc_s *ioc)
394{
395 uint32_t r32 = readl(ioc->ioc_regs.ioc_fail_sync);
396 uint32_t sync_msk = bfa_ioc_ct_sync_reqd_pos(ioc) |
397 bfa_ioc_ct_sync_pos(ioc);
398
399 writel((r32 & ~sync_msk), ioc->ioc_regs.ioc_fail_sync);
400}
401
402static void
403bfa_ioc_ct_sync_ack(struct bfa_ioc_s *ioc)
404{
405 uint32_t r32 = readl(ioc->ioc_regs.ioc_fail_sync);
402 406
403 /** 407 writel((r32 | bfa_ioc_ct_sync_pos(ioc)),
404 * Clear BISTR 408 ioc->ioc_regs.ioc_fail_sync);
409}
410
411static bfa_boolean_t
412bfa_ioc_ct_sync_complete(struct bfa_ioc_s *ioc)
413{
414 uint32_t r32 = readl(ioc->ioc_regs.ioc_fail_sync);
415 uint32_t sync_reqd = bfa_ioc_ct_get_sync_reqd(r32);
416 uint32_t sync_ackd = bfa_ioc_ct_get_sync_ackd(r32);
417 uint32_t tmp_ackd;
418
419 if (sync_ackd == 0)
420 return BFA_TRUE;
421
422 /*
423 * The check below is to see whether any other PCI fn
424 * has reinitialized the ASIC (reset sync_ackd bits)
425 * and failed again while this IOC was waiting for hw
426 * semaphore (in bfa_iocpf_sm_semwait()).
405 */ 427 */
406 bfa_reg_write((rb + MBIST_CTL_REG), 0); 428 tmp_ackd = sync_ackd;
429 if ((sync_reqd & bfa_ioc_ct_sync_pos(ioc)) &&
430 !(sync_ackd & bfa_ioc_ct_sync_pos(ioc)))
431 sync_ackd |= bfa_ioc_ct_sync_pos(ioc);
432
433 if (sync_reqd == sync_ackd) {
434 writel(bfa_ioc_ct_clear_sync_ackd(r32),
435 ioc->ioc_regs.ioc_fail_sync);
436 writel(BFI_IOC_FAIL, ioc->ioc_regs.ioc_fwstate);
437 writel(BFI_IOC_FAIL, ioc->ioc_regs.alt_ioc_fwstate);
438 return BFA_TRUE;
439 }
407 440
408 /* 441 /*
409 * release semaphore. 442 * If another PCI fn reinitialized and failed again while
443 * this IOC was waiting for hw sem, the sync_ackd bit for
444 * this IOC need to be set again to allow reinitialization.
410 */ 445 */
411 bfa_ioc_sem_release(ioc->ioc_regs.ioc_init_sem_reg); 446 if (tmp_ackd != sync_ackd)
447 writel((r32 | sync_ackd), ioc->ioc_regs.ioc_fail_sync);
412 448
413 return BFA_STATUS_OK; 449 return BFA_FALSE;
414} 450}
415 451
416/** 452/*
417 * Cleanup hw semaphore and usecnt registers 453 * Check the firmware state to know if pll_init has been completed already
418 */ 454 */
419static void 455bfa_boolean_t
420bfa_ioc_ct_ownership_reset(struct bfa_ioc_s *ioc) 456bfa_ioc_ct_pll_init_complete(void __iomem *rb)
421{ 457{
458 if ((readl(rb + BFA_IOC0_STATE_REG) == BFI_IOC_OP) ||
459 (readl(rb + BFA_IOC1_STATE_REG) == BFI_IOC_OP))
460 return BFA_TRUE;
422 461
423 if (ioc->cna) { 462 return BFA_FALSE;
424 bfa_ioc_sem_get(ioc->ioc_regs.ioc_usage_sem_reg); 463}
425 bfa_reg_write(ioc->ioc_regs.ioc_usage_reg, 0); 464
426 bfa_ioc_sem_release(ioc->ioc_regs.ioc_usage_sem_reg); 465bfa_status_t
466bfa_ioc_ct_pll_init(void __iomem *rb, bfa_boolean_t fcmode)
467{
468 u32 pll_sclk, pll_fclk, r32;
469
470 pll_sclk = __APP_PLL_312_LRESETN | __APP_PLL_312_ENARST |
471 __APP_PLL_312_RSEL200500 | __APP_PLL_312_P0_1(3U) |
472 __APP_PLL_312_JITLMT0_1(3U) |
473 __APP_PLL_312_CNTLMT0_1(1U);
474 pll_fclk = __APP_PLL_425_LRESETN | __APP_PLL_425_ENARST |
475 __APP_PLL_425_RSEL200500 | __APP_PLL_425_P0_1(3U) |
476 __APP_PLL_425_JITLMT0_1(3U) |
477 __APP_PLL_425_CNTLMT0_1(1U);
478 if (fcmode) {
479 writel(0, (rb + OP_MODE));
480 writel(__APP_EMS_CMLCKSEL | __APP_EMS_REFCKBUFEN2 |
481 __APP_EMS_CHANNEL_SEL, (rb + ETH_MAC_SER_REG));
482 } else {
483 writel(__GLOBAL_FCOE_MODE, (rb + OP_MODE));
484 writel(__APP_EMS_REFCKBUFEN1, (rb + ETH_MAC_SER_REG));
485 }
486 writel(BFI_IOC_UNINIT, (rb + BFA_IOC0_STATE_REG));
487 writel(BFI_IOC_UNINIT, (rb + BFA_IOC1_STATE_REG));
488 writel(0xffffffffU, (rb + HOSTFN0_INT_MSK));
489 writel(0xffffffffU, (rb + HOSTFN1_INT_MSK));
490 writel(0xffffffffU, (rb + HOSTFN0_INT_STATUS));
491 writel(0xffffffffU, (rb + HOSTFN1_INT_STATUS));
492 writel(0xffffffffU, (rb + HOSTFN0_INT_MSK));
493 writel(0xffffffffU, (rb + HOSTFN1_INT_MSK));
494 writel(pll_sclk | __APP_PLL_312_LOGIC_SOFT_RESET,
495 rb + APP_PLL_312_CTL_REG);
496 writel(pll_fclk | __APP_PLL_425_LOGIC_SOFT_RESET,
497 rb + APP_PLL_425_CTL_REG);
498 writel(pll_sclk | __APP_PLL_312_LOGIC_SOFT_RESET | __APP_PLL_312_ENABLE,
499 rb + APP_PLL_312_CTL_REG);
500 writel(pll_fclk | __APP_PLL_425_LOGIC_SOFT_RESET | __APP_PLL_425_ENABLE,
501 rb + APP_PLL_425_CTL_REG);
502 readl(rb + HOSTFN0_INT_MSK);
503 udelay(2000);
504 writel(0xffffffffU, (rb + HOSTFN0_INT_STATUS));
505 writel(0xffffffffU, (rb + HOSTFN1_INT_STATUS));
506 writel(pll_sclk | __APP_PLL_312_ENABLE, rb + APP_PLL_312_CTL_REG);
507 writel(pll_fclk | __APP_PLL_425_ENABLE, rb + APP_PLL_425_CTL_REG);
508 if (!fcmode) {
509 writel(__PMM_1T_RESET_P, (rb + PMM_1T_RESET_REG_P0));
510 writel(__PMM_1T_RESET_P, (rb + PMM_1T_RESET_REG_P1));
511 }
512 r32 = readl((rb + PSS_CTL_REG));
513 r32 &= ~__PSS_LMEM_RESET;
514 writel(r32, (rb + PSS_CTL_REG));
515 udelay(1000);
516 if (!fcmode) {
517 writel(0, (rb + PMM_1T_RESET_REG_P0));
518 writel(0, (rb + PMM_1T_RESET_REG_P1));
427 } 519 }
428 520
429 /* 521 writel(__EDRAM_BISTR_START, (rb + MBIST_CTL_REG));
430 * Read the hw sem reg to make sure that it is locked 522 udelay(1000);
431 * before we clear it. If it is not locked, writing 1 523 r32 = readl((rb + MBIST_STAT_REG));
432 * will lock it instead of clearing it. 524 writel(0, (rb + MBIST_CTL_REG));
433 */ 525 return BFA_STATUS_OK;
434 bfa_reg_read(ioc->ioc_regs.ioc_sem_reg);
435 bfa_ioc_hw_sem_release(ioc);
436} 526}
diff --git a/drivers/scsi/bfa/bfa_iocfc.c b/drivers/scsi/bfa/bfa_iocfc.c
deleted file mode 100644
index 90820be99864..000000000000
--- a/drivers/scsi/bfa/bfa_iocfc.c
+++ /dev/null
@@ -1,927 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <cs/bfa_debug.h>
19#include <bfa_priv.h>
20#include <log/bfa_log_hal.h>
21#include <bfi/bfi_boot.h>
22#include <bfi/bfi_cbreg.h>
23#include <aen/bfa_aen_ioc.h>
24#include <defs/bfa_defs_iocfc.h>
25#include <defs/bfa_defs_pci.h>
26#include "bfa_callback_priv.h"
27#include "bfad_drv.h"
28
29BFA_TRC_FILE(HAL, IOCFC);
30
31/**
32 * IOC local definitions
33 */
34#define BFA_IOCFC_TOV 5000 /* msecs */
35
36enum {
37 BFA_IOCFC_ACT_NONE = 0,
38 BFA_IOCFC_ACT_INIT = 1,
39 BFA_IOCFC_ACT_STOP = 2,
40 BFA_IOCFC_ACT_DISABLE = 3,
41};
42
43/*
44 * forward declarations
45 */
46static void bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status);
47static void bfa_iocfc_disable_cbfn(void *bfa_arg);
48static void bfa_iocfc_hbfail_cbfn(void *bfa_arg);
49static void bfa_iocfc_reset_cbfn(void *bfa_arg);
50static void bfa_iocfc_stats_clear(void *bfa_arg);
51static void bfa_iocfc_stats_swap(struct bfa_fw_stats_s *d,
52 struct bfa_fw_stats_s *s);
53static void bfa_iocfc_stats_clr_cb(void *bfa_arg, bfa_boolean_t complete);
54static void bfa_iocfc_stats_clr_timeout(void *bfa_arg);
55static void bfa_iocfc_stats_cb(void *bfa_arg, bfa_boolean_t complete);
56static void bfa_iocfc_stats_timeout(void *bfa_arg);
57
58static struct bfa_ioc_cbfn_s bfa_iocfc_cbfn;
59
60/**
61 * bfa_ioc_pvt BFA IOC private functions
62 */
63
64static void
65bfa_iocfc_cqs_sz(struct bfa_iocfc_cfg_s *cfg, u32 *dm_len)
66{
67 int i, per_reqq_sz, per_rspq_sz;
68
69 per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ),
70 BFA_DMA_ALIGN_SZ);
71 per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ),
72 BFA_DMA_ALIGN_SZ);
73
74 /*
75 * Calculate CQ size
76 */
77 for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
78 *dm_len = *dm_len + per_reqq_sz;
79 *dm_len = *dm_len + per_rspq_sz;
80 }
81
82 /*
83 * Calculate Shadow CI/PI size
84 */
85 for (i = 0; i < cfg->fwcfg.num_cqs; i++)
86 *dm_len += (2 * BFA_CACHELINE_SZ);
87}
88
89static void
90bfa_iocfc_fw_cfg_sz(struct bfa_iocfc_cfg_s *cfg, u32 *dm_len)
91{
92 *dm_len +=
93 BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
94 *dm_len +=
95 BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
96 BFA_CACHELINE_SZ);
97 *dm_len += BFA_ROUNDUP(sizeof(struct bfa_fw_stats_s), BFA_CACHELINE_SZ);
98}
99
100/**
101 * Use the Mailbox interface to send BFI_IOCFC_H2I_CFG_REQ
102 */
103static void
104bfa_iocfc_send_cfg(void *bfa_arg)
105{
106 struct bfa_s *bfa = bfa_arg;
107 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
108 struct bfi_iocfc_cfg_req_s cfg_req;
109 struct bfi_iocfc_cfg_s *cfg_info = iocfc->cfginfo;
110 struct bfa_iocfc_cfg_s *cfg = &iocfc->cfg;
111 int i;
112
113 bfa_assert(cfg->fwcfg.num_cqs <= BFI_IOC_MAX_CQS);
114 bfa_trc(bfa, cfg->fwcfg.num_cqs);
115
116 bfa_iocfc_reset_queues(bfa);
117
118 /**
119 * initialize IOC configuration info
120 */
121 cfg_info->endian_sig = BFI_IOC_ENDIAN_SIG;
122 cfg_info->num_cqs = cfg->fwcfg.num_cqs;
123
124 bfa_dma_be_addr_set(cfg_info->cfgrsp_addr, iocfc->cfgrsp_dma.pa);
125 bfa_dma_be_addr_set(cfg_info->stats_addr, iocfc->stats_pa);
126
127 /**
128 * dma map REQ and RSP circular queues and shadow pointers
129 */
130 for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
131 bfa_dma_be_addr_set(cfg_info->req_cq_ba[i],
132 iocfc->req_cq_ba[i].pa);
133 bfa_dma_be_addr_set(cfg_info->req_shadow_ci[i],
134 iocfc->req_cq_shadow_ci[i].pa);
135 cfg_info->req_cq_elems[i] =
136 bfa_os_htons(cfg->drvcfg.num_reqq_elems);
137
138 bfa_dma_be_addr_set(cfg_info->rsp_cq_ba[i],
139 iocfc->rsp_cq_ba[i].pa);
140 bfa_dma_be_addr_set(cfg_info->rsp_shadow_pi[i],
141 iocfc->rsp_cq_shadow_pi[i].pa);
142 cfg_info->rsp_cq_elems[i] =
143 bfa_os_htons(cfg->drvcfg.num_rspq_elems);
144 }
145
146 /**
147 * Enable interrupt coalescing if it is driver init path
148 * and not ioc disable/enable path.
149 */
150 if (!iocfc->cfgdone)
151 cfg_info->intr_attr.coalesce = BFA_TRUE;
152
153 iocfc->cfgdone = BFA_FALSE;
154
155 /**
156 * dma map IOC configuration itself
157 */
158 bfi_h2i_set(cfg_req.mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_CFG_REQ,
159 bfa_lpuid(bfa));
160 bfa_dma_be_addr_set(cfg_req.ioc_cfg_dma_addr, iocfc->cfg_info.pa);
161
162 bfa_ioc_mbox_send(&bfa->ioc, &cfg_req,
163 sizeof(struct bfi_iocfc_cfg_req_s));
164}
165
166static void
167bfa_iocfc_init_mem(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
168 struct bfa_pcidev_s *pcidev)
169{
170 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
171
172 bfa->bfad = bfad;
173 iocfc->bfa = bfa;
174 iocfc->action = BFA_IOCFC_ACT_NONE;
175
176 bfa_os_assign(iocfc->cfg, *cfg);
177
178 /**
179 * Initialize chip specific handlers.
180 */
181 if (bfa_asic_id_ct(bfa_ioc_devid(&bfa->ioc))) {
182 iocfc->hwif.hw_reginit = bfa_hwct_reginit;
183 iocfc->hwif.hw_reqq_ack = bfa_hwct_reqq_ack;
184 iocfc->hwif.hw_rspq_ack = bfa_hwct_rspq_ack;
185 iocfc->hwif.hw_msix_init = bfa_hwct_msix_init;
186 iocfc->hwif.hw_msix_install = bfa_hwct_msix_install;
187 iocfc->hwif.hw_msix_uninstall = bfa_hwct_msix_uninstall;
188 iocfc->hwif.hw_isr_mode_set = bfa_hwct_isr_mode_set;
189 iocfc->hwif.hw_msix_getvecs = bfa_hwct_msix_getvecs;
190 iocfc->hwif.hw_msix_get_rme_range = bfa_hwct_msix_get_rme_range;
191 } else {
192 iocfc->hwif.hw_reginit = bfa_hwcb_reginit;
193 iocfc->hwif.hw_reqq_ack = bfa_hwcb_reqq_ack;
194 iocfc->hwif.hw_rspq_ack = bfa_hwcb_rspq_ack;
195 iocfc->hwif.hw_msix_init = bfa_hwcb_msix_init;
196 iocfc->hwif.hw_msix_install = bfa_hwcb_msix_install;
197 iocfc->hwif.hw_msix_uninstall = bfa_hwcb_msix_uninstall;
198 iocfc->hwif.hw_isr_mode_set = bfa_hwcb_isr_mode_set;
199 iocfc->hwif.hw_msix_getvecs = bfa_hwcb_msix_getvecs;
200 iocfc->hwif.hw_msix_get_rme_range = bfa_hwcb_msix_get_rme_range;
201 }
202
203 iocfc->hwif.hw_reginit(bfa);
204 bfa->msix.nvecs = 0;
205}
206
207static void
208bfa_iocfc_mem_claim(struct bfa_s *bfa, struct bfa_iocfc_cfg_s *cfg,
209 struct bfa_meminfo_s *meminfo)
210{
211 u8 *dm_kva;
212 u64 dm_pa;
213 int i, per_reqq_sz, per_rspq_sz;
214 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
215 int dbgsz;
216
217 dm_kva = bfa_meminfo_dma_virt(meminfo);
218 dm_pa = bfa_meminfo_dma_phys(meminfo);
219
220 /*
221 * First allocate dma memory for IOC.
222 */
223 bfa_ioc_mem_claim(&bfa->ioc, dm_kva, dm_pa);
224 dm_kva += bfa_ioc_meminfo();
225 dm_pa += bfa_ioc_meminfo();
226
227 /*
228 * Claim DMA-able memory for the request/response queues and for shadow
229 * ci/pi registers
230 */
231 per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ),
232 BFA_DMA_ALIGN_SZ);
233 per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ),
234 BFA_DMA_ALIGN_SZ);
235
236 for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
237 iocfc->req_cq_ba[i].kva = dm_kva;
238 iocfc->req_cq_ba[i].pa = dm_pa;
239 bfa_os_memset(dm_kva, 0, per_reqq_sz);
240 dm_kva += per_reqq_sz;
241 dm_pa += per_reqq_sz;
242
243 iocfc->rsp_cq_ba[i].kva = dm_kva;
244 iocfc->rsp_cq_ba[i].pa = dm_pa;
245 bfa_os_memset(dm_kva, 0, per_rspq_sz);
246 dm_kva += per_rspq_sz;
247 dm_pa += per_rspq_sz;
248 }
249
250 for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
251 iocfc->req_cq_shadow_ci[i].kva = dm_kva;
252 iocfc->req_cq_shadow_ci[i].pa = dm_pa;
253 dm_kva += BFA_CACHELINE_SZ;
254 dm_pa += BFA_CACHELINE_SZ;
255
256 iocfc->rsp_cq_shadow_pi[i].kva = dm_kva;
257 iocfc->rsp_cq_shadow_pi[i].pa = dm_pa;
258 dm_kva += BFA_CACHELINE_SZ;
259 dm_pa += BFA_CACHELINE_SZ;
260 }
261
262 /*
263 * Claim DMA-able memory for the config info page
264 */
265 bfa->iocfc.cfg_info.kva = dm_kva;
266 bfa->iocfc.cfg_info.pa = dm_pa;
267 bfa->iocfc.cfginfo = (struct bfi_iocfc_cfg_s *) dm_kva;
268 dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
269 dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
270
271 /*
272 * Claim DMA-able memory for the config response
273 */
274 bfa->iocfc.cfgrsp_dma.kva = dm_kva;
275 bfa->iocfc.cfgrsp_dma.pa = dm_pa;
276 bfa->iocfc.cfgrsp = (struct bfi_iocfc_cfgrsp_s *) dm_kva;
277
278 dm_kva +=
279 BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
280 BFA_CACHELINE_SZ);
281 dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
282 BFA_CACHELINE_SZ);
283
284 /*
285 * Claim DMA-able memory for iocfc stats
286 */
287 bfa->iocfc.stats_kva = dm_kva;
288 bfa->iocfc.stats_pa = dm_pa;
289 bfa->iocfc.fw_stats = (struct bfa_fw_stats_s *) dm_kva;
290 dm_kva += BFA_ROUNDUP(sizeof(struct bfa_fw_stats_s), BFA_CACHELINE_SZ);
291 dm_pa += BFA_ROUNDUP(sizeof(struct bfa_fw_stats_s), BFA_CACHELINE_SZ);
292
293 bfa_meminfo_dma_virt(meminfo) = dm_kva;
294 bfa_meminfo_dma_phys(meminfo) = dm_pa;
295
296 dbgsz = bfa_ioc_debug_trcsz(bfa_auto_recover);
297 if (dbgsz > 0) {
298 bfa_ioc_debug_memclaim(&bfa->ioc, bfa_meminfo_kva(meminfo));
299 bfa_meminfo_kva(meminfo) += dbgsz;
300 }
301}
302
303/**
304 * Start BFA submodules.
305 */
306static void
307bfa_iocfc_start_submod(struct bfa_s *bfa)
308{
309 int i;
310
311 bfa->rme_process = BFA_TRUE;
312
313 for (i = 0; hal_mods[i]; i++)
314 hal_mods[i]->start(bfa);
315}
316
317/**
318 * Disable BFA submodules.
319 */
320static void
321bfa_iocfc_disable_submod(struct bfa_s *bfa)
322{
323 int i;
324
325 for (i = 0; hal_mods[i]; i++)
326 hal_mods[i]->iocdisable(bfa);
327}
328
329static void
330bfa_iocfc_init_cb(void *bfa_arg, bfa_boolean_t complete)
331{
332 struct bfa_s *bfa = bfa_arg;
333
334 if (complete) {
335 if (bfa->iocfc.cfgdone)
336 bfa_cb_init(bfa->bfad, BFA_STATUS_OK);
337 else
338 bfa_cb_init(bfa->bfad, BFA_STATUS_FAILED);
339 } else {
340 if (bfa->iocfc.cfgdone)
341 bfa->iocfc.action = BFA_IOCFC_ACT_NONE;
342 }
343}
344
345static void
346bfa_iocfc_stop_cb(void *bfa_arg, bfa_boolean_t compl)
347{
348 struct bfa_s *bfa = bfa_arg;
349 struct bfad_s *bfad = bfa->bfad;
350
351 if (compl)
352 complete(&bfad->comp);
353
354 else
355 bfa->iocfc.action = BFA_IOCFC_ACT_NONE;
356}
357
358static void
359bfa_iocfc_disable_cb(void *bfa_arg, bfa_boolean_t compl)
360{
361 struct bfa_s *bfa = bfa_arg;
362 struct bfad_s *bfad = bfa->bfad;
363
364 if (compl)
365 complete(&bfad->disable_comp);
366}
367
368/**
369 * Update BFA configuration from firmware configuration.
370 */
371static void
372bfa_iocfc_cfgrsp(struct bfa_s *bfa)
373{
374 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
375 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
376 struct bfa_iocfc_fwcfg_s *fwcfg = &cfgrsp->fwcfg;
377
378 fwcfg->num_cqs = fwcfg->num_cqs;
379 fwcfg->num_ioim_reqs = bfa_os_ntohs(fwcfg->num_ioim_reqs);
380 fwcfg->num_tskim_reqs = bfa_os_ntohs(fwcfg->num_tskim_reqs);
381 fwcfg->num_fcxp_reqs = bfa_os_ntohs(fwcfg->num_fcxp_reqs);
382 fwcfg->num_uf_bufs = bfa_os_ntohs(fwcfg->num_uf_bufs);
383 fwcfg->num_rports = bfa_os_ntohs(fwcfg->num_rports);
384
385 iocfc->cfgdone = BFA_TRUE;
386
387 /**
388 * Configuration is complete - initialize/start submodules
389 */
390 bfa_fcport_init(bfa);
391
392 if (iocfc->action == BFA_IOCFC_ACT_INIT)
393 bfa_cb_queue(bfa, &iocfc->init_hcb_qe, bfa_iocfc_init_cb, bfa);
394 else
395 bfa_iocfc_start_submod(bfa);
396}
397
398static void
399bfa_iocfc_stats_clear(void *bfa_arg)
400{
401 struct bfa_s *bfa = bfa_arg;
402 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
403 struct bfi_iocfc_stats_req_s stats_req;
404
405 bfa_timer_start(bfa, &iocfc->stats_timer,
406 bfa_iocfc_stats_clr_timeout, bfa,
407 BFA_IOCFC_TOV);
408
409 bfi_h2i_set(stats_req.mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_CLEAR_STATS_REQ,
410 bfa_lpuid(bfa));
411 bfa_ioc_mbox_send(&bfa->ioc, &stats_req,
412 sizeof(struct bfi_iocfc_stats_req_s));
413}
414
415static void
416bfa_iocfc_stats_swap(struct bfa_fw_stats_s *d, struct bfa_fw_stats_s *s)
417{
418 u32 *dip = (u32 *) d;
419 u32 *sip = (u32 *) s;
420 int i;
421
422 for (i = 0; i < (sizeof(struct bfa_fw_stats_s) / sizeof(u32)); i++)
423 dip[i] = bfa_os_ntohl(sip[i]);
424}
425
426static void
427bfa_iocfc_stats_clr_cb(void *bfa_arg, bfa_boolean_t complete)
428{
429 struct bfa_s *bfa = bfa_arg;
430 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
431
432 if (complete) {
433 bfa_ioc_clr_stats(&bfa->ioc);
434 iocfc->stats_cbfn(iocfc->stats_cbarg, iocfc->stats_status);
435 } else {
436 iocfc->stats_busy = BFA_FALSE;
437 iocfc->stats_status = BFA_STATUS_OK;
438 }
439}
440
441static void
442bfa_iocfc_stats_clr_timeout(void *bfa_arg)
443{
444 struct bfa_s *bfa = bfa_arg;
445 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
446
447 bfa_trc(bfa, 0);
448
449 iocfc->stats_status = BFA_STATUS_ETIMER;
450 bfa_cb_queue(bfa, &iocfc->stats_hcb_qe, bfa_iocfc_stats_clr_cb, bfa);
451}
452
453static void
454bfa_iocfc_stats_cb(void *bfa_arg, bfa_boolean_t complete)
455{
456 struct bfa_s *bfa = bfa_arg;
457 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
458
459 if (complete) {
460 if (iocfc->stats_status == BFA_STATUS_OK) {
461 bfa_os_memset(iocfc->stats_ret, 0,
462 sizeof(*iocfc->stats_ret));
463 bfa_iocfc_stats_swap(&iocfc->stats_ret->fw_stats,
464 iocfc->fw_stats);
465 }
466 iocfc->stats_cbfn(iocfc->stats_cbarg, iocfc->stats_status);
467 } else {
468 iocfc->stats_busy = BFA_FALSE;
469 iocfc->stats_status = BFA_STATUS_OK;
470 }
471}
472
473static void
474bfa_iocfc_stats_timeout(void *bfa_arg)
475{
476 struct bfa_s *bfa = bfa_arg;
477 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
478
479 bfa_trc(bfa, 0);
480
481 iocfc->stats_status = BFA_STATUS_ETIMER;
482 bfa_cb_queue(bfa, &iocfc->stats_hcb_qe, bfa_iocfc_stats_cb, bfa);
483}
484
485static void
486bfa_iocfc_stats_query(struct bfa_s *bfa)
487{
488 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
489 struct bfi_iocfc_stats_req_s stats_req;
490
491 bfa_timer_start(bfa, &iocfc->stats_timer,
492 bfa_iocfc_stats_timeout, bfa, BFA_IOCFC_TOV);
493
494 bfi_h2i_set(stats_req.mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_GET_STATS_REQ,
495 bfa_lpuid(bfa));
496 bfa_ioc_mbox_send(&bfa->ioc, &stats_req,
497 sizeof(struct bfi_iocfc_stats_req_s));
498}
499
500void
501bfa_iocfc_reset_queues(struct bfa_s *bfa)
502{
503 int q;
504
505 for (q = 0; q < BFI_IOC_MAX_CQS; q++) {
506 bfa_reqq_ci(bfa, q) = 0;
507 bfa_reqq_pi(bfa, q) = 0;
508 bfa_rspq_ci(bfa, q) = 0;
509 bfa_rspq_pi(bfa, q) = 0;
510 }
511}
512
513/**
514 * IOC enable request is complete
515 */
516static void
517bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status)
518{
519 struct bfa_s *bfa = bfa_arg;
520
521 if (status != BFA_STATUS_OK) {
522 bfa_isr_disable(bfa);
523 if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
524 bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe,
525 bfa_iocfc_init_cb, bfa);
526 return;
527 }
528
529 bfa_iocfc_send_cfg(bfa);
530}
531
532/**
533 * IOC disable request is complete
534 */
535static void
536bfa_iocfc_disable_cbfn(void *bfa_arg)
537{
538 struct bfa_s *bfa = bfa_arg;
539
540 bfa_isr_disable(bfa);
541 bfa_iocfc_disable_submod(bfa);
542
543 if (bfa->iocfc.action == BFA_IOCFC_ACT_STOP)
544 bfa_cb_queue(bfa, &bfa->iocfc.stop_hcb_qe, bfa_iocfc_stop_cb,
545 bfa);
546 else {
547 bfa_assert(bfa->iocfc.action == BFA_IOCFC_ACT_DISABLE);
548 bfa_cb_queue(bfa, &bfa->iocfc.dis_hcb_qe, bfa_iocfc_disable_cb,
549 bfa);
550 }
551}
552
553/**
554 * Notify sub-modules of hardware failure.
555 */
556static void
557bfa_iocfc_hbfail_cbfn(void *bfa_arg)
558{
559 struct bfa_s *bfa = bfa_arg;
560
561 bfa->rme_process = BFA_FALSE;
562
563 bfa_isr_disable(bfa);
564 bfa_iocfc_disable_submod(bfa);
565
566 if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
567 bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe, bfa_iocfc_init_cb,
568 bfa);
569}
570
571/**
572 * Actions on chip-reset completion.
573 */
574static void
575bfa_iocfc_reset_cbfn(void *bfa_arg)
576{
577 struct bfa_s *bfa = bfa_arg;
578
579 bfa_iocfc_reset_queues(bfa);
580 bfa_isr_enable(bfa);
581}
582
583
584
585/**
586 * bfa_ioc_public
587 */
588
589/**
590 * Query IOC memory requirement information.
591 */
592void
593bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
594 u32 *dm_len)
595{
596 /* dma memory for IOC */
597 *dm_len += bfa_ioc_meminfo();
598
599 bfa_iocfc_fw_cfg_sz(cfg, dm_len);
600 bfa_iocfc_cqs_sz(cfg, dm_len);
601 *km_len += bfa_ioc_debug_trcsz(bfa_auto_recover);
602}
603
604/**
605 * Query IOC memory requirement information.
606 */
607void
608bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
609 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
610{
611 int i;
612
613 bfa_iocfc_cbfn.enable_cbfn = bfa_iocfc_enable_cbfn;
614 bfa_iocfc_cbfn.disable_cbfn = bfa_iocfc_disable_cbfn;
615 bfa_iocfc_cbfn.hbfail_cbfn = bfa_iocfc_hbfail_cbfn;
616 bfa_iocfc_cbfn.reset_cbfn = bfa_iocfc_reset_cbfn;
617
618 bfa_ioc_attach(&bfa->ioc, bfa, &bfa_iocfc_cbfn, &bfa->timer_mod,
619 bfa->trcmod, bfa->aen, bfa->logm);
620
621 /**
622 * Set FC mode for BFA_PCI_DEVICE_ID_CT_FC.
623 */
624 if (pcidev->device_id == BFA_PCI_DEVICE_ID_CT_FC)
625 bfa_ioc_set_fcmode(&bfa->ioc);
626
627 bfa_ioc_pci_init(&bfa->ioc, pcidev, BFI_MC_IOCFC);
628 bfa_ioc_mbox_register(&bfa->ioc, bfa_mbox_isrs);
629
630 bfa_iocfc_init_mem(bfa, bfad, cfg, pcidev);
631 bfa_iocfc_mem_claim(bfa, cfg, meminfo);
632 bfa_timer_init(&bfa->timer_mod);
633
634 INIT_LIST_HEAD(&bfa->comp_q);
635 for (i = 0; i < BFI_IOC_MAX_CQS; i++)
636 INIT_LIST_HEAD(&bfa->reqq_waitq[i]);
637}
638
639/**
640 * Query IOC memory requirement information.
641 */
642void
643bfa_iocfc_detach(struct bfa_s *bfa)
644{
645 bfa_ioc_detach(&bfa->ioc);
646}
647
648/**
649 * Query IOC memory requirement information.
650 */
651void
652bfa_iocfc_init(struct bfa_s *bfa)
653{
654 bfa->iocfc.action = BFA_IOCFC_ACT_INIT;
655 bfa_ioc_enable(&bfa->ioc);
656}
657
658/**
659 * IOC start called from bfa_start(). Called to start IOC operations
660 * at driver instantiation for this instance.
661 */
662void
663bfa_iocfc_start(struct bfa_s *bfa)
664{
665 if (bfa->iocfc.cfgdone)
666 bfa_iocfc_start_submod(bfa);
667}
668
669/**
670 * IOC stop called from bfa_stop(). Called only when driver is unloaded
671 * for this instance.
672 */
673void
674bfa_iocfc_stop(struct bfa_s *bfa)
675{
676 bfa->iocfc.action = BFA_IOCFC_ACT_STOP;
677
678 bfa->rme_process = BFA_FALSE;
679 bfa_ioc_disable(&bfa->ioc);
680}
681
682void
683bfa_iocfc_isr(void *bfaarg, struct bfi_mbmsg_s *m)
684{
685 struct bfa_s *bfa = bfaarg;
686 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
687 union bfi_iocfc_i2h_msg_u *msg;
688
689 msg = (union bfi_iocfc_i2h_msg_u *) m;
690 bfa_trc(bfa, msg->mh.msg_id);
691
692 switch (msg->mh.msg_id) {
693 case BFI_IOCFC_I2H_CFG_REPLY:
694 iocfc->cfg_reply = &msg->cfg_reply;
695 bfa_iocfc_cfgrsp(bfa);
696 break;
697
698 case BFI_IOCFC_I2H_GET_STATS_RSP:
699 if (iocfc->stats_busy == BFA_FALSE
700 || iocfc->stats_status == BFA_STATUS_ETIMER)
701 break;
702
703 bfa_timer_stop(&iocfc->stats_timer);
704 iocfc->stats_status = BFA_STATUS_OK;
705 bfa_cb_queue(bfa, &iocfc->stats_hcb_qe, bfa_iocfc_stats_cb,
706 bfa);
707 break;
708 case BFI_IOCFC_I2H_CLEAR_STATS_RSP:
709 /*
710 * check for timer pop before processing the rsp
711 */
712 if (iocfc->stats_busy == BFA_FALSE
713 || iocfc->stats_status == BFA_STATUS_ETIMER)
714 break;
715
716 bfa_timer_stop(&iocfc->stats_timer);
717 iocfc->stats_status = BFA_STATUS_OK;
718 bfa_cb_queue(bfa, &iocfc->stats_hcb_qe,
719 bfa_iocfc_stats_clr_cb, bfa);
720 break;
721 case BFI_IOCFC_I2H_UPDATEQ_RSP:
722 iocfc->updateq_cbfn(iocfc->updateq_cbarg, BFA_STATUS_OK);
723 break;
724 default:
725 bfa_assert(0);
726 }
727}
728
729#ifndef BFA_BIOS_BUILD
730void
731bfa_adapter_get_attr(struct bfa_s *bfa, struct bfa_adapter_attr_s *ad_attr)
732{
733 bfa_ioc_get_adapter_attr(&bfa->ioc, ad_attr);
734}
735
736u64
737bfa_adapter_get_id(struct bfa_s *bfa)
738{
739 return bfa_ioc_get_adid(&bfa->ioc);
740}
741
742void
743bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr)
744{
745 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
746
747 attr->intr_attr.coalesce = iocfc->cfginfo->intr_attr.coalesce;
748
749 attr->intr_attr.delay = iocfc->cfginfo->intr_attr.delay ?
750 bfa_os_ntohs(iocfc->cfginfo->intr_attr.delay) :
751 bfa_os_ntohs(iocfc->cfgrsp->intr_attr.delay);
752
753 attr->intr_attr.latency = iocfc->cfginfo->intr_attr.latency ?
754 bfa_os_ntohs(iocfc->cfginfo->intr_attr.latency) :
755 bfa_os_ntohs(iocfc->cfgrsp->intr_attr.latency);
756
757 attr->config = iocfc->cfg;
758
759}
760
761bfa_status_t
762bfa_iocfc_israttr_set(struct bfa_s *bfa, struct bfa_iocfc_intr_attr_s *attr)
763{
764 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
765 struct bfi_iocfc_set_intr_req_s *m;
766
767 iocfc->cfginfo->intr_attr.coalesce = attr->coalesce;
768 iocfc->cfginfo->intr_attr.delay = bfa_os_htons(attr->delay);
769 iocfc->cfginfo->intr_attr.latency = bfa_os_htons(attr->latency);
770
771 if (!bfa_iocfc_is_operational(bfa))
772 return BFA_STATUS_OK;
773
774 m = bfa_reqq_next(bfa, BFA_REQQ_IOC);
775 if (!m)
776 return BFA_STATUS_DEVBUSY;
777
778 bfi_h2i_set(m->mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_SET_INTR_REQ,
779 bfa_lpuid(bfa));
780 m->coalesce = iocfc->cfginfo->intr_attr.coalesce;
781 m->delay = iocfc->cfginfo->intr_attr.delay;
782 m->latency = iocfc->cfginfo->intr_attr.latency;
783
784
785 bfa_trc(bfa, attr->delay);
786 bfa_trc(bfa, attr->latency);
787
788 bfa_reqq_produce(bfa, BFA_REQQ_IOC);
789 return BFA_STATUS_OK;
790}
791
792void
793bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa)
794{
795 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
796
797 iocfc->cfginfo->sense_buf_len = (BFI_IOIM_SNSLEN - 1);
798 bfa_dma_be_addr_set(iocfc->cfginfo->ioim_snsbase, snsbase_pa);
799}
800
801bfa_status_t
802bfa_iocfc_get_stats(struct bfa_s *bfa, struct bfa_iocfc_stats_s *stats,
803 bfa_cb_ioc_t cbfn, void *cbarg)
804{
805 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
806
807 if (iocfc->stats_busy) {
808 bfa_trc(bfa, iocfc->stats_busy);
809 return BFA_STATUS_DEVBUSY;
810 }
811
812 if (!bfa_iocfc_is_operational(bfa)) {
813 bfa_trc(bfa, 0);
814 return BFA_STATUS_IOC_NON_OP;
815 }
816
817 iocfc->stats_busy = BFA_TRUE;
818 iocfc->stats_ret = stats;
819 iocfc->stats_cbfn = cbfn;
820 iocfc->stats_cbarg = cbarg;
821
822 bfa_iocfc_stats_query(bfa);
823
824 return BFA_STATUS_OK;
825}
826
827bfa_status_t
828bfa_iocfc_clear_stats(struct bfa_s *bfa, bfa_cb_ioc_t cbfn, void *cbarg)
829{
830 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
831
832 if (iocfc->stats_busy) {
833 bfa_trc(bfa, iocfc->stats_busy);
834 return BFA_STATUS_DEVBUSY;
835 }
836
837 if (!bfa_iocfc_is_operational(bfa)) {
838 bfa_trc(bfa, 0);
839 return BFA_STATUS_IOC_NON_OP;
840 }
841
842 iocfc->stats_busy = BFA_TRUE;
843 iocfc->stats_cbfn = cbfn;
844 iocfc->stats_cbarg = cbarg;
845
846 bfa_iocfc_stats_clear(bfa);
847 return BFA_STATUS_OK;
848}
849
850/**
851 * Enable IOC after it is disabled.
852 */
853void
854bfa_iocfc_enable(struct bfa_s *bfa)
855{
856 bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
857 "IOC Enable");
858 bfa_ioc_enable(&bfa->ioc);
859}
860
861void
862bfa_iocfc_disable(struct bfa_s *bfa)
863{
864 bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
865 "IOC Disable");
866 bfa->iocfc.action = BFA_IOCFC_ACT_DISABLE;
867
868 bfa->rme_process = BFA_FALSE;
869 bfa_ioc_disable(&bfa->ioc);
870}
871
872
873bfa_boolean_t
874bfa_iocfc_is_operational(struct bfa_s *bfa)
875{
876 return bfa_ioc_is_operational(&bfa->ioc) && bfa->iocfc.cfgdone;
877}
878
879/**
880 * Return boot target port wwns -- read from boot information in flash.
881 */
882void
883bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns)
884{
885 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
886 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
887 int i;
888
889 if (cfgrsp->pbc_cfg.boot_enabled && cfgrsp->pbc_cfg.nbluns) {
890 bfa_trc(bfa, cfgrsp->pbc_cfg.nbluns);
891 *nwwns = cfgrsp->pbc_cfg.nbluns;
892 for (i = 0; i < cfgrsp->pbc_cfg.nbluns; i++)
893 wwns[i] = cfgrsp->pbc_cfg.blun[i].tgt_pwwn;
894
895 return;
896 }
897
898 *nwwns = cfgrsp->bootwwns.nwwns;
899 memcpy(wwns, cfgrsp->bootwwns.wwn, sizeof(cfgrsp->bootwwns.wwn));
900}
901
902void
903bfa_iocfc_get_pbc_boot_cfg(struct bfa_s *bfa, struct bfa_boot_pbc_s *pbcfg)
904{
905 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
906 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
907
908 pbcfg->enable = cfgrsp->pbc_cfg.boot_enabled;
909 pbcfg->nbluns = cfgrsp->pbc_cfg.nbluns;
910 pbcfg->speed = cfgrsp->pbc_cfg.port_speed;
911 memcpy(pbcfg->pblun, cfgrsp->pbc_cfg.blun, sizeof(pbcfg->pblun));
912}
913
914int
915bfa_iocfc_get_pbc_vports(struct bfa_s *bfa, struct bfi_pbc_vport_s *pbc_vport)
916{
917 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
918 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
919
920 memcpy(pbc_vport, cfgrsp->pbc_cfg.vport, sizeof(cfgrsp->pbc_cfg.vport));
921 return cfgrsp->pbc_cfg.nvports;
922}
923
924
925#endif
926
927
diff --git a/drivers/scsi/bfa/bfa_iocfc.h b/drivers/scsi/bfa/bfa_iocfc.h
deleted file mode 100644
index 74a6a048d1fd..000000000000
--- a/drivers/scsi/bfa/bfa_iocfc.h
+++ /dev/null
@@ -1,184 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_IOCFC_H__
19#define __BFA_IOCFC_H__
20
21#include <bfa_ioc.h>
22#include <bfa.h>
23#include <bfi/bfi_iocfc.h>
24#include <bfi/bfi_pbc.h>
25#include <bfa_callback_priv.h>
26
27#define BFA_REQQ_NELEMS_MIN (4)
28#define BFA_RSPQ_NELEMS_MIN (4)
29
30struct bfa_iocfc_regs_s {
31 bfa_os_addr_t intr_status;
32 bfa_os_addr_t intr_mask;
33 bfa_os_addr_t cpe_q_pi[BFI_IOC_MAX_CQS];
34 bfa_os_addr_t cpe_q_ci[BFI_IOC_MAX_CQS];
35 bfa_os_addr_t cpe_q_depth[BFI_IOC_MAX_CQS];
36 bfa_os_addr_t cpe_q_ctrl[BFI_IOC_MAX_CQS];
37 bfa_os_addr_t rme_q_ci[BFI_IOC_MAX_CQS];
38 bfa_os_addr_t rme_q_pi[BFI_IOC_MAX_CQS];
39 bfa_os_addr_t rme_q_depth[BFI_IOC_MAX_CQS];
40 bfa_os_addr_t rme_q_ctrl[BFI_IOC_MAX_CQS];
41};
42
43/**
44 * MSIX vector handlers
45 */
46#define BFA_MSIX_MAX_VECTORS 22
47typedef void (*bfa_msix_handler_t)(struct bfa_s *bfa, int vec);
48struct bfa_msix_s {
49 int nvecs;
50 bfa_msix_handler_t handler[BFA_MSIX_MAX_VECTORS];
51};
52
53/**
54 * Chip specific interfaces
55 */
56struct bfa_hwif_s {
57 void (*hw_reginit)(struct bfa_s *bfa);
58 void (*hw_reqq_ack)(struct bfa_s *bfa, int reqq);
59 void (*hw_rspq_ack)(struct bfa_s *bfa, int rspq);
60 void (*hw_msix_init)(struct bfa_s *bfa, int nvecs);
61 void (*hw_msix_install)(struct bfa_s *bfa);
62 void (*hw_msix_uninstall)(struct bfa_s *bfa);
63 void (*hw_isr_mode_set)(struct bfa_s *bfa, bfa_boolean_t msix);
64 void (*hw_msix_getvecs)(struct bfa_s *bfa, u32 *vecmap,
65 u32 *nvecs, u32 *maxvec);
66 void (*hw_msix_get_rme_range) (struct bfa_s *bfa, u32 *start,
67 u32 *end);
68};
69typedef void (*bfa_cb_iocfc_t) (void *cbarg, enum bfa_status status);
70
71struct bfa_iocfc_s {
72 struct bfa_s *bfa;
73 struct bfa_iocfc_cfg_s cfg;
74 int action;
75
76 u32 req_cq_pi[BFI_IOC_MAX_CQS];
77 u32 rsp_cq_ci[BFI_IOC_MAX_CQS];
78
79 struct bfa_cb_qe_s init_hcb_qe;
80 struct bfa_cb_qe_s stop_hcb_qe;
81 struct bfa_cb_qe_s dis_hcb_qe;
82 struct bfa_cb_qe_s stats_hcb_qe;
83 bfa_boolean_t cfgdone;
84
85 struct bfa_dma_s cfg_info;
86 struct bfi_iocfc_cfg_s *cfginfo;
87 struct bfa_dma_s cfgrsp_dma;
88 struct bfi_iocfc_cfgrsp_s *cfgrsp;
89 struct bfi_iocfc_cfg_reply_s *cfg_reply;
90
91 u8 *stats_kva;
92 u64 stats_pa;
93 struct bfa_fw_stats_s *fw_stats;
94 struct bfa_timer_s stats_timer; /* timer */
95 struct bfa_iocfc_stats_s *stats_ret; /* driver stats location */
96 bfa_status_t stats_status; /* stats/statsclr status */
97 bfa_boolean_t stats_busy; /* outstanding stats */
98 bfa_cb_ioc_t stats_cbfn; /* driver callback function */
99 void *stats_cbarg; /* user callback arg */
100
101 struct bfa_dma_s req_cq_ba[BFI_IOC_MAX_CQS];
102 struct bfa_dma_s req_cq_shadow_ci[BFI_IOC_MAX_CQS];
103 struct bfa_dma_s rsp_cq_ba[BFI_IOC_MAX_CQS];
104 struct bfa_dma_s rsp_cq_shadow_pi[BFI_IOC_MAX_CQS];
105 struct bfa_iocfc_regs_s bfa_regs; /* BFA device registers */
106 struct bfa_hwif_s hwif;
107
108 bfa_cb_iocfc_t updateq_cbfn; /* bios callback function */
109 void *updateq_cbarg; /* bios callback arg */
110 u32 intr_mask;
111};
112
113#define bfa_lpuid(__bfa) bfa_ioc_portid(&(__bfa)->ioc)
114#define bfa_msix_init(__bfa, __nvecs) \
115 ((__bfa)->iocfc.hwif.hw_msix_init(__bfa, __nvecs))
116#define bfa_msix_install(__bfa) \
117 ((__bfa)->iocfc.hwif.hw_msix_install(__bfa))
118#define bfa_msix_uninstall(__bfa) \
119 ((__bfa)->iocfc.hwif.hw_msix_uninstall(__bfa))
120#define bfa_isr_mode_set(__bfa, __msix) \
121 ((__bfa)->iocfc.hwif.hw_isr_mode_set(__bfa, __msix))
122#define bfa_msix_getvecs(__bfa, __vecmap, __nvecs, __maxvec) \
123 ((__bfa)->iocfc.hwif.hw_msix_getvecs(__bfa, __vecmap, \
124 __nvecs, __maxvec))
125#define bfa_msix_get_rme_range(__bfa, __start, __end) \
126 ((__bfa)->iocfc.hwif.hw_msix_get_rme_range(__bfa, __start, __end))
127
128/*
129 * FC specific IOC functions.
130 */
131void bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
132 u32 *dm_len);
133void bfa_iocfc_attach(struct bfa_s *bfa, void *bfad,
134 struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo,
135 struct bfa_pcidev_s *pcidev);
136void bfa_iocfc_detach(struct bfa_s *bfa);
137void bfa_iocfc_init(struct bfa_s *bfa);
138void bfa_iocfc_start(struct bfa_s *bfa);
139void bfa_iocfc_stop(struct bfa_s *bfa);
140void bfa_iocfc_isr(void *bfa, struct bfi_mbmsg_s *msg);
141void bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa);
142bfa_boolean_t bfa_iocfc_is_operational(struct bfa_s *bfa);
143void bfa_iocfc_reset_queues(struct bfa_s *bfa);
144void bfa_iocfc_updateq(struct bfa_s *bfa, u32 reqq_ba, u32 rspq_ba,
145 u32 reqq_sci, u32 rspq_spi,
146 bfa_cb_iocfc_t cbfn, void *cbarg);
147
148void bfa_msix_all(struct bfa_s *bfa, int vec);
149void bfa_msix_reqq(struct bfa_s *bfa, int vec);
150void bfa_msix_rspq(struct bfa_s *bfa, int vec);
151void bfa_msix_lpu_err(struct bfa_s *bfa, int vec);
152
153void bfa_hwcb_reginit(struct bfa_s *bfa);
154void bfa_hwcb_reqq_ack(struct bfa_s *bfa, int rspq);
155void bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq);
156void bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs);
157void bfa_hwcb_msix_install(struct bfa_s *bfa);
158void bfa_hwcb_msix_uninstall(struct bfa_s *bfa);
159void bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
160void bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *vecmap,
161 u32 *nvecs, u32 *maxvec);
162void bfa_hwcb_msix_get_rme_range(struct bfa_s *bfa, u32 *start, u32 *end);
163void bfa_hwct_reginit(struct bfa_s *bfa);
164void bfa_hwct_reqq_ack(struct bfa_s *bfa, int rspq);
165void bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq);
166void bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs);
167void bfa_hwct_msix_install(struct bfa_s *bfa);
168void bfa_hwct_msix_uninstall(struct bfa_s *bfa);
169void bfa_hwct_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
170void bfa_hwct_msix_getvecs(struct bfa_s *bfa, u32 *vecmap,
171 u32 *nvecs, u32 *maxvec);
172void bfa_hwct_msix_get_rme_range(struct bfa_s *bfa, u32 *start, u32 *end);
173
174void bfa_com_meminfo(bfa_boolean_t mincfg, u32 *dm_len);
175void bfa_com_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi,
176 bfa_boolean_t mincfg);
177void bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns);
178void bfa_iocfc_get_pbc_boot_cfg(struct bfa_s *bfa,
179 struct bfa_boot_pbc_s *pbcfg);
180int bfa_iocfc_get_pbc_vports(struct bfa_s *bfa,
181 struct bfi_pbc_vport_s *pbc_vport);
182
183#endif /* __BFA_IOCFC_H__ */
184
diff --git a/drivers/scsi/bfa/bfa_iocfc_q.c b/drivers/scsi/bfa/bfa_iocfc_q.c
deleted file mode 100644
index 500a17df40b2..000000000000
--- a/drivers/scsi/bfa/bfa_iocfc_q.c
+++ /dev/null
@@ -1,44 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
19#include "bfa_intr_priv.h"
20
21BFA_TRC_FILE(HAL, IOCFC_Q);
22
23void
24bfa_iocfc_updateq(struct bfa_s *bfa, u32 reqq_ba, u32 rspq_ba,
25 u32 reqq_sci, u32 rspq_spi, bfa_cb_iocfc_t cbfn,
26 void *cbarg)
27{
28 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
29 struct bfi_iocfc_updateq_req_s updateq_req;
30
31 iocfc->updateq_cbfn = cbfn;
32 iocfc->updateq_cbarg = cbarg;
33
34 bfi_h2i_set(updateq_req.mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_UPDATEQ_REQ,
35 bfa_lpuid(bfa));
36
37 updateq_req.reqq_ba = bfa_os_htonl(reqq_ba);
38 updateq_req.rspq_ba = bfa_os_htonl(rspq_ba);
39 updateq_req.reqq_sci = bfa_os_htonl(reqq_sci);
40 updateq_req.rspq_spi = bfa_os_htonl(rspq_spi);
41
42 bfa_ioc_mbox_send(&bfa->ioc, &updateq_req,
43 sizeof(struct bfi_iocfc_updateq_req_s));
44}
diff --git a/drivers/scsi/bfa/bfa_ioim.c b/drivers/scsi/bfa/bfa_ioim.c
deleted file mode 100644
index bdfdc19915f8..000000000000
--- a/drivers/scsi/bfa/bfa_ioim.c
+++ /dev/null
@@ -1,1364 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
19#include <cs/bfa_debug.h>
20#include <bfa_cb_ioim_macros.h>
21
22BFA_TRC_FILE(HAL, IOIM);
23
24/*
25 * forward declarations.
26 */
27static bfa_boolean_t bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim);
28static bfa_boolean_t bfa_ioim_sge_setup(struct bfa_ioim_s *ioim);
29static void bfa_ioim_sgpg_setup(struct bfa_ioim_s *ioim);
30static bfa_boolean_t bfa_ioim_send_abort(struct bfa_ioim_s *ioim);
31static void bfa_ioim_notify_cleanup(struct bfa_ioim_s *ioim);
32static void __bfa_cb_ioim_good_comp(void *cbarg, bfa_boolean_t complete);
33static void __bfa_cb_ioim_comp(void *cbarg, bfa_boolean_t complete);
34static void __bfa_cb_ioim_abort(void *cbarg, bfa_boolean_t complete);
35static void __bfa_cb_ioim_failed(void *cbarg, bfa_boolean_t complete);
36static void __bfa_cb_ioim_pathtov(void *cbarg, bfa_boolean_t complete);
37
38/**
39 * bfa_ioim_sm
40 */
41
42/**
43 * IO state machine events
44 */
45enum bfa_ioim_event {
46 BFA_IOIM_SM_START = 1, /* io start request from host */
47 BFA_IOIM_SM_COMP_GOOD = 2, /* io good comp, resource free */
48 BFA_IOIM_SM_COMP = 3, /* io comp, resource is free */
49 BFA_IOIM_SM_COMP_UTAG = 4, /* io comp, resource is free */
50 BFA_IOIM_SM_DONE = 5, /* io comp, resource not free */
51 BFA_IOIM_SM_FREE = 6, /* io resource is freed */
52 BFA_IOIM_SM_ABORT = 7, /* abort request from scsi stack */
53 BFA_IOIM_SM_ABORT_COMP = 8, /* abort from f/w */
54 BFA_IOIM_SM_ABORT_DONE = 9, /* abort completion from f/w */
55 BFA_IOIM_SM_QRESUME = 10, /* CQ space available to queue IO */
56 BFA_IOIM_SM_SGALLOCED = 11, /* SG page allocation successful */
57 BFA_IOIM_SM_SQRETRY = 12, /* sequence recovery retry */
58 BFA_IOIM_SM_HCB = 13, /* bfa callback complete */
59 BFA_IOIM_SM_CLEANUP = 14, /* IO cleanup from itnim */
60 BFA_IOIM_SM_TMSTART = 15, /* IO cleanup from tskim */
61 BFA_IOIM_SM_TMDONE = 16, /* IO cleanup from tskim */
62 BFA_IOIM_SM_HWFAIL = 17, /* IOC h/w failure event */
63 BFA_IOIM_SM_IOTOV = 18, /* ITN offline TOV */
64};
65
66/*
67 * forward declaration of IO state machine
68 */
69static void bfa_ioim_sm_uninit(struct bfa_ioim_s *ioim,
70 enum bfa_ioim_event event);
71static void bfa_ioim_sm_sgalloc(struct bfa_ioim_s *ioim,
72 enum bfa_ioim_event event);
73static void bfa_ioim_sm_active(struct bfa_ioim_s *ioim,
74 enum bfa_ioim_event event);
75static void bfa_ioim_sm_abort(struct bfa_ioim_s *ioim,
76 enum bfa_ioim_event event);
77static void bfa_ioim_sm_cleanup(struct bfa_ioim_s *ioim,
78 enum bfa_ioim_event event);
79static void bfa_ioim_sm_qfull(struct bfa_ioim_s *ioim,
80 enum bfa_ioim_event event);
81static void bfa_ioim_sm_abort_qfull(struct bfa_ioim_s *ioim,
82 enum bfa_ioim_event event);
83static void bfa_ioim_sm_cleanup_qfull(struct bfa_ioim_s *ioim,
84 enum bfa_ioim_event event);
85static void bfa_ioim_sm_hcb(struct bfa_ioim_s *ioim,
86 enum bfa_ioim_event event);
87static void bfa_ioim_sm_hcb_free(struct bfa_ioim_s *ioim,
88 enum bfa_ioim_event event);
89static void bfa_ioim_sm_resfree(struct bfa_ioim_s *ioim,
90 enum bfa_ioim_event event);
91
92/**
93 * IO is not started (unallocated).
94 */
95static void
96bfa_ioim_sm_uninit(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
97{
98 bfa_trc_fp(ioim->bfa, ioim->iotag);
99 bfa_trc_fp(ioim->bfa, event);
100
101 switch (event) {
102 case BFA_IOIM_SM_START:
103 if (!bfa_itnim_is_online(ioim->itnim)) {
104 if (!bfa_itnim_hold_io(ioim->itnim)) {
105 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
106 list_del(&ioim->qe);
107 list_add_tail(&ioim->qe,
108 &ioim->fcpim->ioim_comp_q);
109 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
110 __bfa_cb_ioim_pathtov, ioim);
111 } else {
112 list_del(&ioim->qe);
113 list_add_tail(&ioim->qe,
114 &ioim->itnim->pending_q);
115 }
116 break;
117 }
118
119 if (ioim->nsges > BFI_SGE_INLINE) {
120 if (!bfa_ioim_sge_setup(ioim)) {
121 bfa_sm_set_state(ioim, bfa_ioim_sm_sgalloc);
122 return;
123 }
124 }
125
126 if (!bfa_ioim_send_ioreq(ioim)) {
127 bfa_sm_set_state(ioim, bfa_ioim_sm_qfull);
128 break;
129 }
130
131 bfa_sm_set_state(ioim, bfa_ioim_sm_active);
132 break;
133
134 case BFA_IOIM_SM_IOTOV:
135 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
136 list_del(&ioim->qe);
137 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
138 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
139 __bfa_cb_ioim_pathtov, ioim);
140 break;
141
142 case BFA_IOIM_SM_ABORT:
143 /**
144 * IO in pending queue can get abort requests. Complete abort
145 * requests immediately.
146 */
147 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
148 bfa_assert(bfa_q_is_on_q(&ioim->itnim->pending_q, ioim));
149 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
150 ioim);
151 break;
152
153 default:
154 bfa_sm_fault(ioim->bfa, event);
155 }
156}
157
158/**
159 * IO is waiting for SG pages.
160 */
161static void
162bfa_ioim_sm_sgalloc(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
163{
164 bfa_trc(ioim->bfa, ioim->iotag);
165 bfa_trc(ioim->bfa, event);
166
167 switch (event) {
168 case BFA_IOIM_SM_SGALLOCED:
169 if (!bfa_ioim_send_ioreq(ioim)) {
170 bfa_sm_set_state(ioim, bfa_ioim_sm_qfull);
171 break;
172 }
173 bfa_sm_set_state(ioim, bfa_ioim_sm_active);
174 break;
175
176 case BFA_IOIM_SM_CLEANUP:
177 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
178 bfa_sgpg_wcancel(ioim->bfa, &ioim->iosp->sgpg_wqe);
179 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
180 ioim);
181 bfa_ioim_notify_cleanup(ioim);
182 break;
183
184 case BFA_IOIM_SM_ABORT:
185 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
186 bfa_sgpg_wcancel(ioim->bfa, &ioim->iosp->sgpg_wqe);
187 list_del(&ioim->qe);
188 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
189 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
190 ioim);
191 break;
192
193 case BFA_IOIM_SM_HWFAIL:
194 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
195 bfa_sgpg_wcancel(ioim->bfa, &ioim->iosp->sgpg_wqe);
196 list_del(&ioim->qe);
197 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
198 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
199 ioim);
200 break;
201
202 default:
203 bfa_sm_fault(ioim->bfa, event);
204 }
205}
206
207/**
208 * IO is active.
209 */
210static void
211bfa_ioim_sm_active(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
212{
213 bfa_trc_fp(ioim->bfa, ioim->iotag);
214 bfa_trc_fp(ioim->bfa, event);
215
216 switch (event) {
217 case BFA_IOIM_SM_COMP_GOOD:
218 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
219 list_del(&ioim->qe);
220 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
221 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe,
222 __bfa_cb_ioim_good_comp, ioim);
223 break;
224
225 case BFA_IOIM_SM_COMP:
226 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
227 list_del(&ioim->qe);
228 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
229 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_comp,
230 ioim);
231 break;
232
233 case BFA_IOIM_SM_DONE:
234 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
235 list_del(&ioim->qe);
236 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
237 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_comp,
238 ioim);
239 break;
240
241 case BFA_IOIM_SM_ABORT:
242 ioim->iosp->abort_explicit = BFA_TRUE;
243 ioim->io_cbfn = __bfa_cb_ioim_abort;
244
245 if (bfa_ioim_send_abort(ioim))
246 bfa_sm_set_state(ioim, bfa_ioim_sm_abort);
247 else {
248 bfa_sm_set_state(ioim, bfa_ioim_sm_abort_qfull);
249 bfa_reqq_wait(ioim->bfa, ioim->reqq,
250 &ioim->iosp->reqq_wait);
251 }
252 break;
253
254 case BFA_IOIM_SM_CLEANUP:
255 ioim->iosp->abort_explicit = BFA_FALSE;
256 ioim->io_cbfn = __bfa_cb_ioim_failed;
257
258 if (bfa_ioim_send_abort(ioim))
259 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup);
260 else {
261 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup_qfull);
262 bfa_reqq_wait(ioim->bfa, ioim->reqq,
263 &ioim->iosp->reqq_wait);
264 }
265 break;
266
267 case BFA_IOIM_SM_HWFAIL:
268 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
269 list_del(&ioim->qe);
270 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
271 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
272 ioim);
273 break;
274
275 default:
276 bfa_sm_fault(ioim->bfa, event);
277 }
278}
279
280/**
281 * IO is being aborted, waiting for completion from firmware.
282 */
283static void
284bfa_ioim_sm_abort(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
285{
286 bfa_trc(ioim->bfa, ioim->iotag);
287 bfa_trc(ioim->bfa, event);
288
289 switch (event) {
290 case BFA_IOIM_SM_COMP_GOOD:
291 case BFA_IOIM_SM_COMP:
292 case BFA_IOIM_SM_DONE:
293 case BFA_IOIM_SM_FREE:
294 break;
295
296 case BFA_IOIM_SM_ABORT_DONE:
297 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
298 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
299 ioim);
300 break;
301
302 case BFA_IOIM_SM_ABORT_COMP:
303 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
304 list_del(&ioim->qe);
305 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
306 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
307 ioim);
308 break;
309
310 case BFA_IOIM_SM_COMP_UTAG:
311 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
312 list_del(&ioim->qe);
313 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
314 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
315 ioim);
316 break;
317
318 case BFA_IOIM_SM_CLEANUP:
319 bfa_assert(ioim->iosp->abort_explicit == BFA_TRUE);
320 ioim->iosp->abort_explicit = BFA_FALSE;
321
322 if (bfa_ioim_send_abort(ioim))
323 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup);
324 else {
325 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup_qfull);
326 bfa_reqq_wait(ioim->bfa, ioim->reqq,
327 &ioim->iosp->reqq_wait);
328 }
329 break;
330
331 case BFA_IOIM_SM_HWFAIL:
332 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
333 list_del(&ioim->qe);
334 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
335 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
336 ioim);
337 break;
338
339 default:
340 bfa_sm_fault(ioim->bfa, event);
341 }
342}
343
344/**
345 * IO is being cleaned up (implicit abort), waiting for completion from
346 * firmware.
347 */
348static void
349bfa_ioim_sm_cleanup(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
350{
351 bfa_trc(ioim->bfa, ioim->iotag);
352 bfa_trc(ioim->bfa, event);
353
354 switch (event) {
355 case BFA_IOIM_SM_COMP_GOOD:
356 case BFA_IOIM_SM_COMP:
357 case BFA_IOIM_SM_DONE:
358 case BFA_IOIM_SM_FREE:
359 break;
360
361 case BFA_IOIM_SM_ABORT:
362 /**
363 * IO is already being aborted implicitly
364 */
365 ioim->io_cbfn = __bfa_cb_ioim_abort;
366 break;
367
368 case BFA_IOIM_SM_ABORT_DONE:
369 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
370 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
371 bfa_ioim_notify_cleanup(ioim);
372 break;
373
374 case BFA_IOIM_SM_ABORT_COMP:
375 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
376 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
377 bfa_ioim_notify_cleanup(ioim);
378 break;
379
380 case BFA_IOIM_SM_COMP_UTAG:
381 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
382 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
383 bfa_ioim_notify_cleanup(ioim);
384 break;
385
386 case BFA_IOIM_SM_HWFAIL:
387 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
388 list_del(&ioim->qe);
389 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
390 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
391 ioim);
392 break;
393
394 case BFA_IOIM_SM_CLEANUP:
395 /**
396 * IO can be in cleanup state already due to TM command. 2nd cleanup
397 * request comes from ITN offline event.
398 */
399 break;
400
401 default:
402 bfa_sm_fault(ioim->bfa, event);
403 }
404}
405
406/**
407 * IO is waiting for room in request CQ
408 */
409static void
410bfa_ioim_sm_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
411{
412 bfa_trc(ioim->bfa, ioim->iotag);
413 bfa_trc(ioim->bfa, event);
414
415 switch (event) {
416 case BFA_IOIM_SM_QRESUME:
417 bfa_sm_set_state(ioim, bfa_ioim_sm_active);
418 bfa_ioim_send_ioreq(ioim);
419 break;
420
421 case BFA_IOIM_SM_ABORT:
422 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
423 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
424 list_del(&ioim->qe);
425 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
426 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
427 ioim);
428 break;
429
430 case BFA_IOIM_SM_CLEANUP:
431 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
432 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
433 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
434 ioim);
435 bfa_ioim_notify_cleanup(ioim);
436 break;
437
438 case BFA_IOIM_SM_HWFAIL:
439 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
440 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
441 list_del(&ioim->qe);
442 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
443 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
444 ioim);
445 break;
446
447 default:
448 bfa_sm_fault(ioim->bfa, event);
449 }
450}
451
452/**
453 * Active IO is being aborted, waiting for room in request CQ.
454 */
455static void
456bfa_ioim_sm_abort_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
457{
458 bfa_trc(ioim->bfa, ioim->iotag);
459 bfa_trc(ioim->bfa, event);
460
461 switch (event) {
462 case BFA_IOIM_SM_QRESUME:
463 bfa_sm_set_state(ioim, bfa_ioim_sm_abort);
464 bfa_ioim_send_abort(ioim);
465 break;
466
467 case BFA_IOIM_SM_CLEANUP:
468 bfa_assert(ioim->iosp->abort_explicit == BFA_TRUE);
469 ioim->iosp->abort_explicit = BFA_FALSE;
470 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup_qfull);
471 break;
472
473 case BFA_IOIM_SM_COMP_GOOD:
474 case BFA_IOIM_SM_COMP:
475 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
476 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
477 list_del(&ioim->qe);
478 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
479 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
480 ioim);
481 break;
482
483 case BFA_IOIM_SM_DONE:
484 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
485 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
486 list_del(&ioim->qe);
487 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
488 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_abort,
489 ioim);
490 break;
491
492 case BFA_IOIM_SM_HWFAIL:
493 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
494 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
495 list_del(&ioim->qe);
496 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
497 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
498 ioim);
499 break;
500
501 default:
502 bfa_sm_fault(ioim->bfa, event);
503 }
504}
505
506/**
507 * Active IO is being cleaned up, waiting for room in request CQ.
508 */
509static void
510bfa_ioim_sm_cleanup_qfull(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
511{
512 bfa_trc(ioim->bfa, ioim->iotag);
513 bfa_trc(ioim->bfa, event);
514
515 switch (event) {
516 case BFA_IOIM_SM_QRESUME:
517 bfa_sm_set_state(ioim, bfa_ioim_sm_cleanup);
518 bfa_ioim_send_abort(ioim);
519 break;
520
521 case BFA_IOIM_SM_ABORT:
522 /**
523 * IO is already being cleaned up implicitly
524 */
525 ioim->io_cbfn = __bfa_cb_ioim_abort;
526 break;
527
528 case BFA_IOIM_SM_COMP_GOOD:
529 case BFA_IOIM_SM_COMP:
530 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
531 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
532 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
533 bfa_ioim_notify_cleanup(ioim);
534 break;
535
536 case BFA_IOIM_SM_DONE:
537 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb_free);
538 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
539 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
540 bfa_ioim_notify_cleanup(ioim);
541 break;
542
543 case BFA_IOIM_SM_HWFAIL:
544 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
545 bfa_reqq_wcancel(&ioim->iosp->reqq_wait);
546 list_del(&ioim->qe);
547 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
548 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, __bfa_cb_ioim_failed,
549 ioim);
550 break;
551
552 default:
553 bfa_sm_fault(ioim->bfa, event);
554 }
555}
556
557/**
558 * IO bfa callback is pending.
559 */
560static void
561bfa_ioim_sm_hcb(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
562{
563 bfa_trc_fp(ioim->bfa, ioim->iotag);
564 bfa_trc_fp(ioim->bfa, event);
565
566 switch (event) {
567 case BFA_IOIM_SM_HCB:
568 bfa_sm_set_state(ioim, bfa_ioim_sm_uninit);
569 bfa_ioim_free(ioim);
570 bfa_cb_ioim_resfree(ioim->bfa->bfad);
571 break;
572
573 case BFA_IOIM_SM_CLEANUP:
574 bfa_ioim_notify_cleanup(ioim);
575 break;
576
577 case BFA_IOIM_SM_HWFAIL:
578 break;
579
580 default:
581 bfa_sm_fault(ioim->bfa, event);
582 }
583}
584
585/**
586 * IO bfa callback is pending. IO resource cannot be freed.
587 */
588static void
589bfa_ioim_sm_hcb_free(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
590{
591 bfa_trc(ioim->bfa, ioim->iotag);
592 bfa_trc(ioim->bfa, event);
593
594 switch (event) {
595 case BFA_IOIM_SM_HCB:
596 bfa_sm_set_state(ioim, bfa_ioim_sm_resfree);
597 list_del(&ioim->qe);
598 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_resfree_q);
599 break;
600
601 case BFA_IOIM_SM_FREE:
602 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
603 break;
604
605 case BFA_IOIM_SM_CLEANUP:
606 bfa_ioim_notify_cleanup(ioim);
607 break;
608
609 case BFA_IOIM_SM_HWFAIL:
610 bfa_sm_set_state(ioim, bfa_ioim_sm_hcb);
611 break;
612
613 default:
614 bfa_sm_fault(ioim->bfa, event);
615 }
616}
617
618/**
619 * IO is completed, waiting resource free from firmware.
620 */
621static void
622bfa_ioim_sm_resfree(struct bfa_ioim_s *ioim, enum bfa_ioim_event event)
623{
624 bfa_trc(ioim->bfa, ioim->iotag);
625 bfa_trc(ioim->bfa, event);
626
627 switch (event) {
628 case BFA_IOIM_SM_FREE:
629 bfa_sm_set_state(ioim, bfa_ioim_sm_uninit);
630 bfa_ioim_free(ioim);
631 bfa_cb_ioim_resfree(ioim->bfa->bfad);
632 break;
633
634 case BFA_IOIM_SM_CLEANUP:
635 bfa_ioim_notify_cleanup(ioim);
636 break;
637
638 case BFA_IOIM_SM_HWFAIL:
639 break;
640
641 default:
642 bfa_sm_fault(ioim->bfa, event);
643 }
644}
645
646
647
648/**
649 * bfa_ioim_private
650 */
651
652static void
653__bfa_cb_ioim_good_comp(void *cbarg, bfa_boolean_t complete)
654{
655 struct bfa_ioim_s *ioim = cbarg;
656
657 if (!complete) {
658 bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
659 return;
660 }
661
662 bfa_cb_ioim_good_comp(ioim->bfa->bfad, ioim->dio);
663}
664
665static void
666__bfa_cb_ioim_comp(void *cbarg, bfa_boolean_t complete)
667{
668 struct bfa_ioim_s *ioim = cbarg;
669 struct bfi_ioim_rsp_s *m;
670 u8 *snsinfo = NULL;
671 u8 sns_len = 0;
672 s32 residue = 0;
673
674 if (!complete) {
675 bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
676 return;
677 }
678
679 m = (struct bfi_ioim_rsp_s *) &ioim->iosp->comp_rspmsg;
680 if (m->io_status == BFI_IOIM_STS_OK) {
681 /**
682 * setup sense information, if present
683 */
684 if (m->scsi_status == SCSI_STATUS_CHECK_CONDITION
685 && m->sns_len) {
686 sns_len = m->sns_len;
687 snsinfo = ioim->iosp->snsinfo;
688 }
689
690 /**
691 * setup residue value correctly for normal completions
692 */
693 if (m->resid_flags == FCP_RESID_UNDER)
694 residue = bfa_os_ntohl(m->residue);
695 if (m->resid_flags == FCP_RESID_OVER) {
696 residue = bfa_os_ntohl(m->residue);
697 residue = -residue;
698 }
699 }
700
701 bfa_cb_ioim_done(ioim->bfa->bfad, ioim->dio, m->io_status,
702 m->scsi_status, sns_len, snsinfo, residue);
703}
704
705static void
706__bfa_cb_ioim_failed(void *cbarg, bfa_boolean_t complete)
707{
708 struct bfa_ioim_s *ioim = cbarg;
709
710 if (!complete) {
711 bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
712 return;
713 }
714
715 bfa_cb_ioim_done(ioim->bfa->bfad, ioim->dio, BFI_IOIM_STS_ABORTED,
716 0, 0, NULL, 0);
717}
718
719static void
720__bfa_cb_ioim_pathtov(void *cbarg, bfa_boolean_t complete)
721{
722 struct bfa_ioim_s *ioim = cbarg;
723
724 if (!complete) {
725 bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
726 return;
727 }
728
729 bfa_cb_ioim_done(ioim->bfa->bfad, ioim->dio, BFI_IOIM_STS_PATHTOV,
730 0, 0, NULL, 0);
731}
732
733static void
734__bfa_cb_ioim_abort(void *cbarg, bfa_boolean_t complete)
735{
736 struct bfa_ioim_s *ioim = cbarg;
737
738 if (!complete) {
739 bfa_sm_send_event(ioim, BFA_IOIM_SM_HCB);
740 return;
741 }
742
743 bfa_cb_ioim_abort(ioim->bfa->bfad, ioim->dio);
744}
745
746static void
747bfa_ioim_sgpg_alloced(void *cbarg)
748{
749 struct bfa_ioim_s *ioim = cbarg;
750
751 ioim->nsgpgs = BFA_SGPG_NPAGE(ioim->nsges);
752 list_splice_tail_init(&ioim->iosp->sgpg_wqe.sgpg_q, &ioim->sgpg_q);
753 bfa_ioim_sgpg_setup(ioim);
754 bfa_sm_send_event(ioim, BFA_IOIM_SM_SGALLOCED);
755}
756
757/**
758 * Send I/O request to firmware.
759 */
760static bfa_boolean_t
761bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim)
762{
763 struct bfa_itnim_s *itnim = ioim->itnim;
764 struct bfi_ioim_req_s *m;
765 static struct fcp_cmnd_s cmnd_z0 = { 0 };
766 struct bfi_sge_s *sge;
767 u32 pgdlen = 0;
768 u64 addr;
769 struct scatterlist *sg;
770 struct scsi_cmnd *cmnd = (struct scsi_cmnd *) ioim->dio;
771
772 /**
773 * check for room in queue to send request now
774 */
775 m = bfa_reqq_next(ioim->bfa, ioim->reqq);
776 if (!m) {
777 bfa_reqq_wait(ioim->bfa, ioim->reqq,
778 &ioim->iosp->reqq_wait);
779 return BFA_FALSE;
780 }
781
782 /**
783 * build i/o request message next
784 */
785 m->io_tag = bfa_os_htons(ioim->iotag);
786 m->rport_hdl = ioim->itnim->rport->fw_handle;
787 m->io_timeout = bfa_cb_ioim_get_timeout(ioim->dio);
788
789 /**
790 * build inline IO SG element here
791 */
792 sge = &m->sges[0];
793 if (ioim->nsges) {
794 sg = (struct scatterlist *)scsi_sglist(cmnd);
795 addr = bfa_os_sgaddr(sg_dma_address(sg));
796 sge->sga = *(union bfi_addr_u *) &addr;
797 pgdlen = sg_dma_len(sg);
798 sge->sg_len = pgdlen;
799 sge->flags = (ioim->nsges > BFI_SGE_INLINE) ?
800 BFI_SGE_DATA_CPL : BFI_SGE_DATA_LAST;
801 bfa_sge_to_be(sge);
802 sge++;
803 }
804
805 if (ioim->nsges > BFI_SGE_INLINE) {
806 sge->sga = ioim->sgpg->sgpg_pa;
807 } else {
808 sge->sga.a32.addr_lo = 0;
809 sge->sga.a32.addr_hi = 0;
810 }
811 sge->sg_len = pgdlen;
812 sge->flags = BFI_SGE_PGDLEN;
813 bfa_sge_to_be(sge);
814
815 /**
816 * set up I/O command parameters
817 */
818 bfa_os_assign(m->cmnd, cmnd_z0);
819 m->cmnd.lun = bfa_cb_ioim_get_lun(ioim->dio);
820 m->cmnd.iodir = bfa_cb_ioim_get_iodir(ioim->dio);
821 bfa_os_assign(m->cmnd.cdb,
822 *(struct scsi_cdb_s *)bfa_cb_ioim_get_cdb(ioim->dio));
823 m->cmnd.fcp_dl = bfa_os_htonl(bfa_cb_ioim_get_size(ioim->dio));
824
825 /**
826 * set up I/O message header
827 */
828 switch (m->cmnd.iodir) {
829 case FCP_IODIR_READ:
830 bfi_h2i_set(m->mh, BFI_MC_IOIM_READ, 0, bfa_lpuid(ioim->bfa));
831 bfa_stats(itnim, input_reqs);
832 break;
833 case FCP_IODIR_WRITE:
834 bfi_h2i_set(m->mh, BFI_MC_IOIM_WRITE, 0, bfa_lpuid(ioim->bfa));
835 bfa_stats(itnim, output_reqs);
836 break;
837 case FCP_IODIR_RW:
838 bfa_stats(itnim, input_reqs);
839 bfa_stats(itnim, output_reqs);
840 default:
841 bfi_h2i_set(m->mh, BFI_MC_IOIM_IO, 0, bfa_lpuid(ioim->bfa));
842 }
843 if (itnim->seq_rec ||
844 (bfa_cb_ioim_get_size(ioim->dio) & (sizeof(u32) - 1)))
845 bfi_h2i_set(m->mh, BFI_MC_IOIM_IO, 0, bfa_lpuid(ioim->bfa));
846
847#ifdef IOIM_ADVANCED
848 m->cmnd.crn = bfa_cb_ioim_get_crn(ioim->dio);
849 m->cmnd.priority = bfa_cb_ioim_get_priority(ioim->dio);
850 m->cmnd.taskattr = bfa_cb_ioim_get_taskattr(ioim->dio);
851
852 /**
853 * Handle large CDB (>16 bytes).
854 */
855 m->cmnd.addl_cdb_len = (bfa_cb_ioim_get_cdblen(ioim->dio) -
856 FCP_CMND_CDB_LEN) / sizeof(u32);
857 if (m->cmnd.addl_cdb_len) {
858 bfa_os_memcpy(&m->cmnd.cdb + 1, (struct scsi_cdb_s *)
859 bfa_cb_ioim_get_cdb(ioim->dio) + 1,
860 m->cmnd.addl_cdb_len * sizeof(u32));
861 fcp_cmnd_fcpdl(&m->cmnd) =
862 bfa_os_htonl(bfa_cb_ioim_get_size(ioim->dio));
863 }
864#endif
865
866 /**
867 * queue I/O message to firmware
868 */
869 bfa_reqq_produce(ioim->bfa, ioim->reqq);
870 return BFA_TRUE;
871}
872
873/**
874 * Setup any additional SG pages needed.Inline SG element is setup
875 * at queuing time.
876 */
877static bfa_boolean_t
878bfa_ioim_sge_setup(struct bfa_ioim_s *ioim)
879{
880 u16 nsgpgs;
881
882 bfa_assert(ioim->nsges > BFI_SGE_INLINE);
883
884 /**
885 * allocate SG pages needed
886 */
887 nsgpgs = BFA_SGPG_NPAGE(ioim->nsges);
888 if (!nsgpgs)
889 return BFA_TRUE;
890
891 if (bfa_sgpg_malloc(ioim->bfa, &ioim->sgpg_q, nsgpgs)
892 != BFA_STATUS_OK) {
893 bfa_sgpg_wait(ioim->bfa, &ioim->iosp->sgpg_wqe, nsgpgs);
894 return BFA_FALSE;
895 }
896
897 ioim->nsgpgs = nsgpgs;
898 bfa_ioim_sgpg_setup(ioim);
899
900 return BFA_TRUE;
901}
902
903static void
904bfa_ioim_sgpg_setup(struct bfa_ioim_s *ioim)
905{
906 int sgeid, nsges, i;
907 struct bfi_sge_s *sge;
908 struct bfa_sgpg_s *sgpg;
909 u32 pgcumsz;
910 u64 addr;
911 struct scatterlist *sg;
912 struct scsi_cmnd *cmnd = (struct scsi_cmnd *) ioim->dio;
913
914 sgeid = BFI_SGE_INLINE;
915 ioim->sgpg = sgpg = bfa_q_first(&ioim->sgpg_q);
916
917 sg = scsi_sglist(cmnd);
918 sg = sg_next(sg);
919
920 do {
921 sge = sgpg->sgpg->sges;
922 nsges = ioim->nsges - sgeid;
923 if (nsges > BFI_SGPG_DATA_SGES)
924 nsges = BFI_SGPG_DATA_SGES;
925
926 pgcumsz = 0;
927 for (i = 0; i < nsges; i++, sge++, sgeid++, sg = sg_next(sg)) {
928 addr = bfa_os_sgaddr(sg_dma_address(sg));
929 sge->sga = *(union bfi_addr_u *) &addr;
930 sge->sg_len = sg_dma_len(sg);
931 pgcumsz += sge->sg_len;
932
933 /**
934 * set flags
935 */
936 if (i < (nsges - 1))
937 sge->flags = BFI_SGE_DATA;
938 else if (sgeid < (ioim->nsges - 1))
939 sge->flags = BFI_SGE_DATA_CPL;
940 else
941 sge->flags = BFI_SGE_DATA_LAST;
942 }
943
944 sgpg = (struct bfa_sgpg_s *) bfa_q_next(sgpg);
945
946 /**
947 * set the link element of each page
948 */
949 if (sgeid == ioim->nsges) {
950 sge->flags = BFI_SGE_PGDLEN;
951 sge->sga.a32.addr_lo = 0;
952 sge->sga.a32.addr_hi = 0;
953 } else {
954 sge->flags = BFI_SGE_LINK;
955 sge->sga = sgpg->sgpg_pa;
956 }
957 sge->sg_len = pgcumsz;
958 } while (sgeid < ioim->nsges);
959}
960
961/**
962 * Send I/O abort request to firmware.
963 */
964static bfa_boolean_t
965bfa_ioim_send_abort(struct bfa_ioim_s *ioim)
966{
967 struct bfi_ioim_abort_req_s *m;
968 enum bfi_ioim_h2i msgop;
969
970 /**
971 * check for room in queue to send request now
972 */
973 m = bfa_reqq_next(ioim->bfa, ioim->reqq);
974 if (!m)
975 return BFA_FALSE;
976
977 /**
978 * build i/o request message next
979 */
980 if (ioim->iosp->abort_explicit)
981 msgop = BFI_IOIM_H2I_IOABORT_REQ;
982 else
983 msgop = BFI_IOIM_H2I_IOCLEANUP_REQ;
984
985 bfi_h2i_set(m->mh, BFI_MC_IOIM, msgop, bfa_lpuid(ioim->bfa));
986 m->io_tag = bfa_os_htons(ioim->iotag);
987 m->abort_tag = ++ioim->abort_tag;
988
989 /**
990 * queue I/O message to firmware
991 */
992 bfa_reqq_produce(ioim->bfa, ioim->reqq);
993 return BFA_TRUE;
994}
995
996/**
997 * Call to resume any I/O requests waiting for room in request queue.
998 */
999static void
1000bfa_ioim_qresume(void *cbarg)
1001{
1002 struct bfa_ioim_s *ioim = cbarg;
1003
1004 bfa_fcpim_stats(ioim->fcpim, qresumes);
1005 bfa_sm_send_event(ioim, BFA_IOIM_SM_QRESUME);
1006}
1007
1008
1009static void
1010bfa_ioim_notify_cleanup(struct bfa_ioim_s *ioim)
1011{
1012 /**
1013 * Move IO from itnim queue to fcpim global queue since itnim will be
1014 * freed.
1015 */
1016 list_del(&ioim->qe);
1017 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
1018
1019 if (!ioim->iosp->tskim) {
1020 if (ioim->fcpim->delay_comp && ioim->itnim->iotov_active) {
1021 bfa_cb_dequeue(&ioim->hcb_qe);
1022 list_del(&ioim->qe);
1023 list_add_tail(&ioim->qe, &ioim->itnim->delay_comp_q);
1024 }
1025 bfa_itnim_iodone(ioim->itnim);
1026 } else
1027 bfa_tskim_iodone(ioim->iosp->tskim);
1028}
1029
1030/**
1031 * or after the link comes back.
1032 */
1033void
1034bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim, bfa_boolean_t iotov)
1035{
1036 /**
1037 * If path tov timer expired, failback with PATHTOV status - these
1038 * IO requests are not normally retried by IO stack.
1039 *
1040 * Otherwise device cameback online and fail it with normal failed
1041 * status so that IO stack retries these failed IO requests.
1042 */
1043 if (iotov)
1044 ioim->io_cbfn = __bfa_cb_ioim_pathtov;
1045 else
1046 ioim->io_cbfn = __bfa_cb_ioim_failed;
1047
1048 bfa_cb_queue(ioim->bfa, &ioim->hcb_qe, ioim->io_cbfn, ioim);
1049
1050 /**
1051 * Move IO to fcpim global queue since itnim will be
1052 * freed.
1053 */
1054 list_del(&ioim->qe);
1055 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
1056}
1057
1058
1059
1060/**
1061 * bfa_ioim_friend
1062 */
1063
1064/**
1065 * Memory allocation and initialization.
1066 */
1067void
1068bfa_ioim_attach(struct bfa_fcpim_mod_s *fcpim, struct bfa_meminfo_s *minfo)
1069{
1070 struct bfa_ioim_s *ioim;
1071 struct bfa_ioim_sp_s *iosp;
1072 u16 i;
1073 u8 *snsinfo;
1074 u32 snsbufsz;
1075
1076 /**
1077 * claim memory first
1078 */
1079 ioim = (struct bfa_ioim_s *) bfa_meminfo_kva(minfo);
1080 fcpim->ioim_arr = ioim;
1081 bfa_meminfo_kva(minfo) = (u8 *) (ioim + fcpim->num_ioim_reqs);
1082
1083 iosp = (struct bfa_ioim_sp_s *) bfa_meminfo_kva(minfo);
1084 fcpim->ioim_sp_arr = iosp;
1085 bfa_meminfo_kva(minfo) = (u8 *) (iosp + fcpim->num_ioim_reqs);
1086
1087 /**
1088 * Claim DMA memory for per IO sense data.
1089 */
1090 snsbufsz = fcpim->num_ioim_reqs * BFI_IOIM_SNSLEN;
1091 fcpim->snsbase.pa = bfa_meminfo_dma_phys(minfo);
1092 bfa_meminfo_dma_phys(minfo) += snsbufsz;
1093
1094 fcpim->snsbase.kva = bfa_meminfo_dma_virt(minfo);
1095 bfa_meminfo_dma_virt(minfo) += snsbufsz;
1096 snsinfo = fcpim->snsbase.kva;
1097 bfa_iocfc_set_snsbase(fcpim->bfa, fcpim->snsbase.pa);
1098
1099 /**
1100 * Initialize ioim free queues
1101 */
1102 INIT_LIST_HEAD(&fcpim->ioim_free_q);
1103 INIT_LIST_HEAD(&fcpim->ioim_resfree_q);
1104 INIT_LIST_HEAD(&fcpim->ioim_comp_q);
1105
1106 for (i = 0; i < fcpim->num_ioim_reqs;
1107 i++, ioim++, iosp++, snsinfo += BFI_IOIM_SNSLEN) {
1108 /*
1109 * initialize IOIM
1110 */
1111 bfa_os_memset(ioim, 0, sizeof(struct bfa_ioim_s));
1112 ioim->iotag = i;
1113 ioim->bfa = fcpim->bfa;
1114 ioim->fcpim = fcpim;
1115 ioim->iosp = iosp;
1116 iosp->snsinfo = snsinfo;
1117 INIT_LIST_HEAD(&ioim->sgpg_q);
1118 bfa_reqq_winit(&ioim->iosp->reqq_wait,
1119 bfa_ioim_qresume, ioim);
1120 bfa_sgpg_winit(&ioim->iosp->sgpg_wqe,
1121 bfa_ioim_sgpg_alloced, ioim);
1122 bfa_sm_set_state(ioim, bfa_ioim_sm_uninit);
1123
1124 list_add_tail(&ioim->qe, &fcpim->ioim_free_q);
1125 }
1126}
1127
1128/**
1129 * Driver detach time call.
1130 */
1131void
1132bfa_ioim_detach(struct bfa_fcpim_mod_s *fcpim)
1133{
1134}
1135
1136void
1137bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
1138{
1139 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
1140 struct bfi_ioim_rsp_s *rsp = (struct bfi_ioim_rsp_s *) m;
1141 struct bfa_ioim_s *ioim;
1142 u16 iotag;
1143 enum bfa_ioim_event evt = BFA_IOIM_SM_COMP;
1144
1145 iotag = bfa_os_ntohs(rsp->io_tag);
1146
1147 ioim = BFA_IOIM_FROM_TAG(fcpim, iotag);
1148 bfa_assert(ioim->iotag == iotag);
1149
1150 bfa_trc(ioim->bfa, ioim->iotag);
1151 bfa_trc(ioim->bfa, rsp->io_status);
1152 bfa_trc(ioim->bfa, rsp->reuse_io_tag);
1153
1154 if (bfa_sm_cmp_state(ioim, bfa_ioim_sm_active))
1155 bfa_os_assign(ioim->iosp->comp_rspmsg, *m);
1156
1157 switch (rsp->io_status) {
1158 case BFI_IOIM_STS_OK:
1159 bfa_fcpim_stats(fcpim, iocomp_ok);
1160 if (rsp->reuse_io_tag == 0)
1161 evt = BFA_IOIM_SM_DONE;
1162 else
1163 evt = BFA_IOIM_SM_COMP;
1164 break;
1165
1166 case BFI_IOIM_STS_TIMEDOUT:
1167 case BFI_IOIM_STS_ABORTED:
1168 rsp->io_status = BFI_IOIM_STS_ABORTED;
1169 bfa_fcpim_stats(fcpim, iocomp_aborted);
1170 if (rsp->reuse_io_tag == 0)
1171 evt = BFA_IOIM_SM_DONE;
1172 else
1173 evt = BFA_IOIM_SM_COMP;
1174 break;
1175
1176 case BFI_IOIM_STS_PROTO_ERR:
1177 bfa_fcpim_stats(fcpim, iocom_proto_err);
1178 bfa_assert(rsp->reuse_io_tag);
1179 evt = BFA_IOIM_SM_COMP;
1180 break;
1181
1182 case BFI_IOIM_STS_SQER_NEEDED:
1183 bfa_fcpim_stats(fcpim, iocom_sqer_needed);
1184 bfa_assert(rsp->reuse_io_tag == 0);
1185 evt = BFA_IOIM_SM_SQRETRY;
1186 break;
1187
1188 case BFI_IOIM_STS_RES_FREE:
1189 bfa_fcpim_stats(fcpim, iocom_res_free);
1190 evt = BFA_IOIM_SM_FREE;
1191 break;
1192
1193 case BFI_IOIM_STS_HOST_ABORTED:
1194 bfa_fcpim_stats(fcpim, iocom_hostabrts);
1195 if (rsp->abort_tag != ioim->abort_tag) {
1196 bfa_trc(ioim->bfa, rsp->abort_tag);
1197 bfa_trc(ioim->bfa, ioim->abort_tag);
1198 return;
1199 }
1200
1201 if (rsp->reuse_io_tag)
1202 evt = BFA_IOIM_SM_ABORT_COMP;
1203 else
1204 evt = BFA_IOIM_SM_ABORT_DONE;
1205 break;
1206
1207 case BFI_IOIM_STS_UTAG:
1208 bfa_fcpim_stats(fcpim, iocom_utags);
1209 evt = BFA_IOIM_SM_COMP_UTAG;
1210 break;
1211
1212 default:
1213 bfa_assert(0);
1214 }
1215
1216 bfa_sm_send_event(ioim, evt);
1217}
1218
1219void
1220bfa_ioim_good_comp_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
1221{
1222 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
1223 struct bfi_ioim_rsp_s *rsp = (struct bfi_ioim_rsp_s *) m;
1224 struct bfa_ioim_s *ioim;
1225 u16 iotag;
1226
1227 iotag = bfa_os_ntohs(rsp->io_tag);
1228
1229 ioim = BFA_IOIM_FROM_TAG(fcpim, iotag);
1230 bfa_assert(ioim->iotag == iotag);
1231
1232 bfa_trc_fp(ioim->bfa, ioim->iotag);
1233 bfa_sm_send_event(ioim, BFA_IOIM_SM_COMP_GOOD);
1234}
1235
1236/**
1237 * Called by itnim to clean up IO while going offline.
1238 */
1239void
1240bfa_ioim_cleanup(struct bfa_ioim_s *ioim)
1241{
1242 bfa_trc(ioim->bfa, ioim->iotag);
1243 bfa_fcpim_stats(ioim->fcpim, io_cleanups);
1244
1245 ioim->iosp->tskim = NULL;
1246 bfa_sm_send_event(ioim, BFA_IOIM_SM_CLEANUP);
1247}
1248
1249void
1250bfa_ioim_cleanup_tm(struct bfa_ioim_s *ioim, struct bfa_tskim_s *tskim)
1251{
1252 bfa_trc(ioim->bfa, ioim->iotag);
1253 bfa_fcpim_stats(ioim->fcpim, io_tmaborts);
1254
1255 ioim->iosp->tskim = tskim;
1256 bfa_sm_send_event(ioim, BFA_IOIM_SM_CLEANUP);
1257}
1258
1259/**
1260 * IOC failure handling.
1261 */
1262void
1263bfa_ioim_iocdisable(struct bfa_ioim_s *ioim)
1264{
1265 bfa_sm_send_event(ioim, BFA_IOIM_SM_HWFAIL);
1266}
1267
1268/**
1269 * IO offline TOV popped. Fail the pending IO.
1270 */
1271void
1272bfa_ioim_tov(struct bfa_ioim_s *ioim)
1273{
1274 bfa_sm_send_event(ioim, BFA_IOIM_SM_IOTOV);
1275}
1276
1277
1278
1279/**
1280 * bfa_ioim_api
1281 */
1282
1283/**
1284 * Allocate IOIM resource for initiator mode I/O request.
1285 */
1286struct bfa_ioim_s *
1287bfa_ioim_alloc(struct bfa_s *bfa, struct bfad_ioim_s *dio,
1288 struct bfa_itnim_s *itnim, u16 nsges)
1289{
1290 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
1291 struct bfa_ioim_s *ioim;
1292
1293 /**
1294 * alocate IOIM resource
1295 */
1296 bfa_q_deq(&fcpim->ioim_free_q, &ioim);
1297 if (!ioim) {
1298 bfa_fcpim_stats(fcpim, no_iotags);
1299 return NULL;
1300 }
1301
1302 ioim->dio = dio;
1303 ioim->itnim = itnim;
1304 ioim->nsges = nsges;
1305 ioim->nsgpgs = 0;
1306
1307 bfa_stats(fcpim, total_ios);
1308 bfa_stats(itnim, ios);
1309 fcpim->ios_active++;
1310
1311 list_add_tail(&ioim->qe, &itnim->io_q);
1312 bfa_trc_fp(ioim->bfa, ioim->iotag);
1313
1314 return ioim;
1315}
1316
1317void
1318bfa_ioim_free(struct bfa_ioim_s *ioim)
1319{
1320 struct bfa_fcpim_mod_s *fcpim = ioim->fcpim;
1321
1322 bfa_trc_fp(ioim->bfa, ioim->iotag);
1323 bfa_assert_fp(bfa_sm_cmp_state(ioim, bfa_ioim_sm_uninit));
1324
1325 bfa_assert_fp(list_empty(&ioim->sgpg_q)
1326 || (ioim->nsges > BFI_SGE_INLINE));
1327
1328 if (ioim->nsgpgs > 0)
1329 bfa_sgpg_mfree(ioim->bfa, &ioim->sgpg_q, ioim->nsgpgs);
1330
1331 bfa_stats(ioim->itnim, io_comps);
1332 fcpim->ios_active--;
1333
1334 list_del(&ioim->qe);
1335 list_add_tail(&ioim->qe, &fcpim->ioim_free_q);
1336}
1337
1338void
1339bfa_ioim_start(struct bfa_ioim_s *ioim)
1340{
1341 bfa_trc_fp(ioim->bfa, ioim->iotag);
1342
1343 /**
1344 * Obtain the queue over which this request has to be issued
1345 */
1346 ioim->reqq = bfa_fcpim_ioredirect_enabled(ioim->bfa) ?
1347 bfa_cb_ioim_get_reqq(ioim->dio) :
1348 bfa_itnim_get_reqq(ioim);
1349
1350 bfa_sm_send_event(ioim, BFA_IOIM_SM_START);
1351}
1352
1353/**
1354 * Driver I/O abort request.
1355 */
1356void
1357bfa_ioim_abort(struct bfa_ioim_s *ioim)
1358{
1359 bfa_trc(ioim->bfa, ioim->iotag);
1360 bfa_fcpim_stats(ioim->fcpim, io_aborts);
1361 bfa_sm_send_event(ioim, BFA_IOIM_SM_ABORT);
1362}
1363
1364
diff --git a/drivers/scsi/bfa/bfa_itnim.c b/drivers/scsi/bfa/bfa_itnim.c
deleted file mode 100644
index a914ff255135..000000000000
--- a/drivers/scsi/bfa/bfa_itnim.c
+++ /dev/null
@@ -1,1088 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
19#include <bfa_fcpim.h>
20#include "bfa_fcpim_priv.h"
21
22BFA_TRC_FILE(HAL, ITNIM);
23
24#define BFA_ITNIM_FROM_TAG(_fcpim, _tag) \
25 ((_fcpim)->itnim_arr + ((_tag) & ((_fcpim)->num_itnims - 1)))
26
27#define bfa_fcpim_additn(__itnim) \
28 list_add_tail(&(__itnim)->qe, &(__itnim)->fcpim->itnim_q)
29#define bfa_fcpim_delitn(__itnim) do { \
30 bfa_assert(bfa_q_is_on_q(&(__itnim)->fcpim->itnim_q, __itnim)); \
31 list_del(&(__itnim)->qe); \
32 bfa_assert(list_empty(&(__itnim)->io_q)); \
33 bfa_assert(list_empty(&(__itnim)->io_cleanup_q)); \
34 bfa_assert(list_empty(&(__itnim)->pending_q)); \
35} while (0)
36
37#define bfa_itnim_online_cb(__itnim) do { \
38 if ((__itnim)->bfa->fcs) \
39 bfa_cb_itnim_online((__itnim)->ditn); \
40 else { \
41 bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe, \
42 __bfa_cb_itnim_online, (__itnim)); \
43 } \
44} while (0)
45
46#define bfa_itnim_offline_cb(__itnim) do { \
47 if ((__itnim)->bfa->fcs) \
48 bfa_cb_itnim_offline((__itnim)->ditn); \
49 else { \
50 bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe, \
51 __bfa_cb_itnim_offline, (__itnim)); \
52 } \
53} while (0)
54
55#define bfa_itnim_sler_cb(__itnim) do { \
56 if ((__itnim)->bfa->fcs) \
57 bfa_cb_itnim_sler((__itnim)->ditn); \
58 else { \
59 bfa_cb_queue((__itnim)->bfa, &(__itnim)->hcb_qe, \
60 __bfa_cb_itnim_sler, (__itnim)); \
61 } \
62} while (0)
63
64/*
65 * forward declarations
66 */
67static void bfa_itnim_iocdisable_cleanup(struct bfa_itnim_s *itnim);
68static bfa_boolean_t bfa_itnim_send_fwcreate(struct bfa_itnim_s *itnim);
69static bfa_boolean_t bfa_itnim_send_fwdelete(struct bfa_itnim_s *itnim);
70static void bfa_itnim_cleanp_comp(void *itnim_cbarg);
71static void bfa_itnim_cleanup(struct bfa_itnim_s *itnim);
72static void __bfa_cb_itnim_online(void *cbarg, bfa_boolean_t complete);
73static void __bfa_cb_itnim_offline(void *cbarg, bfa_boolean_t complete);
74static void __bfa_cb_itnim_sler(void *cbarg, bfa_boolean_t complete);
75static void bfa_itnim_iotov_online(struct bfa_itnim_s *itnim);
76static void bfa_itnim_iotov_cleanup(struct bfa_itnim_s *itnim);
77static void bfa_itnim_iotov(void *itnim_arg);
78static void bfa_itnim_iotov_start(struct bfa_itnim_s *itnim);
79static void bfa_itnim_iotov_stop(struct bfa_itnim_s *itnim);
80static void bfa_itnim_iotov_delete(struct bfa_itnim_s *itnim);
81
82/**
83 * bfa_itnim_sm BFA itnim state machine
84 */
85
86
87enum bfa_itnim_event {
88 BFA_ITNIM_SM_CREATE = 1, /* itnim is created */
89 BFA_ITNIM_SM_ONLINE = 2, /* itnim is online */
90 BFA_ITNIM_SM_OFFLINE = 3, /* itnim is offline */
91 BFA_ITNIM_SM_FWRSP = 4, /* firmware response */
92 BFA_ITNIM_SM_DELETE = 5, /* deleting an existing itnim */
93 BFA_ITNIM_SM_CLEANUP = 6, /* IO cleanup completion */
94 BFA_ITNIM_SM_SLER = 7, /* second level error recovery */
95 BFA_ITNIM_SM_HWFAIL = 8, /* IOC h/w failure event */
96 BFA_ITNIM_SM_QRESUME = 9, /* queue space available */
97};
98
99static void bfa_itnim_sm_uninit(struct bfa_itnim_s *itnim,
100 enum bfa_itnim_event event);
101static void bfa_itnim_sm_created(struct bfa_itnim_s *itnim,
102 enum bfa_itnim_event event);
103static void bfa_itnim_sm_fwcreate(struct bfa_itnim_s *itnim,
104 enum bfa_itnim_event event);
105static void bfa_itnim_sm_delete_pending(struct bfa_itnim_s *itnim,
106 enum bfa_itnim_event event);
107static void bfa_itnim_sm_online(struct bfa_itnim_s *itnim,
108 enum bfa_itnim_event event);
109static void bfa_itnim_sm_sler(struct bfa_itnim_s *itnim,
110 enum bfa_itnim_event event);
111static void bfa_itnim_sm_cleanup_offline(struct bfa_itnim_s *itnim,
112 enum bfa_itnim_event event);
113static void bfa_itnim_sm_cleanup_delete(struct bfa_itnim_s *itnim,
114 enum bfa_itnim_event event);
115static void bfa_itnim_sm_fwdelete(struct bfa_itnim_s *itnim,
116 enum bfa_itnim_event event);
117static void bfa_itnim_sm_offline(struct bfa_itnim_s *itnim,
118 enum bfa_itnim_event event);
119static void bfa_itnim_sm_iocdisable(struct bfa_itnim_s *itnim,
120 enum bfa_itnim_event event);
121static void bfa_itnim_sm_deleting(struct bfa_itnim_s *itnim,
122 enum bfa_itnim_event event);
123static void bfa_itnim_sm_fwcreate_qfull(struct bfa_itnim_s *itnim,
124 enum bfa_itnim_event event);
125static void bfa_itnim_sm_fwdelete_qfull(struct bfa_itnim_s *itnim,
126 enum bfa_itnim_event event);
127static void bfa_itnim_sm_deleting_qfull(struct bfa_itnim_s *itnim,
128 enum bfa_itnim_event event);
129
130/**
131 * Beginning/unallocated state - no events expected.
132 */
133static void
134bfa_itnim_sm_uninit(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
135{
136 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
137 bfa_trc(itnim->bfa, event);
138
139 switch (event) {
140 case BFA_ITNIM_SM_CREATE:
141 bfa_sm_set_state(itnim, bfa_itnim_sm_created);
142 itnim->is_online = BFA_FALSE;
143 bfa_fcpim_additn(itnim);
144 break;
145
146 default:
147 bfa_sm_fault(itnim->bfa, event);
148 }
149}
150
151/**
152 * Beginning state, only online event expected.
153 */
154static void
155bfa_itnim_sm_created(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
156{
157 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
158 bfa_trc(itnim->bfa, event);
159
160 switch (event) {
161 case BFA_ITNIM_SM_ONLINE:
162 if (bfa_itnim_send_fwcreate(itnim))
163 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
164 else
165 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate_qfull);
166 break;
167
168 case BFA_ITNIM_SM_DELETE:
169 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
170 bfa_fcpim_delitn(itnim);
171 break;
172
173 case BFA_ITNIM_SM_HWFAIL:
174 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
175 break;
176
177 default:
178 bfa_sm_fault(itnim->bfa, event);
179 }
180}
181
182/**
183 * Waiting for itnim create response from firmware.
184 */
185static void
186bfa_itnim_sm_fwcreate(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
187{
188 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
189 bfa_trc(itnim->bfa, event);
190
191 switch (event) {
192 case BFA_ITNIM_SM_FWRSP:
193 bfa_sm_set_state(itnim, bfa_itnim_sm_online);
194 itnim->is_online = BFA_TRUE;
195 bfa_itnim_iotov_online(itnim);
196 bfa_itnim_online_cb(itnim);
197 break;
198
199 case BFA_ITNIM_SM_DELETE:
200 bfa_sm_set_state(itnim, bfa_itnim_sm_delete_pending);
201 break;
202
203 case BFA_ITNIM_SM_OFFLINE:
204 if (bfa_itnim_send_fwdelete(itnim))
205 bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete);
206 else
207 bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete_qfull);
208 break;
209
210 case BFA_ITNIM_SM_HWFAIL:
211 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
212 break;
213
214 default:
215 bfa_sm_fault(itnim->bfa, event);
216 }
217}
218
219static void
220bfa_itnim_sm_fwcreate_qfull(struct bfa_itnim_s *itnim,
221 enum bfa_itnim_event event)
222{
223 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
224 bfa_trc(itnim->bfa, event);
225
226 switch (event) {
227 case BFA_ITNIM_SM_QRESUME:
228 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
229 bfa_itnim_send_fwcreate(itnim);
230 break;
231
232 case BFA_ITNIM_SM_DELETE:
233 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
234 bfa_reqq_wcancel(&itnim->reqq_wait);
235 bfa_fcpim_delitn(itnim);
236 break;
237
238 case BFA_ITNIM_SM_OFFLINE:
239 bfa_sm_set_state(itnim, bfa_itnim_sm_offline);
240 bfa_reqq_wcancel(&itnim->reqq_wait);
241 bfa_itnim_offline_cb(itnim);
242 break;
243
244 case BFA_ITNIM_SM_HWFAIL:
245 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
246 bfa_reqq_wcancel(&itnim->reqq_wait);
247 break;
248
249 default:
250 bfa_sm_fault(itnim->bfa, event);
251 }
252}
253
254/**
255 * Waiting for itnim create response from firmware, a delete is pending.
256 */
257static void
258bfa_itnim_sm_delete_pending(struct bfa_itnim_s *itnim,
259 enum bfa_itnim_event event)
260{
261 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
262 bfa_trc(itnim->bfa, event);
263
264 switch (event) {
265 case BFA_ITNIM_SM_FWRSP:
266 if (bfa_itnim_send_fwdelete(itnim))
267 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
268 else
269 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting_qfull);
270 break;
271
272 case BFA_ITNIM_SM_HWFAIL:
273 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
274 bfa_fcpim_delitn(itnim);
275 break;
276
277 default:
278 bfa_sm_fault(itnim->bfa, event);
279 }
280}
281
282/**
283 * Online state - normal parking state.
284 */
285static void
286bfa_itnim_sm_online(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
287{
288 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
289 bfa_trc(itnim->bfa, event);
290
291 switch (event) {
292 case BFA_ITNIM_SM_OFFLINE:
293 bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_offline);
294 itnim->is_online = BFA_FALSE;
295 bfa_itnim_iotov_start(itnim);
296 bfa_itnim_cleanup(itnim);
297 break;
298
299 case BFA_ITNIM_SM_DELETE:
300 bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_delete);
301 itnim->is_online = BFA_FALSE;
302 bfa_itnim_cleanup(itnim);
303 break;
304
305 case BFA_ITNIM_SM_SLER:
306 bfa_sm_set_state(itnim, bfa_itnim_sm_sler);
307 itnim->is_online = BFA_FALSE;
308 bfa_itnim_iotov_start(itnim);
309 bfa_itnim_sler_cb(itnim);
310 break;
311
312 case BFA_ITNIM_SM_HWFAIL:
313 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
314 itnim->is_online = BFA_FALSE;
315 bfa_itnim_iotov_start(itnim);
316 bfa_itnim_iocdisable_cleanup(itnim);
317 break;
318
319 default:
320 bfa_sm_fault(itnim->bfa, event);
321 }
322}
323
324/**
325 * Second level error recovery need.
326 */
327static void
328bfa_itnim_sm_sler(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
329{
330 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
331 bfa_trc(itnim->bfa, event);
332
333 switch (event) {
334 case BFA_ITNIM_SM_OFFLINE:
335 bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_offline);
336 bfa_itnim_cleanup(itnim);
337 break;
338
339 case BFA_ITNIM_SM_DELETE:
340 bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_delete);
341 bfa_itnim_cleanup(itnim);
342 bfa_itnim_iotov_delete(itnim);
343 break;
344
345 case BFA_ITNIM_SM_HWFAIL:
346 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
347 bfa_itnim_iocdisable_cleanup(itnim);
348 break;
349
350 default:
351 bfa_sm_fault(itnim->bfa, event);
352 }
353}
354
355/**
356 * Going offline. Waiting for active IO cleanup.
357 */
358static void
359bfa_itnim_sm_cleanup_offline(struct bfa_itnim_s *itnim,
360 enum bfa_itnim_event event)
361{
362 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
363 bfa_trc(itnim->bfa, event);
364
365 switch (event) {
366 case BFA_ITNIM_SM_CLEANUP:
367 if (bfa_itnim_send_fwdelete(itnim))
368 bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete);
369 else
370 bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete_qfull);
371 break;
372
373 case BFA_ITNIM_SM_DELETE:
374 bfa_sm_set_state(itnim, bfa_itnim_sm_cleanup_delete);
375 bfa_itnim_iotov_delete(itnim);
376 break;
377
378 case BFA_ITNIM_SM_HWFAIL:
379 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
380 bfa_itnim_iocdisable_cleanup(itnim);
381 bfa_itnim_offline_cb(itnim);
382 break;
383
384 case BFA_ITNIM_SM_SLER:
385 break;
386
387 default:
388 bfa_sm_fault(itnim->bfa, event);
389 }
390}
391
392/**
393 * Deleting itnim. Waiting for active IO cleanup.
394 */
395static void
396bfa_itnim_sm_cleanup_delete(struct bfa_itnim_s *itnim,
397 enum bfa_itnim_event event)
398{
399 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
400 bfa_trc(itnim->bfa, event);
401
402 switch (event) {
403 case BFA_ITNIM_SM_CLEANUP:
404 if (bfa_itnim_send_fwdelete(itnim))
405 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
406 else
407 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting_qfull);
408 break;
409
410 case BFA_ITNIM_SM_HWFAIL:
411 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
412 bfa_itnim_iocdisable_cleanup(itnim);
413 break;
414
415 default:
416 bfa_sm_fault(itnim->bfa, event);
417 }
418}
419
420/**
421 * Rport offline. Fimrware itnim is being deleted - awaiting f/w response.
422 */
423static void
424bfa_itnim_sm_fwdelete(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
425{
426 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
427 bfa_trc(itnim->bfa, event);
428
429 switch (event) {
430 case BFA_ITNIM_SM_FWRSP:
431 bfa_sm_set_state(itnim, bfa_itnim_sm_offline);
432 bfa_itnim_offline_cb(itnim);
433 break;
434
435 case BFA_ITNIM_SM_DELETE:
436 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
437 break;
438
439 case BFA_ITNIM_SM_HWFAIL:
440 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
441 bfa_itnim_offline_cb(itnim);
442 break;
443
444 default:
445 bfa_sm_fault(itnim->bfa, event);
446 }
447}
448
449static void
450bfa_itnim_sm_fwdelete_qfull(struct bfa_itnim_s *itnim,
451 enum bfa_itnim_event event)
452{
453 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
454 bfa_trc(itnim->bfa, event);
455
456 switch (event) {
457 case BFA_ITNIM_SM_QRESUME:
458 bfa_sm_set_state(itnim, bfa_itnim_sm_fwdelete);
459 bfa_itnim_send_fwdelete(itnim);
460 break;
461
462 case BFA_ITNIM_SM_DELETE:
463 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting_qfull);
464 break;
465
466 case BFA_ITNIM_SM_HWFAIL:
467 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
468 bfa_reqq_wcancel(&itnim->reqq_wait);
469 bfa_itnim_offline_cb(itnim);
470 break;
471
472 default:
473 bfa_sm_fault(itnim->bfa, event);
474 }
475}
476
477/**
478 * Offline state.
479 */
480static void
481bfa_itnim_sm_offline(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
482{
483 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
484 bfa_trc(itnim->bfa, event);
485
486 switch (event) {
487 case BFA_ITNIM_SM_DELETE:
488 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
489 bfa_itnim_iotov_delete(itnim);
490 bfa_fcpim_delitn(itnim);
491 break;
492
493 case BFA_ITNIM_SM_ONLINE:
494 if (bfa_itnim_send_fwcreate(itnim))
495 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
496 else
497 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate_qfull);
498 break;
499
500 case BFA_ITNIM_SM_HWFAIL:
501 bfa_sm_set_state(itnim, bfa_itnim_sm_iocdisable);
502 break;
503
504 default:
505 bfa_sm_fault(itnim->bfa, event);
506 }
507}
508
509/**
510 * IOC h/w failed state.
511 */
512static void
513bfa_itnim_sm_iocdisable(struct bfa_itnim_s *itnim,
514 enum bfa_itnim_event event)
515{
516 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
517 bfa_trc(itnim->bfa, event);
518
519 switch (event) {
520 case BFA_ITNIM_SM_DELETE:
521 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
522 bfa_itnim_iotov_delete(itnim);
523 bfa_fcpim_delitn(itnim);
524 break;
525
526 case BFA_ITNIM_SM_OFFLINE:
527 bfa_itnim_offline_cb(itnim);
528 break;
529
530 case BFA_ITNIM_SM_ONLINE:
531 if (bfa_itnim_send_fwcreate(itnim))
532 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate);
533 else
534 bfa_sm_set_state(itnim, bfa_itnim_sm_fwcreate_qfull);
535 break;
536
537 case BFA_ITNIM_SM_HWFAIL:
538 break;
539
540 default:
541 bfa_sm_fault(itnim->bfa, event);
542 }
543}
544
545/**
546 * Itnim is deleted, waiting for firmware response to delete.
547 */
548static void
549bfa_itnim_sm_deleting(struct bfa_itnim_s *itnim, enum bfa_itnim_event event)
550{
551 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
552 bfa_trc(itnim->bfa, event);
553
554 switch (event) {
555 case BFA_ITNIM_SM_FWRSP:
556 case BFA_ITNIM_SM_HWFAIL:
557 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
558 bfa_fcpim_delitn(itnim);
559 break;
560
561 default:
562 bfa_sm_fault(itnim->bfa, event);
563 }
564}
565
566static void
567bfa_itnim_sm_deleting_qfull(struct bfa_itnim_s *itnim,
568 enum bfa_itnim_event event)
569{
570 bfa_trc(itnim->bfa, itnim->rport->rport_tag);
571 bfa_trc(itnim->bfa, event);
572
573 switch (event) {
574 case BFA_ITNIM_SM_QRESUME:
575 bfa_sm_set_state(itnim, bfa_itnim_sm_deleting);
576 bfa_itnim_send_fwdelete(itnim);
577 break;
578
579 case BFA_ITNIM_SM_HWFAIL:
580 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
581 bfa_reqq_wcancel(&itnim->reqq_wait);
582 bfa_fcpim_delitn(itnim);
583 break;
584
585 default:
586 bfa_sm_fault(itnim->bfa, event);
587 }
588}
589
590
591
592/**
593 * bfa_itnim_private
594 */
595
596/**
597 * Initiate cleanup of all IOs on an IOC failure.
598 */
599static void
600bfa_itnim_iocdisable_cleanup(struct bfa_itnim_s *itnim)
601{
602 struct bfa_tskim_s *tskim;
603 struct bfa_ioim_s *ioim;
604 struct list_head *qe, *qen;
605
606 list_for_each_safe(qe, qen, &itnim->tsk_q) {
607 tskim = (struct bfa_tskim_s *) qe;
608 bfa_tskim_iocdisable(tskim);
609 }
610
611 list_for_each_safe(qe, qen, &itnim->io_q) {
612 ioim = (struct bfa_ioim_s *) qe;
613 bfa_ioim_iocdisable(ioim);
614 }
615
616 /**
617 * For IO request in pending queue, we pretend an early timeout.
618 */
619 list_for_each_safe(qe, qen, &itnim->pending_q) {
620 ioim = (struct bfa_ioim_s *) qe;
621 bfa_ioim_tov(ioim);
622 }
623
624 list_for_each_safe(qe, qen, &itnim->io_cleanup_q) {
625 ioim = (struct bfa_ioim_s *) qe;
626 bfa_ioim_iocdisable(ioim);
627 }
628}
629
630/**
631 * IO cleanup completion
632 */
633static void
634bfa_itnim_cleanp_comp(void *itnim_cbarg)
635{
636 struct bfa_itnim_s *itnim = itnim_cbarg;
637
638 bfa_stats(itnim, cleanup_comps);
639 bfa_sm_send_event(itnim, BFA_ITNIM_SM_CLEANUP);
640}
641
642/**
643 * Initiate cleanup of all IOs.
644 */
645static void
646bfa_itnim_cleanup(struct bfa_itnim_s *itnim)
647{
648 struct bfa_ioim_s *ioim;
649 struct bfa_tskim_s *tskim;
650 struct list_head *qe, *qen;
651
652 bfa_wc_init(&itnim->wc, bfa_itnim_cleanp_comp, itnim);
653
654 list_for_each_safe(qe, qen, &itnim->io_q) {
655 ioim = (struct bfa_ioim_s *) qe;
656
657 /**
658 * Move IO to a cleanup queue from active queue so that a later
659 * TM will not pickup this IO.
660 */
661 list_del(&ioim->qe);
662 list_add_tail(&ioim->qe, &itnim->io_cleanup_q);
663
664 bfa_wc_up(&itnim->wc);
665 bfa_ioim_cleanup(ioim);
666 }
667
668 list_for_each_safe(qe, qen, &itnim->tsk_q) {
669 tskim = (struct bfa_tskim_s *) qe;
670 bfa_wc_up(&itnim->wc);
671 bfa_tskim_cleanup(tskim);
672 }
673
674 bfa_wc_wait(&itnim->wc);
675}
676
677static void
678__bfa_cb_itnim_online(void *cbarg, bfa_boolean_t complete)
679{
680 struct bfa_itnim_s *itnim = cbarg;
681
682 if (complete)
683 bfa_cb_itnim_online(itnim->ditn);
684}
685
686static void
687__bfa_cb_itnim_offline(void *cbarg, bfa_boolean_t complete)
688{
689 struct bfa_itnim_s *itnim = cbarg;
690
691 if (complete)
692 bfa_cb_itnim_offline(itnim->ditn);
693}
694
695static void
696__bfa_cb_itnim_sler(void *cbarg, bfa_boolean_t complete)
697{
698 struct bfa_itnim_s *itnim = cbarg;
699
700 if (complete)
701 bfa_cb_itnim_sler(itnim->ditn);
702}
703
704/**
705 * Call to resume any I/O requests waiting for room in request queue.
706 */
707static void
708bfa_itnim_qresume(void *cbarg)
709{
710 struct bfa_itnim_s *itnim = cbarg;
711
712 bfa_sm_send_event(itnim, BFA_ITNIM_SM_QRESUME);
713}
714
715
716
717
718/**
719 * bfa_itnim_public
720 */
721
722void
723bfa_itnim_iodone(struct bfa_itnim_s *itnim)
724{
725 bfa_wc_down(&itnim->wc);
726}
727
728void
729bfa_itnim_tskdone(struct bfa_itnim_s *itnim)
730{
731 bfa_wc_down(&itnim->wc);
732}
733
734void
735bfa_itnim_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
736 u32 *dm_len)
737{
738 /**
739 * ITN memory
740 */
741 *km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_itnim_s);
742}
743
744void
745bfa_itnim_attach(struct bfa_fcpim_mod_s *fcpim, struct bfa_meminfo_s *minfo)
746{
747 struct bfa_s *bfa = fcpim->bfa;
748 struct bfa_itnim_s *itnim;
749 int i;
750
751 INIT_LIST_HEAD(&fcpim->itnim_q);
752
753 itnim = (struct bfa_itnim_s *) bfa_meminfo_kva(minfo);
754 fcpim->itnim_arr = itnim;
755
756 for (i = 0; i < fcpim->num_itnims; i++, itnim++) {
757 bfa_os_memset(itnim, 0, sizeof(struct bfa_itnim_s));
758 itnim->bfa = bfa;
759 itnim->fcpim = fcpim;
760 itnim->reqq = BFA_REQQ_QOS_LO;
761 itnim->rport = BFA_RPORT_FROM_TAG(bfa, i);
762 itnim->iotov_active = BFA_FALSE;
763 bfa_reqq_winit(&itnim->reqq_wait, bfa_itnim_qresume, itnim);
764
765 INIT_LIST_HEAD(&itnim->io_q);
766 INIT_LIST_HEAD(&itnim->io_cleanup_q);
767 INIT_LIST_HEAD(&itnim->pending_q);
768 INIT_LIST_HEAD(&itnim->tsk_q);
769 INIT_LIST_HEAD(&itnim->delay_comp_q);
770 bfa_sm_set_state(itnim, bfa_itnim_sm_uninit);
771 }
772
773 bfa_meminfo_kva(minfo) = (u8 *) itnim;
774}
775
776void
777bfa_itnim_iocdisable(struct bfa_itnim_s *itnim)
778{
779 bfa_stats(itnim, ioc_disabled);
780 bfa_sm_send_event(itnim, BFA_ITNIM_SM_HWFAIL);
781}
782
783static bfa_boolean_t
784bfa_itnim_send_fwcreate(struct bfa_itnim_s *itnim)
785{
786 struct bfi_itnim_create_req_s *m;
787
788 itnim->msg_no++;
789
790 /**
791 * check for room in queue to send request now
792 */
793 m = bfa_reqq_next(itnim->bfa, itnim->reqq);
794 if (!m) {
795 bfa_reqq_wait(itnim->bfa, itnim->reqq, &itnim->reqq_wait);
796 return BFA_FALSE;
797 }
798
799 bfi_h2i_set(m->mh, BFI_MC_ITNIM, BFI_ITNIM_H2I_CREATE_REQ,
800 bfa_lpuid(itnim->bfa));
801 m->fw_handle = itnim->rport->fw_handle;
802 m->class = FC_CLASS_3;
803 m->seq_rec = itnim->seq_rec;
804 m->msg_no = itnim->msg_no;
805
806 /**
807 * queue I/O message to firmware
808 */
809 bfa_reqq_produce(itnim->bfa, itnim->reqq);
810 return BFA_TRUE;
811}
812
813static bfa_boolean_t
814bfa_itnim_send_fwdelete(struct bfa_itnim_s *itnim)
815{
816 struct bfi_itnim_delete_req_s *m;
817
818 /**
819 * check for room in queue to send request now
820 */
821 m = bfa_reqq_next(itnim->bfa, itnim->reqq);
822 if (!m) {
823 bfa_reqq_wait(itnim->bfa, itnim->reqq, &itnim->reqq_wait);
824 return BFA_FALSE;
825 }
826
827 bfi_h2i_set(m->mh, BFI_MC_ITNIM, BFI_ITNIM_H2I_DELETE_REQ,
828 bfa_lpuid(itnim->bfa));
829 m->fw_handle = itnim->rport->fw_handle;
830
831 /**
832 * queue I/O message to firmware
833 */
834 bfa_reqq_produce(itnim->bfa, itnim->reqq);
835 return BFA_TRUE;
836}
837
838/**
839 * Cleanup all pending failed inflight requests.
840 */
841static void
842bfa_itnim_delayed_comp(struct bfa_itnim_s *itnim, bfa_boolean_t iotov)
843{
844 struct bfa_ioim_s *ioim;
845 struct list_head *qe, *qen;
846
847 list_for_each_safe(qe, qen, &itnim->delay_comp_q) {
848 ioim = (struct bfa_ioim_s *)qe;
849 bfa_ioim_delayed_comp(ioim, iotov);
850 }
851}
852
853/**
854 * Start all pending IO requests.
855 */
856static void
857bfa_itnim_iotov_online(struct bfa_itnim_s *itnim)
858{
859 struct bfa_ioim_s *ioim;
860
861 bfa_itnim_iotov_stop(itnim);
862
863 /**
864 * Abort all inflight IO requests in the queue
865 */
866 bfa_itnim_delayed_comp(itnim, BFA_FALSE);
867
868 /**
869 * Start all pending IO requests.
870 */
871 while (!list_empty(&itnim->pending_q)) {
872 bfa_q_deq(&itnim->pending_q, &ioim);
873 list_add_tail(&ioim->qe, &itnim->io_q);
874 bfa_ioim_start(ioim);
875 }
876}
877
878/**
879 * Fail all pending IO requests
880 */
881static void
882bfa_itnim_iotov_cleanup(struct bfa_itnim_s *itnim)
883{
884 struct bfa_ioim_s *ioim;
885
886 /**
887 * Fail all inflight IO requests in the queue
888 */
889 bfa_itnim_delayed_comp(itnim, BFA_TRUE);
890
891 /**
892 * Fail any pending IO requests.
893 */
894 while (!list_empty(&itnim->pending_q)) {
895 bfa_q_deq(&itnim->pending_q, &ioim);
896 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
897 bfa_ioim_tov(ioim);
898 }
899}
900
901/**
902 * IO TOV timer callback. Fail any pending IO requests.
903 */
904static void
905bfa_itnim_iotov(void *itnim_arg)
906{
907 struct bfa_itnim_s *itnim = itnim_arg;
908
909 itnim->iotov_active = BFA_FALSE;
910
911 bfa_cb_itnim_tov_begin(itnim->ditn);
912 bfa_itnim_iotov_cleanup(itnim);
913 bfa_cb_itnim_tov(itnim->ditn);
914}
915
916/**
917 * Start IO TOV timer for failing back pending IO requests in offline state.
918 */
919static void
920bfa_itnim_iotov_start(struct bfa_itnim_s *itnim)
921{
922 if (itnim->fcpim->path_tov > 0) {
923
924 itnim->iotov_active = BFA_TRUE;
925 bfa_assert(bfa_itnim_hold_io(itnim));
926 bfa_timer_start(itnim->bfa, &itnim->timer,
927 bfa_itnim_iotov, itnim, itnim->fcpim->path_tov);
928 }
929}
930
931/**
932 * Stop IO TOV timer.
933 */
934static void
935bfa_itnim_iotov_stop(struct bfa_itnim_s *itnim)
936{
937 if (itnim->iotov_active) {
938 itnim->iotov_active = BFA_FALSE;
939 bfa_timer_stop(&itnim->timer);
940 }
941}
942
943/**
944 * Stop IO TOV timer.
945 */
946static void
947bfa_itnim_iotov_delete(struct bfa_itnim_s *itnim)
948{
949 bfa_boolean_t pathtov_active = BFA_FALSE;
950
951 if (itnim->iotov_active)
952 pathtov_active = BFA_TRUE;
953
954 bfa_itnim_iotov_stop(itnim);
955 if (pathtov_active)
956 bfa_cb_itnim_tov_begin(itnim->ditn);
957 bfa_itnim_iotov_cleanup(itnim);
958 if (pathtov_active)
959 bfa_cb_itnim_tov(itnim->ditn);
960}
961
962
963
964/**
965 * bfa_itnim_public
966 */
967
968/**
969 * Itnim interrupt processing.
970 */
971void
972bfa_itnim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
973{
974 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
975 union bfi_itnim_i2h_msg_u msg;
976 struct bfa_itnim_s *itnim;
977
978 bfa_trc(bfa, m->mhdr.msg_id);
979
980 msg.msg = m;
981
982 switch (m->mhdr.msg_id) {
983 case BFI_ITNIM_I2H_CREATE_RSP:
984 itnim = BFA_ITNIM_FROM_TAG(fcpim,
985 msg.create_rsp->bfa_handle);
986 bfa_assert(msg.create_rsp->status == BFA_STATUS_OK);
987 bfa_stats(itnim, create_comps);
988 bfa_sm_send_event(itnim, BFA_ITNIM_SM_FWRSP);
989 break;
990
991 case BFI_ITNIM_I2H_DELETE_RSP:
992 itnim = BFA_ITNIM_FROM_TAG(fcpim,
993 msg.delete_rsp->bfa_handle);
994 bfa_assert(msg.delete_rsp->status == BFA_STATUS_OK);
995 bfa_stats(itnim, delete_comps);
996 bfa_sm_send_event(itnim, BFA_ITNIM_SM_FWRSP);
997 break;
998
999 case BFI_ITNIM_I2H_SLER_EVENT:
1000 itnim = BFA_ITNIM_FROM_TAG(fcpim,
1001 msg.sler_event->bfa_handle);
1002 bfa_stats(itnim, sler_events);
1003 bfa_sm_send_event(itnim, BFA_ITNIM_SM_SLER);
1004 break;
1005
1006 default:
1007 bfa_trc(bfa, m->mhdr.msg_id);
1008 bfa_assert(0);
1009 }
1010}
1011
1012
1013
1014/**
1015 * bfa_itnim_api
1016 */
1017
1018struct bfa_itnim_s *
1019bfa_itnim_create(struct bfa_s *bfa, struct bfa_rport_s *rport, void *ditn)
1020{
1021 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
1022 struct bfa_itnim_s *itnim;
1023
1024 itnim = BFA_ITNIM_FROM_TAG(fcpim, rport->rport_tag);
1025 bfa_assert(itnim->rport == rport);
1026
1027 itnim->ditn = ditn;
1028
1029 bfa_stats(itnim, creates);
1030 bfa_sm_send_event(itnim, BFA_ITNIM_SM_CREATE);
1031
1032 return itnim;
1033}
1034
1035void
1036bfa_itnim_delete(struct bfa_itnim_s *itnim)
1037{
1038 bfa_stats(itnim, deletes);
1039 bfa_sm_send_event(itnim, BFA_ITNIM_SM_DELETE);
1040}
1041
1042void
1043bfa_itnim_online(struct bfa_itnim_s *itnim, bfa_boolean_t seq_rec)
1044{
1045 itnim->seq_rec = seq_rec;
1046 bfa_stats(itnim, onlines);
1047 bfa_sm_send_event(itnim, BFA_ITNIM_SM_ONLINE);
1048}
1049
1050void
1051bfa_itnim_offline(struct bfa_itnim_s *itnim)
1052{
1053 bfa_stats(itnim, offlines);
1054 bfa_sm_send_event(itnim, BFA_ITNIM_SM_OFFLINE);
1055}
1056
1057/**
1058 * Return true if itnim is considered offline for holding off IO request.
1059 * IO is not held if itnim is being deleted.
1060 */
1061bfa_boolean_t
1062bfa_itnim_hold_io(struct bfa_itnim_s *itnim)
1063{
1064 return
1065 itnim->fcpim->path_tov && itnim->iotov_active &&
1066 (bfa_sm_cmp_state(itnim, bfa_itnim_sm_fwcreate) ||
1067 bfa_sm_cmp_state(itnim, bfa_itnim_sm_sler) ||
1068 bfa_sm_cmp_state(itnim, bfa_itnim_sm_cleanup_offline) ||
1069 bfa_sm_cmp_state(itnim, bfa_itnim_sm_fwdelete) ||
1070 bfa_sm_cmp_state(itnim, bfa_itnim_sm_offline) ||
1071 bfa_sm_cmp_state(itnim, bfa_itnim_sm_iocdisable))
1072 ;
1073}
1074
1075void
1076bfa_itnim_get_stats(struct bfa_itnim_s *itnim,
1077 struct bfa_itnim_hal_stats_s *stats)
1078{
1079 *stats = itnim->stats;
1080}
1081
1082void
1083bfa_itnim_clear_stats(struct bfa_itnim_s *itnim)
1084{
1085 bfa_os_memset(&itnim->stats, 0, sizeof(itnim->stats));
1086}
1087
1088
diff --git a/drivers/scsi/bfa/bfa_log.c b/drivers/scsi/bfa/bfa_log.c
deleted file mode 100644
index e7514016c9c6..000000000000
--- a/drivers/scsi/bfa/bfa_log.c
+++ /dev/null
@@ -1,346 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_log.c BFA log library
20 */
21
22#include <bfa_os_inc.h>
23#include <cs/bfa_log.h>
24
25/*
26 * global log info structure
27 */
28struct bfa_log_info_s {
29 u32 start_idx; /* start index for a module */
30 u32 total_count; /* total count for a module */
31 enum bfa_log_severity level; /* global log level */
32 bfa_log_cb_t cbfn; /* callback function */
33};
34
35static struct bfa_log_info_s bfa_log_info[BFA_LOG_MODULE_ID_MAX + 1];
36static u32 bfa_log_msg_total_count;
37static int bfa_log_initialized;
38
39static char *bfa_log_severity[] =
40 { "[none]", "[critical]", "[error]", "[warn]", "[info]", "" };
41
42/**
43 * BFA log library initialization
44 *
45 * The log library initialization includes the following,
46 * - set log instance name and callback function
47 * - read the message array generated from xml files
48 * - calculate start index for each module
49 * - calculate message count for each module
50 * - perform error checking
51 *
52 * @param[in] log_mod - log module info
53 * @param[in] instance_name - instance name
54 * @param[in] cbfn - callback function
55 *
56 * It return 0 on success, or -1 on failure
57 */
58int
59bfa_log_init(struct bfa_log_mod_s *log_mod, char *instance_name,
60 bfa_log_cb_t cbfn)
61{
62 struct bfa_log_msgdef_s *msg;
63 u32 pre_mod_id = 0;
64 u32 cur_mod_id = 0;
65 u32 i, pre_idx, idx, msg_id;
66
67 /*
68 * set instance name
69 */
70 if (log_mod) {
71 strncpy(log_mod->instance_info, instance_name,
72 sizeof(log_mod->instance_info));
73 log_mod->cbfn = cbfn;
74 for (i = 0; i <= BFA_LOG_MODULE_ID_MAX; i++)
75 log_mod->log_level[i] = BFA_LOG_WARNING;
76 }
77
78 if (bfa_log_initialized)
79 return 0;
80
81 for (i = 0; i <= BFA_LOG_MODULE_ID_MAX; i++) {
82 bfa_log_info[i].start_idx = 0;
83 bfa_log_info[i].total_count = 0;
84 bfa_log_info[i].level = BFA_LOG_WARNING;
85 bfa_log_info[i].cbfn = cbfn;
86 }
87
88 pre_idx = 0;
89 idx = 0;
90 msg = bfa_log_msg_array;
91 msg_id = BFA_LOG_GET_MSG_ID(msg);
92 pre_mod_id = BFA_LOG_GET_MOD_ID(msg_id);
93 while (msg_id != 0) {
94 cur_mod_id = BFA_LOG_GET_MOD_ID(msg_id);
95
96 if (cur_mod_id > BFA_LOG_MODULE_ID_MAX) {
97 cbfn(log_mod, msg_id,
98 "%s%s log: module id %u out of range\n",
99 BFA_LOG_CAT_NAME,
100 bfa_log_severity[BFA_LOG_ERROR],
101 cur_mod_id);
102 return -1;
103 }
104
105 if (pre_mod_id > BFA_LOG_MODULE_ID_MAX) {
106 cbfn(log_mod, msg_id,
107 "%s%s log: module id %u out of range\n",
108 BFA_LOG_CAT_NAME,
109 bfa_log_severity[BFA_LOG_ERROR],
110 pre_mod_id);
111 return -1;
112 }
113
114 if (cur_mod_id != pre_mod_id) {
115 bfa_log_info[pre_mod_id].start_idx = pre_idx;
116 bfa_log_info[pre_mod_id].total_count = idx - pre_idx;
117 pre_mod_id = cur_mod_id;
118 pre_idx = idx;
119 }
120
121 idx++;
122 msg++;
123 msg_id = BFA_LOG_GET_MSG_ID(msg);
124 }
125
126 bfa_log_info[cur_mod_id].start_idx = pre_idx;
127 bfa_log_info[cur_mod_id].total_count = idx - pre_idx;
128 bfa_log_msg_total_count = idx;
129
130 cbfn(log_mod, msg_id, "%s%s log: init OK, msg total count %u\n",
131 BFA_LOG_CAT_NAME,
132 bfa_log_severity[BFA_LOG_INFO], bfa_log_msg_total_count);
133
134 bfa_log_initialized = 1;
135
136 return 0;
137}
138
139/**
140 * BFA log set log level for a module
141 *
142 * @param[in] log_mod - log module info
143 * @param[in] mod_id - module id
144 * @param[in] log_level - log severity level
145 *
146 * It return BFA_STATUS_OK on success, or > 0 on failure
147 */
148bfa_status_t
149bfa_log_set_level(struct bfa_log_mod_s *log_mod, int mod_id,
150 enum bfa_log_severity log_level)
151{
152 if (mod_id <= BFA_LOG_UNUSED_ID || mod_id > BFA_LOG_MODULE_ID_MAX)
153 return BFA_STATUS_EINVAL;
154
155 if (log_level <= BFA_LOG_INVALID || log_level > BFA_LOG_LEVEL_MAX)
156 return BFA_STATUS_EINVAL;
157
158 if (log_mod)
159 log_mod->log_level[mod_id] = log_level;
160 else
161 bfa_log_info[mod_id].level = log_level;
162
163 return BFA_STATUS_OK;
164}
165
166/**
167 * BFA log set log level for all modules
168 *
169 * @param[in] log_mod - log module info
170 * @param[in] log_level - log severity level
171 *
172 * It return BFA_STATUS_OK on success, or > 0 on failure
173 */
174bfa_status_t
175bfa_log_set_level_all(struct bfa_log_mod_s *log_mod,
176 enum bfa_log_severity log_level)
177{
178 int mod_id = BFA_LOG_UNUSED_ID + 1;
179
180 if (log_level <= BFA_LOG_INVALID || log_level > BFA_LOG_LEVEL_MAX)
181 return BFA_STATUS_EINVAL;
182
183 if (log_mod) {
184 for (; mod_id <= BFA_LOG_MODULE_ID_MAX; mod_id++)
185 log_mod->log_level[mod_id] = log_level;
186 } else {
187 for (; mod_id <= BFA_LOG_MODULE_ID_MAX; mod_id++)
188 bfa_log_info[mod_id].level = log_level;
189 }
190
191 return BFA_STATUS_OK;
192}
193
194/**
195 * BFA log set log level for all aen sub-modules
196 *
197 * @param[in] log_mod - log module info
198 * @param[in] log_level - log severity level
199 *
200 * It return BFA_STATUS_OK on success, or > 0 on failure
201 */
202bfa_status_t
203bfa_log_set_level_aen(struct bfa_log_mod_s *log_mod,
204 enum bfa_log_severity log_level)
205{
206 int mod_id = BFA_LOG_AEN_MIN + 1;
207
208 if (log_mod) {
209 for (; mod_id <= BFA_LOG_AEN_MAX; mod_id++)
210 log_mod->log_level[mod_id] = log_level;
211 } else {
212 for (; mod_id <= BFA_LOG_AEN_MAX; mod_id++)
213 bfa_log_info[mod_id].level = log_level;
214 }
215
216 return BFA_STATUS_OK;
217}
218
219/**
220 * BFA log get log level for a module
221 *
222 * @param[in] log_mod - log module info
223 * @param[in] mod_id - module id
224 *
225 * It returns log level or -1 on error
226 */
227enum bfa_log_severity
228bfa_log_get_level(struct bfa_log_mod_s *log_mod, int mod_id)
229{
230 if (mod_id <= BFA_LOG_UNUSED_ID || mod_id > BFA_LOG_MODULE_ID_MAX)
231 return BFA_LOG_INVALID;
232
233 if (log_mod)
234 return log_mod->log_level[mod_id];
235 else
236 return bfa_log_info[mod_id].level;
237}
238
239enum bfa_log_severity
240bfa_log_get_msg_level(struct bfa_log_mod_s *log_mod, u32 msg_id)
241{
242 struct bfa_log_msgdef_s *msg;
243 u32 mod = BFA_LOG_GET_MOD_ID(msg_id);
244 u32 idx = BFA_LOG_GET_MSG_IDX(msg_id) - 1;
245
246 if (!bfa_log_initialized)
247 return BFA_LOG_INVALID;
248
249 if (mod > BFA_LOG_MODULE_ID_MAX)
250 return BFA_LOG_INVALID;
251
252 if (idx >= bfa_log_info[mod].total_count) {
253 bfa_log_info[mod].cbfn(log_mod, msg_id,
254 "%s%s log: inconsistent idx %u vs. total count %u\n",
255 BFA_LOG_CAT_NAME, bfa_log_severity[BFA_LOG_ERROR], idx,
256 bfa_log_info[mod].total_count);
257 return BFA_LOG_INVALID;
258 }
259
260 msg = bfa_log_msg_array + bfa_log_info[mod].start_idx + idx;
261 if (msg_id != BFA_LOG_GET_MSG_ID(msg)) {
262 bfa_log_info[mod].cbfn(log_mod, msg_id,
263 "%s%s log: inconsistent msg id %u array msg id %u\n",
264 BFA_LOG_CAT_NAME, bfa_log_severity[BFA_LOG_ERROR],
265 msg_id, BFA_LOG_GET_MSG_ID(msg));
266 return BFA_LOG_INVALID;
267 }
268
269 return BFA_LOG_GET_SEVERITY(msg);
270}
271
272/**
273 * BFA log message handling
274 *
275 * BFA log message handling finds the message based on message id and prints
276 * out the message based on its format and arguments. It also does prefix
277 * the severity etc.
278 *
279 * @param[in] log_mod - log module info
280 * @param[in] msg_id - message id
281 * @param[in] ... - message arguments
282 *
283 * It return 0 on success, or -1 on errors
284 */
285int
286bfa_log(struct bfa_log_mod_s *log_mod, u32 msg_id, ...)
287{
288 va_list ap;
289 char buf[256];
290 struct bfa_log_msgdef_s *msg;
291 int log_level;
292 u32 mod = BFA_LOG_GET_MOD_ID(msg_id);
293 u32 idx = BFA_LOG_GET_MSG_IDX(msg_id) - 1;
294
295 if (!bfa_log_initialized)
296 return -1;
297
298 if (mod > BFA_LOG_MODULE_ID_MAX)
299 return -1;
300
301 if (idx >= bfa_log_info[mod].total_count) {
302 bfa_log_info[mod].
303 cbfn
304 (log_mod, msg_id,
305 "%s%s log: inconsistent idx %u vs. total count %u\n",
306 BFA_LOG_CAT_NAME, bfa_log_severity[BFA_LOG_ERROR], idx,
307 bfa_log_info[mod].total_count);
308 return -1;
309 }
310
311 msg = bfa_log_msg_array + bfa_log_info[mod].start_idx + idx;
312 if (msg_id != BFA_LOG_GET_MSG_ID(msg)) {
313 bfa_log_info[mod].
314 cbfn
315 (log_mod, msg_id,
316 "%s%s log: inconsistent msg id %u array msg id %u\n",
317 BFA_LOG_CAT_NAME, bfa_log_severity[BFA_LOG_ERROR],
318 msg_id, BFA_LOG_GET_MSG_ID(msg));
319 return -1;
320 }
321
322 log_level = log_mod ? log_mod->log_level[mod] : bfa_log_info[mod].level;
323 if ((BFA_LOG_GET_SEVERITY(msg) > log_level) &&
324 (msg->attributes != BFA_LOG_ATTR_NONE))
325 return 0;
326
327 va_start(ap, msg_id);
328 bfa_os_vsprintf(buf, BFA_LOG_GET_MSG_FMT_STRING(msg), ap);
329 va_end(ap);
330
331 if (log_mod)
332 log_mod->cbfn(log_mod, msg_id, "%s[%s]%s%s %s: %s\n",
333 BFA_LOG_CAT_NAME, log_mod->instance_info,
334 bfa_log_severity[BFA_LOG_GET_SEVERITY(msg)],
335 (msg->attributes & BFA_LOG_ATTR_AUDIT)
336 ? " (audit) " : "", msg->msg_value, buf);
337 else
338 bfa_log_info[mod].cbfn(log_mod, msg_id, "%s%s%s %s: %s\n",
339 BFA_LOG_CAT_NAME,
340 bfa_log_severity[BFA_LOG_GET_SEVERITY(msg)],
341 (msg->attributes & BFA_LOG_ATTR_AUDIT) ?
342 " (audit) " : "", msg->msg_value, buf);
343
344 return 0;
345}
346
diff --git a/drivers/scsi/bfa/bfa_log_module.c b/drivers/scsi/bfa/bfa_log_module.c
deleted file mode 100644
index cf577ef7cb97..000000000000
--- a/drivers/scsi/bfa/bfa_log_module.c
+++ /dev/null
@@ -1,537 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <cs/bfa_log.h>
19#include <aen/bfa_aen_adapter.h>
20#include <aen/bfa_aen_audit.h>
21#include <aen/bfa_aen_ethport.h>
22#include <aen/bfa_aen_ioc.h>
23#include <aen/bfa_aen_itnim.h>
24#include <aen/bfa_aen_lport.h>
25#include <aen/bfa_aen_port.h>
26#include <aen/bfa_aen_rport.h>
27#include <log/bfa_log_fcs.h>
28#include <log/bfa_log_hal.h>
29#include <log/bfa_log_linux.h>
30#include <log/bfa_log_wdrv.h>
31
32struct bfa_log_msgdef_s bfa_log_msg_array[] = {
33
34
35/* messages define for BFA_AEN_CAT_ADAPTER Module */
36{BFA_AEN_ADAPTER_ADD, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
37 "BFA_AEN_ADAPTER_ADD",
38 "New adapter found: SN = %s, base port WWN = %s.",
39 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
40
41{BFA_AEN_ADAPTER_REMOVE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
42 BFA_LOG_WARNING, "BFA_AEN_ADAPTER_REMOVE",
43 "Adapter removed: SN = %s.",
44 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
45
46
47
48
49/* messages define for BFA_AEN_CAT_AUDIT Module */
50{BFA_AEN_AUDIT_AUTH_ENABLE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
51 BFA_LOG_INFO, "BFA_AEN_AUDIT_AUTH_ENABLE",
52 "Authentication enabled for base port: WWN = %s.",
53 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
54
55{BFA_AEN_AUDIT_AUTH_DISABLE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
56 BFA_LOG_INFO, "BFA_AEN_AUDIT_AUTH_DISABLE",
57 "Authentication disabled for base port: WWN = %s.",
58 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
59
60
61
62
63/* messages define for BFA_AEN_CAT_ETHPORT Module */
64{BFA_AEN_ETHPORT_LINKUP, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
65 "BFA_AEN_ETHPORT_LINKUP",
66 "Base port ethernet linkup: mac = %s.",
67 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
68
69{BFA_AEN_ETHPORT_LINKDOWN, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
70 "BFA_AEN_ETHPORT_LINKDOWN",
71 "Base port ethernet linkdown: mac = %s.",
72 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
73
74{BFA_AEN_ETHPORT_ENABLE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
75 "BFA_AEN_ETHPORT_ENABLE",
76 "Base port ethernet interface enabled: mac = %s.",
77 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
78
79{BFA_AEN_ETHPORT_DISABLE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
80 "BFA_AEN_ETHPORT_DISABLE",
81 "Base port ethernet interface disabled: mac = %s.",
82 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
83
84
85
86
87/* messages define for BFA_AEN_CAT_IOC Module */
88{BFA_AEN_IOC_HBGOOD, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
89 "BFA_AEN_IOC_HBGOOD",
90 "Heart Beat of IOC %d is good.",
91 ((BFA_LOG_D << BFA_LOG_ARG0) | 0), 1},
92
93{BFA_AEN_IOC_HBFAIL, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_CRITICAL,
94 "BFA_AEN_IOC_HBFAIL",
95 "Heart Beat of IOC %d has failed.",
96 ((BFA_LOG_D << BFA_LOG_ARG0) | 0), 1},
97
98{BFA_AEN_IOC_ENABLE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
99 "BFA_AEN_IOC_ENABLE",
100 "IOC %d is enabled.",
101 ((BFA_LOG_D << BFA_LOG_ARG0) | 0), 1},
102
103{BFA_AEN_IOC_DISABLE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
104 "BFA_AEN_IOC_DISABLE",
105 "IOC %d is disabled.",
106 ((BFA_LOG_D << BFA_LOG_ARG0) | 0), 1},
107
108{BFA_AEN_IOC_FWMISMATCH, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
109 BFA_LOG_CRITICAL, "BFA_AEN_IOC_FWMISMATCH",
110 "Running firmware version is incompatible with the driver version.",
111 (0), 0},
112
113{BFA_AEN_IOC_FWCFG_ERROR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
114 BFA_LOG_CRITICAL, "BFA_AEN_IOC_FWCFG_ERROR",
115 "Link initialization failed due to firmware configuration read error:"
116 " WWN = %s.",
117 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
118
119{BFA_AEN_IOC_INVALID_VENDOR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
120 BFA_LOG_ERROR, "BFA_AEN_IOC_INVALID_VENDOR",
121 "Unsupported switch vendor. Link initialization failed: WWN = %s.",
122 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
123
124{BFA_AEN_IOC_INVALID_NWWN, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
125 BFA_LOG_ERROR, "BFA_AEN_IOC_INVALID_NWWN",
126 "Invalid NWWN. Link initialization failed: NWWN = 00:00:00:00:00:00:00:00.",
127 (0), 0},
128
129{BFA_AEN_IOC_INVALID_PWWN, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
130 BFA_LOG_ERROR, "BFA_AEN_IOC_INVALID_PWWN",
131 "Invalid PWWN. Link initialization failed: PWWN = 00:00:00:00:00:00:00:00.",
132 (0), 0},
133
134
135
136
137/* messages define for BFA_AEN_CAT_ITNIM Module */
138{BFA_AEN_ITNIM_ONLINE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
139 "BFA_AEN_ITNIM_ONLINE",
140 "Target (WWN = %s) is online for initiator (WWN = %s).",
141 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
142
143{BFA_AEN_ITNIM_OFFLINE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
144 "BFA_AEN_ITNIM_OFFLINE",
145 "Target (WWN = %s) offlined by initiator (WWN = %s).",
146 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
147
148{BFA_AEN_ITNIM_DISCONNECT, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
149 BFA_LOG_ERROR, "BFA_AEN_ITNIM_DISCONNECT",
150 "Target (WWN = %s) connectivity lost for initiator (WWN = %s).",
151 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
152
153
154
155
156/* messages define for BFA_AEN_CAT_LPORT Module */
157{BFA_AEN_LPORT_NEW, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
158 "BFA_AEN_LPORT_NEW",
159 "New logical port created: WWN = %s, Role = %s.",
160 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
161
162{BFA_AEN_LPORT_DELETE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
163 "BFA_AEN_LPORT_DELETE",
164 "Logical port deleted: WWN = %s, Role = %s.",
165 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
166
167{BFA_AEN_LPORT_ONLINE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
168 "BFA_AEN_LPORT_ONLINE",
169 "Logical port online: WWN = %s, Role = %s.",
170 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
171
172{BFA_AEN_LPORT_OFFLINE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
173 "BFA_AEN_LPORT_OFFLINE",
174 "Logical port taken offline: WWN = %s, Role = %s.",
175 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
176
177{BFA_AEN_LPORT_DISCONNECT, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
178 BFA_LOG_ERROR, "BFA_AEN_LPORT_DISCONNECT",
179 "Logical port lost fabric connectivity: WWN = %s, Role = %s.",
180 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
181
182{BFA_AEN_LPORT_NEW_PROP, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
183 "BFA_AEN_LPORT_NEW_PROP",
184 "New virtual port created using proprietary interface: WWN = %s, Role = %s.",
185 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
186
187{BFA_AEN_LPORT_DELETE_PROP, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
188 BFA_LOG_INFO, "BFA_AEN_LPORT_DELETE_PROP",
189 "Virtual port deleted using proprietary interface: WWN = %s, Role = %s.",
190 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
191
192{BFA_AEN_LPORT_NEW_STANDARD, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
193 BFA_LOG_INFO, "BFA_AEN_LPORT_NEW_STANDARD",
194 "New virtual port created using standard interface: WWN = %s, Role = %s.",
195 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
196
197{BFA_AEN_LPORT_DELETE_STANDARD, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
198 BFA_LOG_INFO, "BFA_AEN_LPORT_DELETE_STANDARD",
199 "Virtual port deleted using standard interface: WWN = %s, Role = %s.",
200 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
201
202{BFA_AEN_LPORT_NPIV_DUP_WWN, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
203 BFA_LOG_WARNING, "BFA_AEN_LPORT_NPIV_DUP_WWN",
204 "Virtual port login failed. Duplicate WWN = %s reported by fabric.",
205 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
206
207{BFA_AEN_LPORT_NPIV_FABRIC_MAX, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
208 BFA_LOG_WARNING, "BFA_AEN_LPORT_NPIV_FABRIC_MAX",
209 "Virtual port (WWN = %s) login failed. Max NPIV ports already exist in"
210 " fabric/fport.",
211 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
212
213{BFA_AEN_LPORT_NPIV_UNKNOWN, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
214 BFA_LOG_WARNING, "BFA_AEN_LPORT_NPIV_UNKNOWN",
215 "Virtual port (WWN = %s) login failed.",
216 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
217
218
219
220
221/* messages define for BFA_AEN_CAT_PORT Module */
222{BFA_AEN_PORT_ONLINE, BFA_LOG_ATTR_NONE, BFA_LOG_INFO, "BFA_AEN_PORT_ONLINE",
223 "Base port online: WWN = %s.",
224 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
225
226{BFA_AEN_PORT_OFFLINE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_WARNING,
227 "BFA_AEN_PORT_OFFLINE",
228 "Base port offline: WWN = %s.",
229 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
230
231{BFA_AEN_PORT_RLIR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
232 "BFA_AEN_PORT_RLIR",
233 "RLIR event not supported.",
234 (0), 0},
235
236{BFA_AEN_PORT_SFP_INSERT, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
237 "BFA_AEN_PORT_SFP_INSERT",
238 "New SFP found: WWN/MAC = %s.",
239 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
240
241{BFA_AEN_PORT_SFP_REMOVE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
242 BFA_LOG_WARNING, "BFA_AEN_PORT_SFP_REMOVE",
243 "SFP removed: WWN/MAC = %s.",
244 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
245
246{BFA_AEN_PORT_SFP_POM, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_WARNING,
247 "BFA_AEN_PORT_SFP_POM",
248 "SFP POM level to %s: WWN/MAC = %s.",
249 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
250
251{BFA_AEN_PORT_ENABLE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
252 "BFA_AEN_PORT_ENABLE",
253 "Base port enabled: WWN = %s.",
254 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
255
256{BFA_AEN_PORT_DISABLE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
257 "BFA_AEN_PORT_DISABLE",
258 "Base port disabled: WWN = %s.",
259 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
260
261{BFA_AEN_PORT_AUTH_ON, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
262 "BFA_AEN_PORT_AUTH_ON",
263 "Authentication successful for base port: WWN = %s.",
264 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
265
266{BFA_AEN_PORT_AUTH_OFF, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_ERROR,
267 "BFA_AEN_PORT_AUTH_OFF",
268 "Authentication unsuccessful for base port: WWN = %s.",
269 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
270
271{BFA_AEN_PORT_DISCONNECT, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_ERROR,
272 "BFA_AEN_PORT_DISCONNECT",
273 "Base port (WWN = %s) lost fabric connectivity.",
274 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
275
276{BFA_AEN_PORT_QOS_NEG, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_WARNING,
277 "BFA_AEN_PORT_QOS_NEG",
278 "QOS negotiation failed for base port: WWN = %s.",
279 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
280
281{BFA_AEN_PORT_FABRIC_NAME_CHANGE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
282 BFA_LOG_WARNING, "BFA_AEN_PORT_FABRIC_NAME_CHANGE",
283 "Base port WWN = %s, Fabric WWN = %s.",
284 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
285
286{BFA_AEN_PORT_SFP_ACCESS_ERROR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
287 BFA_LOG_WARNING, "BFA_AEN_PORT_SFP_ACCESS_ERROR",
288 "SFP access error: WWN/MAC = %s.",
289 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
290
291{BFA_AEN_PORT_SFP_UNSUPPORT, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
292 BFA_LOG_WARNING, "BFA_AEN_PORT_SFP_UNSUPPORT",
293 "Unsupported SFP found: WWN/MAC = %s.",
294 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
295
296
297
298
299/* messages define for BFA_AEN_CAT_RPORT Module */
300{BFA_AEN_RPORT_ONLINE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
301 "BFA_AEN_RPORT_ONLINE",
302 "Remote port (WWN = %s) online for logical port (WWN = %s).",
303 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
304
305{BFA_AEN_RPORT_OFFLINE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
306 "BFA_AEN_RPORT_OFFLINE",
307 "Remote port (WWN = %s) offlined by logical port (WWN = %s).",
308 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
309
310{BFA_AEN_RPORT_DISCONNECT, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
311 BFA_LOG_ERROR, "BFA_AEN_RPORT_DISCONNECT",
312 "Remote port (WWN = %s) connectivity lost for logical port (WWN = %s).",
313 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) | 0), 2},
314
315{BFA_AEN_RPORT_QOS_PRIO, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
316 "BFA_AEN_RPORT_QOS_PRIO",
317 "QOS priority changed to %s: RPWWN = %s and LPWWN = %s.",
318 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) |
319 (BFA_LOG_S << BFA_LOG_ARG2) | 0), 3},
320
321{BFA_AEN_RPORT_QOS_FLOWID, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
322 "BFA_AEN_RPORT_QOS_FLOWID",
323 "QOS flow ID changed to %d: RPWWN = %s and LPWWN = %s.",
324 ((BFA_LOG_D << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) |
325 (BFA_LOG_S << BFA_LOG_ARG2) | 0), 3},
326
327
328
329
330/* messages define for FCS Module */
331{BFA_LOG_FCS_FABRIC_NOSWITCH, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
332 BFA_LOG_INFO, "FCS_FABRIC_NOSWITCH",
333 "No switched fabric presence is detected.",
334 (0), 0},
335
336{BFA_LOG_FCS_FABRIC_ISOLATED, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
337 BFA_LOG_INFO, "FCS_FABRIC_ISOLATED",
338 "Port is isolated due to VF_ID mismatch. PWWN: %s, Port VF_ID: %04x and"
339 " switch port VF_ID: %04x.",
340 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_X << BFA_LOG_ARG1) |
341 (BFA_LOG_X << BFA_LOG_ARG2) | 0), 3},
342
343
344
345
346/* messages define for HAL Module */
347{BFA_LOG_HAL_ASSERT, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_ERROR,
348 "HAL_ASSERT",
349 "Assertion failure: %s:%d: %s",
350 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_D << BFA_LOG_ARG1) |
351 (BFA_LOG_S << BFA_LOG_ARG2) | 0), 3},
352
353{BFA_LOG_HAL_HEARTBEAT_FAILURE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
354 BFA_LOG_CRITICAL, "HAL_HEARTBEAT_FAILURE",
355 "Firmware heartbeat failure at %d",
356 ((BFA_LOG_D << BFA_LOG_ARG0) | 0), 1},
357
358{BFA_LOG_HAL_FCPIM_PARM_INVALID, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
359 BFA_LOG_INFO, "HAL_FCPIM_PARM_INVALID",
360 "Driver configuration %s value %d is invalid. Value should be within"
361 " %d and %d.",
362 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_D << BFA_LOG_ARG1) |
363 (BFA_LOG_D << BFA_LOG_ARG2) | (BFA_LOG_D << BFA_LOG_ARG3) | 0), 4},
364
365{BFA_LOG_HAL_SM_ASSERT, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_ERROR,
366 "HAL_SM_ASSERT",
367 "SM Assertion failure: %s:%d: event = %d",
368 ((BFA_LOG_S << BFA_LOG_ARG0) | (BFA_LOG_D << BFA_LOG_ARG1) |
369 (BFA_LOG_D << BFA_LOG_ARG2) | 0), 3},
370
371{BFA_LOG_HAL_DRIVER_ERROR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
372 BFA_LOG_INFO, "HAL_DRIVER_ERROR",
373 "%s",
374 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
375
376{BFA_LOG_HAL_DRIVER_CONFIG_ERROR,
377 BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
378 "HAL_DRIVER_CONFIG_ERROR",
379 "%s",
380 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
381
382{BFA_LOG_HAL_MBOX_ERROR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
383 BFA_LOG_INFO, "HAL_MBOX_ERROR",
384 "%s",
385 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
386
387
388
389
390/* messages define for LINUX Module */
391{BFA_LOG_LINUX_DEVICE_CLAIMED, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
392 BFA_LOG_INFO, "LINUX_DEVICE_CLAIMED",
393 "bfa device at %s claimed.",
394 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
395
396{BFA_LOG_LINUX_HASH_INIT_FAILED, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
397 BFA_LOG_INFO, "LINUX_HASH_INIT_FAILED",
398 "Hash table initialization failure for the port %s.",
399 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
400
401{BFA_LOG_LINUX_SYSFS_FAILED, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
402 BFA_LOG_INFO, "LINUX_SYSFS_FAILED",
403 "sysfs file creation failure for the port %s.",
404 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
405
406{BFA_LOG_LINUX_MEM_ALLOC_FAILED, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
407 BFA_LOG_INFO, "LINUX_MEM_ALLOC_FAILED",
408 "Memory allocation failed: %s. ",
409 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
410
411{BFA_LOG_LINUX_DRIVER_REGISTRATION_FAILED,
412 BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
413 "LINUX_DRIVER_REGISTRATION_FAILED",
414 "%s. ",
415 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
416
417{BFA_LOG_LINUX_ITNIM_FREE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
418 "LINUX_ITNIM_FREE",
419 "scsi%d: FCID: %s WWPN: %s",
420 ((BFA_LOG_D << BFA_LOG_ARG0) | (BFA_LOG_S << BFA_LOG_ARG1) |
421 (BFA_LOG_S << BFA_LOG_ARG2) | 0), 3},
422
423{BFA_LOG_LINUX_ITNIM_ONLINE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
424 BFA_LOG_INFO, "LINUX_ITNIM_ONLINE",
425 "Target: %d:0:%d FCID: %s WWPN: %s",
426 ((BFA_LOG_D << BFA_LOG_ARG0) | (BFA_LOG_D << BFA_LOG_ARG1) |
427 (BFA_LOG_S << BFA_LOG_ARG2) | (BFA_LOG_S << BFA_LOG_ARG3) | 0), 4},
428
429{BFA_LOG_LINUX_ITNIM_OFFLINE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
430 BFA_LOG_INFO, "LINUX_ITNIM_OFFLINE",
431 "Target: %d:0:%d FCID: %s WWPN: %s",
432 ((BFA_LOG_D << BFA_LOG_ARG0) | (BFA_LOG_D << BFA_LOG_ARG1) |
433 (BFA_LOG_S << BFA_LOG_ARG2) | (BFA_LOG_S << BFA_LOG_ARG3) | 0), 4},
434
435{BFA_LOG_LINUX_SCSI_HOST_FREE, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
436 BFA_LOG_INFO, "LINUX_SCSI_HOST_FREE",
437 "Free scsi%d",
438 ((BFA_LOG_D << BFA_LOG_ARG0) | 0), 1},
439
440{BFA_LOG_LINUX_SCSI_ABORT, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
441 "LINUX_SCSI_ABORT",
442 "scsi%d: abort cmnd %p, iotag %x",
443 ((BFA_LOG_D << BFA_LOG_ARG0) | (BFA_LOG_P << BFA_LOG_ARG1) |
444 (BFA_LOG_X << BFA_LOG_ARG2) | 0), 3},
445
446{BFA_LOG_LINUX_SCSI_ABORT_COMP, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
447 BFA_LOG_INFO, "LINUX_SCSI_ABORT_COMP",
448 "scsi%d: complete abort 0x%p, iotag 0x%x",
449 ((BFA_LOG_D << BFA_LOG_ARG0) | (BFA_LOG_P << BFA_LOG_ARG1) |
450 (BFA_LOG_X << BFA_LOG_ARG2) | 0), 3},
451
452{BFA_LOG_LINUX_DRIVER_CONFIG_ERROR,
453 BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
454 "LINUX_DRIVER_CONFIG_ERROR",
455 "%s",
456 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
457
458{BFA_LOG_LINUX_BNA_STATE_MACHINE,
459 BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
460 "LINUX_BNA_STATE_MACHINE",
461 "%s",
462 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
463
464{BFA_LOG_LINUX_IOC_ERROR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
465 BFA_LOG_INFO, "LINUX_IOC_ERROR",
466 "%s",
467 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
468
469{BFA_LOG_LINUX_RESOURCE_ALLOC_ERROR,
470 BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
471 "LINUX_RESOURCE_ALLOC_ERROR",
472 "%s",
473 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
474
475{BFA_LOG_LINUX_RING_BUFFER_ERROR,
476 BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG, BFA_LOG_INFO,
477 "LINUX_RING_BUFFER_ERROR",
478 "%s",
479 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
480
481{BFA_LOG_LINUX_DRIVER_ERROR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
482 BFA_LOG_ERROR, "LINUX_DRIVER_ERROR",
483 "%s",
484 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
485
486{BFA_LOG_LINUX_DRIVER_INFO, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
487 BFA_LOG_INFO, "LINUX_DRIVER_INFO",
488 "%s",
489 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
490
491{BFA_LOG_LINUX_DRIVER_DIAG, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
492 BFA_LOG_INFO, "LINUX_DRIVER_DIAG",
493 "%s",
494 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
495
496{BFA_LOG_LINUX_DRIVER_AEN, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
497 BFA_LOG_INFO, "LINUX_DRIVER_AEN",
498 "%s",
499 ((BFA_LOG_S << BFA_LOG_ARG0) | 0), 1},
500
501
502
503
504/* messages define for WDRV Module */
505{BFA_LOG_WDRV_IOC_INIT_ERROR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
506 BFA_LOG_INFO, "WDRV_IOC_INIT_ERROR",
507 "IOC initialization has failed.",
508 (0), 0},
509
510{BFA_LOG_WDRV_IOC_INTERNAL_ERROR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
511 BFA_LOG_INFO, "WDRV_IOC_INTERNAL_ERROR",
512 "IOC internal error. ",
513 (0), 0},
514
515{BFA_LOG_WDRV_IOC_START_ERROR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
516 BFA_LOG_INFO, "WDRV_IOC_START_ERROR",
517 "IOC could not be started. ",
518 (0), 0},
519
520{BFA_LOG_WDRV_IOC_STOP_ERROR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
521 BFA_LOG_INFO, "WDRV_IOC_STOP_ERROR",
522 "IOC could not be stopped. ",
523 (0), 0},
524
525{BFA_LOG_WDRV_INSUFFICIENT_RESOURCES, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
526 BFA_LOG_INFO, "WDRV_INSUFFICIENT_RESOURCES",
527 "Insufficient memory. ",
528 (0), 0},
529
530{BFA_LOG_WDRV_BASE_ADDRESS_MAP_ERROR, BFA_LOG_ATTR_NONE | BFA_LOG_ATTR_LOG,
531 BFA_LOG_INFO, "WDRV_BASE_ADDRESS_MAP_ERROR",
532 "Unable to map the IOC onto the system address space. ",
533 (0), 0},
534
535
536{0, 0, 0, "", "", 0, 0},
537};
diff --git a/drivers/scsi/bfa/bfa_lps.c b/drivers/scsi/bfa/bfa_lps.c
deleted file mode 100644
index acabb44f092f..000000000000
--- a/drivers/scsi/bfa/bfa_lps.c
+++ /dev/null
@@ -1,892 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
19#include <bfi/bfi_lps.h>
20#include <cs/bfa_debug.h>
21#include <defs/bfa_defs_pci.h>
22
23BFA_TRC_FILE(HAL, LPS);
24BFA_MODULE(lps);
25
26#define BFA_LPS_MIN_LPORTS (1)
27#define BFA_LPS_MAX_LPORTS (256)
28
29/*
30 * Maximum Vports supported per physical port or vf.
31 */
32#define BFA_LPS_MAX_VPORTS_SUPP_CB 255
33#define BFA_LPS_MAX_VPORTS_SUPP_CT 190
34
35/**
36 * forward declarations
37 */
38static void bfa_lps_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len,
39 u32 *dm_len);
40static void bfa_lps_attach(struct bfa_s *bfa, void *bfad,
41 struct bfa_iocfc_cfg_s *cfg,
42 struct bfa_meminfo_s *meminfo,
43 struct bfa_pcidev_s *pcidev);
44static void bfa_lps_detach(struct bfa_s *bfa);
45static void bfa_lps_start(struct bfa_s *bfa);
46static void bfa_lps_stop(struct bfa_s *bfa);
47static void bfa_lps_iocdisable(struct bfa_s *bfa);
48static void bfa_lps_login_rsp(struct bfa_s *bfa,
49 struct bfi_lps_login_rsp_s *rsp);
50static void bfa_lps_logout_rsp(struct bfa_s *bfa,
51 struct bfi_lps_logout_rsp_s *rsp);
52static void bfa_lps_reqq_resume(void *lps_arg);
53static void bfa_lps_free(struct bfa_lps_s *lps);
54static void bfa_lps_send_login(struct bfa_lps_s *lps);
55static void bfa_lps_send_logout(struct bfa_lps_s *lps);
56static void bfa_lps_login_comp(struct bfa_lps_s *lps);
57static void bfa_lps_logout_comp(struct bfa_lps_s *lps);
58static void bfa_lps_cvl_event(struct bfa_lps_s *lps);
59
60/**
61 * lps_pvt BFA LPS private functions
62 */
63
64enum bfa_lps_event {
65 BFA_LPS_SM_LOGIN = 1, /* login request from user */
66 BFA_LPS_SM_LOGOUT = 2, /* logout request from user */
67 BFA_LPS_SM_FWRSP = 3, /* f/w response to login/logout */
68 BFA_LPS_SM_RESUME = 4, /* space present in reqq queue */
69 BFA_LPS_SM_DELETE = 5, /* lps delete from user */
70 BFA_LPS_SM_OFFLINE = 6, /* Link is offline */
71 BFA_LPS_SM_RX_CVL = 7, /* Rx clear virtual link */
72};
73
74static void bfa_lps_sm_init(struct bfa_lps_s *lps, enum bfa_lps_event event);
75static void bfa_lps_sm_login(struct bfa_lps_s *lps, enum bfa_lps_event event);
76static void bfa_lps_sm_loginwait(struct bfa_lps_s *lps,
77 enum bfa_lps_event event);
78static void bfa_lps_sm_online(struct bfa_lps_s *lps, enum bfa_lps_event event);
79static void bfa_lps_sm_logout(struct bfa_lps_s *lps, enum bfa_lps_event event);
80static void bfa_lps_sm_logowait(struct bfa_lps_s *lps,
81 enum bfa_lps_event event);
82
83/**
84 * Init state -- no login
85 */
86static void
87bfa_lps_sm_init(struct bfa_lps_s *lps, enum bfa_lps_event event)
88{
89 bfa_trc(lps->bfa, lps->lp_tag);
90 bfa_trc(lps->bfa, event);
91
92 switch (event) {
93 case BFA_LPS_SM_LOGIN:
94 if (bfa_reqq_full(lps->bfa, lps->reqq)) {
95 bfa_sm_set_state(lps, bfa_lps_sm_loginwait);
96 bfa_reqq_wait(lps->bfa, lps->reqq, &lps->wqe);
97 } else {
98 bfa_sm_set_state(lps, bfa_lps_sm_login);
99 bfa_lps_send_login(lps);
100 }
101 if (lps->fdisc)
102 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
103 BFA_PL_EID_LOGIN, 0, "FDISC Request");
104 else
105 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
106 BFA_PL_EID_LOGIN, 0, "FLOGI Request");
107 break;
108
109 case BFA_LPS_SM_LOGOUT:
110 bfa_lps_logout_comp(lps);
111 break;
112
113 case BFA_LPS_SM_DELETE:
114 bfa_lps_free(lps);
115 break;
116
117 case BFA_LPS_SM_RX_CVL:
118 case BFA_LPS_SM_OFFLINE:
119 break;
120
121 case BFA_LPS_SM_FWRSP:
122 /* Could happen when fabric detects loopback and discards
123 * the lps request. Fw will eventually sent out the timeout
124 * Just ignore
125 */
126 break;
127
128 default:
129 bfa_sm_fault(lps->bfa, event);
130 }
131}
132
133/**
134 * login is in progress -- awaiting response from firmware
135 */
136static void
137bfa_lps_sm_login(struct bfa_lps_s *lps, enum bfa_lps_event event)
138{
139 bfa_trc(lps->bfa, lps->lp_tag);
140 bfa_trc(lps->bfa, event);
141
142 switch (event) {
143 case BFA_LPS_SM_FWRSP:
144 if (lps->status == BFA_STATUS_OK) {
145 bfa_sm_set_state(lps, bfa_lps_sm_online);
146 if (lps->fdisc)
147 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
148 BFA_PL_EID_LOGIN, 0, "FDISC Accept");
149 else
150 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
151 BFA_PL_EID_LOGIN, 0, "FLOGI Accept");
152 } else {
153 bfa_sm_set_state(lps, bfa_lps_sm_init);
154 if (lps->fdisc)
155 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
156 BFA_PL_EID_LOGIN, 0,
157 "FDISC Fail (RJT or timeout)");
158 else
159 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
160 BFA_PL_EID_LOGIN, 0,
161 "FLOGI Fail (RJT or timeout)");
162 }
163 bfa_lps_login_comp(lps);
164 break;
165
166 case BFA_LPS_SM_OFFLINE:
167 bfa_sm_set_state(lps, bfa_lps_sm_init);
168 break;
169
170 default:
171 bfa_sm_fault(lps->bfa, event);
172 }
173}
174
175/**
176 * login pending - awaiting space in request queue
177 */
178static void
179bfa_lps_sm_loginwait(struct bfa_lps_s *lps, enum bfa_lps_event event)
180{
181 bfa_trc(lps->bfa, lps->lp_tag);
182 bfa_trc(lps->bfa, event);
183
184 switch (event) {
185 case BFA_LPS_SM_RESUME:
186 bfa_sm_set_state(lps, bfa_lps_sm_login);
187 break;
188
189 case BFA_LPS_SM_OFFLINE:
190 bfa_sm_set_state(lps, bfa_lps_sm_init);
191 bfa_reqq_wcancel(&lps->wqe);
192 break;
193
194 case BFA_LPS_SM_RX_CVL:
195 /*
196 * Login was not even sent out; so when getting out
197 * of this state, it will appear like a login retry
198 * after Clear virtual link
199 */
200 break;
201
202 default:
203 bfa_sm_fault(lps->bfa, event);
204 }
205}
206
207/**
208 * login complete
209 */
210static void
211bfa_lps_sm_online(struct bfa_lps_s *lps, enum bfa_lps_event event)
212{
213 bfa_trc(lps->bfa, lps->lp_tag);
214 bfa_trc(lps->bfa, event);
215
216 switch (event) {
217 case BFA_LPS_SM_LOGOUT:
218 if (bfa_reqq_full(lps->bfa, lps->reqq)) {
219 bfa_sm_set_state(lps, bfa_lps_sm_logowait);
220 bfa_reqq_wait(lps->bfa, lps->reqq, &lps->wqe);
221 } else {
222 bfa_sm_set_state(lps, bfa_lps_sm_logout);
223 bfa_lps_send_logout(lps);
224 }
225 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
226 BFA_PL_EID_LOGO, 0, "Logout");
227 break;
228
229 case BFA_LPS_SM_RX_CVL:
230 bfa_sm_set_state(lps, bfa_lps_sm_init);
231
232 /* Let the vport module know about this event */
233 bfa_lps_cvl_event(lps);
234 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
235 BFA_PL_EID_FIP_FCF_CVL, 0, "FCF Clear Virt. Link Rx");
236 break;
237
238 case BFA_LPS_SM_OFFLINE:
239 case BFA_LPS_SM_DELETE:
240 bfa_sm_set_state(lps, bfa_lps_sm_init);
241 break;
242
243 default:
244 bfa_sm_fault(lps->bfa, event);
245 }
246}
247
248/**
249 * logout in progress - awaiting firmware response
250 */
251static void
252bfa_lps_sm_logout(struct bfa_lps_s *lps, enum bfa_lps_event event)
253{
254 bfa_trc(lps->bfa, lps->lp_tag);
255 bfa_trc(lps->bfa, event);
256
257 switch (event) {
258 case BFA_LPS_SM_FWRSP:
259 bfa_sm_set_state(lps, bfa_lps_sm_init);
260 bfa_lps_logout_comp(lps);
261 break;
262
263 case BFA_LPS_SM_OFFLINE:
264 bfa_sm_set_state(lps, bfa_lps_sm_init);
265 break;
266
267 default:
268 bfa_sm_fault(lps->bfa, event);
269 }
270}
271
272/**
273 * logout pending -- awaiting space in request queue
274 */
275static void
276bfa_lps_sm_logowait(struct bfa_lps_s *lps, enum bfa_lps_event event)
277{
278 bfa_trc(lps->bfa, lps->lp_tag);
279 bfa_trc(lps->bfa, event);
280
281 switch (event) {
282 case BFA_LPS_SM_RESUME:
283 bfa_sm_set_state(lps, bfa_lps_sm_logout);
284 bfa_lps_send_logout(lps);
285 break;
286
287 case BFA_LPS_SM_OFFLINE:
288 bfa_sm_set_state(lps, bfa_lps_sm_init);
289 bfa_reqq_wcancel(&lps->wqe);
290 break;
291
292 default:
293 bfa_sm_fault(lps->bfa, event);
294 }
295}
296
297
298
299/**
300 * lps_pvt BFA LPS private functions
301 */
302
303/**
304 * return memory requirement
305 */
306static void
307bfa_lps_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, u32 *dm_len)
308{
309 if (cfg->drvcfg.min_cfg)
310 *ndm_len += sizeof(struct bfa_lps_s) * BFA_LPS_MIN_LPORTS;
311 else
312 *ndm_len += sizeof(struct bfa_lps_s) * BFA_LPS_MAX_LPORTS;
313}
314
315/**
316 * bfa module attach at initialization time
317 */
318static void
319bfa_lps_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
320 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
321{
322 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
323 struct bfa_lps_s *lps;
324 int i;
325
326 bfa_os_memset(mod, 0, sizeof(struct bfa_lps_mod_s));
327 mod->num_lps = BFA_LPS_MAX_LPORTS;
328 if (cfg->drvcfg.min_cfg)
329 mod->num_lps = BFA_LPS_MIN_LPORTS;
330 else
331 mod->num_lps = BFA_LPS_MAX_LPORTS;
332 mod->lps_arr = lps = (struct bfa_lps_s *) bfa_meminfo_kva(meminfo);
333
334 bfa_meminfo_kva(meminfo) += mod->num_lps * sizeof(struct bfa_lps_s);
335
336 INIT_LIST_HEAD(&mod->lps_free_q);
337 INIT_LIST_HEAD(&mod->lps_active_q);
338
339 for (i = 0; i < mod->num_lps; i++, lps++) {
340 lps->bfa = bfa;
341 lps->lp_tag = (u8) i;
342 lps->reqq = BFA_REQQ_LPS;
343 bfa_reqq_winit(&lps->wqe, bfa_lps_reqq_resume, lps);
344 list_add_tail(&lps->qe, &mod->lps_free_q);
345 }
346}
347
348static void
349bfa_lps_detach(struct bfa_s *bfa)
350{
351}
352
353static void
354bfa_lps_start(struct bfa_s *bfa)
355{
356}
357
358static void
359bfa_lps_stop(struct bfa_s *bfa)
360{
361}
362
363/**
364 * IOC in disabled state -- consider all lps offline
365 */
366static void
367bfa_lps_iocdisable(struct bfa_s *bfa)
368{
369 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
370 struct bfa_lps_s *lps;
371 struct list_head *qe, *qen;
372
373 list_for_each_safe(qe, qen, &mod->lps_active_q) {
374 lps = (struct bfa_lps_s *) qe;
375 bfa_sm_send_event(lps, BFA_LPS_SM_OFFLINE);
376 }
377}
378
379/**
380 * Firmware login response
381 */
382static void
383bfa_lps_login_rsp(struct bfa_s *bfa, struct bfi_lps_login_rsp_s *rsp)
384{
385 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
386 struct bfa_lps_s *lps;
387
388 bfa_assert(rsp->lp_tag < mod->num_lps);
389 lps = BFA_LPS_FROM_TAG(mod, rsp->lp_tag);
390
391 lps->status = rsp->status;
392 switch (rsp->status) {
393 case BFA_STATUS_OK:
394 lps->fport = rsp->f_port;
395 lps->npiv_en = rsp->npiv_en;
396 lps->lp_pid = rsp->lp_pid;
397 lps->pr_bbcred = bfa_os_ntohs(rsp->bb_credit);
398 lps->pr_pwwn = rsp->port_name;
399 lps->pr_nwwn = rsp->node_name;
400 lps->auth_req = rsp->auth_req;
401 lps->lp_mac = rsp->lp_mac;
402 lps->brcd_switch = rsp->brcd_switch;
403 lps->fcf_mac = rsp->fcf_mac;
404
405 break;
406
407 case BFA_STATUS_FABRIC_RJT:
408 lps->lsrjt_rsn = rsp->lsrjt_rsn;
409 lps->lsrjt_expl = rsp->lsrjt_expl;
410
411 break;
412
413 case BFA_STATUS_EPROTOCOL:
414 lps->ext_status = rsp->ext_status;
415
416 break;
417
418 default:
419 /* Nothing to do with other status */
420 break;
421 }
422
423 bfa_sm_send_event(lps, BFA_LPS_SM_FWRSP);
424}
425
426/**
427 * Firmware logout response
428 */
429static void
430bfa_lps_logout_rsp(struct bfa_s *bfa, struct bfi_lps_logout_rsp_s *rsp)
431{
432 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
433 struct bfa_lps_s *lps;
434
435 bfa_assert(rsp->lp_tag < mod->num_lps);
436 lps = BFA_LPS_FROM_TAG(mod, rsp->lp_tag);
437
438 bfa_sm_send_event(lps, BFA_LPS_SM_FWRSP);
439}
440
441/**
442 * Firmware received a Clear virtual link request (for FCoE)
443 */
444static void
445bfa_lps_rx_cvl_event(struct bfa_s *bfa, struct bfi_lps_cvl_event_s *cvl)
446{
447 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
448 struct bfa_lps_s *lps;
449
450 lps = BFA_LPS_FROM_TAG(mod, cvl->lp_tag);
451
452 bfa_sm_send_event(lps, BFA_LPS_SM_RX_CVL);
453}
454
455/**
456 * Space is available in request queue, resume queueing request to firmware.
457 */
458static void
459bfa_lps_reqq_resume(void *lps_arg)
460{
461 struct bfa_lps_s *lps = lps_arg;
462
463 bfa_sm_send_event(lps, BFA_LPS_SM_RESUME);
464}
465
466/**
467 * lps is freed -- triggered by vport delete
468 */
469static void
470bfa_lps_free(struct bfa_lps_s *lps)
471{
472 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(lps->bfa);
473
474 list_del(&lps->qe);
475 list_add_tail(&lps->qe, &mod->lps_free_q);
476}
477
478/**
479 * send login request to firmware
480 */
481static void
482bfa_lps_send_login(struct bfa_lps_s *lps)
483{
484 struct bfi_lps_login_req_s *m;
485
486 m = bfa_reqq_next(lps->bfa, lps->reqq);
487 bfa_assert(m);
488
489 bfi_h2i_set(m->mh, BFI_MC_LPS, BFI_LPS_H2I_LOGIN_REQ,
490 bfa_lpuid(lps->bfa));
491
492 m->lp_tag = lps->lp_tag;
493 m->alpa = lps->alpa;
494 m->pdu_size = bfa_os_htons(lps->pdusz);
495 m->pwwn = lps->pwwn;
496 m->nwwn = lps->nwwn;
497 m->fdisc = lps->fdisc;
498 m->auth_en = lps->auth_en;
499
500 bfa_reqq_produce(lps->bfa, lps->reqq);
501}
502
503/**
504 * send logout request to firmware
505 */
506static void
507bfa_lps_send_logout(struct bfa_lps_s *lps)
508{
509 struct bfi_lps_logout_req_s *m;
510
511 m = bfa_reqq_next(lps->bfa, lps->reqq);
512 bfa_assert(m);
513
514 bfi_h2i_set(m->mh, BFI_MC_LPS, BFI_LPS_H2I_LOGOUT_REQ,
515 bfa_lpuid(lps->bfa));
516
517 m->lp_tag = lps->lp_tag;
518 m->port_name = lps->pwwn;
519 bfa_reqq_produce(lps->bfa, lps->reqq);
520}
521
522/**
523 * Indirect login completion handler for non-fcs
524 */
525static void
526bfa_lps_login_comp_cb(void *arg, bfa_boolean_t complete)
527{
528 struct bfa_lps_s *lps = arg;
529
530 if (!complete)
531 return;
532
533 if (lps->fdisc)
534 bfa_cb_lps_fdisc_comp(lps->bfa->bfad, lps->uarg, lps->status);
535 else
536 bfa_cb_lps_flogi_comp(lps->bfa->bfad, lps->uarg, lps->status);
537}
538
539/**
540 * Login completion handler -- direct call for fcs, queue for others
541 */
542static void
543bfa_lps_login_comp(struct bfa_lps_s *lps)
544{
545 if (!lps->bfa->fcs) {
546 bfa_cb_queue(lps->bfa, &lps->hcb_qe,
547 bfa_lps_login_comp_cb, lps);
548 return;
549 }
550
551 if (lps->fdisc)
552 bfa_cb_lps_fdisc_comp(lps->bfa->bfad, lps->uarg, lps->status);
553 else
554 bfa_cb_lps_flogi_comp(lps->bfa->bfad, lps->uarg, lps->status);
555}
556
557/**
558 * Indirect logout completion handler for non-fcs
559 */
560static void
561bfa_lps_logout_comp_cb(void *arg, bfa_boolean_t complete)
562{
563 struct bfa_lps_s *lps = arg;
564
565 if (!complete)
566 return;
567
568 if (lps->fdisc)
569 bfa_cb_lps_fdisclogo_comp(lps->bfa->bfad, lps->uarg);
570 else
571 bfa_cb_lps_flogo_comp(lps->bfa->bfad, lps->uarg);
572}
573
574/**
575 * Logout completion handler -- direct call for fcs, queue for others
576 */
577static void
578bfa_lps_logout_comp(struct bfa_lps_s *lps)
579{
580 if (!lps->bfa->fcs) {
581 bfa_cb_queue(lps->bfa, &lps->hcb_qe,
582 bfa_lps_logout_comp_cb, lps);
583 return;
584 }
585 if (lps->fdisc)
586 bfa_cb_lps_fdisclogo_comp(lps->bfa->bfad, lps->uarg);
587 else
588 bfa_cb_lps_flogo_comp(lps->bfa->bfad, lps->uarg);
589}
590
591/**
592 * Clear virtual link completion handler for non-fcs
593 */
594static void
595bfa_lps_cvl_event_cb(void *arg, bfa_boolean_t complete)
596{
597 struct bfa_lps_s *lps = arg;
598
599 if (!complete)
600 return;
601
602 /* Clear virtual link to base port will result in link down */
603 if (lps->fdisc)
604 bfa_cb_lps_cvl_event(lps->bfa->bfad, lps->uarg);
605}
606
607/**
608 * Received Clear virtual link event --direct call for fcs,
609 * queue for others
610 */
611static void
612bfa_lps_cvl_event(struct bfa_lps_s *lps)
613{
614 if (!lps->bfa->fcs) {
615 bfa_cb_queue(lps->bfa, &lps->hcb_qe, bfa_lps_cvl_event_cb,
616 lps);
617 return;
618 }
619
620 /* Clear virtual link to base port will result in link down */
621 if (lps->fdisc)
622 bfa_cb_lps_cvl_event(lps->bfa->bfad, lps->uarg);
623}
624
625u32
626bfa_lps_get_max_vport(struct bfa_s *bfa)
627{
628 if (bfa_ioc_devid(&bfa->ioc) == BFA_PCI_DEVICE_ID_CT)
629 return BFA_LPS_MAX_VPORTS_SUPP_CT;
630 else
631 return BFA_LPS_MAX_VPORTS_SUPP_CB;
632}
633
634/**
635 * lps_public BFA LPS public functions
636 */
637
638/**
639 * Allocate a lport srvice tag.
640 */
641struct bfa_lps_s *
642bfa_lps_alloc(struct bfa_s *bfa)
643{
644 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
645 struct bfa_lps_s *lps = NULL;
646
647 bfa_q_deq(&mod->lps_free_q, &lps);
648
649 if (lps == NULL)
650 return NULL;
651
652 list_add_tail(&lps->qe, &mod->lps_active_q);
653
654 bfa_sm_set_state(lps, bfa_lps_sm_init);
655 return lps;
656}
657
658/**
659 * Free lport service tag. This can be called anytime after an alloc.
660 * No need to wait for any pending login/logout completions.
661 */
662void
663bfa_lps_delete(struct bfa_lps_s *lps)
664{
665 bfa_sm_send_event(lps, BFA_LPS_SM_DELETE);
666}
667
668/**
669 * Initiate a lport login.
670 */
671void
672bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa, u16 pdusz,
673 wwn_t pwwn, wwn_t nwwn, bfa_boolean_t auth_en)
674{
675 lps->uarg = uarg;
676 lps->alpa = alpa;
677 lps->pdusz = pdusz;
678 lps->pwwn = pwwn;
679 lps->nwwn = nwwn;
680 lps->fdisc = BFA_FALSE;
681 lps->auth_en = auth_en;
682 bfa_sm_send_event(lps, BFA_LPS_SM_LOGIN);
683}
684
685/**
686 * Initiate a lport fdisc login.
687 */
688void
689bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz, wwn_t pwwn,
690 wwn_t nwwn)
691{
692 lps->uarg = uarg;
693 lps->alpa = 0;
694 lps->pdusz = pdusz;
695 lps->pwwn = pwwn;
696 lps->nwwn = nwwn;
697 lps->fdisc = BFA_TRUE;
698 lps->auth_en = BFA_FALSE;
699 bfa_sm_send_event(lps, BFA_LPS_SM_LOGIN);
700}
701
702/**
703 * Initiate a lport logout (flogi).
704 */
705void
706bfa_lps_flogo(struct bfa_lps_s *lps)
707{
708 bfa_sm_send_event(lps, BFA_LPS_SM_LOGOUT);
709}
710
711/**
712 * Initiate a lport FDSIC logout.
713 */
714void
715bfa_lps_fdisclogo(struct bfa_lps_s *lps)
716{
717 bfa_sm_send_event(lps, BFA_LPS_SM_LOGOUT);
718}
719
720/**
721 * Discard a pending login request -- should be called only for
722 * link down handling.
723 */
724void
725bfa_lps_discard(struct bfa_lps_s *lps)
726{
727 bfa_sm_send_event(lps, BFA_LPS_SM_OFFLINE);
728}
729
730/**
731 * Return lport services tag
732 */
733u8
734bfa_lps_get_tag(struct bfa_lps_s *lps)
735{
736 return lps->lp_tag;
737}
738
739/**
740 * Return lport services tag given the pid
741 */
742u8
743bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid)
744{
745 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
746 struct bfa_lps_s *lps;
747 int i;
748
749 for (i = 0, lps = mod->lps_arr; i < mod->num_lps; i++, lps++) {
750 if (lps->lp_pid == pid)
751 return lps->lp_tag;
752 }
753
754 /* Return base port tag anyway */
755 return 0;
756}
757
758/**
759 * return if fabric login indicates support for NPIV
760 */
761bfa_boolean_t
762bfa_lps_is_npiv_en(struct bfa_lps_s *lps)
763{
764 return lps->npiv_en;
765}
766
767/**
768 * Return TRUE if attached to F-Port, else return FALSE
769 */
770bfa_boolean_t
771bfa_lps_is_fport(struct bfa_lps_s *lps)
772{
773 return lps->fport;
774}
775
776/**
777 * Return TRUE if attached to a Brocade Fabric
778 */
779bfa_boolean_t
780bfa_lps_is_brcd_fabric(struct bfa_lps_s *lps)
781{
782 return lps->brcd_switch;
783}
784/**
785 * return TRUE if authentication is required
786 */
787bfa_boolean_t
788bfa_lps_is_authreq(struct bfa_lps_s *lps)
789{
790 return lps->auth_req;
791}
792
793bfa_eproto_status_t
794bfa_lps_get_extstatus(struct bfa_lps_s *lps)
795{
796 return lps->ext_status;
797}
798
799/**
800 * return port id assigned to the lport
801 */
802u32
803bfa_lps_get_pid(struct bfa_lps_s *lps)
804{
805 return lps->lp_pid;
806}
807
808/**
809 * Return bb_credit assigned in FLOGI response
810 */
811u16
812bfa_lps_get_peer_bbcredit(struct bfa_lps_s *lps)
813{
814 return lps->pr_bbcred;
815}
816
817/**
818 * Return peer port name
819 */
820wwn_t
821bfa_lps_get_peer_pwwn(struct bfa_lps_s *lps)
822{
823 return lps->pr_pwwn;
824}
825
826/**
827 * Return peer node name
828 */
829wwn_t
830bfa_lps_get_peer_nwwn(struct bfa_lps_s *lps)
831{
832 return lps->pr_nwwn;
833}
834
835/**
836 * return reason code if login request is rejected
837 */
838u8
839bfa_lps_get_lsrjt_rsn(struct bfa_lps_s *lps)
840{
841 return lps->lsrjt_rsn;
842}
843
844/**
845 * return explanation code if login request is rejected
846 */
847u8
848bfa_lps_get_lsrjt_expl(struct bfa_lps_s *lps)
849{
850 return lps->lsrjt_expl;
851}
852
853/**
854 * Return fpma/spma MAC for lport
855 */
856struct mac_s
857bfa_lps_get_lp_mac(struct bfa_lps_s *lps)
858{
859 return lps->lp_mac;
860}
861
862/**
863 * LPS firmware message class handler.
864 */
865void
866bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
867{
868 union bfi_lps_i2h_msg_u msg;
869
870 bfa_trc(bfa, m->mhdr.msg_id);
871 msg.msg = m;
872
873 switch (m->mhdr.msg_id) {
874 case BFI_LPS_H2I_LOGIN_RSP:
875 bfa_lps_login_rsp(bfa, msg.login_rsp);
876 break;
877
878 case BFI_LPS_H2I_LOGOUT_RSP:
879 bfa_lps_logout_rsp(bfa, msg.logout_rsp);
880 break;
881
882 case BFI_LPS_H2I_CVL_EVENT:
883 bfa_lps_rx_cvl_event(bfa, msg.cvl_event);
884 break;
885
886 default:
887 bfa_trc(bfa, m->mhdr.msg_id);
888 bfa_assert(0);
889 }
890}
891
892
diff --git a/drivers/scsi/bfa/bfa_lps_priv.h b/drivers/scsi/bfa/bfa_lps_priv.h
deleted file mode 100644
index d16c6ce995df..000000000000
--- a/drivers/scsi/bfa/bfa_lps_priv.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_LPS_PRIV_H__
19#define __BFA_LPS_PRIV_H__
20
21#include <bfa_svc.h>
22
23struct bfa_lps_mod_s {
24 struct list_head lps_free_q;
25 struct list_head lps_active_q;
26 struct bfa_lps_s *lps_arr;
27 int num_lps;
28};
29
30#define BFA_LPS_MOD(__bfa) (&(__bfa)->modules.lps_mod)
31#define BFA_LPS_FROM_TAG(__mod, __tag) (&(__mod)->lps_arr[__tag])
32
33/*
34 * external functions
35 */
36void bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
37
38#endif /* __BFA_LPS_PRIV_H__ */
diff --git a/drivers/scsi/bfa/bfa_module.c b/drivers/scsi/bfa/bfa_module.c
deleted file mode 100644
index a7fcc80c177e..000000000000
--- a/drivers/scsi/bfa/bfa_module.c
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
18#include <defs/bfa_defs_pci.h>
19#include <cs/bfa_debug.h>
20#include <bfa_iocfc.h>
21
22/**
23 * BFA module list terminated by NULL
24 */
25struct bfa_module_s *hal_mods[] = {
26 &hal_mod_sgpg,
27 &hal_mod_fcport,
28 &hal_mod_fcxp,
29 &hal_mod_lps,
30 &hal_mod_uf,
31 &hal_mod_rport,
32 &hal_mod_fcpim,
33#ifdef BFA_CFG_PBIND
34 &hal_mod_pbind,
35#endif
36 NULL
37};
38
39/**
40 * Message handlers for various modules.
41 */
42bfa_isr_func_t bfa_isrs[BFI_MC_MAX] = {
43 bfa_isr_unhandled, /* NONE */
44 bfa_isr_unhandled, /* BFI_MC_IOC */
45 bfa_isr_unhandled, /* BFI_MC_DIAG */
46 bfa_isr_unhandled, /* BFI_MC_FLASH */
47 bfa_isr_unhandled, /* BFI_MC_CEE */
48 bfa_fcport_isr, /* BFI_MC_FCPORT */
49 bfa_isr_unhandled, /* BFI_MC_IOCFC */
50 bfa_isr_unhandled, /* BFI_MC_LL */
51 bfa_uf_isr, /* BFI_MC_UF */
52 bfa_fcxp_isr, /* BFI_MC_FCXP */
53 bfa_lps_isr, /* BFI_MC_LPS */
54 bfa_rport_isr, /* BFI_MC_RPORT */
55 bfa_itnim_isr, /* BFI_MC_ITNIM */
56 bfa_isr_unhandled, /* BFI_MC_IOIM_READ */
57 bfa_isr_unhandled, /* BFI_MC_IOIM_WRITE */
58 bfa_isr_unhandled, /* BFI_MC_IOIM_IO */
59 bfa_ioim_isr, /* BFI_MC_IOIM */
60 bfa_ioim_good_comp_isr, /* BFI_MC_IOIM_IOCOM */
61 bfa_tskim_isr, /* BFI_MC_TSKIM */
62 bfa_isr_unhandled, /* BFI_MC_SBOOT */
63 bfa_isr_unhandled, /* BFI_MC_IPFC */
64 bfa_isr_unhandled, /* BFI_MC_PORT */
65 bfa_isr_unhandled, /* --------- */
66 bfa_isr_unhandled, /* --------- */
67 bfa_isr_unhandled, /* --------- */
68 bfa_isr_unhandled, /* --------- */
69 bfa_isr_unhandled, /* --------- */
70 bfa_isr_unhandled, /* --------- */
71 bfa_isr_unhandled, /* --------- */
72 bfa_isr_unhandled, /* --------- */
73 bfa_isr_unhandled, /* --------- */
74 bfa_isr_unhandled, /* --------- */
75};
76
77/**
78 * Message handlers for mailbox command classes
79 */
80bfa_ioc_mbox_mcfunc_t bfa_mbox_isrs[BFI_MC_MAX] = {
81 NULL,
82 NULL, /* BFI_MC_IOC */
83 NULL, /* BFI_MC_DIAG */
84 NULL, /* BFI_MC_FLASH */
85 NULL, /* BFI_MC_CEE */
86 NULL, /* BFI_MC_PORT */
87 bfa_iocfc_isr, /* BFI_MC_IOCFC */
88 NULL,
89};
90
diff --git a/drivers/scsi/bfa/bfa_priv.h b/drivers/scsi/bfa/bfa_modules.h
index bf4939b1676c..ab79ff6fdeea 100644
--- a/drivers/scsi/bfa/bfa_priv.h
+++ b/drivers/scsi/bfa/bfa_modules.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,26 +15,52 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#ifndef __BFA_PRIV_H__ 18/*
19#define __BFA_PRIV_H__ 19 * bfa_modules.h BFA modules
20 */
20 21
21#include "bfa_iocfc.h" 22#ifndef __BFA_MODULES_H__
22#include "bfa_intr_priv.h" 23#define __BFA_MODULES_H__
23#include "bfa_trcmod_priv.h"
24#include "bfa_modules_priv.h"
25#include "bfa_fwimg_priv.h"
26#include <cs/bfa_log.h>
27#include <bfa_timer.h>
28 24
29/** 25#include "bfa_cs.h"
26#include "bfa.h"
27#include "bfa_svc.h"
28#include "bfa_fcpim.h"
29#include "bfa_port.h"
30
31struct bfa_modules_s {
32 struct bfa_fcport_s fcport; /* fc port module */
33 struct bfa_fcxp_mod_s fcxp_mod; /* fcxp module */
34 struct bfa_lps_mod_s lps_mod; /* fcxp module */
35 struct bfa_uf_mod_s uf_mod; /* unsolicited frame module */
36 struct bfa_rport_mod_s rport_mod; /* remote port module */
37 struct bfa_fcpim_mod_s fcpim_mod; /* FCP initiator module */
38 struct bfa_sgpg_mod_s sgpg_mod; /* SG page module */
39 struct bfa_port_s port; /* Physical port module */
40};
41
42/*
43 * !!! Only append to the enums defined here to avoid any versioning
44 * !!! needed between trace utility and driver version
45 */
46enum {
47 BFA_TRC_HAL_CORE = 1,
48 BFA_TRC_HAL_FCXP = 2,
49 BFA_TRC_HAL_FCPIM = 3,
50 BFA_TRC_HAL_IOCFC_CT = 4,
51 BFA_TRC_HAL_IOCFC_CB = 5,
52};
53
54
55/*
30 * Macro to define a new BFA module 56 * Macro to define a new BFA module
31 */ 57 */
32#define BFA_MODULE(__mod) \ 58#define BFA_MODULE(__mod) \
33 static void bfa_ ## __mod ## _meminfo( \ 59 static void bfa_ ## __mod ## _meminfo( \
34 struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, \ 60 struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, \
35 u32 *dm_len); \ 61 u32 *dm_len); \
36 static void bfa_ ## __mod ## _attach(struct bfa_s *bfa, \ 62 static void bfa_ ## __mod ## _attach(struct bfa_s *bfa, \
37 void *bfad, struct bfa_iocfc_cfg_s *cfg, \ 63 void *bfad, struct bfa_iocfc_cfg_s *cfg, \
38 struct bfa_meminfo_s *meminfo, \ 64 struct bfa_meminfo_s *meminfo, \
39 struct bfa_pcidev_s *pcidev); \ 65 struct bfa_pcidev_s *pcidev); \
40 static void bfa_ ## __mod ## _detach(struct bfa_s *bfa); \ 66 static void bfa_ ## __mod ## _detach(struct bfa_s *bfa); \
@@ -54,7 +80,7 @@
54 80
55#define BFA_CACHELINE_SZ (256) 81#define BFA_CACHELINE_SZ (256)
56 82
57/** 83/*
58 * Structure used to interact between different BFA sub modules 84 * Structure used to interact between different BFA sub modules
59 * 85 *
60 * Each sub module needs to implement only the entry points relevant to it (and 86 * Each sub module needs to implement only the entry points relevant to it (and
@@ -73,30 +99,23 @@ struct bfa_module_s {
73 void (*iocdisable) (struct bfa_s *bfa); 99 void (*iocdisable) (struct bfa_s *bfa);
74}; 100};
75 101
76extern struct bfa_module_s *hal_mods[];
77 102
78struct bfa_s { 103struct bfa_s {
79 void *bfad; /* BFA driver instance */ 104 void *bfad; /* BFA driver instance */
80 struct bfa_aen_s *aen; /* AEN module */
81 struct bfa_plog_s *plog; /* portlog buffer */ 105 struct bfa_plog_s *plog; /* portlog buffer */
82 struct bfa_log_mod_s *logm; /* driver logging modulen */
83 struct bfa_trc_mod_s *trcmod; /* driver tracing */ 106 struct bfa_trc_mod_s *trcmod; /* driver tracing */
84 struct bfa_ioc_s ioc; /* IOC module */ 107 struct bfa_ioc_s ioc; /* IOC module */
85 struct bfa_iocfc_s iocfc; /* IOCFC module */ 108 struct bfa_iocfc_s iocfc; /* IOCFC module */
86 struct bfa_timer_mod_s timer_mod; /* timer module */ 109 struct bfa_timer_mod_s timer_mod; /* timer module */
87 struct bfa_modules_s modules; /* BFA modules */ 110 struct bfa_modules_s modules; /* BFA modules */
88 struct list_head comp_q; /* pending completions */ 111 struct list_head comp_q; /* pending completions */
89 bfa_boolean_t rme_process; /* RME processing enabled */ 112 bfa_boolean_t rme_process; /* RME processing enabled */
90 struct list_head reqq_waitq[BFI_IOC_MAX_CQS]; 113 struct list_head reqq_waitq[BFI_IOC_MAX_CQS];
91 bfa_boolean_t fcs; /* FCS is attached to BFA */ 114 bfa_boolean_t fcs; /* FCS is attached to BFA */
92 struct bfa_msix_s msix; 115 struct bfa_msix_s msix;
93}; 116};
94 117
95extern bfa_isr_func_t bfa_isrs[BFI_MC_MAX];
96extern bfa_ioc_mbox_mcfunc_t bfa_mbox_isrs[];
97extern bfa_boolean_t bfa_auto_recover; 118extern bfa_boolean_t bfa_auto_recover;
98extern struct bfa_module_s hal_mod_flash;
99extern struct bfa_module_s hal_mod_fcdiag;
100extern struct bfa_module_s hal_mod_sgpg; 119extern struct bfa_module_s hal_mod_sgpg;
101extern struct bfa_module_s hal_mod_fcport; 120extern struct bfa_module_s hal_mod_fcport;
102extern struct bfa_module_s hal_mod_fcxp; 121extern struct bfa_module_s hal_mod_fcxp;
@@ -104,7 +123,5 @@ extern struct bfa_module_s hal_mod_lps;
104extern struct bfa_module_s hal_mod_uf; 123extern struct bfa_module_s hal_mod_uf;
105extern struct bfa_module_s hal_mod_rport; 124extern struct bfa_module_s hal_mod_rport;
106extern struct bfa_module_s hal_mod_fcpim; 125extern struct bfa_module_s hal_mod_fcpim;
107extern struct bfa_module_s hal_mod_pbind;
108
109#endif /* __BFA_PRIV_H__ */
110 126
127#endif /* __BFA_MODULES_H__ */
diff --git a/drivers/scsi/bfa/bfa_modules_priv.h b/drivers/scsi/bfa/bfa_modules_priv.h
deleted file mode 100644
index f554c2fad6a9..000000000000
--- a/drivers/scsi/bfa/bfa_modules_priv.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_MODULES_PRIV_H__
19#define __BFA_MODULES_PRIV_H__
20
21#include "bfa_uf_priv.h"
22#include "bfa_port_priv.h"
23#include "bfa_rport_priv.h"
24#include "bfa_fcxp_priv.h"
25#include "bfa_lps_priv.h"
26#include "bfa_fcpim_priv.h"
27#include <cee/bfa_cee.h>
28#include <port/bfa_port.h>
29
30
31struct bfa_modules_s {
32 struct bfa_fcport_s fcport; /* fc port module */
33 struct bfa_fcxp_mod_s fcxp_mod; /* fcxp module */
34 struct bfa_lps_mod_s lps_mod; /* fcxp module */
35 struct bfa_uf_mod_s uf_mod; /* unsolicited frame module */
36 struct bfa_rport_mod_s rport_mod; /* remote port module */
37 struct bfa_fcpim_mod_s fcpim_mod; /* FCP initiator module */
38 struct bfa_sgpg_mod_s sgpg_mod; /* SG page module */
39 struct bfa_cee_s cee; /* CEE Module */
40 struct bfa_port_s port; /* Physical port module */
41};
42
43#endif /* __BFA_MODULES_PRIV_H__ */
diff --git a/drivers/scsi/bfa/bfa_os_inc.h b/drivers/scsi/bfa/bfa_os_inc.h
deleted file mode 100644
index bd1cd3ee3022..000000000000
--- a/drivers/scsi/bfa/bfa_os_inc.h
+++ /dev/null
@@ -1,237 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * Contains declarations all OS Specific files needed for BFA layer
20 */
21
22#ifndef __BFA_OS_INC_H__
23#define __BFA_OS_INC_H__
24
25#ifndef __KERNEL__
26#include <stdint.h>
27#else
28#include <linux/types.h>
29
30#include <linux/version.h>
31#include <linux/pci.h>
32
33#include <linux/dma-mapping.h>
34#define SET_MODULE_VERSION(VER)
35
36#include <linux/idr.h>
37
38#include <linux/interrupt.h>
39#include <linux/cdev.h>
40#include <linux/fs.h>
41#include <linux/delay.h>
42#include <linux/vmalloc.h>
43
44#include <linux/workqueue.h>
45
46#include <scsi/scsi.h>
47#include <scsi/scsi_host.h>
48
49#include <scsi/scsi_tcq.h>
50#include <scsi/scsi_transport_fc.h>
51#include <scsi/scsi_transport.h>
52
53#ifdef __BIG_ENDIAN
54#define __BIGENDIAN
55#endif
56
57#define BFA_ERR KERN_ERR
58#define BFA_WARNING KERN_WARNING
59#define BFA_NOTICE KERN_NOTICE
60#define BFA_INFO KERN_INFO
61#define BFA_DEBUG KERN_DEBUG
62
63#define LOG_BFAD_INIT 0x00000001
64#define LOG_FCP_IO 0x00000002
65
66#ifdef DEBUG
67#define BFA_LOG_TRACE(bfad, level, mask, fmt, arg...) \
68 BFA_LOG(bfad, level, mask, fmt, ## arg)
69#define BFA_DEV_TRACE(bfad, level, fmt, arg...) \
70 BFA_DEV_PRINTF(bfad, level, fmt, ## arg)
71#define BFA_TRACE(level, fmt, arg...) \
72 BFA_PRINTF(level, fmt, ## arg)
73#else
74#define BFA_LOG_TRACE(bfad, level, mask, fmt, arg...)
75#define BFA_DEV_TRACE(bfad, level, fmt, arg...)
76#define BFA_TRACE(level, fmt, arg...)
77#endif
78
79#define BFA_ASSERT(p) do { \
80 if (!(p)) { \
81 printk(KERN_ERR "assert(%s) failed at %s:%d\n", \
82 #p, __FILE__, __LINE__); \
83 BUG(); \
84 } \
85} while (0)
86
87
88#define BFA_LOG(bfad, level, mask, fmt, arg...) \
89do { \
90 if (((mask) & (((struct bfad_s *)(bfad))-> \
91 cfg_data[cfg_log_mask])) || (level[1] <= '3')) \
92 dev_printk(level, &(((struct bfad_s *) \
93 (bfad))->pcidev->dev), fmt, ##arg); \
94} while (0)
95
96#ifndef BFA_DEV_PRINTF
97#define BFA_DEV_PRINTF(bfad, level, fmt, arg...) \
98 dev_printk(level, &(((struct bfad_s *) \
99 (bfad))->pcidev->dev), fmt, ##arg);
100#endif
101
102#define BFA_PRINTF(level, fmt, arg...) \
103 printk(level fmt, ##arg);
104
105int bfa_os_MWB(void *);
106
107#define bfa_os_mmiowb() mmiowb()
108
109#define bfa_swap_3b(_x) \
110 ((((_x) & 0xff) << 16) | \
111 ((_x) & 0x00ff00) | \
112 (((_x) & 0xff0000) >> 16))
113
114#define bfa_swap_8b(_x) \
115 ((((_x) & 0xff00000000000000ull) >> 56) \
116 | (((_x) & 0x00ff000000000000ull) >> 40) \
117 | (((_x) & 0x0000ff0000000000ull) >> 24) \
118 | (((_x) & 0x000000ff00000000ull) >> 8) \
119 | (((_x) & 0x00000000ff000000ull) << 8) \
120 | (((_x) & 0x0000000000ff0000ull) << 24) \
121 | (((_x) & 0x000000000000ff00ull) << 40) \
122 | (((_x) & 0x00000000000000ffull) << 56))
123
124#define bfa_os_swap32(_x) \
125 ((((_x) & 0xff) << 24) | \
126 (((_x) & 0x0000ff00) << 8) | \
127 (((_x) & 0x00ff0000) >> 8) | \
128 (((_x) & 0xff000000) >> 24))
129
130#define bfa_os_swap_sgaddr(_x) ((u64)( \
131 (((u64)(_x) & (u64)0x00000000000000ffull) << 32) | \
132 (((u64)(_x) & (u64)0x000000000000ff00ull) << 32) | \
133 (((u64)(_x) & (u64)0x0000000000ff0000ull) << 32) | \
134 (((u64)(_x) & (u64)0x00000000ff000000ull) << 32) | \
135 (((u64)(_x) & (u64)0x000000ff00000000ull) >> 32) | \
136 (((u64)(_x) & (u64)0x0000ff0000000000ull) >> 32) | \
137 (((u64)(_x) & (u64)0x00ff000000000000ull) >> 32) | \
138 (((u64)(_x) & (u64)0xff00000000000000ull) >> 32)))
139
140#ifndef __BIGENDIAN
141#define bfa_os_htons(_x) ((u16)((((_x) & 0xff00) >> 8) | \
142 (((_x) & 0x00ff) << 8)))
143
144#define bfa_os_htonl(_x) bfa_os_swap32(_x)
145#define bfa_os_htonll(_x) bfa_swap_8b(_x)
146#define bfa_os_hton3b(_x) bfa_swap_3b(_x)
147
148#define bfa_os_wtole(_x) (_x)
149#define bfa_os_sgaddr(_x) (_x)
150
151#else
152
153#define bfa_os_htons(_x) (_x)
154#define bfa_os_htonl(_x) (_x)
155#define bfa_os_hton3b(_x) (_x)
156#define bfa_os_htonll(_x) (_x)
157#define bfa_os_wtole(_x) bfa_os_swap32(_x)
158#define bfa_os_sgaddr(_x) bfa_os_swap_sgaddr(_x)
159
160#endif
161
162#define bfa_os_ntohs(_x) bfa_os_htons(_x)
163#define bfa_os_ntohl(_x) bfa_os_htonl(_x)
164#define bfa_os_ntohll(_x) bfa_os_htonll(_x)
165#define bfa_os_ntoh3b(_x) bfa_os_hton3b(_x)
166
167#define bfa_os_u32(__pa64) ((__pa64) >> 32)
168
169#define bfa_os_memset memset
170#define bfa_os_memcpy memcpy
171#define bfa_os_udelay udelay
172#define bfa_os_vsprintf vsprintf
173
174#define bfa_os_assign(__t, __s) __t = __s
175
176#define bfa_os_addr_t char __iomem *
177#define bfa_os_panic()
178
179#define bfa_os_reg_read(_raddr) readl(_raddr)
180#define bfa_os_reg_write(_raddr, _val) writel((_val), (_raddr))
181#define bfa_os_mem_read(_raddr, _off) \
182 bfa_os_swap32(readl(((_raddr) + (_off))))
183#define bfa_os_mem_write(_raddr, _off, _val) \
184 writel(bfa_os_swap32((_val)), ((_raddr) + (_off)))
185
186#define BFA_TRC_TS(_trcm) \
187 ({ \
188 struct timeval tv; \
189 \
190 do_gettimeofday(&tv); \
191 (tv.tv_sec*1000000+tv.tv_usec); \
192 })
193
194struct bfa_log_mod_s;
195void bfa_os_printf(struct bfa_log_mod_s *log_mod, u32 msg_id,
196 const char *fmt, ...);
197#endif
198
199#define boolean_t int
200
201/**
202 * For current time stamp, OS API will fill-in
203 */
204struct bfa_timeval_s {
205 u32 tv_sec; /* seconds */
206 u32 tv_usec; /* microseconds */
207};
208
209void bfa_os_gettimeofday(struct bfa_timeval_s *tv);
210
211static inline void
212wwn2str(char *wwn_str, u64 wwn)
213{
214 union {
215 u64 wwn;
216 u8 byte[8];
217 } w;
218
219 w.wwn = wwn;
220 sprintf(wwn_str, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", w.byte[0],
221 w.byte[1], w.byte[2], w.byte[3], w.byte[4], w.byte[5],
222 w.byte[6], w.byte[7]);
223}
224
225static inline void
226fcid2str(char *fcid_str, u32 fcid)
227{
228 union {
229 u32 fcid;
230 u8 byte[4];
231 } f;
232
233 f.fcid = fcid;
234 sprintf(fcid_str, "%02x:%02x:%02x", f.byte[1], f.byte[2], f.byte[3]);
235}
236
237#endif /* __BFA_OS_INC_H__ */
diff --git a/drivers/scsi/bfa/include/cs/bfa_plog.h b/drivers/scsi/bfa/bfa_plog.h
index f5bef63b5877..1c9baa68339b 100644
--- a/drivers/scsi/bfa/include/cs/bfa_plog.h
+++ b/drivers/scsi/bfa/bfa_plog.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -17,8 +17,8 @@
17#ifndef __BFA_PORTLOG_H__ 17#ifndef __BFA_PORTLOG_H__
18#define __BFA_PORTLOG_H__ 18#define __BFA_PORTLOG_H__
19 19
20#include "protocol/fc.h" 20#include "bfa_fc.h"
21#include <defs/bfa_defs_types.h> 21#include "bfa_defs.h"
22 22
23#define BFA_PL_NLOG_ENTS 256 23#define BFA_PL_NLOG_ENTS 256
24#define BFA_PL_LOG_REC_INCR(_x) ((_x)++, (_x) %= BFA_PL_NLOG_ENTS) 24#define BFA_PL_LOG_REC_INCR(_x) ((_x)++, (_x) %= BFA_PL_NLOG_ENTS)
@@ -27,38 +27,30 @@
27#define BFA_PL_INT_LOG_SZ 8 /* number of integers in the integer log */ 27#define BFA_PL_INT_LOG_SZ 8 /* number of integers in the integer log */
28 28
29enum bfa_plog_log_type { 29enum bfa_plog_log_type {
30 BFA_PL_LOG_TYPE_INVALID = 0, 30 BFA_PL_LOG_TYPE_INVALID = 0,
31 BFA_PL_LOG_TYPE_INT = 1, 31 BFA_PL_LOG_TYPE_INT = 1,
32 BFA_PL_LOG_TYPE_STRING = 2, 32 BFA_PL_LOG_TYPE_STRING = 2,
33}; 33};
34 34
35/* 35/*
36 * the (fixed size) record format for each entry in the portlog 36 * the (fixed size) record format for each entry in the portlog
37 */ 37 */
38struct bfa_plog_rec_s { 38struct bfa_plog_rec_s {
39 u32 tv; /* Filled by the portlog driver when the * 39 u64 tv; /* timestamp */
40 * entry is added to the circular log. */ 40 u8 port; /* Source port that logged this entry */
41 u8 port; /* Source port that logged this entry. CM 41 u8 mid; /* module id */
42 * entities will use 0xFF */ 42 u8 eid; /* indicates Rx, Tx, IOCTL, etc. bfa_plog_eid */
43 u8 mid; /* Integer value to be used by all entities * 43 u8 log_type; /* string/integer log, bfa_plog_log_type_t */
44 * while logging. The module id to string * 44 u8 log_num_ints;
45 * conversion will be done by BFAL. See
46 * enum bfa_plog_mid */
47 u8 eid; /* indicates Rx, Tx, IOCTL, etc. See
48 * enum bfa_plog_eid */
49 u8 log_type; /* indicates string log or integer log.
50 * see bfa_plog_log_type_t */
51 u8 log_num_ints;
52 /* 45 /*
53 * interpreted only if log_type is INT_LOG. indicates number of 46 * interpreted only if log_type is INT_LOG. indicates number of
54 * integers in the int_log[] (0-PL_INT_LOG_SZ). 47 * integers in the int_log[] (0-PL_INT_LOG_SZ).
55 */ 48 */
56 u8 rsvd; 49 u8 rsvd;
57 u16 misc; /* can be used to indicate fc frame length, 50 u16 misc; /* can be used to indicate fc frame length */
58 *etc.. */
59 union { 51 union {
60 char string_log[BFA_PL_STRING_LOG_SZ]; 52 char string_log[BFA_PL_STRING_LOG_SZ];
61 u32 int_log[BFA_PL_INT_LOG_SZ]; 53 u32 int_log[BFA_PL_INT_LOG_SZ];
62 } log_entry; 54 } log_entry;
63 55
64}; 56};
@@ -73,20 +65,20 @@ struct bfa_plog_rec_s {
73 * - Do not remove any entry or rearrange the order. 65 * - Do not remove any entry or rearrange the order.
74 */ 66 */
75enum bfa_plog_mid { 67enum bfa_plog_mid {
76 BFA_PL_MID_INVALID = 0, 68 BFA_PL_MID_INVALID = 0,
77 BFA_PL_MID_DEBUG = 1, 69 BFA_PL_MID_DEBUG = 1,
78 BFA_PL_MID_DRVR = 2, 70 BFA_PL_MID_DRVR = 2,
79 BFA_PL_MID_HAL = 3, 71 BFA_PL_MID_HAL = 3,
80 BFA_PL_MID_HAL_FCXP = 4, 72 BFA_PL_MID_HAL_FCXP = 4,
81 BFA_PL_MID_HAL_UF = 5, 73 BFA_PL_MID_HAL_UF = 5,
82 BFA_PL_MID_FCS = 6, 74 BFA_PL_MID_FCS = 6,
83 BFA_PL_MID_LPS = 7, 75 BFA_PL_MID_LPS = 7,
84 BFA_PL_MID_MAX = 8 76 BFA_PL_MID_MAX = 8
85}; 77};
86 78
87#define BFA_PL_MID_STRLEN 8 79#define BFA_PL_MID_STRLEN 8
88struct bfa_plog_mid_strings_s { 80struct bfa_plog_mid_strings_s {
89 char m_str[BFA_PL_MID_STRLEN]; 81 char m_str[BFA_PL_MID_STRLEN];
90}; 82};
91 83
92/* 84/*
@@ -99,36 +91,37 @@ struct bfa_plog_mid_strings_s {
99 * - Do not remove any entry or rearrange the order. 91 * - Do not remove any entry or rearrange the order.
100 */ 92 */
101enum bfa_plog_eid { 93enum bfa_plog_eid {
102 BFA_PL_EID_INVALID = 0, 94 BFA_PL_EID_INVALID = 0,
103 BFA_PL_EID_IOC_DISABLE = 1, 95 BFA_PL_EID_IOC_DISABLE = 1,
104 BFA_PL_EID_IOC_ENABLE = 2, 96 BFA_PL_EID_IOC_ENABLE = 2,
105 BFA_PL_EID_PORT_DISABLE = 3, 97 BFA_PL_EID_PORT_DISABLE = 3,
106 BFA_PL_EID_PORT_ENABLE = 4, 98 BFA_PL_EID_PORT_ENABLE = 4,
107 BFA_PL_EID_PORT_ST_CHANGE = 5, 99 BFA_PL_EID_PORT_ST_CHANGE = 5,
108 BFA_PL_EID_TX = 6, 100 BFA_PL_EID_TX = 6,
109 BFA_PL_EID_TX_ACK1 = 7, 101 BFA_PL_EID_TX_ACK1 = 7,
110 BFA_PL_EID_TX_RJT = 8, 102 BFA_PL_EID_TX_RJT = 8,
111 BFA_PL_EID_TX_BSY = 9, 103 BFA_PL_EID_TX_BSY = 9,
112 BFA_PL_EID_RX = 10, 104 BFA_PL_EID_RX = 10,
113 BFA_PL_EID_RX_ACK1 = 11, 105 BFA_PL_EID_RX_ACK1 = 11,
114 BFA_PL_EID_RX_RJT = 12, 106 BFA_PL_EID_RX_RJT = 12,
115 BFA_PL_EID_RX_BSY = 13, 107 BFA_PL_EID_RX_BSY = 13,
116 BFA_PL_EID_CT_IN = 14, 108 BFA_PL_EID_CT_IN = 14,
117 BFA_PL_EID_CT_OUT = 15, 109 BFA_PL_EID_CT_OUT = 15,
118 BFA_PL_EID_DRIVER_START = 16, 110 BFA_PL_EID_DRIVER_START = 16,
119 BFA_PL_EID_RSCN = 17, 111 BFA_PL_EID_RSCN = 17,
120 BFA_PL_EID_DEBUG = 18, 112 BFA_PL_EID_DEBUG = 18,
121 BFA_PL_EID_MISC = 19, 113 BFA_PL_EID_MISC = 19,
122 BFA_PL_EID_FIP_FCF_DISC = 20, 114 BFA_PL_EID_FIP_FCF_DISC = 20,
123 BFA_PL_EID_FIP_FCF_CVL = 21, 115 BFA_PL_EID_FIP_FCF_CVL = 21,
124 BFA_PL_EID_LOGIN = 22, 116 BFA_PL_EID_LOGIN = 22,
125 BFA_PL_EID_LOGO = 23, 117 BFA_PL_EID_LOGO = 23,
126 BFA_PL_EID_MAX = 24 118 BFA_PL_EID_TRUNK_SCN = 24,
119 BFA_PL_EID_MAX
127}; 120};
128 121
129#define BFA_PL_ENAME_STRLEN 8 122#define BFA_PL_ENAME_STRLEN 8
130struct bfa_plog_eid_strings_s { 123struct bfa_plog_eid_strings_s {
131 char e_str[BFA_PL_ENAME_STRLEN]; 124 char e_str[BFA_PL_ENAME_STRLEN];
132}; 125};
133 126
134#define BFA_PL_SIG_LEN 8 127#define BFA_PL_SIG_LEN 8
@@ -138,12 +131,12 @@ struct bfa_plog_eid_strings_s {
138 * per port circular log buffer 131 * per port circular log buffer
139 */ 132 */
140struct bfa_plog_s { 133struct bfa_plog_s {
141 char plog_sig[BFA_PL_SIG_LEN]; /* Start signature */ 134 char plog_sig[BFA_PL_SIG_LEN]; /* Start signature */
142 u8 plog_enabled; 135 u8 plog_enabled;
143 u8 rsvd[7]; 136 u8 rsvd[7];
144 u32 ticks; 137 u32 ticks;
145 u16 head; 138 u16 head;
146 u16 tail; 139 u16 tail;
147 struct bfa_plog_rec_s plog_recs[BFA_PL_NLOG_ENTS]; 140 struct bfa_plog_rec_s plog_recs[BFA_PL_NLOG_ENTS];
148}; 141};
149 142
@@ -154,14 +147,9 @@ void bfa_plog_intarr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
154 enum bfa_plog_eid event, u16 misc, 147 enum bfa_plog_eid event, u16 misc,
155 u32 *intarr, u32 num_ints); 148 u32 *intarr, u32 num_ints);
156void bfa_plog_fchdr(struct bfa_plog_s *plog, enum bfa_plog_mid mid, 149void bfa_plog_fchdr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
157 enum bfa_plog_eid event, u16 misc, 150 enum bfa_plog_eid event, u16 misc, struct fchs_s *fchdr);
158 struct fchs_s *fchdr);
159void bfa_plog_fchdr_and_pl(struct bfa_plog_s *plog, enum bfa_plog_mid mid, 151void bfa_plog_fchdr_and_pl(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
160 enum bfa_plog_eid event, u16 misc, 152 enum bfa_plog_eid event, u16 misc,
161 struct fchs_s *fchdr, u32 pld_w0); 153 struct fchs_s *fchdr, u32 pld_w0);
162void bfa_plog_clear(struct bfa_plog_s *plog);
163void bfa_plog_enable(struct bfa_plog_s *plog);
164void bfa_plog_disable(struct bfa_plog_s *plog);
165bfa_boolean_t bfa_plog_get_setting(struct bfa_plog_s *plog);
166 154
167#endif /* __BFA_PORTLOG_H__ */ 155#endif /* __BFA_PORTLOG_H__ */
diff --git a/drivers/scsi/bfa/bfa_port.c b/drivers/scsi/bfa/bfa_port.c
index c7e69f1e56e3..3f8e9d6066ec 100644
--- a/drivers/scsi/bfa/bfa_port.c
+++ b/drivers/scsi/bfa/bfa_port.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,48 +15,39 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18#include <defs/bfa_defs_port.h> 18#include "bfad_drv.h"
19#include <cs/bfa_trc.h> 19#include "bfa_defs_svc.h"
20#include <cs/bfa_log.h> 20#include "bfa_port.h"
21#include <cs/bfa_debug.h> 21#include "bfi.h"
22#include <port/bfa_port.h> 22#include "bfa_ioc.h"
23#include <bfi/bfi.h> 23
24#include <bfi/bfi_port.h>
25#include <bfa_ioc.h>
26#include <cna/bfa_cna_trcmod.h>
27 24
28BFA_TRC_FILE(CNA, PORT); 25BFA_TRC_FILE(CNA, PORT);
29 26
30#define bfa_ioc_portid(__ioc) ((__ioc)->port_id) 27#define bfa_ioc_portid(__ioc) ((__ioc)->port_id)
31#define bfa_lpuid(__arg) bfa_ioc_portid(&(__arg)->ioc)
32 28
33static void 29static void
34bfa_port_stats_swap(struct bfa_port_s *port, union bfa_pport_stats_u *stats) 30bfa_port_stats_swap(struct bfa_port_s *port, union bfa_port_stats_u *stats)
35{ 31{
36 u32 *dip = (u32 *) stats; 32 u32 *dip = (u32 *) stats;
37 u32 t0, t1; 33 __be32 t0, t1;
38 int i; 34 int i;
39 35
40 for (i = 0; i < sizeof(union bfa_pport_stats_u) / sizeof(u32); 36 for (i = 0; i < sizeof(union bfa_port_stats_u)/sizeof(u32);
41 i += 2) { 37 i += 2) {
42 t0 = dip[i]; 38 t0 = dip[i];
43 t1 = dip[i + 1]; 39 t1 = dip[i + 1];
44#ifdef __BIGENDIAN 40#ifdef __BIG_ENDIAN
45 dip[i] = bfa_os_ntohl(t0); 41 dip[i] = be32_to_cpu(t0);
46 dip[i + 1] = bfa_os_ntohl(t1); 42 dip[i + 1] = be32_to_cpu(t1);
47#else 43#else
48 dip[i] = bfa_os_ntohl(t1); 44 dip[i] = be32_to_cpu(t1);
49 dip[i + 1] = bfa_os_ntohl(t0); 45 dip[i + 1] = be32_to_cpu(t0);
50#endif 46#endif
51 } 47 }
52
53 /** todo
54 * QoS stats r also swapped as 64bit; that structure also
55 * has to use 64 bit counters
56 */
57} 48}
58 49
59/** 50/*
60 * bfa_port_enable_isr() 51 * bfa_port_enable_isr()
61 * 52 *
62 * 53 *
@@ -68,10 +59,12 @@ bfa_port_stats_swap(struct bfa_port_s *port, union bfa_pport_stats_u *stats)
68static void 59static void
69bfa_port_enable_isr(struct bfa_port_s *port, bfa_status_t status) 60bfa_port_enable_isr(struct bfa_port_s *port, bfa_status_t status)
70{ 61{
71 bfa_assert(0); 62 bfa_trc(port, status);
63 port->endis_pending = BFA_FALSE;
64 port->endis_cbfn(port->endis_cbarg, status);
72} 65}
73 66
74/** 67/*
75 * bfa_port_disable_isr() 68 * bfa_port_disable_isr()
76 * 69 *
77 * 70 *
@@ -83,10 +76,12 @@ bfa_port_enable_isr(struct bfa_port_s *port, bfa_status_t status)
83static void 76static void
84bfa_port_disable_isr(struct bfa_port_s *port, bfa_status_t status) 77bfa_port_disable_isr(struct bfa_port_s *port, bfa_status_t status)
85{ 78{
86 bfa_assert(0); 79 bfa_trc(port, status);
80 port->endis_pending = BFA_FALSE;
81 port->endis_cbfn(port->endis_cbarg, status);
87} 82}
88 83
89/** 84/*
90 * bfa_port_get_stats_isr() 85 * bfa_port_get_stats_isr()
91 * 86 *
92 * 87 *
@@ -102,13 +97,13 @@ bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status)
102 port->stats_busy = BFA_FALSE; 97 port->stats_busy = BFA_FALSE;
103 98
104 if (status == BFA_STATUS_OK) { 99 if (status == BFA_STATUS_OK) {
105 struct bfa_timeval_s tv; 100 struct timeval tv;
106 101
107 memcpy(port->stats, port->stats_dma.kva, 102 memcpy(port->stats, port->stats_dma.kva,
108 sizeof(union bfa_pport_stats_u)); 103 sizeof(union bfa_port_stats_u));
109 bfa_port_stats_swap(port, port->stats); 104 bfa_port_stats_swap(port, port->stats);
110 105
111 bfa_os_gettimeofday(&tv); 106 do_gettimeofday(&tv);
112 port->stats->fc.secs_reset = tv.tv_sec - port->stats_reset_time; 107 port->stats->fc.secs_reset = tv.tv_sec - port->stats_reset_time;
113 } 108 }
114 109
@@ -118,7 +113,7 @@ bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status)
118 } 113 }
119} 114}
120 115
121/** 116/*
122 * bfa_port_clear_stats_isr() 117 * bfa_port_clear_stats_isr()
123 * 118 *
124 * 119 *
@@ -130,15 +125,15 @@ bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status)
130static void 125static void
131bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status) 126bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status)
132{ 127{
133 struct bfa_timeval_s tv; 128 struct timeval tv;
134 129
135 port->stats_status = status; 130 port->stats_status = status;
136 port->stats_busy = BFA_FALSE; 131 port->stats_busy = BFA_FALSE;
137 132
138 /** 133 /*
139 * re-initialize time stamp for stats reset 134 * re-initialize time stamp for stats reset
140 */ 135 */
141 bfa_os_gettimeofday(&tv); 136 do_gettimeofday(&tv);
142 port->stats_reset_time = tv.tv_sec; 137 port->stats_reset_time = tv.tv_sec;
143 138
144 if (port->stats_cbfn) { 139 if (port->stats_cbfn) {
@@ -147,7 +142,7 @@ bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status)
147 } 142 }
148} 143}
149 144
150/** 145/*
151 * bfa_port_isr() 146 * bfa_port_isr()
152 * 147 *
153 * 148 *
@@ -158,10 +153,10 @@ bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status)
158static void 153static void
159bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m) 154bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m)
160{ 155{
161 struct bfa_port_s *port = (struct bfa_port_s *)cbarg; 156 struct bfa_port_s *port = (struct bfa_port_s *) cbarg;
162 union bfi_port_i2h_msg_u *i2hmsg; 157 union bfi_port_i2h_msg_u *i2hmsg;
163 158
164 i2hmsg = (union bfi_port_i2h_msg_u *)m; 159 i2hmsg = (union bfi_port_i2h_msg_u *) m;
165 bfa_trc(port, m->mh.msg_id); 160 bfa_trc(port, m->mh.msg_id);
166 161
167 switch (m->mh.msg_id) { 162 switch (m->mh.msg_id) {
@@ -178,9 +173,7 @@ bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m)
178 break; 173 break;
179 174
180 case BFI_PORT_I2H_GET_STATS_RSP: 175 case BFI_PORT_I2H_GET_STATS_RSP:
181 /* 176 /* Stats busy flag is still set? (may be cmd timed out) */
182 * Stats busy flag is still set? (may be cmd timed out)
183 */
184 if (port->stats_busy == BFA_FALSE) 177 if (port->stats_busy == BFA_FALSE)
185 break; 178 break;
186 bfa_port_get_stats_isr(port, i2hmsg->getstats_rsp.status); 179 bfa_port_get_stats_isr(port, i2hmsg->getstats_rsp.status);
@@ -193,11 +186,11 @@ bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m)
193 break; 186 break;
194 187
195 default: 188 default:
196 bfa_assert(0); 189 WARN_ON(1);
197 } 190 }
198} 191}
199 192
200/** 193/*
201 * bfa_port_meminfo() 194 * bfa_port_meminfo()
202 * 195 *
203 * 196 *
@@ -208,16 +201,16 @@ bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m)
208u32 201u32
209bfa_port_meminfo(void) 202bfa_port_meminfo(void)
210{ 203{
211 return BFA_ROUNDUP(sizeof(union bfa_pport_stats_u), BFA_DMA_ALIGN_SZ); 204 return BFA_ROUNDUP(sizeof(union bfa_port_stats_u), BFA_DMA_ALIGN_SZ);
212} 205}
213 206
214/** 207/*
215 * bfa_port_mem_claim() 208 * bfa_port_mem_claim()
216 * 209 *
217 * 210 *
218 * @param[in] port Port module pointer 211 * @param[in] port Port module pointer
219 * dma_kva Kernel Virtual Address of Port DMA Memory 212 * dma_kva Kernel Virtual Address of Port DMA Memory
220 * dma_pa Physical Address of Port DMA Memory 213 * dma_pa Physical Address of Port DMA Memory
221 * 214 *
222 * @return void 215 * @return void
223 */ 216 */
@@ -225,10 +218,10 @@ void
225bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva, u64 dma_pa) 218bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva, u64 dma_pa)
226{ 219{
227 port->stats_dma.kva = dma_kva; 220 port->stats_dma.kva = dma_kva;
228 port->stats_dma.pa = dma_pa; 221 port->stats_dma.pa = dma_pa;
229} 222}
230 223
231/** 224/*
232 * bfa_port_enable() 225 * bfa_port_enable()
233 * 226 *
234 * Send the Port enable request to the f/w 227 * Send the Port enable request to the f/w
@@ -239,12 +232,14 @@ bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva, u64 dma_pa)
239 */ 232 */
240bfa_status_t 233bfa_status_t
241bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn, 234bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
242 void *cbarg) 235 void *cbarg)
243{ 236{
244 struct bfi_port_generic_req_s *m; 237 struct bfi_port_generic_req_s *m;
245 238
246 /** todo Not implemented */ 239 if (bfa_ioc_is_disabled(port->ioc)) {
247 bfa_assert(0); 240 bfa_trc(port, BFA_STATUS_IOC_DISABLED);
241 return BFA_STATUS_IOC_DISABLED;
242 }
248 243
249 if (!bfa_ioc_is_operational(port->ioc)) { 244 if (!bfa_ioc_is_operational(port->ioc)) {
250 bfa_trc(port, BFA_STATUS_IOC_FAILURE); 245 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
@@ -256,11 +251,11 @@ bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
256 return BFA_STATUS_DEVBUSY; 251 return BFA_STATUS_DEVBUSY;
257 } 252 }
258 253
259 m = (struct bfi_port_generic_req_s *)port->endis_mb.msg; 254 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
260 255
261 port->msgtag++; 256 port->msgtag++;
262 port->endis_cbfn = cbfn; 257 port->endis_cbfn = cbfn;
263 port->endis_cbarg = cbarg; 258 port->endis_cbarg = cbarg;
264 port->endis_pending = BFA_TRUE; 259 port->endis_pending = BFA_TRUE;
265 260
266 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_ENABLE_REQ, 261 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_ENABLE_REQ,
@@ -270,7 +265,7 @@ bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
270 return BFA_STATUS_OK; 265 return BFA_STATUS_OK;
271} 266}
272 267
273/** 268/*
274 * bfa_port_disable() 269 * bfa_port_disable()
275 * 270 *
276 * Send the Port disable request to the f/w 271 * Send the Port disable request to the f/w
@@ -281,12 +276,14 @@ bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
281 */ 276 */
282bfa_status_t 277bfa_status_t
283bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn, 278bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
284 void *cbarg) 279 void *cbarg)
285{ 280{
286 struct bfi_port_generic_req_s *m; 281 struct bfi_port_generic_req_s *m;
287 282
288 /** todo Not implemented */ 283 if (bfa_ioc_is_disabled(port->ioc)) {
289 bfa_assert(0); 284 bfa_trc(port, BFA_STATUS_IOC_DISABLED);
285 return BFA_STATUS_IOC_DISABLED;
286 }
290 287
291 if (!bfa_ioc_is_operational(port->ioc)) { 288 if (!bfa_ioc_is_operational(port->ioc)) {
292 bfa_trc(port, BFA_STATUS_IOC_FAILURE); 289 bfa_trc(port, BFA_STATUS_IOC_FAILURE);
@@ -298,11 +295,11 @@ bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
298 return BFA_STATUS_DEVBUSY; 295 return BFA_STATUS_DEVBUSY;
299 } 296 }
300 297
301 m = (struct bfi_port_generic_req_s *)port->endis_mb.msg; 298 m = (struct bfi_port_generic_req_s *) port->endis_mb.msg;
302 299
303 port->msgtag++; 300 port->msgtag++;
304 port->endis_cbfn = cbfn; 301 port->endis_cbfn = cbfn;
305 port->endis_cbarg = cbarg; 302 port->endis_cbarg = cbarg;
306 port->endis_pending = BFA_TRUE; 303 port->endis_pending = BFA_TRUE;
307 304
308 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_DISABLE_REQ, 305 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_DISABLE_REQ,
@@ -312,7 +309,7 @@ bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
312 return BFA_STATUS_OK; 309 return BFA_STATUS_OK;
313} 310}
314 311
315/** 312/*
316 * bfa_port_get_stats() 313 * bfa_port_get_stats()
317 * 314 *
318 * Send the request to the f/w to fetch Port statistics. 315 * Send the request to the f/w to fetch Port statistics.
@@ -322,8 +319,8 @@ bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn,
322 * @return Status 319 * @return Status
323 */ 320 */
324bfa_status_t 321bfa_status_t
325bfa_port_get_stats(struct bfa_port_s *port, union bfa_pport_stats_u *stats, 322bfa_port_get_stats(struct bfa_port_s *port, union bfa_port_stats_u *stats,
326 bfa_port_stats_cbfn_t cbfn, void *cbarg) 323 bfa_port_stats_cbfn_t cbfn, void *cbarg)
327{ 324{
328 struct bfi_port_get_stats_req_s *m; 325 struct bfi_port_get_stats_req_s *m;
329 326
@@ -337,12 +334,12 @@ bfa_port_get_stats(struct bfa_port_s *port, union bfa_pport_stats_u *stats,
337 return BFA_STATUS_DEVBUSY; 334 return BFA_STATUS_DEVBUSY;
338 } 335 }
339 336
340 m = (struct bfi_port_get_stats_req_s *)port->stats_mb.msg; 337 m = (struct bfi_port_get_stats_req_s *) port->stats_mb.msg;
341 338
342 port->stats = stats; 339 port->stats = stats;
343 port->stats_cbfn = cbfn; 340 port->stats_cbfn = cbfn;
344 port->stats_cbarg = cbarg; 341 port->stats_cbarg = cbarg;
345 port->stats_busy = BFA_TRUE; 342 port->stats_busy = BFA_TRUE;
346 bfa_dma_be_addr_set(m->dma_addr, port->stats_dma.pa); 343 bfa_dma_be_addr_set(m->dma_addr, port->stats_dma.pa);
347 344
348 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_GET_STATS_REQ, 345 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_GET_STATS_REQ,
@@ -352,7 +349,7 @@ bfa_port_get_stats(struct bfa_port_s *port, union bfa_pport_stats_u *stats,
352 return BFA_STATUS_OK; 349 return BFA_STATUS_OK;
353} 350}
354 351
355/** 352/*
356 * bfa_port_clear_stats() 353 * bfa_port_clear_stats()
357 * 354 *
358 * 355 *
@@ -362,7 +359,7 @@ bfa_port_get_stats(struct bfa_port_s *port, union bfa_pport_stats_u *stats,
362 */ 359 */
363bfa_status_t 360bfa_status_t
364bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn, 361bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn,
365 void *cbarg) 362 void *cbarg)
366{ 363{
367 struct bfi_port_generic_req_s *m; 364 struct bfi_port_generic_req_s *m;
368 365
@@ -376,11 +373,11 @@ bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn,
376 return BFA_STATUS_DEVBUSY; 373 return BFA_STATUS_DEVBUSY;
377 } 374 }
378 375
379 m = (struct bfi_port_generic_req_s *)port->stats_mb.msg; 376 m = (struct bfi_port_generic_req_s *) port->stats_mb.msg;
380 377
381 port->stats_cbfn = cbfn; 378 port->stats_cbfn = cbfn;
382 port->stats_cbarg = cbarg; 379 port->stats_cbarg = cbarg;
383 port->stats_busy = BFA_TRUE; 380 port->stats_busy = BFA_TRUE;
384 381
385 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_CLEAR_STATS_REQ, 382 bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_CLEAR_STATS_REQ,
386 bfa_ioc_portid(port->ioc)); 383 bfa_ioc_portid(port->ioc));
@@ -389,7 +386,7 @@ bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn,
389 return BFA_STATUS_OK; 386 return BFA_STATUS_OK;
390} 387}
391 388
392/** 389/*
393 * bfa_port_hbfail() 390 * bfa_port_hbfail()
394 * 391 *
395 * 392 *
@@ -400,11 +397,9 @@ bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn,
400void 397void
401bfa_port_hbfail(void *arg) 398bfa_port_hbfail(void *arg)
402{ 399{
403 struct bfa_port_s *port = (struct bfa_port_s *)arg; 400 struct bfa_port_s *port = (struct bfa_port_s *) arg;
404 401
405 /* 402 /* Fail any pending get_stats/clear_stats requests */
406 * Fail any pending get_stats/clear_stats requests
407 */
408 if (port->stats_busy) { 403 if (port->stats_busy) {
409 if (port->stats_cbfn) 404 if (port->stats_cbfn)
410 port->stats_cbfn(port->stats_cbarg, BFA_STATUS_FAILED); 405 port->stats_cbfn(port->stats_cbarg, BFA_STATUS_FAILED);
@@ -412,9 +407,7 @@ bfa_port_hbfail(void *arg)
412 port->stats_busy = BFA_FALSE; 407 port->stats_busy = BFA_FALSE;
413 } 408 }
414 409
415 /* 410 /* Clear any enable/disable is pending */
416 * Clear any enable/disable is pending
417 */
418 if (port->endis_pending) { 411 if (port->endis_pending) {
419 if (port->endis_cbfn) 412 if (port->endis_cbfn)
420 port->endis_cbfn(port->endis_cbarg, BFA_STATUS_FAILED); 413 port->endis_cbfn(port->endis_cbarg, BFA_STATUS_FAILED);
@@ -423,7 +416,7 @@ bfa_port_hbfail(void *arg)
423 } 416 }
424} 417}
425 418
426/** 419/*
427 * bfa_port_attach() 420 * bfa_port_attach()
428 * 421 *
429 * 422 *
@@ -433,22 +426,20 @@ bfa_port_hbfail(void *arg)
433 * The device driver specific mbox ISR functions have 426 * The device driver specific mbox ISR functions have
434 * this pointer as one of the parameters. 427 * this pointer as one of the parameters.
435 * trcmod - 428 * trcmod -
436 * logmod -
437 * 429 *
438 * @return void 430 * @return void
439 */ 431 */
440void 432void
441bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc, void *dev, 433bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
442 struct bfa_trc_mod_s *trcmod, struct bfa_log_mod_s *logmod) 434 void *dev, struct bfa_trc_mod_s *trcmod)
443{ 435{
444 struct bfa_timeval_s tv; 436 struct timeval tv;
445 437
446 bfa_assert(port); 438 WARN_ON(!port);
447 439
448 port->dev = dev; 440 port->dev = dev;
449 port->ioc = ioc; 441 port->ioc = ioc;
450 port->trcmod = trcmod; 442 port->trcmod = trcmod;
451 port->logmod = logmod;
452 443
453 port->stats_busy = BFA_FALSE; 444 port->stats_busy = BFA_FALSE;
454 port->endis_pending = BFA_FALSE; 445 port->endis_pending = BFA_FALSE;
@@ -457,27 +448,13 @@ bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc, void *dev,
457 448
458 bfa_ioc_mbox_regisr(port->ioc, BFI_MC_PORT, bfa_port_isr, port); 449 bfa_ioc_mbox_regisr(port->ioc, BFI_MC_PORT, bfa_port_isr, port);
459 bfa_ioc_hbfail_init(&port->hbfail, bfa_port_hbfail, port); 450 bfa_ioc_hbfail_init(&port->hbfail, bfa_port_hbfail, port);
460 bfa_ioc_hbfail_register(port->ioc, &port->hbfail); 451 list_add_tail(&port->hbfail.qe, &port->ioc->hb_notify_q);
461 452
462 /** 453 /*
463 * initialize time stamp for stats reset 454 * initialize time stamp for stats reset
464 */ 455 */
465 bfa_os_gettimeofday(&tv); 456 do_gettimeofday(&tv);
466 port->stats_reset_time = tv.tv_sec; 457 port->stats_reset_time = tv.tv_sec;
467 458
468 bfa_trc(port, 0); 459 bfa_trc(port, 0);
469} 460}
470
471/**
472 * bfa_port_detach()
473 *
474 *
475 * @param[in] port - Pointer to the Port module data structure
476 *
477 * @return void
478 */
479void
480bfa_port_detach(struct bfa_port_s *port)
481{
482 bfa_trc(port, 0);
483}
diff --git a/drivers/scsi/bfa/bfa_port.h b/drivers/scsi/bfa/bfa_port.h
new file mode 100644
index 000000000000..c4ee9db6b470
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_port.h
@@ -0,0 +1,65 @@
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_PORT_H__
19#define __BFA_PORT_H__
20
21#include "bfa_defs_svc.h"
22#include "bfa_ioc.h"
23#include "bfa_cs.h"
24
25typedef void (*bfa_port_stats_cbfn_t) (void *dev, bfa_status_t status);
26typedef void (*bfa_port_endis_cbfn_t) (void *dev, bfa_status_t status);
27
28struct bfa_port_s {
29 void *dev;
30 struct bfa_ioc_s *ioc;
31 struct bfa_trc_mod_s *trcmod;
32 u32 msgtag;
33 bfa_boolean_t stats_busy;
34 struct bfa_mbox_cmd_s stats_mb;
35 bfa_port_stats_cbfn_t stats_cbfn;
36 void *stats_cbarg;
37 bfa_status_t stats_status;
38 u32 stats_reset_time;
39 union bfa_port_stats_u *stats;
40 struct bfa_dma_s stats_dma;
41 bfa_boolean_t endis_pending;
42 struct bfa_mbox_cmd_s endis_mb;
43 bfa_port_endis_cbfn_t endis_cbfn;
44 void *endis_cbarg;
45 bfa_status_t endis_status;
46 struct bfa_ioc_hbfail_notify_s hbfail;
47};
48
49void bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
50 void *dev, struct bfa_trc_mod_s *trcmod);
51void bfa_port_hbfail(void *arg);
52
53bfa_status_t bfa_port_get_stats(struct bfa_port_s *port,
54 union bfa_port_stats_u *stats,
55 bfa_port_stats_cbfn_t cbfn, void *cbarg);
56bfa_status_t bfa_port_clear_stats(struct bfa_port_s *port,
57 bfa_port_stats_cbfn_t cbfn, void *cbarg);
58bfa_status_t bfa_port_enable(struct bfa_port_s *port,
59 bfa_port_endis_cbfn_t cbfn, void *cbarg);
60bfa_status_t bfa_port_disable(struct bfa_port_s *port,
61 bfa_port_endis_cbfn_t cbfn, void *cbarg);
62u32 bfa_port_meminfo(void);
63void bfa_port_mem_claim(struct bfa_port_s *port,
64 u8 *dma_kva, u64 dma_pa);
65#endif /* __BFA_PORT_H__ */
diff --git a/drivers/scsi/bfa/bfa_port_priv.h b/drivers/scsi/bfa/bfa_port_priv.h
deleted file mode 100644
index c9ebe0426fa6..000000000000
--- a/drivers/scsi/bfa/bfa_port_priv.h
+++ /dev/null
@@ -1,94 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_PORT_PRIV_H__
19#define __BFA_PORT_PRIV_H__
20
21#include <defs/bfa_defs_pport.h>
22#include <bfi/bfi_pport.h>
23#include "bfa_intr_priv.h"
24
25/**
26 * Link notification data structure
27 */
28struct bfa_fcport_ln_s {
29 struct bfa_fcport_s *fcport;
30 bfa_sm_t sm;
31 struct bfa_cb_qe_s ln_qe; /* BFA callback queue elem for ln */
32 enum bfa_pport_linkstate ln_event; /* ln event for callback */
33};
34
35/**
36 * BFA FC port data structure
37 */
38struct bfa_fcport_s {
39 struct bfa_s *bfa; /* parent BFA instance */
40 bfa_sm_t sm; /* port state machine */
41 wwn_t nwwn; /* node wwn of physical port */
42 wwn_t pwwn; /* port wwn of physical oprt */
43 enum bfa_pport_speed speed_sup;
44 /* supported speeds */
45 enum bfa_pport_speed speed; /* current speed */
46 enum bfa_pport_topology topology; /* current topology */
47 u8 myalpa; /* my ALPA in LOOP topology */
48 u8 rsvd[3];
49 u32 mypid:24;
50 u32 rsvd_b:8;
51 struct bfa_pport_cfg_s cfg; /* current port configuration */
52 struct bfa_qos_attr_s qos_attr; /* QoS Attributes */
53 struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */
54 struct bfa_reqq_wait_s reqq_wait;
55 /* to wait for room in reqq */
56 struct bfa_reqq_wait_s svcreq_wait;
57 /* to wait for room in reqq */
58 struct bfa_reqq_wait_s stats_reqq_wait;
59 /* to wait for room in reqq (stats) */
60 void *event_cbarg;
61 void (*event_cbfn) (void *cbarg,
62 bfa_pport_event_t event);
63 union {
64 union bfi_fcport_i2h_msg_u i2hmsg;
65 } event_arg;
66 void *bfad; /* BFA driver handle */
67 struct bfa_fcport_ln_s ln; /* Link Notification */
68 struct bfa_cb_qe_s hcb_qe; /* BFA callback queue elem */
69 struct bfa_timer_s timer; /* timer */
70 u32 msgtag; /* fimrware msg tag for reply */
71 u8 *stats_kva;
72 u64 stats_pa;
73 union bfa_fcport_stats_u *stats;
74 union bfa_fcport_stats_u *stats_ret; /* driver stats location */
75 bfa_status_t stats_status; /* stats/statsclr status */
76 bfa_boolean_t stats_busy; /* outstanding stats/statsclr */
77 bfa_boolean_t stats_qfull;
78 u32 stats_reset_time; /* stats reset time stamp */
79 bfa_cb_pport_t stats_cbfn; /* driver callback function */
80 void *stats_cbarg; /* user callback arg */
81 bfa_boolean_t diag_busy; /* diag busy status */
82 bfa_boolean_t beacon; /* port beacon status */
83 bfa_boolean_t link_e2e_beacon; /* link beacon status */
84};
85
86#define BFA_FCPORT_MOD(__bfa) (&(__bfa)->modules.fcport)
87
88/*
89 * public functions
90 */
91void bfa_fcport_init(struct bfa_s *bfa);
92void bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
93
94#endif /* __BFA_PORT_PRIV_H__ */
diff --git a/drivers/scsi/bfa/bfa_rport.c b/drivers/scsi/bfa/bfa_rport.c
deleted file mode 100644
index ccd0680f6f16..000000000000
--- a/drivers/scsi/bfa/bfa_rport.c
+++ /dev/null
@@ -1,906 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
19#include <bfa_svc.h>
20#include <cs/bfa_debug.h>
21#include <bfi/bfi_rport.h>
22#include "bfa_intr_priv.h"
23
24BFA_TRC_FILE(HAL, RPORT);
25BFA_MODULE(rport);
26
27#define bfa_rport_offline_cb(__rp) do { \
28 if ((__rp)->bfa->fcs) \
29 bfa_cb_rport_offline((__rp)->rport_drv); \
30 else { \
31 bfa_cb_queue((__rp)->bfa, &(__rp)->hcb_qe, \
32 __bfa_cb_rport_offline, (__rp)); \
33 } \
34} while (0)
35
36#define bfa_rport_online_cb(__rp) do { \
37 if ((__rp)->bfa->fcs) \
38 bfa_cb_rport_online((__rp)->rport_drv); \
39 else { \
40 bfa_cb_queue((__rp)->bfa, &(__rp)->hcb_qe, \
41 __bfa_cb_rport_online, (__rp)); \
42 } \
43} while (0)
44
45/*
46 * forward declarations
47 */
48static struct bfa_rport_s *bfa_rport_alloc(struct bfa_rport_mod_s *rp_mod);
49static void bfa_rport_free(struct bfa_rport_s *rport);
50static bfa_boolean_t bfa_rport_send_fwcreate(struct bfa_rport_s *rp);
51static bfa_boolean_t bfa_rport_send_fwdelete(struct bfa_rport_s *rp);
52static bfa_boolean_t bfa_rport_send_fwspeed(struct bfa_rport_s *rp);
53static void __bfa_cb_rport_online(void *cbarg, bfa_boolean_t complete);
54static void __bfa_cb_rport_offline(void *cbarg, bfa_boolean_t complete);
55
56/**
57 * bfa_rport_sm BFA rport state machine
58 */
59
60
61enum bfa_rport_event {
62 BFA_RPORT_SM_CREATE = 1, /* rport create event */
63 BFA_RPORT_SM_DELETE = 2, /* deleting an existing rport */
64 BFA_RPORT_SM_ONLINE = 3, /* rport is online */
65 BFA_RPORT_SM_OFFLINE = 4, /* rport is offline */
66 BFA_RPORT_SM_FWRSP = 5, /* firmware response */
67 BFA_RPORT_SM_HWFAIL = 6, /* IOC h/w failure */
68 BFA_RPORT_SM_QOS_SCN = 7, /* QoS SCN from firmware */
69 BFA_RPORT_SM_SET_SPEED = 8, /* Set Rport Speed */
70 BFA_RPORT_SM_QRESUME = 9, /* space in requeue queue */
71};
72
73static void bfa_rport_sm_uninit(struct bfa_rport_s *rp,
74 enum bfa_rport_event event);
75static void bfa_rport_sm_created(struct bfa_rport_s *rp,
76 enum bfa_rport_event event);
77static void bfa_rport_sm_fwcreate(struct bfa_rport_s *rp,
78 enum bfa_rport_event event);
79static void bfa_rport_sm_online(struct bfa_rport_s *rp,
80 enum bfa_rport_event event);
81static void bfa_rport_sm_fwdelete(struct bfa_rport_s *rp,
82 enum bfa_rport_event event);
83static void bfa_rport_sm_offline(struct bfa_rport_s *rp,
84 enum bfa_rport_event event);
85static void bfa_rport_sm_deleting(struct bfa_rport_s *rp,
86 enum bfa_rport_event event);
87static void bfa_rport_sm_offline_pending(struct bfa_rport_s *rp,
88 enum bfa_rport_event event);
89static void bfa_rport_sm_delete_pending(struct bfa_rport_s *rp,
90 enum bfa_rport_event event);
91static void bfa_rport_sm_iocdisable(struct bfa_rport_s *rp,
92 enum bfa_rport_event event);
93static void bfa_rport_sm_fwcreate_qfull(struct bfa_rport_s *rp,
94 enum bfa_rport_event event);
95static void bfa_rport_sm_fwdelete_qfull(struct bfa_rport_s *rp,
96 enum bfa_rport_event event);
97static void bfa_rport_sm_deleting_qfull(struct bfa_rport_s *rp,
98 enum bfa_rport_event event);
99
100/**
101 * Beginning state, only online event expected.
102 */
103static void
104bfa_rport_sm_uninit(struct bfa_rport_s *rp, enum bfa_rport_event event)
105{
106 bfa_trc(rp->bfa, rp->rport_tag);
107 bfa_trc(rp->bfa, event);
108
109 switch (event) {
110 case BFA_RPORT_SM_CREATE:
111 bfa_stats(rp, sm_un_cr);
112 bfa_sm_set_state(rp, bfa_rport_sm_created);
113 break;
114
115 default:
116 bfa_stats(rp, sm_un_unexp);
117 bfa_sm_fault(rp->bfa, event);
118 }
119}
120
121static void
122bfa_rport_sm_created(struct bfa_rport_s *rp, enum bfa_rport_event event)
123{
124 bfa_trc(rp->bfa, rp->rport_tag);
125 bfa_trc(rp->bfa, event);
126
127 switch (event) {
128 case BFA_RPORT_SM_ONLINE:
129 bfa_stats(rp, sm_cr_on);
130 if (bfa_rport_send_fwcreate(rp))
131 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
132 else
133 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate_qfull);
134 break;
135
136 case BFA_RPORT_SM_DELETE:
137 bfa_stats(rp, sm_cr_del);
138 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
139 bfa_rport_free(rp);
140 break;
141
142 case BFA_RPORT_SM_HWFAIL:
143 bfa_stats(rp, sm_cr_hwf);
144 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
145 break;
146
147 default:
148 bfa_stats(rp, sm_cr_unexp);
149 bfa_sm_fault(rp->bfa, event);
150 }
151}
152
153/**
154 * Waiting for rport create response from firmware.
155 */
156static void
157bfa_rport_sm_fwcreate(struct bfa_rport_s *rp, enum bfa_rport_event event)
158{
159 bfa_trc(rp->bfa, rp->rport_tag);
160 bfa_trc(rp->bfa, event);
161
162 switch (event) {
163 case BFA_RPORT_SM_FWRSP:
164 bfa_stats(rp, sm_fwc_rsp);
165 bfa_sm_set_state(rp, bfa_rport_sm_online);
166 bfa_rport_online_cb(rp);
167 break;
168
169 case BFA_RPORT_SM_DELETE:
170 bfa_stats(rp, sm_fwc_del);
171 bfa_sm_set_state(rp, bfa_rport_sm_delete_pending);
172 break;
173
174 case BFA_RPORT_SM_OFFLINE:
175 bfa_stats(rp, sm_fwc_off);
176 bfa_sm_set_state(rp, bfa_rport_sm_offline_pending);
177 break;
178
179 case BFA_RPORT_SM_HWFAIL:
180 bfa_stats(rp, sm_fwc_hwf);
181 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
182 break;
183
184 default:
185 bfa_stats(rp, sm_fwc_unexp);
186 bfa_sm_fault(rp->bfa, event);
187 }
188}
189
190/**
191 * Request queue is full, awaiting queue resume to send create request.
192 */
193static void
194bfa_rport_sm_fwcreate_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event)
195{
196 bfa_trc(rp->bfa, rp->rport_tag);
197 bfa_trc(rp->bfa, event);
198
199 switch (event) {
200 case BFA_RPORT_SM_QRESUME:
201 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
202 bfa_rport_send_fwcreate(rp);
203 break;
204
205 case BFA_RPORT_SM_DELETE:
206 bfa_stats(rp, sm_fwc_del);
207 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
208 bfa_reqq_wcancel(&rp->reqq_wait);
209 bfa_rport_free(rp);
210 break;
211
212 case BFA_RPORT_SM_OFFLINE:
213 bfa_stats(rp, sm_fwc_off);
214 bfa_sm_set_state(rp, bfa_rport_sm_offline);
215 bfa_reqq_wcancel(&rp->reqq_wait);
216 bfa_rport_offline_cb(rp);
217 break;
218
219 case BFA_RPORT_SM_HWFAIL:
220 bfa_stats(rp, sm_fwc_hwf);
221 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
222 bfa_reqq_wcancel(&rp->reqq_wait);
223 break;
224
225 default:
226 bfa_stats(rp, sm_fwc_unexp);
227 bfa_sm_fault(rp->bfa, event);
228 }
229}
230
231/**
232 * Online state - normal parking state.
233 */
234static void
235bfa_rport_sm_online(struct bfa_rport_s *rp, enum bfa_rport_event event)
236{
237 struct bfi_rport_qos_scn_s *qos_scn;
238
239 bfa_trc(rp->bfa, rp->rport_tag);
240 bfa_trc(rp->bfa, event);
241
242 switch (event) {
243 case BFA_RPORT_SM_OFFLINE:
244 bfa_stats(rp, sm_on_off);
245 if (bfa_rport_send_fwdelete(rp))
246 bfa_sm_set_state(rp, bfa_rport_sm_fwdelete);
247 else
248 bfa_sm_set_state(rp, bfa_rport_sm_fwdelete_qfull);
249 break;
250
251 case BFA_RPORT_SM_DELETE:
252 bfa_stats(rp, sm_on_del);
253 if (bfa_rport_send_fwdelete(rp))
254 bfa_sm_set_state(rp, bfa_rport_sm_deleting);
255 else
256 bfa_sm_set_state(rp, bfa_rport_sm_deleting_qfull);
257 break;
258
259 case BFA_RPORT_SM_HWFAIL:
260 bfa_stats(rp, sm_on_hwf);
261 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
262 break;
263
264 case BFA_RPORT_SM_SET_SPEED:
265 bfa_rport_send_fwspeed(rp);
266 break;
267
268 case BFA_RPORT_SM_QOS_SCN:
269 qos_scn = (struct bfi_rport_qos_scn_s *) rp->event_arg.fw_msg;
270 rp->qos_attr = qos_scn->new_qos_attr;
271 bfa_trc(rp->bfa, qos_scn->old_qos_attr.qos_flow_id);
272 bfa_trc(rp->bfa, qos_scn->new_qos_attr.qos_flow_id);
273 bfa_trc(rp->bfa, qos_scn->old_qos_attr.qos_priority);
274 bfa_trc(rp->bfa, qos_scn->new_qos_attr.qos_priority);
275
276 qos_scn->old_qos_attr.qos_flow_id =
277 bfa_os_ntohl(qos_scn->old_qos_attr.qos_flow_id);
278 qos_scn->new_qos_attr.qos_flow_id =
279 bfa_os_ntohl(qos_scn->new_qos_attr.qos_flow_id);
280 qos_scn->old_qos_attr.qos_priority =
281 bfa_os_ntohl(qos_scn->old_qos_attr.qos_priority);
282 qos_scn->new_qos_attr.qos_priority =
283 bfa_os_ntohl(qos_scn->new_qos_attr.qos_priority);
284
285 if (qos_scn->old_qos_attr.qos_flow_id !=
286 qos_scn->new_qos_attr.qos_flow_id)
287 bfa_cb_rport_qos_scn_flowid(rp->rport_drv,
288 qos_scn->old_qos_attr,
289 qos_scn->new_qos_attr);
290 if (qos_scn->old_qos_attr.qos_priority !=
291 qos_scn->new_qos_attr.qos_priority)
292 bfa_cb_rport_qos_scn_prio(rp->rport_drv,
293 qos_scn->old_qos_attr,
294 qos_scn->new_qos_attr);
295 break;
296
297 default:
298 bfa_stats(rp, sm_on_unexp);
299 bfa_sm_fault(rp->bfa, event);
300 }
301}
302
303/**
304 * Firmware rport is being deleted - awaiting f/w response.
305 */
306static void
307bfa_rport_sm_fwdelete(struct bfa_rport_s *rp, enum bfa_rport_event event)
308{
309 bfa_trc(rp->bfa, rp->rport_tag);
310 bfa_trc(rp->bfa, event);
311
312 switch (event) {
313 case BFA_RPORT_SM_FWRSP:
314 bfa_stats(rp, sm_fwd_rsp);
315 bfa_sm_set_state(rp, bfa_rport_sm_offline);
316 bfa_rport_offline_cb(rp);
317 break;
318
319 case BFA_RPORT_SM_DELETE:
320 bfa_stats(rp, sm_fwd_del);
321 bfa_sm_set_state(rp, bfa_rport_sm_deleting);
322 break;
323
324 case BFA_RPORT_SM_HWFAIL:
325 bfa_stats(rp, sm_fwd_hwf);
326 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
327 bfa_rport_offline_cb(rp);
328 break;
329
330 default:
331 bfa_stats(rp, sm_fwd_unexp);
332 bfa_sm_fault(rp->bfa, event);
333 }
334}
335
336static void
337bfa_rport_sm_fwdelete_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event)
338{
339 bfa_trc(rp->bfa, rp->rport_tag);
340 bfa_trc(rp->bfa, event);
341
342 switch (event) {
343 case BFA_RPORT_SM_QRESUME:
344 bfa_sm_set_state(rp, bfa_rport_sm_fwdelete);
345 bfa_rport_send_fwdelete(rp);
346 break;
347
348 case BFA_RPORT_SM_DELETE:
349 bfa_stats(rp, sm_fwd_del);
350 bfa_sm_set_state(rp, bfa_rport_sm_deleting_qfull);
351 break;
352
353 case BFA_RPORT_SM_HWFAIL:
354 bfa_stats(rp, sm_fwd_hwf);
355 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
356 bfa_reqq_wcancel(&rp->reqq_wait);
357 bfa_rport_offline_cb(rp);
358 break;
359
360 default:
361 bfa_stats(rp, sm_fwd_unexp);
362 bfa_sm_fault(rp->bfa, event);
363 }
364}
365
366/**
367 * Offline state.
368 */
369static void
370bfa_rport_sm_offline(struct bfa_rport_s *rp, enum bfa_rport_event event)
371{
372 bfa_trc(rp->bfa, rp->rport_tag);
373 bfa_trc(rp->bfa, event);
374
375 switch (event) {
376 case BFA_RPORT_SM_DELETE:
377 bfa_stats(rp, sm_off_del);
378 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
379 bfa_rport_free(rp);
380 break;
381
382 case BFA_RPORT_SM_ONLINE:
383 bfa_stats(rp, sm_off_on);
384 if (bfa_rport_send_fwcreate(rp))
385 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
386 else
387 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate_qfull);
388 break;
389
390 case BFA_RPORT_SM_HWFAIL:
391 bfa_stats(rp, sm_off_hwf);
392 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
393 break;
394
395 default:
396 bfa_stats(rp, sm_off_unexp);
397 bfa_sm_fault(rp->bfa, event);
398 }
399}
400
401/**
402 * Rport is deleted, waiting for firmware response to delete.
403 */
404static void
405bfa_rport_sm_deleting(struct bfa_rport_s *rp, enum bfa_rport_event event)
406{
407 bfa_trc(rp->bfa, rp->rport_tag);
408 bfa_trc(rp->bfa, event);
409
410 switch (event) {
411 case BFA_RPORT_SM_FWRSP:
412 bfa_stats(rp, sm_del_fwrsp);
413 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
414 bfa_rport_free(rp);
415 break;
416
417 case BFA_RPORT_SM_HWFAIL:
418 bfa_stats(rp, sm_del_hwf);
419 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
420 bfa_rport_free(rp);
421 break;
422
423 default:
424 bfa_sm_fault(rp->bfa, event);
425 }
426}
427
428static void
429bfa_rport_sm_deleting_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event)
430{
431 bfa_trc(rp->bfa, rp->rport_tag);
432 bfa_trc(rp->bfa, event);
433
434 switch (event) {
435 case BFA_RPORT_SM_QRESUME:
436 bfa_stats(rp, sm_del_fwrsp);
437 bfa_sm_set_state(rp, bfa_rport_sm_deleting);
438 bfa_rport_send_fwdelete(rp);
439 break;
440
441 case BFA_RPORT_SM_HWFAIL:
442 bfa_stats(rp, sm_del_hwf);
443 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
444 bfa_reqq_wcancel(&rp->reqq_wait);
445 bfa_rport_free(rp);
446 break;
447
448 default:
449 bfa_sm_fault(rp->bfa, event);
450 }
451}
452
453/**
454 * Waiting for rport create response from firmware. A delete is pending.
455 */
456static void
457bfa_rport_sm_delete_pending(struct bfa_rport_s *rp,
458 enum bfa_rport_event event)
459{
460 bfa_trc(rp->bfa, rp->rport_tag);
461 bfa_trc(rp->bfa, event);
462
463 switch (event) {
464 case BFA_RPORT_SM_FWRSP:
465 bfa_stats(rp, sm_delp_fwrsp);
466 if (bfa_rport_send_fwdelete(rp))
467 bfa_sm_set_state(rp, bfa_rport_sm_deleting);
468 else
469 bfa_sm_set_state(rp, bfa_rport_sm_deleting_qfull);
470 break;
471
472 case BFA_RPORT_SM_HWFAIL:
473 bfa_stats(rp, sm_delp_hwf);
474 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
475 bfa_rport_free(rp);
476 break;
477
478 default:
479 bfa_stats(rp, sm_delp_unexp);
480 bfa_sm_fault(rp->bfa, event);
481 }
482}
483
484/**
485 * Waiting for rport create response from firmware. Rport offline is pending.
486 */
487static void
488bfa_rport_sm_offline_pending(struct bfa_rport_s *rp,
489 enum bfa_rport_event event)
490{
491 bfa_trc(rp->bfa, rp->rport_tag);
492 bfa_trc(rp->bfa, event);
493
494 switch (event) {
495 case BFA_RPORT_SM_FWRSP:
496 bfa_stats(rp, sm_offp_fwrsp);
497 if (bfa_rport_send_fwdelete(rp))
498 bfa_sm_set_state(rp, bfa_rport_sm_fwdelete);
499 else
500 bfa_sm_set_state(rp, bfa_rport_sm_fwdelete_qfull);
501 break;
502
503 case BFA_RPORT_SM_DELETE:
504 bfa_stats(rp, sm_offp_del);
505 bfa_sm_set_state(rp, bfa_rport_sm_delete_pending);
506 break;
507
508 case BFA_RPORT_SM_HWFAIL:
509 bfa_stats(rp, sm_offp_hwf);
510 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
511 break;
512
513 default:
514 bfa_stats(rp, sm_offp_unexp);
515 bfa_sm_fault(rp->bfa, event);
516 }
517}
518
519/**
520 * IOC h/w failed.
521 */
522static void
523bfa_rport_sm_iocdisable(struct bfa_rport_s *rp, enum bfa_rport_event event)
524{
525 bfa_trc(rp->bfa, rp->rport_tag);
526 bfa_trc(rp->bfa, event);
527
528 switch (event) {
529 case BFA_RPORT_SM_OFFLINE:
530 bfa_stats(rp, sm_iocd_off);
531 bfa_rport_offline_cb(rp);
532 break;
533
534 case BFA_RPORT_SM_DELETE:
535 bfa_stats(rp, sm_iocd_del);
536 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
537 bfa_rport_free(rp);
538 break;
539
540 case BFA_RPORT_SM_ONLINE:
541 bfa_stats(rp, sm_iocd_on);
542 if (bfa_rport_send_fwcreate(rp))
543 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
544 else
545 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate_qfull);
546 break;
547
548 case BFA_RPORT_SM_HWFAIL:
549 break;
550
551 default:
552 bfa_stats(rp, sm_iocd_unexp);
553 bfa_sm_fault(rp->bfa, event);
554 }
555}
556
557
558
559/**
560 * bfa_rport_private BFA rport private functions
561 */
562
563static void
564__bfa_cb_rport_online(void *cbarg, bfa_boolean_t complete)
565{
566 struct bfa_rport_s *rp = cbarg;
567
568 if (complete)
569 bfa_cb_rport_online(rp->rport_drv);
570}
571
572static void
573__bfa_cb_rport_offline(void *cbarg, bfa_boolean_t complete)
574{
575 struct bfa_rport_s *rp = cbarg;
576
577 if (complete)
578 bfa_cb_rport_offline(rp->rport_drv);
579}
580
581static void
582bfa_rport_qresume(void *cbarg)
583{
584 struct bfa_rport_s *rp = cbarg;
585
586 bfa_sm_send_event(rp, BFA_RPORT_SM_QRESUME);
587}
588
589static void
590bfa_rport_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
591 u32 *dm_len)
592{
593 if (cfg->fwcfg.num_rports < BFA_RPORT_MIN)
594 cfg->fwcfg.num_rports = BFA_RPORT_MIN;
595
596 *km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_rport_s);
597}
598
599static void
600bfa_rport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
601 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
602{
603 struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(bfa);
604 struct bfa_rport_s *rp;
605 u16 i;
606
607 INIT_LIST_HEAD(&mod->rp_free_q);
608 INIT_LIST_HEAD(&mod->rp_active_q);
609
610 rp = (struct bfa_rport_s *) bfa_meminfo_kva(meminfo);
611 mod->rps_list = rp;
612 mod->num_rports = cfg->fwcfg.num_rports;
613
614 bfa_assert(mod->num_rports
615 && !(mod->num_rports & (mod->num_rports - 1)));
616
617 for (i = 0; i < mod->num_rports; i++, rp++) {
618 bfa_os_memset(rp, 0, sizeof(struct bfa_rport_s));
619 rp->bfa = bfa;
620 rp->rport_tag = i;
621 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
622
623 /**
624 * - is unused
625 */
626 if (i)
627 list_add_tail(&rp->qe, &mod->rp_free_q);
628
629 bfa_reqq_winit(&rp->reqq_wait, bfa_rport_qresume, rp);
630 }
631
632 /**
633 * consume memory
634 */
635 bfa_meminfo_kva(meminfo) = (u8 *) rp;
636}
637
638static void
639bfa_rport_detach(struct bfa_s *bfa)
640{
641}
642
643static void
644bfa_rport_start(struct bfa_s *bfa)
645{
646}
647
648static void
649bfa_rport_stop(struct bfa_s *bfa)
650{
651}
652
653static void
654bfa_rport_iocdisable(struct bfa_s *bfa)
655{
656 struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(bfa);
657 struct bfa_rport_s *rport;
658 struct list_head *qe, *qen;
659
660 list_for_each_safe(qe, qen, &mod->rp_active_q) {
661 rport = (struct bfa_rport_s *) qe;
662 bfa_sm_send_event(rport, BFA_RPORT_SM_HWFAIL);
663 }
664}
665
666static struct bfa_rport_s *
667bfa_rport_alloc(struct bfa_rport_mod_s *mod)
668{
669 struct bfa_rport_s *rport;
670
671 bfa_q_deq(&mod->rp_free_q, &rport);
672 if (rport)
673 list_add_tail(&rport->qe, &mod->rp_active_q);
674
675 return rport;
676}
677
678static void
679bfa_rport_free(struct bfa_rport_s *rport)
680{
681 struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(rport->bfa);
682
683 bfa_assert(bfa_q_is_on_q(&mod->rp_active_q, rport));
684 list_del(&rport->qe);
685 list_add_tail(&rport->qe, &mod->rp_free_q);
686}
687
688static bfa_boolean_t
689bfa_rport_send_fwcreate(struct bfa_rport_s *rp)
690{
691 struct bfi_rport_create_req_s *m;
692
693 /**
694 * check for room in queue to send request now
695 */
696 m = bfa_reqq_next(rp->bfa, BFA_REQQ_RPORT);
697 if (!m) {
698 bfa_reqq_wait(rp->bfa, BFA_REQQ_RPORT, &rp->reqq_wait);
699 return BFA_FALSE;
700 }
701
702 bfi_h2i_set(m->mh, BFI_MC_RPORT, BFI_RPORT_H2I_CREATE_REQ,
703 bfa_lpuid(rp->bfa));
704 m->bfa_handle = rp->rport_tag;
705 m->max_frmsz = bfa_os_htons(rp->rport_info.max_frmsz);
706 m->pid = rp->rport_info.pid;
707 m->lp_tag = rp->rport_info.lp_tag;
708 m->local_pid = rp->rport_info.local_pid;
709 m->fc_class = rp->rport_info.fc_class;
710 m->vf_en = rp->rport_info.vf_en;
711 m->vf_id = rp->rport_info.vf_id;
712 m->cisc = rp->rport_info.cisc;
713
714 /**
715 * queue I/O message to firmware
716 */
717 bfa_reqq_produce(rp->bfa, BFA_REQQ_RPORT);
718 return BFA_TRUE;
719}
720
721static bfa_boolean_t
722bfa_rport_send_fwdelete(struct bfa_rport_s *rp)
723{
724 struct bfi_rport_delete_req_s *m;
725
726 /**
727 * check for room in queue to send request now
728 */
729 m = bfa_reqq_next(rp->bfa, BFA_REQQ_RPORT);
730 if (!m) {
731 bfa_reqq_wait(rp->bfa, BFA_REQQ_RPORT, &rp->reqq_wait);
732 return BFA_FALSE;
733 }
734
735 bfi_h2i_set(m->mh, BFI_MC_RPORT, BFI_RPORT_H2I_DELETE_REQ,
736 bfa_lpuid(rp->bfa));
737 m->fw_handle = rp->fw_handle;
738
739 /**
740 * queue I/O message to firmware
741 */
742 bfa_reqq_produce(rp->bfa, BFA_REQQ_RPORT);
743 return BFA_TRUE;
744}
745
746static bfa_boolean_t
747bfa_rport_send_fwspeed(struct bfa_rport_s *rp)
748{
749 struct bfa_rport_speed_req_s *m;
750
751 /**
752 * check for room in queue to send request now
753 */
754 m = bfa_reqq_next(rp->bfa, BFA_REQQ_RPORT);
755 if (!m) {
756 bfa_trc(rp->bfa, rp->rport_info.speed);
757 return BFA_FALSE;
758 }
759
760 bfi_h2i_set(m->mh, BFI_MC_RPORT, BFI_RPORT_H2I_SET_SPEED_REQ,
761 bfa_lpuid(rp->bfa));
762 m->fw_handle = rp->fw_handle;
763 m->speed = (u8)rp->rport_info.speed;
764
765 /**
766 * queue I/O message to firmware
767 */
768 bfa_reqq_produce(rp->bfa, BFA_REQQ_RPORT);
769 return BFA_TRUE;
770}
771
772
773
774/**
775 * bfa_rport_public
776 */
777
778/**
779 * Rport interrupt processing.
780 */
781void
782bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
783{
784 union bfi_rport_i2h_msg_u msg;
785 struct bfa_rport_s *rp;
786
787 bfa_trc(bfa, m->mhdr.msg_id);
788
789 msg.msg = m;
790
791 switch (m->mhdr.msg_id) {
792 case BFI_RPORT_I2H_CREATE_RSP:
793 rp = BFA_RPORT_FROM_TAG(bfa, msg.create_rsp->bfa_handle);
794 rp->fw_handle = msg.create_rsp->fw_handle;
795 rp->qos_attr = msg.create_rsp->qos_attr;
796 bfa_assert(msg.create_rsp->status == BFA_STATUS_OK);
797 bfa_sm_send_event(rp, BFA_RPORT_SM_FWRSP);
798 break;
799
800 case BFI_RPORT_I2H_DELETE_RSP:
801 rp = BFA_RPORT_FROM_TAG(bfa, msg.delete_rsp->bfa_handle);
802 bfa_assert(msg.delete_rsp->status == BFA_STATUS_OK);
803 bfa_sm_send_event(rp, BFA_RPORT_SM_FWRSP);
804 break;
805
806 case BFI_RPORT_I2H_QOS_SCN:
807 rp = BFA_RPORT_FROM_TAG(bfa, msg.qos_scn_evt->bfa_handle);
808 rp->event_arg.fw_msg = msg.qos_scn_evt;
809 bfa_sm_send_event(rp, BFA_RPORT_SM_QOS_SCN);
810 break;
811
812 default:
813 bfa_trc(bfa, m->mhdr.msg_id);
814 bfa_assert(0);
815 }
816}
817
818
819
820/**
821 * bfa_rport_api
822 */
823
824struct bfa_rport_s *
825bfa_rport_create(struct bfa_s *bfa, void *rport_drv)
826{
827 struct bfa_rport_s *rp;
828
829 rp = bfa_rport_alloc(BFA_RPORT_MOD(bfa));
830
831 if (rp == NULL)
832 return NULL;
833
834 rp->bfa = bfa;
835 rp->rport_drv = rport_drv;
836 bfa_rport_clear_stats(rp);
837
838 bfa_assert(bfa_sm_cmp_state(rp, bfa_rport_sm_uninit));
839 bfa_sm_send_event(rp, BFA_RPORT_SM_CREATE);
840
841 return rp;
842}
843
844void
845bfa_rport_delete(struct bfa_rport_s *rport)
846{
847 bfa_sm_send_event(rport, BFA_RPORT_SM_DELETE);
848}
849
850void
851bfa_rport_online(struct bfa_rport_s *rport, struct bfa_rport_info_s *rport_info)
852{
853 bfa_assert(rport_info->max_frmsz != 0);
854
855 /**
856 * Some JBODs are seen to be not setting PDU size correctly in PLOGI
857 * responses. Default to minimum size.
858 */
859 if (rport_info->max_frmsz == 0) {
860 bfa_trc(rport->bfa, rport->rport_tag);
861 rport_info->max_frmsz = FC_MIN_PDUSZ;
862 }
863
864 bfa_os_assign(rport->rport_info, *rport_info);
865 bfa_sm_send_event(rport, BFA_RPORT_SM_ONLINE);
866}
867
868void
869bfa_rport_offline(struct bfa_rport_s *rport)
870{
871 bfa_sm_send_event(rport, BFA_RPORT_SM_OFFLINE);
872}
873
874void
875bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_pport_speed speed)
876{
877 bfa_assert(speed != 0);
878 bfa_assert(speed != BFA_PPORT_SPEED_AUTO);
879
880 rport->rport_info.speed = speed;
881 bfa_sm_send_event(rport, BFA_RPORT_SM_SET_SPEED);
882}
883
884void
885bfa_rport_get_stats(struct bfa_rport_s *rport,
886 struct bfa_rport_hal_stats_s *stats)
887{
888 *stats = rport->stats;
889}
890
891void
892bfa_rport_get_qos_attr(struct bfa_rport_s *rport,
893 struct bfa_rport_qos_attr_s *qos_attr)
894{
895 qos_attr->qos_priority = bfa_os_ntohl(rport->qos_attr.qos_priority);
896 qos_attr->qos_flow_id = bfa_os_ntohl(rport->qos_attr.qos_flow_id);
897
898}
899
900void
901bfa_rport_clear_stats(struct bfa_rport_s *rport)
902{
903 bfa_os_memset(&rport->stats, 0, sizeof(rport->stats));
904}
905
906
diff --git a/drivers/scsi/bfa/bfa_rport_priv.h b/drivers/scsi/bfa/bfa_rport_priv.h
deleted file mode 100644
index 6490ce2e990d..000000000000
--- a/drivers/scsi/bfa/bfa_rport_priv.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_RPORT_PRIV_H__
19#define __BFA_RPORT_PRIV_H__
20
21#include <bfa_svc.h>
22
23#define BFA_RPORT_MIN 4
24
25struct bfa_rport_mod_s {
26 struct bfa_rport_s *rps_list; /* list of rports */
27 struct list_head rp_free_q; /* free bfa_rports */
28 struct list_head rp_active_q; /* free bfa_rports */
29 u16 num_rports; /* number of rports */
30};
31
32#define BFA_RPORT_MOD(__bfa) (&(__bfa)->modules.rport_mod)
33
34/**
35 * Convert rport tag to RPORT
36 */
37#define BFA_RPORT_FROM_TAG(__bfa, _tag) \
38 (BFA_RPORT_MOD(__bfa)->rps_list + \
39 ((_tag) & (BFA_RPORT_MOD(__bfa)->num_rports - 1)))
40
41/*
42 * external functions
43 */
44void bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
45#endif /* __BFA_RPORT_PRIV_H__ */
diff --git a/drivers/scsi/bfa/bfa_sgpg.c b/drivers/scsi/bfa/bfa_sgpg.c
deleted file mode 100644
index ae452c42e40e..000000000000
--- a/drivers/scsi/bfa/bfa_sgpg.c
+++ /dev/null
@@ -1,226 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
19
20BFA_TRC_FILE(HAL, SGPG);
21BFA_MODULE(sgpg);
22
23/**
24 * bfa_sgpg_mod BFA SGPG Mode module
25 */
26
27/**
28 * Compute and return memory needed by FCP(im) module.
29 */
30static void
31bfa_sgpg_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
32 u32 *dm_len)
33{
34 if (cfg->drvcfg.num_sgpgs < BFA_SGPG_MIN)
35 cfg->drvcfg.num_sgpgs = BFA_SGPG_MIN;
36
37 *km_len += (cfg->drvcfg.num_sgpgs + 1) * sizeof(struct bfa_sgpg_s);
38 *dm_len += (cfg->drvcfg.num_sgpgs + 1) * sizeof(struct bfi_sgpg_s);
39}
40
41
42static void
43bfa_sgpg_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
44 struct bfa_meminfo_s *minfo, struct bfa_pcidev_s *pcidev)
45{
46 struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
47 int i;
48 struct bfa_sgpg_s *hsgpg;
49 struct bfi_sgpg_s *sgpg;
50 u64 align_len;
51
52 union {
53 u64 pa;
54 union bfi_addr_u addr;
55 } sgpg_pa;
56
57 INIT_LIST_HEAD(&mod->sgpg_q);
58 INIT_LIST_HEAD(&mod->sgpg_wait_q);
59
60 bfa_trc(bfa, cfg->drvcfg.num_sgpgs);
61
62 mod->num_sgpgs = cfg->drvcfg.num_sgpgs;
63 mod->sgpg_arr_pa = bfa_meminfo_dma_phys(minfo);
64 align_len = (BFA_SGPG_ROUNDUP(mod->sgpg_arr_pa) - mod->sgpg_arr_pa);
65 mod->sgpg_arr_pa += align_len;
66 mod->hsgpg_arr = (struct bfa_sgpg_s *) (bfa_meminfo_kva(minfo) +
67 align_len);
68 mod->sgpg_arr = (struct bfi_sgpg_s *) (bfa_meminfo_dma_virt(minfo) +
69 align_len);
70
71 hsgpg = mod->hsgpg_arr;
72 sgpg = mod->sgpg_arr;
73 sgpg_pa.pa = mod->sgpg_arr_pa;
74 mod->free_sgpgs = mod->num_sgpgs;
75
76 bfa_assert(!(sgpg_pa.pa & (sizeof(struct bfi_sgpg_s) - 1)));
77
78 for (i = 0; i < mod->num_sgpgs; i++) {
79 bfa_os_memset(hsgpg, 0, sizeof(*hsgpg));
80 bfa_os_memset(sgpg, 0, sizeof(*sgpg));
81
82 hsgpg->sgpg = sgpg;
83 hsgpg->sgpg_pa = sgpg_pa.addr;
84 list_add_tail(&hsgpg->qe, &mod->sgpg_q);
85
86 hsgpg++;
87 sgpg++;
88 sgpg_pa.pa += sizeof(struct bfi_sgpg_s);
89 }
90
91 bfa_meminfo_kva(minfo) = (u8 *) hsgpg;
92 bfa_meminfo_dma_virt(minfo) = (u8 *) sgpg;
93 bfa_meminfo_dma_phys(minfo) = sgpg_pa.pa;
94}
95
96static void
97bfa_sgpg_detach(struct bfa_s *bfa)
98{
99}
100
101static void
102bfa_sgpg_start(struct bfa_s *bfa)
103{
104}
105
106static void
107bfa_sgpg_stop(struct bfa_s *bfa)
108{
109}
110
111static void
112bfa_sgpg_iocdisable(struct bfa_s *bfa)
113{
114}
115
116
117
118/**
119 * bfa_sgpg_public BFA SGPG public functions
120 */
121
122bfa_status_t
123bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpgs)
124{
125 struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
126 struct bfa_sgpg_s *hsgpg;
127 int i;
128
129 bfa_trc_fp(bfa, nsgpgs);
130
131 if (mod->free_sgpgs < nsgpgs)
132 return BFA_STATUS_ENOMEM;
133
134 for (i = 0; i < nsgpgs; i++) {
135 bfa_q_deq(&mod->sgpg_q, &hsgpg);
136 bfa_assert(hsgpg);
137 list_add_tail(&hsgpg->qe, sgpg_q);
138 }
139
140 mod->free_sgpgs -= nsgpgs;
141 return BFA_STATUS_OK;
142}
143
144void
145bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpg)
146{
147 struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
148 struct bfa_sgpg_wqe_s *wqe;
149
150 bfa_trc_fp(bfa, nsgpg);
151
152 mod->free_sgpgs += nsgpg;
153 bfa_assert(mod->free_sgpgs <= mod->num_sgpgs);
154
155 list_splice_tail_init(sgpg_q, &mod->sgpg_q);
156
157 if (list_empty(&mod->sgpg_wait_q))
158 return;
159
160 /**
161 * satisfy as many waiting requests as possible
162 */
163 do {
164 wqe = bfa_q_first(&mod->sgpg_wait_q);
165 if (mod->free_sgpgs < wqe->nsgpg)
166 nsgpg = mod->free_sgpgs;
167 else
168 nsgpg = wqe->nsgpg;
169 bfa_sgpg_malloc(bfa, &wqe->sgpg_q, nsgpg);
170 wqe->nsgpg -= nsgpg;
171 if (wqe->nsgpg == 0) {
172 list_del(&wqe->qe);
173 wqe->cbfn(wqe->cbarg);
174 }
175 } while (mod->free_sgpgs && !list_empty(&mod->sgpg_wait_q));
176}
177
178void
179bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe, int nsgpg)
180{
181 struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
182
183 bfa_assert(nsgpg > 0);
184 bfa_assert(nsgpg > mod->free_sgpgs);
185
186 wqe->nsgpg_total = wqe->nsgpg = nsgpg;
187
188 /**
189 * allocate any left to this one first
190 */
191 if (mod->free_sgpgs) {
192 /**
193 * no one else is waiting for SGPG
194 */
195 bfa_assert(list_empty(&mod->sgpg_wait_q));
196 list_splice_tail_init(&mod->sgpg_q, &wqe->sgpg_q);
197 wqe->nsgpg -= mod->free_sgpgs;
198 mod->free_sgpgs = 0;
199 }
200
201 list_add_tail(&wqe->qe, &mod->sgpg_wait_q);
202}
203
204void
205bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe)
206{
207 struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
208
209 bfa_assert(bfa_q_is_on_q(&mod->sgpg_wait_q, wqe));
210 list_del(&wqe->qe);
211
212 if (wqe->nsgpg_total != wqe->nsgpg)
213 bfa_sgpg_mfree(bfa, &wqe->sgpg_q,
214 wqe->nsgpg_total - wqe->nsgpg);
215}
216
217void
218bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe, void (*cbfn) (void *cbarg),
219 void *cbarg)
220{
221 INIT_LIST_HEAD(&wqe->sgpg_q);
222 wqe->cbfn = cbfn;
223 wqe->cbarg = cbarg;
224}
225
226
diff --git a/drivers/scsi/bfa/bfa_sgpg_priv.h b/drivers/scsi/bfa/bfa_sgpg_priv.h
deleted file mode 100644
index 9c2a8cbe7522..000000000000
--- a/drivers/scsi/bfa/bfa_sgpg_priv.h
+++ /dev/null
@@ -1,79 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * hal_sgpg.h BFA SG page module
20 */
21
22#ifndef __BFA_SGPG_PRIV_H__
23#define __BFA_SGPG_PRIV_H__
24
25#include <cs/bfa_q.h>
26
27#define BFA_SGPG_MIN (16)
28
29/**
30 * Alignment macro for SG page allocation
31 */
32#define BFA_SGPG_ROUNDUP(_l) (((_l) + (sizeof(struct bfi_sgpg_s) - 1)) \
33 & ~(sizeof(struct bfi_sgpg_s) - 1))
34
35struct bfa_sgpg_wqe_s {
36 struct list_head qe; /* queue sg page element */
37 int nsgpg; /* pages to be allocated */
38 int nsgpg_total; /* total pages required */
39 void (*cbfn) (void *cbarg);
40 /* callback function */
41 void *cbarg; /* callback arg */
42 struct list_head sgpg_q; /* queue of alloced sgpgs */
43};
44
45struct bfa_sgpg_s {
46 struct list_head qe; /* queue sg page element */
47 struct bfi_sgpg_s *sgpg; /* va of SG page */
48 union bfi_addr_u sgpg_pa;/* pa of SG page */
49};
50
51/**
52 * Given number of SG elements, BFA_SGPG_NPAGE() returns the number of
53 * SG pages required.
54 */
55#define BFA_SGPG_NPAGE(_nsges) (((_nsges) / BFI_SGPG_DATA_SGES) + 1)
56
57struct bfa_sgpg_mod_s {
58 struct bfa_s *bfa;
59 int num_sgpgs; /* number of SG pages */
60 int free_sgpgs; /* number of free SG pages */
61 struct bfa_sgpg_s *hsgpg_arr; /* BFA SG page array */
62 struct bfi_sgpg_s *sgpg_arr; /* actual SG page array */
63 u64 sgpg_arr_pa; /* SG page array DMA addr */
64 struct list_head sgpg_q; /* queue of free SG pages */
65 struct list_head sgpg_wait_q; /* wait queue for SG pages */
66};
67#define BFA_SGPG_MOD(__bfa) (&(__bfa)->modules.sgpg_mod)
68
69bfa_status_t bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q,
70 int nsgpgs);
71void bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q,
72 int nsgpgs);
73void bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe,
74 void (*cbfn) (void *cbarg), void *cbarg);
75void bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe,
76 int nsgpgs);
77void bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe);
78
79#endif /* __BFA_SGPG_PRIV_H__ */
diff --git a/drivers/scsi/bfa/bfa_sm.c b/drivers/scsi/bfa/bfa_sm.c
deleted file mode 100644
index 5420f4f45e58..000000000000
--- a/drivers/scsi/bfa/bfa_sm.c
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfasm.c BFA State machine utility functions
20 */
21
22#include <cs/bfa_sm.h>
23
24/**
25 * cs_sm_api
26 */
27
28int
29bfa_sm_to_state(struct bfa_sm_table_s *smt, bfa_sm_t sm)
30{
31 int i = 0;
32
33 while (smt[i].sm && smt[i].sm != sm)
34 i++;
35 return smt[i].state;
36}
37
38
diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c
new file mode 100644
index 000000000000..16d9a5f61c18
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_svc.c
@@ -0,0 +1,5075 @@
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#include "bfad_drv.h"
19#include "bfa_plog.h"
20#include "bfa_cs.h"
21#include "bfa_modules.h"
22
23BFA_TRC_FILE(HAL, FCXP);
24BFA_MODULE(fcxp);
25BFA_MODULE(sgpg);
26BFA_MODULE(lps);
27BFA_MODULE(fcport);
28BFA_MODULE(rport);
29BFA_MODULE(uf);
30
31/*
32 * LPS related definitions
33 */
34#define BFA_LPS_MIN_LPORTS (1)
35#define BFA_LPS_MAX_LPORTS (256)
36
37/*
38 * Maximum Vports supported per physical port or vf.
39 */
40#define BFA_LPS_MAX_VPORTS_SUPP_CB 255
41#define BFA_LPS_MAX_VPORTS_SUPP_CT 190
42
43
44/*
45 * FC PORT related definitions
46 */
47/*
48 * The port is considered disabled if corresponding physical port or IOC are
49 * disabled explicitly
50 */
51#define BFA_PORT_IS_DISABLED(bfa) \
52 ((bfa_fcport_is_disabled(bfa) == BFA_TRUE) || \
53 (bfa_ioc_is_disabled(&bfa->ioc) == BFA_TRUE))
54
55/*
56 * BFA port state machine events
57 */
58enum bfa_fcport_sm_event {
59 BFA_FCPORT_SM_START = 1, /* start port state machine */
60 BFA_FCPORT_SM_STOP = 2, /* stop port state machine */
61 BFA_FCPORT_SM_ENABLE = 3, /* enable port */
62 BFA_FCPORT_SM_DISABLE = 4, /* disable port state machine */
63 BFA_FCPORT_SM_FWRSP = 5, /* firmware enable/disable rsp */
64 BFA_FCPORT_SM_LINKUP = 6, /* firmware linkup event */
65 BFA_FCPORT_SM_LINKDOWN = 7, /* firmware linkup down */
66 BFA_FCPORT_SM_QRESUME = 8, /* CQ space available */
67 BFA_FCPORT_SM_HWFAIL = 9, /* IOC h/w failure */
68};
69
70/*
71 * BFA port link notification state machine events
72 */
73
74enum bfa_fcport_ln_sm_event {
75 BFA_FCPORT_LN_SM_LINKUP = 1, /* linkup event */
76 BFA_FCPORT_LN_SM_LINKDOWN = 2, /* linkdown event */
77 BFA_FCPORT_LN_SM_NOTIFICATION = 3 /* done notification */
78};
79
80/*
81 * RPORT related definitions
82 */
83#define bfa_rport_offline_cb(__rp) do { \
84 if ((__rp)->bfa->fcs) \
85 bfa_cb_rport_offline((__rp)->rport_drv); \
86 else { \
87 bfa_cb_queue((__rp)->bfa, &(__rp)->hcb_qe, \
88 __bfa_cb_rport_offline, (__rp)); \
89 } \
90} while (0)
91
92#define bfa_rport_online_cb(__rp) do { \
93 if ((__rp)->bfa->fcs) \
94 bfa_cb_rport_online((__rp)->rport_drv); \
95 else { \
96 bfa_cb_queue((__rp)->bfa, &(__rp)->hcb_qe, \
97 __bfa_cb_rport_online, (__rp)); \
98 } \
99} while (0)
100
101/*
102 * forward declarations FCXP related functions
103 */
104static void __bfa_fcxp_send_cbfn(void *cbarg, bfa_boolean_t complete);
105static void hal_fcxp_rx_plog(struct bfa_s *bfa, struct bfa_fcxp_s *fcxp,
106 struct bfi_fcxp_send_rsp_s *fcxp_rsp);
107static void hal_fcxp_tx_plog(struct bfa_s *bfa, u32 reqlen,
108 struct bfa_fcxp_s *fcxp, struct fchs_s *fchs);
109static void bfa_fcxp_qresume(void *cbarg);
110static void bfa_fcxp_queue(struct bfa_fcxp_s *fcxp,
111 struct bfi_fcxp_send_req_s *send_req);
112
113/*
114 * forward declarations for LPS functions
115 */
116static void bfa_lps_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len,
117 u32 *dm_len);
118static void bfa_lps_attach(struct bfa_s *bfa, void *bfad,
119 struct bfa_iocfc_cfg_s *cfg,
120 struct bfa_meminfo_s *meminfo,
121 struct bfa_pcidev_s *pcidev);
122static void bfa_lps_detach(struct bfa_s *bfa);
123static void bfa_lps_start(struct bfa_s *bfa);
124static void bfa_lps_stop(struct bfa_s *bfa);
125static void bfa_lps_iocdisable(struct bfa_s *bfa);
126static void bfa_lps_login_rsp(struct bfa_s *bfa,
127 struct bfi_lps_login_rsp_s *rsp);
128static void bfa_lps_logout_rsp(struct bfa_s *bfa,
129 struct bfi_lps_logout_rsp_s *rsp);
130static void bfa_lps_reqq_resume(void *lps_arg);
131static void bfa_lps_free(struct bfa_lps_s *lps);
132static void bfa_lps_send_login(struct bfa_lps_s *lps);
133static void bfa_lps_send_logout(struct bfa_lps_s *lps);
134static void bfa_lps_send_set_n2n_pid(struct bfa_lps_s *lps);
135static void bfa_lps_login_comp(struct bfa_lps_s *lps);
136static void bfa_lps_logout_comp(struct bfa_lps_s *lps);
137static void bfa_lps_cvl_event(struct bfa_lps_s *lps);
138
139/*
140 * forward declaration for LPS state machine
141 */
142static void bfa_lps_sm_init(struct bfa_lps_s *lps, enum bfa_lps_event event);
143static void bfa_lps_sm_login(struct bfa_lps_s *lps, enum bfa_lps_event event);
144static void bfa_lps_sm_loginwait(struct bfa_lps_s *lps, enum bfa_lps_event
145 event);
146static void bfa_lps_sm_online(struct bfa_lps_s *lps, enum bfa_lps_event event);
147static void bfa_lps_sm_online_n2n_pid_wait(struct bfa_lps_s *lps,
148 enum bfa_lps_event event);
149static void bfa_lps_sm_logout(struct bfa_lps_s *lps, enum bfa_lps_event event);
150static void bfa_lps_sm_logowait(struct bfa_lps_s *lps, enum bfa_lps_event
151 event);
152
153/*
154 * forward declaration for FC Port functions
155 */
156static bfa_boolean_t bfa_fcport_send_enable(struct bfa_fcport_s *fcport);
157static bfa_boolean_t bfa_fcport_send_disable(struct bfa_fcport_s *fcport);
158static void bfa_fcport_update_linkinfo(struct bfa_fcport_s *fcport);
159static void bfa_fcport_reset_linkinfo(struct bfa_fcport_s *fcport);
160static void bfa_fcport_set_wwns(struct bfa_fcport_s *fcport);
161static void __bfa_cb_fcport_event(void *cbarg, bfa_boolean_t complete);
162static void bfa_fcport_scn(struct bfa_fcport_s *fcport,
163 enum bfa_port_linkstate event, bfa_boolean_t trunk);
164static void bfa_fcport_queue_cb(struct bfa_fcport_ln_s *ln,
165 enum bfa_port_linkstate event);
166static void __bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete);
167static void bfa_fcport_stats_get_timeout(void *cbarg);
168static void bfa_fcport_stats_clr_timeout(void *cbarg);
169static void bfa_trunk_iocdisable(struct bfa_s *bfa);
170
171/*
172 * forward declaration for FC PORT state machine
173 */
174static void bfa_fcport_sm_uninit(struct bfa_fcport_s *fcport,
175 enum bfa_fcport_sm_event event);
176static void bfa_fcport_sm_enabling_qwait(struct bfa_fcport_s *fcport,
177 enum bfa_fcport_sm_event event);
178static void bfa_fcport_sm_enabling(struct bfa_fcport_s *fcport,
179 enum bfa_fcport_sm_event event);
180static void bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport,
181 enum bfa_fcport_sm_event event);
182static void bfa_fcport_sm_linkup(struct bfa_fcport_s *fcport,
183 enum bfa_fcport_sm_event event);
184static void bfa_fcport_sm_disabling(struct bfa_fcport_s *fcport,
185 enum bfa_fcport_sm_event event);
186static void bfa_fcport_sm_disabling_qwait(struct bfa_fcport_s *fcport,
187 enum bfa_fcport_sm_event event);
188static void bfa_fcport_sm_toggling_qwait(struct bfa_fcport_s *fcport,
189 enum bfa_fcport_sm_event event);
190static void bfa_fcport_sm_disabled(struct bfa_fcport_s *fcport,
191 enum bfa_fcport_sm_event event);
192static void bfa_fcport_sm_stopped(struct bfa_fcport_s *fcport,
193 enum bfa_fcport_sm_event event);
194static void bfa_fcport_sm_iocdown(struct bfa_fcport_s *fcport,
195 enum bfa_fcport_sm_event event);
196static void bfa_fcport_sm_iocfail(struct bfa_fcport_s *fcport,
197 enum bfa_fcport_sm_event event);
198
199static void bfa_fcport_ln_sm_dn(struct bfa_fcport_ln_s *ln,
200 enum bfa_fcport_ln_sm_event event);
201static void bfa_fcport_ln_sm_dn_nf(struct bfa_fcport_ln_s *ln,
202 enum bfa_fcport_ln_sm_event event);
203static void bfa_fcport_ln_sm_dn_up_nf(struct bfa_fcport_ln_s *ln,
204 enum bfa_fcport_ln_sm_event event);
205static void bfa_fcport_ln_sm_up(struct bfa_fcport_ln_s *ln,
206 enum bfa_fcport_ln_sm_event event);
207static void bfa_fcport_ln_sm_up_nf(struct bfa_fcport_ln_s *ln,
208 enum bfa_fcport_ln_sm_event event);
209static void bfa_fcport_ln_sm_up_dn_nf(struct bfa_fcport_ln_s *ln,
210 enum bfa_fcport_ln_sm_event event);
211static void bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln,
212 enum bfa_fcport_ln_sm_event event);
213
214static struct bfa_sm_table_s hal_port_sm_table[] = {
215 {BFA_SM(bfa_fcport_sm_uninit), BFA_PORT_ST_UNINIT},
216 {BFA_SM(bfa_fcport_sm_enabling_qwait), BFA_PORT_ST_ENABLING_QWAIT},
217 {BFA_SM(bfa_fcport_sm_enabling), BFA_PORT_ST_ENABLING},
218 {BFA_SM(bfa_fcport_sm_linkdown), BFA_PORT_ST_LINKDOWN},
219 {BFA_SM(bfa_fcport_sm_linkup), BFA_PORT_ST_LINKUP},
220 {BFA_SM(bfa_fcport_sm_disabling_qwait), BFA_PORT_ST_DISABLING_QWAIT},
221 {BFA_SM(bfa_fcport_sm_toggling_qwait), BFA_PORT_ST_TOGGLING_QWAIT},
222 {BFA_SM(bfa_fcport_sm_disabling), BFA_PORT_ST_DISABLING},
223 {BFA_SM(bfa_fcport_sm_disabled), BFA_PORT_ST_DISABLED},
224 {BFA_SM(bfa_fcport_sm_stopped), BFA_PORT_ST_STOPPED},
225 {BFA_SM(bfa_fcport_sm_iocdown), BFA_PORT_ST_IOCDOWN},
226 {BFA_SM(bfa_fcport_sm_iocfail), BFA_PORT_ST_IOCDOWN},
227};
228
229
230/*
231 * forward declaration for RPORT related functions
232 */
233static struct bfa_rport_s *bfa_rport_alloc(struct bfa_rport_mod_s *rp_mod);
234static void bfa_rport_free(struct bfa_rport_s *rport);
235static bfa_boolean_t bfa_rport_send_fwcreate(struct bfa_rport_s *rp);
236static bfa_boolean_t bfa_rport_send_fwdelete(struct bfa_rport_s *rp);
237static bfa_boolean_t bfa_rport_send_fwspeed(struct bfa_rport_s *rp);
238static void __bfa_cb_rport_online(void *cbarg,
239 bfa_boolean_t complete);
240static void __bfa_cb_rport_offline(void *cbarg,
241 bfa_boolean_t complete);
242
243/*
244 * forward declaration for RPORT state machine
245 */
246static void bfa_rport_sm_uninit(struct bfa_rport_s *rp,
247 enum bfa_rport_event event);
248static void bfa_rport_sm_created(struct bfa_rport_s *rp,
249 enum bfa_rport_event event);
250static void bfa_rport_sm_fwcreate(struct bfa_rport_s *rp,
251 enum bfa_rport_event event);
252static void bfa_rport_sm_online(struct bfa_rport_s *rp,
253 enum bfa_rport_event event);
254static void bfa_rport_sm_fwdelete(struct bfa_rport_s *rp,
255 enum bfa_rport_event event);
256static void bfa_rport_sm_offline(struct bfa_rport_s *rp,
257 enum bfa_rport_event event);
258static void bfa_rport_sm_deleting(struct bfa_rport_s *rp,
259 enum bfa_rport_event event);
260static void bfa_rport_sm_offline_pending(struct bfa_rport_s *rp,
261 enum bfa_rport_event event);
262static void bfa_rport_sm_delete_pending(struct bfa_rport_s *rp,
263 enum bfa_rport_event event);
264static void bfa_rport_sm_iocdisable(struct bfa_rport_s *rp,
265 enum bfa_rport_event event);
266static void bfa_rport_sm_fwcreate_qfull(struct bfa_rport_s *rp,
267 enum bfa_rport_event event);
268static void bfa_rport_sm_fwdelete_qfull(struct bfa_rport_s *rp,
269 enum bfa_rport_event event);
270static void bfa_rport_sm_deleting_qfull(struct bfa_rport_s *rp,
271 enum bfa_rport_event event);
272
273/*
274 * PLOG related definitions
275 */
276static int
277plkd_validate_logrec(struct bfa_plog_rec_s *pl_rec)
278{
279 if ((pl_rec->log_type != BFA_PL_LOG_TYPE_INT) &&
280 (pl_rec->log_type != BFA_PL_LOG_TYPE_STRING))
281 return 1;
282
283 if ((pl_rec->log_type != BFA_PL_LOG_TYPE_INT) &&
284 (pl_rec->log_num_ints > BFA_PL_INT_LOG_SZ))
285 return 1;
286
287 return 0;
288}
289
290static u64
291bfa_get_log_time(void)
292{
293 u64 system_time = 0;
294 struct timeval tv;
295 do_gettimeofday(&tv);
296
297 /* We are interested in seconds only. */
298 system_time = tv.tv_sec;
299 return system_time;
300}
301
302static void
303bfa_plog_add(struct bfa_plog_s *plog, struct bfa_plog_rec_s *pl_rec)
304{
305 u16 tail;
306 struct bfa_plog_rec_s *pl_recp;
307
308 if (plog->plog_enabled == 0)
309 return;
310
311 if (plkd_validate_logrec(pl_rec)) {
312 WARN_ON(1);
313 return;
314 }
315
316 tail = plog->tail;
317
318 pl_recp = &(plog->plog_recs[tail]);
319
320 memcpy(pl_recp, pl_rec, sizeof(struct bfa_plog_rec_s));
321
322 pl_recp->tv = bfa_get_log_time();
323 BFA_PL_LOG_REC_INCR(plog->tail);
324
325 if (plog->head == plog->tail)
326 BFA_PL_LOG_REC_INCR(plog->head);
327}
328
329void
330bfa_plog_init(struct bfa_plog_s *plog)
331{
332 memset((char *)plog, 0, sizeof(struct bfa_plog_s));
333
334 memcpy(plog->plog_sig, BFA_PL_SIG_STR, BFA_PL_SIG_LEN);
335 plog->head = plog->tail = 0;
336 plog->plog_enabled = 1;
337}
338
339void
340bfa_plog_str(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
341 enum bfa_plog_eid event,
342 u16 misc, char *log_str)
343{
344 struct bfa_plog_rec_s lp;
345
346 if (plog->plog_enabled) {
347 memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
348 lp.mid = mid;
349 lp.eid = event;
350 lp.log_type = BFA_PL_LOG_TYPE_STRING;
351 lp.misc = misc;
352 strncpy(lp.log_entry.string_log, log_str,
353 BFA_PL_STRING_LOG_SZ - 1);
354 lp.log_entry.string_log[BFA_PL_STRING_LOG_SZ - 1] = '\0';
355 bfa_plog_add(plog, &lp);
356 }
357}
358
359void
360bfa_plog_intarr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
361 enum bfa_plog_eid event,
362 u16 misc, u32 *intarr, u32 num_ints)
363{
364 struct bfa_plog_rec_s lp;
365 u32 i;
366
367 if (num_ints > BFA_PL_INT_LOG_SZ)
368 num_ints = BFA_PL_INT_LOG_SZ;
369
370 if (plog->plog_enabled) {
371 memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
372 lp.mid = mid;
373 lp.eid = event;
374 lp.log_type = BFA_PL_LOG_TYPE_INT;
375 lp.misc = misc;
376
377 for (i = 0; i < num_ints; i++)
378 lp.log_entry.int_log[i] = intarr[i];
379
380 lp.log_num_ints = (u8) num_ints;
381
382 bfa_plog_add(plog, &lp);
383 }
384}
385
386void
387bfa_plog_fchdr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
388 enum bfa_plog_eid event,
389 u16 misc, struct fchs_s *fchdr)
390{
391 struct bfa_plog_rec_s lp;
392 u32 *tmp_int = (u32 *) fchdr;
393 u32 ints[BFA_PL_INT_LOG_SZ];
394
395 if (plog->plog_enabled) {
396 memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
397
398 ints[0] = tmp_int[0];
399 ints[1] = tmp_int[1];
400 ints[2] = tmp_int[4];
401
402 bfa_plog_intarr(plog, mid, event, misc, ints, 3);
403 }
404}
405
406void
407bfa_plog_fchdr_and_pl(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
408 enum bfa_plog_eid event, u16 misc, struct fchs_s *fchdr,
409 u32 pld_w0)
410{
411 struct bfa_plog_rec_s lp;
412 u32 *tmp_int = (u32 *) fchdr;
413 u32 ints[BFA_PL_INT_LOG_SZ];
414
415 if (plog->plog_enabled) {
416 memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
417
418 ints[0] = tmp_int[0];
419 ints[1] = tmp_int[1];
420 ints[2] = tmp_int[4];
421 ints[3] = pld_w0;
422
423 bfa_plog_intarr(plog, mid, event, misc, ints, 4);
424 }
425}
426
427
428/*
429 * fcxp_pvt BFA FCXP private functions
430 */
431
432static void
433claim_fcxp_req_rsp_mem(struct bfa_fcxp_mod_s *mod, struct bfa_meminfo_s *mi)
434{
435 u8 *dm_kva = NULL;
436 u64 dm_pa;
437 u32 buf_pool_sz;
438
439 dm_kva = bfa_meminfo_dma_virt(mi);
440 dm_pa = bfa_meminfo_dma_phys(mi);
441
442 buf_pool_sz = mod->req_pld_sz * mod->num_fcxps;
443
444 /*
445 * Initialize the fcxp req payload list
446 */
447 mod->req_pld_list_kva = dm_kva;
448 mod->req_pld_list_pa = dm_pa;
449 dm_kva += buf_pool_sz;
450 dm_pa += buf_pool_sz;
451 memset(mod->req_pld_list_kva, 0, buf_pool_sz);
452
453 /*
454 * Initialize the fcxp rsp payload list
455 */
456 buf_pool_sz = mod->rsp_pld_sz * mod->num_fcxps;
457 mod->rsp_pld_list_kva = dm_kva;
458 mod->rsp_pld_list_pa = dm_pa;
459 dm_kva += buf_pool_sz;
460 dm_pa += buf_pool_sz;
461 memset(mod->rsp_pld_list_kva, 0, buf_pool_sz);
462
463 bfa_meminfo_dma_virt(mi) = dm_kva;
464 bfa_meminfo_dma_phys(mi) = dm_pa;
465}
466
467static void
468claim_fcxps_mem(struct bfa_fcxp_mod_s *mod, struct bfa_meminfo_s *mi)
469{
470 u16 i;
471 struct bfa_fcxp_s *fcxp;
472
473 fcxp = (struct bfa_fcxp_s *) bfa_meminfo_kva(mi);
474 memset(fcxp, 0, sizeof(struct bfa_fcxp_s) * mod->num_fcxps);
475
476 INIT_LIST_HEAD(&mod->fcxp_free_q);
477 INIT_LIST_HEAD(&mod->fcxp_active_q);
478
479 mod->fcxp_list = fcxp;
480
481 for (i = 0; i < mod->num_fcxps; i++) {
482 fcxp->fcxp_mod = mod;
483 fcxp->fcxp_tag = i;
484
485 list_add_tail(&fcxp->qe, &mod->fcxp_free_q);
486 bfa_reqq_winit(&fcxp->reqq_wqe, bfa_fcxp_qresume, fcxp);
487 fcxp->reqq_waiting = BFA_FALSE;
488
489 fcxp = fcxp + 1;
490 }
491
492 bfa_meminfo_kva(mi) = (void *)fcxp;
493}
494
495static void
496bfa_fcxp_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len,
497 u32 *dm_len)
498{
499 u16 num_fcxp_reqs = cfg->fwcfg.num_fcxp_reqs;
500
501 if (num_fcxp_reqs == 0)
502 return;
503
504 /*
505 * Account for req/rsp payload
506 */
507 *dm_len += BFA_FCXP_MAX_IBUF_SZ * num_fcxp_reqs;
508 if (cfg->drvcfg.min_cfg)
509 *dm_len += BFA_FCXP_MAX_IBUF_SZ * num_fcxp_reqs;
510 else
511 *dm_len += BFA_FCXP_MAX_LBUF_SZ * num_fcxp_reqs;
512
513 /*
514 * Account for fcxp structs
515 */
516 *ndm_len += sizeof(struct bfa_fcxp_s) * num_fcxp_reqs;
517}
518
519static void
520bfa_fcxp_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
521 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
522{
523 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
524
525 memset(mod, 0, sizeof(struct bfa_fcxp_mod_s));
526 mod->bfa = bfa;
527 mod->num_fcxps = cfg->fwcfg.num_fcxp_reqs;
528
529 /*
530 * Initialize FCXP request and response payload sizes.
531 */
532 mod->req_pld_sz = mod->rsp_pld_sz = BFA_FCXP_MAX_IBUF_SZ;
533 if (!cfg->drvcfg.min_cfg)
534 mod->rsp_pld_sz = BFA_FCXP_MAX_LBUF_SZ;
535
536 INIT_LIST_HEAD(&mod->wait_q);
537
538 claim_fcxp_req_rsp_mem(mod, meminfo);
539 claim_fcxps_mem(mod, meminfo);
540}
541
542static void
543bfa_fcxp_detach(struct bfa_s *bfa)
544{
545}
546
547static void
548bfa_fcxp_start(struct bfa_s *bfa)
549{
550}
551
552static void
553bfa_fcxp_stop(struct bfa_s *bfa)
554{
555}
556
557static void
558bfa_fcxp_iocdisable(struct bfa_s *bfa)
559{
560 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
561 struct bfa_fcxp_s *fcxp;
562 struct list_head *qe, *qen;
563
564 list_for_each_safe(qe, qen, &mod->fcxp_active_q) {
565 fcxp = (struct bfa_fcxp_s *) qe;
566 if (fcxp->caller == NULL) {
567 fcxp->send_cbfn(fcxp->caller, fcxp, fcxp->send_cbarg,
568 BFA_STATUS_IOC_FAILURE, 0, 0, NULL);
569 bfa_fcxp_free(fcxp);
570 } else {
571 fcxp->rsp_status = BFA_STATUS_IOC_FAILURE;
572 bfa_cb_queue(bfa, &fcxp->hcb_qe,
573 __bfa_fcxp_send_cbfn, fcxp);
574 }
575 }
576}
577
578static struct bfa_fcxp_s *
579bfa_fcxp_get(struct bfa_fcxp_mod_s *fm)
580{
581 struct bfa_fcxp_s *fcxp;
582
583 bfa_q_deq(&fm->fcxp_free_q, &fcxp);
584
585 if (fcxp)
586 list_add_tail(&fcxp->qe, &fm->fcxp_active_q);
587
588 return fcxp;
589}
590
591static void
592bfa_fcxp_init_reqrsp(struct bfa_fcxp_s *fcxp,
593 struct bfa_s *bfa,
594 u8 *use_ibuf,
595 u32 *nr_sgles,
596 bfa_fcxp_get_sgaddr_t *r_sga_cbfn,
597 bfa_fcxp_get_sglen_t *r_sglen_cbfn,
598 struct list_head *r_sgpg_q,
599 int n_sgles,
600 bfa_fcxp_get_sgaddr_t sga_cbfn,
601 bfa_fcxp_get_sglen_t sglen_cbfn)
602{
603
604 WARN_ON(bfa == NULL);
605
606 bfa_trc(bfa, fcxp->fcxp_tag);
607
608 if (n_sgles == 0) {
609 *use_ibuf = 1;
610 } else {
611 WARN_ON(*sga_cbfn == NULL);
612 WARN_ON(*sglen_cbfn == NULL);
613
614 *use_ibuf = 0;
615 *r_sga_cbfn = sga_cbfn;
616 *r_sglen_cbfn = sglen_cbfn;
617
618 *nr_sgles = n_sgles;
619
620 /*
621 * alloc required sgpgs
622 */
623 if (n_sgles > BFI_SGE_INLINE)
624 WARN_ON(1);
625 }
626
627}
628
629static void
630bfa_fcxp_init(struct bfa_fcxp_s *fcxp,
631 void *caller, struct bfa_s *bfa, int nreq_sgles,
632 int nrsp_sgles, bfa_fcxp_get_sgaddr_t req_sga_cbfn,
633 bfa_fcxp_get_sglen_t req_sglen_cbfn,
634 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn,
635 bfa_fcxp_get_sglen_t rsp_sglen_cbfn)
636{
637
638 WARN_ON(bfa == NULL);
639
640 bfa_trc(bfa, fcxp->fcxp_tag);
641
642 fcxp->caller = caller;
643
644 bfa_fcxp_init_reqrsp(fcxp, bfa,
645 &fcxp->use_ireqbuf, &fcxp->nreq_sgles, &fcxp->req_sga_cbfn,
646 &fcxp->req_sglen_cbfn, &fcxp->req_sgpg_q,
647 nreq_sgles, req_sga_cbfn, req_sglen_cbfn);
648
649 bfa_fcxp_init_reqrsp(fcxp, bfa,
650 &fcxp->use_irspbuf, &fcxp->nrsp_sgles, &fcxp->rsp_sga_cbfn,
651 &fcxp->rsp_sglen_cbfn, &fcxp->rsp_sgpg_q,
652 nrsp_sgles, rsp_sga_cbfn, rsp_sglen_cbfn);
653
654}
655
656static void
657bfa_fcxp_put(struct bfa_fcxp_s *fcxp)
658{
659 struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
660 struct bfa_fcxp_wqe_s *wqe;
661
662 bfa_q_deq(&mod->wait_q, &wqe);
663 if (wqe) {
664 bfa_trc(mod->bfa, fcxp->fcxp_tag);
665
666 bfa_fcxp_init(fcxp, wqe->caller, wqe->bfa, wqe->nreq_sgles,
667 wqe->nrsp_sgles, wqe->req_sga_cbfn,
668 wqe->req_sglen_cbfn, wqe->rsp_sga_cbfn,
669 wqe->rsp_sglen_cbfn);
670
671 wqe->alloc_cbfn(wqe->alloc_cbarg, fcxp);
672 return;
673 }
674
675 WARN_ON(!bfa_q_is_on_q(&mod->fcxp_active_q, fcxp));
676 list_del(&fcxp->qe);
677 list_add_tail(&fcxp->qe, &mod->fcxp_free_q);
678}
679
680static void
681bfa_fcxp_null_comp(void *bfad_fcxp, struct bfa_fcxp_s *fcxp, void *cbarg,
682 bfa_status_t req_status, u32 rsp_len,
683 u32 resid_len, struct fchs_s *rsp_fchs)
684{
685 /* discarded fcxp completion */
686}
687
688static void
689__bfa_fcxp_send_cbfn(void *cbarg, bfa_boolean_t complete)
690{
691 struct bfa_fcxp_s *fcxp = cbarg;
692
693 if (complete) {
694 fcxp->send_cbfn(fcxp->caller, fcxp, fcxp->send_cbarg,
695 fcxp->rsp_status, fcxp->rsp_len,
696 fcxp->residue_len, &fcxp->rsp_fchs);
697 } else {
698 bfa_fcxp_free(fcxp);
699 }
700}
701
702static void
703hal_fcxp_send_comp(struct bfa_s *bfa, struct bfi_fcxp_send_rsp_s *fcxp_rsp)
704{
705 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
706 struct bfa_fcxp_s *fcxp;
707 u16 fcxp_tag = be16_to_cpu(fcxp_rsp->fcxp_tag);
708
709 bfa_trc(bfa, fcxp_tag);
710
711 fcxp_rsp->rsp_len = be32_to_cpu(fcxp_rsp->rsp_len);
712
713 /*
714 * @todo f/w should not set residue to non-0 when everything
715 * is received.
716 */
717 if (fcxp_rsp->req_status == BFA_STATUS_OK)
718 fcxp_rsp->residue_len = 0;
719 else
720 fcxp_rsp->residue_len = be32_to_cpu(fcxp_rsp->residue_len);
721
722 fcxp = BFA_FCXP_FROM_TAG(mod, fcxp_tag);
723
724 WARN_ON(fcxp->send_cbfn == NULL);
725
726 hal_fcxp_rx_plog(mod->bfa, fcxp, fcxp_rsp);
727
728 if (fcxp->send_cbfn != NULL) {
729 bfa_trc(mod->bfa, (NULL == fcxp->caller));
730 if (fcxp->caller == NULL) {
731 fcxp->send_cbfn(fcxp->caller, fcxp, fcxp->send_cbarg,
732 fcxp_rsp->req_status, fcxp_rsp->rsp_len,
733 fcxp_rsp->residue_len, &fcxp_rsp->fchs);
734 /*
735 * fcxp automatically freed on return from the callback
736 */
737 bfa_fcxp_free(fcxp);
738 } else {
739 fcxp->rsp_status = fcxp_rsp->req_status;
740 fcxp->rsp_len = fcxp_rsp->rsp_len;
741 fcxp->residue_len = fcxp_rsp->residue_len;
742 fcxp->rsp_fchs = fcxp_rsp->fchs;
743
744 bfa_cb_queue(bfa, &fcxp->hcb_qe,
745 __bfa_fcxp_send_cbfn, fcxp);
746 }
747 } else {
748 bfa_trc(bfa, (NULL == fcxp->send_cbfn));
749 }
750}
751
752static void
753hal_fcxp_set_local_sges(struct bfi_sge_s *sge, u32 reqlen, u64 req_pa)
754{
755 union bfi_addr_u sga_zero = { {0} };
756
757 sge->sg_len = reqlen;
758 sge->flags = BFI_SGE_DATA_LAST;
759 bfa_dma_addr_set(sge[0].sga, req_pa);
760 bfa_sge_to_be(sge);
761 sge++;
762
763 sge->sga = sga_zero;
764 sge->sg_len = reqlen;
765 sge->flags = BFI_SGE_PGDLEN;
766 bfa_sge_to_be(sge);
767}
768
769static void
770hal_fcxp_tx_plog(struct bfa_s *bfa, u32 reqlen, struct bfa_fcxp_s *fcxp,
771 struct fchs_s *fchs)
772{
773 /*
774 * TODO: TX ox_id
775 */
776 if (reqlen > 0) {
777 if (fcxp->use_ireqbuf) {
778 u32 pld_w0 =
779 *((u32 *) BFA_FCXP_REQ_PLD(fcxp));
780
781 bfa_plog_fchdr_and_pl(bfa->plog, BFA_PL_MID_HAL_FCXP,
782 BFA_PL_EID_TX,
783 reqlen + sizeof(struct fchs_s), fchs,
784 pld_w0);
785 } else {
786 bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP,
787 BFA_PL_EID_TX,
788 reqlen + sizeof(struct fchs_s),
789 fchs);
790 }
791 } else {
792 bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP, BFA_PL_EID_TX,
793 reqlen + sizeof(struct fchs_s), fchs);
794 }
795}
796
797static void
798hal_fcxp_rx_plog(struct bfa_s *bfa, struct bfa_fcxp_s *fcxp,
799 struct bfi_fcxp_send_rsp_s *fcxp_rsp)
800{
801 if (fcxp_rsp->rsp_len > 0) {
802 if (fcxp->use_irspbuf) {
803 u32 pld_w0 =
804 *((u32 *) BFA_FCXP_RSP_PLD(fcxp));
805
806 bfa_plog_fchdr_and_pl(bfa->plog, BFA_PL_MID_HAL_FCXP,
807 BFA_PL_EID_RX,
808 (u16) fcxp_rsp->rsp_len,
809 &fcxp_rsp->fchs, pld_w0);
810 } else {
811 bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP,
812 BFA_PL_EID_RX,
813 (u16) fcxp_rsp->rsp_len,
814 &fcxp_rsp->fchs);
815 }
816 } else {
817 bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_FCXP, BFA_PL_EID_RX,
818 (u16) fcxp_rsp->rsp_len, &fcxp_rsp->fchs);
819 }
820}
821
822/*
823 * Handler to resume sending fcxp when space in available in cpe queue.
824 */
825static void
826bfa_fcxp_qresume(void *cbarg)
827{
828 struct bfa_fcxp_s *fcxp = cbarg;
829 struct bfa_s *bfa = fcxp->fcxp_mod->bfa;
830 struct bfi_fcxp_send_req_s *send_req;
831
832 fcxp->reqq_waiting = BFA_FALSE;
833 send_req = bfa_reqq_next(bfa, BFA_REQQ_FCXP);
834 bfa_fcxp_queue(fcxp, send_req);
835}
836
837/*
838 * Queue fcxp send request to foimrware.
839 */
840static void
841bfa_fcxp_queue(struct bfa_fcxp_s *fcxp, struct bfi_fcxp_send_req_s *send_req)
842{
843 struct bfa_s *bfa = fcxp->fcxp_mod->bfa;
844 struct bfa_fcxp_req_info_s *reqi = &fcxp->req_info;
845 struct bfa_fcxp_rsp_info_s *rspi = &fcxp->rsp_info;
846 struct bfa_rport_s *rport = reqi->bfa_rport;
847
848 bfi_h2i_set(send_req->mh, BFI_MC_FCXP, BFI_FCXP_H2I_SEND_REQ,
849 bfa_lpuid(bfa));
850
851 send_req->fcxp_tag = cpu_to_be16(fcxp->fcxp_tag);
852 if (rport) {
853 send_req->rport_fw_hndl = rport->fw_handle;
854 send_req->max_frmsz = cpu_to_be16(rport->rport_info.max_frmsz);
855 if (send_req->max_frmsz == 0)
856 send_req->max_frmsz = cpu_to_be16(FC_MAX_PDUSZ);
857 } else {
858 send_req->rport_fw_hndl = 0;
859 send_req->max_frmsz = cpu_to_be16(FC_MAX_PDUSZ);
860 }
861
862 send_req->vf_id = cpu_to_be16(reqi->vf_id);
863 send_req->lp_tag = reqi->lp_tag;
864 send_req->class = reqi->class;
865 send_req->rsp_timeout = rspi->rsp_timeout;
866 send_req->cts = reqi->cts;
867 send_req->fchs = reqi->fchs;
868
869 send_req->req_len = cpu_to_be32(reqi->req_tot_len);
870 send_req->rsp_maxlen = cpu_to_be32(rspi->rsp_maxlen);
871
872 /*
873 * setup req sgles
874 */
875 if (fcxp->use_ireqbuf == 1) {
876 hal_fcxp_set_local_sges(send_req->req_sge, reqi->req_tot_len,
877 BFA_FCXP_REQ_PLD_PA(fcxp));
878 } else {
879 if (fcxp->nreq_sgles > 0) {
880 WARN_ON(fcxp->nreq_sgles != 1);
881 hal_fcxp_set_local_sges(send_req->req_sge,
882 reqi->req_tot_len,
883 fcxp->req_sga_cbfn(fcxp->caller,
884 0));
885 } else {
886 WARN_ON(reqi->req_tot_len != 0);
887 hal_fcxp_set_local_sges(send_req->rsp_sge, 0, 0);
888 }
889 }
890
891 /*
892 * setup rsp sgles
893 */
894 if (fcxp->use_irspbuf == 1) {
895 WARN_ON(rspi->rsp_maxlen > BFA_FCXP_MAX_LBUF_SZ);
896
897 hal_fcxp_set_local_sges(send_req->rsp_sge, rspi->rsp_maxlen,
898 BFA_FCXP_RSP_PLD_PA(fcxp));
899
900 } else {
901 if (fcxp->nrsp_sgles > 0) {
902 WARN_ON(fcxp->nrsp_sgles != 1);
903 hal_fcxp_set_local_sges(send_req->rsp_sge,
904 rspi->rsp_maxlen,
905 fcxp->rsp_sga_cbfn(fcxp->caller,
906 0));
907 } else {
908 WARN_ON(rspi->rsp_maxlen != 0);
909 hal_fcxp_set_local_sges(send_req->rsp_sge, 0, 0);
910 }
911 }
912
913 hal_fcxp_tx_plog(bfa, reqi->req_tot_len, fcxp, &reqi->fchs);
914
915 bfa_reqq_produce(bfa, BFA_REQQ_FCXP);
916
917 bfa_trc(bfa, bfa_reqq_pi(bfa, BFA_REQQ_FCXP));
918 bfa_trc(bfa, bfa_reqq_ci(bfa, BFA_REQQ_FCXP));
919}
920
921/*
922 * Allocate an FCXP instance to send a response or to send a request
923 * that has a response. Request/response buffers are allocated by caller.
924 *
925 * @param[in] bfa BFA bfa instance
926 * @param[in] nreq_sgles Number of SG elements required for request
927 * buffer. 0, if fcxp internal buffers are used.
928 * Use bfa_fcxp_get_reqbuf() to get the
929 * internal req buffer.
930 * @param[in] req_sgles SG elements describing request buffer. Will be
931 * copied in by BFA and hence can be freed on
932 * return from this function.
933 * @param[in] get_req_sga function ptr to be called to get a request SG
934 * Address (given the sge index).
935 * @param[in] get_req_sglen function ptr to be called to get a request SG
936 * len (given the sge index).
937 * @param[in] get_rsp_sga function ptr to be called to get a response SG
938 * Address (given the sge index).
939 * @param[in] get_rsp_sglen function ptr to be called to get a response SG
940 * len (given the sge index).
941 *
942 * @return FCXP instance. NULL on failure.
943 */
944struct bfa_fcxp_s *
945bfa_fcxp_alloc(void *caller, struct bfa_s *bfa, int nreq_sgles,
946 int nrsp_sgles, bfa_fcxp_get_sgaddr_t req_sga_cbfn,
947 bfa_fcxp_get_sglen_t req_sglen_cbfn,
948 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn,
949 bfa_fcxp_get_sglen_t rsp_sglen_cbfn)
950{
951 struct bfa_fcxp_s *fcxp = NULL;
952
953 WARN_ON(bfa == NULL);
954
955 fcxp = bfa_fcxp_get(BFA_FCXP_MOD(bfa));
956 if (fcxp == NULL)
957 return NULL;
958
959 bfa_trc(bfa, fcxp->fcxp_tag);
960
961 bfa_fcxp_init(fcxp, caller, bfa, nreq_sgles, nrsp_sgles, req_sga_cbfn,
962 req_sglen_cbfn, rsp_sga_cbfn, rsp_sglen_cbfn);
963
964 return fcxp;
965}
966
967/*
968 * Get the internal request buffer pointer
969 *
970 * @param[in] fcxp BFA fcxp pointer
971 *
972 * @return pointer to the internal request buffer
973 */
974void *
975bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp)
976{
977 struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
978 void *reqbuf;
979
980 WARN_ON(fcxp->use_ireqbuf != 1);
981 reqbuf = ((u8 *)mod->req_pld_list_kva) +
982 fcxp->fcxp_tag * mod->req_pld_sz;
983 return reqbuf;
984}
985
986u32
987bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp)
988{
989 struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
990
991 return mod->req_pld_sz;
992}
993
994/*
995 * Get the internal response buffer pointer
996 *
997 * @param[in] fcxp BFA fcxp pointer
998 *
999 * @return pointer to the internal request buffer
1000 */
1001void *
1002bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp)
1003{
1004 struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
1005 void *rspbuf;
1006
1007 WARN_ON(fcxp->use_irspbuf != 1);
1008
1009 rspbuf = ((u8 *)mod->rsp_pld_list_kva) +
1010 fcxp->fcxp_tag * mod->rsp_pld_sz;
1011 return rspbuf;
1012}
1013
1014/*
1015 * Free the BFA FCXP
1016 *
1017 * @param[in] fcxp BFA fcxp pointer
1018 *
1019 * @return void
1020 */
1021void
1022bfa_fcxp_free(struct bfa_fcxp_s *fcxp)
1023{
1024 struct bfa_fcxp_mod_s *mod = fcxp->fcxp_mod;
1025
1026 WARN_ON(fcxp == NULL);
1027 bfa_trc(mod->bfa, fcxp->fcxp_tag);
1028 bfa_fcxp_put(fcxp);
1029}
1030
1031/*
1032 * Send a FCXP request
1033 *
1034 * @param[in] fcxp BFA fcxp pointer
1035 * @param[in] rport BFA rport pointer. Could be left NULL for WKA rports
1036 * @param[in] vf_id virtual Fabric ID
1037 * @param[in] lp_tag lport tag
1038 * @param[in] cts use Continuous sequence
1039 * @param[in] cos fc Class of Service
1040 * @param[in] reqlen request length, does not include FCHS length
1041 * @param[in] fchs fc Header Pointer. The header content will be copied
1042 * in by BFA.
1043 *
1044 * @param[in] cbfn call back function to be called on receiving
1045 * the response
1046 * @param[in] cbarg arg for cbfn
1047 * @param[in] rsp_timeout
1048 * response timeout
1049 *
1050 * @return bfa_status_t
1051 */
1052void
1053bfa_fcxp_send(struct bfa_fcxp_s *fcxp, struct bfa_rport_s *rport,
1054 u16 vf_id, u8 lp_tag, bfa_boolean_t cts, enum fc_cos cos,
1055 u32 reqlen, struct fchs_s *fchs, bfa_cb_fcxp_send_t cbfn,
1056 void *cbarg, u32 rsp_maxlen, u8 rsp_timeout)
1057{
1058 struct bfa_s *bfa = fcxp->fcxp_mod->bfa;
1059 struct bfa_fcxp_req_info_s *reqi = &fcxp->req_info;
1060 struct bfa_fcxp_rsp_info_s *rspi = &fcxp->rsp_info;
1061 struct bfi_fcxp_send_req_s *send_req;
1062
1063 bfa_trc(bfa, fcxp->fcxp_tag);
1064
1065 /*
1066 * setup request/response info
1067 */
1068 reqi->bfa_rport = rport;
1069 reqi->vf_id = vf_id;
1070 reqi->lp_tag = lp_tag;
1071 reqi->class = cos;
1072 rspi->rsp_timeout = rsp_timeout;
1073 reqi->cts = cts;
1074 reqi->fchs = *fchs;
1075 reqi->req_tot_len = reqlen;
1076 rspi->rsp_maxlen = rsp_maxlen;
1077 fcxp->send_cbfn = cbfn ? cbfn : bfa_fcxp_null_comp;
1078 fcxp->send_cbarg = cbarg;
1079
1080 /*
1081 * If no room in CPE queue, wait for space in request queue
1082 */
1083 send_req = bfa_reqq_next(bfa, BFA_REQQ_FCXP);
1084 if (!send_req) {
1085 bfa_trc(bfa, fcxp->fcxp_tag);
1086 fcxp->reqq_waiting = BFA_TRUE;
1087 bfa_reqq_wait(bfa, BFA_REQQ_FCXP, &fcxp->reqq_wqe);
1088 return;
1089 }
1090
1091 bfa_fcxp_queue(fcxp, send_req);
1092}
1093
1094/*
1095 * Abort a BFA FCXP
1096 *
1097 * @param[in] fcxp BFA fcxp pointer
1098 *
1099 * @return void
1100 */
1101bfa_status_t
1102bfa_fcxp_abort(struct bfa_fcxp_s *fcxp)
1103{
1104 bfa_trc(fcxp->fcxp_mod->bfa, fcxp->fcxp_tag);
1105 WARN_ON(1);
1106 return BFA_STATUS_OK;
1107}
1108
1109void
1110bfa_fcxp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
1111 bfa_fcxp_alloc_cbfn_t alloc_cbfn, void *alloc_cbarg,
1112 void *caller, int nreq_sgles,
1113 int nrsp_sgles, bfa_fcxp_get_sgaddr_t req_sga_cbfn,
1114 bfa_fcxp_get_sglen_t req_sglen_cbfn,
1115 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn,
1116 bfa_fcxp_get_sglen_t rsp_sglen_cbfn)
1117{
1118 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
1119
1120 WARN_ON(!list_empty(&mod->fcxp_free_q));
1121
1122 wqe->alloc_cbfn = alloc_cbfn;
1123 wqe->alloc_cbarg = alloc_cbarg;
1124 wqe->caller = caller;
1125 wqe->bfa = bfa;
1126 wqe->nreq_sgles = nreq_sgles;
1127 wqe->nrsp_sgles = nrsp_sgles;
1128 wqe->req_sga_cbfn = req_sga_cbfn;
1129 wqe->req_sglen_cbfn = req_sglen_cbfn;
1130 wqe->rsp_sga_cbfn = rsp_sga_cbfn;
1131 wqe->rsp_sglen_cbfn = rsp_sglen_cbfn;
1132
1133 list_add_tail(&wqe->qe, &mod->wait_q);
1134}
1135
1136void
1137bfa_fcxp_walloc_cancel(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe)
1138{
1139 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
1140
1141 WARN_ON(!bfa_q_is_on_q(&mod->wait_q, wqe));
1142 list_del(&wqe->qe);
1143}
1144
1145void
1146bfa_fcxp_discard(struct bfa_fcxp_s *fcxp)
1147{
1148 /*
1149 * If waiting for room in request queue, cancel reqq wait
1150 * and free fcxp.
1151 */
1152 if (fcxp->reqq_waiting) {
1153 fcxp->reqq_waiting = BFA_FALSE;
1154 bfa_reqq_wcancel(&fcxp->reqq_wqe);
1155 bfa_fcxp_free(fcxp);
1156 return;
1157 }
1158
1159 fcxp->send_cbfn = bfa_fcxp_null_comp;
1160}
1161
1162void
1163bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
1164{
1165 switch (msg->mhdr.msg_id) {
1166 case BFI_FCXP_I2H_SEND_RSP:
1167 hal_fcxp_send_comp(bfa, (struct bfi_fcxp_send_rsp_s *) msg);
1168 break;
1169
1170 default:
1171 bfa_trc(bfa, msg->mhdr.msg_id);
1172 WARN_ON(1);
1173 }
1174}
1175
1176u32
1177bfa_fcxp_get_maxrsp(struct bfa_s *bfa)
1178{
1179 struct bfa_fcxp_mod_s *mod = BFA_FCXP_MOD(bfa);
1180
1181 return mod->rsp_pld_sz;
1182}
1183
1184
1185/*
1186 * BFA LPS state machine functions
1187 */
1188
1189/*
1190 * Init state -- no login
1191 */
1192static void
1193bfa_lps_sm_init(struct bfa_lps_s *lps, enum bfa_lps_event event)
1194{
1195 bfa_trc(lps->bfa, lps->lp_tag);
1196 bfa_trc(lps->bfa, event);
1197
1198 switch (event) {
1199 case BFA_LPS_SM_LOGIN:
1200 if (bfa_reqq_full(lps->bfa, lps->reqq)) {
1201 bfa_sm_set_state(lps, bfa_lps_sm_loginwait);
1202 bfa_reqq_wait(lps->bfa, lps->reqq, &lps->wqe);
1203 } else {
1204 bfa_sm_set_state(lps, bfa_lps_sm_login);
1205 bfa_lps_send_login(lps);
1206 }
1207
1208 if (lps->fdisc)
1209 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
1210 BFA_PL_EID_LOGIN, 0, "FDISC Request");
1211 else
1212 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
1213 BFA_PL_EID_LOGIN, 0, "FLOGI Request");
1214 break;
1215
1216 case BFA_LPS_SM_LOGOUT:
1217 bfa_lps_logout_comp(lps);
1218 break;
1219
1220 case BFA_LPS_SM_DELETE:
1221 bfa_lps_free(lps);
1222 break;
1223
1224 case BFA_LPS_SM_RX_CVL:
1225 case BFA_LPS_SM_OFFLINE:
1226 break;
1227
1228 case BFA_LPS_SM_FWRSP:
1229 /*
1230 * Could happen when fabric detects loopback and discards
1231 * the lps request. Fw will eventually sent out the timeout
1232 * Just ignore
1233 */
1234 break;
1235
1236 default:
1237 bfa_sm_fault(lps->bfa, event);
1238 }
1239}
1240
1241/*
1242 * login is in progress -- awaiting response from firmware
1243 */
1244static void
1245bfa_lps_sm_login(struct bfa_lps_s *lps, enum bfa_lps_event event)
1246{
1247 bfa_trc(lps->bfa, lps->lp_tag);
1248 bfa_trc(lps->bfa, event);
1249
1250 switch (event) {
1251 case BFA_LPS_SM_FWRSP:
1252 if (lps->status == BFA_STATUS_OK) {
1253 bfa_sm_set_state(lps, bfa_lps_sm_online);
1254 if (lps->fdisc)
1255 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
1256 BFA_PL_EID_LOGIN, 0, "FDISC Accept");
1257 else
1258 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
1259 BFA_PL_EID_LOGIN, 0, "FLOGI Accept");
1260 /* If N2N, send the assigned PID to FW */
1261 bfa_trc(lps->bfa, lps->fport);
1262 bfa_trc(lps->bfa, lps->lp_pid);
1263
1264 if (!lps->fport && lps->lp_pid)
1265 bfa_sm_send_event(lps, BFA_LPS_SM_SET_N2N_PID);
1266 } else {
1267 bfa_sm_set_state(lps, bfa_lps_sm_init);
1268 if (lps->fdisc)
1269 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
1270 BFA_PL_EID_LOGIN, 0,
1271 "FDISC Fail (RJT or timeout)");
1272 else
1273 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
1274 BFA_PL_EID_LOGIN, 0,
1275 "FLOGI Fail (RJT or timeout)");
1276 }
1277 bfa_lps_login_comp(lps);
1278 break;
1279
1280 case BFA_LPS_SM_OFFLINE:
1281 bfa_sm_set_state(lps, bfa_lps_sm_init);
1282 break;
1283
1284 case BFA_LPS_SM_SET_N2N_PID:
1285 bfa_trc(lps->bfa, lps->fport);
1286 bfa_trc(lps->bfa, lps->lp_pid);
1287 break;
1288
1289 default:
1290 bfa_sm_fault(lps->bfa, event);
1291 }
1292}
1293
1294/*
1295 * login pending - awaiting space in request queue
1296 */
1297static void
1298bfa_lps_sm_loginwait(struct bfa_lps_s *lps, enum bfa_lps_event event)
1299{
1300 bfa_trc(lps->bfa, lps->lp_tag);
1301 bfa_trc(lps->bfa, event);
1302
1303 switch (event) {
1304 case BFA_LPS_SM_RESUME:
1305 bfa_sm_set_state(lps, bfa_lps_sm_login);
1306 break;
1307
1308 case BFA_LPS_SM_OFFLINE:
1309 bfa_sm_set_state(lps, bfa_lps_sm_init);
1310 bfa_reqq_wcancel(&lps->wqe);
1311 break;
1312
1313 case BFA_LPS_SM_RX_CVL:
1314 /*
1315 * Login was not even sent out; so when getting out
1316 * of this state, it will appear like a login retry
1317 * after Clear virtual link
1318 */
1319 break;
1320
1321 default:
1322 bfa_sm_fault(lps->bfa, event);
1323 }
1324}
1325
1326/*
1327 * login complete
1328 */
1329static void
1330bfa_lps_sm_online(struct bfa_lps_s *lps, enum bfa_lps_event event)
1331{
1332 bfa_trc(lps->bfa, lps->lp_tag);
1333 bfa_trc(lps->bfa, event);
1334
1335 switch (event) {
1336 case BFA_LPS_SM_LOGOUT:
1337 if (bfa_reqq_full(lps->bfa, lps->reqq)) {
1338 bfa_sm_set_state(lps, bfa_lps_sm_logowait);
1339 bfa_reqq_wait(lps->bfa, lps->reqq, &lps->wqe);
1340 } else {
1341 bfa_sm_set_state(lps, bfa_lps_sm_logout);
1342 bfa_lps_send_logout(lps);
1343 }
1344 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
1345 BFA_PL_EID_LOGO, 0, "Logout");
1346 break;
1347
1348 case BFA_LPS_SM_RX_CVL:
1349 bfa_sm_set_state(lps, bfa_lps_sm_init);
1350
1351 /* Let the vport module know about this event */
1352 bfa_lps_cvl_event(lps);
1353 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
1354 BFA_PL_EID_FIP_FCF_CVL, 0, "FCF Clear Virt. Link Rx");
1355 break;
1356
1357 case BFA_LPS_SM_SET_N2N_PID:
1358 if (bfa_reqq_full(lps->bfa, lps->reqq)) {
1359 bfa_sm_set_state(lps, bfa_lps_sm_online_n2n_pid_wait);
1360 bfa_reqq_wait(lps->bfa, lps->reqq, &lps->wqe);
1361 } else
1362 bfa_lps_send_set_n2n_pid(lps);
1363 break;
1364
1365 case BFA_LPS_SM_OFFLINE:
1366 case BFA_LPS_SM_DELETE:
1367 bfa_sm_set_state(lps, bfa_lps_sm_init);
1368 break;
1369
1370 default:
1371 bfa_sm_fault(lps->bfa, event);
1372 }
1373}
1374
1375/*
1376 * login complete
1377 */
1378static void
1379bfa_lps_sm_online_n2n_pid_wait(struct bfa_lps_s *lps, enum bfa_lps_event event)
1380{
1381 bfa_trc(lps->bfa, lps->lp_tag);
1382 bfa_trc(lps->bfa, event);
1383
1384 switch (event) {
1385 case BFA_LPS_SM_RESUME:
1386 bfa_sm_set_state(lps, bfa_lps_sm_online);
1387 bfa_lps_send_set_n2n_pid(lps);
1388 break;
1389
1390 case BFA_LPS_SM_LOGOUT:
1391 bfa_sm_set_state(lps, bfa_lps_sm_logowait);
1392 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
1393 BFA_PL_EID_LOGO, 0, "Logout");
1394 break;
1395
1396 case BFA_LPS_SM_RX_CVL:
1397 bfa_sm_set_state(lps, bfa_lps_sm_init);
1398 bfa_reqq_wcancel(&lps->wqe);
1399
1400 /* Let the vport module know about this event */
1401 bfa_lps_cvl_event(lps);
1402 bfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,
1403 BFA_PL_EID_FIP_FCF_CVL, 0, "FCF Clear Virt. Link Rx");
1404 break;
1405
1406 case BFA_LPS_SM_OFFLINE:
1407 case BFA_LPS_SM_DELETE:
1408 bfa_sm_set_state(lps, bfa_lps_sm_init);
1409 bfa_reqq_wcancel(&lps->wqe);
1410 break;
1411
1412 default:
1413 bfa_sm_fault(lps->bfa, event);
1414 }
1415}
1416
1417/*
1418 * logout in progress - awaiting firmware response
1419 */
1420static void
1421bfa_lps_sm_logout(struct bfa_lps_s *lps, enum bfa_lps_event event)
1422{
1423 bfa_trc(lps->bfa, lps->lp_tag);
1424 bfa_trc(lps->bfa, event);
1425
1426 switch (event) {
1427 case BFA_LPS_SM_FWRSP:
1428 bfa_sm_set_state(lps, bfa_lps_sm_init);
1429 bfa_lps_logout_comp(lps);
1430 break;
1431
1432 case BFA_LPS_SM_OFFLINE:
1433 bfa_sm_set_state(lps, bfa_lps_sm_init);
1434 break;
1435
1436 default:
1437 bfa_sm_fault(lps->bfa, event);
1438 }
1439}
1440
1441/*
1442 * logout pending -- awaiting space in request queue
1443 */
1444static void
1445bfa_lps_sm_logowait(struct bfa_lps_s *lps, enum bfa_lps_event event)
1446{
1447 bfa_trc(lps->bfa, lps->lp_tag);
1448 bfa_trc(lps->bfa, event);
1449
1450 switch (event) {
1451 case BFA_LPS_SM_RESUME:
1452 bfa_sm_set_state(lps, bfa_lps_sm_logout);
1453 bfa_lps_send_logout(lps);
1454 break;
1455
1456 case BFA_LPS_SM_OFFLINE:
1457 bfa_sm_set_state(lps, bfa_lps_sm_init);
1458 bfa_reqq_wcancel(&lps->wqe);
1459 break;
1460
1461 default:
1462 bfa_sm_fault(lps->bfa, event);
1463 }
1464}
1465
1466
1467
1468/*
1469 * lps_pvt BFA LPS private functions
1470 */
1471
1472/*
1473 * return memory requirement
1474 */
1475static void
1476bfa_lps_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len,
1477 u32 *dm_len)
1478{
1479 if (cfg->drvcfg.min_cfg)
1480 *ndm_len += sizeof(struct bfa_lps_s) * BFA_LPS_MIN_LPORTS;
1481 else
1482 *ndm_len += sizeof(struct bfa_lps_s) * BFA_LPS_MAX_LPORTS;
1483}
1484
1485/*
1486 * bfa module attach at initialization time
1487 */
1488static void
1489bfa_lps_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
1490 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
1491{
1492 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
1493 struct bfa_lps_s *lps;
1494 int i;
1495
1496 memset(mod, 0, sizeof(struct bfa_lps_mod_s));
1497 mod->num_lps = BFA_LPS_MAX_LPORTS;
1498 if (cfg->drvcfg.min_cfg)
1499 mod->num_lps = BFA_LPS_MIN_LPORTS;
1500 else
1501 mod->num_lps = BFA_LPS_MAX_LPORTS;
1502 mod->lps_arr = lps = (struct bfa_lps_s *) bfa_meminfo_kva(meminfo);
1503
1504 bfa_meminfo_kva(meminfo) += mod->num_lps * sizeof(struct bfa_lps_s);
1505
1506 INIT_LIST_HEAD(&mod->lps_free_q);
1507 INIT_LIST_HEAD(&mod->lps_active_q);
1508
1509 for (i = 0; i < mod->num_lps; i++, lps++) {
1510 lps->bfa = bfa;
1511 lps->lp_tag = (u8) i;
1512 lps->reqq = BFA_REQQ_LPS;
1513 bfa_reqq_winit(&lps->wqe, bfa_lps_reqq_resume, lps);
1514 list_add_tail(&lps->qe, &mod->lps_free_q);
1515 }
1516}
1517
1518static void
1519bfa_lps_detach(struct bfa_s *bfa)
1520{
1521}
1522
1523static void
1524bfa_lps_start(struct bfa_s *bfa)
1525{
1526}
1527
1528static void
1529bfa_lps_stop(struct bfa_s *bfa)
1530{
1531}
1532
1533/*
1534 * IOC in disabled state -- consider all lps offline
1535 */
1536static void
1537bfa_lps_iocdisable(struct bfa_s *bfa)
1538{
1539 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
1540 struct bfa_lps_s *lps;
1541 struct list_head *qe, *qen;
1542
1543 list_for_each_safe(qe, qen, &mod->lps_active_q) {
1544 lps = (struct bfa_lps_s *) qe;
1545 bfa_sm_send_event(lps, BFA_LPS_SM_OFFLINE);
1546 }
1547}
1548
1549/*
1550 * Firmware login response
1551 */
1552static void
1553bfa_lps_login_rsp(struct bfa_s *bfa, struct bfi_lps_login_rsp_s *rsp)
1554{
1555 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
1556 struct bfa_lps_s *lps;
1557
1558 WARN_ON(rsp->lp_tag >= mod->num_lps);
1559 lps = BFA_LPS_FROM_TAG(mod, rsp->lp_tag);
1560
1561 lps->status = rsp->status;
1562 switch (rsp->status) {
1563 case BFA_STATUS_OK:
1564 lps->fport = rsp->f_port;
1565 if (lps->fport)
1566 lps->lp_pid = rsp->lp_pid;
1567 lps->npiv_en = rsp->npiv_en;
1568 lps->pr_bbcred = be16_to_cpu(rsp->bb_credit);
1569 lps->pr_pwwn = rsp->port_name;
1570 lps->pr_nwwn = rsp->node_name;
1571 lps->auth_req = rsp->auth_req;
1572 lps->lp_mac = rsp->lp_mac;
1573 lps->brcd_switch = rsp->brcd_switch;
1574 lps->fcf_mac = rsp->fcf_mac;
1575
1576 break;
1577
1578 case BFA_STATUS_FABRIC_RJT:
1579 lps->lsrjt_rsn = rsp->lsrjt_rsn;
1580 lps->lsrjt_expl = rsp->lsrjt_expl;
1581
1582 break;
1583
1584 case BFA_STATUS_EPROTOCOL:
1585 lps->ext_status = rsp->ext_status;
1586
1587 break;
1588
1589 default:
1590 /* Nothing to do with other status */
1591 break;
1592 }
1593
1594 bfa_sm_send_event(lps, BFA_LPS_SM_FWRSP);
1595}
1596
1597/*
1598 * Firmware logout response
1599 */
1600static void
1601bfa_lps_logout_rsp(struct bfa_s *bfa, struct bfi_lps_logout_rsp_s *rsp)
1602{
1603 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
1604 struct bfa_lps_s *lps;
1605
1606 WARN_ON(rsp->lp_tag >= mod->num_lps);
1607 lps = BFA_LPS_FROM_TAG(mod, rsp->lp_tag);
1608
1609 bfa_sm_send_event(lps, BFA_LPS_SM_FWRSP);
1610}
1611
1612/*
1613 * Firmware received a Clear virtual link request (for FCoE)
1614 */
1615static void
1616bfa_lps_rx_cvl_event(struct bfa_s *bfa, struct bfi_lps_cvl_event_s *cvl)
1617{
1618 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
1619 struct bfa_lps_s *lps;
1620
1621 lps = BFA_LPS_FROM_TAG(mod, cvl->lp_tag);
1622
1623 bfa_sm_send_event(lps, BFA_LPS_SM_RX_CVL);
1624}
1625
1626/*
1627 * Space is available in request queue, resume queueing request to firmware.
1628 */
1629static void
1630bfa_lps_reqq_resume(void *lps_arg)
1631{
1632 struct bfa_lps_s *lps = lps_arg;
1633
1634 bfa_sm_send_event(lps, BFA_LPS_SM_RESUME);
1635}
1636
1637/*
1638 * lps is freed -- triggered by vport delete
1639 */
1640static void
1641bfa_lps_free(struct bfa_lps_s *lps)
1642{
1643 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(lps->bfa);
1644
1645 lps->lp_pid = 0;
1646 list_del(&lps->qe);
1647 list_add_tail(&lps->qe, &mod->lps_free_q);
1648}
1649
1650/*
1651 * send login request to firmware
1652 */
1653static void
1654bfa_lps_send_login(struct bfa_lps_s *lps)
1655{
1656 struct bfi_lps_login_req_s *m;
1657
1658 m = bfa_reqq_next(lps->bfa, lps->reqq);
1659 WARN_ON(!m);
1660
1661 bfi_h2i_set(m->mh, BFI_MC_LPS, BFI_LPS_H2I_LOGIN_REQ,
1662 bfa_lpuid(lps->bfa));
1663
1664 m->lp_tag = lps->lp_tag;
1665 m->alpa = lps->alpa;
1666 m->pdu_size = cpu_to_be16(lps->pdusz);
1667 m->pwwn = lps->pwwn;
1668 m->nwwn = lps->nwwn;
1669 m->fdisc = lps->fdisc;
1670 m->auth_en = lps->auth_en;
1671
1672 bfa_reqq_produce(lps->bfa, lps->reqq);
1673}
1674
1675/*
1676 * send logout request to firmware
1677 */
1678static void
1679bfa_lps_send_logout(struct bfa_lps_s *lps)
1680{
1681 struct bfi_lps_logout_req_s *m;
1682
1683 m = bfa_reqq_next(lps->bfa, lps->reqq);
1684 WARN_ON(!m);
1685
1686 bfi_h2i_set(m->mh, BFI_MC_LPS, BFI_LPS_H2I_LOGOUT_REQ,
1687 bfa_lpuid(lps->bfa));
1688
1689 m->lp_tag = lps->lp_tag;
1690 m->port_name = lps->pwwn;
1691 bfa_reqq_produce(lps->bfa, lps->reqq);
1692}
1693
1694/*
1695 * send n2n pid set request to firmware
1696 */
1697static void
1698bfa_lps_send_set_n2n_pid(struct bfa_lps_s *lps)
1699{
1700 struct bfi_lps_n2n_pid_req_s *m;
1701
1702 m = bfa_reqq_next(lps->bfa, lps->reqq);
1703 WARN_ON(!m);
1704
1705 bfi_h2i_set(m->mh, BFI_MC_LPS, BFI_LPS_H2I_N2N_PID_REQ,
1706 bfa_lpuid(lps->bfa));
1707
1708 m->lp_tag = lps->lp_tag;
1709 m->lp_pid = lps->lp_pid;
1710 bfa_reqq_produce(lps->bfa, lps->reqq);
1711}
1712
1713/*
1714 * Indirect login completion handler for non-fcs
1715 */
1716static void
1717bfa_lps_login_comp_cb(void *arg, bfa_boolean_t complete)
1718{
1719 struct bfa_lps_s *lps = arg;
1720
1721 if (!complete)
1722 return;
1723
1724 if (lps->fdisc)
1725 bfa_cb_lps_fdisc_comp(lps->bfa->bfad, lps->uarg, lps->status);
1726 else
1727 bfa_cb_lps_flogi_comp(lps->bfa->bfad, lps->uarg, lps->status);
1728}
1729
1730/*
1731 * Login completion handler -- direct call for fcs, queue for others
1732 */
1733static void
1734bfa_lps_login_comp(struct bfa_lps_s *lps)
1735{
1736 if (!lps->bfa->fcs) {
1737 bfa_cb_queue(lps->bfa, &lps->hcb_qe, bfa_lps_login_comp_cb,
1738 lps);
1739 return;
1740 }
1741
1742 if (lps->fdisc)
1743 bfa_cb_lps_fdisc_comp(lps->bfa->bfad, lps->uarg, lps->status);
1744 else
1745 bfa_cb_lps_flogi_comp(lps->bfa->bfad, lps->uarg, lps->status);
1746}
1747
1748/*
1749 * Indirect logout completion handler for non-fcs
1750 */
1751static void
1752bfa_lps_logout_comp_cb(void *arg, bfa_boolean_t complete)
1753{
1754 struct bfa_lps_s *lps = arg;
1755
1756 if (!complete)
1757 return;
1758
1759 if (lps->fdisc)
1760 bfa_cb_lps_fdisclogo_comp(lps->bfa->bfad, lps->uarg);
1761}
1762
1763/*
1764 * Logout completion handler -- direct call for fcs, queue for others
1765 */
1766static void
1767bfa_lps_logout_comp(struct bfa_lps_s *lps)
1768{
1769 if (!lps->bfa->fcs) {
1770 bfa_cb_queue(lps->bfa, &lps->hcb_qe, bfa_lps_logout_comp_cb,
1771 lps);
1772 return;
1773 }
1774 if (lps->fdisc)
1775 bfa_cb_lps_fdisclogo_comp(lps->bfa->bfad, lps->uarg);
1776}
1777
1778/*
1779 * Clear virtual link completion handler for non-fcs
1780 */
1781static void
1782bfa_lps_cvl_event_cb(void *arg, bfa_boolean_t complete)
1783{
1784 struct bfa_lps_s *lps = arg;
1785
1786 if (!complete)
1787 return;
1788
1789 /* Clear virtual link to base port will result in link down */
1790 if (lps->fdisc)
1791 bfa_cb_lps_cvl_event(lps->bfa->bfad, lps->uarg);
1792}
1793
1794/*
1795 * Received Clear virtual link event --direct call for fcs,
1796 * queue for others
1797 */
1798static void
1799bfa_lps_cvl_event(struct bfa_lps_s *lps)
1800{
1801 if (!lps->bfa->fcs) {
1802 bfa_cb_queue(lps->bfa, &lps->hcb_qe, bfa_lps_cvl_event_cb,
1803 lps);
1804 return;
1805 }
1806
1807 /* Clear virtual link to base port will result in link down */
1808 if (lps->fdisc)
1809 bfa_cb_lps_cvl_event(lps->bfa->bfad, lps->uarg);
1810}
1811
1812
1813
1814/*
1815 * lps_public BFA LPS public functions
1816 */
1817
1818u32
1819bfa_lps_get_max_vport(struct bfa_s *bfa)
1820{
1821 if (bfa_ioc_devid(&bfa->ioc) == BFA_PCI_DEVICE_ID_CT)
1822 return BFA_LPS_MAX_VPORTS_SUPP_CT;
1823 else
1824 return BFA_LPS_MAX_VPORTS_SUPP_CB;
1825}
1826
1827/*
1828 * Allocate a lport srvice tag.
1829 */
1830struct bfa_lps_s *
1831bfa_lps_alloc(struct bfa_s *bfa)
1832{
1833 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
1834 struct bfa_lps_s *lps = NULL;
1835
1836 bfa_q_deq(&mod->lps_free_q, &lps);
1837
1838 if (lps == NULL)
1839 return NULL;
1840
1841 list_add_tail(&lps->qe, &mod->lps_active_q);
1842
1843 bfa_sm_set_state(lps, bfa_lps_sm_init);
1844 return lps;
1845}
1846
1847/*
1848 * Free lport service tag. This can be called anytime after an alloc.
1849 * No need to wait for any pending login/logout completions.
1850 */
1851void
1852bfa_lps_delete(struct bfa_lps_s *lps)
1853{
1854 bfa_sm_send_event(lps, BFA_LPS_SM_DELETE);
1855}
1856
1857/*
1858 * Initiate a lport login.
1859 */
1860void
1861bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa, u16 pdusz,
1862 wwn_t pwwn, wwn_t nwwn, bfa_boolean_t auth_en)
1863{
1864 lps->uarg = uarg;
1865 lps->alpa = alpa;
1866 lps->pdusz = pdusz;
1867 lps->pwwn = pwwn;
1868 lps->nwwn = nwwn;
1869 lps->fdisc = BFA_FALSE;
1870 lps->auth_en = auth_en;
1871 bfa_sm_send_event(lps, BFA_LPS_SM_LOGIN);
1872}
1873
1874/*
1875 * Initiate a lport fdisc login.
1876 */
1877void
1878bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz, wwn_t pwwn,
1879 wwn_t nwwn)
1880{
1881 lps->uarg = uarg;
1882 lps->alpa = 0;
1883 lps->pdusz = pdusz;
1884 lps->pwwn = pwwn;
1885 lps->nwwn = nwwn;
1886 lps->fdisc = BFA_TRUE;
1887 lps->auth_en = BFA_FALSE;
1888 bfa_sm_send_event(lps, BFA_LPS_SM_LOGIN);
1889}
1890
1891
1892/*
1893 * Initiate a lport FDSIC logout.
1894 */
1895void
1896bfa_lps_fdisclogo(struct bfa_lps_s *lps)
1897{
1898 bfa_sm_send_event(lps, BFA_LPS_SM_LOGOUT);
1899}
1900
1901
1902/*
1903 * Return lport services tag given the pid
1904 */
1905u8
1906bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid)
1907{
1908 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
1909 struct bfa_lps_s *lps;
1910 int i;
1911
1912 for (i = 0, lps = mod->lps_arr; i < mod->num_lps; i++, lps++) {
1913 if (lps->lp_pid == pid)
1914 return lps->lp_tag;
1915 }
1916
1917 /* Return base port tag anyway */
1918 return 0;
1919}
1920
1921
1922/*
1923 * return port id assigned to the base lport
1924 */
1925u32
1926bfa_lps_get_base_pid(struct bfa_s *bfa)
1927{
1928 struct bfa_lps_mod_s *mod = BFA_LPS_MOD(bfa);
1929
1930 return BFA_LPS_FROM_TAG(mod, 0)->lp_pid;
1931}
1932
1933/*
1934 * Set PID in case of n2n (which is assigned during PLOGI)
1935 */
1936void
1937bfa_lps_set_n2n_pid(struct bfa_lps_s *lps, uint32_t n2n_pid)
1938{
1939 bfa_trc(lps->bfa, lps->lp_tag);
1940 bfa_trc(lps->bfa, n2n_pid);
1941
1942 lps->lp_pid = n2n_pid;
1943 bfa_sm_send_event(lps, BFA_LPS_SM_SET_N2N_PID);
1944}
1945
1946/*
1947 * LPS firmware message class handler.
1948 */
1949void
1950bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
1951{
1952 union bfi_lps_i2h_msg_u msg;
1953
1954 bfa_trc(bfa, m->mhdr.msg_id);
1955 msg.msg = m;
1956
1957 switch (m->mhdr.msg_id) {
1958 case BFI_LPS_H2I_LOGIN_RSP:
1959 bfa_lps_login_rsp(bfa, msg.login_rsp);
1960 break;
1961
1962 case BFI_LPS_H2I_LOGOUT_RSP:
1963 bfa_lps_logout_rsp(bfa, msg.logout_rsp);
1964 break;
1965
1966 case BFI_LPS_H2I_CVL_EVENT:
1967 bfa_lps_rx_cvl_event(bfa, msg.cvl_event);
1968 break;
1969
1970 default:
1971 bfa_trc(bfa, m->mhdr.msg_id);
1972 WARN_ON(1);
1973 }
1974}
1975
1976/*
1977 * FC PORT state machine functions
1978 */
1979static void
1980bfa_fcport_sm_uninit(struct bfa_fcport_s *fcport,
1981 enum bfa_fcport_sm_event event)
1982{
1983 bfa_trc(fcport->bfa, event);
1984
1985 switch (event) {
1986 case BFA_FCPORT_SM_START:
1987 /*
1988 * Start event after IOC is configured and BFA is started.
1989 */
1990 fcport->use_flash_cfg = BFA_TRUE;
1991
1992 if (bfa_fcport_send_enable(fcport)) {
1993 bfa_trc(fcport->bfa, BFA_TRUE);
1994 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
1995 } else {
1996 bfa_trc(fcport->bfa, BFA_FALSE);
1997 bfa_sm_set_state(fcport,
1998 bfa_fcport_sm_enabling_qwait);
1999 }
2000 break;
2001
2002 case BFA_FCPORT_SM_ENABLE:
2003 /*
2004 * Port is persistently configured to be in enabled state. Do
2005 * not change state. Port enabling is done when START event is
2006 * received.
2007 */
2008 break;
2009
2010 case BFA_FCPORT_SM_DISABLE:
2011 /*
2012 * If a port is persistently configured to be disabled, the
2013 * first event will a port disable request.
2014 */
2015 bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
2016 break;
2017
2018 case BFA_FCPORT_SM_HWFAIL:
2019 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
2020 break;
2021
2022 default:
2023 bfa_sm_fault(fcport->bfa, event);
2024 }
2025}
2026
2027static void
2028bfa_fcport_sm_enabling_qwait(struct bfa_fcport_s *fcport,
2029 enum bfa_fcport_sm_event event)
2030{
2031 char pwwn_buf[BFA_STRING_32];
2032 struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
2033 bfa_trc(fcport->bfa, event);
2034
2035 switch (event) {
2036 case BFA_FCPORT_SM_QRESUME:
2037 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
2038 bfa_fcport_send_enable(fcport);
2039 break;
2040
2041 case BFA_FCPORT_SM_STOP:
2042 bfa_reqq_wcancel(&fcport->reqq_wait);
2043 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
2044 break;
2045
2046 case BFA_FCPORT_SM_ENABLE:
2047 /*
2048 * Already enable is in progress.
2049 */
2050 break;
2051
2052 case BFA_FCPORT_SM_DISABLE:
2053 /*
2054 * Just send disable request to firmware when room becomes
2055 * available in request queue.
2056 */
2057 bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
2058 bfa_reqq_wcancel(&fcport->reqq_wait);
2059 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
2060 BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
2061 wwn2str(pwwn_buf, fcport->pwwn);
2062 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2063 "Base port disabled: WWN = %s\n", pwwn_buf);
2064 break;
2065
2066 case BFA_FCPORT_SM_LINKUP:
2067 case BFA_FCPORT_SM_LINKDOWN:
2068 /*
2069 * Possible to get link events when doing back-to-back
2070 * enable/disables.
2071 */
2072 break;
2073
2074 case BFA_FCPORT_SM_HWFAIL:
2075 bfa_reqq_wcancel(&fcport->reqq_wait);
2076 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
2077 break;
2078
2079 default:
2080 bfa_sm_fault(fcport->bfa, event);
2081 }
2082}
2083
2084static void
2085bfa_fcport_sm_enabling(struct bfa_fcport_s *fcport,
2086 enum bfa_fcport_sm_event event)
2087{
2088 char pwwn_buf[BFA_STRING_32];
2089 struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
2090 bfa_trc(fcport->bfa, event);
2091
2092 switch (event) {
2093 case BFA_FCPORT_SM_FWRSP:
2094 case BFA_FCPORT_SM_LINKDOWN:
2095 bfa_sm_set_state(fcport, bfa_fcport_sm_linkdown);
2096 break;
2097
2098 case BFA_FCPORT_SM_LINKUP:
2099 bfa_fcport_update_linkinfo(fcport);
2100 bfa_sm_set_state(fcport, bfa_fcport_sm_linkup);
2101
2102 WARN_ON(!fcport->event_cbfn);
2103 bfa_fcport_scn(fcport, BFA_PORT_LINKUP, BFA_FALSE);
2104 break;
2105
2106 case BFA_FCPORT_SM_ENABLE:
2107 /*
2108 * Already being enabled.
2109 */
2110 break;
2111
2112 case BFA_FCPORT_SM_DISABLE:
2113 if (bfa_fcport_send_disable(fcport))
2114 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
2115 else
2116 bfa_sm_set_state(fcport,
2117 bfa_fcport_sm_disabling_qwait);
2118
2119 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
2120 BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
2121 wwn2str(pwwn_buf, fcport->pwwn);
2122 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2123 "Base port disabled: WWN = %s\n", pwwn_buf);
2124 break;
2125
2126 case BFA_FCPORT_SM_STOP:
2127 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
2128 break;
2129
2130 case BFA_FCPORT_SM_HWFAIL:
2131 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
2132 break;
2133
2134 default:
2135 bfa_sm_fault(fcport->bfa, event);
2136 }
2137}
2138
2139static void
2140bfa_fcport_sm_linkdown(struct bfa_fcport_s *fcport,
2141 enum bfa_fcport_sm_event event)
2142{
2143 struct bfi_fcport_event_s *pevent = fcport->event_arg.i2hmsg.event;
2144 char pwwn_buf[BFA_STRING_32];
2145 struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
2146
2147 bfa_trc(fcport->bfa, event);
2148
2149 switch (event) {
2150 case BFA_FCPORT_SM_LINKUP:
2151 bfa_fcport_update_linkinfo(fcport);
2152 bfa_sm_set_state(fcport, bfa_fcport_sm_linkup);
2153 WARN_ON(!fcport->event_cbfn);
2154 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
2155 BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkup");
2156 if (!bfa_ioc_get_fcmode(&fcport->bfa->ioc)) {
2157
2158 bfa_trc(fcport->bfa,
2159 pevent->link_state.vc_fcf.fcf.fipenabled);
2160 bfa_trc(fcport->bfa,
2161 pevent->link_state.vc_fcf.fcf.fipfailed);
2162
2163 if (pevent->link_state.vc_fcf.fcf.fipfailed)
2164 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
2165 BFA_PL_EID_FIP_FCF_DISC, 0,
2166 "FIP FCF Discovery Failed");
2167 else
2168 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
2169 BFA_PL_EID_FIP_FCF_DISC, 0,
2170 "FIP FCF Discovered");
2171 }
2172
2173 bfa_fcport_scn(fcport, BFA_PORT_LINKUP, BFA_FALSE);
2174 wwn2str(pwwn_buf, fcport->pwwn);
2175 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2176 "Base port online: WWN = %s\n", pwwn_buf);
2177 break;
2178
2179 case BFA_FCPORT_SM_LINKDOWN:
2180 /*
2181 * Possible to get link down event.
2182 */
2183 break;
2184
2185 case BFA_FCPORT_SM_ENABLE:
2186 /*
2187 * Already enabled.
2188 */
2189 break;
2190
2191 case BFA_FCPORT_SM_DISABLE:
2192 if (bfa_fcport_send_disable(fcport))
2193 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
2194 else
2195 bfa_sm_set_state(fcport,
2196 bfa_fcport_sm_disabling_qwait);
2197
2198 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
2199 BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
2200 wwn2str(pwwn_buf, fcport->pwwn);
2201 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2202 "Base port disabled: WWN = %s\n", pwwn_buf);
2203 break;
2204
2205 case BFA_FCPORT_SM_STOP:
2206 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
2207 break;
2208
2209 case BFA_FCPORT_SM_HWFAIL:
2210 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
2211 break;
2212
2213 default:
2214 bfa_sm_fault(fcport->bfa, event);
2215 }
2216}
2217
2218static void
2219bfa_fcport_sm_linkup(struct bfa_fcport_s *fcport,
2220 enum bfa_fcport_sm_event event)
2221{
2222 char pwwn_buf[BFA_STRING_32];
2223 struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
2224
2225 bfa_trc(fcport->bfa, event);
2226
2227 switch (event) {
2228 case BFA_FCPORT_SM_ENABLE:
2229 /*
2230 * Already enabled.
2231 */
2232 break;
2233
2234 case BFA_FCPORT_SM_DISABLE:
2235 if (bfa_fcport_send_disable(fcport))
2236 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
2237 else
2238 bfa_sm_set_state(fcport,
2239 bfa_fcport_sm_disabling_qwait);
2240
2241 bfa_fcport_reset_linkinfo(fcport);
2242 bfa_fcport_scn(fcport, BFA_PORT_LINKDOWN, BFA_FALSE);
2243 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
2244 BFA_PL_EID_PORT_DISABLE, 0, "Port Disable");
2245 wwn2str(pwwn_buf, fcport->pwwn);
2246 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2247 "Base port offline: WWN = %s\n", pwwn_buf);
2248 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2249 "Base port disabled: WWN = %s\n", pwwn_buf);
2250 break;
2251
2252 case BFA_FCPORT_SM_LINKDOWN:
2253 bfa_sm_set_state(fcport, bfa_fcport_sm_linkdown);
2254 bfa_fcport_reset_linkinfo(fcport);
2255 bfa_fcport_scn(fcport, BFA_PORT_LINKDOWN, BFA_FALSE);
2256 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
2257 BFA_PL_EID_PORT_ST_CHANGE, 0, "Port Linkdown");
2258 wwn2str(pwwn_buf, fcport->pwwn);
2259 if (BFA_PORT_IS_DISABLED(fcport->bfa))
2260 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2261 "Base port offline: WWN = %s\n", pwwn_buf);
2262 else
2263 BFA_LOG(KERN_ERR, bfad, bfa_log_level,
2264 "Base port (WWN = %s) "
2265 "lost fabric connectivity\n", pwwn_buf);
2266 break;
2267
2268 case BFA_FCPORT_SM_STOP:
2269 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
2270 bfa_fcport_reset_linkinfo(fcport);
2271 wwn2str(pwwn_buf, fcport->pwwn);
2272 if (BFA_PORT_IS_DISABLED(fcport->bfa))
2273 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2274 "Base port offline: WWN = %s\n", pwwn_buf);
2275 else
2276 BFA_LOG(KERN_ERR, bfad, bfa_log_level,
2277 "Base port (WWN = %s) "
2278 "lost fabric connectivity\n", pwwn_buf);
2279 break;
2280
2281 case BFA_FCPORT_SM_HWFAIL:
2282 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
2283 bfa_fcport_reset_linkinfo(fcport);
2284 bfa_fcport_scn(fcport, BFA_PORT_LINKDOWN, BFA_FALSE);
2285 wwn2str(pwwn_buf, fcport->pwwn);
2286 if (BFA_PORT_IS_DISABLED(fcport->bfa))
2287 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2288 "Base port offline: WWN = %s\n", pwwn_buf);
2289 else
2290 BFA_LOG(KERN_ERR, bfad, bfa_log_level,
2291 "Base port (WWN = %s) "
2292 "lost fabric connectivity\n", pwwn_buf);
2293 break;
2294
2295 default:
2296 bfa_sm_fault(fcport->bfa, event);
2297 }
2298}
2299
2300static void
2301bfa_fcport_sm_disabling_qwait(struct bfa_fcport_s *fcport,
2302 enum bfa_fcport_sm_event event)
2303{
2304 bfa_trc(fcport->bfa, event);
2305
2306 switch (event) {
2307 case BFA_FCPORT_SM_QRESUME:
2308 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
2309 bfa_fcport_send_disable(fcport);
2310 break;
2311
2312 case BFA_FCPORT_SM_STOP:
2313 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
2314 bfa_reqq_wcancel(&fcport->reqq_wait);
2315 break;
2316
2317 case BFA_FCPORT_SM_ENABLE:
2318 bfa_sm_set_state(fcport, bfa_fcport_sm_toggling_qwait);
2319 break;
2320
2321 case BFA_FCPORT_SM_DISABLE:
2322 /*
2323 * Already being disabled.
2324 */
2325 break;
2326
2327 case BFA_FCPORT_SM_LINKUP:
2328 case BFA_FCPORT_SM_LINKDOWN:
2329 /*
2330 * Possible to get link events when doing back-to-back
2331 * enable/disables.
2332 */
2333 break;
2334
2335 case BFA_FCPORT_SM_HWFAIL:
2336 bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
2337 bfa_reqq_wcancel(&fcport->reqq_wait);
2338 break;
2339
2340 default:
2341 bfa_sm_fault(fcport->bfa, event);
2342 }
2343}
2344
2345static void
2346bfa_fcport_sm_toggling_qwait(struct bfa_fcport_s *fcport,
2347 enum bfa_fcport_sm_event event)
2348{
2349 bfa_trc(fcport->bfa, event);
2350
2351 switch (event) {
2352 case BFA_FCPORT_SM_QRESUME:
2353 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling);
2354 bfa_fcport_send_disable(fcport);
2355 if (bfa_fcport_send_enable(fcport))
2356 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
2357 else
2358 bfa_sm_set_state(fcport,
2359 bfa_fcport_sm_enabling_qwait);
2360 break;
2361
2362 case BFA_FCPORT_SM_STOP:
2363 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
2364 bfa_reqq_wcancel(&fcport->reqq_wait);
2365 break;
2366
2367 case BFA_FCPORT_SM_ENABLE:
2368 break;
2369
2370 case BFA_FCPORT_SM_DISABLE:
2371 bfa_sm_set_state(fcport, bfa_fcport_sm_disabling_qwait);
2372 break;
2373
2374 case BFA_FCPORT_SM_LINKUP:
2375 case BFA_FCPORT_SM_LINKDOWN:
2376 /*
2377 * Possible to get link events when doing back-to-back
2378 * enable/disables.
2379 */
2380 break;
2381
2382 case BFA_FCPORT_SM_HWFAIL:
2383 bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
2384 bfa_reqq_wcancel(&fcport->reqq_wait);
2385 break;
2386
2387 default:
2388 bfa_sm_fault(fcport->bfa, event);
2389 }
2390}
2391
2392static void
2393bfa_fcport_sm_disabling(struct bfa_fcport_s *fcport,
2394 enum bfa_fcport_sm_event event)
2395{
2396 char pwwn_buf[BFA_STRING_32];
2397 struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
2398 bfa_trc(fcport->bfa, event);
2399
2400 switch (event) {
2401 case BFA_FCPORT_SM_FWRSP:
2402 bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
2403 break;
2404
2405 case BFA_FCPORT_SM_DISABLE:
2406 /*
2407 * Already being disabled.
2408 */
2409 break;
2410
2411 case BFA_FCPORT_SM_ENABLE:
2412 if (bfa_fcport_send_enable(fcport))
2413 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
2414 else
2415 bfa_sm_set_state(fcport,
2416 bfa_fcport_sm_enabling_qwait);
2417
2418 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
2419 BFA_PL_EID_PORT_ENABLE, 0, "Port Enable");
2420 wwn2str(pwwn_buf, fcport->pwwn);
2421 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2422 "Base port enabled: WWN = %s\n", pwwn_buf);
2423 break;
2424
2425 case BFA_FCPORT_SM_STOP:
2426 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
2427 break;
2428
2429 case BFA_FCPORT_SM_LINKUP:
2430 case BFA_FCPORT_SM_LINKDOWN:
2431 /*
2432 * Possible to get link events when doing back-to-back
2433 * enable/disables.
2434 */
2435 break;
2436
2437 case BFA_FCPORT_SM_HWFAIL:
2438 bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
2439 break;
2440
2441 default:
2442 bfa_sm_fault(fcport->bfa, event);
2443 }
2444}
2445
2446static void
2447bfa_fcport_sm_disabled(struct bfa_fcport_s *fcport,
2448 enum bfa_fcport_sm_event event)
2449{
2450 char pwwn_buf[BFA_STRING_32];
2451 struct bfad_s *bfad = (struct bfad_s *)fcport->bfa->bfad;
2452 bfa_trc(fcport->bfa, event);
2453
2454 switch (event) {
2455 case BFA_FCPORT_SM_START:
2456 /*
2457 * Ignore start event for a port that is disabled.
2458 */
2459 break;
2460
2461 case BFA_FCPORT_SM_STOP:
2462 bfa_sm_set_state(fcport, bfa_fcport_sm_stopped);
2463 break;
2464
2465 case BFA_FCPORT_SM_ENABLE:
2466 if (bfa_fcport_send_enable(fcport))
2467 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
2468 else
2469 bfa_sm_set_state(fcport,
2470 bfa_fcport_sm_enabling_qwait);
2471
2472 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
2473 BFA_PL_EID_PORT_ENABLE, 0, "Port Enable");
2474 wwn2str(pwwn_buf, fcport->pwwn);
2475 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
2476 "Base port enabled: WWN = %s\n", pwwn_buf);
2477 break;
2478
2479 case BFA_FCPORT_SM_DISABLE:
2480 /*
2481 * Already disabled.
2482 */
2483 break;
2484
2485 case BFA_FCPORT_SM_HWFAIL:
2486 bfa_sm_set_state(fcport, bfa_fcport_sm_iocfail);
2487 break;
2488
2489 default:
2490 bfa_sm_fault(fcport->bfa, event);
2491 }
2492}
2493
2494static void
2495bfa_fcport_sm_stopped(struct bfa_fcport_s *fcport,
2496 enum bfa_fcport_sm_event event)
2497{
2498 bfa_trc(fcport->bfa, event);
2499
2500 switch (event) {
2501 case BFA_FCPORT_SM_START:
2502 if (bfa_fcport_send_enable(fcport))
2503 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
2504 else
2505 bfa_sm_set_state(fcport,
2506 bfa_fcport_sm_enabling_qwait);
2507 break;
2508
2509 default:
2510 /*
2511 * Ignore all other events.
2512 */
2513 ;
2514 }
2515}
2516
2517/*
2518 * Port is enabled. IOC is down/failed.
2519 */
2520static void
2521bfa_fcport_sm_iocdown(struct bfa_fcport_s *fcport,
2522 enum bfa_fcport_sm_event event)
2523{
2524 bfa_trc(fcport->bfa, event);
2525
2526 switch (event) {
2527 case BFA_FCPORT_SM_START:
2528 if (bfa_fcport_send_enable(fcport))
2529 bfa_sm_set_state(fcport, bfa_fcport_sm_enabling);
2530 else
2531 bfa_sm_set_state(fcport,
2532 bfa_fcport_sm_enabling_qwait);
2533 break;
2534
2535 default:
2536 /*
2537 * Ignore all events.
2538 */
2539 ;
2540 }
2541}
2542
2543/*
2544 * Port is disabled. IOC is down/failed.
2545 */
2546static void
2547bfa_fcport_sm_iocfail(struct bfa_fcport_s *fcport,
2548 enum bfa_fcport_sm_event event)
2549{
2550 bfa_trc(fcport->bfa, event);
2551
2552 switch (event) {
2553 case BFA_FCPORT_SM_START:
2554 bfa_sm_set_state(fcport, bfa_fcport_sm_disabled);
2555 break;
2556
2557 case BFA_FCPORT_SM_ENABLE:
2558 bfa_sm_set_state(fcport, bfa_fcport_sm_iocdown);
2559 break;
2560
2561 default:
2562 /*
2563 * Ignore all events.
2564 */
2565 ;
2566 }
2567}
2568
2569/*
2570 * Link state is down
2571 */
2572static void
2573bfa_fcport_ln_sm_dn(struct bfa_fcport_ln_s *ln,
2574 enum bfa_fcport_ln_sm_event event)
2575{
2576 bfa_trc(ln->fcport->bfa, event);
2577
2578 switch (event) {
2579 case BFA_FCPORT_LN_SM_LINKUP:
2580 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_nf);
2581 bfa_fcport_queue_cb(ln, BFA_PORT_LINKUP);
2582 break;
2583
2584 default:
2585 bfa_sm_fault(ln->fcport->bfa, event);
2586 }
2587}
2588
2589/*
2590 * Link state is waiting for down notification
2591 */
2592static void
2593bfa_fcport_ln_sm_dn_nf(struct bfa_fcport_ln_s *ln,
2594 enum bfa_fcport_ln_sm_event event)
2595{
2596 bfa_trc(ln->fcport->bfa, event);
2597
2598 switch (event) {
2599 case BFA_FCPORT_LN_SM_LINKUP:
2600 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_up_nf);
2601 break;
2602
2603 case BFA_FCPORT_LN_SM_NOTIFICATION:
2604 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn);
2605 break;
2606
2607 default:
2608 bfa_sm_fault(ln->fcport->bfa, event);
2609 }
2610}
2611
2612/*
2613 * Link state is waiting for down notification and there is a pending up
2614 */
2615static void
2616bfa_fcport_ln_sm_dn_up_nf(struct bfa_fcport_ln_s *ln,
2617 enum bfa_fcport_ln_sm_event event)
2618{
2619 bfa_trc(ln->fcport->bfa, event);
2620
2621 switch (event) {
2622 case BFA_FCPORT_LN_SM_LINKDOWN:
2623 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf);
2624 break;
2625
2626 case BFA_FCPORT_LN_SM_NOTIFICATION:
2627 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_nf);
2628 bfa_fcport_queue_cb(ln, BFA_PORT_LINKUP);
2629 break;
2630
2631 default:
2632 bfa_sm_fault(ln->fcport->bfa, event);
2633 }
2634}
2635
2636/*
2637 * Link state is up
2638 */
2639static void
2640bfa_fcport_ln_sm_up(struct bfa_fcport_ln_s *ln,
2641 enum bfa_fcport_ln_sm_event event)
2642{
2643 bfa_trc(ln->fcport->bfa, event);
2644
2645 switch (event) {
2646 case BFA_FCPORT_LN_SM_LINKDOWN:
2647 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf);
2648 bfa_fcport_queue_cb(ln, BFA_PORT_LINKDOWN);
2649 break;
2650
2651 default:
2652 bfa_sm_fault(ln->fcport->bfa, event);
2653 }
2654}
2655
2656/*
2657 * Link state is waiting for up notification
2658 */
2659static void
2660bfa_fcport_ln_sm_up_nf(struct bfa_fcport_ln_s *ln,
2661 enum bfa_fcport_ln_sm_event event)
2662{
2663 bfa_trc(ln->fcport->bfa, event);
2664
2665 switch (event) {
2666 case BFA_FCPORT_LN_SM_LINKDOWN:
2667 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_nf);
2668 break;
2669
2670 case BFA_FCPORT_LN_SM_NOTIFICATION:
2671 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up);
2672 break;
2673
2674 default:
2675 bfa_sm_fault(ln->fcport->bfa, event);
2676 }
2677}
2678
2679/*
2680 * Link state is waiting for up notification and there is a pending down
2681 */
2682static void
2683bfa_fcport_ln_sm_up_dn_nf(struct bfa_fcport_ln_s *ln,
2684 enum bfa_fcport_ln_sm_event event)
2685{
2686 bfa_trc(ln->fcport->bfa, event);
2687
2688 switch (event) {
2689 case BFA_FCPORT_LN_SM_LINKUP:
2690 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_up_nf);
2691 break;
2692
2693 case BFA_FCPORT_LN_SM_NOTIFICATION:
2694 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_nf);
2695 bfa_fcport_queue_cb(ln, BFA_PORT_LINKDOWN);
2696 break;
2697
2698 default:
2699 bfa_sm_fault(ln->fcport->bfa, event);
2700 }
2701}
2702
2703/*
2704 * Link state is waiting for up notification and there are pending down and up
2705 */
2706static void
2707bfa_fcport_ln_sm_up_dn_up_nf(struct bfa_fcport_ln_s *ln,
2708 enum bfa_fcport_ln_sm_event event)
2709{
2710 bfa_trc(ln->fcport->bfa, event);
2711
2712 switch (event) {
2713 case BFA_FCPORT_LN_SM_LINKDOWN:
2714 bfa_sm_set_state(ln, bfa_fcport_ln_sm_up_dn_nf);
2715 break;
2716
2717 case BFA_FCPORT_LN_SM_NOTIFICATION:
2718 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn_up_nf);
2719 bfa_fcport_queue_cb(ln, BFA_PORT_LINKDOWN);
2720 break;
2721
2722 default:
2723 bfa_sm_fault(ln->fcport->bfa, event);
2724 }
2725}
2726
2727static void
2728__bfa_cb_fcport_event(void *cbarg, bfa_boolean_t complete)
2729{
2730 struct bfa_fcport_ln_s *ln = cbarg;
2731
2732 if (complete)
2733 ln->fcport->event_cbfn(ln->fcport->event_cbarg, ln->ln_event);
2734 else
2735 bfa_sm_send_event(ln, BFA_FCPORT_LN_SM_NOTIFICATION);
2736}
2737
2738/*
2739 * Send SCN notification to upper layers.
2740 * trunk - false if caller is fcport to ignore fcport event in trunked mode
2741 */
2742static void
2743bfa_fcport_scn(struct bfa_fcport_s *fcport, enum bfa_port_linkstate event,
2744 bfa_boolean_t trunk)
2745{
2746 if (fcport->cfg.trunked && !trunk)
2747 return;
2748
2749 switch (event) {
2750 case BFA_PORT_LINKUP:
2751 bfa_sm_send_event(&fcport->ln, BFA_FCPORT_LN_SM_LINKUP);
2752 break;
2753 case BFA_PORT_LINKDOWN:
2754 bfa_sm_send_event(&fcport->ln, BFA_FCPORT_LN_SM_LINKDOWN);
2755 break;
2756 default:
2757 WARN_ON(1);
2758 }
2759}
2760
2761static void
2762bfa_fcport_queue_cb(struct bfa_fcport_ln_s *ln, enum bfa_port_linkstate event)
2763{
2764 struct bfa_fcport_s *fcport = ln->fcport;
2765
2766 if (fcport->bfa->fcs) {
2767 fcport->event_cbfn(fcport->event_cbarg, event);
2768 bfa_sm_send_event(ln, BFA_FCPORT_LN_SM_NOTIFICATION);
2769 } else {
2770 ln->ln_event = event;
2771 bfa_cb_queue(fcport->bfa, &ln->ln_qe,
2772 __bfa_cb_fcport_event, ln);
2773 }
2774}
2775
2776#define FCPORT_STATS_DMA_SZ (BFA_ROUNDUP(sizeof(union bfa_fcport_stats_u), \
2777 BFA_CACHELINE_SZ))
2778
2779static void
2780bfa_fcport_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len,
2781 u32 *dm_len)
2782{
2783 *dm_len += FCPORT_STATS_DMA_SZ;
2784}
2785
2786static void
2787bfa_fcport_qresume(void *cbarg)
2788{
2789 struct bfa_fcport_s *fcport = cbarg;
2790
2791 bfa_sm_send_event(fcport, BFA_FCPORT_SM_QRESUME);
2792}
2793
2794static void
2795bfa_fcport_mem_claim(struct bfa_fcport_s *fcport, struct bfa_meminfo_s *meminfo)
2796{
2797 u8 *dm_kva;
2798 u64 dm_pa;
2799
2800 dm_kva = bfa_meminfo_dma_virt(meminfo);
2801 dm_pa = bfa_meminfo_dma_phys(meminfo);
2802
2803 fcport->stats_kva = dm_kva;
2804 fcport->stats_pa = dm_pa;
2805 fcport->stats = (union bfa_fcport_stats_u *) dm_kva;
2806
2807 dm_kva += FCPORT_STATS_DMA_SZ;
2808 dm_pa += FCPORT_STATS_DMA_SZ;
2809
2810 bfa_meminfo_dma_virt(meminfo) = dm_kva;
2811 bfa_meminfo_dma_phys(meminfo) = dm_pa;
2812}
2813
2814/*
2815 * Memory initialization.
2816 */
2817static void
2818bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
2819 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
2820{
2821 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
2822 struct bfa_port_cfg_s *port_cfg = &fcport->cfg;
2823 struct bfa_fcport_ln_s *ln = &fcport->ln;
2824 struct timeval tv;
2825
2826 memset(fcport, 0, sizeof(struct bfa_fcport_s));
2827 fcport->bfa = bfa;
2828 ln->fcport = fcport;
2829
2830 bfa_fcport_mem_claim(fcport, meminfo);
2831
2832 bfa_sm_set_state(fcport, bfa_fcport_sm_uninit);
2833 bfa_sm_set_state(ln, bfa_fcport_ln_sm_dn);
2834
2835 /*
2836 * initialize time stamp for stats reset
2837 */
2838 do_gettimeofday(&tv);
2839 fcport->stats_reset_time = tv.tv_sec;
2840
2841 /*
2842 * initialize and set default configuration
2843 */
2844 port_cfg->topology = BFA_PORT_TOPOLOGY_P2P;
2845 port_cfg->speed = BFA_PORT_SPEED_AUTO;
2846 port_cfg->trunked = BFA_FALSE;
2847 port_cfg->maxfrsize = 0;
2848
2849 port_cfg->trl_def_speed = BFA_PORT_SPEED_1GBPS;
2850
2851 bfa_reqq_winit(&fcport->reqq_wait, bfa_fcport_qresume, fcport);
2852}
2853
2854static void
2855bfa_fcport_detach(struct bfa_s *bfa)
2856{
2857}
2858
2859/*
2860 * Called when IOC is ready.
2861 */
2862static void
2863bfa_fcport_start(struct bfa_s *bfa)
2864{
2865 bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_START);
2866}
2867
2868/*
2869 * Called before IOC is stopped.
2870 */
2871static void
2872bfa_fcport_stop(struct bfa_s *bfa)
2873{
2874 bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_STOP);
2875 bfa_trunk_iocdisable(bfa);
2876}
2877
2878/*
2879 * Called when IOC failure is detected.
2880 */
2881static void
2882bfa_fcport_iocdisable(struct bfa_s *bfa)
2883{
2884 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
2885
2886 bfa_sm_send_event(fcport, BFA_FCPORT_SM_HWFAIL);
2887 bfa_trunk_iocdisable(bfa);
2888}
2889
2890static void
2891bfa_fcport_update_linkinfo(struct bfa_fcport_s *fcport)
2892{
2893 struct bfi_fcport_event_s *pevent = fcport->event_arg.i2hmsg.event;
2894 struct bfa_fcport_trunk_s *trunk = &fcport->trunk;
2895
2896 fcport->speed = pevent->link_state.speed;
2897 fcport->topology = pevent->link_state.topology;
2898
2899 if (fcport->topology == BFA_PORT_TOPOLOGY_LOOP)
2900 fcport->myalpa = 0;
2901
2902 /* QoS Details */
2903 fcport->qos_attr = pevent->link_state.qos_attr;
2904 fcport->qos_vc_attr = pevent->link_state.vc_fcf.qos_vc_attr;
2905
2906 /*
2907 * update trunk state if applicable
2908 */
2909 if (!fcport->cfg.trunked)
2910 trunk->attr.state = BFA_TRUNK_DISABLED;
2911
2912 /* update FCoE specific */
2913 fcport->fcoe_vlan = be16_to_cpu(pevent->link_state.vc_fcf.fcf.vlan);
2914
2915 bfa_trc(fcport->bfa, fcport->speed);
2916 bfa_trc(fcport->bfa, fcport->topology);
2917}
2918
2919static void
2920bfa_fcport_reset_linkinfo(struct bfa_fcport_s *fcport)
2921{
2922 fcport->speed = BFA_PORT_SPEED_UNKNOWN;
2923 fcport->topology = BFA_PORT_TOPOLOGY_NONE;
2924}
2925
2926/*
2927 * Send port enable message to firmware.
2928 */
2929static bfa_boolean_t
2930bfa_fcport_send_enable(struct bfa_fcport_s *fcport)
2931{
2932 struct bfi_fcport_enable_req_s *m;
2933
2934 /*
2935 * Increment message tag before queue check, so that responses to old
2936 * requests are discarded.
2937 */
2938 fcport->msgtag++;
2939
2940 /*
2941 * check for room in queue to send request now
2942 */
2943 m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
2944 if (!m) {
2945 bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
2946 &fcport->reqq_wait);
2947 return BFA_FALSE;
2948 }
2949
2950 bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_ENABLE_REQ,
2951 bfa_lpuid(fcport->bfa));
2952 m->nwwn = fcport->nwwn;
2953 m->pwwn = fcport->pwwn;
2954 m->port_cfg = fcport->cfg;
2955 m->msgtag = fcport->msgtag;
2956 m->port_cfg.maxfrsize = cpu_to_be16(fcport->cfg.maxfrsize);
2957 m->use_flash_cfg = fcport->use_flash_cfg;
2958 bfa_dma_be_addr_set(m->stats_dma_addr, fcport->stats_pa);
2959 bfa_trc(fcport->bfa, m->stats_dma_addr.a32.addr_lo);
2960 bfa_trc(fcport->bfa, m->stats_dma_addr.a32.addr_hi);
2961
2962 /*
2963 * queue I/O message to firmware
2964 */
2965 bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT);
2966 return BFA_TRUE;
2967}
2968
2969/*
2970 * Send port disable message to firmware.
2971 */
2972static bfa_boolean_t
2973bfa_fcport_send_disable(struct bfa_fcport_s *fcport)
2974{
2975 struct bfi_fcport_req_s *m;
2976
2977 /*
2978 * Increment message tag before queue check, so that responses to old
2979 * requests are discarded.
2980 */
2981 fcport->msgtag++;
2982
2983 /*
2984 * check for room in queue to send request now
2985 */
2986 m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
2987 if (!m) {
2988 bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
2989 &fcport->reqq_wait);
2990 return BFA_FALSE;
2991 }
2992
2993 bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_DISABLE_REQ,
2994 bfa_lpuid(fcport->bfa));
2995 m->msgtag = fcport->msgtag;
2996
2997 /*
2998 * queue I/O message to firmware
2999 */
3000 bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT);
3001
3002 return BFA_TRUE;
3003}
3004
3005static void
3006bfa_fcport_set_wwns(struct bfa_fcport_s *fcport)
3007{
3008 fcport->pwwn = fcport->bfa->ioc.attr->pwwn;
3009 fcport->nwwn = fcport->bfa->ioc.attr->nwwn;
3010
3011 bfa_trc(fcport->bfa, fcport->pwwn);
3012 bfa_trc(fcport->bfa, fcport->nwwn);
3013}
3014
3015static void
3016bfa_fcport_send_txcredit(void *port_cbarg)
3017{
3018
3019 struct bfa_fcport_s *fcport = port_cbarg;
3020 struct bfi_fcport_set_svc_params_req_s *m;
3021
3022 /*
3023 * check for room in queue to send request now
3024 */
3025 m = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
3026 if (!m) {
3027 bfa_trc(fcport->bfa, fcport->cfg.tx_bbcredit);
3028 return;
3029 }
3030
3031 bfi_h2i_set(m->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ,
3032 bfa_lpuid(fcport->bfa));
3033 m->tx_bbcredit = cpu_to_be16((u16)fcport->cfg.tx_bbcredit);
3034
3035 /*
3036 * queue I/O message to firmware
3037 */
3038 bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT);
3039}
3040
3041static void
3042bfa_fcport_qos_stats_swap(struct bfa_qos_stats_s *d,
3043 struct bfa_qos_stats_s *s)
3044{
3045 u32 *dip = (u32 *) d;
3046 __be32 *sip = (__be32 *) s;
3047 int i;
3048
3049 /* Now swap the 32 bit fields */
3050 for (i = 0; i < (sizeof(struct bfa_qos_stats_s)/sizeof(u32)); ++i)
3051 dip[i] = be32_to_cpu(sip[i]);
3052}
3053
3054static void
3055bfa_fcport_fcoe_stats_swap(struct bfa_fcoe_stats_s *d,
3056 struct bfa_fcoe_stats_s *s)
3057{
3058 u32 *dip = (u32 *) d;
3059 __be32 *sip = (__be32 *) s;
3060 int i;
3061
3062 for (i = 0; i < ((sizeof(struct bfa_fcoe_stats_s))/sizeof(u32));
3063 i = i + 2) {
3064#ifdef __BIG_ENDIAN
3065 dip[i] = be32_to_cpu(sip[i]);
3066 dip[i + 1] = be32_to_cpu(sip[i + 1]);
3067#else
3068 dip[i] = be32_to_cpu(sip[i + 1]);
3069 dip[i + 1] = be32_to_cpu(sip[i]);
3070#endif
3071 }
3072}
3073
3074static void
3075__bfa_cb_fcport_stats_get(void *cbarg, bfa_boolean_t complete)
3076{
3077 struct bfa_fcport_s *fcport = cbarg;
3078
3079 if (complete) {
3080 if (fcport->stats_status == BFA_STATUS_OK) {
3081 struct timeval tv;
3082
3083 /* Swap FC QoS or FCoE stats */
3084 if (bfa_ioc_get_fcmode(&fcport->bfa->ioc)) {
3085 bfa_fcport_qos_stats_swap(
3086 &fcport->stats_ret->fcqos,
3087 &fcport->stats->fcqos);
3088 } else {
3089 bfa_fcport_fcoe_stats_swap(
3090 &fcport->stats_ret->fcoe,
3091 &fcport->stats->fcoe);
3092
3093 do_gettimeofday(&tv);
3094 fcport->stats_ret->fcoe.secs_reset =
3095 tv.tv_sec - fcport->stats_reset_time;
3096 }
3097 }
3098 fcport->stats_cbfn(fcport->stats_cbarg, fcport->stats_status);
3099 } else {
3100 fcport->stats_busy = BFA_FALSE;
3101 fcport->stats_status = BFA_STATUS_OK;
3102 }
3103}
3104
3105static void
3106bfa_fcport_stats_get_timeout(void *cbarg)
3107{
3108 struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
3109
3110 bfa_trc(fcport->bfa, fcport->stats_qfull);
3111
3112 if (fcport->stats_qfull) {
3113 bfa_reqq_wcancel(&fcport->stats_reqq_wait);
3114 fcport->stats_qfull = BFA_FALSE;
3115 }
3116
3117 fcport->stats_status = BFA_STATUS_ETIMER;
3118 bfa_cb_queue(fcport->bfa, &fcport->hcb_qe, __bfa_cb_fcport_stats_get,
3119 fcport);
3120}
3121
3122static void
3123bfa_fcport_send_stats_get(void *cbarg)
3124{
3125 struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
3126 struct bfi_fcport_req_s *msg;
3127
3128 msg = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
3129
3130 if (!msg) {
3131 fcport->stats_qfull = BFA_TRUE;
3132 bfa_reqq_winit(&fcport->stats_reqq_wait,
3133 bfa_fcport_send_stats_get, fcport);
3134 bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
3135 &fcport->stats_reqq_wait);
3136 return;
3137 }
3138 fcport->stats_qfull = BFA_FALSE;
3139
3140 memset(msg, 0, sizeof(struct bfi_fcport_req_s));
3141 bfi_h2i_set(msg->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_STATS_GET_REQ,
3142 bfa_lpuid(fcport->bfa));
3143 bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT);
3144}
3145
3146static void
3147__bfa_cb_fcport_stats_clr(void *cbarg, bfa_boolean_t complete)
3148{
3149 struct bfa_fcport_s *fcport = cbarg;
3150
3151 if (complete) {
3152 struct timeval tv;
3153
3154 /*
3155 * re-initialize time stamp for stats reset
3156 */
3157 do_gettimeofday(&tv);
3158 fcport->stats_reset_time = tv.tv_sec;
3159
3160 fcport->stats_cbfn(fcport->stats_cbarg, fcport->stats_status);
3161 } else {
3162 fcport->stats_busy = BFA_FALSE;
3163 fcport->stats_status = BFA_STATUS_OK;
3164 }
3165}
3166
3167static void
3168bfa_fcport_stats_clr_timeout(void *cbarg)
3169{
3170 struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
3171
3172 bfa_trc(fcport->bfa, fcport->stats_qfull);
3173
3174 if (fcport->stats_qfull) {
3175 bfa_reqq_wcancel(&fcport->stats_reqq_wait);
3176 fcport->stats_qfull = BFA_FALSE;
3177 }
3178
3179 fcport->stats_status = BFA_STATUS_ETIMER;
3180 bfa_cb_queue(fcport->bfa, &fcport->hcb_qe,
3181 __bfa_cb_fcport_stats_clr, fcport);
3182}
3183
3184static void
3185bfa_fcport_send_stats_clear(void *cbarg)
3186{
3187 struct bfa_fcport_s *fcport = (struct bfa_fcport_s *) cbarg;
3188 struct bfi_fcport_req_s *msg;
3189
3190 msg = bfa_reqq_next(fcport->bfa, BFA_REQQ_PORT);
3191
3192 if (!msg) {
3193 fcport->stats_qfull = BFA_TRUE;
3194 bfa_reqq_winit(&fcport->stats_reqq_wait,
3195 bfa_fcport_send_stats_clear, fcport);
3196 bfa_reqq_wait(fcport->bfa, BFA_REQQ_PORT,
3197 &fcport->stats_reqq_wait);
3198 return;
3199 }
3200 fcport->stats_qfull = BFA_FALSE;
3201
3202 memset(msg, 0, sizeof(struct bfi_fcport_req_s));
3203 bfi_h2i_set(msg->mh, BFI_MC_FCPORT, BFI_FCPORT_H2I_STATS_CLEAR_REQ,
3204 bfa_lpuid(fcport->bfa));
3205 bfa_reqq_produce(fcport->bfa, BFA_REQQ_PORT);
3206}
3207
3208/*
3209 * Handle trunk SCN event from firmware.
3210 */
3211static void
3212bfa_trunk_scn(struct bfa_fcport_s *fcport, struct bfi_fcport_trunk_scn_s *scn)
3213{
3214 struct bfa_fcport_trunk_s *trunk = &fcport->trunk;
3215 struct bfi_fcport_trunk_link_s *tlink;
3216 struct bfa_trunk_link_attr_s *lattr;
3217 enum bfa_trunk_state state_prev;
3218 int i;
3219 int link_bm = 0;
3220
3221 bfa_trc(fcport->bfa, fcport->cfg.trunked);
3222 WARN_ON(scn->trunk_state != BFA_TRUNK_ONLINE &&
3223 scn->trunk_state != BFA_TRUNK_OFFLINE);
3224
3225 bfa_trc(fcport->bfa, trunk->attr.state);
3226 bfa_trc(fcport->bfa, scn->trunk_state);
3227 bfa_trc(fcport->bfa, scn->trunk_speed);
3228
3229 /*
3230 * Save off new state for trunk attribute query
3231 */
3232 state_prev = trunk->attr.state;
3233 if (fcport->cfg.trunked && (trunk->attr.state != BFA_TRUNK_DISABLED))
3234 trunk->attr.state = scn->trunk_state;
3235 trunk->attr.speed = scn->trunk_speed;
3236 for (i = 0; i < BFA_TRUNK_MAX_PORTS; i++) {
3237 lattr = &trunk->attr.link_attr[i];
3238 tlink = &scn->tlink[i];
3239
3240 lattr->link_state = tlink->state;
3241 lattr->trunk_wwn = tlink->trunk_wwn;
3242 lattr->fctl = tlink->fctl;
3243 lattr->speed = tlink->speed;
3244 lattr->deskew = be32_to_cpu(tlink->deskew);
3245
3246 if (tlink->state == BFA_TRUNK_LINK_STATE_UP) {
3247 fcport->speed = tlink->speed;
3248 fcport->topology = BFA_PORT_TOPOLOGY_P2P;
3249 link_bm |= 1 << i;
3250 }
3251
3252 bfa_trc(fcport->bfa, lattr->link_state);
3253 bfa_trc(fcport->bfa, lattr->trunk_wwn);
3254 bfa_trc(fcport->bfa, lattr->fctl);
3255 bfa_trc(fcport->bfa, lattr->speed);
3256 bfa_trc(fcport->bfa, lattr->deskew);
3257 }
3258
3259 switch (link_bm) {
3260 case 3:
3261 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
3262 BFA_PL_EID_TRUNK_SCN, 0, "Trunk up(0,1)");
3263 break;
3264 case 2:
3265 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
3266 BFA_PL_EID_TRUNK_SCN, 0, "Trunk up(-,1)");
3267 break;
3268 case 1:
3269 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
3270 BFA_PL_EID_TRUNK_SCN, 0, "Trunk up(0,-)");
3271 break;
3272 default:
3273 bfa_plog_str(fcport->bfa->plog, BFA_PL_MID_HAL,
3274 BFA_PL_EID_TRUNK_SCN, 0, "Trunk down");
3275 }
3276
3277 /*
3278 * Notify upper layers if trunk state changed.
3279 */
3280 if ((state_prev != trunk->attr.state) ||
3281 (scn->trunk_state == BFA_TRUNK_OFFLINE)) {
3282 bfa_fcport_scn(fcport, (scn->trunk_state == BFA_TRUNK_ONLINE) ?
3283 BFA_PORT_LINKUP : BFA_PORT_LINKDOWN, BFA_TRUE);
3284 }
3285}
3286
3287static void
3288bfa_trunk_iocdisable(struct bfa_s *bfa)
3289{
3290 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3291 int i = 0;
3292
3293 /*
3294 * In trunked mode, notify upper layers that link is down
3295 */
3296 if (fcport->cfg.trunked) {
3297 if (fcport->trunk.attr.state == BFA_TRUNK_ONLINE)
3298 bfa_fcport_scn(fcport, BFA_PORT_LINKDOWN, BFA_TRUE);
3299
3300 fcport->trunk.attr.state = BFA_TRUNK_OFFLINE;
3301 fcport->trunk.attr.speed = BFA_PORT_SPEED_UNKNOWN;
3302 for (i = 0; i < BFA_TRUNK_MAX_PORTS; i++) {
3303 fcport->trunk.attr.link_attr[i].trunk_wwn = 0;
3304 fcport->trunk.attr.link_attr[i].fctl =
3305 BFA_TRUNK_LINK_FCTL_NORMAL;
3306 fcport->trunk.attr.link_attr[i].link_state =
3307 BFA_TRUNK_LINK_STATE_DN_LINKDN;
3308 fcport->trunk.attr.link_attr[i].speed =
3309 BFA_PORT_SPEED_UNKNOWN;
3310 fcport->trunk.attr.link_attr[i].deskew = 0;
3311 }
3312 }
3313}
3314
3315/*
3316 * Called to initialize port attributes
3317 */
3318void
3319bfa_fcport_init(struct bfa_s *bfa)
3320{
3321 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3322
3323 /*
3324 * Initialize port attributes from IOC hardware data.
3325 */
3326 bfa_fcport_set_wwns(fcport);
3327 if (fcport->cfg.maxfrsize == 0)
3328 fcport->cfg.maxfrsize = bfa_ioc_maxfrsize(&bfa->ioc);
3329 fcport->cfg.rx_bbcredit = bfa_ioc_rx_bbcredit(&bfa->ioc);
3330 fcport->speed_sup = bfa_ioc_speed_sup(&bfa->ioc);
3331
3332 WARN_ON(!fcport->cfg.maxfrsize);
3333 WARN_ON(!fcport->cfg.rx_bbcredit);
3334 WARN_ON(!fcport->speed_sup);
3335}
3336
3337/*
3338 * Firmware message handler.
3339 */
3340void
3341bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
3342{
3343 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3344 union bfi_fcport_i2h_msg_u i2hmsg;
3345
3346 i2hmsg.msg = msg;
3347 fcport->event_arg.i2hmsg = i2hmsg;
3348
3349 bfa_trc(bfa, msg->mhdr.msg_id);
3350 bfa_trc(bfa, bfa_sm_to_state(hal_port_sm_table, fcport->sm));
3351
3352 switch (msg->mhdr.msg_id) {
3353 case BFI_FCPORT_I2H_ENABLE_RSP:
3354 if (fcport->msgtag == i2hmsg.penable_rsp->msgtag) {
3355
3356 if (fcport->use_flash_cfg) {
3357 fcport->cfg = i2hmsg.penable_rsp->port_cfg;
3358 fcport->cfg.maxfrsize =
3359 cpu_to_be16(fcport->cfg.maxfrsize);
3360 fcport->cfg.path_tov =
3361 cpu_to_be16(fcport->cfg.path_tov);
3362 fcport->cfg.q_depth =
3363 cpu_to_be16(fcport->cfg.q_depth);
3364
3365 if (fcport->cfg.trunked)
3366 fcport->trunk.attr.state =
3367 BFA_TRUNK_OFFLINE;
3368 else
3369 fcport->trunk.attr.state =
3370 BFA_TRUNK_DISABLED;
3371 fcport->use_flash_cfg = BFA_FALSE;
3372 }
3373
3374 bfa_sm_send_event(fcport, BFA_FCPORT_SM_FWRSP);
3375 }
3376 break;
3377
3378 case BFI_FCPORT_I2H_DISABLE_RSP:
3379 if (fcport->msgtag == i2hmsg.penable_rsp->msgtag)
3380 bfa_sm_send_event(fcport, BFA_FCPORT_SM_FWRSP);
3381 break;
3382
3383 case BFI_FCPORT_I2H_EVENT:
3384 if (i2hmsg.event->link_state.linkstate == BFA_PORT_LINKUP)
3385 bfa_sm_send_event(fcport, BFA_FCPORT_SM_LINKUP);
3386 else
3387 bfa_sm_send_event(fcport, BFA_FCPORT_SM_LINKDOWN);
3388 break;
3389
3390 case BFI_FCPORT_I2H_TRUNK_SCN:
3391 bfa_trunk_scn(fcport, i2hmsg.trunk_scn);
3392 break;
3393
3394 case BFI_FCPORT_I2H_STATS_GET_RSP:
3395 /*
3396 * check for timer pop before processing the rsp
3397 */
3398 if (fcport->stats_busy == BFA_FALSE ||
3399 fcport->stats_status == BFA_STATUS_ETIMER)
3400 break;
3401
3402 bfa_timer_stop(&fcport->timer);
3403 fcport->stats_status = i2hmsg.pstatsget_rsp->status;
3404 bfa_cb_queue(fcport->bfa, &fcport->hcb_qe,
3405 __bfa_cb_fcport_stats_get, fcport);
3406 break;
3407
3408 case BFI_FCPORT_I2H_STATS_CLEAR_RSP:
3409 /*
3410 * check for timer pop before processing the rsp
3411 */
3412 if (fcport->stats_busy == BFA_FALSE ||
3413 fcport->stats_status == BFA_STATUS_ETIMER)
3414 break;
3415
3416 bfa_timer_stop(&fcport->timer);
3417 fcport->stats_status = BFA_STATUS_OK;
3418 bfa_cb_queue(fcport->bfa, &fcport->hcb_qe,
3419 __bfa_cb_fcport_stats_clr, fcport);
3420 break;
3421
3422 case BFI_FCPORT_I2H_ENABLE_AEN:
3423 bfa_sm_send_event(fcport, BFA_FCPORT_SM_ENABLE);
3424 break;
3425
3426 case BFI_FCPORT_I2H_DISABLE_AEN:
3427 bfa_sm_send_event(fcport, BFA_FCPORT_SM_DISABLE);
3428 break;
3429
3430 default:
3431 WARN_ON(1);
3432 break;
3433 }
3434}
3435
3436/*
3437 * Registered callback for port events.
3438 */
3439void
3440bfa_fcport_event_register(struct bfa_s *bfa,
3441 void (*cbfn) (void *cbarg,
3442 enum bfa_port_linkstate event),
3443 void *cbarg)
3444{
3445 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3446
3447 fcport->event_cbfn = cbfn;
3448 fcport->event_cbarg = cbarg;
3449}
3450
3451bfa_status_t
3452bfa_fcport_enable(struct bfa_s *bfa)
3453{
3454 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3455
3456 if (bfa_ioc_is_disabled(&bfa->ioc))
3457 return BFA_STATUS_IOC_DISABLED;
3458
3459 if (fcport->diag_busy)
3460 return BFA_STATUS_DIAG_BUSY;
3461
3462 bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_ENABLE);
3463 return BFA_STATUS_OK;
3464}
3465
3466bfa_status_t
3467bfa_fcport_disable(struct bfa_s *bfa)
3468{
3469
3470 if (bfa_ioc_is_disabled(&bfa->ioc))
3471 return BFA_STATUS_IOC_DISABLED;
3472
3473 bfa_sm_send_event(BFA_FCPORT_MOD(bfa), BFA_FCPORT_SM_DISABLE);
3474 return BFA_STATUS_OK;
3475}
3476
3477/*
3478 * Configure port speed.
3479 */
3480bfa_status_t
3481bfa_fcport_cfg_speed(struct bfa_s *bfa, enum bfa_port_speed speed)
3482{
3483 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3484
3485 bfa_trc(bfa, speed);
3486
3487 if (fcport->cfg.trunked == BFA_TRUE)
3488 return BFA_STATUS_TRUNK_ENABLED;
3489 if ((speed != BFA_PORT_SPEED_AUTO) && (speed > fcport->speed_sup)) {
3490 bfa_trc(bfa, fcport->speed_sup);
3491 return BFA_STATUS_UNSUPP_SPEED;
3492 }
3493
3494 fcport->cfg.speed = speed;
3495
3496 return BFA_STATUS_OK;
3497}
3498
3499/*
3500 * Get current speed.
3501 */
3502enum bfa_port_speed
3503bfa_fcport_get_speed(struct bfa_s *bfa)
3504{
3505 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3506
3507 return fcport->speed;
3508}
3509
3510/*
3511 * Configure port topology.
3512 */
3513bfa_status_t
3514bfa_fcport_cfg_topology(struct bfa_s *bfa, enum bfa_port_topology topology)
3515{
3516 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3517
3518 bfa_trc(bfa, topology);
3519 bfa_trc(bfa, fcport->cfg.topology);
3520
3521 switch (topology) {
3522 case BFA_PORT_TOPOLOGY_P2P:
3523 case BFA_PORT_TOPOLOGY_LOOP:
3524 case BFA_PORT_TOPOLOGY_AUTO:
3525 break;
3526
3527 default:
3528 return BFA_STATUS_EINVAL;
3529 }
3530
3531 fcport->cfg.topology = topology;
3532 return BFA_STATUS_OK;
3533}
3534
3535/*
3536 * Get current topology.
3537 */
3538enum bfa_port_topology
3539bfa_fcport_get_topology(struct bfa_s *bfa)
3540{
3541 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3542
3543 return fcport->topology;
3544}
3545
3546bfa_status_t
3547bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa)
3548{
3549 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3550
3551 bfa_trc(bfa, alpa);
3552 bfa_trc(bfa, fcport->cfg.cfg_hardalpa);
3553 bfa_trc(bfa, fcport->cfg.hardalpa);
3554
3555 fcport->cfg.cfg_hardalpa = BFA_TRUE;
3556 fcport->cfg.hardalpa = alpa;
3557
3558 return BFA_STATUS_OK;
3559}
3560
3561bfa_status_t
3562bfa_fcport_clr_hardalpa(struct bfa_s *bfa)
3563{
3564 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3565
3566 bfa_trc(bfa, fcport->cfg.cfg_hardalpa);
3567 bfa_trc(bfa, fcport->cfg.hardalpa);
3568
3569 fcport->cfg.cfg_hardalpa = BFA_FALSE;
3570 return BFA_STATUS_OK;
3571}
3572
3573bfa_boolean_t
3574bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa)
3575{
3576 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3577
3578 *alpa = fcport->cfg.hardalpa;
3579 return fcport->cfg.cfg_hardalpa;
3580}
3581
3582u8
3583bfa_fcport_get_myalpa(struct bfa_s *bfa)
3584{
3585 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3586
3587 return fcport->myalpa;
3588}
3589
3590bfa_status_t
3591bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxfrsize)
3592{
3593 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3594
3595 bfa_trc(bfa, maxfrsize);
3596 bfa_trc(bfa, fcport->cfg.maxfrsize);
3597
3598 /* with in range */
3599 if ((maxfrsize > FC_MAX_PDUSZ) || (maxfrsize < FC_MIN_PDUSZ))
3600 return BFA_STATUS_INVLD_DFSZ;
3601
3602 /* power of 2, if not the max frame size of 2112 */
3603 if ((maxfrsize != FC_MAX_PDUSZ) && (maxfrsize & (maxfrsize - 1)))
3604 return BFA_STATUS_INVLD_DFSZ;
3605
3606 fcport->cfg.maxfrsize = maxfrsize;
3607 return BFA_STATUS_OK;
3608}
3609
3610u16
3611bfa_fcport_get_maxfrsize(struct bfa_s *bfa)
3612{
3613 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3614
3615 return fcport->cfg.maxfrsize;
3616}
3617
3618u8
3619bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa)
3620{
3621 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3622
3623 return fcport->cfg.rx_bbcredit;
3624}
3625
3626void
3627bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit)
3628{
3629 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3630
3631 fcport->cfg.tx_bbcredit = (u8)tx_bbcredit;
3632 bfa_fcport_send_txcredit(fcport);
3633}
3634
3635/*
3636 * Get port attributes.
3637 */
3638
3639wwn_t
3640bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node)
3641{
3642 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3643 if (node)
3644 return fcport->nwwn;
3645 else
3646 return fcport->pwwn;
3647}
3648
3649void
3650bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr)
3651{
3652 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3653
3654 memset(attr, 0, sizeof(struct bfa_port_attr_s));
3655
3656 attr->nwwn = fcport->nwwn;
3657 attr->pwwn = fcport->pwwn;
3658
3659 attr->factorypwwn = bfa->ioc.attr->mfg_pwwn;
3660 attr->factorynwwn = bfa->ioc.attr->mfg_nwwn;
3661
3662 memcpy(&attr->pport_cfg, &fcport->cfg,
3663 sizeof(struct bfa_port_cfg_s));
3664 /* speed attributes */
3665 attr->pport_cfg.speed = fcport->cfg.speed;
3666 attr->speed_supported = fcport->speed_sup;
3667 attr->speed = fcport->speed;
3668 attr->cos_supported = FC_CLASS_3;
3669
3670 /* topology attributes */
3671 attr->pport_cfg.topology = fcport->cfg.topology;
3672 attr->topology = fcport->topology;
3673 attr->pport_cfg.trunked = fcport->cfg.trunked;
3674
3675 /* beacon attributes */
3676 attr->beacon = fcport->beacon;
3677 attr->link_e2e_beacon = fcport->link_e2e_beacon;
3678 attr->plog_enabled = (bfa_boolean_t)fcport->bfa->plog->plog_enabled;
3679 attr->io_profile = bfa_fcpim_get_io_profile(fcport->bfa);
3680
3681 attr->pport_cfg.path_tov = bfa_fcpim_path_tov_get(bfa);
3682 attr->pport_cfg.q_depth = bfa_fcpim_qdepth_get(bfa);
3683 attr->port_state = bfa_sm_to_state(hal_port_sm_table, fcport->sm);
3684 if (bfa_ioc_is_disabled(&fcport->bfa->ioc))
3685 attr->port_state = BFA_PORT_ST_IOCDIS;
3686 else if (bfa_ioc_fw_mismatch(&fcport->bfa->ioc))
3687 attr->port_state = BFA_PORT_ST_FWMISMATCH;
3688
3689 /* FCoE vlan */
3690 attr->fcoe_vlan = fcport->fcoe_vlan;
3691}
3692
3693#define BFA_FCPORT_STATS_TOV 1000
3694
3695/*
3696 * Fetch port statistics (FCQoS or FCoE).
3697 */
3698bfa_status_t
3699bfa_fcport_get_stats(struct bfa_s *bfa, union bfa_fcport_stats_u *stats,
3700 bfa_cb_port_t cbfn, void *cbarg)
3701{
3702 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3703
3704 if (fcport->stats_busy) {
3705 bfa_trc(bfa, fcport->stats_busy);
3706 return BFA_STATUS_DEVBUSY;
3707 }
3708
3709 fcport->stats_busy = BFA_TRUE;
3710 fcport->stats_ret = stats;
3711 fcport->stats_cbfn = cbfn;
3712 fcport->stats_cbarg = cbarg;
3713
3714 bfa_fcport_send_stats_get(fcport);
3715
3716 bfa_timer_start(bfa, &fcport->timer, bfa_fcport_stats_get_timeout,
3717 fcport, BFA_FCPORT_STATS_TOV);
3718 return BFA_STATUS_OK;
3719}
3720
3721/*
3722 * Reset port statistics (FCQoS or FCoE).
3723 */
3724bfa_status_t
3725bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_port_t cbfn, void *cbarg)
3726{
3727 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3728
3729 if (fcport->stats_busy) {
3730 bfa_trc(bfa, fcport->stats_busy);
3731 return BFA_STATUS_DEVBUSY;
3732 }
3733
3734 fcport->stats_busy = BFA_TRUE;
3735 fcport->stats_cbfn = cbfn;
3736 fcport->stats_cbarg = cbarg;
3737
3738 bfa_fcport_send_stats_clear(fcport);
3739
3740 bfa_timer_start(bfa, &fcport->timer, bfa_fcport_stats_clr_timeout,
3741 fcport, BFA_FCPORT_STATS_TOV);
3742 return BFA_STATUS_OK;
3743}
3744
3745
3746/*
3747 * Fetch port attributes.
3748 */
3749bfa_boolean_t
3750bfa_fcport_is_disabled(struct bfa_s *bfa)
3751{
3752 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3753
3754 return bfa_sm_to_state(hal_port_sm_table, fcport->sm) ==
3755 BFA_PORT_ST_DISABLED;
3756
3757}
3758
3759bfa_boolean_t
3760bfa_fcport_is_ratelim(struct bfa_s *bfa)
3761{
3762 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3763
3764 return fcport->cfg.ratelimit ? BFA_TRUE : BFA_FALSE;
3765
3766}
3767
3768/*
3769 * Get default minimum ratelim speed
3770 */
3771enum bfa_port_speed
3772bfa_fcport_get_ratelim_speed(struct bfa_s *bfa)
3773{
3774 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3775
3776 bfa_trc(bfa, fcport->cfg.trl_def_speed);
3777 return fcport->cfg.trl_def_speed;
3778
3779}
3780
3781bfa_boolean_t
3782bfa_fcport_is_linkup(struct bfa_s *bfa)
3783{
3784 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3785
3786 return (!fcport->cfg.trunked &&
3787 bfa_sm_cmp_state(fcport, bfa_fcport_sm_linkup)) ||
3788 (fcport->cfg.trunked &&
3789 fcport->trunk.attr.state == BFA_TRUNK_ONLINE);
3790}
3791
3792bfa_boolean_t
3793bfa_fcport_is_qos_enabled(struct bfa_s *bfa)
3794{
3795 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
3796
3797 return fcport->cfg.qos_enabled;
3798}
3799
3800/*
3801 * Rport State machine functions
3802 */
3803/*
3804 * Beginning state, only online event expected.
3805 */
3806static void
3807bfa_rport_sm_uninit(struct bfa_rport_s *rp, enum bfa_rport_event event)
3808{
3809 bfa_trc(rp->bfa, rp->rport_tag);
3810 bfa_trc(rp->bfa, event);
3811
3812 switch (event) {
3813 case BFA_RPORT_SM_CREATE:
3814 bfa_stats(rp, sm_un_cr);
3815 bfa_sm_set_state(rp, bfa_rport_sm_created);
3816 break;
3817
3818 default:
3819 bfa_stats(rp, sm_un_unexp);
3820 bfa_sm_fault(rp->bfa, event);
3821 }
3822}
3823
3824static void
3825bfa_rport_sm_created(struct bfa_rport_s *rp, enum bfa_rport_event event)
3826{
3827 bfa_trc(rp->bfa, rp->rport_tag);
3828 bfa_trc(rp->bfa, event);
3829
3830 switch (event) {
3831 case BFA_RPORT_SM_ONLINE:
3832 bfa_stats(rp, sm_cr_on);
3833 if (bfa_rport_send_fwcreate(rp))
3834 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
3835 else
3836 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate_qfull);
3837 break;
3838
3839 case BFA_RPORT_SM_DELETE:
3840 bfa_stats(rp, sm_cr_del);
3841 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
3842 bfa_rport_free(rp);
3843 break;
3844
3845 case BFA_RPORT_SM_HWFAIL:
3846 bfa_stats(rp, sm_cr_hwf);
3847 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
3848 break;
3849
3850 default:
3851 bfa_stats(rp, sm_cr_unexp);
3852 bfa_sm_fault(rp->bfa, event);
3853 }
3854}
3855
3856/*
3857 * Waiting for rport create response from firmware.
3858 */
3859static void
3860bfa_rport_sm_fwcreate(struct bfa_rport_s *rp, enum bfa_rport_event event)
3861{
3862 bfa_trc(rp->bfa, rp->rport_tag);
3863 bfa_trc(rp->bfa, event);
3864
3865 switch (event) {
3866 case BFA_RPORT_SM_FWRSP:
3867 bfa_stats(rp, sm_fwc_rsp);
3868 bfa_sm_set_state(rp, bfa_rport_sm_online);
3869 bfa_rport_online_cb(rp);
3870 break;
3871
3872 case BFA_RPORT_SM_DELETE:
3873 bfa_stats(rp, sm_fwc_del);
3874 bfa_sm_set_state(rp, bfa_rport_sm_delete_pending);
3875 break;
3876
3877 case BFA_RPORT_SM_OFFLINE:
3878 bfa_stats(rp, sm_fwc_off);
3879 bfa_sm_set_state(rp, bfa_rport_sm_offline_pending);
3880 break;
3881
3882 case BFA_RPORT_SM_HWFAIL:
3883 bfa_stats(rp, sm_fwc_hwf);
3884 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
3885 break;
3886
3887 default:
3888 bfa_stats(rp, sm_fwc_unexp);
3889 bfa_sm_fault(rp->bfa, event);
3890 }
3891}
3892
3893/*
3894 * Request queue is full, awaiting queue resume to send create request.
3895 */
3896static void
3897bfa_rport_sm_fwcreate_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event)
3898{
3899 bfa_trc(rp->bfa, rp->rport_tag);
3900 bfa_trc(rp->bfa, event);
3901
3902 switch (event) {
3903 case BFA_RPORT_SM_QRESUME:
3904 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
3905 bfa_rport_send_fwcreate(rp);
3906 break;
3907
3908 case BFA_RPORT_SM_DELETE:
3909 bfa_stats(rp, sm_fwc_del);
3910 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
3911 bfa_reqq_wcancel(&rp->reqq_wait);
3912 bfa_rport_free(rp);
3913 break;
3914
3915 case BFA_RPORT_SM_OFFLINE:
3916 bfa_stats(rp, sm_fwc_off);
3917 bfa_sm_set_state(rp, bfa_rport_sm_offline);
3918 bfa_reqq_wcancel(&rp->reqq_wait);
3919 bfa_rport_offline_cb(rp);
3920 break;
3921
3922 case BFA_RPORT_SM_HWFAIL:
3923 bfa_stats(rp, sm_fwc_hwf);
3924 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
3925 bfa_reqq_wcancel(&rp->reqq_wait);
3926 break;
3927
3928 default:
3929 bfa_stats(rp, sm_fwc_unexp);
3930 bfa_sm_fault(rp->bfa, event);
3931 }
3932}
3933
3934/*
3935 * Online state - normal parking state.
3936 */
3937static void
3938bfa_rport_sm_online(struct bfa_rport_s *rp, enum bfa_rport_event event)
3939{
3940 struct bfi_rport_qos_scn_s *qos_scn;
3941
3942 bfa_trc(rp->bfa, rp->rport_tag);
3943 bfa_trc(rp->bfa, event);
3944
3945 switch (event) {
3946 case BFA_RPORT_SM_OFFLINE:
3947 bfa_stats(rp, sm_on_off);
3948 if (bfa_rport_send_fwdelete(rp))
3949 bfa_sm_set_state(rp, bfa_rport_sm_fwdelete);
3950 else
3951 bfa_sm_set_state(rp, bfa_rport_sm_fwdelete_qfull);
3952 break;
3953
3954 case BFA_RPORT_SM_DELETE:
3955 bfa_stats(rp, sm_on_del);
3956 if (bfa_rport_send_fwdelete(rp))
3957 bfa_sm_set_state(rp, bfa_rport_sm_deleting);
3958 else
3959 bfa_sm_set_state(rp, bfa_rport_sm_deleting_qfull);
3960 break;
3961
3962 case BFA_RPORT_SM_HWFAIL:
3963 bfa_stats(rp, sm_on_hwf);
3964 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
3965 break;
3966
3967 case BFA_RPORT_SM_SET_SPEED:
3968 bfa_rport_send_fwspeed(rp);
3969 break;
3970
3971 case BFA_RPORT_SM_QOS_SCN:
3972 qos_scn = (struct bfi_rport_qos_scn_s *) rp->event_arg.fw_msg;
3973 rp->qos_attr = qos_scn->new_qos_attr;
3974 bfa_trc(rp->bfa, qos_scn->old_qos_attr.qos_flow_id);
3975 bfa_trc(rp->bfa, qos_scn->new_qos_attr.qos_flow_id);
3976 bfa_trc(rp->bfa, qos_scn->old_qos_attr.qos_priority);
3977 bfa_trc(rp->bfa, qos_scn->new_qos_attr.qos_priority);
3978
3979 qos_scn->old_qos_attr.qos_flow_id =
3980 be32_to_cpu(qos_scn->old_qos_attr.qos_flow_id);
3981 qos_scn->new_qos_attr.qos_flow_id =
3982 be32_to_cpu(qos_scn->new_qos_attr.qos_flow_id);
3983
3984 if (qos_scn->old_qos_attr.qos_flow_id !=
3985 qos_scn->new_qos_attr.qos_flow_id)
3986 bfa_cb_rport_qos_scn_flowid(rp->rport_drv,
3987 qos_scn->old_qos_attr,
3988 qos_scn->new_qos_attr);
3989 if (qos_scn->old_qos_attr.qos_priority !=
3990 qos_scn->new_qos_attr.qos_priority)
3991 bfa_cb_rport_qos_scn_prio(rp->rport_drv,
3992 qos_scn->old_qos_attr,
3993 qos_scn->new_qos_attr);
3994 break;
3995
3996 default:
3997 bfa_stats(rp, sm_on_unexp);
3998 bfa_sm_fault(rp->bfa, event);
3999 }
4000}
4001
4002/*
4003 * Firmware rport is being deleted - awaiting f/w response.
4004 */
4005static void
4006bfa_rport_sm_fwdelete(struct bfa_rport_s *rp, enum bfa_rport_event event)
4007{
4008 bfa_trc(rp->bfa, rp->rport_tag);
4009 bfa_trc(rp->bfa, event);
4010
4011 switch (event) {
4012 case BFA_RPORT_SM_FWRSP:
4013 bfa_stats(rp, sm_fwd_rsp);
4014 bfa_sm_set_state(rp, bfa_rport_sm_offline);
4015 bfa_rport_offline_cb(rp);
4016 break;
4017
4018 case BFA_RPORT_SM_DELETE:
4019 bfa_stats(rp, sm_fwd_del);
4020 bfa_sm_set_state(rp, bfa_rport_sm_deleting);
4021 break;
4022
4023 case BFA_RPORT_SM_HWFAIL:
4024 bfa_stats(rp, sm_fwd_hwf);
4025 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
4026 bfa_rport_offline_cb(rp);
4027 break;
4028
4029 default:
4030 bfa_stats(rp, sm_fwd_unexp);
4031 bfa_sm_fault(rp->bfa, event);
4032 }
4033}
4034
4035static void
4036bfa_rport_sm_fwdelete_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event)
4037{
4038 bfa_trc(rp->bfa, rp->rport_tag);
4039 bfa_trc(rp->bfa, event);
4040
4041 switch (event) {
4042 case BFA_RPORT_SM_QRESUME:
4043 bfa_sm_set_state(rp, bfa_rport_sm_fwdelete);
4044 bfa_rport_send_fwdelete(rp);
4045 break;
4046
4047 case BFA_RPORT_SM_DELETE:
4048 bfa_stats(rp, sm_fwd_del);
4049 bfa_sm_set_state(rp, bfa_rport_sm_deleting_qfull);
4050 break;
4051
4052 case BFA_RPORT_SM_HWFAIL:
4053 bfa_stats(rp, sm_fwd_hwf);
4054 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
4055 bfa_reqq_wcancel(&rp->reqq_wait);
4056 bfa_rport_offline_cb(rp);
4057 break;
4058
4059 default:
4060 bfa_stats(rp, sm_fwd_unexp);
4061 bfa_sm_fault(rp->bfa, event);
4062 }
4063}
4064
4065/*
4066 * Offline state.
4067 */
4068static void
4069bfa_rport_sm_offline(struct bfa_rport_s *rp, enum bfa_rport_event event)
4070{
4071 bfa_trc(rp->bfa, rp->rport_tag);
4072 bfa_trc(rp->bfa, event);
4073
4074 switch (event) {
4075 case BFA_RPORT_SM_DELETE:
4076 bfa_stats(rp, sm_off_del);
4077 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
4078 bfa_rport_free(rp);
4079 break;
4080
4081 case BFA_RPORT_SM_ONLINE:
4082 bfa_stats(rp, sm_off_on);
4083 if (bfa_rport_send_fwcreate(rp))
4084 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
4085 else
4086 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate_qfull);
4087 break;
4088
4089 case BFA_RPORT_SM_HWFAIL:
4090 bfa_stats(rp, sm_off_hwf);
4091 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
4092 break;
4093
4094 default:
4095 bfa_stats(rp, sm_off_unexp);
4096 bfa_sm_fault(rp->bfa, event);
4097 }
4098}
4099
4100/*
4101 * Rport is deleted, waiting for firmware response to delete.
4102 */
4103static void
4104bfa_rport_sm_deleting(struct bfa_rport_s *rp, enum bfa_rport_event event)
4105{
4106 bfa_trc(rp->bfa, rp->rport_tag);
4107 bfa_trc(rp->bfa, event);
4108
4109 switch (event) {
4110 case BFA_RPORT_SM_FWRSP:
4111 bfa_stats(rp, sm_del_fwrsp);
4112 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
4113 bfa_rport_free(rp);
4114 break;
4115
4116 case BFA_RPORT_SM_HWFAIL:
4117 bfa_stats(rp, sm_del_hwf);
4118 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
4119 bfa_rport_free(rp);
4120 break;
4121
4122 default:
4123 bfa_sm_fault(rp->bfa, event);
4124 }
4125}
4126
4127static void
4128bfa_rport_sm_deleting_qfull(struct bfa_rport_s *rp, enum bfa_rport_event event)
4129{
4130 bfa_trc(rp->bfa, rp->rport_tag);
4131 bfa_trc(rp->bfa, event);
4132
4133 switch (event) {
4134 case BFA_RPORT_SM_QRESUME:
4135 bfa_stats(rp, sm_del_fwrsp);
4136 bfa_sm_set_state(rp, bfa_rport_sm_deleting);
4137 bfa_rport_send_fwdelete(rp);
4138 break;
4139
4140 case BFA_RPORT_SM_HWFAIL:
4141 bfa_stats(rp, sm_del_hwf);
4142 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
4143 bfa_reqq_wcancel(&rp->reqq_wait);
4144 bfa_rport_free(rp);
4145 break;
4146
4147 default:
4148 bfa_sm_fault(rp->bfa, event);
4149 }
4150}
4151
4152/*
4153 * Waiting for rport create response from firmware. A delete is pending.
4154 */
4155static void
4156bfa_rport_sm_delete_pending(struct bfa_rport_s *rp,
4157 enum bfa_rport_event event)
4158{
4159 bfa_trc(rp->bfa, rp->rport_tag);
4160 bfa_trc(rp->bfa, event);
4161
4162 switch (event) {
4163 case BFA_RPORT_SM_FWRSP:
4164 bfa_stats(rp, sm_delp_fwrsp);
4165 if (bfa_rport_send_fwdelete(rp))
4166 bfa_sm_set_state(rp, bfa_rport_sm_deleting);
4167 else
4168 bfa_sm_set_state(rp, bfa_rport_sm_deleting_qfull);
4169 break;
4170
4171 case BFA_RPORT_SM_HWFAIL:
4172 bfa_stats(rp, sm_delp_hwf);
4173 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
4174 bfa_rport_free(rp);
4175 break;
4176
4177 default:
4178 bfa_stats(rp, sm_delp_unexp);
4179 bfa_sm_fault(rp->bfa, event);
4180 }
4181}
4182
4183/*
4184 * Waiting for rport create response from firmware. Rport offline is pending.
4185 */
4186static void
4187bfa_rport_sm_offline_pending(struct bfa_rport_s *rp,
4188 enum bfa_rport_event event)
4189{
4190 bfa_trc(rp->bfa, rp->rport_tag);
4191 bfa_trc(rp->bfa, event);
4192
4193 switch (event) {
4194 case BFA_RPORT_SM_FWRSP:
4195 bfa_stats(rp, sm_offp_fwrsp);
4196 if (bfa_rport_send_fwdelete(rp))
4197 bfa_sm_set_state(rp, bfa_rport_sm_fwdelete);
4198 else
4199 bfa_sm_set_state(rp, bfa_rport_sm_fwdelete_qfull);
4200 break;
4201
4202 case BFA_RPORT_SM_DELETE:
4203 bfa_stats(rp, sm_offp_del);
4204 bfa_sm_set_state(rp, bfa_rport_sm_delete_pending);
4205 break;
4206
4207 case BFA_RPORT_SM_HWFAIL:
4208 bfa_stats(rp, sm_offp_hwf);
4209 bfa_sm_set_state(rp, bfa_rport_sm_iocdisable);
4210 break;
4211
4212 default:
4213 bfa_stats(rp, sm_offp_unexp);
4214 bfa_sm_fault(rp->bfa, event);
4215 }
4216}
4217
4218/*
4219 * IOC h/w failed.
4220 */
4221static void
4222bfa_rport_sm_iocdisable(struct bfa_rport_s *rp, enum bfa_rport_event event)
4223{
4224 bfa_trc(rp->bfa, rp->rport_tag);
4225 bfa_trc(rp->bfa, event);
4226
4227 switch (event) {
4228 case BFA_RPORT_SM_OFFLINE:
4229 bfa_stats(rp, sm_iocd_off);
4230 bfa_rport_offline_cb(rp);
4231 break;
4232
4233 case BFA_RPORT_SM_DELETE:
4234 bfa_stats(rp, sm_iocd_del);
4235 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
4236 bfa_rport_free(rp);
4237 break;
4238
4239 case BFA_RPORT_SM_ONLINE:
4240 bfa_stats(rp, sm_iocd_on);
4241 if (bfa_rport_send_fwcreate(rp))
4242 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate);
4243 else
4244 bfa_sm_set_state(rp, bfa_rport_sm_fwcreate_qfull);
4245 break;
4246
4247 case BFA_RPORT_SM_HWFAIL:
4248 break;
4249
4250 default:
4251 bfa_stats(rp, sm_iocd_unexp);
4252 bfa_sm_fault(rp->bfa, event);
4253 }
4254}
4255
4256
4257
4258/*
4259 * bfa_rport_private BFA rport private functions
4260 */
4261
4262static void
4263__bfa_cb_rport_online(void *cbarg, bfa_boolean_t complete)
4264{
4265 struct bfa_rport_s *rp = cbarg;
4266
4267 if (complete)
4268 bfa_cb_rport_online(rp->rport_drv);
4269}
4270
4271static void
4272__bfa_cb_rport_offline(void *cbarg, bfa_boolean_t complete)
4273{
4274 struct bfa_rport_s *rp = cbarg;
4275
4276 if (complete)
4277 bfa_cb_rport_offline(rp->rport_drv);
4278}
4279
4280static void
4281bfa_rport_qresume(void *cbarg)
4282{
4283 struct bfa_rport_s *rp = cbarg;
4284
4285 bfa_sm_send_event(rp, BFA_RPORT_SM_QRESUME);
4286}
4287
4288static void
4289bfa_rport_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
4290 u32 *dm_len)
4291{
4292 if (cfg->fwcfg.num_rports < BFA_RPORT_MIN)
4293 cfg->fwcfg.num_rports = BFA_RPORT_MIN;
4294
4295 *km_len += cfg->fwcfg.num_rports * sizeof(struct bfa_rport_s);
4296}
4297
4298static void
4299bfa_rport_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
4300 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
4301{
4302 struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(bfa);
4303 struct bfa_rport_s *rp;
4304 u16 i;
4305
4306 INIT_LIST_HEAD(&mod->rp_free_q);
4307 INIT_LIST_HEAD(&mod->rp_active_q);
4308
4309 rp = (struct bfa_rport_s *) bfa_meminfo_kva(meminfo);
4310 mod->rps_list = rp;
4311 mod->num_rports = cfg->fwcfg.num_rports;
4312
4313 WARN_ON(!mod->num_rports ||
4314 (mod->num_rports & (mod->num_rports - 1)));
4315
4316 for (i = 0; i < mod->num_rports; i++, rp++) {
4317 memset(rp, 0, sizeof(struct bfa_rport_s));
4318 rp->bfa = bfa;
4319 rp->rport_tag = i;
4320 bfa_sm_set_state(rp, bfa_rport_sm_uninit);
4321
4322 /*
4323 * - is unused
4324 */
4325 if (i)
4326 list_add_tail(&rp->qe, &mod->rp_free_q);
4327
4328 bfa_reqq_winit(&rp->reqq_wait, bfa_rport_qresume, rp);
4329 }
4330
4331 /*
4332 * consume memory
4333 */
4334 bfa_meminfo_kva(meminfo) = (u8 *) rp;
4335}
4336
4337static void
4338bfa_rport_detach(struct bfa_s *bfa)
4339{
4340}
4341
4342static void
4343bfa_rport_start(struct bfa_s *bfa)
4344{
4345}
4346
4347static void
4348bfa_rport_stop(struct bfa_s *bfa)
4349{
4350}
4351
4352static void
4353bfa_rport_iocdisable(struct bfa_s *bfa)
4354{
4355 struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(bfa);
4356 struct bfa_rport_s *rport;
4357 struct list_head *qe, *qen;
4358
4359 list_for_each_safe(qe, qen, &mod->rp_active_q) {
4360 rport = (struct bfa_rport_s *) qe;
4361 bfa_sm_send_event(rport, BFA_RPORT_SM_HWFAIL);
4362 }
4363}
4364
4365static struct bfa_rport_s *
4366bfa_rport_alloc(struct bfa_rport_mod_s *mod)
4367{
4368 struct bfa_rport_s *rport;
4369
4370 bfa_q_deq(&mod->rp_free_q, &rport);
4371 if (rport)
4372 list_add_tail(&rport->qe, &mod->rp_active_q);
4373
4374 return rport;
4375}
4376
4377static void
4378bfa_rport_free(struct bfa_rport_s *rport)
4379{
4380 struct bfa_rport_mod_s *mod = BFA_RPORT_MOD(rport->bfa);
4381
4382 WARN_ON(!bfa_q_is_on_q(&mod->rp_active_q, rport));
4383 list_del(&rport->qe);
4384 list_add_tail(&rport->qe, &mod->rp_free_q);
4385}
4386
4387static bfa_boolean_t
4388bfa_rport_send_fwcreate(struct bfa_rport_s *rp)
4389{
4390 struct bfi_rport_create_req_s *m;
4391
4392 /*
4393 * check for room in queue to send request now
4394 */
4395 m = bfa_reqq_next(rp->bfa, BFA_REQQ_RPORT);
4396 if (!m) {
4397 bfa_reqq_wait(rp->bfa, BFA_REQQ_RPORT, &rp->reqq_wait);
4398 return BFA_FALSE;
4399 }
4400
4401 bfi_h2i_set(m->mh, BFI_MC_RPORT, BFI_RPORT_H2I_CREATE_REQ,
4402 bfa_lpuid(rp->bfa));
4403 m->bfa_handle = rp->rport_tag;
4404 m->max_frmsz = cpu_to_be16(rp->rport_info.max_frmsz);
4405 m->pid = rp->rport_info.pid;
4406 m->lp_tag = rp->rport_info.lp_tag;
4407 m->local_pid = rp->rport_info.local_pid;
4408 m->fc_class = rp->rport_info.fc_class;
4409 m->vf_en = rp->rport_info.vf_en;
4410 m->vf_id = rp->rport_info.vf_id;
4411 m->cisc = rp->rport_info.cisc;
4412
4413 /*
4414 * queue I/O message to firmware
4415 */
4416 bfa_reqq_produce(rp->bfa, BFA_REQQ_RPORT);
4417 return BFA_TRUE;
4418}
4419
4420static bfa_boolean_t
4421bfa_rport_send_fwdelete(struct bfa_rport_s *rp)
4422{
4423 struct bfi_rport_delete_req_s *m;
4424
4425 /*
4426 * check for room in queue to send request now
4427 */
4428 m = bfa_reqq_next(rp->bfa, BFA_REQQ_RPORT);
4429 if (!m) {
4430 bfa_reqq_wait(rp->bfa, BFA_REQQ_RPORT, &rp->reqq_wait);
4431 return BFA_FALSE;
4432 }
4433
4434 bfi_h2i_set(m->mh, BFI_MC_RPORT, BFI_RPORT_H2I_DELETE_REQ,
4435 bfa_lpuid(rp->bfa));
4436 m->fw_handle = rp->fw_handle;
4437
4438 /*
4439 * queue I/O message to firmware
4440 */
4441 bfa_reqq_produce(rp->bfa, BFA_REQQ_RPORT);
4442 return BFA_TRUE;
4443}
4444
4445static bfa_boolean_t
4446bfa_rport_send_fwspeed(struct bfa_rport_s *rp)
4447{
4448 struct bfa_rport_speed_req_s *m;
4449
4450 /*
4451 * check for room in queue to send request now
4452 */
4453 m = bfa_reqq_next(rp->bfa, BFA_REQQ_RPORT);
4454 if (!m) {
4455 bfa_trc(rp->bfa, rp->rport_info.speed);
4456 return BFA_FALSE;
4457 }
4458
4459 bfi_h2i_set(m->mh, BFI_MC_RPORT, BFI_RPORT_H2I_SET_SPEED_REQ,
4460 bfa_lpuid(rp->bfa));
4461 m->fw_handle = rp->fw_handle;
4462 m->speed = (u8)rp->rport_info.speed;
4463
4464 /*
4465 * queue I/O message to firmware
4466 */
4467 bfa_reqq_produce(rp->bfa, BFA_REQQ_RPORT);
4468 return BFA_TRUE;
4469}
4470
4471
4472
4473/*
4474 * bfa_rport_public
4475 */
4476
4477/*
4478 * Rport interrupt processing.
4479 */
4480void
4481bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
4482{
4483 union bfi_rport_i2h_msg_u msg;
4484 struct bfa_rport_s *rp;
4485
4486 bfa_trc(bfa, m->mhdr.msg_id);
4487
4488 msg.msg = m;
4489
4490 switch (m->mhdr.msg_id) {
4491 case BFI_RPORT_I2H_CREATE_RSP:
4492 rp = BFA_RPORT_FROM_TAG(bfa, msg.create_rsp->bfa_handle);
4493 rp->fw_handle = msg.create_rsp->fw_handle;
4494 rp->qos_attr = msg.create_rsp->qos_attr;
4495 WARN_ON(msg.create_rsp->status != BFA_STATUS_OK);
4496 bfa_sm_send_event(rp, BFA_RPORT_SM_FWRSP);
4497 break;
4498
4499 case BFI_RPORT_I2H_DELETE_RSP:
4500 rp = BFA_RPORT_FROM_TAG(bfa, msg.delete_rsp->bfa_handle);
4501 WARN_ON(msg.delete_rsp->status != BFA_STATUS_OK);
4502 bfa_sm_send_event(rp, BFA_RPORT_SM_FWRSP);
4503 break;
4504
4505 case BFI_RPORT_I2H_QOS_SCN:
4506 rp = BFA_RPORT_FROM_TAG(bfa, msg.qos_scn_evt->bfa_handle);
4507 rp->event_arg.fw_msg = msg.qos_scn_evt;
4508 bfa_sm_send_event(rp, BFA_RPORT_SM_QOS_SCN);
4509 break;
4510
4511 default:
4512 bfa_trc(bfa, m->mhdr.msg_id);
4513 WARN_ON(1);
4514 }
4515}
4516
4517
4518
4519/*
4520 * bfa_rport_api
4521 */
4522
4523struct bfa_rport_s *
4524bfa_rport_create(struct bfa_s *bfa, void *rport_drv)
4525{
4526 struct bfa_rport_s *rp;
4527
4528 rp = bfa_rport_alloc(BFA_RPORT_MOD(bfa));
4529
4530 if (rp == NULL)
4531 return NULL;
4532
4533 rp->bfa = bfa;
4534 rp->rport_drv = rport_drv;
4535 memset(&rp->stats, 0, sizeof(rp->stats));
4536
4537 WARN_ON(!bfa_sm_cmp_state(rp, bfa_rport_sm_uninit));
4538 bfa_sm_send_event(rp, BFA_RPORT_SM_CREATE);
4539
4540 return rp;
4541}
4542
4543void
4544bfa_rport_online(struct bfa_rport_s *rport, struct bfa_rport_info_s *rport_info)
4545{
4546 WARN_ON(rport_info->max_frmsz == 0);
4547
4548 /*
4549 * Some JBODs are seen to be not setting PDU size correctly in PLOGI
4550 * responses. Default to minimum size.
4551 */
4552 if (rport_info->max_frmsz == 0) {
4553 bfa_trc(rport->bfa, rport->rport_tag);
4554 rport_info->max_frmsz = FC_MIN_PDUSZ;
4555 }
4556
4557 rport->rport_info = *rport_info;
4558 bfa_sm_send_event(rport, BFA_RPORT_SM_ONLINE);
4559}
4560
4561void
4562bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_port_speed speed)
4563{
4564 WARN_ON(speed == 0);
4565 WARN_ON(speed == BFA_PORT_SPEED_AUTO);
4566
4567 rport->rport_info.speed = speed;
4568 bfa_sm_send_event(rport, BFA_RPORT_SM_SET_SPEED);
4569}
4570
4571
4572/*
4573 * SGPG related functions
4574 */
4575
4576/*
4577 * Compute and return memory needed by FCP(im) module.
4578 */
4579static void
4580bfa_sgpg_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
4581 u32 *dm_len)
4582{
4583 if (cfg->drvcfg.num_sgpgs < BFA_SGPG_MIN)
4584 cfg->drvcfg.num_sgpgs = BFA_SGPG_MIN;
4585
4586 *km_len += (cfg->drvcfg.num_sgpgs + 1) * sizeof(struct bfa_sgpg_s);
4587 *dm_len += (cfg->drvcfg.num_sgpgs + 1) * sizeof(struct bfi_sgpg_s);
4588}
4589
4590
4591static void
4592bfa_sgpg_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
4593 struct bfa_meminfo_s *minfo, struct bfa_pcidev_s *pcidev)
4594{
4595 struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
4596 int i;
4597 struct bfa_sgpg_s *hsgpg;
4598 struct bfi_sgpg_s *sgpg;
4599 u64 align_len;
4600
4601 union {
4602 u64 pa;
4603 union bfi_addr_u addr;
4604 } sgpg_pa, sgpg_pa_tmp;
4605
4606 INIT_LIST_HEAD(&mod->sgpg_q);
4607 INIT_LIST_HEAD(&mod->sgpg_wait_q);
4608
4609 bfa_trc(bfa, cfg->drvcfg.num_sgpgs);
4610
4611 mod->num_sgpgs = cfg->drvcfg.num_sgpgs;
4612 mod->sgpg_arr_pa = bfa_meminfo_dma_phys(minfo);
4613 align_len = (BFA_SGPG_ROUNDUP(mod->sgpg_arr_pa) - mod->sgpg_arr_pa);
4614 mod->sgpg_arr_pa += align_len;
4615 mod->hsgpg_arr = (struct bfa_sgpg_s *) (bfa_meminfo_kva(minfo) +
4616 align_len);
4617 mod->sgpg_arr = (struct bfi_sgpg_s *) (bfa_meminfo_dma_virt(minfo) +
4618 align_len);
4619
4620 hsgpg = mod->hsgpg_arr;
4621 sgpg = mod->sgpg_arr;
4622 sgpg_pa.pa = mod->sgpg_arr_pa;
4623 mod->free_sgpgs = mod->num_sgpgs;
4624
4625 WARN_ON(sgpg_pa.pa & (sizeof(struct bfi_sgpg_s) - 1));
4626
4627 for (i = 0; i < mod->num_sgpgs; i++) {
4628 memset(hsgpg, 0, sizeof(*hsgpg));
4629 memset(sgpg, 0, sizeof(*sgpg));
4630
4631 hsgpg->sgpg = sgpg;
4632 sgpg_pa_tmp.pa = bfa_sgaddr_le(sgpg_pa.pa);
4633 hsgpg->sgpg_pa = sgpg_pa_tmp.addr;
4634 list_add_tail(&hsgpg->qe, &mod->sgpg_q);
4635
4636 hsgpg++;
4637 sgpg++;
4638 sgpg_pa.pa += sizeof(struct bfi_sgpg_s);
4639 }
4640
4641 bfa_meminfo_kva(minfo) = (u8 *) hsgpg;
4642 bfa_meminfo_dma_virt(minfo) = (u8 *) sgpg;
4643 bfa_meminfo_dma_phys(minfo) = sgpg_pa.pa;
4644}
4645
4646static void
4647bfa_sgpg_detach(struct bfa_s *bfa)
4648{
4649}
4650
4651static void
4652bfa_sgpg_start(struct bfa_s *bfa)
4653{
4654}
4655
4656static void
4657bfa_sgpg_stop(struct bfa_s *bfa)
4658{
4659}
4660
4661static void
4662bfa_sgpg_iocdisable(struct bfa_s *bfa)
4663{
4664}
4665
4666bfa_status_t
4667bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpgs)
4668{
4669 struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
4670 struct bfa_sgpg_s *hsgpg;
4671 int i;
4672
4673 if (mod->free_sgpgs < nsgpgs)
4674 return BFA_STATUS_ENOMEM;
4675
4676 for (i = 0; i < nsgpgs; i++) {
4677 bfa_q_deq(&mod->sgpg_q, &hsgpg);
4678 WARN_ON(!hsgpg);
4679 list_add_tail(&hsgpg->qe, sgpg_q);
4680 }
4681
4682 mod->free_sgpgs -= nsgpgs;
4683 return BFA_STATUS_OK;
4684}
4685
4686void
4687bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpg)
4688{
4689 struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
4690 struct bfa_sgpg_wqe_s *wqe;
4691
4692 mod->free_sgpgs += nsgpg;
4693 WARN_ON(mod->free_sgpgs > mod->num_sgpgs);
4694
4695 list_splice_tail_init(sgpg_q, &mod->sgpg_q);
4696
4697 if (list_empty(&mod->sgpg_wait_q))
4698 return;
4699
4700 /*
4701 * satisfy as many waiting requests as possible
4702 */
4703 do {
4704 wqe = bfa_q_first(&mod->sgpg_wait_q);
4705 if (mod->free_sgpgs < wqe->nsgpg)
4706 nsgpg = mod->free_sgpgs;
4707 else
4708 nsgpg = wqe->nsgpg;
4709 bfa_sgpg_malloc(bfa, &wqe->sgpg_q, nsgpg);
4710 wqe->nsgpg -= nsgpg;
4711 if (wqe->nsgpg == 0) {
4712 list_del(&wqe->qe);
4713 wqe->cbfn(wqe->cbarg);
4714 }
4715 } while (mod->free_sgpgs && !list_empty(&mod->sgpg_wait_q));
4716}
4717
4718void
4719bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe, int nsgpg)
4720{
4721 struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
4722
4723 WARN_ON(nsgpg <= 0);
4724 WARN_ON(nsgpg <= mod->free_sgpgs);
4725
4726 wqe->nsgpg_total = wqe->nsgpg = nsgpg;
4727
4728 /*
4729 * allocate any left to this one first
4730 */
4731 if (mod->free_sgpgs) {
4732 /*
4733 * no one else is waiting for SGPG
4734 */
4735 WARN_ON(!list_empty(&mod->sgpg_wait_q));
4736 list_splice_tail_init(&mod->sgpg_q, &wqe->sgpg_q);
4737 wqe->nsgpg -= mod->free_sgpgs;
4738 mod->free_sgpgs = 0;
4739 }
4740
4741 list_add_tail(&wqe->qe, &mod->sgpg_wait_q);
4742}
4743
4744void
4745bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe)
4746{
4747 struct bfa_sgpg_mod_s *mod = BFA_SGPG_MOD(bfa);
4748
4749 WARN_ON(!bfa_q_is_on_q(&mod->sgpg_wait_q, wqe));
4750 list_del(&wqe->qe);
4751
4752 if (wqe->nsgpg_total != wqe->nsgpg)
4753 bfa_sgpg_mfree(bfa, &wqe->sgpg_q,
4754 wqe->nsgpg_total - wqe->nsgpg);
4755}
4756
4757void
4758bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe, void (*cbfn) (void *cbarg),
4759 void *cbarg)
4760{
4761 INIT_LIST_HEAD(&wqe->sgpg_q);
4762 wqe->cbfn = cbfn;
4763 wqe->cbarg = cbarg;
4764}
4765
4766/*
4767 * UF related functions
4768 */
4769/*
4770 *****************************************************************************
4771 * Internal functions
4772 *****************************************************************************
4773 */
4774static void
4775__bfa_cb_uf_recv(void *cbarg, bfa_boolean_t complete)
4776{
4777 struct bfa_uf_s *uf = cbarg;
4778 struct bfa_uf_mod_s *ufm = BFA_UF_MOD(uf->bfa);
4779
4780 if (complete)
4781 ufm->ufrecv(ufm->cbarg, uf);
4782}
4783
4784static void
4785claim_uf_pbs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi)
4786{
4787 u32 uf_pb_tot_sz;
4788
4789 ufm->uf_pbs_kva = (struct bfa_uf_buf_s *) bfa_meminfo_dma_virt(mi);
4790 ufm->uf_pbs_pa = bfa_meminfo_dma_phys(mi);
4791 uf_pb_tot_sz = BFA_ROUNDUP((sizeof(struct bfa_uf_buf_s) * ufm->num_ufs),
4792 BFA_DMA_ALIGN_SZ);
4793
4794 bfa_meminfo_dma_virt(mi) += uf_pb_tot_sz;
4795 bfa_meminfo_dma_phys(mi) += uf_pb_tot_sz;
4796
4797 memset((void *)ufm->uf_pbs_kva, 0, uf_pb_tot_sz);
4798}
4799
4800static void
4801claim_uf_post_msgs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi)
4802{
4803 struct bfi_uf_buf_post_s *uf_bp_msg;
4804 struct bfi_sge_s *sge;
4805 union bfi_addr_u sga_zero = { {0} };
4806 u16 i;
4807 u16 buf_len;
4808
4809 ufm->uf_buf_posts = (struct bfi_uf_buf_post_s *) bfa_meminfo_kva(mi);
4810 uf_bp_msg = ufm->uf_buf_posts;
4811
4812 for (i = 0, uf_bp_msg = ufm->uf_buf_posts; i < ufm->num_ufs;
4813 i++, uf_bp_msg++) {
4814 memset(uf_bp_msg, 0, sizeof(struct bfi_uf_buf_post_s));
4815
4816 uf_bp_msg->buf_tag = i;
4817 buf_len = sizeof(struct bfa_uf_buf_s);
4818 uf_bp_msg->buf_len = cpu_to_be16(buf_len);
4819 bfi_h2i_set(uf_bp_msg->mh, BFI_MC_UF, BFI_UF_H2I_BUF_POST,
4820 bfa_lpuid(ufm->bfa));
4821
4822 sge = uf_bp_msg->sge;
4823 sge[0].sg_len = buf_len;
4824 sge[0].flags = BFI_SGE_DATA_LAST;
4825 bfa_dma_addr_set(sge[0].sga, ufm_pbs_pa(ufm, i));
4826 bfa_sge_to_be(sge);
4827
4828 sge[1].sg_len = buf_len;
4829 sge[1].flags = BFI_SGE_PGDLEN;
4830 sge[1].sga = sga_zero;
4831 bfa_sge_to_be(&sge[1]);
4832 }
4833
4834 /*
4835 * advance pointer beyond consumed memory
4836 */
4837 bfa_meminfo_kva(mi) = (u8 *) uf_bp_msg;
4838}
4839
4840static void
4841claim_ufs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi)
4842{
4843 u16 i;
4844 struct bfa_uf_s *uf;
4845
4846 /*
4847 * Claim block of memory for UF list
4848 */
4849 ufm->uf_list = (struct bfa_uf_s *) bfa_meminfo_kva(mi);
4850
4851 /*
4852 * Initialize UFs and queue it in UF free queue
4853 */
4854 for (i = 0, uf = ufm->uf_list; i < ufm->num_ufs; i++, uf++) {
4855 memset(uf, 0, sizeof(struct bfa_uf_s));
4856 uf->bfa = ufm->bfa;
4857 uf->uf_tag = i;
4858 uf->pb_len = sizeof(struct bfa_uf_buf_s);
4859 uf->buf_kva = (void *)&ufm->uf_pbs_kva[i];
4860 uf->buf_pa = ufm_pbs_pa(ufm, i);
4861 list_add_tail(&uf->qe, &ufm->uf_free_q);
4862 }
4863
4864 /*
4865 * advance memory pointer
4866 */
4867 bfa_meminfo_kva(mi) = (u8 *) uf;
4868}
4869
4870static void
4871uf_mem_claim(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi)
4872{
4873 claim_uf_pbs(ufm, mi);
4874 claim_ufs(ufm, mi);
4875 claim_uf_post_msgs(ufm, mi);
4876}
4877
4878static void
4879bfa_uf_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, u32 *dm_len)
4880{
4881 u32 num_ufs = cfg->fwcfg.num_uf_bufs;
4882
4883 /*
4884 * dma-able memory for UF posted bufs
4885 */
4886 *dm_len += BFA_ROUNDUP((sizeof(struct bfa_uf_buf_s) * num_ufs),
4887 BFA_DMA_ALIGN_SZ);
4888
4889 /*
4890 * kernel Virtual memory for UFs and UF buf post msg copies
4891 */
4892 *ndm_len += sizeof(struct bfa_uf_s) * num_ufs;
4893 *ndm_len += sizeof(struct bfi_uf_buf_post_s) * num_ufs;
4894}
4895
4896static void
4897bfa_uf_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
4898 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
4899{
4900 struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
4901
4902 memset(ufm, 0, sizeof(struct bfa_uf_mod_s));
4903 ufm->bfa = bfa;
4904 ufm->num_ufs = cfg->fwcfg.num_uf_bufs;
4905 INIT_LIST_HEAD(&ufm->uf_free_q);
4906 INIT_LIST_HEAD(&ufm->uf_posted_q);
4907
4908 uf_mem_claim(ufm, meminfo);
4909}
4910
4911static void
4912bfa_uf_detach(struct bfa_s *bfa)
4913{
4914}
4915
4916static struct bfa_uf_s *
4917bfa_uf_get(struct bfa_uf_mod_s *uf_mod)
4918{
4919 struct bfa_uf_s *uf;
4920
4921 bfa_q_deq(&uf_mod->uf_free_q, &uf);
4922 return uf;
4923}
4924
4925static void
4926bfa_uf_put(struct bfa_uf_mod_s *uf_mod, struct bfa_uf_s *uf)
4927{
4928 list_add_tail(&uf->qe, &uf_mod->uf_free_q);
4929}
4930
4931static bfa_status_t
4932bfa_uf_post(struct bfa_uf_mod_s *ufm, struct bfa_uf_s *uf)
4933{
4934 struct bfi_uf_buf_post_s *uf_post_msg;
4935
4936 uf_post_msg = bfa_reqq_next(ufm->bfa, BFA_REQQ_FCXP);
4937 if (!uf_post_msg)
4938 return BFA_STATUS_FAILED;
4939
4940 memcpy(uf_post_msg, &ufm->uf_buf_posts[uf->uf_tag],
4941 sizeof(struct bfi_uf_buf_post_s));
4942 bfa_reqq_produce(ufm->bfa, BFA_REQQ_FCXP);
4943
4944 bfa_trc(ufm->bfa, uf->uf_tag);
4945
4946 list_add_tail(&uf->qe, &ufm->uf_posted_q);
4947 return BFA_STATUS_OK;
4948}
4949
4950static void
4951bfa_uf_post_all(struct bfa_uf_mod_s *uf_mod)
4952{
4953 struct bfa_uf_s *uf;
4954
4955 while ((uf = bfa_uf_get(uf_mod)) != NULL) {
4956 if (bfa_uf_post(uf_mod, uf) != BFA_STATUS_OK)
4957 break;
4958 }
4959}
4960
4961static void
4962uf_recv(struct bfa_s *bfa, struct bfi_uf_frm_rcvd_s *m)
4963{
4964 struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
4965 u16 uf_tag = m->buf_tag;
4966 struct bfa_uf_buf_s *uf_buf = &ufm->uf_pbs_kva[uf_tag];
4967 struct bfa_uf_s *uf = &ufm->uf_list[uf_tag];
4968 u8 *buf = &uf_buf->d[0];
4969 struct fchs_s *fchs;
4970
4971 m->frm_len = be16_to_cpu(m->frm_len);
4972 m->xfr_len = be16_to_cpu(m->xfr_len);
4973
4974 fchs = (struct fchs_s *)uf_buf;
4975
4976 list_del(&uf->qe); /* dequeue from posted queue */
4977
4978 uf->data_ptr = buf;
4979 uf->data_len = m->xfr_len;
4980
4981 WARN_ON(uf->data_len < sizeof(struct fchs_s));
4982
4983 if (uf->data_len == sizeof(struct fchs_s)) {
4984 bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_UF, BFA_PL_EID_RX,
4985 uf->data_len, (struct fchs_s *)buf);
4986 } else {
4987 u32 pld_w0 = *((u32 *) (buf + sizeof(struct fchs_s)));
4988 bfa_plog_fchdr_and_pl(bfa->plog, BFA_PL_MID_HAL_UF,
4989 BFA_PL_EID_RX, uf->data_len,
4990 (struct fchs_s *)buf, pld_w0);
4991 }
4992
4993 if (bfa->fcs)
4994 __bfa_cb_uf_recv(uf, BFA_TRUE);
4995 else
4996 bfa_cb_queue(bfa, &uf->hcb_qe, __bfa_cb_uf_recv, uf);
4997}
4998
4999static void
5000bfa_uf_stop(struct bfa_s *bfa)
5001{
5002}
5003
5004static void
5005bfa_uf_iocdisable(struct bfa_s *bfa)
5006{
5007 struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
5008 struct bfa_uf_s *uf;
5009 struct list_head *qe, *qen;
5010
5011 list_for_each_safe(qe, qen, &ufm->uf_posted_q) {
5012 uf = (struct bfa_uf_s *) qe;
5013 list_del(&uf->qe);
5014 bfa_uf_put(ufm, uf);
5015 }
5016}
5017
5018static void
5019bfa_uf_start(struct bfa_s *bfa)
5020{
5021 bfa_uf_post_all(BFA_UF_MOD(bfa));
5022}
5023
5024/*
5025 * Register handler for all unsolicted receive frames.
5026 *
5027 * @param[in] bfa BFA instance
5028 * @param[in] ufrecv receive handler function
5029 * @param[in] cbarg receive handler arg
5030 */
5031void
5032bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv, void *cbarg)
5033{
5034 struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
5035
5036 ufm->ufrecv = ufrecv;
5037 ufm->cbarg = cbarg;
5038}
5039
5040/*
5041 * Free an unsolicited frame back to BFA.
5042 *
5043 * @param[in] uf unsolicited frame to be freed
5044 *
5045 * @return None
5046 */
5047void
5048bfa_uf_free(struct bfa_uf_s *uf)
5049{
5050 bfa_uf_put(BFA_UF_MOD(uf->bfa), uf);
5051 bfa_uf_post_all(BFA_UF_MOD(uf->bfa));
5052}
5053
5054
5055
5056/*
5057 * uf_pub BFA uf module public functions
5058 */
5059void
5060bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
5061{
5062 bfa_trc(bfa, msg->mhdr.msg_id);
5063
5064 switch (msg->mhdr.msg_id) {
5065 case BFI_UF_I2H_FRM_RCVD:
5066 uf_recv(bfa, (struct bfi_uf_frm_rcvd_s *) msg);
5067 break;
5068
5069 default:
5070 bfa_trc(bfa, msg->mhdr.msg_id);
5071 WARN_ON(1);
5072 }
5073}
5074
5075
diff --git a/drivers/scsi/bfa/bfa_svc.h b/drivers/scsi/bfa/bfa_svc.h
new file mode 100644
index 000000000000..5902a45c080f
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_svc.h
@@ -0,0 +1,621 @@
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_SVC_H__
19#define __BFA_SVC_H__
20
21#include "bfa_cs.h"
22#include "bfi_ms.h"
23
24
25/*
26 * Scatter-gather DMA related defines
27 */
28#define BFA_SGPG_MIN (16)
29
30/*
31 * Alignment macro for SG page allocation
32 */
33#define BFA_SGPG_ROUNDUP(_l) (((_l) + (sizeof(struct bfi_sgpg_s) - 1)) \
34 & ~(sizeof(struct bfi_sgpg_s) - 1))
35
36struct bfa_sgpg_wqe_s {
37 struct list_head qe; /* queue sg page element */
38 int nsgpg; /* pages to be allocated */
39 int nsgpg_total; /* total pages required */
40 void (*cbfn) (void *cbarg); /* callback function */
41 void *cbarg; /* callback arg */
42 struct list_head sgpg_q; /* queue of alloced sgpgs */
43};
44
45struct bfa_sgpg_s {
46 struct list_head qe; /* queue sg page element */
47 struct bfi_sgpg_s *sgpg; /* va of SG page */
48 union bfi_addr_u sgpg_pa; /* pa of SG page */
49};
50
51/*
52 * Given number of SG elements, BFA_SGPG_NPAGE() returns the number of
53 * SG pages required.
54 */
55#define BFA_SGPG_NPAGE(_nsges) (((_nsges) / BFI_SGPG_DATA_SGES) + 1)
56
57struct bfa_sgpg_mod_s {
58 struct bfa_s *bfa;
59 int num_sgpgs; /* number of SG pages */
60 int free_sgpgs; /* number of free SG pages */
61 struct bfa_sgpg_s *hsgpg_arr; /* BFA SG page array */
62 struct bfi_sgpg_s *sgpg_arr; /* actual SG page array */
63 u64 sgpg_arr_pa; /* SG page array DMA addr */
64 struct list_head sgpg_q; /* queue of free SG pages */
65 struct list_head sgpg_wait_q; /* wait queue for SG pages */
66};
67#define BFA_SGPG_MOD(__bfa) (&(__bfa)->modules.sgpg_mod)
68
69bfa_status_t bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q,
70 int nsgpgs);
71void bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q, int nsgpgs);
72void bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe,
73 void (*cbfn) (void *cbarg), void *cbarg);
74void bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe, int nsgpgs);
75void bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe);
76
77
78/*
79 * FCXP related defines
80 */
81#define BFA_FCXP_MIN (1)
82#define BFA_FCXP_MAX_IBUF_SZ (2 * 1024 + 256)
83#define BFA_FCXP_MAX_LBUF_SZ (4 * 1024 + 256)
84
85struct bfa_fcxp_mod_s {
86 struct bfa_s *bfa; /* backpointer to BFA */
87 struct bfa_fcxp_s *fcxp_list; /* array of FCXPs */
88 u16 num_fcxps; /* max num FCXP requests */
89 struct list_head fcxp_free_q; /* free FCXPs */
90 struct list_head fcxp_active_q; /* active FCXPs */
91 void *req_pld_list_kva; /* list of FCXP req pld */
92 u64 req_pld_list_pa; /* list of FCXP req pld */
93 void *rsp_pld_list_kva; /* list of FCXP resp pld */
94 u64 rsp_pld_list_pa; /* list of FCXP resp pld */
95 struct list_head wait_q; /* wait queue for free fcxp */
96 u32 req_pld_sz;
97 u32 rsp_pld_sz;
98};
99
100#define BFA_FCXP_MOD(__bfa) (&(__bfa)->modules.fcxp_mod)
101#define BFA_FCXP_FROM_TAG(__mod, __tag) (&(__mod)->fcxp_list[__tag])
102
103typedef void (*fcxp_send_cb_t) (struct bfa_s *ioc, struct bfa_fcxp_s *fcxp,
104 void *cb_arg, bfa_status_t req_status,
105 u32 rsp_len, u32 resid_len,
106 struct fchs_s *rsp_fchs);
107
108typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid);
109typedef u32 (*bfa_fcxp_get_sglen_t) (void *bfad_fcxp, int sgeid);
110typedef void (*bfa_cb_fcxp_send_t) (void *bfad_fcxp, struct bfa_fcxp_s *fcxp,
111 void *cbarg, enum bfa_status req_status,
112 u32 rsp_len, u32 resid_len,
113 struct fchs_s *rsp_fchs);
114typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
115
116
117
118/*
119 * Information needed for a FCXP request
120 */
121struct bfa_fcxp_req_info_s {
122 struct bfa_rport_s *bfa_rport;
123 /* Pointer to the bfa rport that was
124 * returned from bfa_rport_create().
125 * This could be left NULL for WKA or
126 * for FCXP interactions before the
127 * rport nexus is established
128 */
129 struct fchs_s fchs; /* request FC header structure */
130 u8 cts; /* continuous sequence */
131 u8 class; /* FC class for the request/response */
132 u16 max_frmsz; /* max send frame size */
133 u16 vf_id; /* vsan tag if applicable */
134 u8 lp_tag; /* lport tag */
135 u32 req_tot_len; /* request payload total length */
136};
137
138struct bfa_fcxp_rsp_info_s {
139 struct fchs_s rsp_fchs;
140 /* Response frame's FC header will
141 * be sent back in this field */
142 u8 rsp_timeout;
143 /* timeout in seconds, 0-no response */
144 u8 rsvd2[3];
145 u32 rsp_maxlen; /* max response length expected */
146};
147
148struct bfa_fcxp_s {
149 struct list_head qe; /* fcxp queue element */
150 bfa_sm_t sm; /* state machine */
151 void *caller; /* driver or fcs */
152 struct bfa_fcxp_mod_s *fcxp_mod;
153 /* back pointer to fcxp mod */
154 u16 fcxp_tag; /* internal tag */
155 struct bfa_fcxp_req_info_s req_info;
156 /* request info */
157 struct bfa_fcxp_rsp_info_s rsp_info;
158 /* response info */
159 u8 use_ireqbuf; /* use internal req buf */
160 u8 use_irspbuf; /* use internal rsp buf */
161 u32 nreq_sgles; /* num request SGLEs */
162 u32 nrsp_sgles; /* num response SGLEs */
163 struct list_head req_sgpg_q; /* SG pages for request buf */
164 struct list_head req_sgpg_wqe; /* wait queue for req SG page */
165 struct list_head rsp_sgpg_q; /* SG pages for response buf */
166 struct list_head rsp_sgpg_wqe; /* wait queue for rsp SG page */
167
168 bfa_fcxp_get_sgaddr_t req_sga_cbfn;
169 /* SG elem addr user function */
170 bfa_fcxp_get_sglen_t req_sglen_cbfn;
171 /* SG elem len user function */
172 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
173 /* SG elem addr user function */
174 bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
175 /* SG elem len user function */
176 bfa_cb_fcxp_send_t send_cbfn; /* send completion callback */
177 void *send_cbarg; /* callback arg */
178 struct bfa_sge_s req_sge[BFA_FCXP_MAX_SGES];
179 /* req SG elems */
180 struct bfa_sge_s rsp_sge[BFA_FCXP_MAX_SGES];
181 /* rsp SG elems */
182 u8 rsp_status; /* comp: rsp status */
183 u32 rsp_len; /* comp: actual response len */
184 u32 residue_len; /* comp: residual rsp length */
185 struct fchs_s rsp_fchs; /* comp: response fchs */
186 struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
187 struct bfa_reqq_wait_s reqq_wqe;
188 bfa_boolean_t reqq_waiting;
189};
190
191struct bfa_fcxp_wqe_s {
192 struct list_head qe;
193 bfa_fcxp_alloc_cbfn_t alloc_cbfn;
194 void *alloc_cbarg;
195 void *caller;
196 struct bfa_s *bfa;
197 int nreq_sgles;
198 int nrsp_sgles;
199 bfa_fcxp_get_sgaddr_t req_sga_cbfn;
200 bfa_fcxp_get_sglen_t req_sglen_cbfn;
201 bfa_fcxp_get_sgaddr_t rsp_sga_cbfn;
202 bfa_fcxp_get_sglen_t rsp_sglen_cbfn;
203};
204
205#define BFA_FCXP_REQ_PLD(_fcxp) (bfa_fcxp_get_reqbuf(_fcxp))
206#define BFA_FCXP_RSP_FCHS(_fcxp) (&((_fcxp)->rsp_info.fchs))
207#define BFA_FCXP_RSP_PLD(_fcxp) (bfa_fcxp_get_rspbuf(_fcxp))
208
209#define BFA_FCXP_REQ_PLD_PA(_fcxp) \
210 ((_fcxp)->fcxp_mod->req_pld_list_pa + \
211 ((_fcxp)->fcxp_mod->req_pld_sz * (_fcxp)->fcxp_tag))
212
213#define BFA_FCXP_RSP_PLD_PA(_fcxp) \
214 ((_fcxp)->fcxp_mod->rsp_pld_list_pa + \
215 ((_fcxp)->fcxp_mod->rsp_pld_sz * (_fcxp)->fcxp_tag))
216
217void bfa_fcxp_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
218
219
220/*
221 * RPORT related defines
222 */
223enum bfa_rport_event {
224 BFA_RPORT_SM_CREATE = 1, /* rport create event */
225 BFA_RPORT_SM_DELETE = 2, /* deleting an existing rport */
226 BFA_RPORT_SM_ONLINE = 3, /* rport is online */
227 BFA_RPORT_SM_OFFLINE = 4, /* rport is offline */
228 BFA_RPORT_SM_FWRSP = 5, /* firmware response */
229 BFA_RPORT_SM_HWFAIL = 6, /* IOC h/w failure */
230 BFA_RPORT_SM_QOS_SCN = 7, /* QoS SCN from firmware */
231 BFA_RPORT_SM_SET_SPEED = 8, /* Set Rport Speed */
232 BFA_RPORT_SM_QRESUME = 9, /* space in requeue queue */
233};
234
235#define BFA_RPORT_MIN 4
236
237struct bfa_rport_mod_s {
238 struct bfa_rport_s *rps_list; /* list of rports */
239 struct list_head rp_free_q; /* free bfa_rports */
240 struct list_head rp_active_q; /* free bfa_rports */
241 u16 num_rports; /* number of rports */
242};
243
244#define BFA_RPORT_MOD(__bfa) (&(__bfa)->modules.rport_mod)
245
246/*
247 * Convert rport tag to RPORT
248 */
249#define BFA_RPORT_FROM_TAG(__bfa, _tag) \
250 (BFA_RPORT_MOD(__bfa)->rps_list + \
251 ((_tag) & (BFA_RPORT_MOD(__bfa)->num_rports - 1)))
252
253/*
254 * protected functions
255 */
256void bfa_rport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
257
258/*
259 * BFA rport information.
260 */
261struct bfa_rport_info_s {
262 u16 max_frmsz; /* max rcv pdu size */
263 u32 pid:24, /* remote port ID */
264 lp_tag:8; /* tag */
265 u32 local_pid:24, /* local port ID */
266 cisc:8; /* CIRO supported */
267 u8 fc_class; /* supported FC classes. enum fc_cos */
268 u8 vf_en; /* virtual fabric enable */
269 u16 vf_id; /* virtual fabric ID */
270 enum bfa_port_speed speed; /* Rport's current speed */
271};
272
273/*
274 * BFA rport data structure
275 */
276struct bfa_rport_s {
277 struct list_head qe; /* queue element */
278 bfa_sm_t sm; /* state machine */
279 struct bfa_s *bfa; /* backpointer to BFA */
280 void *rport_drv; /* fcs/driver rport object */
281 u16 fw_handle; /* firmware rport handle */
282 u16 rport_tag; /* BFA rport tag */
283 struct bfa_rport_info_s rport_info; /* rport info from fcs/driver */
284 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
285 struct bfa_cb_qe_s hcb_qe; /* BFA callback qelem */
286 struct bfa_rport_hal_stats_s stats; /* BFA rport statistics */
287 struct bfa_rport_qos_attr_s qos_attr;
288 union a {
289 bfa_status_t status; /* f/w status */
290 void *fw_msg; /* QoS scn event */
291 } event_arg;
292};
293#define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class)
294
295
296/*
297 * UF - unsolicited receive related defines
298 */
299
300#define BFA_UF_MIN (4)
301
302
303struct bfa_uf_s {
304 struct list_head qe; /* queue element */
305 struct bfa_s *bfa; /* bfa instance */
306 u16 uf_tag; /* identifying tag fw msgs */
307 u16 vf_id;
308 u16 src_rport_handle;
309 u16 rsvd;
310 u8 *data_ptr;
311 u16 data_len; /* actual receive length */
312 u16 pb_len; /* posted buffer length */
313 void *buf_kva; /* buffer virtual address */
314 u64 buf_pa; /* buffer physical address */
315 struct bfa_cb_qe_s hcb_qe; /* comp: BFA comp qelem */
316 struct bfa_sge_s sges[BFI_SGE_INLINE_MAX];
317};
318
319/*
320 * Callback prototype for unsolicited frame receive handler.
321 *
322 * @param[in] cbarg callback arg for receive handler
323 * @param[in] uf unsolicited frame descriptor
324 *
325 * @return None
326 */
327typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
328
329struct bfa_uf_mod_s {
330 struct bfa_s *bfa; /* back pointer to BFA */
331 struct bfa_uf_s *uf_list; /* array of UFs */
332 u16 num_ufs; /* num unsolicited rx frames */
333 struct list_head uf_free_q; /* free UFs */
334 struct list_head uf_posted_q; /* UFs posted to IOC */
335 struct bfa_uf_buf_s *uf_pbs_kva; /* list UF bufs request pld */
336 u64 uf_pbs_pa; /* phy addr for UF bufs */
337 struct bfi_uf_buf_post_s *uf_buf_posts;
338 /* pre-built UF post msgs */
339 bfa_cb_uf_recv_t ufrecv; /* uf recv handler function */
340 void *cbarg; /* uf receive handler arg */
341};
342
343#define BFA_UF_MOD(__bfa) (&(__bfa)->modules.uf_mod)
344
345#define ufm_pbs_pa(_ufmod, _uftag) \
346 ((_ufmod)->uf_pbs_pa + sizeof(struct bfa_uf_buf_s) * (_uftag))
347
348void bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
349
350#define BFA_UF_BUFSZ (2 * 1024 + 256)
351
352/*
353 * @todo private
354 */
355struct bfa_uf_buf_s {
356 u8 d[BFA_UF_BUFSZ];
357};
358
359
360/*
361 * LPS - bfa lport login/logout service interface
362 */
363struct bfa_lps_s {
364 struct list_head qe; /* queue element */
365 struct bfa_s *bfa; /* parent bfa instance */
366 bfa_sm_t sm; /* finite state machine */
367 u8 lp_tag; /* lport tag */
368 u8 reqq; /* lport request queue */
369 u8 alpa; /* ALPA for loop topologies */
370 u32 lp_pid; /* lport port ID */
371 bfa_boolean_t fdisc; /* snd FDISC instead of FLOGI */
372 bfa_boolean_t auth_en; /* enable authentication */
373 bfa_boolean_t auth_req; /* authentication required */
374 bfa_boolean_t npiv_en; /* NPIV is allowed by peer */
375 bfa_boolean_t fport; /* attached peer is F_PORT */
376 bfa_boolean_t brcd_switch; /* attached peer is brcd sw */
377 bfa_status_t status; /* login status */
378 u16 pdusz; /* max receive PDU size */
379 u16 pr_bbcred; /* BB_CREDIT from peer */
380 u8 lsrjt_rsn; /* LSRJT reason */
381 u8 lsrjt_expl; /* LSRJT explanation */
382 wwn_t pwwn; /* port wwn of lport */
383 wwn_t nwwn; /* node wwn of lport */
384 wwn_t pr_pwwn; /* port wwn of lport peer */
385 wwn_t pr_nwwn; /* node wwn of lport peer */
386 mac_t lp_mac; /* fpma/spma MAC for lport */
387 mac_t fcf_mac; /* FCF MAC of lport */
388 struct bfa_reqq_wait_s wqe; /* request wait queue element */
389 void *uarg; /* user callback arg */
390 struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
391 struct bfi_lps_login_rsp_s *loginrsp;
392 bfa_eproto_status_t ext_status;
393};
394
395struct bfa_lps_mod_s {
396 struct list_head lps_free_q;
397 struct list_head lps_active_q;
398 struct bfa_lps_s *lps_arr;
399 int num_lps;
400};
401
402#define BFA_LPS_MOD(__bfa) (&(__bfa)->modules.lps_mod)
403#define BFA_LPS_FROM_TAG(__mod, __tag) (&(__mod)->lps_arr[__tag])
404
405/*
406 * external functions
407 */
408void bfa_lps_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
409
410
411/*
412 * FCPORT related defines
413 */
414
415#define BFA_FCPORT(_bfa) (&((_bfa)->modules.port))
416typedef void (*bfa_cb_port_t) (void *cbarg, enum bfa_status status);
417
418/*
419 * Link notification data structure
420 */
421struct bfa_fcport_ln_s {
422 struct bfa_fcport_s *fcport;
423 bfa_sm_t sm;
424 struct bfa_cb_qe_s ln_qe; /* BFA callback queue elem for ln */
425 enum bfa_port_linkstate ln_event; /* ln event for callback */
426};
427
428struct bfa_fcport_trunk_s {
429 struct bfa_trunk_attr_s attr;
430};
431
432/*
433 * BFA FC port data structure
434 */
435struct bfa_fcport_s {
436 struct bfa_s *bfa; /* parent BFA instance */
437 bfa_sm_t sm; /* port state machine */
438 wwn_t nwwn; /* node wwn of physical port */
439 wwn_t pwwn; /* port wwn of physical oprt */
440 enum bfa_port_speed speed_sup;
441 /* supported speeds */
442 enum bfa_port_speed speed; /* current speed */
443 enum bfa_port_topology topology; /* current topology */
444 u8 myalpa; /* my ALPA in LOOP topology */
445 u8 rsvd[3];
446 struct bfa_port_cfg_s cfg; /* current port configuration */
447 bfa_boolean_t use_flash_cfg; /* get port cfg from flash */
448 struct bfa_qos_attr_s qos_attr; /* QoS Attributes */
449 struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */
450 struct bfa_reqq_wait_s reqq_wait;
451 /* to wait for room in reqq */
452 struct bfa_reqq_wait_s svcreq_wait;
453 /* to wait for room in reqq */
454 struct bfa_reqq_wait_s stats_reqq_wait;
455 /* to wait for room in reqq (stats) */
456 void *event_cbarg;
457 void (*event_cbfn) (void *cbarg,
458 enum bfa_port_linkstate event);
459 union {
460 union bfi_fcport_i2h_msg_u i2hmsg;
461 } event_arg;
462 void *bfad; /* BFA driver handle */
463 struct bfa_fcport_ln_s ln; /* Link Notification */
464 struct bfa_cb_qe_s hcb_qe; /* BFA callback queue elem */
465 struct bfa_timer_s timer; /* timer */
466 u32 msgtag; /* fimrware msg tag for reply */
467 u8 *stats_kva;
468 u64 stats_pa;
469 union bfa_fcport_stats_u *stats;
470 union bfa_fcport_stats_u *stats_ret; /* driver stats location */
471 bfa_status_t stats_status; /* stats/statsclr status */
472 bfa_boolean_t stats_busy; /* outstanding stats/statsclr */
473 bfa_boolean_t stats_qfull;
474 u32 stats_reset_time; /* stats reset time stamp */
475 bfa_cb_port_t stats_cbfn; /* driver callback function */
476 void *stats_cbarg; /* *!< user callback arg */
477 bfa_boolean_t diag_busy; /* diag busy status */
478 bfa_boolean_t beacon; /* port beacon status */
479 bfa_boolean_t link_e2e_beacon; /* link beacon status */
480 struct bfa_fcport_trunk_s trunk;
481 u16 fcoe_vlan;
482};
483
484#define BFA_FCPORT_MOD(__bfa) (&(__bfa)->modules.fcport)
485
486/*
487 * protected functions
488 */
489void bfa_fcport_init(struct bfa_s *bfa);
490void bfa_fcport_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
491
492/*
493 * bfa fcport API functions
494 */
495bfa_status_t bfa_fcport_enable(struct bfa_s *bfa);
496bfa_status_t bfa_fcport_disable(struct bfa_s *bfa);
497bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa,
498 enum bfa_port_speed speed);
499enum bfa_port_speed bfa_fcport_get_speed(struct bfa_s *bfa);
500bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa,
501 enum bfa_port_topology topo);
502enum bfa_port_topology bfa_fcport_get_topology(struct bfa_s *bfa);
503bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa);
504bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa);
505u8 bfa_fcport_get_myalpa(struct bfa_s *bfa);
506bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa);
507bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize);
508u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa);
509u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa);
510void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_port_attr_s *attr);
511wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node);
512void bfa_fcport_event_register(struct bfa_s *bfa,
513 void (*event_cbfn) (void *cbarg,
514 enum bfa_port_linkstate event), void *event_cbarg);
515bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa);
516enum bfa_port_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa);
517
518void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit);
519bfa_boolean_t bfa_fcport_is_ratelim(struct bfa_s *bfa);
520bfa_boolean_t bfa_fcport_is_linkup(struct bfa_s *bfa);
521bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa,
522 union bfa_fcport_stats_u *stats,
523 bfa_cb_port_t cbfn, void *cbarg);
524bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_port_t cbfn,
525 void *cbarg);
526bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa);
527
528/*
529 * bfa rport API functions
530 */
531struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
532void bfa_rport_online(struct bfa_rport_s *rport,
533 struct bfa_rport_info_s *rport_info);
534void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_port_speed speed);
535void bfa_cb_rport_online(void *rport);
536void bfa_cb_rport_offline(void *rport);
537void bfa_cb_rport_qos_scn_flowid(void *rport,
538 struct bfa_rport_qos_attr_s old_qos_attr,
539 struct bfa_rport_qos_attr_s new_qos_attr);
540void bfa_cb_rport_qos_scn_prio(void *rport,
541 struct bfa_rport_qos_attr_s old_qos_attr,
542 struct bfa_rport_qos_attr_s new_qos_attr);
543
544/*
545 * bfa fcxp API functions
546 */
547struct bfa_fcxp_s *bfa_fcxp_alloc(void *bfad_fcxp, struct bfa_s *bfa,
548 int nreq_sgles, int nrsp_sgles,
549 bfa_fcxp_get_sgaddr_t get_req_sga,
550 bfa_fcxp_get_sglen_t get_req_sglen,
551 bfa_fcxp_get_sgaddr_t get_rsp_sga,
552 bfa_fcxp_get_sglen_t get_rsp_sglen);
553void bfa_fcxp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
554 bfa_fcxp_alloc_cbfn_t alloc_cbfn,
555 void *cbarg, void *bfad_fcxp,
556 int nreq_sgles, int nrsp_sgles,
557 bfa_fcxp_get_sgaddr_t get_req_sga,
558 bfa_fcxp_get_sglen_t get_req_sglen,
559 bfa_fcxp_get_sgaddr_t get_rsp_sga,
560 bfa_fcxp_get_sglen_t get_rsp_sglen);
561void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
562 struct bfa_fcxp_wqe_s *wqe);
563void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
564
565void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
566void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
567
568void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
569
570void bfa_fcxp_send(struct bfa_fcxp_s *fcxp, struct bfa_rport_s *rport,
571 u16 vf_id, u8 lp_tag,
572 bfa_boolean_t cts, enum fc_cos cos,
573 u32 reqlen, struct fchs_s *fchs,
574 bfa_cb_fcxp_send_t cbfn,
575 void *cbarg,
576 u32 rsp_maxlen, u8 rsp_timeout);
577bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp);
578u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
579u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
580
581static inline void *
582bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
583{
584 return uf->data_ptr;
585}
586
587static inline u16
588bfa_uf_get_frmlen(struct bfa_uf_s *uf)
589{
590 return uf->data_len;
591}
592
593/*
594 * bfa uf API functions
595 */
596void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
597 void *cbarg);
598void bfa_uf_free(struct bfa_uf_s *uf);
599
600/*
601 * bfa lport service api
602 */
603
604u32 bfa_lps_get_max_vport(struct bfa_s *bfa);
605struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
606void bfa_lps_delete(struct bfa_lps_s *lps);
607void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa,
608 u16 pdusz, wwn_t pwwn, wwn_t nwwn,
609 bfa_boolean_t auth_en);
610void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz,
611 wwn_t pwwn, wwn_t nwwn);
612void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
613void bfa_lps_set_n2n_pid(struct bfa_lps_s *lps, u32 n2n_pid);
614u32 bfa_lps_get_base_pid(struct bfa_s *bfa);
615u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
616void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
617void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
618void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
619void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
620
621#endif /* __BFA_SVC_H__ */
diff --git a/drivers/scsi/bfa/bfa_timer.c b/drivers/scsi/bfa/bfa_timer.c
deleted file mode 100644
index cb76481f5cb1..000000000000
--- a/drivers/scsi/bfa/bfa_timer.c
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa_timer.h>
19#include <cs/bfa_debug.h>
20
21void
22bfa_timer_init(struct bfa_timer_mod_s *mod)
23{
24 INIT_LIST_HEAD(&mod->timer_q);
25}
26
27void
28bfa_timer_beat(struct bfa_timer_mod_s *mod)
29{
30 struct list_head *qh = &mod->timer_q;
31 struct list_head *qe, *qe_next;
32 struct bfa_timer_s *elem;
33 struct list_head timedout_q;
34
35 INIT_LIST_HEAD(&timedout_q);
36
37 qe = bfa_q_next(qh);
38
39 while (qe != qh) {
40 qe_next = bfa_q_next(qe);
41
42 elem = (struct bfa_timer_s *) qe;
43 if (elem->timeout <= BFA_TIMER_FREQ) {
44 elem->timeout = 0;
45 list_del(&elem->qe);
46 list_add_tail(&elem->qe, &timedout_q);
47 } else {
48 elem->timeout -= BFA_TIMER_FREQ;
49 }
50
51 qe = qe_next; /* go to next elem */
52 }
53
54 /*
55 * Pop all the timeout entries
56 */
57 while (!list_empty(&timedout_q)) {
58 bfa_q_deq(&timedout_q, &elem);
59 elem->timercb(elem->arg);
60 }
61}
62
63/**
64 * Should be called with lock protection
65 */
66void
67bfa_timer_begin(struct bfa_timer_mod_s *mod, struct bfa_timer_s *timer,
68 void (*timercb) (void *), void *arg, unsigned int timeout)
69{
70
71 bfa_assert(timercb != NULL);
72 bfa_assert(!bfa_q_is_on_q(&mod->timer_q, timer));
73
74 timer->timeout = timeout;
75 timer->timercb = timercb;
76 timer->arg = arg;
77
78 list_add_tail(&timer->qe, &mod->timer_q);
79}
80
81/**
82 * Should be called with lock protection
83 */
84void
85bfa_timer_stop(struct bfa_timer_s *timer)
86{
87 bfa_assert(!list_empty(&timer->qe));
88
89 list_del(&timer->qe);
90}
diff --git a/drivers/scsi/bfa/bfa_trcmod_priv.h b/drivers/scsi/bfa/bfa_trcmod_priv.h
deleted file mode 100644
index a7a82610db85..000000000000
--- a/drivers/scsi/bfa/bfa_trcmod_priv.h
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * hal_trcmod.h BFA trace modules
20 */
21
22#ifndef __BFA_TRCMOD_PRIV_H__
23#define __BFA_TRCMOD_PRIV_H__
24
25#include <cs/bfa_trc.h>
26
27/*
28 * !!! Only append to the enums defined here to avoid any versioning
29 * !!! needed between trace utility and driver version
30 */
31enum {
32 BFA_TRC_HAL_INTR = 1,
33 BFA_TRC_HAL_FCXP = 2,
34 BFA_TRC_HAL_UF = 3,
35 BFA_TRC_HAL_RPORT = 4,
36 BFA_TRC_HAL_FCPIM = 5,
37 BFA_TRC_HAL_IOIM = 6,
38 BFA_TRC_HAL_TSKIM = 7,
39 BFA_TRC_HAL_ITNIM = 8,
40 BFA_TRC_HAL_FCPORT = 9,
41 BFA_TRC_HAL_SGPG = 10,
42 BFA_TRC_HAL_FLASH = 11,
43 BFA_TRC_HAL_DEBUG = 12,
44 BFA_TRC_HAL_WWN = 13,
45 BFA_TRC_HAL_FLASH_RAW = 14,
46 BFA_TRC_HAL_SBOOT = 15,
47 BFA_TRC_HAL_SBOOT_IO = 16,
48 BFA_TRC_HAL_SBOOT_INTR = 17,
49 BFA_TRC_HAL_SBTEST = 18,
50 BFA_TRC_HAL_IPFC = 19,
51 BFA_TRC_HAL_IOCFC = 20,
52 BFA_TRC_HAL_FCPTM = 21,
53 BFA_TRC_HAL_IOTM = 22,
54 BFA_TRC_HAL_TSKTM = 23,
55 BFA_TRC_HAL_TIN = 24,
56 BFA_TRC_HAL_LPS = 25,
57 BFA_TRC_HAL_FCDIAG = 26,
58 BFA_TRC_HAL_PBIND = 27,
59 BFA_TRC_HAL_IOCFC_CT = 28,
60 BFA_TRC_HAL_IOCFC_CB = 29,
61 BFA_TRC_HAL_IOCFC_Q = 30,
62};
63
64#endif /* __BFA_TRCMOD_PRIV_H__ */
diff --git a/drivers/scsi/bfa/bfa_tskim.c b/drivers/scsi/bfa/bfa_tskim.c
deleted file mode 100644
index ad9aaaedd3f1..000000000000
--- a/drivers/scsi/bfa/bfa_tskim.c
+++ /dev/null
@@ -1,690 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
19#include <bfa_cb_ioim_macros.h>
20
21BFA_TRC_FILE(HAL, TSKIM);
22
23/**
24 * task management completion handling
25 */
26#define bfa_tskim_qcomp(__tskim, __cbfn) do { \
27 bfa_cb_queue((__tskim)->bfa, &(__tskim)->hcb_qe, \
28 __cbfn, (__tskim)); \
29 bfa_tskim_notify_comp(__tskim); \
30} while (0)
31
32#define bfa_tskim_notify_comp(__tskim) do { \
33 if ((__tskim)->notify) \
34 bfa_itnim_tskdone((__tskim)->itnim); \
35} while (0)
36
37/*
38 * forward declarations
39 */
40static void __bfa_cb_tskim_done(void *cbarg, bfa_boolean_t complete);
41static void __bfa_cb_tskim_failed(void *cbarg, bfa_boolean_t complete);
42static bfa_boolean_t bfa_tskim_match_scope(struct bfa_tskim_s *tskim,
43 lun_t lun);
44static void bfa_tskim_gather_ios(struct bfa_tskim_s *tskim);
45static void bfa_tskim_cleanp_comp(void *tskim_cbarg);
46static void bfa_tskim_cleanup_ios(struct bfa_tskim_s *tskim);
47static bfa_boolean_t bfa_tskim_send(struct bfa_tskim_s *tskim);
48static bfa_boolean_t bfa_tskim_send_abort(struct bfa_tskim_s *tskim);
49static void bfa_tskim_iocdisable_ios(struct bfa_tskim_s *tskim);
50
51/**
52 * bfa_tskim_sm
53 */
54
55enum bfa_tskim_event {
56 BFA_TSKIM_SM_START = 1, /* TM command start */
57 BFA_TSKIM_SM_DONE = 2, /* TM completion */
58 BFA_TSKIM_SM_QRESUME = 3, /* resume after qfull */
59 BFA_TSKIM_SM_HWFAIL = 5, /* IOC h/w failure event */
60 BFA_TSKIM_SM_HCB = 6, /* BFA callback completion */
61 BFA_TSKIM_SM_IOS_DONE = 7, /* IO and sub TM completions */
62 BFA_TSKIM_SM_CLEANUP = 8, /* TM cleanup on ITN offline */
63 BFA_TSKIM_SM_CLEANUP_DONE = 9, /* TM abort completion */
64};
65
66static void bfa_tskim_sm_uninit(struct bfa_tskim_s *tskim,
67 enum bfa_tskim_event event);
68static void bfa_tskim_sm_active(struct bfa_tskim_s *tskim,
69 enum bfa_tskim_event event);
70static void bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim,
71 enum bfa_tskim_event event);
72static void bfa_tskim_sm_iocleanup(struct bfa_tskim_s *tskim,
73 enum bfa_tskim_event event);
74static void bfa_tskim_sm_qfull(struct bfa_tskim_s *tskim,
75 enum bfa_tskim_event event);
76static void bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s *tskim,
77 enum bfa_tskim_event event);
78static void bfa_tskim_sm_hcb(struct bfa_tskim_s *tskim,
79 enum bfa_tskim_event event);
80
81/**
82 * Task management command beginning state.
83 */
84static void
85bfa_tskim_sm_uninit(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
86{
87 bfa_trc(tskim->bfa, event);
88
89 switch (event) {
90 case BFA_TSKIM_SM_START:
91 bfa_sm_set_state(tskim, bfa_tskim_sm_active);
92 bfa_tskim_gather_ios(tskim);
93
94 /**
95 * If device is offline, do not send TM on wire. Just cleanup
96 * any pending IO requests and complete TM request.
97 */
98 if (!bfa_itnim_is_online(tskim->itnim)) {
99 bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
100 tskim->tsk_status = BFI_TSKIM_STS_OK;
101 bfa_tskim_cleanup_ios(tskim);
102 return;
103 }
104
105 if (!bfa_tskim_send(tskim)) {
106 bfa_sm_set_state(tskim, bfa_tskim_sm_qfull);
107 bfa_reqq_wait(tskim->bfa, tskim->itnim->reqq,
108 &tskim->reqq_wait);
109 }
110 break;
111
112 default:
113 bfa_sm_fault(tskim->bfa, event);
114 }
115}
116
117/**
118 * brief
119 * TM command is active, awaiting completion from firmware to
120 * cleanup IO requests in TM scope.
121 */
122static void
123bfa_tskim_sm_active(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
124{
125 bfa_trc(tskim->bfa, event);
126
127 switch (event) {
128 case BFA_TSKIM_SM_DONE:
129 bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
130 bfa_tskim_cleanup_ios(tskim);
131 break;
132
133 case BFA_TSKIM_SM_CLEANUP:
134 bfa_sm_set_state(tskim, bfa_tskim_sm_cleanup);
135 if (!bfa_tskim_send_abort(tskim)) {
136 bfa_sm_set_state(tskim, bfa_tskim_sm_cleanup_qfull);
137 bfa_reqq_wait(tskim->bfa, tskim->itnim->reqq,
138 &tskim->reqq_wait);
139 }
140 break;
141
142 case BFA_TSKIM_SM_HWFAIL:
143 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
144 bfa_tskim_iocdisable_ios(tskim);
145 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
146 break;
147
148 default:
149 bfa_sm_fault(tskim->bfa, event);
150 }
151}
152
153/**
154 * An active TM is being cleaned up since ITN is offline. Awaiting cleanup
155 * completion event from firmware.
156 */
157static void
158bfa_tskim_sm_cleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
159{
160 bfa_trc(tskim->bfa, event);
161
162 switch (event) {
163 case BFA_TSKIM_SM_DONE:
164 /**
165 * Ignore and wait for ABORT completion from firmware.
166 */
167 break;
168
169 case BFA_TSKIM_SM_CLEANUP_DONE:
170 bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
171 bfa_tskim_cleanup_ios(tskim);
172 break;
173
174 case BFA_TSKIM_SM_HWFAIL:
175 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
176 bfa_tskim_iocdisable_ios(tskim);
177 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
178 break;
179
180 default:
181 bfa_sm_fault(tskim->bfa, event);
182 }
183}
184
185static void
186bfa_tskim_sm_iocleanup(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
187{
188 bfa_trc(tskim->bfa, event);
189
190 switch (event) {
191 case BFA_TSKIM_SM_IOS_DONE:
192 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
193 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_done);
194 break;
195
196 case BFA_TSKIM_SM_CLEANUP:
197 /**
198 * Ignore, TM command completed on wire.
199 * Notify TM conmpletion on IO cleanup completion.
200 */
201 break;
202
203 case BFA_TSKIM_SM_HWFAIL:
204 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
205 bfa_tskim_iocdisable_ios(tskim);
206 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
207 break;
208
209 default:
210 bfa_sm_fault(tskim->bfa, event);
211 }
212}
213
214/**
215 * Task management command is waiting for room in request CQ
216 */
217static void
218bfa_tskim_sm_qfull(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
219{
220 bfa_trc(tskim->bfa, event);
221
222 switch (event) {
223 case BFA_TSKIM_SM_QRESUME:
224 bfa_sm_set_state(tskim, bfa_tskim_sm_active);
225 bfa_tskim_send(tskim);
226 break;
227
228 case BFA_TSKIM_SM_CLEANUP:
229 /**
230 * No need to send TM on wire since ITN is offline.
231 */
232 bfa_sm_set_state(tskim, bfa_tskim_sm_iocleanup);
233 bfa_reqq_wcancel(&tskim->reqq_wait);
234 bfa_tskim_cleanup_ios(tskim);
235 break;
236
237 case BFA_TSKIM_SM_HWFAIL:
238 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
239 bfa_reqq_wcancel(&tskim->reqq_wait);
240 bfa_tskim_iocdisable_ios(tskim);
241 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
242 break;
243
244 default:
245 bfa_sm_fault(tskim->bfa, event);
246 }
247}
248
249/**
250 * Task management command is active, awaiting for room in request CQ
251 * to send clean up request.
252 */
253static void
254bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s *tskim,
255 enum bfa_tskim_event event)
256{
257 bfa_trc(tskim->bfa, event);
258
259 switch (event) {
260 case BFA_TSKIM_SM_DONE:
261 bfa_reqq_wcancel(&tskim->reqq_wait);
262 /**
263 *
264 * Fall through !!!
265 */
266
267 case BFA_TSKIM_SM_QRESUME:
268 bfa_sm_set_state(tskim, bfa_tskim_sm_cleanup);
269 bfa_tskim_send_abort(tskim);
270 break;
271
272 case BFA_TSKIM_SM_HWFAIL:
273 bfa_sm_set_state(tskim, bfa_tskim_sm_hcb);
274 bfa_reqq_wcancel(&tskim->reqq_wait);
275 bfa_tskim_iocdisable_ios(tskim);
276 bfa_tskim_qcomp(tskim, __bfa_cb_tskim_failed);
277 break;
278
279 default:
280 bfa_sm_fault(tskim->bfa, event);
281 }
282}
283
284/**
285 * BFA callback is pending
286 */
287static void
288bfa_tskim_sm_hcb(struct bfa_tskim_s *tskim, enum bfa_tskim_event event)
289{
290 bfa_trc(tskim->bfa, event);
291
292 switch (event) {
293 case BFA_TSKIM_SM_HCB:
294 bfa_sm_set_state(tskim, bfa_tskim_sm_uninit);
295 bfa_tskim_free(tskim);
296 break;
297
298 case BFA_TSKIM_SM_CLEANUP:
299 bfa_tskim_notify_comp(tskim);
300 break;
301
302 case BFA_TSKIM_SM_HWFAIL:
303 break;
304
305 default:
306 bfa_sm_fault(tskim->bfa, event);
307 }
308}
309
310
311
312/**
313 * bfa_tskim_private
314 */
315
316static void
317__bfa_cb_tskim_done(void *cbarg, bfa_boolean_t complete)
318{
319 struct bfa_tskim_s *tskim = cbarg;
320
321 if (!complete) {
322 bfa_sm_send_event(tskim, BFA_TSKIM_SM_HCB);
323 return;
324 }
325
326 bfa_stats(tskim->itnim, tm_success);
327 bfa_cb_tskim_done(tskim->bfa->bfad, tskim->dtsk, tskim->tsk_status);
328}
329
330static void
331__bfa_cb_tskim_failed(void *cbarg, bfa_boolean_t complete)
332{
333 struct bfa_tskim_s *tskim = cbarg;
334
335 if (!complete) {
336 bfa_sm_send_event(tskim, BFA_TSKIM_SM_HCB);
337 return;
338 }
339
340 bfa_stats(tskim->itnim, tm_failures);
341 bfa_cb_tskim_done(tskim->bfa->bfad, tskim->dtsk,
342 BFI_TSKIM_STS_FAILED);
343}
344
345static bfa_boolean_t
346bfa_tskim_match_scope(struct bfa_tskim_s *tskim, lun_t lun)
347{
348 switch (tskim->tm_cmnd) {
349 case FCP_TM_TARGET_RESET:
350 return BFA_TRUE;
351
352 case FCP_TM_ABORT_TASK_SET:
353 case FCP_TM_CLEAR_TASK_SET:
354 case FCP_TM_LUN_RESET:
355 case FCP_TM_CLEAR_ACA:
356 return (tskim->lun == lun);
357
358 default:
359 bfa_assert(0);
360 }
361
362 return BFA_FALSE;
363}
364
365/**
366 * Gather affected IO requests and task management commands.
367 */
368static void
369bfa_tskim_gather_ios(struct bfa_tskim_s *tskim)
370{
371 struct bfa_itnim_s *itnim = tskim->itnim;
372 struct bfa_ioim_s *ioim;
373 struct list_head *qe, *qen;
374
375 INIT_LIST_HEAD(&tskim->io_q);
376
377 /**
378 * Gather any active IO requests first.
379 */
380 list_for_each_safe(qe, qen, &itnim->io_q) {
381 ioim = (struct bfa_ioim_s *) qe;
382 if (bfa_tskim_match_scope
383 (tskim, bfa_cb_ioim_get_lun(ioim->dio))) {
384 list_del(&ioim->qe);
385 list_add_tail(&ioim->qe, &tskim->io_q);
386 }
387 }
388
389 /**
390 * Failback any pending IO requests immediately.
391 */
392 list_for_each_safe(qe, qen, &itnim->pending_q) {
393 ioim = (struct bfa_ioim_s *) qe;
394 if (bfa_tskim_match_scope
395 (tskim, bfa_cb_ioim_get_lun(ioim->dio))) {
396 list_del(&ioim->qe);
397 list_add_tail(&ioim->qe, &ioim->fcpim->ioim_comp_q);
398 bfa_ioim_tov(ioim);
399 }
400 }
401}
402
403/**
404 * IO cleanup completion
405 */
406static void
407bfa_tskim_cleanp_comp(void *tskim_cbarg)
408{
409 struct bfa_tskim_s *tskim = tskim_cbarg;
410
411 bfa_stats(tskim->itnim, tm_io_comps);
412 bfa_sm_send_event(tskim, BFA_TSKIM_SM_IOS_DONE);
413}
414
415/**
416 * Gather affected IO requests and task management commands.
417 */
418static void
419bfa_tskim_cleanup_ios(struct bfa_tskim_s *tskim)
420{
421 struct bfa_ioim_s *ioim;
422 struct list_head *qe, *qen;
423
424 bfa_wc_init(&tskim->wc, bfa_tskim_cleanp_comp, tskim);
425
426 list_for_each_safe(qe, qen, &tskim->io_q) {
427 ioim = (struct bfa_ioim_s *) qe;
428 bfa_wc_up(&tskim->wc);
429 bfa_ioim_cleanup_tm(ioim, tskim);
430 }
431
432 bfa_wc_wait(&tskim->wc);
433}
434
435/**
436 * Send task management request to firmware.
437 */
438static bfa_boolean_t
439bfa_tskim_send(struct bfa_tskim_s *tskim)
440{
441 struct bfa_itnim_s *itnim = tskim->itnim;
442 struct bfi_tskim_req_s *m;
443
444 /**
445 * check for room in queue to send request now
446 */
447 m = bfa_reqq_next(tskim->bfa, itnim->reqq);
448 if (!m)
449 return BFA_FALSE;
450
451 /**
452 * build i/o request message next
453 */
454 bfi_h2i_set(m->mh, BFI_MC_TSKIM, BFI_TSKIM_H2I_TM_REQ,
455 bfa_lpuid(tskim->bfa));
456
457 m->tsk_tag = bfa_os_htons(tskim->tsk_tag);
458 m->itn_fhdl = tskim->itnim->rport->fw_handle;
459 m->t_secs = tskim->tsecs;
460 m->lun = tskim->lun;
461 m->tm_flags = tskim->tm_cmnd;
462
463 /**
464 * queue I/O message to firmware
465 */
466 bfa_reqq_produce(tskim->bfa, itnim->reqq);
467 return BFA_TRUE;
468}
469
470/**
471 * Send abort request to cleanup an active TM to firmware.
472 */
473static bfa_boolean_t
474bfa_tskim_send_abort(struct bfa_tskim_s *tskim)
475{
476 struct bfa_itnim_s *itnim = tskim->itnim;
477 struct bfi_tskim_abortreq_s *m;
478
479 /**
480 * check for room in queue to send request now
481 */
482 m = bfa_reqq_next(tskim->bfa, itnim->reqq);
483 if (!m)
484 return BFA_FALSE;
485
486 /**
487 * build i/o request message next
488 */
489 bfi_h2i_set(m->mh, BFI_MC_TSKIM, BFI_TSKIM_H2I_ABORT_REQ,
490 bfa_lpuid(tskim->bfa));
491
492 m->tsk_tag = bfa_os_htons(tskim->tsk_tag);
493
494 /**
495 * queue I/O message to firmware
496 */
497 bfa_reqq_produce(tskim->bfa, itnim->reqq);
498 return BFA_TRUE;
499}
500
501/**
502 * Call to resume task management cmnd waiting for room in request queue.
503 */
504static void
505bfa_tskim_qresume(void *cbarg)
506{
507 struct bfa_tskim_s *tskim = cbarg;
508
509 bfa_fcpim_stats(tskim->fcpim, qresumes);
510 bfa_stats(tskim->itnim, tm_qresumes);
511 bfa_sm_send_event(tskim, BFA_TSKIM_SM_QRESUME);
512}
513
514/**
515 * Cleanup IOs associated with a task mangement command on IOC failures.
516 */
517static void
518bfa_tskim_iocdisable_ios(struct bfa_tskim_s *tskim)
519{
520 struct bfa_ioim_s *ioim;
521 struct list_head *qe, *qen;
522
523 list_for_each_safe(qe, qen, &tskim->io_q) {
524 ioim = (struct bfa_ioim_s *) qe;
525 bfa_ioim_iocdisable(ioim);
526 }
527}
528
529
530
531/**
532 * bfa_tskim_friend
533 */
534
535/**
536 * Notification on completions from related ioim.
537 */
538void
539bfa_tskim_iodone(struct bfa_tskim_s *tskim)
540{
541 bfa_wc_down(&tskim->wc);
542}
543
544/**
545 * Handle IOC h/w failure notification from itnim.
546 */
547void
548bfa_tskim_iocdisable(struct bfa_tskim_s *tskim)
549{
550 tskim->notify = BFA_FALSE;
551 bfa_stats(tskim->itnim, tm_iocdowns);
552 bfa_sm_send_event(tskim, BFA_TSKIM_SM_HWFAIL);
553}
554
555/**
556 * Cleanup TM command and associated IOs as part of ITNIM offline.
557 */
558void
559bfa_tskim_cleanup(struct bfa_tskim_s *tskim)
560{
561 tskim->notify = BFA_TRUE;
562 bfa_stats(tskim->itnim, tm_cleanups);
563 bfa_sm_send_event(tskim, BFA_TSKIM_SM_CLEANUP);
564}
565
566/**
567 * Memory allocation and initialization.
568 */
569void
570bfa_tskim_attach(struct bfa_fcpim_mod_s *fcpim, struct bfa_meminfo_s *minfo)
571{
572 struct bfa_tskim_s *tskim;
573 u16 i;
574
575 INIT_LIST_HEAD(&fcpim->tskim_free_q);
576
577 tskim = (struct bfa_tskim_s *) bfa_meminfo_kva(minfo);
578 fcpim->tskim_arr = tskim;
579
580 for (i = 0; i < fcpim->num_tskim_reqs; i++, tskim++) {
581 /*
582 * initialize TSKIM
583 */
584 bfa_os_memset(tskim, 0, sizeof(struct bfa_tskim_s));
585 tskim->tsk_tag = i;
586 tskim->bfa = fcpim->bfa;
587 tskim->fcpim = fcpim;
588 tskim->notify = BFA_FALSE;
589 bfa_reqq_winit(&tskim->reqq_wait, bfa_tskim_qresume,
590 tskim);
591 bfa_sm_set_state(tskim, bfa_tskim_sm_uninit);
592
593 list_add_tail(&tskim->qe, &fcpim->tskim_free_q);
594 }
595
596 bfa_meminfo_kva(minfo) = (u8 *) tskim;
597}
598
599void
600bfa_tskim_detach(struct bfa_fcpim_mod_s *fcpim)
601{
602 /**
603 * @todo
604 */
605}
606
607void
608bfa_tskim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
609{
610 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
611 struct bfi_tskim_rsp_s *rsp = (struct bfi_tskim_rsp_s *) m;
612 struct bfa_tskim_s *tskim;
613 u16 tsk_tag = bfa_os_ntohs(rsp->tsk_tag);
614
615 tskim = BFA_TSKIM_FROM_TAG(fcpim, tsk_tag);
616 bfa_assert(tskim->tsk_tag == tsk_tag);
617
618 tskim->tsk_status = rsp->tsk_status;
619
620 /**
621 * Firmware sends BFI_TSKIM_STS_ABORTED status for abort
622 * requests. All other statuses are for normal completions.
623 */
624 if (rsp->tsk_status == BFI_TSKIM_STS_ABORTED) {
625 bfa_stats(tskim->itnim, tm_cleanup_comps);
626 bfa_sm_send_event(tskim, BFA_TSKIM_SM_CLEANUP_DONE);
627 } else {
628 bfa_stats(tskim->itnim, tm_fw_rsps);
629 bfa_sm_send_event(tskim, BFA_TSKIM_SM_DONE);
630 }
631}
632
633
634
635/**
636 * bfa_tskim_api
637 */
638
639
640struct bfa_tskim_s *
641bfa_tskim_alloc(struct bfa_s *bfa, struct bfad_tskim_s *dtsk)
642{
643 struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
644 struct bfa_tskim_s *tskim;
645
646 bfa_q_deq(&fcpim->tskim_free_q, &tskim);
647
648 if (!tskim)
649 bfa_fcpim_stats(fcpim, no_tskims);
650 else
651 tskim->dtsk = dtsk;
652
653 return tskim;
654}
655
656void
657bfa_tskim_free(struct bfa_tskim_s *tskim)
658{
659 bfa_assert(bfa_q_is_on_q_func(&tskim->itnim->tsk_q, &tskim->qe));
660 list_del(&tskim->qe);
661 list_add_tail(&tskim->qe, &tskim->fcpim->tskim_free_q);
662}
663
664/**
665 * Start a task management command.
666 *
667 * @param[in] tskim BFA task management command instance
668 * @param[in] itnim i-t nexus for the task management command
669 * @param[in] lun lun, if applicable
670 * @param[in] tm_cmnd Task management command code.
671 * @param[in] t_secs Timeout in seconds
672 *
673 * @return None.
674 */
675void
676bfa_tskim_start(struct bfa_tskim_s *tskim, struct bfa_itnim_s *itnim, lun_t lun,
677 enum fcp_tm_cmnd tm_cmnd, u8 tsecs)
678{
679 tskim->itnim = itnim;
680 tskim->lun = lun;
681 tskim->tm_cmnd = tm_cmnd;
682 tskim->tsecs = tsecs;
683 tskim->notify = BFA_FALSE;
684 bfa_stats(itnim, tm_cmnds);
685
686 list_add_tail(&tskim->qe, &itnim->tsk_q);
687 bfa_sm_send_event(tskim, BFA_TSKIM_SM_START);
688}
689
690
diff --git a/drivers/scsi/bfa/bfa_uf.c b/drivers/scsi/bfa/bfa_uf.c
deleted file mode 100644
index b9a9a686ef6a..000000000000
--- a/drivers/scsi/bfa/bfa_uf.c
+++ /dev/null
@@ -1,343 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_uf.c BFA unsolicited frame receive implementation
20 */
21
22#include <bfa.h>
23#include <bfa_svc.h>
24#include <bfi/bfi_uf.h>
25#include <cs/bfa_debug.h>
26
27BFA_TRC_FILE(HAL, UF);
28BFA_MODULE(uf);
29
30/*
31 *****************************************************************************
32 * Internal functions
33 *****************************************************************************
34 */
35static void
36__bfa_cb_uf_recv(void *cbarg, bfa_boolean_t complete)
37{
38 struct bfa_uf_s *uf = cbarg;
39 struct bfa_uf_mod_s *ufm = BFA_UF_MOD(uf->bfa);
40
41 if (complete)
42 ufm->ufrecv(ufm->cbarg, uf);
43}
44
45static void
46claim_uf_pbs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi)
47{
48 u32 uf_pb_tot_sz;
49
50 ufm->uf_pbs_kva = (struct bfa_uf_buf_s *) bfa_meminfo_dma_virt(mi);
51 ufm->uf_pbs_pa = bfa_meminfo_dma_phys(mi);
52 uf_pb_tot_sz = BFA_ROUNDUP((sizeof(struct bfa_uf_buf_s) * ufm->num_ufs),
53 BFA_DMA_ALIGN_SZ);
54
55 bfa_meminfo_dma_virt(mi) += uf_pb_tot_sz;
56 bfa_meminfo_dma_phys(mi) += uf_pb_tot_sz;
57
58 bfa_os_memset((void *)ufm->uf_pbs_kva, 0, uf_pb_tot_sz);
59}
60
61static void
62claim_uf_post_msgs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi)
63{
64 struct bfi_uf_buf_post_s *uf_bp_msg;
65 struct bfi_sge_s *sge;
66 union bfi_addr_u sga_zero = { {0} };
67 u16 i;
68 u16 buf_len;
69
70 ufm->uf_buf_posts = (struct bfi_uf_buf_post_s *) bfa_meminfo_kva(mi);
71 uf_bp_msg = ufm->uf_buf_posts;
72
73 for (i = 0, uf_bp_msg = ufm->uf_buf_posts; i < ufm->num_ufs;
74 i++, uf_bp_msg++) {
75 bfa_os_memset(uf_bp_msg, 0, sizeof(struct bfi_uf_buf_post_s));
76
77 uf_bp_msg->buf_tag = i;
78 buf_len = sizeof(struct bfa_uf_buf_s);
79 uf_bp_msg->buf_len = bfa_os_htons(buf_len);
80 bfi_h2i_set(uf_bp_msg->mh, BFI_MC_UF, BFI_UF_H2I_BUF_POST,
81 bfa_lpuid(ufm->bfa));
82
83 sge = uf_bp_msg->sge;
84 sge[0].sg_len = buf_len;
85 sge[0].flags = BFI_SGE_DATA_LAST;
86 bfa_dma_addr_set(sge[0].sga, ufm_pbs_pa(ufm, i));
87 bfa_sge_to_be(sge);
88
89 sge[1].sg_len = buf_len;
90 sge[1].flags = BFI_SGE_PGDLEN;
91 sge[1].sga = sga_zero;
92 bfa_sge_to_be(&sge[1]);
93 }
94
95 /**
96 * advance pointer beyond consumed memory
97 */
98 bfa_meminfo_kva(mi) = (u8 *) uf_bp_msg;
99}
100
101static void
102claim_ufs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi)
103{
104 u16 i;
105 struct bfa_uf_s *uf;
106
107 /*
108 * Claim block of memory for UF list
109 */
110 ufm->uf_list = (struct bfa_uf_s *) bfa_meminfo_kva(mi);
111
112 /*
113 * Initialize UFs and queue it in UF free queue
114 */
115 for (i = 0, uf = ufm->uf_list; i < ufm->num_ufs; i++, uf++) {
116 bfa_os_memset(uf, 0, sizeof(struct bfa_uf_s));
117 uf->bfa = ufm->bfa;
118 uf->uf_tag = i;
119 uf->pb_len = sizeof(struct bfa_uf_buf_s);
120 uf->buf_kva = (void *)&ufm->uf_pbs_kva[i];
121 uf->buf_pa = ufm_pbs_pa(ufm, i);
122 list_add_tail(&uf->qe, &ufm->uf_free_q);
123 }
124
125 /**
126 * advance memory pointer
127 */
128 bfa_meminfo_kva(mi) = (u8 *) uf;
129}
130
131static void
132uf_mem_claim(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi)
133{
134 claim_uf_pbs(ufm, mi);
135 claim_ufs(ufm, mi);
136 claim_uf_post_msgs(ufm, mi);
137}
138
139static void
140bfa_uf_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *ndm_len, u32 *dm_len)
141{
142 u32 num_ufs = cfg->fwcfg.num_uf_bufs;
143
144 /*
145 * dma-able memory for UF posted bufs
146 */
147 *dm_len += BFA_ROUNDUP((sizeof(struct bfa_uf_buf_s) * num_ufs),
148 BFA_DMA_ALIGN_SZ);
149
150 /*
151 * kernel Virtual memory for UFs and UF buf post msg copies
152 */
153 *ndm_len += sizeof(struct bfa_uf_s) * num_ufs;
154 *ndm_len += sizeof(struct bfi_uf_buf_post_s) * num_ufs;
155}
156
157static void
158bfa_uf_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
159 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
160{
161 struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
162
163 bfa_os_memset(ufm, 0, sizeof(struct bfa_uf_mod_s));
164 ufm->bfa = bfa;
165 ufm->num_ufs = cfg->fwcfg.num_uf_bufs;
166 INIT_LIST_HEAD(&ufm->uf_free_q);
167 INIT_LIST_HEAD(&ufm->uf_posted_q);
168
169 uf_mem_claim(ufm, meminfo);
170}
171
172static void
173bfa_uf_detach(struct bfa_s *bfa)
174{
175}
176
177static struct bfa_uf_s *
178bfa_uf_get(struct bfa_uf_mod_s *uf_mod)
179{
180 struct bfa_uf_s *uf;
181
182 bfa_q_deq(&uf_mod->uf_free_q, &uf);
183 return uf;
184}
185
186static void
187bfa_uf_put(struct bfa_uf_mod_s *uf_mod, struct bfa_uf_s *uf)
188{
189 list_add_tail(&uf->qe, &uf_mod->uf_free_q);
190}
191
192static bfa_status_t
193bfa_uf_post(struct bfa_uf_mod_s *ufm, struct bfa_uf_s *uf)
194{
195 struct bfi_uf_buf_post_s *uf_post_msg;
196
197 uf_post_msg = bfa_reqq_next(ufm->bfa, BFA_REQQ_FCXP);
198 if (!uf_post_msg)
199 return BFA_STATUS_FAILED;
200
201 bfa_os_memcpy(uf_post_msg, &ufm->uf_buf_posts[uf->uf_tag],
202 sizeof(struct bfi_uf_buf_post_s));
203 bfa_reqq_produce(ufm->bfa, BFA_REQQ_FCXP);
204
205 bfa_trc(ufm->bfa, uf->uf_tag);
206
207 list_add_tail(&uf->qe, &ufm->uf_posted_q);
208 return BFA_STATUS_OK;
209}
210
211static void
212bfa_uf_post_all(struct bfa_uf_mod_s *uf_mod)
213{
214 struct bfa_uf_s *uf;
215
216 while ((uf = bfa_uf_get(uf_mod)) != NULL) {
217 if (bfa_uf_post(uf_mod, uf) != BFA_STATUS_OK)
218 break;
219 }
220}
221
222static void
223uf_recv(struct bfa_s *bfa, struct bfi_uf_frm_rcvd_s *m)
224{
225 struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
226 u16 uf_tag = m->buf_tag;
227 struct bfa_uf_buf_s *uf_buf = &ufm->uf_pbs_kva[uf_tag];
228 struct bfa_uf_s *uf = &ufm->uf_list[uf_tag];
229 u8 *buf = &uf_buf->d[0];
230 struct fchs_s *fchs;
231
232 m->frm_len = bfa_os_ntohs(m->frm_len);
233 m->xfr_len = bfa_os_ntohs(m->xfr_len);
234
235 fchs = (struct fchs_s *) uf_buf;
236
237 list_del(&uf->qe); /* dequeue from posted queue */
238
239 uf->data_ptr = buf;
240 uf->data_len = m->xfr_len;
241
242 bfa_assert(uf->data_len >= sizeof(struct fchs_s));
243
244 if (uf->data_len == sizeof(struct fchs_s)) {
245 bfa_plog_fchdr(bfa->plog, BFA_PL_MID_HAL_UF, BFA_PL_EID_RX,
246 uf->data_len, (struct fchs_s *) buf);
247 } else {
248 u32 pld_w0 = *((u32 *) (buf + sizeof(struct fchs_s)));
249 bfa_plog_fchdr_and_pl(bfa->plog, BFA_PL_MID_HAL_UF,
250 BFA_PL_EID_RX, uf->data_len,
251 (struct fchs_s *) buf, pld_w0);
252 }
253
254 if (bfa->fcs)
255 __bfa_cb_uf_recv(uf, BFA_TRUE);
256 else
257 bfa_cb_queue(bfa, &uf->hcb_qe, __bfa_cb_uf_recv, uf);
258}
259
260static void
261bfa_uf_stop(struct bfa_s *bfa)
262{
263}
264
265static void
266bfa_uf_iocdisable(struct bfa_s *bfa)
267{
268 struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
269 struct bfa_uf_s *uf;
270 struct list_head *qe, *qen;
271
272 list_for_each_safe(qe, qen, &ufm->uf_posted_q) {
273 uf = (struct bfa_uf_s *) qe;
274 list_del(&uf->qe);
275 bfa_uf_put(ufm, uf);
276 }
277}
278
279static void
280bfa_uf_start(struct bfa_s *bfa)
281{
282 bfa_uf_post_all(BFA_UF_MOD(bfa));
283}
284
285
286
287/**
288 * bfa_uf_api
289 */
290
291/**
292 * Register handler for all unsolicted recieve frames.
293 *
294 * @param[in] bfa BFA instance
295 * @param[in] ufrecv receive handler function
296 * @param[in] cbarg receive handler arg
297 */
298void
299bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv, void *cbarg)
300{
301 struct bfa_uf_mod_s *ufm = BFA_UF_MOD(bfa);
302
303 ufm->ufrecv = ufrecv;
304 ufm->cbarg = cbarg;
305}
306
307/**
308 * Free an unsolicited frame back to BFA.
309 *
310 * @param[in] uf unsolicited frame to be freed
311 *
312 * @return None
313 */
314void
315bfa_uf_free(struct bfa_uf_s *uf)
316{
317 bfa_uf_put(BFA_UF_MOD(uf->bfa), uf);
318 bfa_uf_post_all(BFA_UF_MOD(uf->bfa));
319}
320
321
322
323/**
324 * uf_pub BFA uf module public functions
325 */
326
327void
328bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg)
329{
330 bfa_trc(bfa, msg->mhdr.msg_id);
331
332 switch (msg->mhdr.msg_id) {
333 case BFI_UF_I2H_FRM_RCVD:
334 uf_recv(bfa, (struct bfi_uf_frm_rcvd_s *) msg);
335 break;
336
337 default:
338 bfa_trc(bfa, msg->mhdr.msg_id);
339 bfa_assert(0);
340 }
341}
342
343
diff --git a/drivers/scsi/bfa/bfa_uf_priv.h b/drivers/scsi/bfa/bfa_uf_priv.h
deleted file mode 100644
index bcb490f834f3..000000000000
--- a/drivers/scsi/bfa/bfa_uf_priv.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_UF_PRIV_H__
18#define __BFA_UF_PRIV_H__
19
20#include <cs/bfa_sm.h>
21#include <bfa_svc.h>
22#include <bfi/bfi_uf.h>
23
24#define BFA_UF_MIN (4)
25
26struct bfa_uf_mod_s {
27 struct bfa_s *bfa; /* back pointer to BFA */
28 struct bfa_uf_s *uf_list; /* array of UFs */
29 u16 num_ufs; /* num unsolicited rx frames */
30 struct list_head uf_free_q; /* free UFs */
31 struct list_head uf_posted_q; /* UFs posted to IOC */
32 struct bfa_uf_buf_s *uf_pbs_kva; /* list UF bufs request pld */
33 u64 uf_pbs_pa; /* phy addr for UF bufs */
34 struct bfi_uf_buf_post_s *uf_buf_posts;
35 /* pre-built UF post msgs */
36 bfa_cb_uf_recv_t ufrecv; /* uf recv handler function */
37 void *cbarg; /* uf receive handler arg */
38};
39
40#define BFA_UF_MOD(__bfa) (&(__bfa)->modules.uf_mod)
41
42#define ufm_pbs_pa(_ufmod, _uftag) \
43 ((_ufmod)->uf_pbs_pa + sizeof(struct bfa_uf_buf_s) * (_uftag))
44
45void bfa_uf_isr(struct bfa_s *bfa, struct bfi_msg_s *msg);
46
47#endif /* __BFA_UF_PRIV_H__ */
diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index ca04cc9d332f..59b5e9b61d71 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,49 +15,74 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18/** 18/*
19 * bfad.c Linux driver PCI interface module. 19 * bfad.c Linux driver PCI interface module.
20 */ 20 */
21
22#include <linux/slab.h>
23#include <linux/module.h> 21#include <linux/module.h>
24#include <linux/kthread.h> 22#include <linux/kthread.h>
23#include <linux/errno.h>
24#include <linux/sched.h>
25#include <linux/init.h>
26#include <linux/fs.h>
27#include <linux/pci.h>
28#include <linux/firmware.h>
29#include <asm/uaccess.h>
30#include <asm/fcntl.h>
31
25#include "bfad_drv.h" 32#include "bfad_drv.h"
26#include "bfad_im.h" 33#include "bfad_im.h"
27#include "bfad_tm.h" 34#include "bfa_fcs.h"
28#include "bfad_ipfc.h" 35#include "bfa_defs.h"
29#include "bfad_trcmod.h" 36#include "bfa.h"
30#include <fcb/bfa_fcb_vf.h>
31#include <fcb/bfa_fcb_rport.h>
32#include <fcb/bfa_fcb_port.h>
33#include <fcb/bfa_fcb.h>
34 37
35BFA_TRC_FILE(LDRV, BFAD); 38BFA_TRC_FILE(LDRV, BFAD);
36DEFINE_MUTEX(bfad_mutex); 39DEFINE_MUTEX(bfad_mutex);
37LIST_HEAD(bfad_list); 40LIST_HEAD(bfad_list);
38static int bfad_inst; 41
39int bfad_supported_fc4s; 42static int bfad_inst;
40 43static int num_sgpgs_parm;
41static char *host_name; 44int supported_fc4s;
42static char *os_name; 45char *host_name, *os_name, *os_patch;
43static char *os_patch; 46int num_rports, num_ios, num_tms;
44static int num_rports; 47int num_fcxps, num_ufbufs;
45static int num_ios; 48int reqq_size, rspq_size, num_sgpgs;
46static int num_tms; 49int rport_del_timeout = BFA_FCS_RPORT_DEF_DEL_TIMEOUT;
47static int num_fcxps; 50int bfa_lun_queue_depth = BFAD_LUN_QUEUE_DEPTH;
48static int num_ufbufs; 51int bfa_io_max_sge = BFAD_IO_MAX_SGE;
49static int reqq_size; 52int bfa_log_level = 3; /* WARNING log level */
50static int rspq_size; 53int ioc_auto_recover = BFA_TRUE;
51static int num_sgpgs; 54int bfa_linkup_delay = -1;
52static int rport_del_timeout = BFA_FCS_RPORT_DEF_DEL_TIMEOUT; 55int fdmi_enable = BFA_TRUE;
53static int bfa_io_max_sge = BFAD_IO_MAX_SGE; 56int pcie_max_read_reqsz;
54static int log_level = BFA_LOG_WARNING;
55static int ioc_auto_recover = BFA_TRUE;
56static int ipfc_enable = BFA_FALSE;
57static int fdmi_enable = BFA_TRUE;
58int bfa_lun_queue_depth = BFAD_LUN_QUEUE_DEPTH;
59int bfa_linkup_delay = -1;
60int bfa_debugfs_enable = 1; 57int bfa_debugfs_enable = 1;
58int msix_disable_cb = 0, msix_disable_ct = 0;
59
60/* Firmware releated */
61u32 bfi_image_ct_fc_size, bfi_image_ct_cna_size, bfi_image_cb_fc_size;
62u32 *bfi_image_ct_fc, *bfi_image_ct_cna, *bfi_image_cb_fc;
63
64#define BFAD_FW_FILE_CT_FC "ctfw_fc.bin"
65#define BFAD_FW_FILE_CT_CNA "ctfw_cna.bin"
66#define BFAD_FW_FILE_CB_FC "cbfw_fc.bin"
67
68static u32 *bfad_load_fwimg(struct pci_dev *pdev);
69static void bfad_free_fwimg(void);
70static void bfad_read_firmware(struct pci_dev *pdev, u32 **bfi_image,
71 u32 *bfi_image_size, char *fw_name);
72
73static const char *msix_name_ct[] = {
74 "cpe0", "cpe1", "cpe2", "cpe3",
75 "rme0", "rme1", "rme2", "rme3",
76 "ctrl" };
77
78static const char *msix_name_cb[] = {
79 "cpe0", "cpe1", "cpe2", "cpe3",
80 "rme0", "rme1", "rme2", "rme3",
81 "eemc", "elpu0", "elpu1", "epss", "mlpu" };
82
83MODULE_FIRMWARE(BFAD_FW_FILE_CT_FC);
84MODULE_FIRMWARE(BFAD_FW_FILE_CT_CNA);
85MODULE_FIRMWARE(BFAD_FW_FILE_CB_FC);
61 86
62module_param(os_name, charp, S_IRUGO | S_IWUSR); 87module_param(os_name, charp, S_IRUGO | S_IWUSR);
63MODULE_PARM_DESC(os_name, "OS name of the hba host machine"); 88MODULE_PARM_DESC(os_name, "OS name of the hba host machine");
@@ -66,8 +91,8 @@ MODULE_PARM_DESC(os_patch, "OS patch level of the hba host machine");
66module_param(host_name, charp, S_IRUGO | S_IWUSR); 91module_param(host_name, charp, S_IRUGO | S_IWUSR);
67MODULE_PARM_DESC(host_name, "Hostname of the hba host machine"); 92MODULE_PARM_DESC(host_name, "Hostname of the hba host machine");
68module_param(num_rports, int, S_IRUGO | S_IWUSR); 93module_param(num_rports, int, S_IRUGO | S_IWUSR);
69MODULE_PARM_DESC(num_rports, "Max number of rports supported per port" 94MODULE_PARM_DESC(num_rports, "Max number of rports supported per port "
70 " (physical/logical), default=1024"); 95 "(physical/logical), default=1024");
71module_param(num_ios, int, S_IRUGO | S_IWUSR); 96module_param(num_ios, int, S_IRUGO | S_IWUSR);
72MODULE_PARM_DESC(num_ios, "Max number of ioim requests, default=2000"); 97MODULE_PARM_DESC(num_ios, "Max number of ioim requests, default=2000");
73module_param(num_tms, int, S_IRUGO | S_IWUSR); 98module_param(num_tms, int, S_IRUGO | S_IWUSR);
@@ -75,123 +100,283 @@ MODULE_PARM_DESC(num_tms, "Max number of task im requests, default=128");
75module_param(num_fcxps, int, S_IRUGO | S_IWUSR); 100module_param(num_fcxps, int, S_IRUGO | S_IWUSR);
76MODULE_PARM_DESC(num_fcxps, "Max number of fcxp requests, default=64"); 101MODULE_PARM_DESC(num_fcxps, "Max number of fcxp requests, default=64");
77module_param(num_ufbufs, int, S_IRUGO | S_IWUSR); 102module_param(num_ufbufs, int, S_IRUGO | S_IWUSR);
78MODULE_PARM_DESC(num_ufbufs, "Max number of unsolicited frame buffers," 103MODULE_PARM_DESC(num_ufbufs, "Max number of unsolicited frame "
79 " default=64"); 104 "buffers, default=64");
80module_param(reqq_size, int, S_IRUGO | S_IWUSR); 105module_param(reqq_size, int, S_IRUGO | S_IWUSR);
81MODULE_PARM_DESC(reqq_size, "Max number of request queue elements," 106MODULE_PARM_DESC(reqq_size, "Max number of request queue elements, "
82 " default=256"); 107 "default=256");
83module_param(rspq_size, int, S_IRUGO | S_IWUSR); 108module_param(rspq_size, int, S_IRUGO | S_IWUSR);
84MODULE_PARM_DESC(rspq_size, "Max number of response queue elements," 109MODULE_PARM_DESC(rspq_size, "Max number of response queue elements, "
85 " default=64"); 110 "default=64");
86module_param(num_sgpgs, int, S_IRUGO | S_IWUSR); 111module_param(num_sgpgs, int, S_IRUGO | S_IWUSR);
87MODULE_PARM_DESC(num_sgpgs, "Number of scatter/gather pages, default=2048"); 112MODULE_PARM_DESC(num_sgpgs, "Number of scatter/gather pages, default=2048");
88module_param(rport_del_timeout, int, S_IRUGO | S_IWUSR); 113module_param(rport_del_timeout, int, S_IRUGO | S_IWUSR);
89MODULE_PARM_DESC(rport_del_timeout, "Rport delete timeout, default=90 secs," 114MODULE_PARM_DESC(rport_del_timeout, "Rport delete timeout, default=90 secs, "
90 " Range[>0]"); 115 "Range[>0]");
91module_param(bfa_lun_queue_depth, int, S_IRUGO | S_IWUSR); 116module_param(bfa_lun_queue_depth, int, S_IRUGO | S_IWUSR);
92MODULE_PARM_DESC(bfa_lun_queue_depth, "Lun queue depth, default=32," 117MODULE_PARM_DESC(bfa_lun_queue_depth, "Lun queue depth, default=32, Range[>0]");
93 " Range[>0]");
94module_param(bfa_io_max_sge, int, S_IRUGO | S_IWUSR); 118module_param(bfa_io_max_sge, int, S_IRUGO | S_IWUSR);
95MODULE_PARM_DESC(bfa_io_max_sge, "Max io scatter/gather elements, default=255"); 119MODULE_PARM_DESC(bfa_io_max_sge, "Max io scatter/gather elements, default=255");
96module_param(log_level, int, S_IRUGO | S_IWUSR); 120module_param(bfa_log_level, int, S_IRUGO | S_IWUSR);
97MODULE_PARM_DESC(log_level, "Driver log level, default=3," 121MODULE_PARM_DESC(bfa_log_level, "Driver log level, default=3, "
98 " Range[Critical:1|Error:2|Warning:3|Info:4]"); 122 "Range[Critical:1|Error:2|Warning:3|Info:4]");
99module_param(ioc_auto_recover, int, S_IRUGO | S_IWUSR); 123module_param(ioc_auto_recover, int, S_IRUGO | S_IWUSR);
100MODULE_PARM_DESC(ioc_auto_recover, "IOC auto recovery, default=1," 124MODULE_PARM_DESC(ioc_auto_recover, "IOC auto recovery, default=1, "
101 " Range[off:0|on:1]"); 125 "Range[off:0|on:1]");
102module_param(ipfc_enable, int, S_IRUGO | S_IWUSR);
103MODULE_PARM_DESC(ipfc_enable, "Enable IPoFC, default=0, Range[off:0|on:1]");
104module_param(bfa_linkup_delay, int, S_IRUGO | S_IWUSR); 126module_param(bfa_linkup_delay, int, S_IRUGO | S_IWUSR);
105MODULE_PARM_DESC(bfa_linkup_delay, "Link up delay, default=30 secs for boot" 127MODULE_PARM_DESC(bfa_linkup_delay, "Link up delay, default=30 secs for "
106 " port. Otherwise Range[>0]"); 128 "boot port. Otherwise 10 secs in RHEL4 & 0 for "
129 "[RHEL5, SLES10, ESX40] Range[>0]");
130module_param(msix_disable_cb, int, S_IRUGO | S_IWUSR);
131MODULE_PARM_DESC(msix_disable_cb, "Disable Message Signaled Interrupts "
132 "for Brocade-415/425/815/825 cards, default=0, "
133 " Range[false:0|true:1]");
134module_param(msix_disable_ct, int, S_IRUGO | S_IWUSR);
135MODULE_PARM_DESC(msix_disable_ct, "Disable Message Signaled Interrupts "
136 "if possible for Brocade-1010/1020/804/1007/902/1741 "
137 "cards, default=0, Range[false:0|true:1]");
107module_param(fdmi_enable, int, S_IRUGO | S_IWUSR); 138module_param(fdmi_enable, int, S_IRUGO | S_IWUSR);
108MODULE_PARM_DESC(fdmi_enable, "Enables fdmi registration, default=1," 139MODULE_PARM_DESC(fdmi_enable, "Enables fdmi registration, default=1, "
109 " Range[false:0|true:1]"); 140 "Range[false:0|true:1]");
141module_param(pcie_max_read_reqsz, int, S_IRUGO | S_IWUSR);
142MODULE_PARM_DESC(pcie_max_read_reqsz, "PCIe max read request size, default=0 "
143 "(use system setting), Range[128|256|512|1024|2048|4096]");
110module_param(bfa_debugfs_enable, int, S_IRUGO | S_IWUSR); 144module_param(bfa_debugfs_enable, int, S_IRUGO | S_IWUSR);
111MODULE_PARM_DESC(bfa_debugfs_enable, "Enables debugfs feature, default=1," 145MODULE_PARM_DESC(bfa_debugfs_enable, "Enables debugfs feature, default=1,"
112 " Range[false:0|true:1]"); 146 " Range[false:0|true:1]");
113 147
148static void
149bfad_sm_uninit(struct bfad_s *bfad, enum bfad_sm_event event);
150static void
151bfad_sm_created(struct bfad_s *bfad, enum bfad_sm_event event);
152static void
153bfad_sm_initializing(struct bfad_s *bfad, enum bfad_sm_event event);
154static void
155bfad_sm_operational(struct bfad_s *bfad, enum bfad_sm_event event);
156static void
157bfad_sm_stopping(struct bfad_s *bfad, enum bfad_sm_event event);
158static void
159bfad_sm_failed(struct bfad_s *bfad, enum bfad_sm_event event);
160static void
161bfad_sm_fcs_exit(struct bfad_s *bfad, enum bfad_sm_event event);
162
114/* 163/*
115 * Stores the module parm num_sgpgs value; 164 * Beginning state for the driver instance, awaiting the pci_probe event
116 * used to reset for bfad next instance.
117 */ 165 */
118static int num_sgpgs_parm; 166static void
167bfad_sm_uninit(struct bfad_s *bfad, enum bfad_sm_event event)
168{
169 bfa_trc(bfad, event);
170
171 switch (event) {
172 case BFAD_E_CREATE:
173 bfa_sm_set_state(bfad, bfad_sm_created);
174 bfad->bfad_tsk = kthread_create(bfad_worker, (void *) bfad,
175 "%s", "bfad_worker");
176 if (IS_ERR(bfad->bfad_tsk)) {
177 printk(KERN_INFO "bfad[%d]: Kernel thread "
178 "creation failed!\n", bfad->inst_no);
179 bfa_sm_send_event(bfad, BFAD_E_KTHREAD_CREATE_FAILED);
180 }
181 bfa_sm_send_event(bfad, BFAD_E_INIT);
182 break;
119 183
120static bfa_status_t 184 case BFAD_E_STOP:
121bfad_fc4_probe(struct bfad_s *bfad) 185 /* Ignore stop; already in uninit */
186 break;
187
188 default:
189 bfa_sm_fault(bfad, event);
190 }
191}
192
193/*
194 * Driver Instance is created, awaiting event INIT to initialize the bfad
195 */
196static void
197bfad_sm_created(struct bfad_s *bfad, enum bfad_sm_event event)
122{ 198{
123 int rc; 199 unsigned long flags;
124 200
125 rc = bfad_im_probe(bfad); 201 bfa_trc(bfad, event);
126 if (rc != BFA_STATUS_OK)
127 goto ext;
128 202
129 bfad_tm_probe(bfad); 203 switch (event) {
204 case BFAD_E_INIT:
205 bfa_sm_set_state(bfad, bfad_sm_initializing);
130 206
131 if (ipfc_enable) 207 init_completion(&bfad->comp);
132 bfad_ipfc_probe(bfad);
133 208
134 bfad->bfad_flags |= BFAD_FC4_PROBE_DONE; 209 /* Enable Interrupt and wait bfa_init completion */
135ext: 210 if (bfad_setup_intr(bfad)) {
136 return rc; 211 printk(KERN_WARNING "bfad%d: bfad_setup_intr failed\n",
212 bfad->inst_no);
213 bfa_sm_send_event(bfad, BFAD_E_INTR_INIT_FAILED);
214 break;
215 }
216
217 spin_lock_irqsave(&bfad->bfad_lock, flags);
218 bfa_iocfc_init(&bfad->bfa);
219 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
220
221 /* Set up interrupt handler for each vectors */
222 if ((bfad->bfad_flags & BFAD_MSIX_ON) &&
223 bfad_install_msix_handler(bfad)) {
224 printk(KERN_WARNING "%s: install_msix failed, bfad%d\n",
225 __func__, bfad->inst_no);
226 }
227
228 bfad_init_timer(bfad);
229
230 wait_for_completion(&bfad->comp);
231
232 if ((bfad->bfad_flags & BFAD_HAL_INIT_DONE)) {
233 bfa_sm_send_event(bfad, BFAD_E_INIT_SUCCESS);
234 } else {
235 printk(KERN_WARNING
236 "bfa %s: bfa init failed\n",
237 bfad->pci_name);
238 bfad->bfad_flags |= BFAD_HAL_INIT_FAIL;
239 bfa_sm_send_event(bfad, BFAD_E_INIT_FAILED);
240 }
241
242 break;
243
244 case BFAD_E_KTHREAD_CREATE_FAILED:
245 bfa_sm_set_state(bfad, bfad_sm_uninit);
246 break;
247
248 default:
249 bfa_sm_fault(bfad, event);
250 }
137} 251}
138 252
139static void 253static void
140bfad_fc4_probe_undo(struct bfad_s *bfad) 254bfad_sm_initializing(struct bfad_s *bfad, enum bfad_sm_event event)
141{ 255{
142 bfad_im_probe_undo(bfad); 256 int retval;
143 bfad_tm_probe_undo(bfad); 257 unsigned long flags;
144 if (ipfc_enable) 258
145 bfad_ipfc_probe_undo(bfad); 259 bfa_trc(bfad, event);
146 bfad->bfad_flags &= ~BFAD_FC4_PROBE_DONE; 260
261 switch (event) {
262 case BFAD_E_INIT_SUCCESS:
263 kthread_stop(bfad->bfad_tsk);
264 spin_lock_irqsave(&bfad->bfad_lock, flags);
265 bfad->bfad_tsk = NULL;
266 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
267
268 retval = bfad_start_ops(bfad);
269 if (retval != BFA_STATUS_OK)
270 break;
271 bfa_sm_set_state(bfad, bfad_sm_operational);
272 break;
273
274 case BFAD_E_INTR_INIT_FAILED:
275 bfa_sm_set_state(bfad, bfad_sm_uninit);
276 kthread_stop(bfad->bfad_tsk);
277 spin_lock_irqsave(&bfad->bfad_lock, flags);
278 bfad->bfad_tsk = NULL;
279 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
280 break;
281
282 case BFAD_E_INIT_FAILED:
283 bfa_sm_set_state(bfad, bfad_sm_failed);
284 break;
285 default:
286 bfa_sm_fault(bfad, event);
287 }
147} 288}
148 289
149static void 290static void
150bfad_fc4_probe_post(struct bfad_s *bfad) 291bfad_sm_failed(struct bfad_s *bfad, enum bfad_sm_event event)
151{ 292{
152 if (bfad->im) 293 int retval;
153 bfad_im_probe_post(bfad->im); 294
295 bfa_trc(bfad, event);
154 296
155 bfad_tm_probe_post(bfad); 297 switch (event) {
156 if (ipfc_enable) 298 case BFAD_E_INIT_SUCCESS:
157 bfad_ipfc_probe_post(bfad); 299 retval = bfad_start_ops(bfad);
300 if (retval != BFA_STATUS_OK)
301 break;
302 bfa_sm_set_state(bfad, bfad_sm_operational);
303 break;
304
305 case BFAD_E_STOP:
306 if (bfad->bfad_flags & BFAD_CFG_PPORT_DONE)
307 bfad_uncfg_pport(bfad);
308 if (bfad->bfad_flags & BFAD_FC4_PROBE_DONE) {
309 bfad_im_probe_undo(bfad);
310 bfad->bfad_flags &= ~BFAD_FC4_PROBE_DONE;
311 }
312 bfad_stop(bfad);
313 break;
314
315 case BFAD_E_EXIT_COMP:
316 bfa_sm_set_state(bfad, bfad_sm_uninit);
317 bfad_remove_intr(bfad);
318 del_timer_sync(&bfad->hal_tmo);
319 break;
320
321 default:
322 bfa_sm_fault(bfad, event);
323 }
158} 324}
159 325
160static bfa_status_t 326static void
161bfad_fc4_port_new(struct bfad_s *bfad, struct bfad_port_s *port, int roles) 327bfad_sm_operational(struct bfad_s *bfad, enum bfad_sm_event event)
162{ 328{
163 int rc = BFA_STATUS_FAILED; 329 bfa_trc(bfad, event);
164 330
165 if (roles & BFA_PORT_ROLE_FCP_IM) 331 switch (event) {
166 rc = bfad_im_port_new(bfad, port); 332 case BFAD_E_STOP:
167 if (rc != BFA_STATUS_OK) 333 bfa_sm_set_state(bfad, bfad_sm_fcs_exit);
168 goto ext; 334 bfad_fcs_stop(bfad);
335 break;
169 336
170 if (roles & BFA_PORT_ROLE_FCP_TM) 337 default:
171 rc = bfad_tm_port_new(bfad, port); 338 bfa_sm_fault(bfad, event);
172 if (rc != BFA_STATUS_OK) 339 }
173 goto ext; 340}
174 341
175 if ((roles & BFA_PORT_ROLE_FCP_IPFC) && ipfc_enable) 342static void
176 rc = bfad_ipfc_port_new(bfad, port, port->pvb_type); 343bfad_sm_fcs_exit(struct bfad_s *bfad, enum bfad_sm_event event)
177ext: 344{
178 return rc; 345 bfa_trc(bfad, event);
346
347 switch (event) {
348 case BFAD_E_FCS_EXIT_COMP:
349 bfa_sm_set_state(bfad, bfad_sm_stopping);
350 bfad_stop(bfad);
351 break;
352
353 default:
354 bfa_sm_fault(bfad, event);
355 }
179} 356}
180 357
181static void 358static void
182bfad_fc4_port_delete(struct bfad_s *bfad, struct bfad_port_s *port, int roles) 359bfad_sm_stopping(struct bfad_s *bfad, enum bfad_sm_event event)
183{ 360{
184 if (roles & BFA_PORT_ROLE_FCP_IM) 361 bfa_trc(bfad, event);
185 bfad_im_port_delete(bfad, port);
186 362
187 if (roles & BFA_PORT_ROLE_FCP_TM) 363 switch (event) {
188 bfad_tm_port_delete(bfad, port); 364 case BFAD_E_EXIT_COMP:
365 bfa_sm_set_state(bfad, bfad_sm_uninit);
366 bfad_remove_intr(bfad);
367 del_timer_sync(&bfad->hal_tmo);
368 bfad_im_probe_undo(bfad);
369 bfad->bfad_flags &= ~BFAD_FC4_PROBE_DONE;
370 bfad_uncfg_pport(bfad);
371 break;
189 372
190 if ((roles & BFA_PORT_ROLE_FCP_IPFC) && ipfc_enable) 373 default:
191 bfad_ipfc_port_delete(bfad, port); 374 bfa_sm_fault(bfad, event);
375 break;
376 }
192} 377}
193 378
194/** 379/*
195 * BFA callbacks 380 * BFA callbacks
196 */ 381 */
197void 382void
@@ -203,18 +388,19 @@ bfad_hcb_comp(void *arg, bfa_status_t status)
203 complete(&fcomp->comp); 388 complete(&fcomp->comp);
204} 389}
205 390
206/** 391/*
207 * bfa_init callback 392 * bfa_init callback
208 */ 393 */
209void 394void
210bfa_cb_init(void *drv, bfa_status_t init_status) 395bfa_cb_init(void *drv, bfa_status_t init_status)
211{ 396{
212 struct bfad_s *bfad = drv; 397 struct bfad_s *bfad = drv;
213 398
214 if (init_status == BFA_STATUS_OK) { 399 if (init_status == BFA_STATUS_OK) {
215 bfad->bfad_flags |= BFAD_HAL_INIT_DONE; 400 bfad->bfad_flags |= BFAD_HAL_INIT_DONE;
216 401
217 /* If BFAD_HAL_INIT_FAIL flag is set: 402 /*
403 * If BFAD_HAL_INIT_FAIL flag is set:
218 * Wake up the kernel thread to start 404 * Wake up the kernel thread to start
219 * the bfad operations after HAL init done 405 * the bfad operations after HAL init done
220 */ 406 */
@@ -227,26 +413,16 @@ bfa_cb_init(void *drv, bfa_status_t init_status)
227 complete(&bfad->comp); 413 complete(&bfad->comp);
228} 414}
229 415
230 416/*
231
232/**
233 * BFA_FCS callbacks 417 * BFA_FCS callbacks
234 */ 418 */
235static struct bfad_port_s *
236bfad_get_drv_port(struct bfad_s *bfad, struct bfad_vf_s *vf_drv,
237 struct bfad_vport_s *vp_drv)
238{
239 return (vp_drv) ? (&(vp_drv)->drv_port)
240 : ((vf_drv) ? (&(vf_drv)->base_port) : (&(bfad)->pport));
241}
242
243struct bfad_port_s * 419struct bfad_port_s *
244bfa_fcb_port_new(struct bfad_s *bfad, struct bfa_fcs_port_s *port, 420bfa_fcb_lport_new(struct bfad_s *bfad, struct bfa_fcs_lport_s *port,
245 enum bfa_port_role roles, struct bfad_vf_s *vf_drv, 421 enum bfa_lport_role roles, struct bfad_vf_s *vf_drv,
246 struct bfad_vport_s *vp_drv) 422 struct bfad_vport_s *vp_drv)
247{ 423{
248 bfa_status_t rc; 424 bfa_status_t rc;
249 struct bfad_port_s *port_drv; 425 struct bfad_port_s *port_drv;
250 426
251 if (!vp_drv && !vf_drv) { 427 if (!vp_drv && !vf_drv) {
252 port_drv = &bfad->pport; 428 port_drv = &bfad->pport;
@@ -264,82 +440,43 @@ bfa_fcb_port_new(struct bfad_s *bfad, struct bfa_fcs_port_s *port,
264 440
265 port_drv->fcs_port = port; 441 port_drv->fcs_port = port;
266 port_drv->roles = roles; 442 port_drv->roles = roles;
267 rc = bfad_fc4_port_new(bfad, port_drv, roles); 443
268 if (rc != BFA_STATUS_OK) { 444 if (roles & BFA_LPORT_ROLE_FCP_IM) {
269 bfad_fc4_port_delete(bfad, port_drv, roles); 445 rc = bfad_im_port_new(bfad, port_drv);
270 port_drv = NULL; 446 if (rc != BFA_STATUS_OK) {
447 bfad_im_port_delete(bfad, port_drv);
448 port_drv = NULL;
449 }
271 } 450 }
272 451
273 return port_drv; 452 return port_drv;
274} 453}
275 454
276void 455void
277bfa_fcb_port_delete(struct bfad_s *bfad, enum bfa_port_role roles, 456bfa_fcb_lport_delete(struct bfad_s *bfad, enum bfa_lport_role roles,
278 struct bfad_vf_s *vf_drv, struct bfad_vport_s *vp_drv) 457 struct bfad_vf_s *vf_drv, struct bfad_vport_s *vp_drv)
279{ 458{
280 struct bfad_port_s *port_drv; 459 struct bfad_port_s *port_drv;
281 460
282 /* 461 /* this will be only called from rmmod context */
283 * this will be only called from rmmod context
284 */
285 if (vp_drv && !vp_drv->comp_del) { 462 if (vp_drv && !vp_drv->comp_del) {
286 port_drv = bfad_get_drv_port(bfad, vf_drv, vp_drv); 463 port_drv = (vp_drv) ? (&(vp_drv)->drv_port) :
464 ((vf_drv) ? (&(vf_drv)->base_port) :
465 (&(bfad)->pport));
287 bfa_trc(bfad, roles); 466 bfa_trc(bfad, roles);
288 bfad_fc4_port_delete(bfad, port_drv, roles); 467 if (roles & BFA_LPORT_ROLE_FCP_IM)
289 } 468 bfad_im_port_delete(bfad, port_drv);
290}
291
292void
293bfa_fcb_port_online(struct bfad_s *bfad, enum bfa_port_role roles,
294 struct bfad_vf_s *vf_drv, struct bfad_vport_s *vp_drv)
295{
296 struct bfad_port_s *port_drv = bfad_get_drv_port(bfad, vf_drv, vp_drv);
297
298 if (roles & BFA_PORT_ROLE_FCP_IM)
299 bfad_im_port_online(bfad, port_drv);
300
301 if (roles & BFA_PORT_ROLE_FCP_TM)
302 bfad_tm_port_online(bfad, port_drv);
303
304 if ((roles & BFA_PORT_ROLE_FCP_IPFC) && ipfc_enable)
305 bfad_ipfc_port_online(bfad, port_drv);
306
307 bfad->bfad_flags |= BFAD_PORT_ONLINE;
308}
309
310void
311bfa_fcb_port_offline(struct bfad_s *bfad, enum bfa_port_role roles,
312 struct bfad_vf_s *vf_drv, struct bfad_vport_s *vp_drv)
313{
314 struct bfad_port_s *port_drv = bfad_get_drv_port(bfad, vf_drv, vp_drv);
315
316 if (roles & BFA_PORT_ROLE_FCP_IM)
317 bfad_im_port_offline(bfad, port_drv);
318
319 if (roles & BFA_PORT_ROLE_FCP_TM)
320 bfad_tm_port_offline(bfad, port_drv);
321
322 if ((roles & BFA_PORT_ROLE_FCP_IPFC) && ipfc_enable)
323 bfad_ipfc_port_offline(bfad, port_drv);
324}
325
326void
327bfa_fcb_vport_delete(struct bfad_vport_s *vport_drv)
328{
329 if (vport_drv->comp_del) {
330 complete(vport_drv->comp_del);
331 return;
332 } 469 }
333} 470}
334 471
335/** 472/*
336 * FCS RPORT alloc callback, after successful PLOGI by FCS 473 * FCS RPORT alloc callback, after successful PLOGI by FCS
337 */ 474 */
338bfa_status_t 475bfa_status_t
339bfa_fcb_rport_alloc(struct bfad_s *bfad, struct bfa_fcs_rport_s **rport, 476bfa_fcb_rport_alloc(struct bfad_s *bfad, struct bfa_fcs_rport_s **rport,
340 struct bfad_rport_s **rport_drv) 477 struct bfad_rport_s **rport_drv)
341{ 478{
342 bfa_status_t rc = BFA_STATUS_OK; 479 bfa_status_t rc = BFA_STATUS_OK;
343 480
344 *rport_drv = kzalloc(sizeof(struct bfad_rport_s), GFP_ATOMIC); 481 *rport_drv = kzalloc(sizeof(struct bfad_rport_s), GFP_ATOMIC);
345 if (*rport_drv == NULL) { 482 if (*rport_drv == NULL) {
@@ -353,36 +490,44 @@ ext:
353 return rc; 490 return rc;
354} 491}
355 492
356/** 493/*
357 * @brief
358 * FCS PBC VPORT Create 494 * FCS PBC VPORT Create
359 */ 495 */
360void 496void
361bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s pbc_vport) 497bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s pbc_vport)
362{ 498{
363 499
364 struct bfad_pcfg_s *pcfg; 500 struct bfa_lport_cfg_s port_cfg = {0};
501 struct bfad_vport_s *vport;
502 int rc;
365 503
366 pcfg = kzalloc(sizeof(struct bfad_pcfg_s), GFP_ATOMIC); 504 vport = kzalloc(sizeof(struct bfad_vport_s), GFP_KERNEL);
367 if (!pcfg) { 505 if (!vport) {
368 bfa_trc(bfad, 0); 506 bfa_trc(bfad, 0);
369 return; 507 return;
370 } 508 }
371 509
372 pcfg->port_cfg.roles = BFA_PORT_ROLE_FCP_IM; 510 vport->drv_port.bfad = bfad;
373 pcfg->port_cfg.pwwn = pbc_vport.vp_pwwn; 511 port_cfg.roles = BFA_LPORT_ROLE_FCP_IM;
374 pcfg->port_cfg.nwwn = pbc_vport.vp_nwwn; 512 port_cfg.pwwn = pbc_vport.vp_pwwn;
375 pcfg->port_cfg.preboot_vp = BFA_TRUE; 513 port_cfg.nwwn = pbc_vport.vp_nwwn;
514 port_cfg.preboot_vp = BFA_TRUE;
376 515
377 list_add_tail(&pcfg->list_entry, &bfad->pbc_pcfg_list); 516 rc = bfa_fcs_pbc_vport_create(&vport->fcs_vport, &bfad->bfa_fcs, 0,
517 &port_cfg, vport);
378 518
379 return; 519 if (rc != BFA_STATUS_OK) {
520 bfa_trc(bfad, 0);
521 return;
522 }
523
524 list_add_tail(&vport->list_entry, &bfad->pbc_vport_list);
380} 525}
381 526
382void 527void
383bfad_hal_mem_release(struct bfad_s *bfad) 528bfad_hal_mem_release(struct bfad_s *bfad)
384{ 529{
385 int i; 530 int i;
386 struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo; 531 struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo;
387 struct bfa_mem_elem_s *meminfo_elem; 532 struct bfa_mem_elem_s *meminfo_elem;
388 533
@@ -395,12 +540,12 @@ bfad_hal_mem_release(struct bfad_s *bfad)
395 break; 540 break;
396 case BFA_MEM_TYPE_DMA: 541 case BFA_MEM_TYPE_DMA:
397 dma_free_coherent(&bfad->pcidev->dev, 542 dma_free_coherent(&bfad->pcidev->dev,
398 meminfo_elem->mem_len, 543 meminfo_elem->mem_len,
399 meminfo_elem->kva, 544 meminfo_elem->kva,
400 (dma_addr_t) meminfo_elem->dma); 545 (dma_addr_t) meminfo_elem->dma);
401 break; 546 break;
402 default: 547 default:
403 bfa_assert(0); 548 WARN_ON(1);
404 break; 549 break;
405 } 550 }
406 } 551 }
@@ -434,27 +579,27 @@ bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg)
434 * otherwise, the default values will be shown as 0 in sysfs 579 * otherwise, the default values will be shown as 0 in sysfs
435 */ 580 */
436 num_rports = bfa_cfg->fwcfg.num_rports; 581 num_rports = bfa_cfg->fwcfg.num_rports;
437 num_ios = bfa_cfg->fwcfg.num_ioim_reqs; 582 num_ios = bfa_cfg->fwcfg.num_ioim_reqs;
438 num_tms = bfa_cfg->fwcfg.num_tskim_reqs; 583 num_tms = bfa_cfg->fwcfg.num_tskim_reqs;
439 num_fcxps = bfa_cfg->fwcfg.num_fcxp_reqs; 584 num_fcxps = bfa_cfg->fwcfg.num_fcxp_reqs;
440 num_ufbufs = bfa_cfg->fwcfg.num_uf_bufs; 585 num_ufbufs = bfa_cfg->fwcfg.num_uf_bufs;
441 reqq_size = bfa_cfg->drvcfg.num_reqq_elems; 586 reqq_size = bfa_cfg->drvcfg.num_reqq_elems;
442 rspq_size = bfa_cfg->drvcfg.num_rspq_elems; 587 rspq_size = bfa_cfg->drvcfg.num_rspq_elems;
443 num_sgpgs = bfa_cfg->drvcfg.num_sgpgs; 588 num_sgpgs = bfa_cfg->drvcfg.num_sgpgs;
444} 589}
445 590
446bfa_status_t 591bfa_status_t
447bfad_hal_mem_alloc(struct bfad_s *bfad) 592bfad_hal_mem_alloc(struct bfad_s *bfad)
448{ 593{
594 int i;
449 struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo; 595 struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo;
450 struct bfa_mem_elem_s *meminfo_elem; 596 struct bfa_mem_elem_s *meminfo_elem;
451 bfa_status_t rc = BFA_STATUS_OK; 597 dma_addr_t phys_addr;
452 dma_addr_t phys_addr; 598 void *kva;
453 int retry_count = 0; 599 bfa_status_t rc = BFA_STATUS_OK;
454 int reset_value = 1; 600 int retry_count = 0;
455 int min_num_sgpgs = 512; 601 int reset_value = 1;
456 void *kva; 602 int min_num_sgpgs = 512;
457 int i;
458 603
459 bfa_cfg_get_default(&bfad->ioc_cfg); 604 bfa_cfg_get_default(&bfad->ioc_cfg);
460 605
@@ -478,8 +623,7 @@ retry:
478 break; 623 break;
479 case BFA_MEM_TYPE_DMA: 624 case BFA_MEM_TYPE_DMA:
480 kva = dma_alloc_coherent(&bfad->pcidev->dev, 625 kva = dma_alloc_coherent(&bfad->pcidev->dev,
481 meminfo_elem->mem_len, 626 meminfo_elem->mem_len, &phys_addr, GFP_KERNEL);
482 &phys_addr, GFP_KERNEL);
483 if (kva == NULL) { 627 if (kva == NULL) {
484 bfad_hal_mem_release(bfad); 628 bfad_hal_mem_release(bfad);
485 /* 629 /*
@@ -487,14 +631,14 @@ retry:
487 * num_sgpages try with half the value. 631 * num_sgpages try with half the value.
488 */ 632 */
489 if (num_sgpgs > min_num_sgpgs) { 633 if (num_sgpgs > min_num_sgpgs) {
490 printk(KERN_INFO "bfad[%d]: memory" 634 printk(KERN_INFO
491 " allocation failed with" 635 "bfad[%d]: memory allocation failed"
492 " num_sgpgs: %d\n", 636 " with num_sgpgs: %d\n",
493 bfad->inst_no, num_sgpgs); 637 bfad->inst_no, num_sgpgs);
494 nextLowerInt(&num_sgpgs); 638 nextLowerInt(&num_sgpgs);
495 printk(KERN_INFO "bfad[%d]: trying to" 639 printk(KERN_INFO
496 " allocate memory with" 640 "bfad[%d]: trying to allocate memory"
497 " num_sgpgs: %d\n", 641 " with num_sgpgs: %d\n",
498 bfad->inst_no, num_sgpgs); 642 bfad->inst_no, num_sgpgs);
499 retry_count++; 643 retry_count++;
500 goto retry; 644 goto retry;
@@ -531,16 +675,16 @@ ext:
531 return rc; 675 return rc;
532} 676}
533 677
534/** 678/*
535 * Create a vport under a vf. 679 * Create a vport under a vf.
536 */ 680 */
537bfa_status_t 681bfa_status_t
538bfad_vport_create(struct bfad_s *bfad, u16 vf_id, 682bfad_vport_create(struct bfad_s *bfad, u16 vf_id,
539 struct bfa_port_cfg_s *port_cfg, struct device *dev) 683 struct bfa_lport_cfg_s *port_cfg, struct device *dev)
540{ 684{
541 struct bfad_vport_s *vport; 685 struct bfad_vport_s *vport;
542 int rc = BFA_STATUS_OK; 686 int rc = BFA_STATUS_OK;
543 unsigned long flags; 687 unsigned long flags;
544 struct completion fcomp; 688 struct completion fcomp;
545 689
546 vport = kzalloc(sizeof(struct bfad_vport_s), GFP_KERNEL); 690 vport = kzalloc(sizeof(struct bfad_vport_s), GFP_KERNEL);
@@ -551,18 +695,14 @@ bfad_vport_create(struct bfad_s *bfad, u16 vf_id,
551 695
552 vport->drv_port.bfad = bfad; 696 vport->drv_port.bfad = bfad;
553 spin_lock_irqsave(&bfad->bfad_lock, flags); 697 spin_lock_irqsave(&bfad->bfad_lock, flags);
554 if (port_cfg->preboot_vp == BFA_TRUE) 698 rc = bfa_fcs_vport_create(&vport->fcs_vport, &bfad->bfa_fcs, vf_id,
555 rc = bfa_fcs_pbc_vport_create(&vport->fcs_vport, 699 port_cfg, vport);
556 &bfad->bfa_fcs, vf_id, port_cfg, vport);
557 else
558 rc = bfa_fcs_vport_create(&vport->fcs_vport,
559 &bfad->bfa_fcs, vf_id, port_cfg, vport);
560 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 700 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
561 701
562 if (rc != BFA_STATUS_OK) 702 if (rc != BFA_STATUS_OK)
563 goto ext_free_vport; 703 goto ext_free_vport;
564 704
565 if (port_cfg->roles & BFA_PORT_ROLE_FCP_IM) { 705 if (port_cfg->roles & BFA_LPORT_ROLE_FCP_IM) {
566 rc = bfad_im_scsi_host_alloc(bfad, vport->drv_port.im_port, 706 rc = bfad_im_scsi_host_alloc(bfad, vport->drv_port.im_port,
567 dev); 707 dev);
568 if (rc != BFA_STATUS_OK) 708 if (rc != BFA_STATUS_OK)
@@ -588,40 +728,16 @@ ext:
588 return rc; 728 return rc;
589} 729}
590 730
591/**
592 * Create a vf and its base vport implicitely.
593 */
594bfa_status_t
595bfad_vf_create(struct bfad_s *bfad, u16 vf_id,
596 struct bfa_port_cfg_s *port_cfg)
597{
598 struct bfad_vf_s *vf;
599 int rc = BFA_STATUS_OK;
600
601 vf = kzalloc(sizeof(struct bfad_vf_s), GFP_KERNEL);
602 if (!vf) {
603 rc = BFA_STATUS_FAILED;
604 goto ext;
605 }
606
607 rc = bfa_fcs_vf_create(&vf->fcs_vf, &bfad->bfa_fcs, vf_id, port_cfg,
608 vf);
609 if (rc != BFA_STATUS_OK)
610 kfree(vf);
611ext:
612 return rc;
613}
614
615void 731void
616bfad_bfa_tmo(unsigned long data) 732bfad_bfa_tmo(unsigned long data)
617{ 733{
618 struct bfad_s *bfad = (struct bfad_s *)data; 734 struct bfad_s *bfad = (struct bfad_s *) data;
619 unsigned long flags; 735 unsigned long flags;
620 struct list_head doneq; 736 struct list_head doneq;
621 737
622 spin_lock_irqsave(&bfad->bfad_lock, flags); 738 spin_lock_irqsave(&bfad->bfad_lock, flags);
623 739
624 bfa_timer_tick(&bfad->bfa); 740 bfa_timer_beat(&bfad->bfa.timer_mod);
625 741
626 bfa_comp_deq(&bfad->bfa, &doneq); 742 bfa_comp_deq(&bfad->bfa, &doneq);
627 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 743 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
@@ -633,7 +749,8 @@ bfad_bfa_tmo(unsigned long data)
633 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 749 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
634 } 750 }
635 751
636 mod_timer(&bfad->hal_tmo, jiffies + msecs_to_jiffies(BFA_TIMER_FREQ)); 752 mod_timer(&bfad->hal_tmo,
753 jiffies + msecs_to_jiffies(BFA_TIMER_FREQ));
637} 754}
638 755
639void 756void
@@ -643,16 +760,17 @@ bfad_init_timer(struct bfad_s *bfad)
643 bfad->hal_tmo.function = bfad_bfa_tmo; 760 bfad->hal_tmo.function = bfad_bfa_tmo;
644 bfad->hal_tmo.data = (unsigned long)bfad; 761 bfad->hal_tmo.data = (unsigned long)bfad;
645 762
646 mod_timer(&bfad->hal_tmo, jiffies + msecs_to_jiffies(BFA_TIMER_FREQ)); 763 mod_timer(&bfad->hal_tmo,
764 jiffies + msecs_to_jiffies(BFA_TIMER_FREQ));
647} 765}
648 766
649int 767int
650bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad) 768bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
651{ 769{
652 int rc = -ENODEV; 770 int rc = -ENODEV;
653 771
654 if (pci_enable_device(pdev)) { 772 if (pci_enable_device(pdev)) {
655 BFA_PRINTF(BFA_ERR, "pci_enable_device fail %p\n", pdev); 773 printk(KERN_ERR "pci_enable_device fail %p\n", pdev);
656 goto out; 774 goto out;
657 } 775 }
658 776
@@ -664,14 +782,14 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
664 782
665 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0) 783 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0)
666 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) { 784 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0) {
667 BFA_PRINTF(BFA_ERR, "pci_set_dma_mask fail %p\n", pdev); 785 printk(KERN_ERR "pci_set_dma_mask fail %p\n", pdev);
668 goto out_release_region; 786 goto out_release_region;
669 } 787 }
670 788
671 bfad->pci_bar0_kva = pci_iomap(pdev, 0, pci_resource_len(pdev, 0)); 789 bfad->pci_bar0_kva = pci_iomap(pdev, 0, pci_resource_len(pdev, 0));
672 790
673 if (bfad->pci_bar0_kva == NULL) { 791 if (bfad->pci_bar0_kva == NULL) {
674 BFA_PRINTF(BFA_ERR, "Fail to map bar0\n"); 792 printk(KERN_ERR "Fail to map bar0\n");
675 goto out_release_region; 793 goto out_release_region;
676 } 794 }
677 795
@@ -688,6 +806,54 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
688 bfad->pci_attr.pcifn = PCI_FUNC(pdev->devfn); 806 bfad->pci_attr.pcifn = PCI_FUNC(pdev->devfn);
689 807
690 bfad->pcidev = pdev; 808 bfad->pcidev = pdev;
809
810 /* Adjust PCIe Maximum Read Request Size */
811 if (pcie_max_read_reqsz > 0) {
812 int pcie_cap_reg;
813 u16 pcie_dev_ctl;
814 u16 mask = 0xffff;
815
816 switch (pcie_max_read_reqsz) {
817 case 128:
818 mask = 0x0;
819 break;
820 case 256:
821 mask = 0x1000;
822 break;
823 case 512:
824 mask = 0x2000;
825 break;
826 case 1024:
827 mask = 0x3000;
828 break;
829 case 2048:
830 mask = 0x4000;
831 break;
832 case 4096:
833 mask = 0x5000;
834 break;
835 default:
836 break;
837 }
838
839 pcie_cap_reg = pci_find_capability(pdev, PCI_CAP_ID_EXP);
840 if (mask != 0xffff && pcie_cap_reg) {
841 pcie_cap_reg += 0x08;
842 pci_read_config_word(pdev, pcie_cap_reg, &pcie_dev_ctl);
843 if ((pcie_dev_ctl & 0x7000) != mask) {
844 printk(KERN_WARNING "BFA[%s]: "
845 "pcie_max_read_request_size is %d, "
846 "reset to %d\n", bfad->pci_name,
847 (1 << ((pcie_dev_ctl & 0x7000) >> 12)) << 7,
848 pcie_max_read_reqsz);
849
850 pcie_dev_ctl &= ~0x7000;
851 pci_write_config_word(pdev, pcie_cap_reg,
852 pcie_dev_ctl | mask);
853 }
854 }
855 }
856
691 return 0; 857 return 0;
692 858
693out_release_region: 859out_release_region:
@@ -707,28 +873,11 @@ bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad)
707 pci_set_drvdata(pdev, NULL); 873 pci_set_drvdata(pdev, NULL);
708} 874}
709 875
710void
711bfad_fcs_port_cfg(struct bfad_s *bfad)
712{
713 struct bfa_port_cfg_s port_cfg;
714 struct bfa_pport_attr_s attr;
715 char symname[BFA_SYMNAME_MAXLEN];
716
717 sprintf(symname, "%s-%d", BFAD_DRIVER_NAME, bfad->inst_no);
718 memcpy(port_cfg.sym_name.symname, symname, strlen(symname));
719 bfa_fcport_get_attr(&bfad->bfa, &attr);
720 port_cfg.nwwn = attr.nwwn;
721 port_cfg.pwwn = attr.pwwn;
722
723 bfa_fcs_cfg_base_port(&bfad->bfa_fcs, &port_cfg);
724}
725
726bfa_status_t 876bfa_status_t
727bfad_drv_init(struct bfad_s *bfad) 877bfad_drv_init(struct bfad_s *bfad)
728{ 878{
729 bfa_status_t rc; 879 bfa_status_t rc;
730 unsigned long flags; 880 unsigned long flags;
731 struct bfa_fcs_driver_info_s driver_info;
732 881
733 bfad->cfg_data.rport_del_timeout = rport_del_timeout; 882 bfad->cfg_data.rport_del_timeout = rport_del_timeout;
734 bfad->cfg_data.lun_queue_depth = bfa_lun_queue_depth; 883 bfad->cfg_data.lun_queue_depth = bfa_lun_queue_depth;
@@ -740,16 +889,13 @@ bfad_drv_init(struct bfad_s *bfad)
740 printk(KERN_WARNING "bfad%d bfad_hal_mem_alloc failure\n", 889 printk(KERN_WARNING "bfad%d bfad_hal_mem_alloc failure\n",
741 bfad->inst_no); 890 bfad->inst_no);
742 printk(KERN_WARNING 891 printk(KERN_WARNING
743 "Not enough memory to attach all Brocade HBA ports," 892 "Not enough memory to attach all Brocade HBA ports, %s",
744 " System may need more memory.\n"); 893 "System may need more memory.\n");
745 goto out_hal_mem_alloc_failure; 894 goto out_hal_mem_alloc_failure;
746 } 895 }
747 896
748 bfa_init_log(&bfad->bfa, bfad->logmod); 897 bfad->bfa.trcmod = bfad->trcmod;
749 bfa_init_trc(&bfad->bfa, bfad->trcmod); 898 bfad->bfa.plog = &bfad->plog_buf;
750 bfa_init_aen(&bfad->bfa, bfad->aen);
751 memset(bfad->file_map, 0, sizeof(bfad->file_map));
752 bfa_init_plog(&bfad->bfa, &bfad->plog_buf);
753 bfa_plog_init(&bfad->plog_buf); 899 bfa_plog_init(&bfad->plog_buf);
754 bfa_plog_str(&bfad->plog_buf, BFA_PL_MID_DRVR, BFA_PL_EID_DRIVER_START, 900 bfa_plog_str(&bfad->plog_buf, BFA_PL_MID_DRVR, BFA_PL_EID_DRIVER_START,
755 0, "Driver Attach"); 901 0, "Driver Attach");
@@ -757,77 +903,17 @@ bfad_drv_init(struct bfad_s *bfad)
757 bfa_attach(&bfad->bfa, bfad, &bfad->ioc_cfg, &bfad->meminfo, 903 bfa_attach(&bfad->bfa, bfad, &bfad->ioc_cfg, &bfad->meminfo,
758 &bfad->hal_pcidev); 904 &bfad->hal_pcidev);
759 905
760 init_completion(&bfad->comp); 906 /* FCS INIT */
761
762 /*
763 * Enable Interrupt and wait bfa_init completion
764 */
765 if (bfad_setup_intr(bfad)) {
766 printk(KERN_WARNING "bfad%d: bfad_setup_intr failed\n",
767 bfad->inst_no);
768 goto out_setup_intr_failure;
769 }
770
771 spin_lock_irqsave(&bfad->bfad_lock, flags); 907 spin_lock_irqsave(&bfad->bfad_lock, flags);
772 bfa_init(&bfad->bfa); 908 bfad->bfa_fcs.trcmod = bfad->trcmod;
773 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
774
775 /*
776 * Set up interrupt handler for each vectors
777 */
778 if ((bfad->bfad_flags & BFAD_MSIX_ON)
779 && bfad_install_msix_handler(bfad)) {
780 printk(KERN_WARNING "%s: install_msix failed, bfad%d\n",
781 __func__, bfad->inst_no);
782 }
783
784 bfad_init_timer(bfad);
785
786 wait_for_completion(&bfad->comp);
787
788 memset(&driver_info, 0, sizeof(driver_info));
789 strncpy(driver_info.version, BFAD_DRIVER_VERSION,
790 sizeof(driver_info.version) - 1);
791 __kernel_param_lock();
792 if (host_name)
793 strncpy(driver_info.host_machine_name, host_name,
794 sizeof(driver_info.host_machine_name) - 1);
795 if (os_name)
796 strncpy(driver_info.host_os_name, os_name,
797 sizeof(driver_info.host_os_name) - 1);
798 if (os_patch)
799 strncpy(driver_info.host_os_patch, os_patch,
800 sizeof(driver_info.host_os_patch) - 1);
801 __kernel_param_unlock();
802
803 strncpy(driver_info.os_device_name, bfad->pci_name,
804 sizeof(driver_info.os_device_name - 1));
805
806 /*
807 * FCS INIT
808 */
809 spin_lock_irqsave(&bfad->bfad_lock, flags);
810 bfa_fcs_log_init(&bfad->bfa_fcs, bfad->logmod);
811 bfa_fcs_trc_init(&bfad->bfa_fcs, bfad->trcmod);
812 bfa_fcs_aen_init(&bfad->bfa_fcs, bfad->aen);
813 bfa_fcs_attach(&bfad->bfa_fcs, &bfad->bfa, bfad, BFA_FALSE); 909 bfa_fcs_attach(&bfad->bfa_fcs, &bfad->bfa, bfad, BFA_FALSE);
814 910 bfad->bfa_fcs.fdmi_enabled = fdmi_enable;
815 /* Do FCS init only when HAL init is done */
816 if ((bfad->bfad_flags & BFAD_HAL_INIT_DONE)) {
817 bfa_fcs_init(&bfad->bfa_fcs);
818 bfad->bfad_flags |= BFAD_FCS_INIT_DONE;
819 }
820
821 bfa_fcs_driver_info_init(&bfad->bfa_fcs, &driver_info);
822 bfa_fcs_set_fdmi_param(&bfad->bfa_fcs, fdmi_enable);
823 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 911 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
824 912
825 bfad->bfad_flags |= BFAD_DRV_INIT_DONE; 913 bfad->bfad_flags |= BFAD_DRV_INIT_DONE;
914
826 return BFA_STATUS_OK; 915 return BFA_STATUS_OK;
827 916
828out_setup_intr_failure:
829 bfa_detach(&bfad->bfa);
830 bfad_hal_mem_release(bfad);
831out_hal_mem_alloc_failure: 917out_hal_mem_alloc_failure:
832 return BFA_STATUS_FAILED; 918 return BFA_STATUS_FAILED;
833} 919}
@@ -839,7 +925,7 @@ bfad_drv_uninit(struct bfad_s *bfad)
839 925
840 spin_lock_irqsave(&bfad->bfad_lock, flags); 926 spin_lock_irqsave(&bfad->bfad_lock, flags);
841 init_completion(&bfad->comp); 927 init_completion(&bfad->comp);
842 bfa_stop(&bfad->bfa); 928 bfa_iocfc_stop(&bfad->bfa);
843 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 929 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
844 wait_for_completion(&bfad->comp); 930 wait_for_completion(&bfad->comp);
845 931
@@ -855,21 +941,22 @@ bfad_drv_uninit(struct bfad_s *bfad)
855void 941void
856bfad_drv_start(struct bfad_s *bfad) 942bfad_drv_start(struct bfad_s *bfad)
857{ 943{
858 unsigned long flags; 944 unsigned long flags;
859 945
860 spin_lock_irqsave(&bfad->bfad_lock, flags); 946 spin_lock_irqsave(&bfad->bfad_lock, flags);
861 bfa_start(&bfad->bfa); 947 bfa_iocfc_start(&bfad->bfa);
862 bfa_fcs_start(&bfad->bfa_fcs); 948 bfa_fcs_fabric_modstart(&bfad->bfa_fcs);
863 bfad->bfad_flags |= BFAD_HAL_START_DONE; 949 bfad->bfad_flags |= BFAD_HAL_START_DONE;
864 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 950 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
865 951
866 bfad_fc4_probe_post(bfad); 952 if (bfad->im)
953 flush_workqueue(bfad->im->drv_workq);
867} 954}
868 955
869void 956void
870bfad_drv_stop(struct bfad_s *bfad) 957bfad_fcs_stop(struct bfad_s *bfad)
871{ 958{
872 unsigned long flags; 959 unsigned long flags;
873 960
874 spin_lock_irqsave(&bfad->bfad_lock, flags); 961 spin_lock_irqsave(&bfad->bfad_lock, flags);
875 init_completion(&bfad->comp); 962 init_completion(&bfad->comp);
@@ -878,24 +965,32 @@ bfad_drv_stop(struct bfad_s *bfad)
878 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 965 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
879 wait_for_completion(&bfad->comp); 966 wait_for_completion(&bfad->comp);
880 967
968 bfa_sm_send_event(bfad, BFAD_E_FCS_EXIT_COMP);
969}
970
971void
972bfad_stop(struct bfad_s *bfad)
973{
974 unsigned long flags;
975
881 spin_lock_irqsave(&bfad->bfad_lock, flags); 976 spin_lock_irqsave(&bfad->bfad_lock, flags);
882 init_completion(&bfad->comp); 977 init_completion(&bfad->comp);
883 bfa_stop(&bfad->bfa); 978 bfa_iocfc_stop(&bfad->bfa);
884 bfad->bfad_flags &= ~BFAD_HAL_START_DONE; 979 bfad->bfad_flags &= ~BFAD_HAL_START_DONE;
885 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 980 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
886 wait_for_completion(&bfad->comp); 981 wait_for_completion(&bfad->comp);
982
983 bfa_sm_send_event(bfad, BFAD_E_EXIT_COMP);
887} 984}
888 985
889bfa_status_t 986bfa_status_t
890bfad_cfg_pport(struct bfad_s *bfad, enum bfa_port_role role) 987bfad_cfg_pport(struct bfad_s *bfad, enum bfa_lport_role role)
891{ 988{
892 int rc = BFA_STATUS_OK; 989 int rc = BFA_STATUS_OK;
893 990
894 /* 991 /* Allocate scsi_host for the physical port */
895 * Allocate scsi_host for the physical port 992 if ((supported_fc4s & BFA_LPORT_ROLE_FCP_IM) &&
896 */ 993 (role & BFA_LPORT_ROLE_FCP_IM)) {
897 if ((bfad_supported_fc4s & BFA_PORT_ROLE_FCP_IM)
898 && (role & BFA_PORT_ROLE_FCP_IM)) {
899 if (bfad->pport.im_port == NULL) { 994 if (bfad->pport.im_port == NULL) {
900 rc = BFA_STATUS_FAILED; 995 rc = BFA_STATUS_FAILED;
901 goto out; 996 goto out;
@@ -906,13 +1001,9 @@ bfad_cfg_pport(struct bfad_s *bfad, enum bfa_port_role role)
906 if (rc != BFA_STATUS_OK) 1001 if (rc != BFA_STATUS_OK)
907 goto out; 1002 goto out;
908 1003
909 bfad->pport.roles |= BFA_PORT_ROLE_FCP_IM; 1004 bfad->pport.roles |= BFA_LPORT_ROLE_FCP_IM;
910 } 1005 }
911 1006
912 /* Setup the debugfs node for this scsi_host */
913 if (bfa_debugfs_enable)
914 bfad_debugfs_init(&bfad->pport);
915
916 bfad->bfad_flags |= BFAD_CFG_PPORT_DONE; 1007 bfad->bfad_flags |= BFAD_CFG_PPORT_DONE;
917 1008
918out: 1009out:
@@ -922,100 +1013,112 @@ out:
922void 1013void
923bfad_uncfg_pport(struct bfad_s *bfad) 1014bfad_uncfg_pport(struct bfad_s *bfad)
924{ 1015{
925 /* Remove the debugfs node for this scsi_host */ 1016 if ((supported_fc4s & BFA_LPORT_ROLE_FCP_IM) &&
926 kfree(bfad->regdata); 1017 (bfad->pport.roles & BFA_LPORT_ROLE_FCP_IM)) {
927 bfad_debugfs_exit(&bfad->pport);
928
929 if ((bfad->pport.roles & BFA_PORT_ROLE_FCP_IPFC) && ipfc_enable) {
930 bfad_ipfc_port_delete(bfad, &bfad->pport);
931 bfad->pport.roles &= ~BFA_PORT_ROLE_FCP_IPFC;
932 }
933
934 if ((bfad_supported_fc4s & BFA_PORT_ROLE_FCP_IM)
935 && (bfad->pport.roles & BFA_PORT_ROLE_FCP_IM)) {
936 bfad_im_scsi_host_free(bfad, bfad->pport.im_port); 1018 bfad_im_scsi_host_free(bfad, bfad->pport.im_port);
937 bfad_im_port_clean(bfad->pport.im_port); 1019 bfad_im_port_clean(bfad->pport.im_port);
938 kfree(bfad->pport.im_port); 1020 kfree(bfad->pport.im_port);
939 bfad->pport.roles &= ~BFA_PORT_ROLE_FCP_IM; 1021 bfad->pport.roles &= ~BFA_LPORT_ROLE_FCP_IM;
940 } 1022 }
941 1023
942 bfad->bfad_flags &= ~BFAD_CFG_PPORT_DONE; 1024 bfad->bfad_flags &= ~BFAD_CFG_PPORT_DONE;
943} 1025}
944 1026
945void
946bfad_drv_log_level_set(struct bfad_s *bfad)
947{
948 if (log_level > BFA_LOG_INVALID && log_level <= BFA_LOG_LEVEL_MAX)
949 bfa_log_set_level_all(&bfad->log_data, log_level);
950}
951
952bfa_status_t 1027bfa_status_t
953bfad_start_ops(struct bfad_s *bfad) 1028bfad_start_ops(struct bfad_s *bfad) {
954{
955 int retval;
956 struct bfad_pcfg_s *pcfg, *pcfg_new;
957 1029
958 /* PPORT FCS config */ 1030 int retval;
959 bfad_fcs_port_cfg(bfad); 1031 unsigned long flags;
1032 struct bfad_vport_s *vport, *vport_new;
1033 struct bfa_fcs_driver_info_s driver_info;
960 1034
961 retval = bfad_cfg_pport(bfad, BFA_PORT_ROLE_FCP_IM); 1035 /* Fill the driver_info info to fcs*/
962 if (retval != BFA_STATUS_OK) 1036 memset(&driver_info, 0, sizeof(driver_info));
963 goto out_cfg_pport_failure; 1037 strncpy(driver_info.version, BFAD_DRIVER_VERSION,
1038 sizeof(driver_info.version) - 1);
1039 if (host_name)
1040 strncpy(driver_info.host_machine_name, host_name,
1041 sizeof(driver_info.host_machine_name) - 1);
1042 if (os_name)
1043 strncpy(driver_info.host_os_name, os_name,
1044 sizeof(driver_info.host_os_name) - 1);
1045 if (os_patch)
1046 strncpy(driver_info.host_os_patch, os_patch,
1047 sizeof(driver_info.host_os_patch) - 1);
964 1048
965 /* BFAD level FC4 (IM/TM/IPFC) specific resource allocation */ 1049 strncpy(driver_info.os_device_name, bfad->pci_name,
966 retval = bfad_fc4_probe(bfad); 1050 sizeof(driver_info.os_device_name - 1));
1051
1052 /* FCS INIT */
1053 spin_lock_irqsave(&bfad->bfad_lock, flags);
1054 bfa_fcs_driver_info_init(&bfad->bfa_fcs, &driver_info);
1055 bfa_fcs_init(&bfad->bfa_fcs);
1056 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1057
1058 retval = bfad_cfg_pport(bfad, BFA_LPORT_ROLE_FCP_IM);
967 if (retval != BFA_STATUS_OK) { 1059 if (retval != BFA_STATUS_OK) {
968 printk(KERN_WARNING "bfad_fc4_probe failed\n"); 1060 if (bfa_sm_cmp_state(bfad, bfad_sm_initializing))
969 goto out_fc4_probe_failure; 1061 bfa_sm_set_state(bfad, bfad_sm_failed);
1062 bfad_stop(bfad);
1063 return BFA_STATUS_FAILED;
970 } 1064 }
971 1065
1066 /* BFAD level FC4 IM specific resource allocation */
1067 retval = bfad_im_probe(bfad);
1068 if (retval != BFA_STATUS_OK) {
1069 printk(KERN_WARNING "bfad_im_probe failed\n");
1070 if (bfa_sm_cmp_state(bfad, bfad_sm_initializing))
1071 bfa_sm_set_state(bfad, bfad_sm_failed);
1072 bfad_im_probe_undo(bfad);
1073 bfad->bfad_flags &= ~BFAD_FC4_PROBE_DONE;
1074 bfad_uncfg_pport(bfad);
1075 bfad_stop(bfad);
1076 return BFA_STATUS_FAILED;
1077 } else
1078 bfad->bfad_flags |= BFAD_FC4_PROBE_DONE;
1079
972 bfad_drv_start(bfad); 1080 bfad_drv_start(bfad);
973 1081
974 /* pbc vport creation */ 1082 /* Complete pbc vport create */
975 list_for_each_entry_safe(pcfg, pcfg_new, &bfad->pbc_pcfg_list, 1083 list_for_each_entry_safe(vport, vport_new, &bfad->pbc_vport_list,
976 list_entry) { 1084 list_entry) {
977 struct fc_vport_identifiers vid; 1085 struct fc_vport_identifiers vid;
978 struct fc_vport *fc_vport; 1086 struct fc_vport *fc_vport;
1087 char pwwn_buf[BFA_STRING_32];
979 1088
980 memset(&vid, 0, sizeof(vid)); 1089 memset(&vid, 0, sizeof(vid));
981 vid.roles = FC_PORT_ROLE_FCP_INITIATOR; 1090 vid.roles = FC_PORT_ROLE_FCP_INITIATOR;
982 vid.vport_type = FC_PORTTYPE_NPIV; 1091 vid.vport_type = FC_PORTTYPE_NPIV;
983 vid.disable = false; 1092 vid.disable = false;
984 vid.node_name = wwn_to_u64((u8 *)&pcfg->port_cfg.nwwn); 1093 vid.node_name = wwn_to_u64((u8 *)
985 vid.port_name = wwn_to_u64((u8 *)&pcfg->port_cfg.pwwn); 1094 (&((vport->fcs_vport).lport.port_cfg.nwwn)));
1095 vid.port_name = wwn_to_u64((u8 *)
1096 (&((vport->fcs_vport).lport.port_cfg.pwwn)));
986 fc_vport = fc_vport_create(bfad->pport.im_port->shost, 0, &vid); 1097 fc_vport = fc_vport_create(bfad->pport.im_port->shost, 0, &vid);
987 if (!fc_vport) 1098 if (!fc_vport) {
1099 wwn2str(pwwn_buf, vid.port_name);
988 printk(KERN_WARNING "bfad%d: failed to create pbc vport" 1100 printk(KERN_WARNING "bfad%d: failed to create pbc vport"
989 " %llx\n", bfad->inst_no, vid.port_name); 1101 " %s\n", bfad->inst_no, pwwn_buf);
990 list_del(&pcfg->list_entry); 1102 }
991 kfree(pcfg); 1103 list_del(&vport->list_entry);
992 1104 kfree(vport);
993 } 1105 }
994 1106
995 /* 1107 /*
996 * If bfa_linkup_delay is set to -1 default; try to retrive the 1108 * If bfa_linkup_delay is set to -1 default; try to retrive the
997 * value using the bfad_os_get_linkup_delay(); else use the 1109 * value using the bfad_get_linkup_delay(); else use the
998 * passed in module param value as the bfa_linkup_delay. 1110 * passed in module param value as the bfa_linkup_delay.
999 */ 1111 */
1000 if (bfa_linkup_delay < 0) { 1112 if (bfa_linkup_delay < 0) {
1001 1113 bfa_linkup_delay = bfad_get_linkup_delay(bfad);
1002 bfa_linkup_delay = bfad_os_get_linkup_delay(bfad); 1114 bfad_rport_online_wait(bfad);
1003 bfad_os_rport_online_wait(bfad);
1004 bfa_linkup_delay = -1; 1115 bfa_linkup_delay = -1;
1116 } else
1117 bfad_rport_online_wait(bfad);
1005 1118
1006 } else { 1119 BFA_LOG(KERN_INFO, bfad, bfa_log_level, "bfa device claimed\n");
1007 bfad_os_rport_online_wait(bfad);
1008 }
1009
1010 bfa_log(bfad->logmod, BFA_LOG_LINUX_DEVICE_CLAIMED, bfad->pci_name);
1011 1120
1012 return BFA_STATUS_OK; 1121 return BFA_STATUS_OK;
1013
1014out_fc4_probe_failure:
1015 bfad_fc4_probe_undo(bfad);
1016 bfad_uncfg_pport(bfad);
1017out_cfg_pport_failure:
1018 return BFA_STATUS_FAILED;
1019} 1122}
1020 1123
1021int 1124int
@@ -1028,18 +1131,8 @@ bfad_worker(void *ptr)
1028 1131
1029 while (!kthread_should_stop()) { 1132 while (!kthread_should_stop()) {
1030 1133
1031 /* Check if the FCS init is done from bfad_drv_init; 1134 /* Send event BFAD_E_INIT_SUCCESS */
1032 * if not done do FCS init and set the flag. 1135 bfa_sm_send_event(bfad, BFAD_E_INIT_SUCCESS);
1033 */
1034 if (!(bfad->bfad_flags & BFAD_FCS_INIT_DONE)) {
1035 spin_lock_irqsave(&bfad->bfad_lock, flags);
1036 bfa_fcs_init(&bfad->bfa_fcs);
1037 bfad->bfad_flags |= BFAD_FCS_INIT_DONE;
1038 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1039 }
1040
1041 /* Start the bfad operations after HAL init done */
1042 bfad_start_ops(bfad);
1043 1136
1044 spin_lock_irqsave(&bfad->bfad_lock, flags); 1137 spin_lock_irqsave(&bfad->bfad_lock, flags);
1045 bfad->bfad_tsk = NULL; 1138 bfad->bfad_tsk = NULL;
@@ -1051,28 +1144,212 @@ bfad_worker(void *ptr)
1051 return 0; 1144 return 0;
1052} 1145}
1053 1146
1054 /* 1147/*
1055 * PCI_entry PCI driver entries * { 1148 * BFA driver interrupt functions
1056 */ 1149 */
1150irqreturn_t
1151bfad_intx(int irq, void *dev_id)
1152{
1153 struct bfad_s *bfad = dev_id;
1154 struct list_head doneq;
1155 unsigned long flags;
1156 bfa_boolean_t rc;
1157
1158 spin_lock_irqsave(&bfad->bfad_lock, flags);
1159 rc = bfa_intx(&bfad->bfa);
1160 if (!rc) {
1161 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1162 return IRQ_NONE;
1163 }
1164
1165 bfa_comp_deq(&bfad->bfa, &doneq);
1166 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1167
1168 if (!list_empty(&doneq)) {
1169 bfa_comp_process(&bfad->bfa, &doneq);
1170
1171 spin_lock_irqsave(&bfad->bfad_lock, flags);
1172 bfa_comp_free(&bfad->bfa, &doneq);
1173 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1174 }
1175
1176 return IRQ_HANDLED;
1177
1178}
1179
1180static irqreturn_t
1181bfad_msix(int irq, void *dev_id)
1182{
1183 struct bfad_msix_s *vec = dev_id;
1184 struct bfad_s *bfad = vec->bfad;
1185 struct list_head doneq;
1186 unsigned long flags;
1187
1188 spin_lock_irqsave(&bfad->bfad_lock, flags);
1189
1190 bfa_msix(&bfad->bfa, vec->msix.entry);
1191 bfa_comp_deq(&bfad->bfa, &doneq);
1192 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1193
1194 if (!list_empty(&doneq)) {
1195 bfa_comp_process(&bfad->bfa, &doneq);
1196
1197 spin_lock_irqsave(&bfad->bfad_lock, flags);
1198 bfa_comp_free(&bfad->bfa, &doneq);
1199 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1200 }
1201
1202 return IRQ_HANDLED;
1203}
1204
1205/*
1206 * Initialize the MSIX entry table.
1207 */
1208static void
1209bfad_init_msix_entry(struct bfad_s *bfad, struct msix_entry *msix_entries,
1210 int mask, int max_bit)
1211{
1212 int i;
1213 int match = 0x00000001;
1214
1215 for (i = 0, bfad->nvec = 0; i < MAX_MSIX_ENTRY; i++) {
1216 if (mask & match) {
1217 bfad->msix_tab[bfad->nvec].msix.entry = i;
1218 bfad->msix_tab[bfad->nvec].bfad = bfad;
1219 msix_entries[bfad->nvec].entry = i;
1220 bfad->nvec++;
1221 }
1222
1223 match <<= 1;
1224 }
1225
1226}
1227
1228int
1229bfad_install_msix_handler(struct bfad_s *bfad)
1230{
1231 int i, error = 0;
1232
1233 for (i = 0; i < bfad->nvec; i++) {
1234 sprintf(bfad->msix_tab[i].name, "bfa-%s-%s",
1235 bfad->pci_name,
1236 ((bfa_asic_id_ct(bfad->hal_pcidev.device_id)) ?
1237 msix_name_ct[i] : msix_name_cb[i]));
1238
1239 error = request_irq(bfad->msix_tab[i].msix.vector,
1240 (irq_handler_t) bfad_msix, 0,
1241 bfad->msix_tab[i].name, &bfad->msix_tab[i]);
1242 bfa_trc(bfad, i);
1243 bfa_trc(bfad, bfad->msix_tab[i].msix.vector);
1244 if (error) {
1245 int j;
1246
1247 for (j = 0; j < i; j++)
1248 free_irq(bfad->msix_tab[j].msix.vector,
1249 &bfad->msix_tab[j]);
1250
1251 return 1;
1252 }
1253 }
1254
1255 return 0;
1256}
1257
1258/*
1259 * Setup MSIX based interrupt.
1260 */
1261int
1262bfad_setup_intr(struct bfad_s *bfad)
1263{
1264 int error = 0;
1265 u32 mask = 0, i, num_bit = 0, max_bit = 0;
1266 struct msix_entry msix_entries[MAX_MSIX_ENTRY];
1267 struct pci_dev *pdev = bfad->pcidev;
1268
1269 /* Call BFA to get the msix map for this PCI function. */
1270 bfa_msix_getvecs(&bfad->bfa, &mask, &num_bit, &max_bit);
1271
1272 /* Set up the msix entry table */
1273 bfad_init_msix_entry(bfad, msix_entries, mask, max_bit);
1274
1275 if ((bfa_asic_id_ct(pdev->device) && !msix_disable_ct) ||
1276 (!bfa_asic_id_ct(pdev->device) && !msix_disable_cb)) {
1277
1278 error = pci_enable_msix(bfad->pcidev, msix_entries, bfad->nvec);
1279 if (error) {
1280 /*
1281 * Only error number of vector is available.
1282 * We don't have a mechanism to map multiple
1283 * interrupts into one vector, so even if we
1284 * can try to request less vectors, we don't
1285 * know how to associate interrupt events to
1286 * vectors. Linux doesn't duplicate vectors
1287 * in the MSIX table for this case.
1288 */
1289
1290 printk(KERN_WARNING "bfad%d: "
1291 "pci_enable_msix failed (%d),"
1292 " use line based.\n", bfad->inst_no, error);
1293
1294 goto line_based;
1295 }
1296
1297 /* Save the vectors */
1298 for (i = 0; i < bfad->nvec; i++) {
1299 bfa_trc(bfad, msix_entries[i].vector);
1300 bfad->msix_tab[i].msix.vector = msix_entries[i].vector;
1301 }
1302
1303 bfa_msix_init(&bfad->bfa, bfad->nvec);
1304
1305 bfad->bfad_flags |= BFAD_MSIX_ON;
1306
1307 return error;
1308 }
1309
1310line_based:
1311 error = 0;
1312 if (request_irq
1313 (bfad->pcidev->irq, (irq_handler_t) bfad_intx, BFAD_IRQ_FLAGS,
1314 BFAD_DRIVER_NAME, bfad) != 0) {
1315 /* Enable interrupt handler failed */
1316 return 1;
1317 }
1318
1319 return error;
1320}
1321
1322void
1323bfad_remove_intr(struct bfad_s *bfad)
1324{
1325 int i;
1326
1327 if (bfad->bfad_flags & BFAD_MSIX_ON) {
1328 for (i = 0; i < bfad->nvec; i++)
1329 free_irq(bfad->msix_tab[i].msix.vector,
1330 &bfad->msix_tab[i]);
1331
1332 pci_disable_msix(bfad->pcidev);
1333 bfad->bfad_flags &= ~BFAD_MSIX_ON;
1334 } else {
1335 free_irq(bfad->pcidev->irq, bfad);
1336 }
1337}
1057 1338
1058/** 1339/*
1059 * PCI probe entry. 1340 * PCI probe entry.
1060 */ 1341 */
1061int 1342int
1062bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid) 1343bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
1063{ 1344{
1064 struct bfad_s *bfad; 1345 struct bfad_s *bfad;
1065 int error = -ENODEV, retval; 1346 int error = -ENODEV, retval;
1066 1347
1067 /* 1348 /* For single port cards - only claim function 0 */
1068 * For single port cards - only claim function 0 1349 if ((pdev->device == BFA_PCI_DEVICE_ID_FC_8G1P) &&
1069 */ 1350 (PCI_FUNC(pdev->devfn) != 0))
1070 if ((pdev->device == BFA_PCI_DEVICE_ID_FC_8G1P)
1071 && (PCI_FUNC(pdev->devfn) != 0))
1072 return -ENODEV; 1351 return -ENODEV;
1073 1352
1074 BFA_TRACE(BFA_INFO, "bfad_pci_probe entry");
1075
1076 bfad = kzalloc(sizeof(struct bfad_s), GFP_KERNEL); 1353 bfad = kzalloc(sizeof(struct bfad_s), GFP_KERNEL);
1077 if (!bfad) { 1354 if (!bfad) {
1078 error = -ENOMEM; 1355 error = -ENOMEM;
@@ -1086,21 +1363,11 @@ bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
1086 goto out_alloc_trace_failure; 1363 goto out_alloc_trace_failure;
1087 } 1364 }
1088 1365
1089 /* 1366 /* TRACE INIT */
1090 * LOG/TRACE INIT
1091 */
1092 bfa_trc_init(bfad->trcmod); 1367 bfa_trc_init(bfad->trcmod);
1093 bfa_trc(bfad, bfad_inst); 1368 bfa_trc(bfad, bfad_inst);
1094 1369
1095 bfad->logmod = &bfad->log_data;
1096 bfa_log_init(bfad->logmod, (char *)pci_name(pdev), bfa_os_printf);
1097
1098 bfad_drv_log_level_set(bfad);
1099
1100 bfad->aen = &bfad->aen_buf;
1101
1102 if (!(bfad_load_fwimg(pdev))) { 1370 if (!(bfad_load_fwimg(pdev))) {
1103 printk(KERN_WARNING "bfad_load_fwimg failure!\n");
1104 kfree(bfad->trcmod); 1371 kfree(bfad->trcmod);
1105 goto out_alloc_trace_failure; 1372 goto out_alloc_trace_failure;
1106 } 1373 }
@@ -1117,46 +1384,38 @@ bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
1117 list_add_tail(&bfad->list_entry, &bfad_list); 1384 list_add_tail(&bfad->list_entry, &bfad_list);
1118 mutex_unlock(&bfad_mutex); 1385 mutex_unlock(&bfad_mutex);
1119 1386
1387 /* Initializing the state machine: State set to uninit */
1388 bfa_sm_set_state(bfad, bfad_sm_uninit);
1389
1120 spin_lock_init(&bfad->bfad_lock); 1390 spin_lock_init(&bfad->bfad_lock);
1121 pci_set_drvdata(pdev, bfad); 1391 pci_set_drvdata(pdev, bfad);
1122 1392
1123 bfad->ref_count = 0; 1393 bfad->ref_count = 0;
1124 bfad->pport.bfad = bfad; 1394 bfad->pport.bfad = bfad;
1125 INIT_LIST_HEAD(&bfad->pbc_pcfg_list); 1395 INIT_LIST_HEAD(&bfad->pbc_vport_list);
1126 1396
1127 bfad->bfad_tsk = kthread_create(bfad_worker, (void *) bfad, "%s", 1397 /* Setup the debugfs node for this bfad */
1128 "bfad_worker"); 1398 if (bfa_debugfs_enable)
1129 if (IS_ERR(bfad->bfad_tsk)) { 1399 bfad_debugfs_init(&bfad->pport);
1130 printk(KERN_INFO "bfad[%d]: Kernel thread"
1131 " creation failed!\n",
1132 bfad->inst_no);
1133 goto out_kthread_create_failure;
1134 }
1135 1400
1136 retval = bfad_drv_init(bfad); 1401 retval = bfad_drv_init(bfad);
1137 if (retval != BFA_STATUS_OK) 1402 if (retval != BFA_STATUS_OK)
1138 goto out_drv_init_failure; 1403 goto out_drv_init_failure;
1139 if (!(bfad->bfad_flags & BFAD_HAL_INIT_DONE)) {
1140 bfad->bfad_flags |= BFAD_HAL_INIT_FAIL;
1141 printk(KERN_WARNING "bfad%d: hal init failed\n", bfad->inst_no);
1142 goto ok;
1143 }
1144 1404
1145 retval = bfad_start_ops(bfad); 1405 bfa_sm_send_event(bfad, BFAD_E_CREATE);
1146 if (retval != BFA_STATUS_OK)
1147 goto out_start_ops_failure;
1148 1406
1149 kthread_stop(bfad->bfad_tsk); 1407 if (bfa_sm_cmp_state(bfad, bfad_sm_uninit))
1150 bfad->bfad_tsk = NULL; 1408 goto out_bfad_sm_failure;
1151 1409
1152ok:
1153 return 0; 1410 return 0;
1154 1411
1155out_start_ops_failure: 1412out_bfad_sm_failure:
1156 bfad_drv_uninit(bfad); 1413 bfa_detach(&bfad->bfa);
1414 bfad_hal_mem_release(bfad);
1157out_drv_init_failure: 1415out_drv_init_failure:
1158 kthread_stop(bfad->bfad_tsk); 1416 /* Remove the debugfs node for this bfad */
1159out_kthread_create_failure: 1417 kfree(bfad->regdata);
1418 bfad_debugfs_exit(&bfad->pport);
1160 mutex_lock(&bfad_mutex); 1419 mutex_lock(&bfad_mutex);
1161 bfad_inst--; 1420 bfad_inst--;
1162 list_del(&bfad->list_entry); 1421 list_del(&bfad->list_entry);
@@ -1170,68 +1429,39 @@ out:
1170 return error; 1429 return error;
1171} 1430}
1172 1431
1173/** 1432/*
1174 * PCI remove entry. 1433 * PCI remove entry.
1175 */ 1434 */
1176void 1435void
1177bfad_pci_remove(struct pci_dev *pdev) 1436bfad_pci_remove(struct pci_dev *pdev)
1178{ 1437{
1179 struct bfad_s *bfad = pci_get_drvdata(pdev); 1438 struct bfad_s *bfad = pci_get_drvdata(pdev);
1180 unsigned long flags; 1439 unsigned long flags;
1181 1440
1182 bfa_trc(bfad, bfad->inst_no); 1441 bfa_trc(bfad, bfad->inst_no);
1183 1442
1184 spin_lock_irqsave(&bfad->bfad_lock, flags); 1443 spin_lock_irqsave(&bfad->bfad_lock, flags);
1185 if (bfad->bfad_tsk != NULL) 1444 if (bfad->bfad_tsk != NULL) {
1186 kthread_stop(bfad->bfad_tsk);
1187 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1188
1189 if ((bfad->bfad_flags & BFAD_DRV_INIT_DONE)
1190 && !(bfad->bfad_flags & BFAD_HAL_INIT_DONE)) {
1191
1192 spin_lock_irqsave(&bfad->bfad_lock, flags);
1193 init_completion(&bfad->comp);
1194 bfa_stop(&bfad->bfa);
1195 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 1445 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1196 wait_for_completion(&bfad->comp); 1446 kthread_stop(bfad->bfad_tsk);
1197 1447 } else {
1198 bfad_remove_intr(bfad);
1199 del_timer_sync(&bfad->hal_tmo);
1200 goto hal_detach;
1201 } else if (!(bfad->bfad_flags & BFAD_DRV_INIT_DONE)) {
1202 goto remove_sysfs;
1203 }
1204
1205 if (bfad->bfad_flags & BFAD_HAL_START_DONE) {
1206 bfad_drv_stop(bfad);
1207 } else if (bfad->bfad_flags & BFAD_DRV_INIT_DONE) {
1208 /* Invoking bfa_stop() before bfa_detach
1209 * when HAL and DRV init are success
1210 * but HAL start did not occur.
1211 */
1212 spin_lock_irqsave(&bfad->bfad_lock, flags);
1213 init_completion(&bfad->comp);
1214 bfa_stop(&bfad->bfa);
1215 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 1448 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1216 wait_for_completion(&bfad->comp);
1217 } 1449 }
1218 1450
1219 bfad_remove_intr(bfad); 1451 /* Send Event BFAD_E_STOP */
1220 del_timer_sync(&bfad->hal_tmo); 1452 bfa_sm_send_event(bfad, BFAD_E_STOP);
1221
1222 if (bfad->bfad_flags & BFAD_FC4_PROBE_DONE)
1223 bfad_fc4_probe_undo(bfad);
1224
1225 if (bfad->bfad_flags & BFAD_CFG_PPORT_DONE)
1226 bfad_uncfg_pport(bfad);
1227 1453
1228hal_detach: 1454 /* Driver detach and dealloc mem */
1229 spin_lock_irqsave(&bfad->bfad_lock, flags); 1455 spin_lock_irqsave(&bfad->bfad_lock, flags);
1230 bfa_detach(&bfad->bfa); 1456 bfa_detach(&bfad->bfa);
1231 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 1457 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1232 bfad_hal_mem_release(bfad); 1458 bfad_hal_mem_release(bfad);
1233remove_sysfs:
1234 1459
1460 /* Remove the debugfs node for this bfad */
1461 kfree(bfad->regdata);
1462 bfad_debugfs_exit(&bfad->pport);
1463
1464 /* Cleaning the BFAD instance */
1235 mutex_lock(&bfad_mutex); 1465 mutex_lock(&bfad_mutex);
1236 bfad_inst--; 1466 bfad_inst--;
1237 list_del(&bfad->list_entry); 1467 list_del(&bfad->list_entry);
@@ -1242,35 +1472,34 @@ remove_sysfs:
1242 kfree(bfad); 1472 kfree(bfad);
1243} 1473}
1244 1474
1245 1475struct pci_device_id bfad_id_table[] = {
1246static struct pci_device_id bfad_id_table[] = {
1247 { 1476 {
1248 .vendor = BFA_PCI_VENDOR_ID_BROCADE, 1477 .vendor = BFA_PCI_VENDOR_ID_BROCADE,
1249 .device = BFA_PCI_DEVICE_ID_FC_8G2P, 1478 .device = BFA_PCI_DEVICE_ID_FC_8G2P,
1250 .subvendor = PCI_ANY_ID, 1479 .subvendor = PCI_ANY_ID,
1251 .subdevice = PCI_ANY_ID, 1480 .subdevice = PCI_ANY_ID,
1252 }, 1481 },
1253 { 1482 {
1254 .vendor = BFA_PCI_VENDOR_ID_BROCADE, 1483 .vendor = BFA_PCI_VENDOR_ID_BROCADE,
1255 .device = BFA_PCI_DEVICE_ID_FC_8G1P, 1484 .device = BFA_PCI_DEVICE_ID_FC_8G1P,
1256 .subvendor = PCI_ANY_ID, 1485 .subvendor = PCI_ANY_ID,
1257 .subdevice = PCI_ANY_ID, 1486 .subdevice = PCI_ANY_ID,
1258 }, 1487 },
1259 { 1488 {
1260 .vendor = BFA_PCI_VENDOR_ID_BROCADE, 1489 .vendor = BFA_PCI_VENDOR_ID_BROCADE,
1261 .device = BFA_PCI_DEVICE_ID_CT, 1490 .device = BFA_PCI_DEVICE_ID_CT,
1262 .subvendor = PCI_ANY_ID, 1491 .subvendor = PCI_ANY_ID,
1263 .subdevice = PCI_ANY_ID, 1492 .subdevice = PCI_ANY_ID,
1264 .class = (PCI_CLASS_SERIAL_FIBER << 8), 1493 .class = (PCI_CLASS_SERIAL_FIBER << 8),
1265 .class_mask = ~0, 1494 .class_mask = ~0,
1266 }, 1495 },
1267 { 1496 {
1268 .vendor = BFA_PCI_VENDOR_ID_BROCADE, 1497 .vendor = BFA_PCI_VENDOR_ID_BROCADE,
1269 .device = BFA_PCI_DEVICE_ID_CT_FC, 1498 .device = BFA_PCI_DEVICE_ID_CT_FC,
1270 .subvendor = PCI_ANY_ID, 1499 .subvendor = PCI_ANY_ID,
1271 .subdevice = PCI_ANY_ID, 1500 .subdevice = PCI_ANY_ID,
1272 .class = (PCI_CLASS_SERIAL_FIBER << 8), 1501 .class = (PCI_CLASS_SERIAL_FIBER << 8),
1273 .class_mask = ~0, 1502 .class_mask = ~0,
1274 }, 1503 },
1275 1504
1276 {0, 0}, 1505 {0, 0},
@@ -1285,90 +1514,114 @@ static struct pci_driver bfad_pci_driver = {
1285 .remove = __devexit_p(bfad_pci_remove), 1514 .remove = __devexit_p(bfad_pci_remove),
1286}; 1515};
1287 1516
1288/** 1517/*
1289 * Linux driver module functions
1290 */
1291bfa_status_t
1292bfad_fc4_module_init(void)
1293{
1294 int rc;
1295
1296 rc = bfad_im_module_init();
1297 if (rc != BFA_STATUS_OK)
1298 goto ext;
1299
1300 bfad_tm_module_init();
1301 if (ipfc_enable)
1302 bfad_ipfc_module_init();
1303ext:
1304 return rc;
1305}
1306
1307void
1308bfad_fc4_module_exit(void)
1309{
1310 if (ipfc_enable)
1311 bfad_ipfc_module_exit();
1312 bfad_tm_module_exit();
1313 bfad_im_module_exit();
1314}
1315
1316/**
1317 * Driver module init. 1518 * Driver module init.
1318 */ 1519 */
1319static int __init 1520static int __init
1320bfad_init(void) 1521bfad_init(void)
1321{ 1522{
1322 int error = 0; 1523 int error = 0;
1323 1524
1324 printk(KERN_INFO "Brocade BFA FC/FCOE SCSI driver - version: %s\n", 1525 printk(KERN_INFO "Brocade BFA FC/FCOE SCSI driver - version: %s\n",
1325 BFAD_DRIVER_VERSION); 1526 BFAD_DRIVER_VERSION);
1326 1527
1327 if (num_sgpgs > 0) 1528 if (num_sgpgs > 0)
1328 num_sgpgs_parm = num_sgpgs; 1529 num_sgpgs_parm = num_sgpgs;
1329 1530
1330 error = bfad_fc4_module_init(); 1531 error = bfad_im_module_init();
1331 if (error) { 1532 if (error) {
1332 error = -ENOMEM; 1533 error = -ENOMEM;
1333 printk(KERN_WARNING "bfad_fc4_module_init failure\n"); 1534 printk(KERN_WARNING "bfad_im_module_init failure\n");
1334 goto ext; 1535 goto ext;
1335 } 1536 }
1336 1537
1337 if (!strcmp(FCPI_NAME, " fcpim")) 1538 if (strcmp(FCPI_NAME, " fcpim") == 0)
1338 bfad_supported_fc4s |= BFA_PORT_ROLE_FCP_IM; 1539 supported_fc4s |= BFA_LPORT_ROLE_FCP_IM;
1339 if (!strcmp(FCPT_NAME, " fcptm"))
1340 bfad_supported_fc4s |= BFA_PORT_ROLE_FCP_TM;
1341 if (!strcmp(IPFC_NAME, " ipfc"))
1342 bfad_supported_fc4s |= BFA_PORT_ROLE_FCP_IPFC;
1343 1540
1344 bfa_ioc_auto_recover(ioc_auto_recover); 1541 bfa_auto_recover = ioc_auto_recover;
1345 bfa_fcs_rport_set_del_timeout(rport_del_timeout); 1542 bfa_fcs_rport_set_del_timeout(rport_del_timeout);
1346 error = pci_register_driver(&bfad_pci_driver);
1347 1543
1544 error = pci_register_driver(&bfad_pci_driver);
1348 if (error) { 1545 if (error) {
1349 printk(KERN_WARNING "bfad pci_register_driver failure\n"); 1546 printk(KERN_WARNING "pci_register_driver failure\n");
1350 goto ext; 1547 goto ext;
1351 } 1548 }
1352 1549
1353 return 0; 1550 return 0;
1354 1551
1355ext: 1552ext:
1356 bfad_fc4_module_exit(); 1553 bfad_im_module_exit();
1357 return error; 1554 return error;
1358} 1555}
1359 1556
1360/** 1557/*
1361 * Driver module exit. 1558 * Driver module exit.
1362 */ 1559 */
1363static void __exit 1560static void __exit
1364bfad_exit(void) 1561bfad_exit(void)
1365{ 1562{
1366 pci_unregister_driver(&bfad_pci_driver); 1563 pci_unregister_driver(&bfad_pci_driver);
1367 bfad_fc4_module_exit(); 1564 bfad_im_module_exit();
1368 bfad_free_fwimg(); 1565 bfad_free_fwimg();
1369} 1566}
1370 1567
1371#define BFAD_PROTO_NAME FCPI_NAME FCPT_NAME IPFC_NAME 1568/* Firmware handling */
1569static void
1570bfad_read_firmware(struct pci_dev *pdev, u32 **bfi_image,
1571 u32 *bfi_image_size, char *fw_name)
1572{
1573 const struct firmware *fw;
1574
1575 if (request_firmware(&fw, fw_name, &pdev->dev)) {
1576 printk(KERN_ALERT "Can't locate firmware %s\n", fw_name);
1577 *bfi_image = NULL;
1578 goto out;
1579 }
1580
1581 *bfi_image = vmalloc(fw->size);
1582 if (NULL == *bfi_image) {
1583 printk(KERN_ALERT "Fail to allocate buffer for fw image "
1584 "size=%x!\n", (u32) fw->size);
1585 goto out;
1586 }
1587
1588 memcpy(*bfi_image, fw->data, fw->size);
1589 *bfi_image_size = fw->size/sizeof(u32);
1590out:
1591 release_firmware(fw);
1592}
1593
1594static u32 *
1595bfad_load_fwimg(struct pci_dev *pdev)
1596{
1597 if (pdev->device == BFA_PCI_DEVICE_ID_CT_FC) {
1598 if (bfi_image_ct_fc_size == 0)
1599 bfad_read_firmware(pdev, &bfi_image_ct_fc,
1600 &bfi_image_ct_fc_size, BFAD_FW_FILE_CT_FC);
1601 return bfi_image_ct_fc;
1602 } else if (pdev->device == BFA_PCI_DEVICE_ID_CT) {
1603 if (bfi_image_ct_cna_size == 0)
1604 bfad_read_firmware(pdev, &bfi_image_ct_cna,
1605 &bfi_image_ct_cna_size, BFAD_FW_FILE_CT_CNA);
1606 return bfi_image_ct_cna;
1607 } else {
1608 if (bfi_image_cb_fc_size == 0)
1609 bfad_read_firmware(pdev, &bfi_image_cb_fc,
1610 &bfi_image_cb_fc_size, BFAD_FW_FILE_CB_FC);
1611 return bfi_image_cb_fc;
1612 }
1613}
1614
1615static void
1616bfad_free_fwimg(void)
1617{
1618 if (bfi_image_ct_fc_size && bfi_image_ct_fc)
1619 vfree(bfi_image_ct_fc);
1620 if (bfi_image_ct_cna_size && bfi_image_ct_cna)
1621 vfree(bfi_image_ct_cna);
1622 if (bfi_image_cb_fc_size && bfi_image_cb_fc)
1623 vfree(bfi_image_cb_fc);
1624}
1372 1625
1373module_init(bfad_init); 1626module_init(bfad_init);
1374module_exit(bfad_exit); 1627module_exit(bfad_exit);
@@ -1376,5 +1629,3 @@ MODULE_LICENSE("GPL");
1376MODULE_DESCRIPTION("Brocade Fibre Channel HBA Driver" BFAD_PROTO_NAME); 1629MODULE_DESCRIPTION("Brocade Fibre Channel HBA Driver" BFAD_PROTO_NAME);
1377MODULE_AUTHOR("Brocade Communications Systems, Inc."); 1630MODULE_AUTHOR("Brocade Communications Systems, Inc.");
1378MODULE_VERSION(BFAD_DRIVER_VERSION); 1631MODULE_VERSION(BFAD_DRIVER_VERSION);
1379
1380
diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c
index 0818eb07ef88..a94ea4235433 100644
--- a/drivers/scsi/bfa/bfad_attr.c
+++ b/drivers/scsi/bfa/bfad_attr.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,24 +15,17 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18/** 18/*
19 * bfa_attr.c Linux driver configuration interface module. 19 * bfa_attr.c Linux driver configuration interface module.
20 */ 20 */
21 21
22#include <linux/slab.h>
23#include "bfad_drv.h" 22#include "bfad_drv.h"
24#include "bfad_im.h" 23#include "bfad_im.h"
25#include "bfad_trcmod.h"
26#include "bfad_attr.h"
27
28/**
29 * FC_transport_template FC transport template
30 */
31 24
32/** 25/*
33 * FC transport template entry, get SCSI target port ID. 26 * FC transport template entry, get SCSI target port ID.
34 */ 27 */
35void 28static void
36bfad_im_get_starget_port_id(struct scsi_target *starget) 29bfad_im_get_starget_port_id(struct scsi_target *starget)
37{ 30{
38 struct Scsi_Host *shost; 31 struct Scsi_Host *shost;
@@ -42,12 +35,12 @@ bfad_im_get_starget_port_id(struct scsi_target *starget)
42 u32 fc_id = -1; 35 u32 fc_id = -1;
43 unsigned long flags; 36 unsigned long flags;
44 37
45 shost = bfad_os_starget_to_shost(starget); 38 shost = dev_to_shost(starget->dev.parent);
46 im_port = (struct bfad_im_port_s *) shost->hostdata[0]; 39 im_port = (struct bfad_im_port_s *) shost->hostdata[0];
47 bfad = im_port->bfad; 40 bfad = im_port->bfad;
48 spin_lock_irqsave(&bfad->bfad_lock, flags); 41 spin_lock_irqsave(&bfad->bfad_lock, flags);
49 42
50 itnim = bfad_os_get_itnim(im_port, starget->id); 43 itnim = bfad_get_itnim(im_port, starget->id);
51 if (itnim) 44 if (itnim)
52 fc_id = bfa_fcs_itnim_get_fcid(&itnim->fcs_itnim); 45 fc_id = bfa_fcs_itnim_get_fcid(&itnim->fcs_itnim);
53 46
@@ -55,10 +48,10 @@ bfad_im_get_starget_port_id(struct scsi_target *starget)
55 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 48 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
56} 49}
57 50
58/** 51/*
59 * FC transport template entry, get SCSI target nwwn. 52 * FC transport template entry, get SCSI target nwwn.
60 */ 53 */
61void 54static void
62bfad_im_get_starget_node_name(struct scsi_target *starget) 55bfad_im_get_starget_node_name(struct scsi_target *starget)
63{ 56{
64 struct Scsi_Host *shost; 57 struct Scsi_Host *shost;
@@ -68,23 +61,23 @@ bfad_im_get_starget_node_name(struct scsi_target *starget)
68 u64 node_name = 0; 61 u64 node_name = 0;
69 unsigned long flags; 62 unsigned long flags;
70 63
71 shost = bfad_os_starget_to_shost(starget); 64 shost = dev_to_shost(starget->dev.parent);
72 im_port = (struct bfad_im_port_s *) shost->hostdata[0]; 65 im_port = (struct bfad_im_port_s *) shost->hostdata[0];
73 bfad = im_port->bfad; 66 bfad = im_port->bfad;
74 spin_lock_irqsave(&bfad->bfad_lock, flags); 67 spin_lock_irqsave(&bfad->bfad_lock, flags);
75 68
76 itnim = bfad_os_get_itnim(im_port, starget->id); 69 itnim = bfad_get_itnim(im_port, starget->id);
77 if (itnim) 70 if (itnim)
78 node_name = bfa_fcs_itnim_get_nwwn(&itnim->fcs_itnim); 71 node_name = bfa_fcs_itnim_get_nwwn(&itnim->fcs_itnim);
79 72
80 fc_starget_node_name(starget) = bfa_os_htonll(node_name); 73 fc_starget_node_name(starget) = cpu_to_be64(node_name);
81 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 74 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
82} 75}
83 76
84/** 77/*
85 * FC transport template entry, get SCSI target pwwn. 78 * FC transport template entry, get SCSI target pwwn.
86 */ 79 */
87void 80static void
88bfad_im_get_starget_port_name(struct scsi_target *starget) 81bfad_im_get_starget_port_name(struct scsi_target *starget)
89{ 82{
90 struct Scsi_Host *shost; 83 struct Scsi_Host *shost;
@@ -94,23 +87,23 @@ bfad_im_get_starget_port_name(struct scsi_target *starget)
94 u64 port_name = 0; 87 u64 port_name = 0;
95 unsigned long flags; 88 unsigned long flags;
96 89
97 shost = bfad_os_starget_to_shost(starget); 90 shost = dev_to_shost(starget->dev.parent);
98 im_port = (struct bfad_im_port_s *) shost->hostdata[0]; 91 im_port = (struct bfad_im_port_s *) shost->hostdata[0];
99 bfad = im_port->bfad; 92 bfad = im_port->bfad;
100 spin_lock_irqsave(&bfad->bfad_lock, flags); 93 spin_lock_irqsave(&bfad->bfad_lock, flags);
101 94
102 itnim = bfad_os_get_itnim(im_port, starget->id); 95 itnim = bfad_get_itnim(im_port, starget->id);
103 if (itnim) 96 if (itnim)
104 port_name = bfa_fcs_itnim_get_pwwn(&itnim->fcs_itnim); 97 port_name = bfa_fcs_itnim_get_pwwn(&itnim->fcs_itnim);
105 98
106 fc_starget_port_name(starget) = bfa_os_htonll(port_name); 99 fc_starget_port_name(starget) = cpu_to_be64(port_name);
107 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 100 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
108} 101}
109 102
110/** 103/*
111 * FC transport template entry, get SCSI host port ID. 104 * FC transport template entry, get SCSI host port ID.
112 */ 105 */
113void 106static void
114bfad_im_get_host_port_id(struct Scsi_Host *shost) 107bfad_im_get_host_port_id(struct Scsi_Host *shost)
115{ 108{
116 struct bfad_im_port_s *im_port = 109 struct bfad_im_port_s *im_port =
@@ -118,20 +111,10 @@ bfad_im_get_host_port_id(struct Scsi_Host *shost)
118 struct bfad_port_s *port = im_port->port; 111 struct bfad_port_s *port = im_port->port;
119 112
120 fc_host_port_id(shost) = 113 fc_host_port_id(shost) =
121 bfa_os_hton3b(bfa_fcs_port_get_fcid(port->fcs_port)); 114 bfa_hton3b(bfa_fcs_lport_get_fcid(port->fcs_port));
122}
123
124
125
126
127
128struct Scsi_Host *
129bfad_os_starget_to_shost(struct scsi_target *starget)
130{
131 return dev_to_shost(starget->dev.parent);
132} 115}
133 116
134/** 117/*
135 * FC transport template entry, get SCSI host port type. 118 * FC transport template entry, get SCSI host port type.
136 */ 119 */
137static void 120static void
@@ -140,21 +123,21 @@ bfad_im_get_host_port_type(struct Scsi_Host *shost)
140 struct bfad_im_port_s *im_port = 123 struct bfad_im_port_s *im_port =
141 (struct bfad_im_port_s *) shost->hostdata[0]; 124 (struct bfad_im_port_s *) shost->hostdata[0];
142 struct bfad_s *bfad = im_port->bfad; 125 struct bfad_s *bfad = im_port->bfad;
143 struct bfa_pport_attr_s attr; 126 struct bfa_lport_attr_s port_attr;
144 127
145 bfa_fcport_get_attr(&bfad->bfa, &attr); 128 bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr);
146 129
147 switch (attr.port_type) { 130 switch (port_attr.port_type) {
148 case BFA_PPORT_TYPE_NPORT: 131 case BFA_PORT_TYPE_NPORT:
149 fc_host_port_type(shost) = FC_PORTTYPE_NPORT; 132 fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
150 break; 133 break;
151 case BFA_PPORT_TYPE_NLPORT: 134 case BFA_PORT_TYPE_NLPORT:
152 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; 135 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
153 break; 136 break;
154 case BFA_PPORT_TYPE_P2P: 137 case BFA_PORT_TYPE_P2P:
155 fc_host_port_type(shost) = FC_PORTTYPE_PTP; 138 fc_host_port_type(shost) = FC_PORTTYPE_PTP;
156 break; 139 break;
157 case BFA_PPORT_TYPE_LPORT: 140 case BFA_PORT_TYPE_LPORT:
158 fc_host_port_type(shost) = FC_PORTTYPE_LPORT; 141 fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
159 break; 142 break;
160 default: 143 default:
@@ -163,7 +146,7 @@ bfad_im_get_host_port_type(struct Scsi_Host *shost)
163 } 146 }
164} 147}
165 148
166/** 149/*
167 * FC transport template entry, get SCSI host port state. 150 * FC transport template entry, get SCSI host port state.
168 */ 151 */
169static void 152static void
@@ -172,32 +155,35 @@ bfad_im_get_host_port_state(struct Scsi_Host *shost)
172 struct bfad_im_port_s *im_port = 155 struct bfad_im_port_s *im_port =
173 (struct bfad_im_port_s *) shost->hostdata[0]; 156 (struct bfad_im_port_s *) shost->hostdata[0];
174 struct bfad_s *bfad = im_port->bfad; 157 struct bfad_s *bfad = im_port->bfad;
175 struct bfa_pport_attr_s attr; 158 struct bfa_port_attr_s attr;
176 159
177 bfa_fcport_get_attr(&bfad->bfa, &attr); 160 bfa_fcport_get_attr(&bfad->bfa, &attr);
178 161
179 switch (attr.port_state) { 162 switch (attr.port_state) {
180 case BFA_PPORT_ST_LINKDOWN: 163 case BFA_PORT_ST_LINKDOWN:
181 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; 164 fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
182 break; 165 break;
183 case BFA_PPORT_ST_LINKUP: 166 case BFA_PORT_ST_LINKUP:
184 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; 167 fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
185 break; 168 break;
186 case BFA_PPORT_ST_UNINIT: 169 case BFA_PORT_ST_DISABLED:
187 case BFA_PPORT_ST_ENABLING_QWAIT: 170 case BFA_PORT_ST_STOPPED:
188 case BFA_PPORT_ST_ENABLING: 171 case BFA_PORT_ST_IOCDOWN:
189 case BFA_PPORT_ST_DISABLING_QWAIT: 172 case BFA_PORT_ST_IOCDIS:
190 case BFA_PPORT_ST_DISABLING: 173 fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
191 case BFA_PPORT_ST_DISABLED: 174 break;
192 case BFA_PPORT_ST_STOPPED: 175 case BFA_PORT_ST_UNINIT:
193 case BFA_PPORT_ST_IOCDOWN: 176 case BFA_PORT_ST_ENABLING_QWAIT:
177 case BFA_PORT_ST_ENABLING:
178 case BFA_PORT_ST_DISABLING_QWAIT:
179 case BFA_PORT_ST_DISABLING:
194 default: 180 default:
195 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN; 181 fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
196 break; 182 break;
197 } 183 }
198} 184}
199 185
200/** 186/*
201 * FC transport template entry, get SCSI host active fc4s. 187 * FC transport template entry, get SCSI host active fc4s.
202 */ 188 */
203static void 189static void
@@ -210,17 +196,13 @@ bfad_im_get_host_active_fc4s(struct Scsi_Host *shost)
210 memset(fc_host_active_fc4s(shost), 0, 196 memset(fc_host_active_fc4s(shost), 0,
211 sizeof(fc_host_active_fc4s(shost))); 197 sizeof(fc_host_active_fc4s(shost)));
212 198
213 if (port->supported_fc4s & 199 if (port->supported_fc4s & BFA_LPORT_ROLE_FCP_IM)
214 (BFA_PORT_ROLE_FCP_IM | BFA_PORT_ROLE_FCP_TM))
215 fc_host_active_fc4s(shost)[2] = 1; 200 fc_host_active_fc4s(shost)[2] = 1;
216 201
217 if (port->supported_fc4s & BFA_PORT_ROLE_FCP_IPFC)
218 fc_host_active_fc4s(shost)[3] = 0x20;
219
220 fc_host_active_fc4s(shost)[7] = 1; 202 fc_host_active_fc4s(shost)[7] = 1;
221} 203}
222 204
223/** 205/*
224 * FC transport template entry, get SCSI host link speed. 206 * FC transport template entry, get SCSI host link speed.
225 */ 207 */
226static void 208static void
@@ -229,32 +211,32 @@ bfad_im_get_host_speed(struct Scsi_Host *shost)
229 struct bfad_im_port_s *im_port = 211 struct bfad_im_port_s *im_port =
230 (struct bfad_im_port_s *) shost->hostdata[0]; 212 (struct bfad_im_port_s *) shost->hostdata[0];
231 struct bfad_s *bfad = im_port->bfad; 213 struct bfad_s *bfad = im_port->bfad;
232 struct bfa_pport_attr_s attr; 214 struct bfa_port_attr_s attr;
233 unsigned long flags;
234 215
235 spin_lock_irqsave(shost->host_lock, flags);
236 bfa_fcport_get_attr(&bfad->bfa, &attr); 216 bfa_fcport_get_attr(&bfad->bfa, &attr);
237 switch (attr.speed) { 217 switch (attr.speed) {
238 case BFA_PPORT_SPEED_8GBPS: 218 case BFA_PORT_SPEED_10GBPS:
219 fc_host_speed(shost) = FC_PORTSPEED_10GBIT;
220 break;
221 case BFA_PORT_SPEED_8GBPS:
239 fc_host_speed(shost) = FC_PORTSPEED_8GBIT; 222 fc_host_speed(shost) = FC_PORTSPEED_8GBIT;
240 break; 223 break;
241 case BFA_PPORT_SPEED_4GBPS: 224 case BFA_PORT_SPEED_4GBPS:
242 fc_host_speed(shost) = FC_PORTSPEED_4GBIT; 225 fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
243 break; 226 break;
244 case BFA_PPORT_SPEED_2GBPS: 227 case BFA_PORT_SPEED_2GBPS:
245 fc_host_speed(shost) = FC_PORTSPEED_2GBIT; 228 fc_host_speed(shost) = FC_PORTSPEED_2GBIT;
246 break; 229 break;
247 case BFA_PPORT_SPEED_1GBPS: 230 case BFA_PORT_SPEED_1GBPS:
248 fc_host_speed(shost) = FC_PORTSPEED_1GBIT; 231 fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
249 break; 232 break;
250 default: 233 default:
251 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; 234 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
252 break; 235 break;
253 } 236 }
254 spin_unlock_irqrestore(shost->host_lock, flags);
255} 237}
256 238
257/** 239/*
258 * FC transport template entry, get SCSI host port type. 240 * FC transport template entry, get SCSI host port type.
259 */ 241 */
260static void 242static void
@@ -265,13 +247,13 @@ bfad_im_get_host_fabric_name(struct Scsi_Host *shost)
265 struct bfad_port_s *port = im_port->port; 247 struct bfad_port_s *port = im_port->port;
266 wwn_t fabric_nwwn = 0; 248 wwn_t fabric_nwwn = 0;
267 249
268 fabric_nwwn = bfa_fcs_port_get_fabric_name(port->fcs_port); 250 fabric_nwwn = bfa_fcs_lport_get_fabric_name(port->fcs_port);
269 251
270 fc_host_fabric_name(shost) = bfa_os_htonll(fabric_nwwn); 252 fc_host_fabric_name(shost) = cpu_to_be64(fabric_nwwn);
271 253
272} 254}
273 255
274/** 256/*
275 * FC transport template entry, get BFAD statistics. 257 * FC transport template entry, get BFAD statistics.
276 */ 258 */
277static struct fc_host_statistics * 259static struct fc_host_statistics *
@@ -281,27 +263,48 @@ bfad_im_get_stats(struct Scsi_Host *shost)
281 (struct bfad_im_port_s *) shost->hostdata[0]; 263 (struct bfad_im_port_s *) shost->hostdata[0];
282 struct bfad_s *bfad = im_port->bfad; 264 struct bfad_s *bfad = im_port->bfad;
283 struct bfad_hal_comp fcomp; 265 struct bfad_hal_comp fcomp;
266 union bfa_port_stats_u *fcstats;
284 struct fc_host_statistics *hstats; 267 struct fc_host_statistics *hstats;
285 bfa_status_t rc; 268 bfa_status_t rc;
286 unsigned long flags; 269 unsigned long flags;
287 270
271 fcstats = kzalloc(sizeof(union bfa_port_stats_u), GFP_KERNEL);
272 if (fcstats == NULL)
273 return NULL;
274
288 hstats = &bfad->link_stats; 275 hstats = &bfad->link_stats;
289 init_completion(&fcomp.comp); 276 init_completion(&fcomp.comp);
290 spin_lock_irqsave(&bfad->bfad_lock, flags); 277 spin_lock_irqsave(&bfad->bfad_lock, flags);
291 memset(hstats, 0, sizeof(struct fc_host_statistics)); 278 memset(hstats, 0, sizeof(struct fc_host_statistics));
292 rc = bfa_port_get_stats(BFA_FCPORT(&bfad->bfa), 279 rc = bfa_port_get_stats(BFA_FCPORT(&bfad->bfa),
293 (union bfa_pport_stats_u *) hstats, 280 fcstats, bfad_hcb_comp, &fcomp);
294 bfad_hcb_comp, &fcomp);
295 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 281 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
296 if (rc != BFA_STATUS_OK) 282 if (rc != BFA_STATUS_OK)
297 return NULL; 283 return NULL;
298 284
299 wait_for_completion(&fcomp.comp); 285 wait_for_completion(&fcomp.comp);
300 286
287 /* Fill the fc_host_statistics structure */
288 hstats->seconds_since_last_reset = fcstats->fc.secs_reset;
289 hstats->tx_frames = fcstats->fc.tx_frames;
290 hstats->tx_words = fcstats->fc.tx_words;
291 hstats->rx_frames = fcstats->fc.rx_frames;
292 hstats->rx_words = fcstats->fc.rx_words;
293 hstats->lip_count = fcstats->fc.lip_count;
294 hstats->nos_count = fcstats->fc.nos_count;
295 hstats->error_frames = fcstats->fc.error_frames;
296 hstats->dumped_frames = fcstats->fc.dropped_frames;
297 hstats->link_failure_count = fcstats->fc.link_failures;
298 hstats->loss_of_sync_count = fcstats->fc.loss_of_syncs;
299 hstats->loss_of_signal_count = fcstats->fc.loss_of_signals;
300 hstats->prim_seq_protocol_err_count = fcstats->fc.primseq_errs;
301 hstats->invalid_crc_count = fcstats->fc.invalid_crcs;
302
303 kfree(fcstats);
301 return hstats; 304 return hstats;
302} 305}
303 306
304/** 307/*
305 * FC transport template entry, reset BFAD statistics. 308 * FC transport template entry, reset BFAD statistics.
306 */ 309 */
307static void 310static void
@@ -317,7 +320,7 @@ bfad_im_reset_stats(struct Scsi_Host *shost)
317 init_completion(&fcomp.comp); 320 init_completion(&fcomp.comp);
318 spin_lock_irqsave(&bfad->bfad_lock, flags); 321 spin_lock_irqsave(&bfad->bfad_lock, flags);
319 rc = bfa_port_clear_stats(BFA_FCPORT(&bfad->bfa), bfad_hcb_comp, 322 rc = bfa_port_clear_stats(BFA_FCPORT(&bfad->bfa), bfad_hcb_comp,
320 &fcomp); 323 &fcomp);
321 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 324 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
322 325
323 if (rc != BFA_STATUS_OK) 326 if (rc != BFA_STATUS_OK)
@@ -328,7 +331,7 @@ bfad_im_reset_stats(struct Scsi_Host *shost)
328 return; 331 return;
329} 332}
330 333
331/** 334/*
332 * FC transport template entry, get rport loss timeout. 335 * FC transport template entry, get rport loss timeout.
333 */ 336 */
334static void 337static void
@@ -344,7 +347,7 @@ bfad_im_get_rport_loss_tmo(struct fc_rport *rport)
344 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 347 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
345} 348}
346 349
347/** 350/*
348 * FC transport template entry, set rport loss timeout. 351 * FC transport template entry, set rport loss timeout.
349 */ 352 */
350static void 353static void
@@ -372,8 +375,8 @@ bfad_im_vport_create(struct fc_vport *fc_vport, bool disable)
372 struct bfad_im_port_s *im_port = 375 struct bfad_im_port_s *im_port =
373 (struct bfad_im_port_s *) shost->hostdata[0]; 376 (struct bfad_im_port_s *) shost->hostdata[0];
374 struct bfad_s *bfad = im_port->bfad; 377 struct bfad_s *bfad = im_port->bfad;
375 struct bfa_port_cfg_s port_cfg; 378 struct bfa_lport_cfg_s port_cfg;
376 struct bfad_pcfg_s *pcfg; 379 struct bfad_vport_s *vp;
377 int status = 0, rc; 380 int status = 0, rc;
378 unsigned long flags; 381 unsigned long flags;
379 382
@@ -382,12 +385,14 @@ bfad_im_vport_create(struct fc_vport *fc_vport, bool disable)
382 u64_to_wwn(fc_vport->port_name, (u8 *)&port_cfg.pwwn); 385 u64_to_wwn(fc_vport->port_name, (u8 *)&port_cfg.pwwn);
383 if (strlen(vname) > 0) 386 if (strlen(vname) > 0)
384 strcpy((char *)&port_cfg.sym_name, vname); 387 strcpy((char *)&port_cfg.sym_name, vname);
385 port_cfg.roles = BFA_PORT_ROLE_FCP_IM; 388 port_cfg.roles = BFA_LPORT_ROLE_FCP_IM;
386 389
387 spin_lock_irqsave(&bfad->bfad_lock, flags); 390 spin_lock_irqsave(&bfad->bfad_lock, flags);
388 list_for_each_entry(pcfg, &bfad->pbc_pcfg_list, list_entry) { 391 list_for_each_entry(vp, &bfad->pbc_vport_list, list_entry) {
389 if (port_cfg.pwwn == pcfg->port_cfg.pwwn) { 392 if (port_cfg.pwwn ==
390 port_cfg.preboot_vp = pcfg->port_cfg.preboot_vp; 393 vp->fcs_vport.lport.port_cfg.pwwn) {
394 port_cfg.preboot_vp =
395 vp->fcs_vport.lport.port_cfg.preboot_vp;
391 break; 396 break;
392 } 397 }
393 } 398 }
@@ -482,7 +487,7 @@ bfad_im_vport_delete(struct fc_vport *fc_vport)
482 wait_for_completion(vport->comp_del); 487 wait_for_completion(vport->comp_del);
483 488
484free_scsi_host: 489free_scsi_host:
485 bfad_os_scsi_host_free(bfad, im_port); 490 bfad_scsi_host_free(bfad, im_port);
486 491
487 kfree(vport); 492 kfree(vport);
488 493
@@ -628,7 +633,7 @@ struct fc_function_template bfad_im_vport_fc_function_template = {
628 .set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo, 633 .set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo,
629}; 634};
630 635
631/** 636/*
632 * Scsi_Host_attrs SCSI host attributes 637 * Scsi_Host_attrs SCSI host attributes
633 */ 638 */
634static ssize_t 639static ssize_t
@@ -638,7 +643,7 @@ bfad_im_serial_num_show(struct device *dev, struct device_attribute *attr,
638 struct Scsi_Host *shost = class_to_shost(dev); 643 struct Scsi_Host *shost = class_to_shost(dev);
639 struct bfad_im_port_s *im_port = 644 struct bfad_im_port_s *im_port =
640 (struct bfad_im_port_s *) shost->hostdata[0]; 645 (struct bfad_im_port_s *) shost->hostdata[0];
641 struct bfad_s *bfad = im_port->bfad; 646 struct bfad_s *bfad = im_port->bfad;
642 char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN]; 647 char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
643 648
644 bfa_get_adapter_serial_num(&bfad->bfa, serial_num); 649 bfa_get_adapter_serial_num(&bfad->bfa, serial_num);
@@ -652,7 +657,7 @@ bfad_im_model_show(struct device *dev, struct device_attribute *attr,
652 struct Scsi_Host *shost = class_to_shost(dev); 657 struct Scsi_Host *shost = class_to_shost(dev);
653 struct bfad_im_port_s *im_port = 658 struct bfad_im_port_s *im_port =
654 (struct bfad_im_port_s *) shost->hostdata[0]; 659 (struct bfad_im_port_s *) shost->hostdata[0];
655 struct bfad_s *bfad = im_port->bfad; 660 struct bfad_s *bfad = im_port->bfad;
656 char model[BFA_ADAPTER_MODEL_NAME_LEN]; 661 char model[BFA_ADAPTER_MODEL_NAME_LEN];
657 662
658 bfa_get_adapter_model(&bfad->bfa, model); 663 bfa_get_adapter_model(&bfad->bfa, model);
@@ -666,10 +671,54 @@ bfad_im_model_desc_show(struct device *dev, struct device_attribute *attr,
666 struct Scsi_Host *shost = class_to_shost(dev); 671 struct Scsi_Host *shost = class_to_shost(dev);
667 struct bfad_im_port_s *im_port = 672 struct bfad_im_port_s *im_port =
668 (struct bfad_im_port_s *) shost->hostdata[0]; 673 (struct bfad_im_port_s *) shost->hostdata[0];
669 struct bfad_s *bfad = im_port->bfad; 674 struct bfad_s *bfad = im_port->bfad;
675 char model[BFA_ADAPTER_MODEL_NAME_LEN];
670 char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN]; 676 char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN];
671 677
672 bfa_get_adapter_model(&bfad->bfa, model_descr); 678 bfa_get_adapter_model(&bfad->bfa, model);
679 if (!strcmp(model, "Brocade-425"))
680 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
681 "Brocade 4Gbps PCIe dual port FC HBA");
682 else if (!strcmp(model, "Brocade-825"))
683 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
684 "Brocade 8Gbps PCIe dual port FC HBA");
685 else if (!strcmp(model, "Brocade-42B"))
686 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
687 "HP 4Gbps PCIe dual port FC HBA");
688 else if (!strcmp(model, "Brocade-82B"))
689 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
690 "HP 8Gbps PCIe dual port FC HBA");
691 else if (!strcmp(model, "Brocade-1010"))
692 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
693 "Brocade 10Gbps single port CNA");
694 else if (!strcmp(model, "Brocade-1020"))
695 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
696 "Brocade 10Gbps dual port CNA");
697 else if (!strcmp(model, "Brocade-1007"))
698 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
699 "Brocade 10Gbps CNA");
700 else if (!strcmp(model, "Brocade-415"))
701 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
702 "Brocade 4Gbps PCIe single port FC HBA");
703 else if (!strcmp(model, "Brocade-815"))
704 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
705 "Brocade 8Gbps PCIe single port FC HBA");
706 else if (!strcmp(model, "Brocade-41B"))
707 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
708 "HP 4Gbps PCIe single port FC HBA");
709 else if (!strcmp(model, "Brocade-81B"))
710 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
711 "HP 8Gbps PCIe single port FC HBA");
712 else if (!strcmp(model, "Brocade-804"))
713 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
714 "HP Bladesystem C-class 8Gbps FC HBA");
715 else if (!strcmp(model, "Brocade-902"))
716 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
717 "Brocade 10Gbps CNA");
718 else
719 snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
720 "Invalid Model");
721
673 return snprintf(buf, PAGE_SIZE, "%s\n", model_descr); 722 return snprintf(buf, PAGE_SIZE, "%s\n", model_descr);
674} 723}
675 724
@@ -683,8 +732,8 @@ bfad_im_node_name_show(struct device *dev, struct device_attribute *attr,
683 struct bfad_port_s *port = im_port->port; 732 struct bfad_port_s *port = im_port->port;
684 u64 nwwn; 733 u64 nwwn;
685 734
686 nwwn = bfa_fcs_port_get_nwwn(port->fcs_port); 735 nwwn = bfa_fcs_lport_get_nwwn(port->fcs_port);
687 return snprintf(buf, PAGE_SIZE, "0x%llx\n", bfa_os_htonll(nwwn)); 736 return snprintf(buf, PAGE_SIZE, "0x%llx\n", cpu_to_be64(nwwn));
688} 737}
689 738
690static ssize_t 739static ssize_t
@@ -694,14 +743,14 @@ bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr,
694 struct Scsi_Host *shost = class_to_shost(dev); 743 struct Scsi_Host *shost = class_to_shost(dev);
695 struct bfad_im_port_s *im_port = 744 struct bfad_im_port_s *im_port =
696 (struct bfad_im_port_s *) shost->hostdata[0]; 745 (struct bfad_im_port_s *) shost->hostdata[0];
697 struct bfad_s *bfad = im_port->bfad; 746 struct bfad_s *bfad = im_port->bfad;
698 char model[BFA_ADAPTER_MODEL_NAME_LEN]; 747 struct bfa_lport_attr_s port_attr;
699 char fw_ver[BFA_VERSION_LEN]; 748 char symname[BFA_SYMNAME_MAXLEN];
700 749
701 bfa_get_adapter_model(&bfad->bfa, model); 750 bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr);
702 bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver); 751 strncpy(symname, port_attr.port_cfg.sym_name.symname,
703 return snprintf(buf, PAGE_SIZE, "Brocade %s FV%s DV%s\n", 752 BFA_SYMNAME_MAXLEN);
704 model, fw_ver, BFAD_DRIVER_VERSION); 753 return snprintf(buf, PAGE_SIZE, "%s\n", symname);
705} 754}
706 755
707static ssize_t 756static ssize_t
@@ -711,7 +760,7 @@ bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr,
711 struct Scsi_Host *shost = class_to_shost(dev); 760 struct Scsi_Host *shost = class_to_shost(dev);
712 struct bfad_im_port_s *im_port = 761 struct bfad_im_port_s *im_port =
713 (struct bfad_im_port_s *) shost->hostdata[0]; 762 (struct bfad_im_port_s *) shost->hostdata[0];
714 struct bfad_s *bfad = im_port->bfad; 763 struct bfad_s *bfad = im_port->bfad;
715 char hw_ver[BFA_VERSION_LEN]; 764 char hw_ver[BFA_VERSION_LEN];
716 765
717 bfa_get_pci_chip_rev(&bfad->bfa, hw_ver); 766 bfa_get_pci_chip_rev(&bfad->bfa, hw_ver);
@@ -732,7 +781,7 @@ bfad_im_optionrom_version_show(struct device *dev,
732 struct Scsi_Host *shost = class_to_shost(dev); 781 struct Scsi_Host *shost = class_to_shost(dev);
733 struct bfad_im_port_s *im_port = 782 struct bfad_im_port_s *im_port =
734 (struct bfad_im_port_s *) shost->hostdata[0]; 783 (struct bfad_im_port_s *) shost->hostdata[0];
735 struct bfad_s *bfad = im_port->bfad; 784 struct bfad_s *bfad = im_port->bfad;
736 char optrom_ver[BFA_VERSION_LEN]; 785 char optrom_ver[BFA_VERSION_LEN];
737 786
738 bfa_get_adapter_optrom_ver(&bfad->bfa, optrom_ver); 787 bfa_get_adapter_optrom_ver(&bfad->bfa, optrom_ver);
@@ -746,7 +795,7 @@ bfad_im_fw_version_show(struct device *dev, struct device_attribute *attr,
746 struct Scsi_Host *shost = class_to_shost(dev); 795 struct Scsi_Host *shost = class_to_shost(dev);
747 struct bfad_im_port_s *im_port = 796 struct bfad_im_port_s *im_port =
748 (struct bfad_im_port_s *) shost->hostdata[0]; 797 (struct bfad_im_port_s *) shost->hostdata[0];
749 struct bfad_s *bfad = im_port->bfad; 798 struct bfad_s *bfad = im_port->bfad;
750 char fw_ver[BFA_VERSION_LEN]; 799 char fw_ver[BFA_VERSION_LEN];
751 800
752 bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver); 801 bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver);
@@ -760,10 +809,10 @@ bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr,
760 struct Scsi_Host *shost = class_to_shost(dev); 809 struct Scsi_Host *shost = class_to_shost(dev);
761 struct bfad_im_port_s *im_port = 810 struct bfad_im_port_s *im_port =
762 (struct bfad_im_port_s *) shost->hostdata[0]; 811 (struct bfad_im_port_s *) shost->hostdata[0];
763 struct bfad_s *bfad = im_port->bfad; 812 struct bfad_s *bfad = im_port->bfad;
764 813
765 return snprintf(buf, PAGE_SIZE, "%d\n", 814 return snprintf(buf, PAGE_SIZE, "%d\n",
766 bfa_get_nports(&bfad->bfa)); 815 bfa_get_nports(&bfad->bfa));
767} 816}
768 817
769static ssize_t 818static ssize_t
@@ -788,10 +837,10 @@ bfad_im_num_of_discovered_ports_show(struct device *dev,
788 837
789 rports = kzalloc(sizeof(wwn_t) * nrports , GFP_ATOMIC); 838 rports = kzalloc(sizeof(wwn_t) * nrports , GFP_ATOMIC);
790 if (rports == NULL) 839 if (rports == NULL)
791 return -ENOMEM; 840 return snprintf(buf, PAGE_SIZE, "Failed\n");
792 841
793 spin_lock_irqsave(&bfad->bfad_lock, flags); 842 spin_lock_irqsave(&bfad->bfad_lock, flags);
794 bfa_fcs_port_get_rports(port->fcs_port, rports, &nrports); 843 bfa_fcs_lport_get_rports(port->fcs_port, rports, &nrports);
795 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 844 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
796 kfree(rports); 845 kfree(rports);
797 846
@@ -837,19 +886,19 @@ struct device_attribute *bfad_im_host_attrs[] = {
837}; 886};
838 887
839struct device_attribute *bfad_im_vport_attrs[] = { 888struct device_attribute *bfad_im_vport_attrs[] = {
840 &dev_attr_serial_number, 889 &dev_attr_serial_number,
841 &dev_attr_model, 890 &dev_attr_model,
842 &dev_attr_model_description, 891 &dev_attr_model_description,
843 &dev_attr_node_name, 892 &dev_attr_node_name,
844 &dev_attr_symbolic_name, 893 &dev_attr_symbolic_name,
845 &dev_attr_hardware_version, 894 &dev_attr_hardware_version,
846 &dev_attr_driver_version, 895 &dev_attr_driver_version,
847 &dev_attr_option_rom_version, 896 &dev_attr_option_rom_version,
848 &dev_attr_firmware_version, 897 &dev_attr_firmware_version,
849 &dev_attr_number_of_ports, 898 &dev_attr_number_of_ports,
850 &dev_attr_driver_name, 899 &dev_attr_driver_name,
851 &dev_attr_number_of_discovered_ports, 900 &dev_attr_number_of_discovered_ports,
852 NULL, 901 NULL,
853}; 902};
854 903
855 904
diff --git a/drivers/scsi/bfa/bfad_attr.h b/drivers/scsi/bfa/bfad_attr.h
deleted file mode 100644
index bf0102076508..000000000000
--- a/drivers/scsi/bfa/bfad_attr.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFAD_ATTR_H__
19#define __BFAD_ATTR_H__
20
21/**
22 * FC_transport_template FC transport template
23 */
24
25struct Scsi_Host*
26bfad_os_dev_to_shost(struct scsi_target *starget);
27
28/**
29 * FC transport template entry, get SCSI target port ID.
30 */
31void
32bfad_im_get_starget_port_id(struct scsi_target *starget);
33
34/**
35 * FC transport template entry, get SCSI target nwwn.
36 */
37void
38bfad_im_get_starget_node_name(struct scsi_target *starget);
39
40/**
41 * FC transport template entry, get SCSI target pwwn.
42 */
43void
44bfad_im_get_starget_port_name(struct scsi_target *starget);
45
46/**
47 * FC transport template entry, get SCSI host port ID.
48 */
49void
50bfad_im_get_host_port_id(struct Scsi_Host *shost);
51
52struct Scsi_Host*
53bfad_os_starget_to_shost(struct scsi_target *starget);
54
55
56#endif /* __BFAD_ATTR_H__ */
diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c
index 4b82f12aad62..48be0c54f2de 100644
--- a/drivers/scsi/bfa/bfad_debugfs.c
+++ b/drivers/scsi/bfa/bfad_debugfs.c
@@ -17,8 +17,8 @@
17 17
18#include <linux/debugfs.h> 18#include <linux/debugfs.h>
19 19
20#include <bfad_drv.h> 20#include "bfad_drv.h"
21#include <bfad_im.h> 21#include "bfad_im.h"
22 22
23/* 23/*
24 * BFA debufs interface 24 * BFA debufs interface
@@ -28,10 +28,10 @@
28 * mount -t debugfs none /sys/kernel/debug 28 * mount -t debugfs none /sys/kernel/debug
29 * 29 *
30 * BFA Hierarchy: 30 * BFA Hierarchy:
31 * - bfa/host# 31 * - bfa/pci_dev:<pci_name>
32 * where the host number corresponds to the one under /sys/class/scsi_host/host# 32 * where the pci_name corresponds to the one under /sys/bus/pci/drivers/bfa
33 * 33 *
34 * Debugging service available per host: 34 * Debugging service available per pci_dev:
35 * fwtrc: To collect current firmware trace. 35 * fwtrc: To collect current firmware trace.
36 * drvtrc: To collect current driver trace 36 * drvtrc: To collect current driver trace
37 * fwsave: To collect last saved fw trace as a result of firmware crash. 37 * fwsave: To collect last saved fw trace as a result of firmware crash.
@@ -90,7 +90,7 @@ bfad_debugfs_open_fwtrc(struct inode *inode, struct file *file)
90 memset(fw_debug->debug_buffer, 0, fw_debug->buffer_len); 90 memset(fw_debug->debug_buffer, 0, fw_debug->buffer_len);
91 91
92 spin_lock_irqsave(&bfad->bfad_lock, flags); 92 spin_lock_irqsave(&bfad->bfad_lock, flags);
93 rc = bfa_debug_fwtrc(&bfad->bfa, 93 rc = bfa_ioc_debug_fwtrc(&bfad->bfa.ioc,
94 fw_debug->debug_buffer, 94 fw_debug->debug_buffer,
95 &fw_debug->buffer_len); 95 &fw_debug->buffer_len);
96 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 96 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
@@ -134,7 +134,7 @@ bfad_debugfs_open_fwsave(struct inode *inode, struct file *file)
134 memset(fw_debug->debug_buffer, 0, fw_debug->buffer_len); 134 memset(fw_debug->debug_buffer, 0, fw_debug->buffer_len);
135 135
136 spin_lock_irqsave(&bfad->bfad_lock, flags); 136 spin_lock_irqsave(&bfad->bfad_lock, flags);
137 rc = bfa_debug_fwsave(&bfad->bfa, 137 rc = bfa_ioc_debug_fwsave(&bfad->bfa.ioc,
138 fw_debug->debug_buffer, 138 fw_debug->debug_buffer,
139 &fw_debug->buffer_len); 139 &fw_debug->buffer_len);
140 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 140 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
@@ -208,7 +208,7 @@ bfad_debugfs_read(struct file *file, char __user *buf,
208 if (!debug || !debug->debug_buffer) 208 if (!debug || !debug->debug_buffer)
209 return 0; 209 return 0;
210 210
211 return memory_read_from_buffer(buf, nbytes, pos, 211 return simple_read_from_buffer(buf, nbytes, pos,
212 debug->debug_buffer, debug->buffer_len); 212 debug->debug_buffer, debug->buffer_len);
213} 213}
214 214
@@ -217,7 +217,7 @@ bfad_debugfs_read(struct file *file, char __user *buf,
217#define BFA_REG_ADDRSZ(__bfa) \ 217#define BFA_REG_ADDRSZ(__bfa) \
218 ((bfa_ioc_devid(&(__bfa)->ioc) == BFA_PCI_DEVICE_ID_CT) ? \ 218 ((bfa_ioc_devid(&(__bfa)->ioc) == BFA_PCI_DEVICE_ID_CT) ? \
219 BFA_REG_CT_ADDRSZ : BFA_REG_CB_ADDRSZ) 219 BFA_REG_CT_ADDRSZ : BFA_REG_CB_ADDRSZ)
220#define BFA_REG_ADDRMSK(__bfa) ((uint32_t)(BFA_REG_ADDRSZ(__bfa) - 1)) 220#define BFA_REG_ADDRMSK(__bfa) ((u32)(BFA_REG_ADDRSZ(__bfa) - 1))
221 221
222static bfa_status_t 222static bfa_status_t
223bfad_reg_offset_check(struct bfa_s *bfa, u32 offset, u32 len) 223bfad_reg_offset_check(struct bfa_s *bfa, u32 offset, u32 len)
@@ -254,7 +254,7 @@ bfad_debugfs_read_regrd(struct file *file, char __user *buf,
254 if (!bfad->regdata) 254 if (!bfad->regdata)
255 return 0; 255 return 0;
256 256
257 rc = memory_read_from_buffer(buf, nbytes, pos, 257 rc = simple_read_from_buffer(buf, nbytes, pos,
258 bfad->regdata, bfad->reglen); 258 bfad->regdata, bfad->reglen);
259 259
260 if ((*pos + nbytes) >= bfad->reglen) { 260 if ((*pos + nbytes) >= bfad->reglen) {
@@ -279,15 +279,31 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
279 u32 *regbuf; 279 u32 *regbuf;
280 void __iomem *rb, *reg_addr; 280 void __iomem *rb, *reg_addr;
281 unsigned long flags; 281 unsigned long flags;
282 void *kern_buf;
282 283
283 rc = sscanf(buf, "%x:%x", &addr, &len); 284 kern_buf = kzalloc(nbytes, GFP_KERNEL);
285
286 if (!kern_buf) {
287 printk(KERN_INFO "bfad[%d]: Failed to allocate buffer\n",
288 bfad->inst_no);
289 return -ENOMEM;
290 }
291
292 if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) {
293 kfree(kern_buf);
294 return -ENOMEM;
295 }
296
297 rc = sscanf(kern_buf, "%x:%x", &addr, &len);
284 if (rc < 2) { 298 if (rc < 2) {
285 printk(KERN_INFO 299 printk(KERN_INFO
286 "bfad[%d]: %s failed to read user buf\n", 300 "bfad[%d]: %s failed to read user buf\n",
287 bfad->inst_no, __func__); 301 bfad->inst_no, __func__);
302 kfree(kern_buf);
288 return -EINVAL; 303 return -EINVAL;
289 } 304 }
290 305
306 kfree(kern_buf);
291 kfree(bfad->regdata); 307 kfree(bfad->regdata);
292 bfad->regdata = NULL; 308 bfad->regdata = NULL;
293 bfad->reglen = 0; 309 bfad->reglen = 0;
@@ -318,7 +334,7 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
318 regbuf = (u32 *)bfad->regdata; 334 regbuf = (u32 *)bfad->regdata;
319 spin_lock_irqsave(&bfad->bfad_lock, flags); 335 spin_lock_irqsave(&bfad->bfad_lock, flags);
320 for (i = 0; i < len; i++) { 336 for (i = 0; i < len; i++) {
321 *regbuf = bfa_reg_read(reg_addr); 337 *regbuf = readl(reg_addr);
322 regbuf++; 338 regbuf++;
323 reg_addr += sizeof(u32); 339 reg_addr += sizeof(u32);
324 } 340 }
@@ -339,14 +355,30 @@ bfad_debugfs_write_regwr(struct file *file, const char __user *buf,
339 int addr, val, rc; 355 int addr, val, rc;
340 void __iomem *reg_addr; 356 void __iomem *reg_addr;
341 unsigned long flags; 357 unsigned long flags;
358 void *kern_buf;
342 359
343 rc = sscanf(buf, "%x:%x", &addr, &val); 360 kern_buf = kzalloc(nbytes, GFP_KERNEL);
361
362 if (!kern_buf) {
363 printk(KERN_INFO "bfad[%d]: Failed to allocate buffer\n",
364 bfad->inst_no);
365 return -ENOMEM;
366 }
367
368 if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) {
369 kfree(kern_buf);
370 return -ENOMEM;
371 }
372
373 rc = sscanf(kern_buf, "%x:%x", &addr, &val);
344 if (rc < 2) { 374 if (rc < 2) {
345 printk(KERN_INFO 375 printk(KERN_INFO
346 "bfad[%d]: %s failed to read user buf\n", 376 "bfad[%d]: %s failed to read user buf\n",
347 bfad->inst_no, __func__); 377 bfad->inst_no, __func__);
378 kfree(kern_buf);
348 return -EINVAL; 379 return -EINVAL;
349 } 380 }
381 kfree(kern_buf);
350 382
351 addr &= BFA_REG_ADDRMSK(bfa); /* offset only 17 bit and word align */ 383 addr &= BFA_REG_ADDRMSK(bfa); /* offset only 17 bit and word align */
352 384
@@ -359,9 +391,9 @@ bfad_debugfs_write_regwr(struct file *file, const char __user *buf,
359 return -EINVAL; 391 return -EINVAL;
360 } 392 }
361 393
362 reg_addr = (uint32_t *) ((uint8_t *) bfa_ioc_bar0(ioc) + addr); 394 reg_addr = (bfa_ioc_bar0(ioc)) + addr;
363 spin_lock_irqsave(&bfad->bfad_lock, flags); 395 spin_lock_irqsave(&bfad->bfad_lock, flags);
364 bfa_reg_write(reg_addr, val); 396 writel(val, reg_addr);
365 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 397 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
366 398
367 return nbytes; 399 return nbytes;
@@ -457,11 +489,9 @@ static atomic_t bfa_debugfs_port_count;
457inline void 489inline void
458bfad_debugfs_init(struct bfad_port_s *port) 490bfad_debugfs_init(struct bfad_port_s *port)
459{ 491{
460 struct bfad_im_port_s *im_port = port->im_port; 492 struct bfad_s *bfad = port->bfad;
461 struct bfad_s *bfad = im_port->bfad;
462 struct Scsi_Host *shost = im_port->shost;
463 const struct bfad_debugfs_entry *file; 493 const struct bfad_debugfs_entry *file;
464 char name[16]; 494 char name[64];
465 int i; 495 int i;
466 496
467 if (!bfa_debugfs_enable) 497 if (!bfa_debugfs_enable)
@@ -478,17 +508,15 @@ bfad_debugfs_init(struct bfad_port_s *port)
478 } 508 }
479 } 509 }
480 510
481 /* 511 /* Setup the pci_dev debugfs directory for the port */
482 * Setup the host# directory for the port, 512 snprintf(name, sizeof(name), "pci_dev:%s", bfad->pci_name);
483 * corresponds to the scsi_host num of this port.
484 */
485 snprintf(name, sizeof(name), "host%d", shost->host_no);
486 if (!port->port_debugfs_root) { 513 if (!port->port_debugfs_root) {
487 port->port_debugfs_root = 514 port->port_debugfs_root =
488 debugfs_create_dir(name, bfa_debugfs_root); 515 debugfs_create_dir(name, bfa_debugfs_root);
489 if (!port->port_debugfs_root) { 516 if (!port->port_debugfs_root) {
490 printk(KERN_WARNING 517 printk(KERN_WARNING
491 "BFA host root dir creation failed\n"); 518 "bfa %s: debugfs root creation failed\n",
519 bfad->pci_name);
492 goto err; 520 goto err;
493 } 521 }
494 522
@@ -504,8 +532,8 @@ bfad_debugfs_init(struct bfad_port_s *port)
504 file->fops); 532 file->fops);
505 if (!bfad->bfad_dentry_files[i]) { 533 if (!bfad->bfad_dentry_files[i]) {
506 printk(KERN_WARNING 534 printk(KERN_WARNING
507 "BFA host%d: create %s entry failed\n", 535 "bfa %s: debugfs %s creation failed\n",
508 shost->host_no, file->name); 536 bfad->pci_name, file->name);
509 goto err; 537 goto err;
510 } 538 }
511 } 539 }
@@ -518,8 +546,7 @@ err:
518inline void 546inline void
519bfad_debugfs_exit(struct bfad_port_s *port) 547bfad_debugfs_exit(struct bfad_port_s *port)
520{ 548{
521 struct bfad_im_port_s *im_port = port->im_port; 549 struct bfad_s *bfad = port->bfad;
522 struct bfad_s *bfad = im_port->bfad;
523 int i; 550 int i;
524 551
525 for (i = 0; i < ARRAY_SIZE(bfad_debugfs_files); i++) { 552 for (i = 0; i < ARRAY_SIZE(bfad_debugfs_files); i++) {
@@ -530,9 +557,7 @@ bfad_debugfs_exit(struct bfad_port_s *port)
530 } 557 }
531 558
532 /* 559 /*
533 * Remove the host# directory for the port, 560 * Remove the pci_dev debugfs directory for the port */
534 * corresponds to the scsi_host num of this port.
535 */
536 if (port->port_debugfs_root) { 561 if (port->port_debugfs_root) {
537 debugfs_remove(port->port_debugfs_root); 562 debugfs_remove(port->port_debugfs_root);
538 port->port_debugfs_root = NULL; 563 port->port_debugfs_root = NULL;
diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h
index 465b8b86ec9c..7f9ea90254cd 100644
--- a/drivers/scsi/bfa/bfad_drv.h
+++ b/drivers/scsi/bfa/bfad_drv.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,43 +15,56 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18/** 18/*
19 * Contains base driver definitions. 19 * Contains base driver definitions.
20 */ 20 */
21 21
22/** 22/*
23 * bfa_drv.h Linux driver data structures. 23 * bfa_drv.h Linux driver data structures.
24 */ 24 */
25 25
26#ifndef __BFAD_DRV_H__ 26#ifndef __BFAD_DRV_H__
27#define __BFAD_DRV_H__ 27#define __BFAD_DRV_H__
28 28
29#include "bfa_os_inc.h" 29#include <linux/types.h>
30 30#include <linux/version.h>
31#include <bfa.h> 31#include <linux/pci.h>
32#include <bfa_svc.h> 32#include <linux/dma-mapping.h>
33#include <fcs/bfa_fcs.h> 33#include <linux/idr.h>
34#include <defs/bfa_defs_pci.h> 34#include <linux/interrupt.h>
35#include <defs/bfa_defs_port.h> 35#include <linux/cdev.h>
36#include <defs/bfa_defs_rport.h> 36#include <linux/fs.h>
37#include <fcs/bfa_fcs_rport.h> 37#include <linux/delay.h>
38#include <defs/bfa_defs_vport.h> 38#include <linux/vmalloc.h>
39#include <fcs/bfa_fcs_vport.h> 39#include <linux/workqueue.h>
40 40#include <linux/bitops.h>
41#include <cs/bfa_plog.h> 41#include <scsi/scsi.h>
42#include "aen/bfa_aen.h" 42#include <scsi/scsi_host.h>
43#include <log/bfa_log_linux.h> 43#include <scsi/scsi_tcq.h>
44 44#include <scsi/scsi_transport_fc.h>
45#define BFAD_DRIVER_NAME "bfa" 45#include <scsi/scsi_transport.h>
46
47#include "bfa_modules.h"
48#include "bfa_fcs.h"
49#include "bfa_defs_fcs.h"
50
51#include "bfa_plog.h"
52#include "bfa_cs.h"
53
54#define BFAD_DRIVER_NAME "bfa"
46#ifdef BFA_DRIVER_VERSION 55#ifdef BFA_DRIVER_VERSION
47#define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION 56#define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION
48#else 57#else
49#define BFAD_DRIVER_VERSION "2.2.2.1" 58#define BFAD_DRIVER_VERSION "2.3.2.3"
50#endif 59#endif
51 60
52 61#define BFAD_PROTO_NAME FCPI_NAME
53#define BFAD_IRQ_FLAGS IRQF_SHARED 62#define BFAD_IRQ_FLAGS IRQF_SHARED
54 63
64#ifndef FC_PORTSPEED_8GBIT
65#define FC_PORTSPEED_8GBIT 0x10
66#endif
67
55/* 68/*
56 * BFAD flags 69 * BFAD flags
57 */ 70 */
@@ -62,9 +75,9 @@
62#define BFAD_HAL_START_DONE 0x00000010 75#define BFAD_HAL_START_DONE 0x00000010
63#define BFAD_PORT_ONLINE 0x00000020 76#define BFAD_PORT_ONLINE 0x00000020
64#define BFAD_RPORT_ONLINE 0x00000040 77#define BFAD_RPORT_ONLINE 0x00000040
65#define BFAD_FCS_INIT_DONE 0x00000080 78#define BFAD_FCS_INIT_DONE 0x00000080
66#define BFAD_HAL_INIT_FAIL 0x00000100 79#define BFAD_HAL_INIT_FAIL 0x00000100
67#define BFAD_FC4_PROBE_DONE 0x00000200 80#define BFAD_FC4_PROBE_DONE 0x00000200
68#define BFAD_PORT_DELETE 0x00000001 81#define BFAD_PORT_DELETE 0x00000001
69 82
70/* 83/*
@@ -77,8 +90,8 @@
77/* 90/*
78 * BFAD configuration parameter default values 91 * BFAD configuration parameter default values
79 */ 92 */
80#define BFAD_LUN_QUEUE_DEPTH 32 93#define BFAD_LUN_QUEUE_DEPTH 32
81#define BFAD_IO_MAX_SGE SG_ALL 94#define BFAD_IO_MAX_SGE SG_ALL
82 95
83#define bfad_isr_t irq_handler_t 96#define bfad_isr_t irq_handler_t
84 97
@@ -87,6 +100,16 @@
87struct bfad_msix_s { 100struct bfad_msix_s {
88 struct bfad_s *bfad; 101 struct bfad_s *bfad;
89 struct msix_entry msix; 102 struct msix_entry msix;
103 char name[32];
104};
105
106/*
107 * Only append to the enums defined here to avoid any versioning
108 * needed between trace utility and driver version
109 */
110enum {
111 BFA_TRC_LDRV_BFAD = 1,
112 BFA_TRC_LDRV_IM = 2,
90}; 113};
91 114
92enum bfad_port_pvb_type { 115enum bfad_port_pvb_type {
@@ -101,17 +124,13 @@ enum bfad_port_pvb_type {
101 */ 124 */
102struct bfad_port_s { 125struct bfad_port_s {
103 struct list_head list_entry; 126 struct list_head list_entry;
104 struct bfad_s *bfad; 127 struct bfad_s *bfad;
105 struct bfa_fcs_port_s *fcs_port; 128 struct bfa_fcs_lport_s *fcs_port;
106 u32 roles; 129 u32 roles;
107 s32 flags; 130 s32 flags;
108 u32 supported_fc4s; 131 u32 supported_fc4s;
109 u8 ipfc_flags;
110 enum bfad_port_pvb_type pvb_type; 132 enum bfad_port_pvb_type pvb_type;
111 struct bfad_im_port_s *im_port; /* IM specific data */ 133 struct bfad_im_port_s *im_port; /* IM specific data */
112 struct bfad_tm_port_s *tm_port; /* TM specific data */
113 struct bfad_ipfc_port_s *ipfc_port; /* IPFC specific data */
114
115 /* port debugfs specific data */ 134 /* port debugfs specific data */
116 struct dentry *port_debugfs_root; 135 struct dentry *port_debugfs_root;
117}; 136};
@@ -124,7 +143,6 @@ struct bfad_vport_s {
124 struct bfa_fcs_vport_s fcs_vport; 143 struct bfa_fcs_vport_s fcs_vport;
125 struct completion *comp_del; 144 struct completion *comp_del;
126 struct list_head list_entry; 145 struct list_head list_entry;
127 struct bfa_port_cfg_s port_cfg;
128}; 146};
129 147
130/* 148/*
@@ -137,20 +155,35 @@ struct bfad_vf_s {
137}; 155};
138 156
139struct bfad_cfg_param_s { 157struct bfad_cfg_param_s {
140 u32 rport_del_timeout; 158 u32 rport_del_timeout;
141 u32 ioc_queue_depth; 159 u32 ioc_queue_depth;
142 u32 lun_queue_depth; 160 u32 lun_queue_depth;
143 u32 io_max_sge; 161 u32 io_max_sge;
144 u32 binding_method; 162 u32 binding_method;
163};
164
165union bfad_tmp_buf {
166 /* From struct bfa_adapter_attr_s */
167 char manufacturer[BFA_ADAPTER_MFG_NAME_LEN];
168 char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
169 char model[BFA_ADAPTER_MODEL_NAME_LEN];
170 char fw_ver[BFA_VERSION_LEN];
171 char optrom_ver[BFA_VERSION_LEN];
172
173 /* From struct bfa_ioc_pci_attr_s */
174 u8 chip_rev[BFA_IOC_CHIP_REV_LEN]; /* chip revision */
175
176 wwn_t wwn[BFA_FCS_MAX_LPORTS];
145}; 177};
146 178
147/* 179/*
148 * BFAD (PCI function) data structure 180 * BFAD (PCI function) data structure
149 */ 181 */
150struct bfad_s { 182struct bfad_s {
183 bfa_sm_t sm; /* state machine */
151 struct list_head list_entry; 184 struct list_head list_entry;
152 struct bfa_s bfa; 185 struct bfa_s bfa;
153 struct bfa_fcs_s bfa_fcs; 186 struct bfa_fcs_s bfa_fcs;
154 struct pci_dev *pcidev; 187 struct pci_dev *pcidev;
155 const char *pci_name; 188 const char *pci_name;
156 struct bfa_pcidev_s hal_pcidev; 189 struct bfa_pcidev_s hal_pcidev;
@@ -163,41 +196,41 @@ struct bfad_s {
163 struct bfad_port_s pport; /* physical port of the BFAD */ 196 struct bfad_port_s pport; /* physical port of the BFAD */
164 struct bfa_meminfo_s meminfo; 197 struct bfa_meminfo_s meminfo;
165 struct bfa_iocfc_cfg_s ioc_cfg; 198 struct bfa_iocfc_cfg_s ioc_cfg;
166 u32 inst_no; /* BFAD instance number */ 199 u32 inst_no; /* BFAD instance number */
167 u32 bfad_flags; 200 u32 bfad_flags;
168 spinlock_t bfad_lock; 201 spinlock_t bfad_lock;
169 struct task_struct *bfad_tsk; 202 struct task_struct *bfad_tsk;
170 struct bfad_cfg_param_s cfg_data; 203 struct bfad_cfg_param_s cfg_data;
171 struct bfad_msix_s msix_tab[MAX_MSIX_ENTRY]; 204 struct bfad_msix_s msix_tab[MAX_MSIX_ENTRY];
172 int nvec; 205 int nvec;
173 char adapter_name[BFA_ADAPTER_SYM_NAME_LEN]; 206 char adapter_name[BFA_ADAPTER_SYM_NAME_LEN];
174 char port_name[BFA_ADAPTER_SYM_NAME_LEN]; 207 char port_name[BFA_ADAPTER_SYM_NAME_LEN];
175 struct timer_list hal_tmo; 208 struct timer_list hal_tmo;
176 unsigned long hs_start; 209 unsigned long hs_start;
177 struct bfad_im_s *im; /* IM specific data */ 210 struct bfad_im_s *im; /* IM specific data */
178 struct bfad_tm_s *tm; /* TM specific data */
179 struct bfad_ipfc_s *ipfc; /* IPFC specific data */
180 struct bfa_log_mod_s log_data;
181 struct bfa_trc_mod_s *trcmod; 211 struct bfa_trc_mod_s *trcmod;
182 struct bfa_log_mod_s *logmod;
183 struct bfa_aen_s *aen;
184 struct bfa_aen_s aen_buf;
185 void *file_map[BFA_AEN_MAX_APP];
186 struct bfa_plog_s plog_buf; 212 struct bfa_plog_s plog_buf;
187 int ref_count; 213 int ref_count;
188 bfa_boolean_t ipfc_enabled; 214 union bfad_tmp_buf tmp_buf;
189 struct fc_host_statistics link_stats; 215 struct fc_host_statistics link_stats;
190 struct list_head pbc_pcfg_list; 216 struct list_head pbc_vport_list;
191 atomic_t wq_reqcnt;
192 /* debugfs specific data */ 217 /* debugfs specific data */
193 char *regdata; 218 char *regdata;
194 u32 reglen; 219 u32 reglen;
195 struct dentry *bfad_dentry_files[5]; 220 struct dentry *bfad_dentry_files[5];
196}; 221};
197 222
198struct bfad_pcfg_s { 223/* BFAD state machine events */
199 struct list_head list_entry; 224enum bfad_sm_event {
200 struct bfa_port_cfg_s port_cfg; 225 BFAD_E_CREATE = 1,
226 BFAD_E_KTHREAD_CREATE_FAILED = 2,
227 BFAD_E_INIT = 3,
228 BFAD_E_INIT_SUCCESS = 4,
229 BFAD_E_INIT_FAILED = 5,
230 BFAD_E_INTR_INIT_FAILED = 6,
231 BFAD_E_FCS_EXIT_COMP = 7,
232 BFAD_E_EXIT_COMP = 8,
233 BFAD_E_STOP = 9
201}; 234};
202 235
203/* 236/*
@@ -208,30 +241,30 @@ struct bfad_rport_s {
208}; 241};
209 242
210struct bfad_buf_info { 243struct bfad_buf_info {
211 void *virt; 244 void *virt;
212 dma_addr_t phys; 245 dma_addr_t phys;
213 u32 size; 246 u32 size;
214}; 247};
215 248
216struct bfad_fcxp { 249struct bfad_fcxp {
217 struct bfad_port_s *port; 250 struct bfad_port_s *port;
218 struct bfa_rport_s *bfa_rport; 251 struct bfa_rport_s *bfa_rport;
219 bfa_status_t req_status; 252 bfa_status_t req_status;
220 u16 tag; 253 u16 tag;
221 u16 rsp_len; 254 u16 rsp_len;
222 u16 rsp_maxlen; 255 u16 rsp_maxlen;
223 u8 use_ireqbuf; 256 u8 use_ireqbuf;
224 u8 use_irspbuf; 257 u8 use_irspbuf;
225 u32 num_req_sgles; 258 u32 num_req_sgles;
226 u32 num_rsp_sgles; 259 u32 num_rsp_sgles;
227 struct fchs_s fchs; 260 struct fchs_s fchs;
228 void *reqbuf_info; 261 void *reqbuf_info;
229 void *rspbuf_info; 262 void *rspbuf_info;
230 struct bfa_sge_s *req_sge; 263 struct bfa_sge_s *req_sge;
231 struct bfa_sge_s *rsp_sge; 264 struct bfa_sge_s *rsp_sge;
232 fcxp_send_cb_t send_cbfn; 265 fcxp_send_cb_t send_cbfn;
233 void *send_cbarg; 266 void *send_cbarg;
234 void *bfa_fcxp; 267 void *bfa_fcxp;
235 struct completion comp; 268 struct completion comp;
236}; 269};
237 270
@@ -244,60 +277,83 @@ struct bfad_hal_comp {
244 * Macro to obtain the immediate lower power 277 * Macro to obtain the immediate lower power
245 * of two for the integer. 278 * of two for the integer.
246 */ 279 */
247#define nextLowerInt(x) \ 280#define nextLowerInt(x) \
248do { \ 281do { \
249 int j; \ 282 int __i; \
250 (*x)--; \ 283 (*x)--; \
251 for (j = 1; j < (sizeof(int) * 8); j <<= 1) \ 284 for (__i = 1; __i < (sizeof(int)*8); __i <<= 1) \
252 (*x) = (*x) | (*x) >> j; \ 285 (*x) = (*x) | (*x) >> __i; \
253 (*x)++; \ 286 (*x)++; \
254 (*x) = (*x) >> 1; \ 287 (*x) = (*x) >> 1; \
255} while (0) 288} while (0)
256 289
257 290
258bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id, 291#define BFA_LOG(level, bfad, mask, fmt, arg...) \
259 struct bfa_port_cfg_s *port_cfg, struct device *dev); 292do { \
260bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id, 293 if (((mask) == 4) || (level[1] <= '4')) \
261 struct bfa_port_cfg_s *port_cfg); 294 dev_printk(level, &((bfad)->pcidev)->dev, fmt, ##arg); \
262bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_port_role role); 295} while (0)
263bfa_status_t bfad_drv_init(struct bfad_s *bfad);
264bfa_status_t bfad_start_ops(struct bfad_s *bfad);
265void bfad_drv_start(struct bfad_s *bfad);
266void bfad_uncfg_pport(struct bfad_s *bfad);
267void bfad_drv_stop(struct bfad_s *bfad);
268void bfad_remove_intr(struct bfad_s *bfad);
269void bfad_hal_mem_release(struct bfad_s *bfad);
270void bfad_hcb_comp(void *arg, bfa_status_t status);
271
272int bfad_setup_intr(struct bfad_s *bfad);
273void bfad_remove_intr(struct bfad_s *bfad);
274 296
297bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id,
298 struct bfa_lport_cfg_s *port_cfg,
299 struct device *dev);
300bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id,
301 struct bfa_lport_cfg_s *port_cfg);
302bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_lport_role role);
303bfa_status_t bfad_drv_init(struct bfad_s *bfad);
304bfa_status_t bfad_start_ops(struct bfad_s *bfad);
305void bfad_drv_start(struct bfad_s *bfad);
306void bfad_uncfg_pport(struct bfad_s *bfad);
307void bfad_stop(struct bfad_s *bfad);
308void bfad_fcs_stop(struct bfad_s *bfad);
309void bfad_remove_intr(struct bfad_s *bfad);
310void bfad_hal_mem_release(struct bfad_s *bfad);
311void bfad_hcb_comp(void *arg, bfa_status_t status);
312
313int bfad_setup_intr(struct bfad_s *bfad);
314void bfad_remove_intr(struct bfad_s *bfad);
275void bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg); 315void bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg);
276bfa_status_t bfad_hal_mem_alloc(struct bfad_s *bfad); 316bfa_status_t bfad_hal_mem_alloc(struct bfad_s *bfad);
277void bfad_bfa_tmo(unsigned long data); 317void bfad_bfa_tmo(unsigned long data);
278void bfad_init_timer(struct bfad_s *bfad); 318void bfad_init_timer(struct bfad_s *bfad);
279int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad); 319int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad);
280void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad); 320void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad);
281void bfad_fcs_port_cfg(struct bfad_s *bfad);
282void bfad_drv_uninit(struct bfad_s *bfad); 321void bfad_drv_uninit(struct bfad_s *bfad);
283void bfad_drv_log_level_set(struct bfad_s *bfad);
284bfa_status_t bfad_fc4_module_init(void);
285void bfad_fc4_module_exit(void);
286int bfad_worker(void *ptr); 322int bfad_worker(void *ptr);
287void bfad_debugfs_init(struct bfad_port_s *port); 323void bfad_debugfs_init(struct bfad_port_s *port);
288void bfad_debugfs_exit(struct bfad_port_s *port); 324void bfad_debugfs_exit(struct bfad_port_s *port);
289 325
290void bfad_pci_remove(struct pci_dev *pdev); 326void bfad_pci_remove(struct pci_dev *pdev);
291int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid); 327int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid);
292void bfad_os_rport_online_wait(struct bfad_s *bfad); 328void bfad_rport_online_wait(struct bfad_s *bfad);
293int bfad_os_get_linkup_delay(struct bfad_s *bfad); 329int bfad_get_linkup_delay(struct bfad_s *bfad);
294int bfad_install_msix_handler(struct bfad_s *bfad); 330int bfad_install_msix_handler(struct bfad_s *bfad);
295 331
296extern struct idr bfad_im_port_index; 332extern struct idr bfad_im_port_index;
333extern struct pci_device_id bfad_id_table[];
297extern struct list_head bfad_list; 334extern struct list_head bfad_list;
298extern int bfa_lun_queue_depth; 335extern char *os_name;
299extern int bfad_supported_fc4s; 336extern char *os_patch;
300extern int bfa_linkup_delay; 337extern char *host_name;
338extern int num_rports;
339extern int num_ios;
340extern int num_tms;
341extern int num_fcxps;
342extern int num_ufbufs;
343extern int reqq_size;
344extern int rspq_size;
345extern int num_sgpgs;
346extern int rport_del_timeout;
347extern int bfa_lun_queue_depth;
348extern int bfa_io_max_sge;
349extern int bfa_log_level;
350extern int ioc_auto_recover;
351extern int bfa_linkup_delay;
352extern int msix_disable_cb;
353extern int msix_disable_ct;
354extern int fdmi_enable;
355extern int supported_fc4s;
356extern int pcie_max_read_reqsz;
301extern int bfa_debugfs_enable; 357extern int bfa_debugfs_enable;
302extern struct mutex bfad_mutex; 358extern struct mutex bfad_mutex;
303 359
diff --git a/drivers/scsi/bfa/bfad_fwimg.c b/drivers/scsi/bfa/bfad_fwimg.c
deleted file mode 100644
index 1baca1a12085..000000000000
--- a/drivers/scsi/bfa/bfad_fwimg.c
+++ /dev/null
@@ -1,131 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfad_fwimg.c Linux driver PCI interface module.
20 */
21#include <bfa_os_inc.h>
22#include <bfad_drv.h>
23#include <bfad_im_compat.h>
24#include <defs/bfa_defs_version.h>
25#include <linux/errno.h>
26#include <linux/sched.h>
27#include <linux/init.h>
28#include <linux/fs.h>
29#include <asm/uaccess.h>
30#include <asm/fcntl.h>
31#include <linux/pci.h>
32#include <linux/firmware.h>
33#include <bfa_fwimg_priv.h>
34#include <bfa.h>
35
36u32 bfi_image_ct_fc_size;
37u32 bfi_image_ct_cna_size;
38u32 bfi_image_cb_fc_size;
39u32 *bfi_image_ct_fc;
40u32 *bfi_image_ct_cna;
41u32 *bfi_image_cb_fc;
42
43
44#define BFAD_FW_FILE_CT_FC "ctfw_fc.bin"
45#define BFAD_FW_FILE_CT_CNA "ctfw_cna.bin"
46#define BFAD_FW_FILE_CB_FC "cbfw_fc.bin"
47MODULE_FIRMWARE(BFAD_FW_FILE_CT_FC);
48MODULE_FIRMWARE(BFAD_FW_FILE_CT_CNA);
49MODULE_FIRMWARE(BFAD_FW_FILE_CB_FC);
50
51u32 *
52bfad_read_firmware(struct pci_dev *pdev, u32 **bfi_image,
53 u32 *bfi_image_size, char *fw_name)
54{
55 const struct firmware *fw;
56
57 if (request_firmware(&fw, fw_name, &pdev->dev)) {
58 printk(KERN_ALERT "Can't locate firmware %s\n", fw_name);
59 goto error;
60 }
61
62 *bfi_image = vmalloc(fw->size);
63 if (NULL == *bfi_image) {
64 printk(KERN_ALERT "Fail to allocate buffer for fw image "
65 "size=%x!\n", (u32) fw->size);
66 goto error;
67 }
68
69 memcpy(*bfi_image, fw->data, fw->size);
70 *bfi_image_size = fw->size/sizeof(u32);
71
72 return *bfi_image;
73
74error:
75 return NULL;
76}
77
78u32 *
79bfad_get_firmware_buf(struct pci_dev *pdev)
80{
81 if (pdev->device == BFA_PCI_DEVICE_ID_CT_FC) {
82 if (bfi_image_ct_fc_size == 0)
83 bfad_read_firmware(pdev, &bfi_image_ct_fc,
84 &bfi_image_ct_fc_size, BFAD_FW_FILE_CT_FC);
85 return bfi_image_ct_fc;
86 } else if (pdev->device == BFA_PCI_DEVICE_ID_CT) {
87 if (bfi_image_ct_cna_size == 0)
88 bfad_read_firmware(pdev, &bfi_image_ct_cna,
89 &bfi_image_ct_cna_size, BFAD_FW_FILE_CT_CNA);
90 return bfi_image_ct_cna;
91 } else {
92 if (bfi_image_cb_fc_size == 0)
93 bfad_read_firmware(pdev, &bfi_image_cb_fc,
94 &bfi_image_cb_fc_size, BFAD_FW_FILE_CB_FC);
95 return bfi_image_cb_fc;
96 }
97}
98
99u32 *
100bfi_image_ct_fc_get_chunk(u32 off)
101{ return (u32 *)(bfi_image_ct_fc + off); }
102
103u32 *
104bfi_image_ct_cna_get_chunk(u32 off)
105{ return (u32 *)(bfi_image_ct_cna + off); }
106
107u32 *
108bfi_image_cb_fc_get_chunk(u32 off)
109{ return (u32 *)(bfi_image_cb_fc + off); }
110
111uint32_t *
112bfi_image_get_chunk(int type, uint32_t off)
113{
114 switch (type) {
115 case BFI_IMAGE_CT_FC: return bfi_image_ct_fc_get_chunk(off); break;
116 case BFI_IMAGE_CT_CNA: return bfi_image_ct_cna_get_chunk(off); break;
117 case BFI_IMAGE_CB_FC: return bfi_image_cb_fc_get_chunk(off); break;
118 default: return 0; break;
119 }
120}
121
122uint32_t
123bfi_image_get_size(int type)
124{
125 switch (type) {
126 case BFI_IMAGE_CT_FC: return bfi_image_ct_fc_size; break;
127 case BFI_IMAGE_CT_CNA: return bfi_image_ct_cna_size; break;
128 case BFI_IMAGE_CB_FC: return bfi_image_cb_fc_size; break;
129 default: return 0; break;
130 }
131}
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 6ef87f6fcdbb..c2b36179e8e8 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -15,16 +15,13 @@
15 * General Public License for more details. 15 * General Public License for more details.
16 */ 16 */
17 17
18/** 18/*
19 * bfad_im.c Linux driver IM module. 19 * bfad_im.c Linux driver IM module.
20 */ 20 */
21 21
22#include <linux/slab.h>
23#include "bfad_drv.h" 22#include "bfad_drv.h"
24#include "bfad_im.h" 23#include "bfad_im.h"
25#include "bfad_trcmod.h" 24#include "bfa_fcs.h"
26#include "bfa_cb_ioim_macros.h"
27#include <fcb/bfa_fcb_fcpim.h>
28 25
29BFA_TRC_FILE(LDRV, IM); 26BFA_TRC_FILE(LDRV, IM);
30 27
@@ -32,9 +29,10 @@ DEFINE_IDR(bfad_im_port_index);
32struct scsi_transport_template *bfad_im_scsi_transport_template; 29struct scsi_transport_template *bfad_im_scsi_transport_template;
33struct scsi_transport_template *bfad_im_scsi_vport_transport_template; 30struct scsi_transport_template *bfad_im_scsi_vport_transport_template;
34static void bfad_im_itnim_work_handler(struct work_struct *work); 31static void bfad_im_itnim_work_handler(struct work_struct *work);
35static int bfad_im_queuecommand(struct scsi_cmnd *cmnd, 32static int bfad_im_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmnd);
36 void (*done)(struct scsi_cmnd *));
37static int bfad_im_slave_alloc(struct scsi_device *sdev); 33static int bfad_im_slave_alloc(struct scsi_device *sdev);
34static void bfad_im_fc_rport_add(struct bfad_im_port_s *im_port,
35 struct bfad_itnim_s *itnim);
38 36
39void 37void
40bfa_cb_ioim_done(void *drv, struct bfad_ioim_s *dio, 38bfa_cb_ioim_done(void *drv, struct bfad_ioim_s *dio,
@@ -58,6 +56,7 @@ bfa_cb_ioim_done(void *drv, struct bfad_ioim_s *dio,
58 sns_len = SCSI_SENSE_BUFFERSIZE; 56 sns_len = SCSI_SENSE_BUFFERSIZE;
59 memcpy(cmnd->sense_buffer, sns_info, sns_len); 57 memcpy(cmnd->sense_buffer, sns_info, sns_len);
60 } 58 }
59
61 if (residue > 0) { 60 if (residue > 0) {
62 bfa_trc(bfad, residue); 61 bfa_trc(bfad, residue);
63 scsi_set_resid(cmnd, residue); 62 scsi_set_resid(cmnd, residue);
@@ -76,7 +75,8 @@ bfa_cb_ioim_done(void *drv, struct bfad_ioim_s *dio,
76 case BFI_IOIM_STS_TIMEDOUT: 75 case BFI_IOIM_STS_TIMEDOUT:
77 case BFI_IOIM_STS_PATHTOV: 76 case BFI_IOIM_STS_PATHTOV:
78 default: 77 default:
79 cmnd->result = ScsiResult(DID_ERROR, 0); 78 host_status = DID_ERROR;
79 cmnd->result = ScsiResult(host_status, 0);
80 } 80 }
81 81
82 /* Unmap DMA, if host is NULL, it means a scsi passthru cmd */ 82 /* Unmap DMA, if host is NULL, it means a scsi passthru cmd */
@@ -92,10 +92,10 @@ bfa_cb_ioim_done(void *drv, struct bfad_ioim_s *dio,
92 if (!cmnd->result && itnim && 92 if (!cmnd->result && itnim &&
93 (bfa_lun_queue_depth > cmnd->device->queue_depth)) { 93 (bfa_lun_queue_depth > cmnd->device->queue_depth)) {
94 /* Queue depth adjustment for good status completion */ 94 /* Queue depth adjustment for good status completion */
95 bfad_os_ramp_up_qdepth(itnim, cmnd->device); 95 bfad_ramp_up_qdepth(itnim, cmnd->device);
96 } else if (cmnd->result == SAM_STAT_TASK_SET_FULL && itnim) { 96 } else if (cmnd->result == SAM_STAT_TASK_SET_FULL && itnim) {
97 /* qfull handling */ 97 /* qfull handling */
98 bfad_os_handle_qfull(itnim, cmnd->device); 98 bfad_handle_qfull(itnim, cmnd->device);
99 } 99 }
100 } 100 }
101 101
@@ -123,7 +123,7 @@ bfa_cb_ioim_good_comp(void *drv, struct bfad_ioim_s *dio)
123 if (itnim_data) { 123 if (itnim_data) {
124 itnim = itnim_data->itnim; 124 itnim = itnim_data->itnim;
125 if (itnim) 125 if (itnim)
126 bfad_os_ramp_up_qdepth(itnim, cmnd->device); 126 bfad_ramp_up_qdepth(itnim, cmnd->device);
127 } 127 }
128 } 128 }
129 129
@@ -162,15 +162,10 @@ bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk,
162 wake_up(wq); 162 wake_up(wq);
163} 163}
164 164
165void 165/*
166bfa_cb_ioim_resfree(void *drv)
167{
168}
169
170/**
171 * Scsi_Host_template SCSI host template 166 * Scsi_Host_template SCSI host template
172 */ 167 */
173/** 168/*
174 * Scsi_Host template entry, returns BFAD PCI info. 169 * Scsi_Host template entry, returns BFAD PCI info.
175 */ 170 */
176static const char * 171static const char *
@@ -179,19 +174,27 @@ bfad_im_info(struct Scsi_Host *shost)
179 static char bfa_buf[256]; 174 static char bfa_buf[256];
180 struct bfad_im_port_s *im_port = 175 struct bfad_im_port_s *im_port =
181 (struct bfad_im_port_s *) shost->hostdata[0]; 176 (struct bfad_im_port_s *) shost->hostdata[0];
182 struct bfad_s *bfad = im_port->bfad; 177 struct bfad_s *bfad = im_port->bfad;
178 struct bfa_s *bfa = &bfad->bfa;
179 struct bfa_ioc_s *ioc = &bfa->ioc;
183 char model[BFA_ADAPTER_MODEL_NAME_LEN]; 180 char model[BFA_ADAPTER_MODEL_NAME_LEN];
184 181
185 bfa_get_adapter_model(&bfad->bfa, model); 182 bfa_get_adapter_model(bfa, model);
186 183
187 memset(bfa_buf, 0, sizeof(bfa_buf)); 184 memset(bfa_buf, 0, sizeof(bfa_buf));
188 snprintf(bfa_buf, sizeof(bfa_buf), 185 if (ioc->ctdev && !ioc->fcmode)
189 "Brocade FC/FCOE Adapter, " "model: %s hwpath: %s driver: %s", 186 snprintf(bfa_buf, sizeof(bfa_buf),
187 "Brocade FCOE Adapter, " "model: %s hwpath: %s driver: %s",
188 model, bfad->pci_name, BFAD_DRIVER_VERSION);
189 else
190 snprintf(bfa_buf, sizeof(bfa_buf),
191 "Brocade FC Adapter, " "model: %s hwpath: %s driver: %s",
190 model, bfad->pci_name, BFAD_DRIVER_VERSION); 192 model, bfad->pci_name, BFAD_DRIVER_VERSION);
193
191 return bfa_buf; 194 return bfa_buf;
192} 195}
193 196
194/** 197/*
195 * Scsi_Host template entry, aborts the specified SCSI command. 198 * Scsi_Host template entry, aborts the specified SCSI command.
196 * 199 *
197 * Returns: SUCCESS or FAILED. 200 * Returns: SUCCESS or FAILED.
@@ -221,9 +224,10 @@ bfad_im_abort_handler(struct scsi_cmnd *cmnd)
221 } 224 }
222 225
223 bfa_trc(bfad, hal_io->iotag); 226 bfa_trc(bfad, hal_io->iotag);
224 bfa_log(bfad->logmod, BFA_LOG_LINUX_SCSI_ABORT, 227 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
228 "scsi%d: abort cmnd %p iotag %x\n",
225 im_port->shost->host_no, cmnd, hal_io->iotag); 229 im_port->shost->host_no, cmnd, hal_io->iotag);
226 bfa_ioim_abort(hal_io); 230 (void) bfa_ioim_abort(hal_io);
227 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 231 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
228 232
229 /* Need to wait until the command get aborted */ 233 /* Need to wait until the command get aborted */
@@ -237,7 +241,8 @@ bfad_im_abort_handler(struct scsi_cmnd *cmnd)
237 241
238 cmnd->scsi_done(cmnd); 242 cmnd->scsi_done(cmnd);
239 bfa_trc(bfad, hal_io->iotag); 243 bfa_trc(bfad, hal_io->iotag);
240 bfa_log(bfad->logmod, BFA_LOG_LINUX_SCSI_ABORT_COMP, 244 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
245 "scsi%d: complete abort 0x%p iotag 0x%x\n",
241 im_port->shost->host_no, cmnd, hal_io->iotag); 246 im_port->shost->host_no, cmnd, hal_io->iotag);
242 return SUCCESS; 247 return SUCCESS;
243out: 248out:
@@ -252,11 +257,12 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd,
252 struct bfa_tskim_s *tskim; 257 struct bfa_tskim_s *tskim;
253 struct bfa_itnim_s *bfa_itnim; 258 struct bfa_itnim_s *bfa_itnim;
254 bfa_status_t rc = BFA_STATUS_OK; 259 bfa_status_t rc = BFA_STATUS_OK;
260 struct scsi_lun scsilun;
255 261
256 tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) cmnd); 262 tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) cmnd);
257 if (!tskim) { 263 if (!tskim) {
258 BFA_DEV_PRINTF(bfad, BFA_ERR, 264 BFA_LOG(KERN_ERR, bfad, bfa_log_level,
259 "target reset, fail to allocate tskim\n"); 265 "target reset, fail to allocate tskim\n");
260 rc = BFA_STATUS_FAILED; 266 rc = BFA_STATUS_FAILED;
261 goto out; 267 goto out;
262 } 268 }
@@ -268,13 +274,14 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd,
268 cmnd->host_scribble = NULL; 274 cmnd->host_scribble = NULL;
269 cmnd->SCp.Status = 0; 275 cmnd->SCp.Status = 0;
270 bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim); 276 bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim);
271 bfa_tskim_start(tskim, bfa_itnim, (lun_t)0, 277 memset(&scsilun, 0, sizeof(scsilun));
278 bfa_tskim_start(tskim, bfa_itnim, scsilun,
272 FCP_TM_TARGET_RESET, BFAD_TARGET_RESET_TMO); 279 FCP_TM_TARGET_RESET, BFAD_TARGET_RESET_TMO);
273out: 280out:
274 return rc; 281 return rc;
275} 282}
276 283
277/** 284/*
278 * Scsi_Host template entry, resets a LUN and abort its all commands. 285 * Scsi_Host template entry, resets a LUN and abort its all commands.
279 * 286 *
280 * Returns: SUCCESS or FAILED. 287 * Returns: SUCCESS or FAILED.
@@ -295,6 +302,7 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
295 int rc = SUCCESS; 302 int rc = SUCCESS;
296 unsigned long flags; 303 unsigned long flags;
297 enum bfi_tskim_status task_status; 304 enum bfi_tskim_status task_status;
305 struct scsi_lun scsilun;
298 306
299 spin_lock_irqsave(&bfad->bfad_lock, flags); 307 spin_lock_irqsave(&bfad->bfad_lock, flags);
300 itnim = itnim_data->itnim; 308 itnim = itnim_data->itnim;
@@ -306,14 +314,14 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
306 314
307 tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) cmnd); 315 tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) cmnd);
308 if (!tskim) { 316 if (!tskim) {
309 BFA_DEV_PRINTF(bfad, BFA_ERR, 317 BFA_LOG(KERN_ERR, bfad, bfa_log_level,
310 "LUN reset, fail to allocate tskim"); 318 "LUN reset, fail to allocate tskim");
311 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 319 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
312 rc = FAILED; 320 rc = FAILED;
313 goto out; 321 goto out;
314 } 322 }
315 323
316 /** 324 /*
317 * Set host_scribble to NULL to avoid aborting a task command 325 * Set host_scribble to NULL to avoid aborting a task command
318 * if happens. 326 * if happens.
319 */ 327 */
@@ -321,8 +329,8 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
321 cmnd->SCp.ptr = (char *)&wq; 329 cmnd->SCp.ptr = (char *)&wq;
322 cmnd->SCp.Status = 0; 330 cmnd->SCp.Status = 0;
323 bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim); 331 bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim);
324 bfa_tskim_start(tskim, bfa_itnim, 332 int_to_scsilun(cmnd->device->lun, &scsilun);
325 bfad_int_to_lun(cmnd->device->lun), 333 bfa_tskim_start(tskim, bfa_itnim, scsilun,
326 FCP_TM_LUN_RESET, BFAD_LUN_RESET_TMO); 334 FCP_TM_LUN_RESET, BFAD_LUN_RESET_TMO);
327 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 335 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
328 336
@@ -331,8 +339,8 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
331 339
332 task_status = cmnd->SCp.Status >> 1; 340 task_status = cmnd->SCp.Status >> 1;
333 if (task_status != BFI_TSKIM_STS_OK) { 341 if (task_status != BFI_TSKIM_STS_OK) {
334 BFA_DEV_PRINTF(bfad, BFA_ERR, "LUN reset failure, status: %d\n", 342 BFA_LOG(KERN_ERR, bfad, bfa_log_level,
335 task_status); 343 "LUN reset failure, status: %d\n", task_status);
336 rc = FAILED; 344 rc = FAILED;
337 } 345 }
338 346
@@ -340,7 +348,7 @@ out:
340 return rc; 348 return rc;
341} 349}
342 350
343/** 351/*
344 * Scsi_Host template entry, resets the bus and abort all commands. 352 * Scsi_Host template entry, resets the bus and abort all commands.
345 */ 353 */
346static int 354static int
@@ -358,7 +366,7 @@ bfad_im_reset_bus_handler(struct scsi_cmnd *cmnd)
358 366
359 spin_lock_irqsave(&bfad->bfad_lock, flags); 367 spin_lock_irqsave(&bfad->bfad_lock, flags);
360 for (i = 0; i < MAX_FCP_TARGET; i++) { 368 for (i = 0; i < MAX_FCP_TARGET; i++) {
361 itnim = bfad_os_get_itnim(im_port, i); 369 itnim = bfad_get_itnim(im_port, i);
362 if (itnim) { 370 if (itnim) {
363 cmnd->SCp.ptr = (char *)&wq; 371 cmnd->SCp.ptr = (char *)&wq;
364 rc = bfad_im_target_reset_send(bfad, cmnd, itnim); 372 rc = bfad_im_target_reset_send(bfad, cmnd, itnim);
@@ -375,7 +383,7 @@ bfad_im_reset_bus_handler(struct scsi_cmnd *cmnd)
375 383
376 task_status = cmnd->SCp.Status >> 1; 384 task_status = cmnd->SCp.Status >> 1;
377 if (task_status != BFI_TSKIM_STS_OK) { 385 if (task_status != BFI_TSKIM_STS_OK) {
378 BFA_DEV_PRINTF(bfad, BFA_ERR, 386 BFA_LOG(KERN_ERR, bfad, bfa_log_level,
379 "target reset failure," 387 "target reset failure,"
380 " status: %d\n", task_status); 388 " status: %d\n", task_status);
381 err_cnt++; 389 err_cnt++;
@@ -390,7 +398,7 @@ bfad_im_reset_bus_handler(struct scsi_cmnd *cmnd)
390 return SUCCESS; 398 return SUCCESS;
391} 399}
392 400
393/** 401/*
394 * Scsi_Host template entry slave_destroy. 402 * Scsi_Host template entry slave_destroy.
395 */ 403 */
396static void 404static void
@@ -400,11 +408,11 @@ bfad_im_slave_destroy(struct scsi_device *sdev)
400 return; 408 return;
401} 409}
402 410
403/** 411/*
404 * BFA FCS itnim callbacks 412 * BFA FCS itnim callbacks
405 */ 413 */
406 414
407/** 415/*
408 * BFA FCS itnim alloc callback, after successful PRLI 416 * BFA FCS itnim alloc callback, after successful PRLI
409 * Context: Interrupt 417 * Context: Interrupt
410 */ 418 */
@@ -427,7 +435,7 @@ bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
427 bfad->bfad_flags |= BFAD_RPORT_ONLINE; 435 bfad->bfad_flags |= BFAD_RPORT_ONLINE;
428} 436}
429 437
430/** 438/*
431 * BFA FCS itnim free callback. 439 * BFA FCS itnim free callback.
432 * Context: Interrupt. bfad_lock is held 440 * Context: Interrupt. bfad_lock is held
433 */ 441 */
@@ -438,9 +446,10 @@ bfa_fcb_itnim_free(struct bfad_s *bfad, struct bfad_itnim_s *itnim_drv)
438 wwn_t wwpn; 446 wwn_t wwpn;
439 u32 fcid; 447 u32 fcid;
440 char wwpn_str[32], fcid_str[16]; 448 char wwpn_str[32], fcid_str[16];
449 struct bfad_im_s *im = itnim_drv->im;
441 450
442 /* online to free state transtion should not happen */ 451 /* online to free state transtion should not happen */
443 bfa_assert(itnim_drv->state != ITNIM_STATE_ONLINE); 452 WARN_ON(itnim_drv->state == ITNIM_STATE_ONLINE);
444 453
445 itnim_drv->queue_work = 1; 454 itnim_drv->queue_work = 1;
446 /* offline request is not yet done, use the same request to free */ 455 /* offline request is not yet done, use the same request to free */
@@ -454,13 +463,17 @@ bfa_fcb_itnim_free(struct bfad_s *bfad, struct bfad_itnim_s *itnim_drv)
454 fcid = bfa_fcs_itnim_get_fcid(&itnim_drv->fcs_itnim); 463 fcid = bfa_fcs_itnim_get_fcid(&itnim_drv->fcs_itnim);
455 wwn2str(wwpn_str, wwpn); 464 wwn2str(wwpn_str, wwpn);
456 fcid2str(fcid_str, fcid); 465 fcid2str(fcid_str, fcid);
457 bfa_log(bfad->logmod, BFA_LOG_LINUX_ITNIM_FREE, 466 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
467 "ITNIM FREE scsi%d: FCID: %s WWPN: %s\n",
458 port->im_port->shost->host_no, 468 port->im_port->shost->host_no,
459 fcid_str, wwpn_str); 469 fcid_str, wwpn_str);
460 bfad_os_itnim_process(itnim_drv); 470
471 /* ITNIM processing */
472 if (itnim_drv->queue_work)
473 queue_work(im->drv_workq, &itnim_drv->itnim_work);
461} 474}
462 475
463/** 476/*
464 * BFA FCS itnim online callback. 477 * BFA FCS itnim online callback.
465 * Context: Interrupt. bfad_lock is held 478 * Context: Interrupt. bfad_lock is held
466 */ 479 */
@@ -468,16 +481,20 @@ void
468bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv) 481bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv)
469{ 482{
470 struct bfad_port_s *port; 483 struct bfad_port_s *port;
484 struct bfad_im_s *im = itnim_drv->im;
471 485
472 itnim_drv->bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim_drv->fcs_itnim); 486 itnim_drv->bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim_drv->fcs_itnim);
473 port = bfa_fcs_itnim_get_drvport(&itnim_drv->fcs_itnim); 487 port = bfa_fcs_itnim_get_drvport(&itnim_drv->fcs_itnim);
474 itnim_drv->state = ITNIM_STATE_ONLINE; 488 itnim_drv->state = ITNIM_STATE_ONLINE;
475 itnim_drv->queue_work = 1; 489 itnim_drv->queue_work = 1;
476 itnim_drv->im_port = port->im_port; 490 itnim_drv->im_port = port->im_port;
477 bfad_os_itnim_process(itnim_drv); 491
492 /* ITNIM processing */
493 if (itnim_drv->queue_work)
494 queue_work(im->drv_workq, &itnim_drv->itnim_work);
478} 495}
479 496
480/** 497/*
481 * BFA FCS itnim offline callback. 498 * BFA FCS itnim offline callback.
482 * Context: Interrupt. bfad_lock is held 499 * Context: Interrupt. bfad_lock is held
483 */ 500 */
@@ -486,6 +503,7 @@ bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv)
486{ 503{
487 struct bfad_port_s *port; 504 struct bfad_port_s *port;
488 struct bfad_s *bfad; 505 struct bfad_s *bfad;
506 struct bfad_im_s *im = itnim_drv->im;
489 507
490 port = bfa_fcs_itnim_get_drvport(&itnim_drv->fcs_itnim); 508 port = bfa_fcs_itnim_get_drvport(&itnim_drv->fcs_itnim);
491 bfad = port->bfad; 509 bfad = port->bfad;
@@ -497,24 +515,18 @@ bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv)
497 itnim_drv->im_port = port->im_port; 515 itnim_drv->im_port = port->im_port;
498 itnim_drv->state = ITNIM_STATE_OFFLINE_PENDING; 516 itnim_drv->state = ITNIM_STATE_OFFLINE_PENDING;
499 itnim_drv->queue_work = 1; 517 itnim_drv->queue_work = 1;
500 bfad_os_itnim_process(itnim_drv);
501}
502 518
503/** 519 /* ITNIM processing */
504 * BFA FCS itnim timeout callback. 520 if (itnim_drv->queue_work)
505 * Context: Interrupt. bfad_lock is held 521 queue_work(im->drv_workq, &itnim_drv->itnim_work);
506 */
507void bfa_fcb_itnim_tov(struct bfad_itnim_s *itnim)
508{
509 itnim->state = ITNIM_STATE_TIMEOUT;
510} 522}
511 523
512/** 524/*
513 * Allocate a Scsi_Host for a port. 525 * Allocate a Scsi_Host for a port.
514 */ 526 */
515int 527int
516bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port, 528bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port,
517 struct device *dev) 529 struct device *dev)
518{ 530{
519 int error = 1; 531 int error = 1;
520 532
@@ -535,7 +547,7 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port,
535 547
536 mutex_unlock(&bfad_mutex); 548 mutex_unlock(&bfad_mutex);
537 549
538 im_port->shost = bfad_os_scsi_host_alloc(im_port, bfad); 550 im_port->shost = bfad_scsi_host_alloc(im_port, bfad);
539 if (!im_port->shost) { 551 if (!im_port->shost) {
540 error = 1; 552 error = 1;
541 goto out_free_idr; 553 goto out_free_idr;
@@ -561,7 +573,7 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port,
561 } 573 }
562 574
563 /* setup host fixed attribute if the lk supports */ 575 /* setup host fixed attribute if the lk supports */
564 bfad_os_fc_host_init(im_port); 576 bfad_fc_host_init(im_port);
565 577
566 return 0; 578 return 0;
567 579
@@ -580,7 +592,7 @@ void
580bfad_im_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port) 592bfad_im_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port)
581{ 593{
582 bfa_trc(bfad, bfad->inst_no); 594 bfa_trc(bfad, bfad->inst_no);
583 bfa_log(bfad->logmod, BFA_LOG_LINUX_SCSI_HOST_FREE, 595 BFA_LOG(KERN_INFO, bfad, bfa_log_level, "Free scsi%d\n",
584 im_port->shost->host_no); 596 im_port->shost->host_no);
585 597
586 fc_remove_host(im_port->shost); 598 fc_remove_host(im_port->shost);
@@ -598,14 +610,11 @@ bfad_im_port_delete_handler(struct work_struct *work)
598{ 610{
599 struct bfad_im_port_s *im_port = 611 struct bfad_im_port_s *im_port =
600 container_of(work, struct bfad_im_port_s, port_delete_work); 612 container_of(work, struct bfad_im_port_s, port_delete_work);
601 struct bfad_s *bfad = im_port->bfad;
602 613
603 if (im_port->port->pvb_type != BFAD_PORT_PHYS_BASE) { 614 if (im_port->port->pvb_type != BFAD_PORT_PHYS_BASE) {
604 im_port->flags |= BFAD_PORT_DELETE; 615 im_port->flags |= BFAD_PORT_DELETE;
605 fc_vport_terminate(im_port->fc_vport); 616 fc_vport_terminate(im_port->fc_vport);
606 atomic_dec(&bfad->wq_reqcnt);
607 } 617 }
608
609} 618}
610 619
611bfa_status_t 620bfa_status_t
@@ -636,11 +645,8 @@ bfad_im_port_delete(struct bfad_s *bfad, struct bfad_port_s *port)
636{ 645{
637 struct bfad_im_port_s *im_port = port->im_port; 646 struct bfad_im_port_s *im_port = port->im_port;
638 647
639 if (im_port->port->pvb_type != BFAD_PORT_PHYS_BASE) { 648 queue_work(bfad->im->drv_workq,
640 atomic_inc(&bfad->wq_reqcnt);
641 queue_work(bfad->im->drv_workq,
642 &im_port->port_delete_work); 649 &im_port->port_delete_work);
643 }
644} 650}
645 651
646void 652void
@@ -658,21 +664,11 @@ bfad_im_port_clean(struct bfad_im_port_s *im_port)
658 } 664 }
659 665
660 /* the itnim_mapped_list must be empty at this time */ 666 /* the itnim_mapped_list must be empty at this time */
661 bfa_assert(list_empty(&im_port->itnim_mapped_list)); 667 WARN_ON(!list_empty(&im_port->itnim_mapped_list));
662 668
663 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 669 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
664} 670}
665 671
666void
667bfad_im_port_online(struct bfad_s *bfad, struct bfad_port_s *port)
668{
669}
670
671void
672bfad_im_port_offline(struct bfad_s *bfad, struct bfad_port_s *port)
673{
674}
675
676bfa_status_t 672bfa_status_t
677bfad_im_probe(struct bfad_s *bfad) 673bfad_im_probe(struct bfad_s *bfad)
678{ 674{
@@ -688,7 +684,7 @@ bfad_im_probe(struct bfad_s *bfad)
688 bfad->im = im; 684 bfad->im = im;
689 im->bfad = bfad; 685 im->bfad = bfad;
690 686
691 if (bfad_os_thread_workq(bfad) != BFA_STATUS_OK) { 687 if (bfad_thread_workq(bfad) != BFA_STATUS_OK) {
692 kfree(im); 688 kfree(im);
693 rc = BFA_STATUS_FAILED; 689 rc = BFA_STATUS_FAILED;
694 } 690 }
@@ -701,29 +697,14 @@ void
701bfad_im_probe_undo(struct bfad_s *bfad) 697bfad_im_probe_undo(struct bfad_s *bfad)
702{ 698{
703 if (bfad->im) { 699 if (bfad->im) {
704 while (atomic_read(&bfad->wq_reqcnt)) { 700 bfad_destroy_workq(bfad->im);
705 printk(KERN_INFO "bfa %s: waiting workq processing,"
706 " wq_reqcnt:%x\n", bfad->pci_name,
707 atomic_read(&bfad->wq_reqcnt));
708 schedule_timeout_uninterruptible(HZ);
709 }
710 bfad_os_destroy_workq(bfad->im);
711 kfree(bfad->im); 701 kfree(bfad->im);
712 bfad->im = NULL; 702 bfad->im = NULL;
713 } 703 }
714} 704}
715 705
716/**
717 * Call back function to handle IO redirection state change
718 */
719void
720bfa_cb_ioredirect_state_change(void *hcb_bfad, bfa_boolean_t ioredirect)
721{
722 /* Do nothing */
723}
724
725struct Scsi_Host * 706struct Scsi_Host *
726bfad_os_scsi_host_alloc(struct bfad_im_port_s *im_port, struct bfad_s *bfad) 707bfad_scsi_host_alloc(struct bfad_im_port_s *im_port, struct bfad_s *bfad)
727{ 708{
728 struct scsi_host_template *sht; 709 struct scsi_host_template *sht;
729 710
@@ -738,7 +719,7 @@ bfad_os_scsi_host_alloc(struct bfad_im_port_s *im_port, struct bfad_s *bfad)
738} 719}
739 720
740void 721void
741bfad_os_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port) 722bfad_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port)
742{ 723{
743 if (!(im_port->flags & BFAD_PORT_DELETE)) 724 if (!(im_port->flags & BFAD_PORT_DELETE))
744 flush_workqueue(bfad->im->drv_workq); 725 flush_workqueue(bfad->im->drv_workq);
@@ -748,21 +729,22 @@ bfad_os_scsi_host_free(struct bfad_s *bfad, struct bfad_im_port_s *im_port)
748} 729}
749 730
750void 731void
751bfad_os_destroy_workq(struct bfad_im_s *im) 732bfad_destroy_workq(struct bfad_im_s *im)
752{ 733{
753 if (im && im->drv_workq) { 734 if (im && im->drv_workq) {
735 flush_workqueue(im->drv_workq);
754 destroy_workqueue(im->drv_workq); 736 destroy_workqueue(im->drv_workq);
755 im->drv_workq = NULL; 737 im->drv_workq = NULL;
756 } 738 }
757} 739}
758 740
759bfa_status_t 741bfa_status_t
760bfad_os_thread_workq(struct bfad_s *bfad) 742bfad_thread_workq(struct bfad_s *bfad)
761{ 743{
762 struct bfad_im_s *im = bfad->im; 744 struct bfad_im_s *im = bfad->im;
763 745
764 bfa_trc(bfad, 0); 746 bfa_trc(bfad, 0);
765 snprintf(im->drv_workq_name, BFAD_KOBJ_NAME_LEN, "bfad_wq_%d", 747 snprintf(im->drv_workq_name, KOBJ_NAME_LEN, "bfad_wq_%d",
766 bfad->inst_no); 748 bfad->inst_no);
767 im->drv_workq = create_singlethread_workqueue(im->drv_workq_name); 749 im->drv_workq = create_singlethread_workqueue(im->drv_workq_name);
768 if (!im->drv_workq) 750 if (!im->drv_workq)
@@ -771,7 +753,7 @@ bfad_os_thread_workq(struct bfad_s *bfad)
771 return BFA_STATUS_OK; 753 return BFA_STATUS_OK;
772} 754}
773 755
774/** 756/*
775 * Scsi_Host template entry. 757 * Scsi_Host template entry.
776 * 758 *
777 * Description: 759 * Description:
@@ -832,12 +814,6 @@ struct scsi_host_template bfad_im_vport_template = {
832 .max_sectors = 0xFFFF, 814 .max_sectors = 0xFFFF,
833}; 815};
834 816
835void
836bfad_im_probe_post(struct bfad_im_s *im)
837{
838 flush_workqueue(im->drv_workq);
839}
840
841bfa_status_t 817bfa_status_t
842bfad_im_module_init(void) 818bfad_im_module_init(void)
843{ 819{
@@ -861,21 +837,13 @@ bfad_im_module_exit(void)
861{ 837{
862 if (bfad_im_scsi_transport_template) 838 if (bfad_im_scsi_transport_template)
863 fc_release_transport(bfad_im_scsi_transport_template); 839 fc_release_transport(bfad_im_scsi_transport_template);
840
864 if (bfad_im_scsi_vport_transport_template) 841 if (bfad_im_scsi_vport_transport_template)
865 fc_release_transport(bfad_im_scsi_vport_transport_template); 842 fc_release_transport(bfad_im_scsi_vport_transport_template);
866} 843}
867 844
868void 845void
869bfad_os_itnim_process(struct bfad_itnim_s *itnim_drv) 846bfad_ramp_up_qdepth(struct bfad_itnim_s *itnim, struct scsi_device *sdev)
870{
871 struct bfad_im_s *im = itnim_drv->im;
872
873 if (itnim_drv->queue_work)
874 queue_work(im->drv_workq, &itnim_drv->itnim_work);
875}
876
877void
878bfad_os_ramp_up_qdepth(struct bfad_itnim_s *itnim, struct scsi_device *sdev)
879{ 847{
880 struct scsi_device *tmp_sdev; 848 struct scsi_device *tmp_sdev;
881 849
@@ -903,7 +871,7 @@ bfad_os_ramp_up_qdepth(struct bfad_itnim_s *itnim, struct scsi_device *sdev)
903} 871}
904 872
905void 873void
906bfad_os_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev) 874bfad_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev)
907{ 875{
908 struct scsi_device *tmp_sdev; 876 struct scsi_device *tmp_sdev;
909 877
@@ -916,11 +884,8 @@ bfad_os_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev)
916 } 884 }
917} 885}
918 886
919
920
921
922struct bfad_itnim_s * 887struct bfad_itnim_s *
923bfad_os_get_itnim(struct bfad_im_port_s *im_port, int id) 888bfad_get_itnim(struct bfad_im_port_s *im_port, int id)
924{ 889{
925 struct bfad_itnim_s *itnim = NULL; 890 struct bfad_itnim_s *itnim = NULL;
926 891
@@ -933,7 +898,7 @@ bfad_os_get_itnim(struct bfad_im_port_s *im_port, int id)
933 return NULL; 898 return NULL;
934} 899}
935 900
936/** 901/*
937 * Scsi_Host template entry slave_alloc 902 * Scsi_Host template entry slave_alloc
938 */ 903 */
939static int 904static int
@@ -949,47 +914,68 @@ bfad_im_slave_alloc(struct scsi_device *sdev)
949 return 0; 914 return 0;
950} 915}
951 916
917static u32
918bfad_im_supported_speeds(struct bfa_s *bfa)
919{
920 struct bfa_ioc_attr_s *ioc_attr;
921 u32 supported_speed = 0;
922
923 ioc_attr = kzalloc(sizeof(struct bfa_ioc_attr_s), GFP_KERNEL);
924 if (!ioc_attr)
925 return 0;
926
927 bfa_ioc_get_attr(&bfa->ioc, ioc_attr);
928 if (ioc_attr->adapter_attr.max_speed == BFA_PORT_SPEED_8GBPS) {
929 if (ioc_attr->adapter_attr.is_mezz) {
930 supported_speed |= FC_PORTSPEED_8GBIT |
931 FC_PORTSPEED_4GBIT |
932 FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
933 } else {
934 supported_speed |= FC_PORTSPEED_8GBIT |
935 FC_PORTSPEED_4GBIT |
936 FC_PORTSPEED_2GBIT;
937 }
938 } else if (ioc_attr->adapter_attr.max_speed == BFA_PORT_SPEED_4GBPS) {
939 supported_speed |= FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT |
940 FC_PORTSPEED_1GBIT;
941 } else if (ioc_attr->adapter_attr.max_speed == BFA_PORT_SPEED_10GBPS) {
942 supported_speed |= FC_PORTSPEED_10GBIT;
943 }
944 kfree(ioc_attr);
945 return supported_speed;
946}
947
952void 948void
953bfad_os_fc_host_init(struct bfad_im_port_s *im_port) 949bfad_fc_host_init(struct bfad_im_port_s *im_port)
954{ 950{
955 struct Scsi_Host *host = im_port->shost; 951 struct Scsi_Host *host = im_port->shost;
956 struct bfad_s *bfad = im_port->bfad; 952 struct bfad_s *bfad = im_port->bfad;
957 struct bfad_port_s *port = im_port->port; 953 struct bfad_port_s *port = im_port->port;
958 struct bfa_pport_attr_s pattr; 954 char symname[BFA_SYMNAME_MAXLEN];
959 char model[BFA_ADAPTER_MODEL_NAME_LEN]; 955 struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(&bfad->bfa);
960 char fw_ver[BFA_VERSION_LEN];
961 956
962 fc_host_node_name(host) = 957 fc_host_node_name(host) =
963 bfa_os_htonll((bfa_fcs_port_get_nwwn(port->fcs_port))); 958 cpu_to_be64((bfa_fcs_lport_get_nwwn(port->fcs_port)));
964 fc_host_port_name(host) = 959 fc_host_port_name(host) =
965 bfa_os_htonll((bfa_fcs_port_get_pwwn(port->fcs_port))); 960 cpu_to_be64((bfa_fcs_lport_get_pwwn(port->fcs_port)));
966 fc_host_max_npiv_vports(host) = bfa_lps_get_max_vport(&bfad->bfa); 961 fc_host_max_npiv_vports(host) = bfa_lps_get_max_vport(&bfad->bfa);
967 962
968 fc_host_supported_classes(host) = FC_COS_CLASS3; 963 fc_host_supported_classes(host) = FC_COS_CLASS3;
969 964
970 memset(fc_host_supported_fc4s(host), 0, 965 memset(fc_host_supported_fc4s(host), 0,
971 sizeof(fc_host_supported_fc4s(host))); 966 sizeof(fc_host_supported_fc4s(host)));
972 if (bfad_supported_fc4s & (BFA_PORT_ROLE_FCP_IM | BFA_PORT_ROLE_FCP_TM)) 967 if (supported_fc4s & BFA_LPORT_ROLE_FCP_IM)
973 /* For FCP type 0x08 */ 968 /* For FCP type 0x08 */
974 fc_host_supported_fc4s(host)[2] = 1; 969 fc_host_supported_fc4s(host)[2] = 1;
975 if (bfad_supported_fc4s & BFA_PORT_ROLE_FCP_IPFC)
976 /* For LLC/SNAP type 0x05 */
977 fc_host_supported_fc4s(host)[3] = 0x20;
978 /* For fibre channel services type 0x20 */ 970 /* For fibre channel services type 0x20 */
979 fc_host_supported_fc4s(host)[7] = 1; 971 fc_host_supported_fc4s(host)[7] = 1;
980 972
981 bfa_get_adapter_model(&bfad->bfa, model); 973 strncpy(symname, bfad->bfa_fcs.fabric.bport.port_cfg.sym_name.symname,
982 bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver); 974 BFA_SYMNAME_MAXLEN);
983 sprintf(fc_host_symbolic_name(host), "Brocade %s FV%s DV%s", 975 sprintf(fc_host_symbolic_name(host), "%s", symname);
984 model, fw_ver, BFAD_DRIVER_VERSION);
985
986 fc_host_supported_speeds(host) = 0;
987 fc_host_supported_speeds(host) |=
988 FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT |
989 FC_PORTSPEED_1GBIT;
990 976
991 bfa_fcport_get_attr(&bfad->bfa, &pattr); 977 fc_host_supported_speeds(host) = bfad_im_supported_speeds(&bfad->bfa);
992 fc_host_maxframe_size(host) = pattr.pport_cfg.maxfrsize; 978 fc_host_maxframe_size(host) = fcport->cfg.maxfrsize;
993} 979}
994 980
995static void 981static void
@@ -1000,11 +986,11 @@ bfad_im_fc_rport_add(struct bfad_im_port_s *im_port, struct bfad_itnim_s *itnim)
1000 struct bfad_itnim_data_s *itnim_data; 986 struct bfad_itnim_data_s *itnim_data;
1001 987
1002 rport_ids.node_name = 988 rport_ids.node_name =
1003 bfa_os_htonll(bfa_fcs_itnim_get_nwwn(&itnim->fcs_itnim)); 989 cpu_to_be64(bfa_fcs_itnim_get_nwwn(&itnim->fcs_itnim));
1004 rport_ids.port_name = 990 rport_ids.port_name =
1005 bfa_os_htonll(bfa_fcs_itnim_get_pwwn(&itnim->fcs_itnim)); 991 cpu_to_be64(bfa_fcs_itnim_get_pwwn(&itnim->fcs_itnim));
1006 rport_ids.port_id = 992 rport_ids.port_id =
1007 bfa_os_hton3b(bfa_fcs_itnim_get_fcid(&itnim->fcs_itnim)); 993 bfa_hton3b(bfa_fcs_itnim_get_fcid(&itnim->fcs_itnim));
1008 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; 994 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
1009 995
1010 itnim->fc_rport = fc_rport = 996 itnim->fc_rport = fc_rport =
@@ -1032,7 +1018,7 @@ bfad_im_fc_rport_add(struct bfad_im_port_s *im_port, struct bfad_itnim_s *itnim)
1032 return; 1018 return;
1033} 1019}
1034 1020
1035/** 1021/*
1036 * Work queue handler using FC transport service 1022 * Work queue handler using FC transport service
1037* Context: kernel 1023* Context: kernel
1038 */ 1024 */
@@ -1065,7 +1051,9 @@ bfad_im_itnim_work_handler(struct work_struct *work)
1065 fcid2str(fcid_str, fcid); 1051 fcid2str(fcid_str, fcid);
1066 list_add_tail(&itnim->list_entry, 1052 list_add_tail(&itnim->list_entry,
1067 &im_port->itnim_mapped_list); 1053 &im_port->itnim_mapped_list);
1068 bfa_log(bfad->logmod, BFA_LOG_LINUX_ITNIM_ONLINE, 1054 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
1055 "ITNIM ONLINE Target: %d:0:%d "
1056 "FCID: %s WWPN: %s\n",
1069 im_port->shost->host_no, 1057 im_port->shost->host_no,
1070 itnim->scsi_tgt_id, 1058 itnim->scsi_tgt_id,
1071 fcid_str, wwpn_str); 1059 fcid_str, wwpn_str);
@@ -1096,7 +1084,9 @@ bfad_im_itnim_work_handler(struct work_struct *work)
1096 wwn2str(wwpn_str, wwpn); 1084 wwn2str(wwpn_str, wwpn);
1097 fcid2str(fcid_str, fcid); 1085 fcid2str(fcid_str, fcid);
1098 list_del(&itnim->list_entry); 1086 list_del(&itnim->list_entry);
1099 bfa_log(bfad->logmod, BFA_LOG_LINUX_ITNIM_OFFLINE, 1087 BFA_LOG(KERN_INFO, bfad, bfa_log_level,
1088 "ITNIM OFFLINE Target: %d:0:%d "
1089 "FCID: %s WWPN: %s\n",
1100 im_port->shost->host_no, 1090 im_port->shost->host_no,
1101 itnim->scsi_tgt_id, 1091 itnim->scsi_tgt_id,
1102 fcid_str, wwpn_str); 1092 fcid_str, wwpn_str);
@@ -1121,18 +1111,18 @@ bfad_im_itnim_work_handler(struct work_struct *work)
1121 kfree(itnim); 1111 kfree(itnim);
1122 break; 1112 break;
1123 default: 1113 default:
1124 bfa_assert(0); 1114 WARN_ON(1);
1125 break; 1115 break;
1126 } 1116 }
1127 1117
1128 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 1118 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1129} 1119}
1130 1120
1131/** 1121/*
1132 * Scsi_Host template entry, queue a SCSI command to the BFAD. 1122 * Scsi_Host template entry, queue a SCSI command to the BFAD.
1133 */ 1123 */
1134static int 1124static int
1135bfad_im_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) 1125bfad_im_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
1136{ 1126{
1137 struct bfad_im_port_s *im_port = 1127 struct bfad_im_port_s *im_port =
1138 (struct bfad_im_port_s *) cmnd->device->host->hostdata[0]; 1128 (struct bfad_im_port_s *) cmnd->device->host->hostdata[0];
@@ -1142,7 +1132,7 @@ bfad_im_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
1142 struct bfa_ioim_s *hal_io; 1132 struct bfa_ioim_s *hal_io;
1143 unsigned long flags; 1133 unsigned long flags;
1144 int rc; 1134 int rc;
1145 s16 sg_cnt = 0; 1135 int sg_cnt = 0;
1146 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); 1136 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
1147 1137
1148 rc = fc_remote_port_chkready(rport); 1138 rc = fc_remote_port_chkready(rport);
@@ -1153,7 +1143,6 @@ bfad_im_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
1153 } 1143 }
1154 1144
1155 sg_cnt = scsi_dma_map(cmnd); 1145 sg_cnt = scsi_dma_map(cmnd);
1156
1157 if (sg_cnt < 0) 1146 if (sg_cnt < 0)
1158 return SCSI_MLQUEUE_HOST_BUSY; 1147 return SCSI_MLQUEUE_HOST_BUSY;
1159 1148
@@ -1168,6 +1157,7 @@ bfad_im_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
1168 goto out_fail_cmd; 1157 goto out_fail_cmd;
1169 } 1158 }
1170 1159
1160
1171 itnim = itnim_data->itnim; 1161 itnim = itnim_data->itnim;
1172 if (!itnim) { 1162 if (!itnim) {
1173 cmnd->result = ScsiResult(DID_IMM_RETRY, 0); 1163 cmnd->result = ScsiResult(DID_IMM_RETRY, 0);
@@ -1184,7 +1174,6 @@ bfad_im_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
1184 } 1174 }
1185 1175
1186 cmnd->host_scribble = (char *)hal_io; 1176 cmnd->host_scribble = (char *)hal_io;
1187 bfa_trc_fp(bfad, hal_io->iotag);
1188 bfa_ioim_start(hal_io); 1177 bfa_ioim_start(hal_io);
1189 spin_unlock_irqrestore(&bfad->bfad_lock, flags); 1178 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
1190 1179
@@ -1199,54 +1188,58 @@ out_fail_cmd:
1199 return 0; 1188 return 0;
1200} 1189}
1201 1190
1191static DEF_SCSI_QCMD(bfad_im_queuecommand)
1192
1202void 1193void
1203bfad_os_rport_online_wait(struct bfad_s *bfad) 1194bfad_rport_online_wait(struct bfad_s *bfad)
1204{ 1195{
1205 int i; 1196 int i;
1206 int rport_delay = 10; 1197 int rport_delay = 10;
1207 1198
1208 for (i = 0; !(bfad->bfad_flags & BFAD_PORT_ONLINE) 1199 for (i = 0; !(bfad->bfad_flags & BFAD_PORT_ONLINE)
1209 && i < bfa_linkup_delay; i++) 1200 && i < bfa_linkup_delay; i++) {
1210 schedule_timeout_uninterruptible(HZ); 1201 set_current_state(TASK_UNINTERRUPTIBLE);
1202 schedule_timeout(HZ);
1203 }
1211 1204
1212 if (bfad->bfad_flags & BFAD_PORT_ONLINE) { 1205 if (bfad->bfad_flags & BFAD_PORT_ONLINE) {
1213 rport_delay = rport_delay < bfa_linkup_delay ? 1206 rport_delay = rport_delay < bfa_linkup_delay ?
1214 rport_delay : bfa_linkup_delay; 1207 rport_delay : bfa_linkup_delay;
1215 for (i = 0; !(bfad->bfad_flags & BFAD_RPORT_ONLINE) 1208 for (i = 0; !(bfad->bfad_flags & BFAD_RPORT_ONLINE)
1216 && i < rport_delay; i++) 1209 && i < rport_delay; i++) {
1217 schedule_timeout_uninterruptible(HZ); 1210 set_current_state(TASK_UNINTERRUPTIBLE);
1211 schedule_timeout(HZ);
1212 }
1218 1213
1219 if (rport_delay > 0 && (bfad->bfad_flags & BFAD_RPORT_ONLINE)) 1214 if (rport_delay > 0 && (bfad->bfad_flags & BFAD_RPORT_ONLINE)) {
1220 schedule_timeout_uninterruptible(rport_delay * HZ); 1215 set_current_state(TASK_UNINTERRUPTIBLE);
1216 schedule_timeout(rport_delay * HZ);
1217 }
1221 } 1218 }
1222} 1219}
1223 1220
1224int 1221int
1225bfad_os_get_linkup_delay(struct bfad_s *bfad) 1222bfad_get_linkup_delay(struct bfad_s *bfad)
1226{ 1223{
1227 1224 u8 nwwns = 0;
1228 u8 nwwns = 0; 1225 wwn_t wwns[BFA_PREBOOT_BOOTLUN_MAX];
1229 wwn_t wwns[BFA_PREBOOT_BOOTLUN_MAX]; 1226 int linkup_delay;
1230 int ldelay;
1231 1227
1232 /* 1228 /*
1233 * Querying for the boot target port wwns 1229 * Querying for the boot target port wwns
1234 * -- read from boot information in flash. 1230 * -- read from boot information in flash.
1235 * If nwwns > 0 => boot over SAN and set bfa_linkup_delay = 30 1231 * If nwwns > 0 => boot over SAN and set linkup_delay = 30
1236 * else => local boot machine set bfa_linkup_delay = 10 1232 * else => local boot machine set linkup_delay = 0
1237 */ 1233 */
1238 1234
1239 bfa_iocfc_get_bootwwns(&bfad->bfa, &nwwns, wwns); 1235 bfa_iocfc_get_bootwwns(&bfad->bfa, &nwwns, wwns);
1240 1236
1241 if (nwwns > 0) { 1237 if (nwwns > 0)
1242 /* If boot over SAN; linkup_delay = 30sec */ 1238 /* If Boot over SAN set linkup_delay = 30sec */
1243 ldelay = 30; 1239 linkup_delay = 30;
1244 } else { 1240 else
1245 /* If local boot; linkup_delay = 10sec */ 1241 /* If local boot; no linkup_delay */
1246 ldelay = 0; 1242 linkup_delay = 0;
1247 }
1248 1243
1249 return ldelay; 1244 return linkup_delay;
1250} 1245}
1251
1252
diff --git a/drivers/scsi/bfa/bfad_im.h b/drivers/scsi/bfa/bfad_im.h
index 973cab4d09c7..c296c8968511 100644
--- a/drivers/scsi/bfa/bfad_im.h
+++ b/drivers/scsi/bfa/bfad_im.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved 3 * All rights reserved
4 * www.brocade.com 4 * www.brocade.com
5 * 5 *
@@ -18,20 +18,20 @@
18#ifndef __BFAD_IM_H__ 18#ifndef __BFAD_IM_H__
19#define __BFAD_IM_H__ 19#define __BFAD_IM_H__
20 20
21#include "fcs/bfa_fcs_fcpim.h" 21#include "bfa_fcs.h"
22#include "bfad_im_compat.h"
23 22
24#define FCPI_NAME " fcpim" 23#define FCPI_NAME " fcpim"
25 24
25#ifndef KOBJ_NAME_LEN
26#define KOBJ_NAME_LEN 20
27#endif
28
26bfa_status_t bfad_im_module_init(void); 29bfa_status_t bfad_im_module_init(void);
27void bfad_im_module_exit(void); 30void bfad_im_module_exit(void);
28bfa_status_t bfad_im_probe(struct bfad_s *bfad); 31bfa_status_t bfad_im_probe(struct bfad_s *bfad);
29void bfad_im_probe_undo(struct bfad_s *bfad); 32void bfad_im_probe_undo(struct bfad_s *bfad);
30void bfad_im_probe_post(struct bfad_im_s *im);
31bfa_status_t bfad_im_port_new(struct bfad_s *bfad, struct bfad_port_s *port); 33bfa_status_t bfad_im_port_new(struct bfad_s *bfad, struct bfad_port_s *port);
32void bfad_im_port_delete(struct bfad_s *bfad, struct bfad_port_s *port); 34void bfad_im_port_delete(struct bfad_s *bfad, struct bfad_port_s *port);
33void bfad_im_port_online(struct bfad_s *bfad, struct bfad_port_s *port);
34void bfad_im_port_offline(struct bfad_s *bfad, struct bfad_port_s *port);
35void bfad_im_port_clean(struct bfad_im_port_s *im_port); 35void bfad_im_port_clean(struct bfad_im_port_s *im_port);
36int bfad_im_scsi_host_alloc(struct bfad_s *bfad, 36int bfad_im_scsi_host_alloc(struct bfad_s *bfad,
37 struct bfad_im_port_s *im_port, struct device *dev); 37 struct bfad_im_port_s *im_port, struct device *dev);
@@ -44,14 +44,10 @@ void bfad_im_scsi_host_free(struct bfad_s *bfad,
44#define BFAD_LUN_RESET_TMO 60 44#define BFAD_LUN_RESET_TMO 60
45#define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code) 45#define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code)
46#define BFA_QUEUE_FULL_RAMP_UP_TIME 120 46#define BFA_QUEUE_FULL_RAMP_UP_TIME 120
47#define BFAD_KOBJ_NAME_LEN 20
48 47
49/* 48/*
50 * itnim flags 49 * itnim flags
51 */ 50 */
52#define ITNIM_MAPPED 0x00000001
53
54#define SCSI_TASK_MGMT 0x00000001
55#define IO_DONE_BIT 0 51#define IO_DONE_BIT 0
56 52
57struct bfad_itnim_data_s { 53struct bfad_itnim_data_s {
@@ -64,7 +60,7 @@ struct bfad_im_port_s {
64 struct work_struct port_delete_work; 60 struct work_struct port_delete_work;
65 int idr_id; 61 int idr_id;
66 u16 cur_scsi_id; 62 u16 cur_scsi_id;
67 u16 flags; 63 u16 flags;
68 struct list_head binding_list; 64 struct list_head binding_list;
69 struct Scsi_Host *shost; 65 struct Scsi_Host *shost;
70 struct list_head itnim_mapped_list; 66 struct list_head itnim_mapped_list;
@@ -118,26 +114,20 @@ struct bfad_fcp_binding {
118struct bfad_im_s { 114struct bfad_im_s {
119 struct bfad_s *bfad; 115 struct bfad_s *bfad;
120 struct workqueue_struct *drv_workq; 116 struct workqueue_struct *drv_workq;
121 char drv_workq_name[BFAD_KOBJ_NAME_LEN]; 117 char drv_workq_name[KOBJ_NAME_LEN];
122}; 118};
123 119
124struct Scsi_Host *bfad_os_scsi_host_alloc(struct bfad_im_port_s *im_port, 120struct Scsi_Host *bfad_scsi_host_alloc(struct bfad_im_port_s *im_port,
125 struct bfad_s *); 121 struct bfad_s *);
126bfa_status_t bfad_os_thread_workq(struct bfad_s *bfad); 122bfa_status_t bfad_thread_workq(struct bfad_s *bfad);
127void bfad_os_destroy_workq(struct bfad_im_s *im); 123void bfad_destroy_workq(struct bfad_im_s *im);
128void bfad_os_itnim_process(struct bfad_itnim_s *itnim_drv); 124void bfad_fc_host_init(struct bfad_im_port_s *im_port);
129void bfad_os_fc_host_init(struct bfad_im_port_s *im_port); 125void bfad_scsi_host_free(struct bfad_s *bfad,
130void bfad_os_scsi_host_free(struct bfad_s *bfad,
131 struct bfad_im_port_s *im_port); 126 struct bfad_im_port_s *im_port);
132void bfad_os_ramp_up_qdepth(struct bfad_itnim_s *itnim, 127void bfad_ramp_up_qdepth(struct bfad_itnim_s *itnim,
133 struct scsi_device *sdev); 128 struct scsi_device *sdev);
134void bfad_os_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev); 129void bfad_handle_qfull(struct bfad_itnim_s *itnim, struct scsi_device *sdev);
135struct bfad_itnim_s *bfad_os_get_itnim(struct bfad_im_port_s *im_port, int id); 130struct bfad_itnim_s *bfad_get_itnim(struct bfad_im_port_s *im_port, int id);
136int bfad_os_scsi_add_host(struct Scsi_Host *shost,
137 struct bfad_im_port_s *im_port, struct bfad_s *bfad);
138
139void bfad_im_itnim_unmap(struct bfad_im_port_s *im_port,
140 struct bfad_itnim_s *itnim);
141 131
142extern struct scsi_host_template bfad_im_scsi_host_template; 132extern struct scsi_host_template bfad_im_scsi_host_template;
143extern struct scsi_host_template bfad_im_vport_template; 133extern struct scsi_host_template bfad_im_vport_template;
@@ -146,4 +136,9 @@ extern struct fc_function_template bfad_im_vport_fc_function_template;
146extern struct scsi_transport_template *bfad_im_scsi_transport_template; 136extern struct scsi_transport_template *bfad_im_scsi_transport_template;
147extern struct scsi_transport_template *bfad_im_scsi_vport_transport_template; 137extern struct scsi_transport_template *bfad_im_scsi_vport_transport_template;
148 138
139extern struct device_attribute *bfad_im_host_attrs[];
140extern struct device_attribute *bfad_im_vport_attrs[];
141
142irqreturn_t bfad_intx(int irq, void *dev_id);
143
149#endif 144#endif
diff --git a/drivers/scsi/bfa/bfad_im_compat.h b/drivers/scsi/bfa/bfad_im_compat.h
deleted file mode 100644
index 0a122abbbe89..000000000000
--- a/drivers/scsi/bfa/bfad_im_compat.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFAD_IM_COMPAT_H__
19#define __BFAD_IM_COMPAT_H__
20
21extern struct device_attribute *bfad_im_host_attrs[];
22extern struct device_attribute *bfad_im_vport_attrs[];
23
24u32 *bfad_get_firmware_buf(struct pci_dev *pdev);
25u32 *bfad_read_firmware(struct pci_dev *pdev, u32 **bfi_image,
26 u32 *bfi_image_size, char *fw_name);
27
28static inline u32 *
29bfad_load_fwimg(struct pci_dev *pdev)
30{
31 return bfad_get_firmware_buf(pdev);
32}
33
34static inline void
35bfad_free_fwimg(void)
36{
37 if (bfi_image_ct_fc_size && bfi_image_ct_fc)
38 vfree(bfi_image_ct_fc);
39 if (bfi_image_ct_cna_size && bfi_image_ct_cna)
40 vfree(bfi_image_ct_cna);
41 if (bfi_image_cb_fc_size && bfi_image_cb_fc)
42 vfree(bfi_image_cb_fc);
43}
44
45#endif
diff --git a/drivers/scsi/bfa/bfad_intr.c b/drivers/scsi/bfa/bfad_intr.c
deleted file mode 100644
index 56a351584f0c..000000000000
--- a/drivers/scsi/bfa/bfad_intr.c
+++ /dev/null
@@ -1,222 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include "bfad_drv.h"
19#include "bfad_trcmod.h"
20
21BFA_TRC_FILE(LDRV, INTR);
22
23/**
24 * bfa_isr BFA driver interrupt functions
25 */
26static int msix_disable_cb;
27static int msix_disable_ct;
28module_param(msix_disable_cb, int, S_IRUGO | S_IWUSR);
29MODULE_PARM_DESC(msix_disable_cb, "Disable MSIX for Brocade-415/425/815/825"
30 " cards, default=0, Range[false:0|true:1]");
31module_param(msix_disable_ct, int, S_IRUGO | S_IWUSR);
32MODULE_PARM_DESC(msix_disable_ct, "Disable MSIX for Brocade-1010/1020/804"
33 " cards, default=0, Range[false:0|true:1]");
34/**
35 * Line based interrupt handler.
36 */
37static irqreturn_t
38bfad_intx(int irq, void *dev_id)
39{
40 struct bfad_s *bfad = dev_id;
41 struct list_head doneq;
42 unsigned long flags;
43 bfa_boolean_t rc;
44
45 spin_lock_irqsave(&bfad->bfad_lock, flags);
46 rc = bfa_intx(&bfad->bfa);
47 if (!rc) {
48 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
49 return IRQ_NONE;
50 }
51
52 bfa_comp_deq(&bfad->bfa, &doneq);
53 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
54
55 if (!list_empty(&doneq)) {
56 bfa_comp_process(&bfad->bfa, &doneq);
57
58 spin_lock_irqsave(&bfad->bfad_lock, flags);
59 bfa_comp_free(&bfad->bfa, &doneq);
60 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
61 bfa_trc_fp(bfad, irq);
62 }
63
64 return IRQ_HANDLED;
65
66}
67
68static irqreturn_t
69bfad_msix(int irq, void *dev_id)
70{
71 struct bfad_msix_s *vec = dev_id;
72 struct bfad_s *bfad = vec->bfad;
73 struct list_head doneq;
74 unsigned long flags;
75
76 spin_lock_irqsave(&bfad->bfad_lock, flags);
77
78 bfa_msix(&bfad->bfa, vec->msix.entry);
79 bfa_comp_deq(&bfad->bfa, &doneq);
80 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
81
82 if (!list_empty(&doneq)) {
83 bfa_comp_process(&bfad->bfa, &doneq);
84
85 spin_lock_irqsave(&bfad->bfad_lock, flags);
86 bfa_comp_free(&bfad->bfa, &doneq);
87 spin_unlock_irqrestore(&bfad->bfad_lock, flags);
88 }
89
90 return IRQ_HANDLED;
91}
92
93/**
94 * Initialize the MSIX entry table.
95 */
96static void
97bfad_init_msix_entry(struct bfad_s *bfad, struct msix_entry *msix_entries,
98 int mask, int max_bit)
99{
100 int i;
101 int match = 0x00000001;
102
103 for (i = 0, bfad->nvec = 0; i < MAX_MSIX_ENTRY; i++) {
104 if (mask & match) {
105 bfad->msix_tab[bfad->nvec].msix.entry = i;
106 bfad->msix_tab[bfad->nvec].bfad = bfad;
107 msix_entries[bfad->nvec].entry = i;
108 bfad->nvec++;
109 }
110
111 match <<= 1;
112 }
113
114}
115
116int
117bfad_install_msix_handler(struct bfad_s *bfad)
118{
119 int i, error = 0;
120
121 for (i = 0; i < bfad->nvec; i++) {
122 error = request_irq(bfad->msix_tab[i].msix.vector,
123 (irq_handler_t) bfad_msix, 0,
124 BFAD_DRIVER_NAME, &bfad->msix_tab[i]);
125 bfa_trc(bfad, i);
126 bfa_trc(bfad, bfad->msix_tab[i].msix.vector);
127 if (error) {
128 int j;
129
130 for (j = 0; j < i; j++)
131 free_irq(bfad->msix_tab[j].msix.vector,
132 &bfad->msix_tab[j]);
133
134 return 1;
135 }
136 }
137
138 return 0;
139}
140
141/**
142 * Setup MSIX based interrupt.
143 */
144int
145bfad_setup_intr(struct bfad_s *bfad)
146{
147 int error = 0;
148 u32 mask = 0, i, num_bit = 0, max_bit = 0;
149 struct msix_entry msix_entries[MAX_MSIX_ENTRY];
150 struct pci_dev *pdev = bfad->pcidev;
151
152 /* Call BFA to get the msix map for this PCI function. */
153 bfa_msix_getvecs(&bfad->bfa, &mask, &num_bit, &max_bit);
154
155 /* Set up the msix entry table */
156 bfad_init_msix_entry(bfad, msix_entries, mask, max_bit);
157
158 if ((bfa_asic_id_ct(pdev->device) && !msix_disable_ct) ||
159 (!bfa_asic_id_ct(pdev->device) && !msix_disable_cb)) {
160
161 error = pci_enable_msix(bfad->pcidev, msix_entries, bfad->nvec);
162 if (error) {
163 /*
164 * Only error number of vector is available.
165 * We don't have a mechanism to map multiple
166 * interrupts into one vector, so even if we
167 * can try to request less vectors, we don't
168 * know how to associate interrupt events to
169 * vectors. Linux doesn't dupicate vectors
170 * in the MSIX table for this case.
171 */
172
173 printk(KERN_WARNING "bfad%d: "
174 "pci_enable_msix failed (%d),"
175 " use line based.\n", bfad->inst_no, error);
176
177 goto line_based;
178 }
179
180 /* Save the vectors */
181 for (i = 0; i < bfad->nvec; i++) {
182 bfa_trc(bfad, msix_entries[i].vector);
183 bfad->msix_tab[i].msix.vector = msix_entries[i].vector;
184 }
185
186 bfa_msix_init(&bfad->bfa, bfad->nvec);
187
188 bfad->bfad_flags |= BFAD_MSIX_ON;
189
190 return error;
191 }
192
193line_based:
194 error = 0;
195 if (request_irq
196 (bfad->pcidev->irq, (irq_handler_t) bfad_intx, BFAD_IRQ_FLAGS,
197 BFAD_DRIVER_NAME, bfad) != 0) {
198 /* Enable interrupt handler failed */
199 return 1;
200 }
201
202 return error;
203}
204
205void
206bfad_remove_intr(struct bfad_s *bfad)
207{
208 int i;
209
210 if (bfad->bfad_flags & BFAD_MSIX_ON) {
211 for (i = 0; i < bfad->nvec; i++)
212 free_irq(bfad->msix_tab[i].msix.vector,
213 &bfad->msix_tab[i]);
214
215 pci_disable_msix(bfad->pcidev);
216 bfad->bfad_flags &= ~BFAD_MSIX_ON;
217 } else {
218 free_irq(bfad->pcidev->irq, bfad);
219 }
220}
221
222
diff --git a/drivers/scsi/bfa/bfad_ipfc.h b/drivers/scsi/bfa/bfad_ipfc.h
deleted file mode 100644
index 718bc5227671..000000000000
--- a/drivers/scsi/bfa/bfad_ipfc.h
+++ /dev/null
@@ -1,42 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_DRV_IPFC_H__
18#define __BFA_DRV_IPFC_H__
19
20
21#define IPFC_NAME ""
22
23#define bfad_ipfc_module_init(x) do {} while (0)
24#define bfad_ipfc_module_exit(x) do {} while (0)
25#define bfad_ipfc_probe(x) do {} while (0)
26#define bfad_ipfc_probe_undo(x) do {} while (0)
27#define bfad_ipfc_port_config(x, y) BFA_STATUS_OK
28#define bfad_ipfc_port_unconfig(x, y) do {} while (0)
29
30#define bfad_ipfc_probe_post(x) do {} while (0)
31#define bfad_ipfc_port_new(x, y, z) BFA_STATUS_OK
32#define bfad_ipfc_port_delete(x, y) do {} while (0)
33#define bfad_ipfc_port_online(x, y) do {} while (0)
34#define bfad_ipfc_port_offline(x, y) do {} while (0)
35
36#define bfad_ip_get_attr(x) BFA_STATUS_FAILED
37#define bfad_ip_reset_drv_stats(x) BFA_STATUS_FAILED
38#define bfad_ip_get_drv_stats(x, y) BFA_STATUS_FAILED
39#define bfad_ip_enable_ipfc(x, y, z) BFA_STATUS_FAILED
40
41
42#endif
diff --git a/drivers/scsi/bfa/bfad_os.c b/drivers/scsi/bfa/bfad_os.c
deleted file mode 100644
index faf47b4f1a38..000000000000
--- a/drivers/scsi/bfa/bfad_os.c
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfad_os.c Linux driver OS specific calls.
20 */
21
22#include "bfa_os_inc.h"
23#include "bfad_drv.h"
24
25void
26bfa_os_gettimeofday(struct bfa_timeval_s *tv)
27{
28 struct timeval tmp_tv;
29
30 do_gettimeofday(&tmp_tv);
31 tv->tv_sec = (u32) tmp_tv.tv_sec;
32 tv->tv_usec = (u32) tmp_tv.tv_usec;
33}
34
35void
36bfa_os_printf(struct bfa_log_mod_s *log_mod, u32 msg_id,
37 const char *fmt, ...)
38{
39 va_list ap;
40 #define BFA_STRING_256 256
41 char tmp[BFA_STRING_256];
42
43 va_start(ap, fmt);
44 vsprintf(tmp, fmt, ap);
45 va_end(ap);
46
47 printk(tmp);
48}
49
50
diff --git a/drivers/scsi/bfa/bfad_tm.h b/drivers/scsi/bfa/bfad_tm.h
deleted file mode 100644
index 4901b1b7df02..000000000000
--- a/drivers/scsi/bfa/bfad_tm.h
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/*
19 * Brocade Fibre Channel HBA Linux Target Mode Driver
20 */
21
22/**
23 * tm/dummy/bfad_tm.h BFA callback dummy header file for BFA Linux target mode PCI interface module.
24 */
25
26#ifndef __BFAD_TM_H__
27#define __BFAD_TM_H__
28
29#include <defs/bfa_defs_status.h>
30
31#define FCPT_NAME ""
32
33/*
34 * Called from base Linux driver on (De)Init events
35 */
36
37/* attach tgt template with scst */
38#define bfad_tm_module_init() do {} while (0)
39
40/* detach/release tgt template */
41#define bfad_tm_module_exit() do {} while (0)
42
43#define bfad_tm_probe(x) do {} while (0)
44#define bfad_tm_probe_undo(x) do {} while (0)
45#define bfad_tm_probe_post(x) do {} while (0)
46
47/*
48 * Called by base Linux driver but triggered by BFA FCS on config events
49 */
50#define bfad_tm_port_new(x, y) BFA_STATUS_OK
51#define bfad_tm_port_delete(x, y) do {} while (0)
52
53/*
54 * Called by base Linux driver but triggered by BFA FCS on PLOGI/O events
55 */
56#define bfad_tm_port_online(x, y) do {} while (0)
57#define bfad_tm_port_offline(x, y) do {} while (0)
58
59#endif
diff --git a/drivers/scsi/bfa/bfad_trcmod.h b/drivers/scsi/bfa/bfad_trcmod.h
deleted file mode 100644
index 2827b2acd041..000000000000
--- a/drivers/scsi/bfa/bfad_trcmod.h
+++ /dev/null
@@ -1,52 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfad_trcmod.h Linux driver trace modules
20 */
21
22
23#ifndef __BFAD_TRCMOD_H__
24#define __BFAD_TRCMOD_H__
25
26#include <cs/bfa_trc.h>
27
28/*
29 * !!! Only append to the enums defined here to avoid any versioning
30 * !!! needed between trace utility and driver version
31 */
32enum {
33 /* 2.6 Driver */
34 BFA_TRC_LDRV_BFAD = 1,
35 BFA_TRC_LDRV_BFAD_2_6 = 2,
36 BFA_TRC_LDRV_BFAD_2_6_9 = 3,
37 BFA_TRC_LDRV_BFAD_2_6_10 = 4,
38 BFA_TRC_LDRV_INTR = 5,
39 BFA_TRC_LDRV_IOCTL = 6,
40 BFA_TRC_LDRV_OS = 7,
41 BFA_TRC_LDRV_IM = 8,
42 BFA_TRC_LDRV_IM_2_6 = 9,
43 BFA_TRC_LDRV_IM_2_6_9 = 10,
44 BFA_TRC_LDRV_IM_2_6_10 = 11,
45 BFA_TRC_LDRV_TM = 12,
46 BFA_TRC_LDRV_IPFC = 13,
47 BFA_TRC_LDRV_IM_2_4 = 14,
48 BFA_TRC_LDRV_IM_VMW = 15,
49 BFA_TRC_LDRV_IM_LT_2_6_10 = 16,
50};
51
52#endif /* __BFAD_TRCMOD_H__ */
diff --git a/drivers/scsi/bfa/bfi.h b/drivers/scsi/bfa/bfi.h
new file mode 100644
index 000000000000..72b69a0c3b51
--- /dev/null
+++ b/drivers/scsi/bfa/bfi.h
@@ -0,0 +1,579 @@
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 __BFI_H__
19#define __BFI_H__
20
21#include "bfa_defs.h"
22#include "bfa_defs_svc.h"
23
24#pragma pack(1)
25
26/*
27 * BFI FW image type
28 */
29#define BFI_FLASH_CHUNK_SZ 256 /* Flash chunk size */
30#define BFI_FLASH_CHUNK_SZ_WORDS (BFI_FLASH_CHUNK_SZ/sizeof(u32))
31enum {
32 BFI_IMAGE_CB_FC,
33 BFI_IMAGE_CT_FC,
34 BFI_IMAGE_CT_CNA,
35 BFI_IMAGE_MAX,
36};
37
38/*
39 * Msg header common to all msgs
40 */
41struct bfi_mhdr_s {
42 u8 msg_class; /* @ref bfi_mclass_t */
43 u8 msg_id; /* msg opcode with in the class */
44 union {
45 struct {
46 u8 rsvd;
47 u8 lpu_id; /* msg destination */
48 } h2i;
49 u16 i2htok; /* token in msgs to host */
50 } mtag;
51};
52
53#define bfi_h2i_set(_mh, _mc, _op, _lpuid) do { \
54 (_mh).msg_class = (_mc); \
55 (_mh).msg_id = (_op); \
56 (_mh).mtag.h2i.lpu_id = (_lpuid); \
57} while (0)
58
59#define bfi_i2h_set(_mh, _mc, _op, _i2htok) do { \
60 (_mh).msg_class = (_mc); \
61 (_mh).msg_id = (_op); \
62 (_mh).mtag.i2htok = (_i2htok); \
63} while (0)
64
65/*
66 * Message opcodes: 0-127 to firmware, 128-255 to host
67 */
68#define BFI_I2H_OPCODE_BASE 128
69#define BFA_I2HM(_x) ((_x) + BFI_I2H_OPCODE_BASE)
70
71/*
72 ****************************************************************************
73 *
74 * Scatter Gather Element and Page definition
75 *
76 ****************************************************************************
77 */
78
79#define BFI_SGE_INLINE 1
80#define BFI_SGE_INLINE_MAX (BFI_SGE_INLINE + 1)
81
82/*
83 * SG Flags
84 */
85enum {
86 BFI_SGE_DATA = 0, /* data address, not last */
87 BFI_SGE_DATA_CPL = 1, /* data addr, last in current page */
88 BFI_SGE_DATA_LAST = 3, /* data address, last */
89 BFI_SGE_LINK = 2, /* link address */
90 BFI_SGE_PGDLEN = 2, /* cumulative data length for page */
91};
92
93/*
94 * DMA addresses
95 */
96union bfi_addr_u {
97 struct {
98 __be32 addr_lo;
99 __be32 addr_hi;
100 } a32;
101};
102
103/*
104 * Scatter Gather Element
105 */
106struct bfi_sge_s {
107#ifdef __BIG_ENDIAN
108 u32 flags:2,
109 rsvd:2,
110 sg_len:28;
111#else
112 u32 sg_len:28,
113 rsvd:2,
114 flags:2;
115#endif
116 union bfi_addr_u sga;
117};
118
119/*
120 * Scatter Gather Page
121 */
122#define BFI_SGPG_DATA_SGES 7
123#define BFI_SGPG_SGES_MAX (BFI_SGPG_DATA_SGES + 1)
124#define BFI_SGPG_RSVD_WD_LEN 8
125struct bfi_sgpg_s {
126 struct bfi_sge_s sges[BFI_SGPG_SGES_MAX];
127 u32 rsvd[BFI_SGPG_RSVD_WD_LEN];
128};
129
130/*
131 * Large Message structure - 128 Bytes size Msgs
132 */
133#define BFI_LMSG_SZ 128
134#define BFI_LMSG_PL_WSZ \
135 ((BFI_LMSG_SZ - sizeof(struct bfi_mhdr_s)) / 4)
136
137struct bfi_msg_s {
138 struct bfi_mhdr_s mhdr;
139 u32 pl[BFI_LMSG_PL_WSZ];
140};
141
142/*
143 * Mailbox message structure
144 */
145#define BFI_MBMSG_SZ 7
146struct bfi_mbmsg_s {
147 struct bfi_mhdr_s mh;
148 u32 pl[BFI_MBMSG_SZ];
149};
150
151/*
152 * Message Classes
153 */
154enum bfi_mclass {
155 BFI_MC_IOC = 1, /* IO Controller (IOC) */
156 BFI_MC_FCPORT = 5, /* FC port */
157 BFI_MC_IOCFC = 6, /* FC - IO Controller (IOC) */
158 BFI_MC_LL = 7, /* Link Layer */
159 BFI_MC_UF = 8, /* Unsolicited frame receive */
160 BFI_MC_FCXP = 9, /* FC Transport */
161 BFI_MC_LPS = 10, /* lport fc login services */
162 BFI_MC_RPORT = 11, /* Remote port */
163 BFI_MC_ITNIM = 12, /* I-T nexus (Initiator mode) */
164 BFI_MC_IOIM_READ = 13, /* read IO (Initiator mode) */
165 BFI_MC_IOIM_WRITE = 14, /* write IO (Initiator mode) */
166 BFI_MC_IOIM_IO = 15, /* IO (Initiator mode) */
167 BFI_MC_IOIM = 16, /* IO (Initiator mode) */
168 BFI_MC_IOIM_IOCOM = 17, /* good IO completion */
169 BFI_MC_TSKIM = 18, /* Initiator Task management */
170 BFI_MC_PORT = 21, /* Physical port */
171 BFI_MC_MAX = 32
172};
173
174#define BFI_IOC_MAX_CQS 4
175#define BFI_IOC_MAX_CQS_ASIC 8
176#define BFI_IOC_MSGLEN_MAX 32 /* 32 bytes */
177
178#define BFI_BOOT_TYPE_OFF 8
179#define BFI_BOOT_LOADER_OFF 12
180
181#define BFI_BOOT_TYPE_NORMAL 0
182#define BFI_BOOT_TYPE_FLASH 1
183#define BFI_BOOT_TYPE_MEMTEST 2
184
185#define BFI_BOOT_LOADER_OS 0
186#define BFI_BOOT_LOADER_BIOS 1
187#define BFI_BOOT_LOADER_UEFI 2
188
189/*
190 *----------------------------------------------------------------------
191 * IOC
192 *----------------------------------------------------------------------
193 */
194
195enum bfi_ioc_h2i_msgs {
196 BFI_IOC_H2I_ENABLE_REQ = 1,
197 BFI_IOC_H2I_DISABLE_REQ = 2,
198 BFI_IOC_H2I_GETATTR_REQ = 3,
199 BFI_IOC_H2I_DBG_SYNC = 4,
200 BFI_IOC_H2I_DBG_DUMP = 5,
201};
202
203enum bfi_ioc_i2h_msgs {
204 BFI_IOC_I2H_ENABLE_REPLY = BFA_I2HM(1),
205 BFI_IOC_I2H_DISABLE_REPLY = BFA_I2HM(2),
206 BFI_IOC_I2H_GETATTR_REPLY = BFA_I2HM(3),
207 BFI_IOC_I2H_READY_EVENT = BFA_I2HM(4),
208 BFI_IOC_I2H_HBEAT = BFA_I2HM(5),
209};
210
211/*
212 * BFI_IOC_H2I_GETATTR_REQ message
213 */
214struct bfi_ioc_getattr_req_s {
215 struct bfi_mhdr_s mh;
216 union bfi_addr_u attr_addr;
217};
218
219struct bfi_ioc_attr_s {
220 wwn_t mfg_pwwn; /* Mfg port wwn */
221 wwn_t mfg_nwwn; /* Mfg node wwn */
222 mac_t mfg_mac; /* Mfg mac */
223 u16 rsvd_a;
224 wwn_t pwwn;
225 wwn_t nwwn;
226 mac_t mac; /* PBC or Mfg mac */
227 u16 rsvd_b;
228 mac_t fcoe_mac;
229 u16 rsvd_c;
230 char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
231 u8 pcie_gen;
232 u8 pcie_lanes_orig;
233 u8 pcie_lanes;
234 u8 rx_bbcredit; /* receive buffer credits */
235 u32 adapter_prop; /* adapter properties */
236 u16 maxfrsize; /* max receive frame size */
237 char asic_rev;
238 u8 rsvd_d;
239 char fw_version[BFA_VERSION_LEN];
240 char optrom_version[BFA_VERSION_LEN];
241 struct bfa_mfg_vpd_s vpd;
242 u32 card_type; /* card type */
243};
244
245/*
246 * BFI_IOC_I2H_GETATTR_REPLY message
247 */
248struct bfi_ioc_getattr_reply_s {
249 struct bfi_mhdr_s mh; /* Common msg header */
250 u8 status; /* cfg reply status */
251 u8 rsvd[3];
252};
253
254/*
255 * Firmware memory page offsets
256 */
257#define BFI_IOC_SMEM_PG0_CB (0x40)
258#define BFI_IOC_SMEM_PG0_CT (0x180)
259
260/*
261 * Firmware statistic offset
262 */
263#define BFI_IOC_FWSTATS_OFF (0x6B40)
264#define BFI_IOC_FWSTATS_SZ (4096)
265
266/*
267 * Firmware trace offset
268 */
269#define BFI_IOC_TRC_OFF (0x4b00)
270#define BFI_IOC_TRC_ENTS 256
271
272#define BFI_IOC_FW_SIGNATURE (0xbfadbfad)
273#define BFI_IOC_MD5SUM_SZ 4
274struct bfi_ioc_image_hdr_s {
275 u32 signature; /* constant signature */
276 u32 rsvd_a;
277 u32 exec; /* exec vector */
278 u32 param; /* parameters */
279 u32 rsvd_b[4];
280 u32 md5sum[BFI_IOC_MD5SUM_SZ];
281};
282
283/*
284 * BFI_IOC_I2H_READY_EVENT message
285 */
286struct bfi_ioc_rdy_event_s {
287 struct bfi_mhdr_s mh; /* common msg header */
288 u8 init_status; /* init event status */
289 u8 rsvd[3];
290};
291
292struct bfi_ioc_hbeat_s {
293 struct bfi_mhdr_s mh; /* common msg header */
294 u32 hb_count; /* current heart beat count */
295};
296
297/*
298 * IOC hardware/firmware state
299 */
300enum bfi_ioc_state {
301 BFI_IOC_UNINIT = 0, /* not initialized */
302 BFI_IOC_INITING = 1, /* h/w is being initialized */
303 BFI_IOC_HWINIT = 2, /* h/w is initialized */
304 BFI_IOC_CFG = 3, /* IOC configuration in progress */
305 BFI_IOC_OP = 4, /* IOC is operational */
306 BFI_IOC_DISABLING = 5, /* IOC is being disabled */
307 BFI_IOC_DISABLED = 6, /* IOC is disabled */
308 BFI_IOC_CFG_DISABLED = 7, /* IOC is being disabled;transient */
309 BFI_IOC_FAIL = 8, /* IOC heart-beat failure */
310 BFI_IOC_MEMTEST = 9, /* IOC is doing memtest */
311};
312
313#define BFI_IOC_ENDIAN_SIG 0x12345678
314
315enum {
316 BFI_ADAPTER_TYPE_FC = 0x01, /* FC adapters */
317 BFI_ADAPTER_TYPE_MK = 0x0f0000, /* adapter type mask */
318 BFI_ADAPTER_TYPE_SH = 16, /* adapter type shift */
319 BFI_ADAPTER_NPORTS_MK = 0xff00, /* number of ports mask */
320 BFI_ADAPTER_NPORTS_SH = 8, /* number of ports shift */
321 BFI_ADAPTER_SPEED_MK = 0xff, /* adapter speed mask */
322 BFI_ADAPTER_SPEED_SH = 0, /* adapter speed shift */
323 BFI_ADAPTER_PROTO = 0x100000, /* prototype adapaters */
324 BFI_ADAPTER_TTV = 0x200000, /* TTV debug capable */
325 BFI_ADAPTER_UNSUPP = 0x400000, /* unknown adapter type */
326};
327
328#define BFI_ADAPTER_GETP(__prop, __adap_prop) \
329 (((__adap_prop) & BFI_ADAPTER_ ## __prop ## _MK) >> \
330 BFI_ADAPTER_ ## __prop ## _SH)
331#define BFI_ADAPTER_SETP(__prop, __val) \
332 ((__val) << BFI_ADAPTER_ ## __prop ## _SH)
333#define BFI_ADAPTER_IS_PROTO(__adap_type) \
334 ((__adap_type) & BFI_ADAPTER_PROTO)
335#define BFI_ADAPTER_IS_TTV(__adap_type) \
336 ((__adap_type) & BFI_ADAPTER_TTV)
337#define BFI_ADAPTER_IS_UNSUPP(__adap_type) \
338 ((__adap_type) & BFI_ADAPTER_UNSUPP)
339#define BFI_ADAPTER_IS_SPECIAL(__adap_type) \
340 ((__adap_type) & (BFI_ADAPTER_TTV | BFI_ADAPTER_PROTO | \
341 BFI_ADAPTER_UNSUPP))
342
343/*
344 * BFI_IOC_H2I_ENABLE_REQ & BFI_IOC_H2I_DISABLE_REQ messages
345 */
346struct bfi_ioc_ctrl_req_s {
347 struct bfi_mhdr_s mh;
348 u8 ioc_class;
349 u8 rsvd[3];
350 u32 tv_sec;
351};
352#define bfi_ioc_enable_req_t struct bfi_ioc_ctrl_req_s;
353#define bfi_ioc_disable_req_t struct bfi_ioc_ctrl_req_s;
354
355/*
356 * BFI_IOC_I2H_ENABLE_REPLY & BFI_IOC_I2H_DISABLE_REPLY messages
357 */
358struct bfi_ioc_ctrl_reply_s {
359 struct bfi_mhdr_s mh; /* Common msg header */
360 u8 status; /* enable/disable status */
361 u8 rsvd[3];
362};
363#define bfi_ioc_enable_reply_t struct bfi_ioc_ctrl_reply_s;
364#define bfi_ioc_disable_reply_t struct bfi_ioc_ctrl_reply_s;
365
366#define BFI_IOC_MSGSZ 8
367/*
368 * H2I Messages
369 */
370union bfi_ioc_h2i_msg_u {
371 struct bfi_mhdr_s mh;
372 struct bfi_ioc_ctrl_req_s enable_req;
373 struct bfi_ioc_ctrl_req_s disable_req;
374 struct bfi_ioc_getattr_req_s getattr_req;
375 u32 mboxmsg[BFI_IOC_MSGSZ];
376};
377
378/*
379 * I2H Messages
380 */
381union bfi_ioc_i2h_msg_u {
382 struct bfi_mhdr_s mh;
383 struct bfi_ioc_rdy_event_s rdy_event;
384 u32 mboxmsg[BFI_IOC_MSGSZ];
385};
386
387
388/*
389 *----------------------------------------------------------------------
390 * PBC
391 *----------------------------------------------------------------------
392 */
393
394#define BFI_PBC_MAX_BLUNS 8
395#define BFI_PBC_MAX_VPORTS 16
396
397/*
398 * PBC boot lun configuration
399 */
400struct bfi_pbc_blun_s {
401 wwn_t tgt_pwwn;
402 struct scsi_lun tgt_lun;
403};
404
405/*
406 * PBC virtual port configuration
407 */
408struct bfi_pbc_vport_s {
409 wwn_t vp_pwwn;
410 wwn_t vp_nwwn;
411};
412
413/*
414 * BFI pre-boot configuration information
415 */
416struct bfi_pbc_s {
417 u8 port_enabled;
418 u8 boot_enabled;
419 u8 nbluns;
420 u8 nvports;
421 u8 port_speed;
422 u8 rsvd_a;
423 u16 hss;
424 wwn_t pbc_pwwn;
425 wwn_t pbc_nwwn;
426 struct bfi_pbc_blun_s blun[BFI_PBC_MAX_BLUNS];
427 struct bfi_pbc_vport_s vport[BFI_PBC_MAX_VPORTS];
428};
429
430/*
431 *----------------------------------------------------------------------
432 * MSGQ
433 *----------------------------------------------------------------------
434 */
435#define BFI_MSGQ_FULL(_q) (((_q->pi + 1) % _q->q_depth) == _q->ci)
436#define BFI_MSGQ_EMPTY(_q) (_q->pi == _q->ci)
437#define BFI_MSGQ_UPDATE_CI(_q) (_q->ci = (_q->ci + 1) % _q->q_depth)
438#define BFI_MSGQ_UPDATE_PI(_q) (_q->pi = (_q->pi + 1) % _q->q_depth)
439
440/* q_depth must be power of 2 */
441#define BFI_MSGQ_FREE_CNT(_q) ((_q->ci - _q->pi - 1) & (_q->q_depth - 1))
442
443enum bfi_msgq_h2i_msgs_e {
444 BFI_MSGQ_H2I_INIT_REQ = 1,
445 BFI_MSGQ_H2I_DOORBELL = 2,
446 BFI_MSGQ_H2I_SHUTDOWN = 3,
447};
448
449enum bfi_msgq_i2h_msgs_e {
450 BFI_MSGQ_I2H_INIT_RSP = 1,
451 BFI_MSGQ_I2H_DOORBELL = 2,
452};
453
454
455/* Messages(commands/responsed/AENS will have the following header */
456struct bfi_msgq_mhdr_s {
457 u8 msg_class;
458 u8 msg_id;
459 u16 msg_token;
460 u16 num_entries;
461 u8 enet_id;
462 u8 rsvd[1];
463};
464
465#define bfi_msgq_mhdr_set(_mh, _mc, _mid, _tok, _enet_id) do { \
466 (_mh).msg_class = (_mc); \
467 (_mh).msg_id = (_mid); \
468 (_mh).msg_token = (_tok); \
469 (_mh).enet_id = (_enet_id); \
470} while (0)
471
472/*
473 * Mailbox for messaging interface
474 *
475*/
476#define BFI_MSGQ_CMD_ENTRY_SIZE (64) /* TBD */
477#define BFI_MSGQ_RSP_ENTRY_SIZE (64) /* TBD */
478#define BFI_MSGQ_MSG_SIZE_MAX (2048) /* TBD */
479
480struct bfi_msgq_s {
481 union bfi_addr_u addr;
482 u16 q_depth; /* Total num of entries in the queue */
483 u8 rsvd[2];
484};
485
486/* BFI_ENET_MSGQ_CFG_REQ TBD init or cfg? */
487struct bfi_msgq_cfg_req_s {
488 struct bfi_mhdr_s mh;
489 struct bfi_msgq_s cmdq;
490 struct bfi_msgq_s rspq;
491};
492
493/* BFI_ENET_MSGQ_CFG_RSP */
494struct bfi_msgq_cfg_rsp_s {
495 struct bfi_mhdr_s mh;
496 u8 cmd_status;
497 u8 rsvd[3];
498};
499
500
501/* BFI_MSGQ_H2I_DOORBELL */
502struct bfi_msgq_h2i_db_s {
503 struct bfi_mhdr_s mh;
504 u16 cmdq_pi;
505 u16 rspq_ci;
506};
507
508/* BFI_MSGQ_I2H_DOORBELL */
509struct bfi_msgq_i2h_db_s {
510 struct bfi_mhdr_s mh;
511 u16 rspq_pi;
512 u16 cmdq_ci;
513};
514
515#pragma pack()
516
517/* BFI port specific */
518#pragma pack(1)
519
520enum bfi_port_h2i {
521 BFI_PORT_H2I_ENABLE_REQ = (1),
522 BFI_PORT_H2I_DISABLE_REQ = (2),
523 BFI_PORT_H2I_GET_STATS_REQ = (3),
524 BFI_PORT_H2I_CLEAR_STATS_REQ = (4),
525};
526
527enum bfi_port_i2h {
528 BFI_PORT_I2H_ENABLE_RSP = BFA_I2HM(1),
529 BFI_PORT_I2H_DISABLE_RSP = BFA_I2HM(2),
530 BFI_PORT_I2H_GET_STATS_RSP = BFA_I2HM(3),
531 BFI_PORT_I2H_CLEAR_STATS_RSP = BFA_I2HM(4),
532};
533
534/*
535 * Generic REQ type
536 */
537struct bfi_port_generic_req_s {
538 struct bfi_mhdr_s mh; /* msg header */
539 u32 msgtag; /* msgtag for reply */
540 u32 rsvd;
541};
542
543/*
544 * Generic RSP type
545 */
546struct bfi_port_generic_rsp_s {
547 struct bfi_mhdr_s mh; /* common msg header */
548 u8 status; /* port enable status */
549 u8 rsvd[3];
550 u32 msgtag; /* msgtag for reply */
551};
552
553/*
554 * BFI_PORT_H2I_GET_STATS_REQ
555 */
556struct bfi_port_get_stats_req_s {
557 struct bfi_mhdr_s mh; /* common msg header */
558 union bfi_addr_u dma_addr;
559};
560
561union bfi_port_h2i_msg_u {
562 struct bfi_mhdr_s mh;
563 struct bfi_port_generic_req_s enable_req;
564 struct bfi_port_generic_req_s disable_req;
565 struct bfi_port_get_stats_req_s getstats_req;
566 struct bfi_port_generic_req_s clearstats_req;
567};
568
569union bfi_port_i2h_msg_u {
570 struct bfi_mhdr_s mh;
571 struct bfi_port_generic_rsp_s enable_rsp;
572 struct bfi_port_generic_rsp_s disable_rsp;
573 struct bfi_port_generic_rsp_s getstats_rsp;
574 struct bfi_port_generic_rsp_s clearstats_rsp;
575};
576
577#pragma pack()
578
579#endif /* __BFI_H__ */
diff --git a/drivers/scsi/bfa/include/bfi/bfi_cbreg.h b/drivers/scsi/bfa/bfi_cbreg.h
index a51ee61ddb19..39ad42b66b5b 100644
--- a/drivers/scsi/bfa/include/bfi/bfi_cbreg.h
+++ b/drivers/scsi/bfa/bfi_cbreg.h
@@ -1,19 +1,3 @@
1/*
2 * Copyright (c) 2005-2009 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 1
18/* 2/*
19 * bfi_cbreg.h crossbow host block register definitions 3 * bfi_cbreg.h crossbow host block register definitions
@@ -177,8 +161,8 @@
177#define __PSS_LMEM_INIT_EN 0x00000100 161#define __PSS_LMEM_INIT_EN 0x00000100
178#define __PSS_LPU1_RESET 0x00000002 162#define __PSS_LPU1_RESET 0x00000002
179#define __PSS_LPU0_RESET 0x00000001 163#define __PSS_LPU0_RESET 0x00000001
180#define PSS_ERR_STATUS_REG 0x00018810 164#define PSS_ERR_STATUS_REG 0x00018810
181#define __PSS_LMEM1_CORR_ERR 0x00000800 165#define __PSS_LMEM1_CORR_ERR 0x00000800
182#define __PSS_LMEM0_CORR_ERR 0x00000400 166#define __PSS_LMEM0_CORR_ERR 0x00000400
183#define __PSS_LMEM1_UNCORR_ERR 0x00000200 167#define __PSS_LMEM1_UNCORR_ERR 0x00000200
184#define __PSS_LMEM0_UNCORR_ERR 0x00000100 168#define __PSS_LMEM0_UNCORR_ERR 0x00000100
@@ -190,8 +174,9 @@
190#define __PSS_SGM_IF_ERR 0x00000004 174#define __PSS_SGM_IF_ERR 0x00000004
191#define __PSS_LPU1_RAM_ERR 0x00000002 175#define __PSS_LPU1_RAM_ERR 0x00000002
192#define __PSS_LPU0_RAM_ERR 0x00000001 176#define __PSS_LPU0_RAM_ERR 0x00000001
193#define ERR_SET_REG 0x00018818 177#define ERR_SET_REG 0x00018818
194#define __PSS_ERR_STATUS_SET 0x00000fff 178#define __PSS_ERR_STATUS_SET 0x00000fff
179
195 180
196/* 181/*
197 * These definitions are either in error/missing in spec. Its auto-generated 182 * These definitions are either in error/missing in spec. Its auto-generated
@@ -223,6 +208,7 @@
223#define BFA_IOC1_HBEAT_REG HOST_SEM2_INFO_REG 208#define BFA_IOC1_HBEAT_REG HOST_SEM2_INFO_REG
224#define BFA_IOC1_STATE_REG HOST_SEM3_INFO_REG 209#define BFA_IOC1_STATE_REG HOST_SEM3_INFO_REG
225#define BFA_FW_USE_COUNT HOST_SEM4_INFO_REG 210#define BFA_FW_USE_COUNT HOST_SEM4_INFO_REG
211#define BFA_IOC_FAIL_SYNC HOST_SEM5_INFO_REG
226 212
227#define CPE_Q_DEPTH(__n) \ 213#define CPE_Q_DEPTH(__n) \
228 (CPE_Q0_DEPTH + (__n) * (CPE_Q1_DEPTH - CPE_Q0_DEPTH)) 214 (CPE_Q0_DEPTH + (__n) * (CPE_Q1_DEPTH - CPE_Q0_DEPTH))
diff --git a/drivers/scsi/bfa/bfi_ctreg.h b/drivers/scsi/bfa/bfi_ctreg.h
new file mode 100644
index 000000000000..fc4ce4a5a183
--- /dev/null
+++ b/drivers/scsi/bfa/bfi_ctreg.h
@@ -0,0 +1,636 @@
1
2/*
3 * bfi_ctreg.h catapult host block register definitions
4 *
5 * !!! Do not edit. Auto generated. !!!
6 */
7
8#ifndef __BFI_CTREG_H__
9#define __BFI_CTREG_H__
10
11
12#define HOSTFN0_LPU_MBOX0_0 0x00019200
13#define HOSTFN1_LPU_MBOX0_8 0x00019260
14#define LPU_HOSTFN0_MBOX0_0 0x00019280
15#define LPU_HOSTFN1_MBOX0_8 0x000192e0
16#define HOSTFN2_LPU_MBOX0_0 0x00019400
17#define HOSTFN3_LPU_MBOX0_8 0x00019460
18#define LPU_HOSTFN2_MBOX0_0 0x00019480
19#define LPU_HOSTFN3_MBOX0_8 0x000194e0
20#define HOSTFN0_INT_STATUS 0x00014000
21#define __HOSTFN0_HALT_OCCURRED 0x01000000
22#define __HOSTFN0_INT_STATUS_LVL_MK 0x00f00000
23#define __HOSTFN0_INT_STATUS_LVL_SH 20
24#define __HOSTFN0_INT_STATUS_LVL(_v) ((_v) << __HOSTFN0_INT_STATUS_LVL_SH)
25#define __HOSTFN0_INT_STATUS_P_MK 0x000f0000
26#define __HOSTFN0_INT_STATUS_P_SH 16
27#define __HOSTFN0_INT_STATUS_P(_v) ((_v) << __HOSTFN0_INT_STATUS_P_SH)
28#define __HOSTFN0_INT_STATUS_F 0x0000ffff
29#define HOSTFN0_INT_MSK 0x00014004
30#define HOST_PAGE_NUM_FN0 0x00014008
31#define __HOST_PAGE_NUM_FN 0x000001ff
32#define HOST_MSIX_ERR_INDEX_FN0 0x0001400c
33#define __MSIX_ERR_INDEX_FN 0x000001ff
34#define HOSTFN1_INT_STATUS 0x00014100
35#define __HOSTFN1_HALT_OCCURRED 0x01000000
36#define __HOSTFN1_INT_STATUS_LVL_MK 0x00f00000
37#define __HOSTFN1_INT_STATUS_LVL_SH 20
38#define __HOSTFN1_INT_STATUS_LVL(_v) ((_v) << __HOSTFN1_INT_STATUS_LVL_SH)
39#define __HOSTFN1_INT_STATUS_P_MK 0x000f0000
40#define __HOSTFN1_INT_STATUS_P_SH 16
41#define __HOSTFN1_INT_STATUS_P(_v) ((_v) << __HOSTFN1_INT_STATUS_P_SH)
42#define __HOSTFN1_INT_STATUS_F 0x0000ffff
43#define HOSTFN1_INT_MSK 0x00014104
44#define HOST_PAGE_NUM_FN1 0x00014108
45#define HOST_MSIX_ERR_INDEX_FN1 0x0001410c
46#define APP_PLL_425_CTL_REG 0x00014204
47#define __P_425_PLL_LOCK 0x80000000
48#define __APP_PLL_425_SRAM_USE_100MHZ 0x00100000
49#define __APP_PLL_425_RESET_TIMER_MK 0x000e0000
50#define __APP_PLL_425_RESET_TIMER_SH 17
51#define __APP_PLL_425_RESET_TIMER(_v) ((_v) << __APP_PLL_425_RESET_TIMER_SH)
52#define __APP_PLL_425_LOGIC_SOFT_RESET 0x00010000
53#define __APP_PLL_425_CNTLMT0_1_MK 0x0000c000
54#define __APP_PLL_425_CNTLMT0_1_SH 14
55#define __APP_PLL_425_CNTLMT0_1(_v) ((_v) << __APP_PLL_425_CNTLMT0_1_SH)
56#define __APP_PLL_425_JITLMT0_1_MK 0x00003000
57#define __APP_PLL_425_JITLMT0_1_SH 12
58#define __APP_PLL_425_JITLMT0_1(_v) ((_v) << __APP_PLL_425_JITLMT0_1_SH)
59#define __APP_PLL_425_HREF 0x00000800
60#define __APP_PLL_425_HDIV 0x00000400
61#define __APP_PLL_425_P0_1_MK 0x00000300
62#define __APP_PLL_425_P0_1_SH 8
63#define __APP_PLL_425_P0_1(_v) ((_v) << __APP_PLL_425_P0_1_SH)
64#define __APP_PLL_425_Z0_2_MK 0x000000e0
65#define __APP_PLL_425_Z0_2_SH 5
66#define __APP_PLL_425_Z0_2(_v) ((_v) << __APP_PLL_425_Z0_2_SH)
67#define __APP_PLL_425_RSEL200500 0x00000010
68#define __APP_PLL_425_ENARST 0x00000008
69#define __APP_PLL_425_BYPASS 0x00000004
70#define __APP_PLL_425_LRESETN 0x00000002
71#define __APP_PLL_425_ENABLE 0x00000001
72#define APP_PLL_312_CTL_REG 0x00014208
73#define __P_312_PLL_LOCK 0x80000000
74#define __ENABLE_MAC_AHB_1 0x00800000
75#define __ENABLE_MAC_AHB_0 0x00400000
76#define __ENABLE_MAC_1 0x00200000
77#define __ENABLE_MAC_0 0x00100000
78#define __APP_PLL_312_RESET_TIMER_MK 0x000e0000
79#define __APP_PLL_312_RESET_TIMER_SH 17
80#define __APP_PLL_312_RESET_TIMER(_v) ((_v) << __APP_PLL_312_RESET_TIMER_SH)
81#define __APP_PLL_312_LOGIC_SOFT_RESET 0x00010000
82#define __APP_PLL_312_CNTLMT0_1_MK 0x0000c000
83#define __APP_PLL_312_CNTLMT0_1_SH 14
84#define __APP_PLL_312_CNTLMT0_1(_v) ((_v) << __APP_PLL_312_CNTLMT0_1_SH)
85#define __APP_PLL_312_JITLMT0_1_MK 0x00003000
86#define __APP_PLL_312_JITLMT0_1_SH 12
87#define __APP_PLL_312_JITLMT0_1(_v) ((_v) << __APP_PLL_312_JITLMT0_1_SH)
88#define __APP_PLL_312_HREF 0x00000800
89#define __APP_PLL_312_HDIV 0x00000400
90#define __APP_PLL_312_P0_1_MK 0x00000300
91#define __APP_PLL_312_P0_1_SH 8
92#define __APP_PLL_312_P0_1(_v) ((_v) << __APP_PLL_312_P0_1_SH)
93#define __APP_PLL_312_Z0_2_MK 0x000000e0
94#define __APP_PLL_312_Z0_2_SH 5
95#define __APP_PLL_312_Z0_2(_v) ((_v) << __APP_PLL_312_Z0_2_SH)
96#define __APP_PLL_312_RSEL200500 0x00000010
97#define __APP_PLL_312_ENARST 0x00000008
98#define __APP_PLL_312_BYPASS 0x00000004
99#define __APP_PLL_312_LRESETN 0x00000002
100#define __APP_PLL_312_ENABLE 0x00000001
101#define MBIST_CTL_REG 0x00014220
102#define __EDRAM_BISTR_START 0x00000004
103#define __MBIST_RESET 0x00000002
104#define __MBIST_START 0x00000001
105#define MBIST_STAT_REG 0x00014224
106#define __EDRAM_BISTR_STATUS 0x00000008
107#define __EDRAM_BISTR_DONE 0x00000004
108#define __MEM_BIT_STATUS 0x00000002
109#define __MBIST_DONE 0x00000001
110#define HOST_SEM0_REG 0x00014230
111#define __HOST_SEMAPHORE 0x00000001
112#define HOST_SEM1_REG 0x00014234
113#define HOST_SEM2_REG 0x00014238
114#define HOST_SEM3_REG 0x0001423c
115#define HOST_SEM0_INFO_REG 0x00014240
116#define HOST_SEM1_INFO_REG 0x00014244
117#define HOST_SEM2_INFO_REG 0x00014248
118#define HOST_SEM3_INFO_REG 0x0001424c
119#define ETH_MAC_SER_REG 0x00014288
120#define __APP_EMS_CKBUFAMPIN 0x00000020
121#define __APP_EMS_REFCLKSEL 0x00000010
122#define __APP_EMS_CMLCKSEL 0x00000008
123#define __APP_EMS_REFCKBUFEN2 0x00000004
124#define __APP_EMS_REFCKBUFEN1 0x00000002
125#define __APP_EMS_CHANNEL_SEL 0x00000001
126#define HOSTFN2_INT_STATUS 0x00014300
127#define __HOSTFN2_HALT_OCCURRED 0x01000000
128#define __HOSTFN2_INT_STATUS_LVL_MK 0x00f00000
129#define __HOSTFN2_INT_STATUS_LVL_SH 20
130#define __HOSTFN2_INT_STATUS_LVL(_v) ((_v) << __HOSTFN2_INT_STATUS_LVL_SH)
131#define __HOSTFN2_INT_STATUS_P_MK 0x000f0000
132#define __HOSTFN2_INT_STATUS_P_SH 16
133#define __HOSTFN2_INT_STATUS_P(_v) ((_v) << __HOSTFN2_INT_STATUS_P_SH)
134#define __HOSTFN2_INT_STATUS_F 0x0000ffff
135#define HOSTFN2_INT_MSK 0x00014304
136#define HOST_PAGE_NUM_FN2 0x00014308
137#define HOST_MSIX_ERR_INDEX_FN2 0x0001430c
138#define HOSTFN3_INT_STATUS 0x00014400
139#define __HALT_OCCURRED 0x01000000
140#define __HOSTFN3_INT_STATUS_LVL_MK 0x00f00000
141#define __HOSTFN3_INT_STATUS_LVL_SH 20
142#define __HOSTFN3_INT_STATUS_LVL(_v) ((_v) << __HOSTFN3_INT_STATUS_LVL_SH)
143#define __HOSTFN3_INT_STATUS_P_MK 0x000f0000
144#define __HOSTFN3_INT_STATUS_P_SH 16
145#define __HOSTFN3_INT_STATUS_P(_v) ((_v) << __HOSTFN3_INT_STATUS_P_SH)
146#define __HOSTFN3_INT_STATUS_F 0x0000ffff
147#define HOSTFN3_INT_MSK 0x00014404
148#define HOST_PAGE_NUM_FN3 0x00014408
149#define HOST_MSIX_ERR_INDEX_FN3 0x0001440c
150#define FNC_ID_REG 0x00014600
151#define __FUNCTION_NUMBER 0x00000007
152#define FNC_PERS_REG 0x00014604
153#define __F3_FUNCTION_ACTIVE 0x80000000
154#define __F3_FUNCTION_MODE 0x40000000
155#define __F3_PORT_MAP_MK 0x30000000
156#define __F3_PORT_MAP_SH 28
157#define __F3_PORT_MAP(_v) ((_v) << __F3_PORT_MAP_SH)
158#define __F3_VM_MODE 0x08000000
159#define __F3_INTX_STATUS_MK 0x07000000
160#define __F3_INTX_STATUS_SH 24
161#define __F3_INTX_STATUS(_v) ((_v) << __F3_INTX_STATUS_SH)
162#define __F2_FUNCTION_ACTIVE 0x00800000
163#define __F2_FUNCTION_MODE 0x00400000
164#define __F2_PORT_MAP_MK 0x00300000
165#define __F2_PORT_MAP_SH 20
166#define __F2_PORT_MAP(_v) ((_v) << __F2_PORT_MAP_SH)
167#define __F2_VM_MODE 0x00080000
168#define __F2_INTX_STATUS_MK 0x00070000
169#define __F2_INTX_STATUS_SH 16
170#define __F2_INTX_STATUS(_v) ((_v) << __F2_INTX_STATUS_SH)
171#define __F1_FUNCTION_ACTIVE 0x00008000
172#define __F1_FUNCTION_MODE 0x00004000
173#define __F1_PORT_MAP_MK 0x00003000
174#define __F1_PORT_MAP_SH 12
175#define __F1_PORT_MAP(_v) ((_v) << __F1_PORT_MAP_SH)
176#define __F1_VM_MODE 0x00000800
177#define __F1_INTX_STATUS_MK 0x00000700
178#define __F1_INTX_STATUS_SH 8
179#define __F1_INTX_STATUS(_v) ((_v) << __F1_INTX_STATUS_SH)
180#define __F0_FUNCTION_ACTIVE 0x00000080
181#define __F0_FUNCTION_MODE 0x00000040
182#define __F0_PORT_MAP_MK 0x00000030
183#define __F0_PORT_MAP_SH 4
184#define __F0_PORT_MAP(_v) ((_v) << __F0_PORT_MAP_SH)
185#define __F0_VM_MODE 0x00000008
186#define __F0_INTX_STATUS 0x00000007
187enum {
188 __F0_INTX_STATUS_MSIX = 0x0,
189 __F0_INTX_STATUS_INTA = 0x1,
190 __F0_INTX_STATUS_INTB = 0x2,
191 __F0_INTX_STATUS_INTC = 0x3,
192 __F0_INTX_STATUS_INTD = 0x4,
193};
194#define OP_MODE 0x0001460c
195#define __APP_ETH_CLK_LOWSPEED 0x00000004
196#define __GLOBAL_CORECLK_HALFSPEED 0x00000002
197#define __GLOBAL_FCOE_MODE 0x00000001
198#define HOST_SEM4_REG 0x00014610
199#define HOST_SEM5_REG 0x00014614
200#define HOST_SEM6_REG 0x00014618
201#define HOST_SEM7_REG 0x0001461c
202#define HOST_SEM4_INFO_REG 0x00014620
203#define HOST_SEM5_INFO_REG 0x00014624
204#define HOST_SEM6_INFO_REG 0x00014628
205#define HOST_SEM7_INFO_REG 0x0001462c
206#define HOSTFN0_LPU0_MBOX0_CMD_STAT 0x00019000
207#define __HOSTFN0_LPU0_MBOX0_INFO_MK 0xfffffffe
208#define __HOSTFN0_LPU0_MBOX0_INFO_SH 1
209#define __HOSTFN0_LPU0_MBOX0_INFO(_v) ((_v) << __HOSTFN0_LPU0_MBOX0_INFO_SH)
210#define __HOSTFN0_LPU0_MBOX0_CMD_STATUS 0x00000001
211#define HOSTFN0_LPU1_MBOX0_CMD_STAT 0x00019004
212#define __HOSTFN0_LPU1_MBOX0_INFO_MK 0xfffffffe
213#define __HOSTFN0_LPU1_MBOX0_INFO_SH 1
214#define __HOSTFN0_LPU1_MBOX0_INFO(_v) ((_v) << __HOSTFN0_LPU1_MBOX0_INFO_SH)
215#define __HOSTFN0_LPU1_MBOX0_CMD_STATUS 0x00000001
216#define LPU0_HOSTFN0_MBOX0_CMD_STAT 0x00019008
217#define __LPU0_HOSTFN0_MBOX0_INFO_MK 0xfffffffe
218#define __LPU0_HOSTFN0_MBOX0_INFO_SH 1
219#define __LPU0_HOSTFN0_MBOX0_INFO(_v) ((_v) << __LPU0_HOSTFN0_MBOX0_INFO_SH)
220#define __LPU0_HOSTFN0_MBOX0_CMD_STATUS 0x00000001
221#define LPU1_HOSTFN0_MBOX0_CMD_STAT 0x0001900c
222#define __LPU1_HOSTFN0_MBOX0_INFO_MK 0xfffffffe
223#define __LPU1_HOSTFN0_MBOX0_INFO_SH 1
224#define __LPU1_HOSTFN0_MBOX0_INFO(_v) ((_v) << __LPU1_HOSTFN0_MBOX0_INFO_SH)
225#define __LPU1_HOSTFN0_MBOX0_CMD_STATUS 0x00000001
226#define HOSTFN1_LPU0_MBOX0_CMD_STAT 0x00019010
227#define __HOSTFN1_LPU0_MBOX0_INFO_MK 0xfffffffe
228#define __HOSTFN1_LPU0_MBOX0_INFO_SH 1
229#define __HOSTFN1_LPU0_MBOX0_INFO(_v) ((_v) << __HOSTFN1_LPU0_MBOX0_INFO_SH)
230#define __HOSTFN1_LPU0_MBOX0_CMD_STATUS 0x00000001
231#define HOSTFN1_LPU1_MBOX0_CMD_STAT 0x00019014
232#define __HOSTFN1_LPU1_MBOX0_INFO_MK 0xfffffffe
233#define __HOSTFN1_LPU1_MBOX0_INFO_SH 1
234#define __HOSTFN1_LPU1_MBOX0_INFO(_v) ((_v) << __HOSTFN1_LPU1_MBOX0_INFO_SH)
235#define __HOSTFN1_LPU1_MBOX0_CMD_STATUS 0x00000001
236#define LPU0_HOSTFN1_MBOX0_CMD_STAT 0x00019018
237#define __LPU0_HOSTFN1_MBOX0_INFO_MK 0xfffffffe
238#define __LPU0_HOSTFN1_MBOX0_INFO_SH 1
239#define __LPU0_HOSTFN1_MBOX0_INFO(_v) ((_v) << __LPU0_HOSTFN1_MBOX0_INFO_SH)
240#define __LPU0_HOSTFN1_MBOX0_CMD_STATUS 0x00000001
241#define LPU1_HOSTFN1_MBOX0_CMD_STAT 0x0001901c
242#define __LPU1_HOSTFN1_MBOX0_INFO_MK 0xfffffffe
243#define __LPU1_HOSTFN1_MBOX0_INFO_SH 1
244#define __LPU1_HOSTFN1_MBOX0_INFO(_v) ((_v) << __LPU1_HOSTFN1_MBOX0_INFO_SH)
245#define __LPU1_HOSTFN1_MBOX0_CMD_STATUS 0x00000001
246#define HOSTFN2_LPU0_MBOX0_CMD_STAT 0x00019150
247#define __HOSTFN2_LPU0_MBOX0_INFO_MK 0xfffffffe
248#define __HOSTFN2_LPU0_MBOX0_INFO_SH 1
249#define __HOSTFN2_LPU0_MBOX0_INFO(_v) ((_v) << __HOSTFN2_LPU0_MBOX0_INFO_SH)
250#define __HOSTFN2_LPU0_MBOX0_CMD_STATUS 0x00000001
251#define HOSTFN2_LPU1_MBOX0_CMD_STAT 0x00019154
252#define __HOSTFN2_LPU1_MBOX0_INFO_MK 0xfffffffe
253#define __HOSTFN2_LPU1_MBOX0_INFO_SH 1
254#define __HOSTFN2_LPU1_MBOX0_INFO(_v) ((_v) << __HOSTFN2_LPU1_MBOX0_INFO_SH)
255#define __HOSTFN2_LPU1_MBOX0BOX0_CMD_STATUS 0x00000001
256#define LPU0_HOSTFN2_MBOX0_CMD_STAT 0x00019158
257#define __LPU0_HOSTFN2_MBOX0_INFO_MK 0xfffffffe
258#define __LPU0_HOSTFN2_MBOX0_INFO_SH 1
259#define __LPU0_HOSTFN2_MBOX0_INFO(_v) ((_v) << __LPU0_HOSTFN2_MBOX0_INFO_SH)
260#define __LPU0_HOSTFN2_MBOX0_CMD_STATUS 0x00000001
261#define LPU1_HOSTFN2_MBOX0_CMD_STAT 0x0001915c
262#define __LPU1_HOSTFN2_MBOX0_INFO_MK 0xfffffffe
263#define __LPU1_HOSTFN2_MBOX0_INFO_SH 1
264#define __LPU1_HOSTFN2_MBOX0_INFO(_v) ((_v) << __LPU1_HOSTFN2_MBOX0_INFO_SH)
265#define __LPU1_HOSTFN2_MBOX0_CMD_STATUS 0x00000001
266#define HOSTFN3_LPU0_MBOX0_CMD_STAT 0x00019160
267#define __HOSTFN3_LPU0_MBOX0_INFO_MK 0xfffffffe
268#define __HOSTFN3_LPU0_MBOX0_INFO_SH 1
269#define __HOSTFN3_LPU0_MBOX0_INFO(_v) ((_v) << __HOSTFN3_LPU0_MBOX0_INFO_SH)
270#define __HOSTFN3_LPU0_MBOX0_CMD_STATUS 0x00000001
271#define HOSTFN3_LPU1_MBOX0_CMD_STAT 0x00019164
272#define __HOSTFN3_LPU1_MBOX0_INFO_MK 0xfffffffe
273#define __HOSTFN3_LPU1_MBOX0_INFO_SH 1
274#define __HOSTFN3_LPU1_MBOX0_INFO(_v) ((_v) << __HOSTFN3_LPU1_MBOX0_INFO_SH)
275#define __HOSTFN3_LPU1_MBOX0_CMD_STATUS 0x00000001
276#define LPU0_HOSTFN3_MBOX0_CMD_STAT 0x00019168
277#define __LPU0_HOSTFN3_MBOX0_INFO_MK 0xfffffffe
278#define __LPU0_HOSTFN3_MBOX0_INFO_SH 1
279#define __LPU0_HOSTFN3_MBOX0_INFO(_v) ((_v) << __LPU0_HOSTFN3_MBOX0_INFO_SH)
280#define __LPU0_HOSTFN3_MBOX0_CMD_STATUS 0x00000001
281#define LPU1_HOSTFN3_MBOX0_CMD_STAT 0x0001916c
282#define __LPU1_HOSTFN3_MBOX0_INFO_MK 0xfffffffe
283#define __LPU1_HOSTFN3_MBOX0_INFO_SH 1
284#define __LPU1_HOSTFN3_MBOX0_INFO(_v) ((_v) << __LPU1_HOSTFN3_MBOX0_INFO_SH)
285#define __LPU1_HOSTFN3_MBOX0_CMD_STATUS 0x00000001
286#define FW_INIT_HALT_P0 0x000191ac
287#define __FW_INIT_HALT_P 0x00000001
288#define FW_INIT_HALT_P1 0x000191bc
289#define CPE_PI_PTR_Q0 0x00038000
290#define __CPE_PI_UNUSED_MK 0xffff0000
291#define __CPE_PI_UNUSED_SH 16
292#define __CPE_PI_UNUSED(_v) ((_v) << __CPE_PI_UNUSED_SH)
293#define __CPE_PI_PTR 0x0000ffff
294#define CPE_PI_PTR_Q1 0x00038040
295#define CPE_CI_PTR_Q0 0x00038004
296#define __CPE_CI_UNUSED_MK 0xffff0000
297#define __CPE_CI_UNUSED_SH 16
298#define __CPE_CI_UNUSED(_v) ((_v) << __CPE_CI_UNUSED_SH)
299#define __CPE_CI_PTR 0x0000ffff
300#define CPE_CI_PTR_Q1 0x00038044
301#define CPE_DEPTH_Q0 0x00038008
302#define __CPE_DEPTH_UNUSED_MK 0xf8000000
303#define __CPE_DEPTH_UNUSED_SH 27
304#define __CPE_DEPTH_UNUSED(_v) ((_v) << __CPE_DEPTH_UNUSED_SH)
305#define __CPE_MSIX_VEC_INDEX_MK 0x07ff0000
306#define __CPE_MSIX_VEC_INDEX_SH 16
307#define __CPE_MSIX_VEC_INDEX(_v) ((_v) << __CPE_MSIX_VEC_INDEX_SH)
308#define __CPE_DEPTH 0x0000ffff
309#define CPE_DEPTH_Q1 0x00038048
310#define CPE_QCTRL_Q0 0x0003800c
311#define __CPE_CTRL_UNUSED30_MK 0xfc000000
312#define __CPE_CTRL_UNUSED30_SH 26
313#define __CPE_CTRL_UNUSED30(_v) ((_v) << __CPE_CTRL_UNUSED30_SH)
314#define __CPE_FUNC_INT_CTRL_MK 0x03000000
315#define __CPE_FUNC_INT_CTRL_SH 24
316#define __CPE_FUNC_INT_CTRL(_v) ((_v) << __CPE_FUNC_INT_CTRL_SH)
317enum {
318 __CPE_FUNC_INT_CTRL_DISABLE = 0x0,
319 __CPE_FUNC_INT_CTRL_F2NF = 0x1,
320 __CPE_FUNC_INT_CTRL_3QUART = 0x2,
321 __CPE_FUNC_INT_CTRL_HALF = 0x3,
322};
323#define __CPE_CTRL_UNUSED20_MK 0x00f00000
324#define __CPE_CTRL_UNUSED20_SH 20
325#define __CPE_CTRL_UNUSED20(_v) ((_v) << __CPE_CTRL_UNUSED20_SH)
326#define __CPE_SCI_TH_MK 0x000f0000
327#define __CPE_SCI_TH_SH 16
328#define __CPE_SCI_TH(_v) ((_v) << __CPE_SCI_TH_SH)
329#define __CPE_CTRL_UNUSED10_MK 0x0000c000
330#define __CPE_CTRL_UNUSED10_SH 14
331#define __CPE_CTRL_UNUSED10(_v) ((_v) << __CPE_CTRL_UNUSED10_SH)
332#define __CPE_ACK_PENDING 0x00002000
333#define __CPE_CTRL_UNUSED40_MK 0x00001c00
334#define __CPE_CTRL_UNUSED40_SH 10
335#define __CPE_CTRL_UNUSED40(_v) ((_v) << __CPE_CTRL_UNUSED40_SH)
336#define __CPE_PCIEID_MK 0x00000300
337#define __CPE_PCIEID_SH 8
338#define __CPE_PCIEID(_v) ((_v) << __CPE_PCIEID_SH)
339#define __CPE_CTRL_UNUSED00_MK 0x000000fe
340#define __CPE_CTRL_UNUSED00_SH 1
341#define __CPE_CTRL_UNUSED00(_v) ((_v) << __CPE_CTRL_UNUSED00_SH)
342#define __CPE_ESIZE 0x00000001
343#define CPE_QCTRL_Q1 0x0003804c
344#define __CPE_CTRL_UNUSED31_MK 0xfc000000
345#define __CPE_CTRL_UNUSED31_SH 26
346#define __CPE_CTRL_UNUSED31(_v) ((_v) << __CPE_CTRL_UNUSED31_SH)
347#define __CPE_CTRL_UNUSED21_MK 0x00f00000
348#define __CPE_CTRL_UNUSED21_SH 20
349#define __CPE_CTRL_UNUSED21(_v) ((_v) << __CPE_CTRL_UNUSED21_SH)
350#define __CPE_CTRL_UNUSED11_MK 0x0000c000
351#define __CPE_CTRL_UNUSED11_SH 14
352#define __CPE_CTRL_UNUSED11(_v) ((_v) << __CPE_CTRL_UNUSED11_SH)
353#define __CPE_CTRL_UNUSED41_MK 0x00001c00
354#define __CPE_CTRL_UNUSED41_SH 10
355#define __CPE_CTRL_UNUSED41(_v) ((_v) << __CPE_CTRL_UNUSED41_SH)
356#define __CPE_CTRL_UNUSED01_MK 0x000000fe
357#define __CPE_CTRL_UNUSED01_SH 1
358#define __CPE_CTRL_UNUSED01(_v) ((_v) << __CPE_CTRL_UNUSED01_SH)
359#define RME_PI_PTR_Q0 0x00038020
360#define __LATENCY_TIME_STAMP_MK 0xffff0000
361#define __LATENCY_TIME_STAMP_SH 16
362#define __LATENCY_TIME_STAMP(_v) ((_v) << __LATENCY_TIME_STAMP_SH)
363#define __RME_PI_PTR 0x0000ffff
364#define RME_PI_PTR_Q1 0x00038060
365#define RME_CI_PTR_Q0 0x00038024
366#define __DELAY_TIME_STAMP_MK 0xffff0000
367#define __DELAY_TIME_STAMP_SH 16
368#define __DELAY_TIME_STAMP(_v) ((_v) << __DELAY_TIME_STAMP_SH)
369#define __RME_CI_PTR 0x0000ffff
370#define RME_CI_PTR_Q1 0x00038064
371#define RME_DEPTH_Q0 0x00038028
372#define __RME_DEPTH_UNUSED_MK 0xf8000000
373#define __RME_DEPTH_UNUSED_SH 27
374#define __RME_DEPTH_UNUSED(_v) ((_v) << __RME_DEPTH_UNUSED_SH)
375#define __RME_MSIX_VEC_INDEX_MK 0x07ff0000
376#define __RME_MSIX_VEC_INDEX_SH 16
377#define __RME_MSIX_VEC_INDEX(_v) ((_v) << __RME_MSIX_VEC_INDEX_SH)
378#define __RME_DEPTH 0x0000ffff
379#define RME_DEPTH_Q1 0x00038068
380#define RME_QCTRL_Q0 0x0003802c
381#define __RME_INT_LATENCY_TIMER_MK 0xff000000
382#define __RME_INT_LATENCY_TIMER_SH 24
383#define __RME_INT_LATENCY_TIMER(_v) ((_v) << __RME_INT_LATENCY_TIMER_SH)
384#define __RME_INT_DELAY_TIMER_MK 0x00ff0000
385#define __RME_INT_DELAY_TIMER_SH 16
386#define __RME_INT_DELAY_TIMER(_v) ((_v) << __RME_INT_DELAY_TIMER_SH)
387#define __RME_INT_DELAY_DISABLE 0x00008000
388#define __RME_DLY_DELAY_DISABLE 0x00004000
389#define __RME_ACK_PENDING 0x00002000
390#define __RME_FULL_INTERRUPT_DISABLE 0x00001000
391#define __RME_CTRL_UNUSED10_MK 0x00000c00
392#define __RME_CTRL_UNUSED10_SH 10
393#define __RME_CTRL_UNUSED10(_v) ((_v) << __RME_CTRL_UNUSED10_SH)
394#define __RME_PCIEID_MK 0x00000300
395#define __RME_PCIEID_SH 8
396#define __RME_PCIEID(_v) ((_v) << __RME_PCIEID_SH)
397#define __RME_CTRL_UNUSED00_MK 0x000000fe
398#define __RME_CTRL_UNUSED00_SH 1
399#define __RME_CTRL_UNUSED00(_v) ((_v) << __RME_CTRL_UNUSED00_SH)
400#define __RME_ESIZE 0x00000001
401#define RME_QCTRL_Q1 0x0003806c
402#define __RME_CTRL_UNUSED11_MK 0x00000c00
403#define __RME_CTRL_UNUSED11_SH 10
404#define __RME_CTRL_UNUSED11(_v) ((_v) << __RME_CTRL_UNUSED11_SH)
405#define __RME_CTRL_UNUSED01_MK 0x000000fe
406#define __RME_CTRL_UNUSED01_SH 1
407#define __RME_CTRL_UNUSED01(_v) ((_v) << __RME_CTRL_UNUSED01_SH)
408#define PSS_CTL_REG 0x00018800
409#define __PSS_I2C_CLK_DIV_MK 0x007f0000
410#define __PSS_I2C_CLK_DIV_SH 16
411#define __PSS_I2C_CLK_DIV(_v) ((_v) << __PSS_I2C_CLK_DIV_SH)
412#define __PSS_LMEM_INIT_DONE 0x00001000
413#define __PSS_LMEM_RESET 0x00000200
414#define __PSS_LMEM_INIT_EN 0x00000100
415#define __PSS_LPU1_RESET 0x00000002
416#define __PSS_LPU0_RESET 0x00000001
417#define PSS_ERR_STATUS_REG 0x00018810
418#define __PSS_LPU1_TCM_READ_ERR 0x00200000
419#define __PSS_LPU0_TCM_READ_ERR 0x00100000
420#define __PSS_LMEM5_CORR_ERR 0x00080000
421#define __PSS_LMEM4_CORR_ERR 0x00040000
422#define __PSS_LMEM3_CORR_ERR 0x00020000
423#define __PSS_LMEM2_CORR_ERR 0x00010000
424#define __PSS_LMEM1_CORR_ERR 0x00008000
425#define __PSS_LMEM0_CORR_ERR 0x00004000
426#define __PSS_LMEM5_UNCORR_ERR 0x00002000
427#define __PSS_LMEM4_UNCORR_ERR 0x00001000
428#define __PSS_LMEM3_UNCORR_ERR 0x00000800
429#define __PSS_LMEM2_UNCORR_ERR 0x00000400
430#define __PSS_LMEM1_UNCORR_ERR 0x00000200
431#define __PSS_LMEM0_UNCORR_ERR 0x00000100
432#define __PSS_BAL_PERR 0x00000080
433#define __PSS_DIP_IF_ERR 0x00000040
434#define __PSS_IOH_IF_ERR 0x00000020
435#define __PSS_TDS_IF_ERR 0x00000010
436#define __PSS_RDS_IF_ERR 0x00000008
437#define __PSS_SGM_IF_ERR 0x00000004
438#define __PSS_LPU1_RAM_ERR 0x00000002
439#define __PSS_LPU0_RAM_ERR 0x00000001
440#define ERR_SET_REG 0x00018818
441#define __PSS_ERR_STATUS_SET 0x003fffff
442#define PMM_1T_RESET_REG_P0 0x0002381c
443#define __PMM_1T_RESET_P 0x00000001
444#define PMM_1T_RESET_REG_P1 0x00023c1c
445#define HQM_QSET0_RXQ_DRBL_P0 0x00038000
446#define __RXQ0_ADD_VECTORS_P 0x80000000
447#define __RXQ0_STOP_P 0x40000000
448#define __RXQ0_PRD_PTR_P 0x0000ffff
449#define HQM_QSET1_RXQ_DRBL_P0 0x00038080
450#define __RXQ1_ADD_VECTORS_P 0x80000000
451#define __RXQ1_STOP_P 0x40000000
452#define __RXQ1_PRD_PTR_P 0x0000ffff
453#define HQM_QSET0_RXQ_DRBL_P1 0x0003c000
454#define HQM_QSET1_RXQ_DRBL_P1 0x0003c080
455#define HQM_QSET0_TXQ_DRBL_P0 0x00038020
456#define __TXQ0_ADD_VECTORS_P 0x80000000
457#define __TXQ0_STOP_P 0x40000000
458#define __TXQ0_PRD_PTR_P 0x0000ffff
459#define HQM_QSET1_TXQ_DRBL_P0 0x000380a0
460#define __TXQ1_ADD_VECTORS_P 0x80000000
461#define __TXQ1_STOP_P 0x40000000
462#define __TXQ1_PRD_PTR_P 0x0000ffff
463#define HQM_QSET0_TXQ_DRBL_P1 0x0003c020
464#define HQM_QSET1_TXQ_DRBL_P1 0x0003c0a0
465#define HQM_QSET0_IB_DRBL_1_P0 0x00038040
466#define __IB1_0_ACK_P 0x80000000
467#define __IB1_0_DISABLE_P 0x40000000
468#define __IB1_0_COALESCING_CFG_P_MK 0x00ff0000
469#define __IB1_0_COALESCING_CFG_P_SH 16
470#define __IB1_0_COALESCING_CFG_P(_v) ((_v) << __IB1_0_COALESCING_CFG_P_SH)
471#define __IB1_0_NUM_OF_ACKED_EVENTS_P 0x0000ffff
472#define HQM_QSET1_IB_DRBL_1_P0 0x000380c0
473#define __IB1_1_ACK_P 0x80000000
474#define __IB1_1_DISABLE_P 0x40000000
475#define __IB1_1_COALESCING_CFG_P_MK 0x00ff0000
476#define __IB1_1_COALESCING_CFG_P_SH 16
477#define __IB1_1_COALESCING_CFG_P(_v) ((_v) << __IB1_1_COALESCING_CFG_P_SH)
478#define __IB1_1_NUM_OF_ACKED_EVENTS_P 0x0000ffff
479#define HQM_QSET0_IB_DRBL_1_P1 0x0003c040
480#define HQM_QSET1_IB_DRBL_1_P1 0x0003c0c0
481#define HQM_QSET0_IB_DRBL_2_P0 0x00038060
482#define __IB2_0_ACK_P 0x80000000
483#define __IB2_0_DISABLE_P 0x40000000
484#define __IB2_0_COALESCING_CFG_P_MK 0x00ff0000
485#define __IB2_0_COALESCING_CFG_P_SH 16
486#define __IB2_0_COALESCING_CFG_P(_v) ((_v) << __IB2_0_COALESCING_CFG_P_SH)
487#define __IB2_0_NUM_OF_ACKED_EVENTS_P 0x0000ffff
488#define HQM_QSET1_IB_DRBL_2_P0 0x000380e0
489#define __IB2_1_ACK_P 0x80000000
490#define __IB2_1_DISABLE_P 0x40000000
491#define __IB2_1_COALESCING_CFG_P_MK 0x00ff0000
492#define __IB2_1_COALESCING_CFG_P_SH 16
493#define __IB2_1_COALESCING_CFG_P(_v) ((_v) << __IB2_1_COALESCING_CFG_P_SH)
494#define __IB2_1_NUM_OF_ACKED_EVENTS_P 0x0000ffff
495#define HQM_QSET0_IB_DRBL_2_P1 0x0003c060
496#define HQM_QSET1_IB_DRBL_2_P1 0x0003c0e0
497
498
499/*
500 * These definitions are either in error/missing in spec. Its auto-generated
501 * from hard coded values in regparse.pl.
502 */
503#define __EMPHPOST_AT_4G_MK_FIX 0x0000001c
504#define __EMPHPOST_AT_4G_SH_FIX 0x00000002
505#define __EMPHPRE_AT_4G_FIX 0x00000003
506#define __SFP_TXRATE_EN_FIX 0x00000100
507#define __SFP_RXRATE_EN_FIX 0x00000080
508
509
510/*
511 * These register definitions are auto-generated from hard coded values
512 * in regparse.pl.
513 */
514
515
516/*
517 * These register mapping definitions are auto-generated from mapping tables
518 * in regparse.pl.
519 */
520#define BFA_IOC0_HBEAT_REG HOST_SEM0_INFO_REG
521#define BFA_IOC0_STATE_REG HOST_SEM1_INFO_REG
522#define BFA_IOC1_HBEAT_REG HOST_SEM2_INFO_REG
523#define BFA_IOC1_STATE_REG HOST_SEM3_INFO_REG
524#define BFA_FW_USE_COUNT HOST_SEM4_INFO_REG
525#define BFA_IOC_FAIL_SYNC HOST_SEM5_INFO_REG
526
527#define CPE_DEPTH_Q(__n) \
528 (CPE_DEPTH_Q0 + (__n) * (CPE_DEPTH_Q1 - CPE_DEPTH_Q0))
529#define CPE_QCTRL_Q(__n) \
530 (CPE_QCTRL_Q0 + (__n) * (CPE_QCTRL_Q1 - CPE_QCTRL_Q0))
531#define CPE_PI_PTR_Q(__n) \
532 (CPE_PI_PTR_Q0 + (__n) * (CPE_PI_PTR_Q1 - CPE_PI_PTR_Q0))
533#define CPE_CI_PTR_Q(__n) \
534 (CPE_CI_PTR_Q0 + (__n) * (CPE_CI_PTR_Q1 - CPE_CI_PTR_Q0))
535#define RME_DEPTH_Q(__n) \
536 (RME_DEPTH_Q0 + (__n) * (RME_DEPTH_Q1 - RME_DEPTH_Q0))
537#define RME_QCTRL_Q(__n) \
538 (RME_QCTRL_Q0 + (__n) * (RME_QCTRL_Q1 - RME_QCTRL_Q0))
539#define RME_PI_PTR_Q(__n) \
540 (RME_PI_PTR_Q0 + (__n) * (RME_PI_PTR_Q1 - RME_PI_PTR_Q0))
541#define RME_CI_PTR_Q(__n) \
542 (RME_CI_PTR_Q0 + (__n) * (RME_CI_PTR_Q1 - RME_CI_PTR_Q0))
543#define HQM_QSET_RXQ_DRBL_P0(__n) \
544 (HQM_QSET0_RXQ_DRBL_P0 + (__n) * \
545 (HQM_QSET1_RXQ_DRBL_P0 - HQM_QSET0_RXQ_DRBL_P0))
546#define HQM_QSET_TXQ_DRBL_P0(__n) \
547 (HQM_QSET0_TXQ_DRBL_P0 + (__n) * \
548 (HQM_QSET1_TXQ_DRBL_P0 - HQM_QSET0_TXQ_DRBL_P0))
549#define HQM_QSET_IB_DRBL_1_P0(__n) \
550 (HQM_QSET0_IB_DRBL_1_P0 + (__n) * \
551 (HQM_QSET1_IB_DRBL_1_P0 - HQM_QSET0_IB_DRBL_1_P0))
552#define HQM_QSET_IB_DRBL_2_P0(__n) \
553 (HQM_QSET0_IB_DRBL_2_P0 + (__n) * \
554 (HQM_QSET1_IB_DRBL_2_P0 - HQM_QSET0_IB_DRBL_2_P0))
555#define HQM_QSET_RXQ_DRBL_P1(__n) \
556 (HQM_QSET0_RXQ_DRBL_P1 + (__n) * \
557 (HQM_QSET1_RXQ_DRBL_P1 - HQM_QSET0_RXQ_DRBL_P1))
558#define HQM_QSET_TXQ_DRBL_P1(__n) \
559 (HQM_QSET0_TXQ_DRBL_P1 + (__n) * \
560 (HQM_QSET1_TXQ_DRBL_P1 - HQM_QSET0_TXQ_DRBL_P1))
561#define HQM_QSET_IB_DRBL_1_P1(__n) \
562 (HQM_QSET0_IB_DRBL_1_P1 + (__n) * \
563 (HQM_QSET1_IB_DRBL_1_P1 - HQM_QSET0_IB_DRBL_1_P1))
564#define HQM_QSET_IB_DRBL_2_P1(__n) \
565 (HQM_QSET0_IB_DRBL_2_P1 + (__n) * \
566 (HQM_QSET1_IB_DRBL_2_P1 - HQM_QSET0_IB_DRBL_2_P1))
567
568#define CPE_Q_NUM(__fn, __q) (((__fn) << 2) + (__q))
569#define RME_Q_NUM(__fn, __q) (((__fn) << 2) + (__q))
570#define CPE_Q_MASK(__q) ((__q) & 0x3)
571#define RME_Q_MASK(__q) ((__q) & 0x3)
572
573
574/*
575 * PCI MSI-X vector defines
576 */
577enum {
578 BFA_MSIX_CPE_Q0 = 0,
579 BFA_MSIX_CPE_Q1 = 1,
580 BFA_MSIX_CPE_Q2 = 2,
581 BFA_MSIX_CPE_Q3 = 3,
582 BFA_MSIX_RME_Q0 = 4,
583 BFA_MSIX_RME_Q1 = 5,
584 BFA_MSIX_RME_Q2 = 6,
585 BFA_MSIX_RME_Q3 = 7,
586 BFA_MSIX_LPU_ERR = 8,
587 BFA_MSIX_CT_MAX = 9,
588};
589
590/*
591 * And corresponding host interrupt status bit field defines
592 */
593#define __HFN_INT_CPE_Q0 0x00000001U
594#define __HFN_INT_CPE_Q1 0x00000002U
595#define __HFN_INT_CPE_Q2 0x00000004U
596#define __HFN_INT_CPE_Q3 0x00000008U
597#define __HFN_INT_CPE_Q4 0x00000010U
598#define __HFN_INT_CPE_Q5 0x00000020U
599#define __HFN_INT_CPE_Q6 0x00000040U
600#define __HFN_INT_CPE_Q7 0x00000080U
601#define __HFN_INT_RME_Q0 0x00000100U
602#define __HFN_INT_RME_Q1 0x00000200U
603#define __HFN_INT_RME_Q2 0x00000400U
604#define __HFN_INT_RME_Q3 0x00000800U
605#define __HFN_INT_RME_Q4 0x00001000U
606#define __HFN_INT_RME_Q5 0x00002000U
607#define __HFN_INT_RME_Q6 0x00004000U
608#define __HFN_INT_RME_Q7 0x00008000U
609#define __HFN_INT_ERR_EMC 0x00010000U
610#define __HFN_INT_ERR_LPU0 0x00020000U
611#define __HFN_INT_ERR_LPU1 0x00040000U
612#define __HFN_INT_ERR_PSS 0x00080000U
613#define __HFN_INT_MBOX_LPU0 0x00100000U
614#define __HFN_INT_MBOX_LPU1 0x00200000U
615#define __HFN_INT_MBOX1_LPU0 0x00400000U
616#define __HFN_INT_MBOX1_LPU1 0x00800000U
617#define __HFN_INT_LL_HALT 0x01000000U
618#define __HFN_INT_CPE_MASK 0x000000ffU
619#define __HFN_INT_RME_MASK 0x0000ff00U
620
621
622/*
623 * catapult memory map.
624 */
625#define LL_PGN_HQM0 0x0096
626#define LL_PGN_HQM1 0x0097
627#define PSS_SMEM_PAGE_START 0x8000
628#define PSS_SMEM_PGNUM(_pg0, _ma) ((_pg0) + ((_ma) >> 15))
629#define PSS_SMEM_PGOFF(_ma) ((_ma) & 0x7fff)
630
631/*
632 * End of catapult memory map
633 */
634
635
636#endif /* __BFI_CTREG_H__ */
diff --git a/drivers/scsi/bfa/bfi_ms.h b/drivers/scsi/bfa/bfi_ms.h
new file mode 100644
index 000000000000..19e888a57555
--- /dev/null
+++ b/drivers/scsi/bfa/bfi_ms.h
@@ -0,0 +1,775 @@
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 __BFI_MS_H__
19#define __BFI_MS_H__
20
21#include "bfi.h"
22#include "bfa_fc.h"
23#include "bfa_defs_svc.h"
24
25#pragma pack(1)
26
27enum bfi_iocfc_h2i_msgs {
28 BFI_IOCFC_H2I_CFG_REQ = 1,
29 BFI_IOCFC_H2I_SET_INTR_REQ = 2,
30 BFI_IOCFC_H2I_UPDATEQ_REQ = 3,
31};
32
33enum bfi_iocfc_i2h_msgs {
34 BFI_IOCFC_I2H_CFG_REPLY = BFA_I2HM(1),
35 BFI_IOCFC_I2H_UPDATEQ_RSP = BFA_I2HM(3),
36};
37
38struct bfi_iocfc_cfg_s {
39 u8 num_cqs; /* Number of CQs to be used */
40 u8 sense_buf_len; /* SCSI sense length */
41 u16 rsvd_1;
42 u32 endian_sig; /* endian signature of host */
43
44 /*
45 * Request and response circular queue base addresses, size and
46 * shadow index pointers.
47 */
48 union bfi_addr_u req_cq_ba[BFI_IOC_MAX_CQS];
49 union bfi_addr_u req_shadow_ci[BFI_IOC_MAX_CQS];
50 __be16 req_cq_elems[BFI_IOC_MAX_CQS];
51 union bfi_addr_u rsp_cq_ba[BFI_IOC_MAX_CQS];
52 union bfi_addr_u rsp_shadow_pi[BFI_IOC_MAX_CQS];
53 __be16 rsp_cq_elems[BFI_IOC_MAX_CQS];
54
55 union bfi_addr_u stats_addr; /* DMA-able address for stats */
56 union bfi_addr_u cfgrsp_addr; /* config response dma address */
57 union bfi_addr_u ioim_snsbase; /* IO sense buffer base address */
58 struct bfa_iocfc_intr_attr_s intr_attr; /* IOC interrupt attributes */
59};
60
61/*
62 * Boot target wwn information for this port. This contains either the stored
63 * or discovered boot target port wwns for the port.
64 */
65struct bfi_iocfc_bootwwns {
66 wwn_t wwn[BFA_BOOT_BOOTLUN_MAX];
67 u8 nwwns;
68 u8 rsvd[7];
69};
70
71struct bfi_iocfc_cfgrsp_s {
72 struct bfa_iocfc_fwcfg_s fwcfg;
73 struct bfa_iocfc_intr_attr_s intr_attr;
74 struct bfi_iocfc_bootwwns bootwwns;
75 struct bfi_pbc_s pbc_cfg;
76};
77
78/*
79 * BFI_IOCFC_H2I_CFG_REQ message
80 */
81struct bfi_iocfc_cfg_req_s {
82 struct bfi_mhdr_s mh;
83 union bfi_addr_u ioc_cfg_dma_addr;
84};
85
86
87/*
88 * BFI_IOCFC_I2H_CFG_REPLY message
89 */
90struct bfi_iocfc_cfg_reply_s {
91 struct bfi_mhdr_s mh; /* Common msg header */
92 u8 cfg_success; /* cfg reply status */
93 u8 lpu_bm; /* LPUs assigned for this IOC */
94 u8 rsvd[2];
95};
96
97
98/*
99 * BFI_IOCFC_H2I_SET_INTR_REQ message
100 */
101struct bfi_iocfc_set_intr_req_s {
102 struct bfi_mhdr_s mh; /* common msg header */
103 u8 coalesce; /* enable intr coalescing */
104 u8 rsvd[3];
105 __be16 delay; /* delay timer 0..1125us */
106 __be16 latency; /* latency timer 0..225us */
107};
108
109
110/*
111 * BFI_IOCFC_H2I_UPDATEQ_REQ message
112 */
113struct bfi_iocfc_updateq_req_s {
114 struct bfi_mhdr_s mh; /* common msg header */
115 u32 reqq_ba; /* reqq base addr */
116 u32 rspq_ba; /* rspq base addr */
117 u32 reqq_sci; /* reqq shadow ci */
118 u32 rspq_spi; /* rspq shadow pi */
119};
120
121
122/*
123 * BFI_IOCFC_I2H_UPDATEQ_RSP message
124 */
125struct bfi_iocfc_updateq_rsp_s {
126 struct bfi_mhdr_s mh; /* common msg header */
127 u8 status; /* updateq status */
128 u8 rsvd[3];
129};
130
131
132/*
133 * H2I Messages
134 */
135union bfi_iocfc_h2i_msg_u {
136 struct bfi_mhdr_s mh;
137 struct bfi_iocfc_cfg_req_s cfg_req;
138 struct bfi_iocfc_updateq_req_s updateq_req;
139 u32 mboxmsg[BFI_IOC_MSGSZ];
140};
141
142
143/*
144 * I2H Messages
145 */
146union bfi_iocfc_i2h_msg_u {
147 struct bfi_mhdr_s mh;
148 struct bfi_iocfc_cfg_reply_s cfg_reply;
149 struct bfi_iocfc_updateq_rsp_s updateq_rsp;
150 u32 mboxmsg[BFI_IOC_MSGSZ];
151};
152
153
154enum bfi_fcport_h2i {
155 BFI_FCPORT_H2I_ENABLE_REQ = (1),
156 BFI_FCPORT_H2I_DISABLE_REQ = (2),
157 BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ = (3),
158 BFI_FCPORT_H2I_STATS_GET_REQ = (4),
159 BFI_FCPORT_H2I_STATS_CLEAR_REQ = (5),
160};
161
162
163enum bfi_fcport_i2h {
164 BFI_FCPORT_I2H_ENABLE_RSP = BFA_I2HM(1),
165 BFI_FCPORT_I2H_DISABLE_RSP = BFA_I2HM(2),
166 BFI_FCPORT_I2H_SET_SVC_PARAMS_RSP = BFA_I2HM(3),
167 BFI_FCPORT_I2H_STATS_GET_RSP = BFA_I2HM(4),
168 BFI_FCPORT_I2H_STATS_CLEAR_RSP = BFA_I2HM(5),
169 BFI_FCPORT_I2H_EVENT = BFA_I2HM(6),
170 BFI_FCPORT_I2H_TRUNK_SCN = BFA_I2HM(7),
171 BFI_FCPORT_I2H_ENABLE_AEN = BFA_I2HM(8),
172 BFI_FCPORT_I2H_DISABLE_AEN = BFA_I2HM(9),
173};
174
175
176/*
177 * Generic REQ type
178 */
179struct bfi_fcport_req_s {
180 struct bfi_mhdr_s mh; /* msg header */
181 u32 msgtag; /* msgtag for reply */
182};
183
184/*
185 * Generic RSP type
186 */
187struct bfi_fcport_rsp_s {
188 struct bfi_mhdr_s mh; /* common msg header */
189 u8 status; /* port enable status */
190 u8 rsvd[3];
191 struct bfa_port_cfg_s port_cfg;/* port configuration */
192 u32 msgtag; /* msgtag for reply */
193};
194
195/*
196 * BFI_FCPORT_H2I_ENABLE_REQ
197 */
198struct bfi_fcport_enable_req_s {
199 struct bfi_mhdr_s mh; /* msg header */
200 u32 rsvd1;
201 wwn_t nwwn; /* node wwn of physical port */
202 wwn_t pwwn; /* port wwn of physical port */
203 struct bfa_port_cfg_s port_cfg; /* port configuration */
204 union bfi_addr_u stats_dma_addr; /* DMA address for stats */
205 u32 msgtag; /* msgtag for reply */
206 u8 use_flash_cfg; /* get prot cfg from flash */
207 u8 rsvd2[3];
208};
209
210/*
211 * BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ
212 */
213struct bfi_fcport_set_svc_params_req_s {
214 struct bfi_mhdr_s mh; /* msg header */
215 __be16 tx_bbcredit; /* Tx credits */
216 u16 rsvd;
217};
218
219/*
220 * BFI_FCPORT_I2H_EVENT
221 */
222struct bfi_fcport_event_s {
223 struct bfi_mhdr_s mh; /* common msg header */
224 struct bfa_port_link_s link_state;
225};
226
227/*
228 * BFI_FCPORT_I2H_TRUNK_SCN
229 */
230struct bfi_fcport_trunk_link_s {
231 wwn_t trunk_wwn;
232 u8 fctl; /* bfa_trunk_link_fctl_t */
233 u8 state; /* bfa_trunk_link_state_t */
234 u8 speed; /* bfa_port_speed_t */
235 u8 rsvd;
236 __be32 deskew;
237};
238
239#define BFI_FCPORT_MAX_LINKS 2
240struct bfi_fcport_trunk_scn_s {
241 struct bfi_mhdr_s mh;
242 u8 trunk_state; /* bfa_trunk_state_t */
243 u8 trunk_speed; /* bfa_port_speed_t */
244 u8 rsvd_a[2];
245 struct bfi_fcport_trunk_link_s tlink[BFI_FCPORT_MAX_LINKS];
246};
247
248/*
249 * fcport H2I message
250 */
251union bfi_fcport_h2i_msg_u {
252 struct bfi_mhdr_s *mhdr;
253 struct bfi_fcport_enable_req_s *penable;
254 struct bfi_fcport_req_s *pdisable;
255 struct bfi_fcport_set_svc_params_req_s *psetsvcparams;
256 struct bfi_fcport_req_s *pstatsget;
257 struct bfi_fcport_req_s *pstatsclear;
258};
259
260/*
261 * fcport I2H message
262 */
263union bfi_fcport_i2h_msg_u {
264 struct bfi_msg_s *msg;
265 struct bfi_fcport_rsp_s *penable_rsp;
266 struct bfi_fcport_rsp_s *pdisable_rsp;
267 struct bfi_fcport_rsp_s *psetsvcparams_rsp;
268 struct bfi_fcport_rsp_s *pstatsget_rsp;
269 struct bfi_fcport_rsp_s *pstatsclear_rsp;
270 struct bfi_fcport_event_s *event;
271 struct bfi_fcport_trunk_scn_s *trunk_scn;
272};
273
274enum bfi_fcxp_h2i {
275 BFI_FCXP_H2I_SEND_REQ = 1,
276};
277
278enum bfi_fcxp_i2h {
279 BFI_FCXP_I2H_SEND_RSP = BFA_I2HM(1),
280};
281
282#define BFA_FCXP_MAX_SGES 2
283
284/*
285 * FCXP send request structure
286 */
287struct bfi_fcxp_send_req_s {
288 struct bfi_mhdr_s mh; /* Common msg header */
289 __be16 fcxp_tag; /* driver request tag */
290 __be16 max_frmsz; /* max send frame size */
291 __be16 vf_id; /* vsan tag if applicable */
292 u16 rport_fw_hndl; /* FW Handle for the remote port */
293 u8 class; /* FC class used for req/rsp */
294 u8 rsp_timeout; /* timeout in secs, 0-no response */
295 u8 cts; /* continue sequence */
296 u8 lp_tag; /* lport tag */
297 struct fchs_s fchs; /* request FC header structure */
298 __be32 req_len; /* request payload length */
299 __be32 rsp_maxlen; /* max response length expected */
300 struct bfi_sge_s req_sge[BFA_FCXP_MAX_SGES]; /* request buf */
301 struct bfi_sge_s rsp_sge[BFA_FCXP_MAX_SGES]; /* response buf */
302};
303
304/*
305 * FCXP send response structure
306 */
307struct bfi_fcxp_send_rsp_s {
308 struct bfi_mhdr_s mh; /* Common msg header */
309 __be16 fcxp_tag; /* send request tag */
310 u8 req_status; /* request status */
311 u8 rsvd;
312 __be32 rsp_len; /* actual response length */
313 __be32 residue_len; /* residual response length */
314 struct fchs_s fchs; /* response FC header structure */
315};
316
317enum bfi_uf_h2i {
318 BFI_UF_H2I_BUF_POST = 1,
319};
320
321enum bfi_uf_i2h {
322 BFI_UF_I2H_FRM_RCVD = BFA_I2HM(1),
323};
324
325#define BFA_UF_MAX_SGES 2
326
327struct bfi_uf_buf_post_s {
328 struct bfi_mhdr_s mh; /* Common msg header */
329 u16 buf_tag; /* buffer tag */
330 __be16 buf_len; /* total buffer length */
331 struct bfi_sge_s sge[BFA_UF_MAX_SGES]; /* buffer DMA SGEs */
332};
333
334struct bfi_uf_frm_rcvd_s {
335 struct bfi_mhdr_s mh; /* Common msg header */
336 u16 buf_tag; /* buffer tag */
337 u16 rsvd;
338 u16 frm_len; /* received frame length */
339 u16 xfr_len; /* tranferred length */
340};
341
342enum bfi_lps_h2i_msgs {
343 BFI_LPS_H2I_LOGIN_REQ = 1,
344 BFI_LPS_H2I_LOGOUT_REQ = 2,
345 BFI_LPS_H2I_N2N_PID_REQ = 3,
346};
347
348enum bfi_lps_i2h_msgs {
349 BFI_LPS_H2I_LOGIN_RSP = BFA_I2HM(1),
350 BFI_LPS_H2I_LOGOUT_RSP = BFA_I2HM(2),
351 BFI_LPS_H2I_CVL_EVENT = BFA_I2HM(3),
352};
353
354struct bfi_lps_login_req_s {
355 struct bfi_mhdr_s mh; /* common msg header */
356 u8 lp_tag;
357 u8 alpa;
358 __be16 pdu_size;
359 wwn_t pwwn;
360 wwn_t nwwn;
361 u8 fdisc;
362 u8 auth_en;
363 u8 rsvd[2];
364};
365
366struct bfi_lps_login_rsp_s {
367 struct bfi_mhdr_s mh; /* common msg header */
368 u8 lp_tag;
369 u8 status;
370 u8 lsrjt_rsn;
371 u8 lsrjt_expl;
372 wwn_t port_name;
373 wwn_t node_name;
374 __be16 bb_credit;
375 u8 f_port;
376 u8 npiv_en;
377 u32 lp_pid:24;
378 u32 auth_req:8;
379 mac_t lp_mac;
380 mac_t fcf_mac;
381 u8 ext_status;
382 u8 brcd_switch; /* attached peer is brcd switch */
383};
384
385struct bfi_lps_logout_req_s {
386 struct bfi_mhdr_s mh; /* common msg header */
387 u8 lp_tag;
388 u8 rsvd[3];
389 wwn_t port_name;
390};
391
392struct bfi_lps_logout_rsp_s {
393 struct bfi_mhdr_s mh; /* common msg header */
394 u8 lp_tag;
395 u8 status;
396 u8 rsvd[2];
397};
398
399struct bfi_lps_cvl_event_s {
400 struct bfi_mhdr_s mh; /* common msg header */
401 u8 lp_tag;
402 u8 rsvd[3];
403};
404
405struct bfi_lps_n2n_pid_req_s {
406 struct bfi_mhdr_s mh; /* common msg header */
407 u8 lp_tag;
408 u32 lp_pid:24;
409};
410
411union bfi_lps_h2i_msg_u {
412 struct bfi_mhdr_s *msg;
413 struct bfi_lps_login_req_s *login_req;
414 struct bfi_lps_logout_req_s *logout_req;
415 struct bfi_lps_n2n_pid_req_s *n2n_pid_req;
416};
417
418union bfi_lps_i2h_msg_u {
419 struct bfi_msg_s *msg;
420 struct bfi_lps_login_rsp_s *login_rsp;
421 struct bfi_lps_logout_rsp_s *logout_rsp;
422 struct bfi_lps_cvl_event_s *cvl_event;
423};
424
425enum bfi_rport_h2i_msgs {
426 BFI_RPORT_H2I_CREATE_REQ = 1,
427 BFI_RPORT_H2I_DELETE_REQ = 2,
428 BFI_RPORT_H2I_SET_SPEED_REQ = 3,
429};
430
431enum bfi_rport_i2h_msgs {
432 BFI_RPORT_I2H_CREATE_RSP = BFA_I2HM(1),
433 BFI_RPORT_I2H_DELETE_RSP = BFA_I2HM(2),
434 BFI_RPORT_I2H_QOS_SCN = BFA_I2HM(3),
435};
436
437struct bfi_rport_create_req_s {
438 struct bfi_mhdr_s mh; /* common msg header */
439 u16 bfa_handle; /* host rport handle */
440 __be16 max_frmsz; /* max rcv pdu size */
441 u32 pid:24, /* remote port ID */
442 lp_tag:8; /* local port tag */
443 u32 local_pid:24, /* local port ID */
444 cisc:8;
445 u8 fc_class; /* supported FC classes */
446 u8 vf_en; /* virtual fabric enable */
447 u16 vf_id; /* virtual fabric ID */
448};
449
450struct bfi_rport_create_rsp_s {
451 struct bfi_mhdr_s mh; /* common msg header */
452 u8 status; /* rport creation status */
453 u8 rsvd[3];
454 u16 bfa_handle; /* host rport handle */
455 u16 fw_handle; /* firmware rport handle */
456 struct bfa_rport_qos_attr_s qos_attr; /* QoS Attributes */
457};
458
459struct bfa_rport_speed_req_s {
460 struct bfi_mhdr_s mh; /* common msg header */
461 u16 fw_handle; /* firmware rport handle */
462 u8 speed; /* rport's speed via RPSC */
463 u8 rsvd;
464};
465
466struct bfi_rport_delete_req_s {
467 struct bfi_mhdr_s mh; /* common msg header */
468 u16 fw_handle; /* firmware rport handle */
469 u16 rsvd;
470};
471
472struct bfi_rport_delete_rsp_s {
473 struct bfi_mhdr_s mh; /* common msg header */
474 u16 bfa_handle; /* host rport handle */
475 u8 status; /* rport deletion status */
476 u8 rsvd;
477};
478
479struct bfi_rport_qos_scn_s {
480 struct bfi_mhdr_s mh; /* common msg header */
481 u16 bfa_handle; /* host rport handle */
482 u16 rsvd;
483 struct bfa_rport_qos_attr_s old_qos_attr; /* Old QoS Attributes */
484 struct bfa_rport_qos_attr_s new_qos_attr; /* New QoS Attributes */
485};
486
487union bfi_rport_h2i_msg_u {
488 struct bfi_msg_s *msg;
489 struct bfi_rport_create_req_s *create_req;
490 struct bfi_rport_delete_req_s *delete_req;
491 struct bfi_rport_speed_req_s *speed_req;
492};
493
494union bfi_rport_i2h_msg_u {
495 struct bfi_msg_s *msg;
496 struct bfi_rport_create_rsp_s *create_rsp;
497 struct bfi_rport_delete_rsp_s *delete_rsp;
498 struct bfi_rport_qos_scn_s *qos_scn_evt;
499};
500
501/*
502 * Initiator mode I-T nexus interface defines.
503 */
504
505enum bfi_itnim_h2i {
506 BFI_ITNIM_H2I_CREATE_REQ = 1, /* i-t nexus creation */
507 BFI_ITNIM_H2I_DELETE_REQ = 2, /* i-t nexus deletion */
508};
509
510enum bfi_itnim_i2h {
511 BFI_ITNIM_I2H_CREATE_RSP = BFA_I2HM(1),
512 BFI_ITNIM_I2H_DELETE_RSP = BFA_I2HM(2),
513 BFI_ITNIM_I2H_SLER_EVENT = BFA_I2HM(3),
514};
515
516struct bfi_itnim_create_req_s {
517 struct bfi_mhdr_s mh; /* common msg header */
518 u16 fw_handle; /* f/w handle for itnim */
519 u8 class; /* FC class for IO */
520 u8 seq_rec; /* sequence recovery support */
521 u8 msg_no; /* seq id of the msg */
522};
523
524struct bfi_itnim_create_rsp_s {
525 struct bfi_mhdr_s mh; /* common msg header */
526 u16 bfa_handle; /* bfa handle for itnim */
527 u8 status; /* fcp request status */
528 u8 seq_id; /* seq id of the msg */
529};
530
531struct bfi_itnim_delete_req_s {
532 struct bfi_mhdr_s mh; /* common msg header */
533 u16 fw_handle; /* f/w itnim handle */
534 u8 seq_id; /* seq id of the msg */
535 u8 rsvd;
536};
537
538struct bfi_itnim_delete_rsp_s {
539 struct bfi_mhdr_s mh; /* common msg header */
540 u16 bfa_handle; /* bfa handle for itnim */
541 u8 status; /* fcp request status */
542 u8 seq_id; /* seq id of the msg */
543};
544
545struct bfi_itnim_sler_event_s {
546 struct bfi_mhdr_s mh; /* common msg header */
547 u16 bfa_handle; /* bfa handle for itnim */
548 u16 rsvd;
549};
550
551union bfi_itnim_h2i_msg_u {
552 struct bfi_itnim_create_req_s *create_req;
553 struct bfi_itnim_delete_req_s *delete_req;
554 struct bfi_msg_s *msg;
555};
556
557union bfi_itnim_i2h_msg_u {
558 struct bfi_itnim_create_rsp_s *create_rsp;
559 struct bfi_itnim_delete_rsp_s *delete_rsp;
560 struct bfi_itnim_sler_event_s *sler_event;
561 struct bfi_msg_s *msg;
562};
563
564/*
565 * Initiator mode IO interface defines.
566 */
567
568enum bfi_ioim_h2i {
569 BFI_IOIM_H2I_IOABORT_REQ = 1, /* IO abort request */
570 BFI_IOIM_H2I_IOCLEANUP_REQ = 2, /* IO cleanup request */
571};
572
573enum bfi_ioim_i2h {
574 BFI_IOIM_I2H_IO_RSP = BFA_I2HM(1), /* non-fp IO response */
575 BFI_IOIM_I2H_IOABORT_RSP = BFA_I2HM(2), /* ABORT rsp */
576};
577
578/*
579 * IO command DIF info
580 */
581struct bfi_ioim_dif_s {
582 u32 dif_info[4];
583};
584
585/*
586 * FCP IO messages overview
587 *
588 * @note
589 * - Max CDB length supported is 64 bytes.
590 * - SCSI Linked commands and SCSI bi-directional Commands not
591 * supported.
592 *
593 */
594struct bfi_ioim_req_s {
595 struct bfi_mhdr_s mh; /* Common msg header */
596 __be16 io_tag; /* I/O tag */
597 u16 rport_hdl; /* itnim/rport firmware handle */
598 struct fcp_cmnd_s cmnd; /* IO request info */
599
600 /*
601 * SG elements array within the IO request must be double word
602 * aligned. This aligment is required to optimize SGM setup for the IO.
603 */
604 struct bfi_sge_s sges[BFI_SGE_INLINE_MAX];
605 u8 io_timeout;
606 u8 dif_en;
607 u8 rsvd_a[2];
608 struct bfi_ioim_dif_s dif;
609};
610
611/*
612 * This table shows various IO status codes from firmware and their
613 * meaning. Host driver can use these status codes to further process
614 * IO completions.
615 *
616 * BFI_IOIM_STS_OK : IO completed with error free SCSI &
617 * transport status.
618 * io-tag can be reused.
619 *
620 * BFA_IOIM_STS_SCSI_ERR : IO completed with scsi error.
621 * - io-tag can be reused.
622 *
623 * BFI_IOIM_STS_HOST_ABORTED : IO was aborted successfully due to
624 * host request.
625 * - io-tag cannot be reused yet.
626 *
627 * BFI_IOIM_STS_ABORTED : IO was aborted successfully
628 * internally by f/w.
629 * - io-tag cannot be reused yet.
630 *
631 * BFI_IOIM_STS_TIMEDOUT : IO timedout and ABTS/RRQ is happening
632 * in the firmware and
633 * - io-tag cannot be reused yet.
634 *
635 * BFI_IOIM_STS_SQER_NEEDED : Firmware could not recover the IO
636 * with sequence level error
637 * logic and hence host needs to retry
638 * this IO with a different IO tag
639 * - io-tag cannot be used yet.
640 *
641 * BFI_IOIM_STS_NEXUS_ABORT : Second Level Error Recovery from host
642 * is required because 2 consecutive ABTS
643 * timedout and host needs logout and
644 * re-login with the target
645 * - io-tag cannot be used yet.
646 *
647 * BFI_IOIM_STS_UNDERRUN : IO completed with SCSI status good,
648 * but the data tranferred is less than
649 * the fcp data length in the command.
650 * ex. SCSI INQUIRY where transferred
651 * data length and residue count in FCP
652 * response accounts for total fcp-dl
653 * - io-tag can be reused.
654 *
655 * BFI_IOIM_STS_OVERRUN : IO completed with SCSI status good,
656 * but the data transerred is more than
657 * fcp data length in the command. ex.
658 * TAPE IOs where blocks can of unequal
659 * lengths.
660 * - io-tag can be reused.
661 *
662 * BFI_IOIM_STS_RES_FREE : Firmware has completed using io-tag
663 * during abort process
664 * - io-tag can be reused.
665 *
666 * BFI_IOIM_STS_PROTO_ERR : Firmware detected a protocol error.
667 * ex target sent more data than
668 * requested, or there was data frame
669 * loss and other reasons
670 * - io-tag cannot be used yet.
671 *
672 * BFI_IOIM_STS_DIF_ERR : Firwmare detected DIF error. ex: DIF
673 * CRC err or Ref Tag err or App tag err.
674 * - io-tag can be reused.
675 *
676 * BFA_IOIM_STS_TSK_MGT_ABORT : IO was aborted because of Task
677 * Management command from the host
678 * - io-tag can be reused.
679 *
680 * BFI_IOIM_STS_UTAG : Firmware does not know about this
681 * io_tag.
682 * - io-tag can be reused.
683 */
684enum bfi_ioim_status {
685 BFI_IOIM_STS_OK = 0,
686 BFI_IOIM_STS_HOST_ABORTED = 1,
687 BFI_IOIM_STS_ABORTED = 2,
688 BFI_IOIM_STS_TIMEDOUT = 3,
689 BFI_IOIM_STS_RES_FREE = 4,
690 BFI_IOIM_STS_SQER_NEEDED = 5,
691 BFI_IOIM_STS_PROTO_ERR = 6,
692 BFI_IOIM_STS_UTAG = 7,
693 BFI_IOIM_STS_PATHTOV = 8,
694};
695
696#define BFI_IOIM_SNSLEN (256)
697/*
698 * I/O response message
699 */
700struct bfi_ioim_rsp_s {
701 struct bfi_mhdr_s mh; /* common msg header */
702 __be16 io_tag; /* completed IO tag */
703 u16 bfa_rport_hndl; /* releated rport handle */
704 u8 io_status; /* IO completion status */
705 u8 reuse_io_tag; /* IO tag can be reused */
706 u16 abort_tag; /* host abort request tag */
707 u8 scsi_status; /* scsi status from target */
708 u8 sns_len; /* scsi sense length */
709 u8 resid_flags; /* IO residue flags */
710 u8 rsvd_a;
711 __be32 residue; /* IO residual length in bytes */
712 u32 rsvd_b[3];
713};
714
715struct bfi_ioim_abort_req_s {
716 struct bfi_mhdr_s mh; /* Common msg header */
717 __be16 io_tag; /* I/O tag */
718 u16 abort_tag; /* unique request tag */
719};
720
721/*
722 * Initiator mode task management command interface defines.
723 */
724
725enum bfi_tskim_h2i {
726 BFI_TSKIM_H2I_TM_REQ = 1, /* task-mgmt command */
727 BFI_TSKIM_H2I_ABORT_REQ = 2, /* task-mgmt command */
728};
729
730enum bfi_tskim_i2h {
731 BFI_TSKIM_I2H_TM_RSP = BFA_I2HM(1),
732};
733
734struct bfi_tskim_req_s {
735 struct bfi_mhdr_s mh; /* Common msg header */
736 __be16 tsk_tag; /* task management tag */
737 u16 itn_fhdl; /* itn firmware handle */
738 struct scsi_lun lun; /* LU number */
739 u8 tm_flags; /* see enum fcp_tm_cmnd */
740 u8 t_secs; /* Timeout value in seconds */
741 u8 rsvd[2];
742};
743
744struct bfi_tskim_abortreq_s {
745 struct bfi_mhdr_s mh; /* Common msg header */
746 __be16 tsk_tag; /* task management tag */
747 u16 rsvd;
748};
749
750enum bfi_tskim_status {
751 /*
752 * Following are FCP-4 spec defined status codes,
753 * **DO NOT CHANGE THEM **
754 */
755 BFI_TSKIM_STS_OK = 0,
756 BFI_TSKIM_STS_NOT_SUPP = 4,
757 BFI_TSKIM_STS_FAILED = 5,
758
759 /*
760 * Defined by BFA
761 */
762 BFI_TSKIM_STS_TIMEOUT = 10, /* TM request timedout */
763 BFI_TSKIM_STS_ABORTED = 11, /* Aborted on host request */
764};
765
766struct bfi_tskim_rsp_s {
767 struct bfi_mhdr_s mh; /* Common msg header */
768 __be16 tsk_tag; /* task mgmt cmnd tag */
769 u8 tsk_status; /* @ref bfi_tskim_status */
770 u8 rsvd;
771};
772
773#pragma pack()
774
775#endif /* __BFI_MS_H__ */
diff --git a/drivers/scsi/bfa/fab.c b/drivers/scsi/bfa/fab.c
deleted file mode 100644
index 7e3a4d5d7bb4..000000000000
--- a/drivers/scsi/bfa/fab.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
19#include <bfa_svc.h>
20#include "fcs_lport.h"
21#include "fcs_rport.h"
22#include "lport_priv.h"
23
24/**
25 * fab.c port fab implementation.
26 */
27
28/**
29 * bfa_fcs_port_fab_public port fab public functions
30 */
31
32/**
33 * Called by port to initialize fabric services of the base port.
34 */
35void
36bfa_fcs_port_fab_init(struct bfa_fcs_port_s *port)
37{
38 bfa_fcs_port_ns_init(port);
39 bfa_fcs_port_scn_init(port);
40 bfa_fcs_port_ms_init(port);
41}
42
43/**
44 * Called by port to notify transition to online state.
45 */
46void
47bfa_fcs_port_fab_online(struct bfa_fcs_port_s *port)
48{
49 bfa_fcs_port_ns_online(port);
50 bfa_fcs_port_scn_online(port);
51}
52
53/**
54 * Called by port to notify transition to offline state.
55 */
56void
57bfa_fcs_port_fab_offline(struct bfa_fcs_port_s *port)
58{
59 bfa_fcs_port_ns_offline(port);
60 bfa_fcs_port_scn_offline(port);
61 bfa_fcs_port_ms_offline(port);
62}
diff --git a/drivers/scsi/bfa/fabric.c b/drivers/scsi/bfa/fabric.c
deleted file mode 100644
index ddd4ba9317e6..000000000000
--- a/drivers/scsi/bfa/fabric.c
+++ /dev/null
@@ -1,1323 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * fabric.c Fabric module implementation.
20 */
21
22#include "fcs_fabric.h"
23#include "fcs_lport.h"
24#include "fcs_vport.h"
25#include "fcs_trcmod.h"
26#include "fcs_fcxp.h"
27#include "fcs_auth.h"
28#include "fcs.h"
29#include "fcbuild.h"
30#include <log/bfa_log_fcs.h>
31#include <aen/bfa_aen_port.h>
32#include <bfa_svc.h>
33
34BFA_TRC_FILE(FCS, FABRIC);
35
36#define BFA_FCS_FABRIC_RETRY_DELAY (2000) /* Milliseconds */
37#define BFA_FCS_FABRIC_CLEANUP_DELAY (10000) /* Milliseconds */
38
39#define bfa_fcs_fabric_set_opertype(__fabric) do { \
40 if (bfa_fcport_get_topology((__fabric)->fcs->bfa) \
41 == BFA_PPORT_TOPOLOGY_P2P) \
42 (__fabric)->oper_type = BFA_PPORT_TYPE_NPORT; \
43 else \
44 (__fabric)->oper_type = BFA_PPORT_TYPE_NLPORT; \
45} while (0)
46
47/*
48 * forward declarations
49 */
50static void bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric);
51static void bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric);
52static void bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric);
53static void bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric);
54static void bfa_fcs_fabric_delay(void *cbarg);
55static void bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric);
56static void bfa_fcs_fabric_delete_comp(void *cbarg);
57static void bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric,
58 struct fchs_s *fchs, u16 len);
59static void bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric,
60 struct fchs_s *fchs, u16 len);
61static void bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric);
62static void bfa_fcs_fabric_flogiacc_comp(void *fcsarg,
63 struct bfa_fcxp_s *fcxp,
64 void *cbarg, bfa_status_t status,
65 u32 rsp_len,
66 u32 resid_len,
67 struct fchs_s *rspfchs);
68/**
69 * fcs_fabric_sm fabric state machine functions
70 */
71
72/**
73 * Fabric state machine events
74 */
75enum bfa_fcs_fabric_event {
76 BFA_FCS_FABRIC_SM_CREATE = 1, /* fabric create from driver */
77 BFA_FCS_FABRIC_SM_DELETE = 2, /* fabric delete from driver */
78 BFA_FCS_FABRIC_SM_LINK_DOWN = 3, /* link down from port */
79 BFA_FCS_FABRIC_SM_LINK_UP = 4, /* link up from port */
80 BFA_FCS_FABRIC_SM_CONT_OP = 5, /* continue op from flogi/auth */
81 BFA_FCS_FABRIC_SM_RETRY_OP = 6, /* continue op from flogi/auth */
82 BFA_FCS_FABRIC_SM_NO_FABRIC = 7, /* no fabric from flogi/auth
83 */
84 BFA_FCS_FABRIC_SM_PERF_EVFP = 8, /* perform EVFP from
85 *flogi/auth */
86 BFA_FCS_FABRIC_SM_ISOLATE = 9, /* isolate from EVFP processing */
87 BFA_FCS_FABRIC_SM_NO_TAGGING = 10,/* no VFT tagging from EVFP */
88 BFA_FCS_FABRIC_SM_DELAYED = 11, /* timeout delay event */
89 BFA_FCS_FABRIC_SM_AUTH_FAILED = 12, /* authentication failed */
90 BFA_FCS_FABRIC_SM_AUTH_SUCCESS = 13, /* authentication successful
91 */
92 BFA_FCS_FABRIC_SM_DELCOMP = 14, /* all vports deleted event */
93 BFA_FCS_FABRIC_SM_LOOPBACK = 15, /* Received our own FLOGI */
94 BFA_FCS_FABRIC_SM_START = 16, /* fabric delete from driver */
95};
96
97static void bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric,
98 enum bfa_fcs_fabric_event event);
99static void bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric,
100 enum bfa_fcs_fabric_event event);
101static void bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric,
102 enum bfa_fcs_fabric_event event);
103static void bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
104 enum bfa_fcs_fabric_event event);
105static void bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric,
106 enum bfa_fcs_fabric_event event);
107static void bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric,
108 enum bfa_fcs_fabric_event event);
109static void bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
110 enum bfa_fcs_fabric_event event);
111static void bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
112 enum bfa_fcs_fabric_event event);
113static void bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
114 enum bfa_fcs_fabric_event event);
115static void bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
116 enum bfa_fcs_fabric_event event);
117static void bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric,
118 enum bfa_fcs_fabric_event event);
119static void bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric,
120 enum bfa_fcs_fabric_event event);
121static void bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric,
122 enum bfa_fcs_fabric_event event);
123static void bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric,
124 enum bfa_fcs_fabric_event event);
125/**
126 * Beginning state before fabric creation.
127 */
128static void
129bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric,
130 enum bfa_fcs_fabric_event event)
131{
132 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
133 bfa_trc(fabric->fcs, event);
134
135 switch (event) {
136 case BFA_FCS_FABRIC_SM_CREATE:
137 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created);
138 bfa_fcs_fabric_init(fabric);
139 bfa_fcs_lport_init(&fabric->bport, &fabric->bport.port_cfg);
140 break;
141
142 case BFA_FCS_FABRIC_SM_LINK_UP:
143 case BFA_FCS_FABRIC_SM_LINK_DOWN:
144 break;
145
146 default:
147 bfa_sm_fault(fabric->fcs, event);
148 }
149}
150
151/**
152 * Beginning state before fabric creation.
153 */
154static void
155bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric,
156 enum bfa_fcs_fabric_event event)
157{
158 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
159 bfa_trc(fabric->fcs, event);
160
161 switch (event) {
162 case BFA_FCS_FABRIC_SM_START:
163 if (bfa_fcport_is_linkup(fabric->fcs->bfa)) {
164 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
165 bfa_fcs_fabric_login(fabric);
166 } else
167 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
168 break;
169
170 case BFA_FCS_FABRIC_SM_LINK_UP:
171 case BFA_FCS_FABRIC_SM_LINK_DOWN:
172 break;
173
174 case BFA_FCS_FABRIC_SM_DELETE:
175 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
176 bfa_fcs_modexit_comp(fabric->fcs);
177 break;
178
179 default:
180 bfa_sm_fault(fabric->fcs, event);
181 }
182}
183
184/**
185 * Link is down, awaiting LINK UP event from port. This is also the
186 * first state at fabric creation.
187 */
188static void
189bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric,
190 enum bfa_fcs_fabric_event event)
191{
192 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
193 bfa_trc(fabric->fcs, event);
194
195 switch (event) {
196 case BFA_FCS_FABRIC_SM_LINK_UP:
197 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
198 bfa_fcs_fabric_login(fabric);
199 break;
200
201 case BFA_FCS_FABRIC_SM_RETRY_OP:
202 break;
203
204 case BFA_FCS_FABRIC_SM_DELETE:
205 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
206 bfa_fcs_fabric_delete(fabric);
207 break;
208
209 default:
210 bfa_sm_fault(fabric->fcs, event);
211 }
212}
213
214/**
215 * FLOGI is in progress, awaiting FLOGI reply.
216 */
217static void
218bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
219 enum bfa_fcs_fabric_event event)
220{
221 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
222 bfa_trc(fabric->fcs, event);
223
224 switch (event) {
225 case BFA_FCS_FABRIC_SM_CONT_OP:
226
227 bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit);
228 fabric->fab_type = BFA_FCS_FABRIC_SWITCHED;
229
230 if (fabric->auth_reqd && fabric->is_auth) {
231 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth);
232 bfa_trc(fabric->fcs, event);
233 } else {
234 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
235 bfa_fcs_fabric_notify_online(fabric);
236 }
237 break;
238
239 case BFA_FCS_FABRIC_SM_RETRY_OP:
240 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi_retry);
241 bfa_timer_start(fabric->fcs->bfa, &fabric->delay_timer,
242 bfa_fcs_fabric_delay, fabric,
243 BFA_FCS_FABRIC_RETRY_DELAY);
244 break;
245
246 case BFA_FCS_FABRIC_SM_LOOPBACK:
247 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_loopback);
248 bfa_lps_discard(fabric->lps);
249 bfa_fcs_fabric_set_opertype(fabric);
250 break;
251
252 case BFA_FCS_FABRIC_SM_NO_FABRIC:
253 fabric->fab_type = BFA_FCS_FABRIC_N2N;
254 bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit);
255 bfa_fcs_fabric_notify_online(fabric);
256 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_nofabric);
257 break;
258
259 case BFA_FCS_FABRIC_SM_LINK_DOWN:
260 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
261 bfa_lps_discard(fabric->lps);
262 break;
263
264 case BFA_FCS_FABRIC_SM_DELETE:
265 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
266 bfa_lps_discard(fabric->lps);
267 bfa_fcs_fabric_delete(fabric);
268 break;
269
270 default:
271 bfa_sm_fault(fabric->fcs, event);
272 }
273}
274
275
276static void
277bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric,
278 enum bfa_fcs_fabric_event event)
279{
280 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
281 bfa_trc(fabric->fcs, event);
282
283 switch (event) {
284 case BFA_FCS_FABRIC_SM_DELAYED:
285 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
286 bfa_fcs_fabric_login(fabric);
287 break;
288
289 case BFA_FCS_FABRIC_SM_LINK_DOWN:
290 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
291 bfa_timer_stop(&fabric->delay_timer);
292 break;
293
294 case BFA_FCS_FABRIC_SM_DELETE:
295 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
296 bfa_timer_stop(&fabric->delay_timer);
297 bfa_fcs_fabric_delete(fabric);
298 break;
299
300 default:
301 bfa_sm_fault(fabric->fcs, event);
302 }
303}
304
305/**
306 * Authentication is in progress, awaiting authentication results.
307 */
308static void
309bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric,
310 enum bfa_fcs_fabric_event event)
311{
312 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
313 bfa_trc(fabric->fcs, event);
314
315 switch (event) {
316 case BFA_FCS_FABRIC_SM_AUTH_FAILED:
317 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
318 bfa_lps_discard(fabric->lps);
319 break;
320
321 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
322 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
323 bfa_fcs_fabric_notify_online(fabric);
324 break;
325
326 case BFA_FCS_FABRIC_SM_PERF_EVFP:
327 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp);
328 break;
329
330 case BFA_FCS_FABRIC_SM_LINK_DOWN:
331 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
332 bfa_lps_discard(fabric->lps);
333 break;
334
335 case BFA_FCS_FABRIC_SM_DELETE:
336 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
337 bfa_fcs_fabric_delete(fabric);
338 break;
339
340 default:
341 bfa_sm_fault(fabric->fcs, event);
342 }
343}
344
345/**
346 * Authentication failed
347 */
348static void
349bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
350 enum bfa_fcs_fabric_event event)
351{
352 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
353 bfa_trc(fabric->fcs, event);
354
355 switch (event) {
356 case BFA_FCS_FABRIC_SM_LINK_DOWN:
357 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
358 bfa_fcs_fabric_notify_offline(fabric);
359 break;
360
361 case BFA_FCS_FABRIC_SM_DELETE:
362 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
363 bfa_fcs_fabric_delete(fabric);
364 break;
365
366 default:
367 bfa_sm_fault(fabric->fcs, event);
368 }
369}
370
371/**
372 * Port is in loopback mode.
373 */
374static void
375bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
376 enum bfa_fcs_fabric_event event)
377{
378 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
379 bfa_trc(fabric->fcs, event);
380
381 switch (event) {
382 case BFA_FCS_FABRIC_SM_LINK_DOWN:
383 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
384 bfa_fcs_fabric_notify_offline(fabric);
385 break;
386
387 case BFA_FCS_FABRIC_SM_DELETE:
388 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
389 bfa_fcs_fabric_delete(fabric);
390 break;
391
392 default:
393 bfa_sm_fault(fabric->fcs, event);
394 }
395}
396
397/**
398 * There is no attached fabric - private loop or NPort-to-NPort topology.
399 */
400static void
401bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
402 enum bfa_fcs_fabric_event event)
403{
404 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
405 bfa_trc(fabric->fcs, event);
406
407 switch (event) {
408 case BFA_FCS_FABRIC_SM_LINK_DOWN:
409 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
410 bfa_lps_discard(fabric->lps);
411 bfa_fcs_fabric_notify_offline(fabric);
412 break;
413
414 case BFA_FCS_FABRIC_SM_DELETE:
415 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
416 bfa_fcs_fabric_delete(fabric);
417 break;
418
419 case BFA_FCS_FABRIC_SM_NO_FABRIC:
420 bfa_trc(fabric->fcs, fabric->bb_credit);
421 bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa, fabric->bb_credit);
422 break;
423
424 default:
425 bfa_sm_fault(fabric->fcs, event);
426 }
427}
428
429/**
430 * Fabric is online - normal operating state.
431 */
432static void
433bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
434 enum bfa_fcs_fabric_event event)
435{
436 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
437 bfa_trc(fabric->fcs, event);
438
439 switch (event) {
440 case BFA_FCS_FABRIC_SM_LINK_DOWN:
441 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
442 bfa_lps_discard(fabric->lps);
443 bfa_fcs_fabric_notify_offline(fabric);
444 break;
445
446 case BFA_FCS_FABRIC_SM_DELETE:
447 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
448 bfa_fcs_fabric_delete(fabric);
449 break;
450
451 case BFA_FCS_FABRIC_SM_AUTH_FAILED:
452 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
453 bfa_lps_discard(fabric->lps);
454 break;
455
456 case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
457 break;
458
459 default:
460 bfa_sm_fault(fabric->fcs, event);
461 }
462}
463
464/**
465 * Exchanging virtual fabric parameters.
466 */
467static void
468bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric,
469 enum bfa_fcs_fabric_event event)
470{
471 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
472 bfa_trc(fabric->fcs, event);
473
474 switch (event) {
475 case BFA_FCS_FABRIC_SM_CONT_OP:
476 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp_done);
477 break;
478
479 case BFA_FCS_FABRIC_SM_ISOLATE:
480 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_isolated);
481 break;
482
483 default:
484 bfa_sm_fault(fabric->fcs, event);
485 }
486}
487
488/**
489 * EVFP exchange complete and VFT tagging is enabled.
490 */
491static void
492bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric,
493 enum bfa_fcs_fabric_event event)
494{
495 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
496 bfa_trc(fabric->fcs, event);
497}
498
499/**
500 * Port is isolated after EVFP exchange due to VF_ID mismatch (N and F).
501 */
502static void
503bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric,
504 enum bfa_fcs_fabric_event event)
505{
506 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
507 bfa_trc(fabric->fcs, event);
508
509 bfa_log(fabric->fcs->logm, BFA_LOG_FCS_FABRIC_ISOLATED,
510 fabric->bport.port_cfg.pwwn, fabric->fcs->port_vfid,
511 fabric->event_arg.swp_vfid);
512}
513
514/**
515 * Fabric is being deleted, awaiting vport delete completions.
516 */
517static void
518bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric,
519 enum bfa_fcs_fabric_event event)
520{
521 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
522 bfa_trc(fabric->fcs, event);
523
524 switch (event) {
525 case BFA_FCS_FABRIC_SM_DELCOMP:
526 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
527 bfa_fcs_modexit_comp(fabric->fcs);
528 break;
529
530 case BFA_FCS_FABRIC_SM_LINK_UP:
531 break;
532
533 case BFA_FCS_FABRIC_SM_LINK_DOWN:
534 bfa_fcs_fabric_notify_offline(fabric);
535 break;
536
537 default:
538 bfa_sm_fault(fabric->fcs, event);
539 }
540}
541
542
543
544/**
545 * fcs_fabric_private fabric private functions
546 */
547
548static void
549bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric)
550{
551 struct bfa_port_cfg_s *port_cfg = &fabric->bport.port_cfg;
552
553 port_cfg->roles = BFA_PORT_ROLE_FCP_IM;
554 port_cfg->nwwn = bfa_ioc_get_nwwn(&fabric->fcs->bfa->ioc);
555 port_cfg->pwwn = bfa_ioc_get_pwwn(&fabric->fcs->bfa->ioc);
556}
557
558/**
559 * Port Symbolic Name Creation for base port.
560 */
561void
562bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)
563{
564 struct bfa_port_cfg_s *port_cfg = &fabric->bport.port_cfg;
565 char model[BFA_ADAPTER_MODEL_NAME_LEN] = {0};
566 struct bfa_fcs_driver_info_s *driver_info = &fabric->fcs->driver_info;
567
568 bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
569
570 /*
571 * Model name/number
572 */
573 strncpy((char *)&port_cfg->sym_name, model,
574 BFA_FCS_PORT_SYMBNAME_MODEL_SZ);
575 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
576 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
577
578 /*
579 * Driver Version
580 */
581 strncat((char *)&port_cfg->sym_name, (char *)driver_info->version,
582 BFA_FCS_PORT_SYMBNAME_VERSION_SZ);
583 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
584 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
585
586 /*
587 * Host machine name
588 */
589 strncat((char *)&port_cfg->sym_name,
590 (char *)driver_info->host_machine_name,
591 BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ);
592 strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
593 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
594
595 /*
596 * Host OS Info :
597 * If OS Patch Info is not there, do not truncate any bytes from the
598 * OS name string and instead copy the entire OS info string (64 bytes).
599 */
600 if (driver_info->host_os_patch[0] == '\0') {
601 strncat((char *)&port_cfg->sym_name,
602 (char *)driver_info->host_os_name, BFA_FCS_OS_STR_LEN);
603 strncat((char *)&port_cfg->sym_name,
604 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
605 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
606 } else {
607 strncat((char *)&port_cfg->sym_name,
608 (char *)driver_info->host_os_name,
609 BFA_FCS_PORT_SYMBNAME_OSINFO_SZ);
610 strncat((char *)&port_cfg->sym_name,
611 BFA_FCS_PORT_SYMBNAME_SEPARATOR,
612 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
613
614 /*
615 * Append host OS Patch Info
616 */
617 strncat((char *)&port_cfg->sym_name,
618 (char *)driver_info->host_os_patch,
619 BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ);
620 }
621
622 /*
623 * null terminate
624 */
625 port_cfg->sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
626}
627
628/**
629 * bfa lps login completion callback
630 */
631void
632bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status)
633{
634 struct bfa_fcs_fabric_s *fabric = uarg;
635
636 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
637 bfa_trc(fabric->fcs, status);
638
639 switch (status) {
640 case BFA_STATUS_OK:
641 fabric->stats.flogi_accepts++;
642 break;
643
644 case BFA_STATUS_INVALID_MAC:
645 /*
646 * Only for CNA
647 */
648 fabric->stats.flogi_acc_err++;
649 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
650
651 return;
652
653 case BFA_STATUS_EPROTOCOL:
654 switch (bfa_lps_get_extstatus(fabric->lps)) {
655 case BFA_EPROTO_BAD_ACCEPT:
656 fabric->stats.flogi_acc_err++;
657 break;
658
659 case BFA_EPROTO_UNKNOWN_RSP:
660 fabric->stats.flogi_unknown_rsp++;
661 break;
662
663 default:
664 break;
665 }
666 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
667
668 return;
669
670 case BFA_STATUS_FABRIC_RJT:
671 fabric->stats.flogi_rejects++;
672 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
673 return;
674
675 default:
676 fabric->stats.flogi_rsp_err++;
677 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
678 return;
679 }
680
681 fabric->bb_credit = bfa_lps_get_peer_bbcredit(fabric->lps);
682 bfa_trc(fabric->fcs, fabric->bb_credit);
683
684 if (!bfa_lps_is_brcd_fabric(fabric->lps))
685 fabric->fabric_name = bfa_lps_get_peer_nwwn(fabric->lps);
686
687 /*
688 * Check port type. It should be 1 = F-port.
689 */
690 if (bfa_lps_is_fport(fabric->lps)) {
691 fabric->bport.pid = bfa_lps_get_pid(fabric->lps);
692 fabric->is_npiv = bfa_lps_is_npiv_en(fabric->lps);
693 fabric->is_auth = bfa_lps_is_authreq(fabric->lps);
694 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_CONT_OP);
695 } else {
696 /*
697 * Nport-2-Nport direct attached
698 */
699 fabric->bport.port_topo.pn2n.rem_port_wwn =
700 bfa_lps_get_peer_pwwn(fabric->lps);
701 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC);
702 }
703
704 bfa_trc(fabric->fcs, fabric->bport.pid);
705 bfa_trc(fabric->fcs, fabric->is_npiv);
706 bfa_trc(fabric->fcs, fabric->is_auth);
707}
708
709/**
710 * Allocate and send FLOGI.
711 */
712static void
713bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric)
714{
715 struct bfa_s *bfa = fabric->fcs->bfa;
716 struct bfa_port_cfg_s *pcfg = &fabric->bport.port_cfg;
717 u8 alpa = 0;
718
719 if (bfa_fcport_get_topology(bfa) == BFA_PPORT_TOPOLOGY_LOOP)
720 alpa = bfa_fcport_get_myalpa(bfa);
721
722 bfa_lps_flogi(fabric->lps, fabric, alpa, bfa_fcport_get_maxfrsize(bfa),
723 pcfg->pwwn, pcfg->nwwn, fabric->auth_reqd);
724
725 fabric->stats.flogi_sent++;
726}
727
728static void
729bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric)
730{
731 struct bfa_fcs_vport_s *vport;
732 struct list_head *qe, *qen;
733
734 bfa_trc(fabric->fcs, fabric->fabric_name);
735
736 bfa_fcs_fabric_set_opertype(fabric);
737 fabric->stats.fabric_onlines++;
738
739 /**
740 * notify online event to base and then virtual ports
741 */
742 bfa_fcs_port_online(&fabric->bport);
743
744 list_for_each_safe(qe, qen, &fabric->vport_q) {
745 vport = (struct bfa_fcs_vport_s *)qe;
746 bfa_fcs_vport_online(vport);
747 }
748}
749
750static void
751bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric)
752{
753 struct bfa_fcs_vport_s *vport;
754 struct list_head *qe, *qen;
755
756 bfa_trc(fabric->fcs, fabric->fabric_name);
757 fabric->stats.fabric_offlines++;
758
759 /**
760 * notify offline event first to vports and then base port.
761 */
762 list_for_each_safe(qe, qen, &fabric->vport_q) {
763 vport = (struct bfa_fcs_vport_s *)qe;
764 bfa_fcs_vport_offline(vport);
765 }
766
767 bfa_fcs_port_offline(&fabric->bport);
768
769 fabric->fabric_name = 0;
770 fabric->fabric_ip_addr[0] = 0;
771}
772
773static void
774bfa_fcs_fabric_delay(void *cbarg)
775{
776 struct bfa_fcs_fabric_s *fabric = cbarg;
777
778 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELAYED);
779}
780
781/**
782 * Delete all vports and wait for vport delete completions.
783 */
784static void
785bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric)
786{
787 struct bfa_fcs_vport_s *vport;
788 struct list_head *qe, *qen;
789
790 list_for_each_safe(qe, qen, &fabric->vport_q) {
791 vport = (struct bfa_fcs_vport_s *)qe;
792 bfa_fcs_vport_fcs_delete(vport);
793 }
794
795 bfa_fcs_port_delete(&fabric->bport);
796 bfa_wc_wait(&fabric->wc);
797}
798
799static void
800bfa_fcs_fabric_delete_comp(void *cbarg)
801{
802 struct bfa_fcs_fabric_s *fabric = cbarg;
803
804 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELCOMP);
805}
806
807
808
809/**
810 * fcs_fabric_public fabric public functions
811 */
812
813/**
814 * Attach time initialization
815 */
816void
817bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs)
818{
819 struct bfa_fcs_fabric_s *fabric;
820
821 fabric = &fcs->fabric;
822 bfa_os_memset(fabric, 0, sizeof(struct bfa_fcs_fabric_s));
823
824 /**
825 * Initialize base fabric.
826 */
827 fabric->fcs = fcs;
828 INIT_LIST_HEAD(&fabric->vport_q);
829 INIT_LIST_HEAD(&fabric->vf_q);
830 fabric->lps = bfa_lps_alloc(fcs->bfa);
831 bfa_assert(fabric->lps);
832
833 /**
834 * Initialize fabric delete completion handler. Fabric deletion is complete
835 * when the last vport delete is complete.
836 */
837 bfa_wc_init(&fabric->wc, bfa_fcs_fabric_delete_comp, fabric);
838 bfa_wc_up(&fabric->wc); /* For the base port */
839
840 bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
841 bfa_fcs_lport_attach(&fabric->bport, fabric->fcs, FC_VF_ID_NULL, NULL);
842}
843
844void
845bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs)
846{
847 bfa_sm_send_event(&fcs->fabric, BFA_FCS_FABRIC_SM_CREATE);
848 bfa_trc(fcs, 0);
849}
850
851/**
852 * Module cleanup
853 */
854void
855bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs)
856{
857 struct bfa_fcs_fabric_s *fabric;
858
859 bfa_trc(fcs, 0);
860
861 /**
862 * Cleanup base fabric.
863 */
864 fabric = &fcs->fabric;
865 bfa_lps_delete(fabric->lps);
866 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELETE);
867}
868
869/**
870 * Fabric module start -- kick starts FCS actions
871 */
872void
873bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs)
874{
875 struct bfa_fcs_fabric_s *fabric;
876
877 bfa_trc(fcs, 0);
878 fabric = &fcs->fabric;
879 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_START);
880}
881
882/**
883 * Suspend fabric activity as part of driver suspend.
884 */
885void
886bfa_fcs_fabric_modsusp(struct bfa_fcs_s *fcs)
887{
888}
889
890bfa_boolean_t
891bfa_fcs_fabric_is_loopback(struct bfa_fcs_fabric_s *fabric)
892{
893 return bfa_sm_cmp_state(fabric, bfa_fcs_fabric_sm_loopback);
894}
895
896bfa_boolean_t
897bfa_fcs_fabric_is_auth_failed(struct bfa_fcs_fabric_s *fabric)
898{
899 return bfa_sm_cmp_state(fabric, bfa_fcs_fabric_sm_auth_failed);
900}
901
902enum bfa_pport_type
903bfa_fcs_fabric_port_type(struct bfa_fcs_fabric_s *fabric)
904{
905 return fabric->oper_type;
906}
907
908/**
909 * Link up notification from BFA physical port module.
910 */
911void
912bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric)
913{
914 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
915 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_UP);
916}
917
918/**
919 * Link down notification from BFA physical port module.
920 */
921void
922bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric)
923{
924 bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
925 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_DOWN);
926}
927
928/**
929 * A child vport is being created in the fabric.
930 *
931 * Call from vport module at vport creation. A list of base port and vports
932 * belonging to a fabric is maintained to propagate link events.
933 *
934 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
935 * param[in] vport - Vport being created.
936 *
937 * @return None (always succeeds)
938 */
939void
940bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
941 struct bfa_fcs_vport_s *vport)
942{
943 /**
944 * - add vport to fabric's vport_q
945 */
946 bfa_trc(fabric->fcs, fabric->vf_id);
947
948 list_add_tail(&vport->qe, &fabric->vport_q);
949 fabric->num_vports++;
950 bfa_wc_up(&fabric->wc);
951}
952
953/**
954 * A child vport is being deleted from fabric.
955 *
956 * Vport is being deleted.
957 */
958void
959bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
960 struct bfa_fcs_vport_s *vport)
961{
962 list_del(&vport->qe);
963 fabric->num_vports--;
964 bfa_wc_down(&fabric->wc);
965}
966
967/**
968 * Base port is deleted.
969 */
970void
971bfa_fcs_fabric_port_delete_comp(struct bfa_fcs_fabric_s *fabric)
972{
973 bfa_wc_down(&fabric->wc);
974}
975
976/**
977 * Check if fabric is online.
978 *
979 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
980 *
981 * @return TRUE/FALSE
982 */
983int
984bfa_fcs_fabric_is_online(struct bfa_fcs_fabric_s *fabric)
985{
986 return bfa_sm_cmp_state(fabric, bfa_fcs_fabric_sm_online);
987}
988
989
990bfa_status_t
991bfa_fcs_fabric_addvf(struct bfa_fcs_fabric_s *vf, struct bfa_fcs_s *fcs,
992 struct bfa_port_cfg_s *port_cfg,
993 struct bfad_vf_s *vf_drv)
994{
995 bfa_sm_set_state(vf, bfa_fcs_fabric_sm_uninit);
996 return BFA_STATUS_OK;
997}
998
999/**
1000 * Lookup for a vport withing a fabric given its pwwn
1001 */
1002struct bfa_fcs_vport_s *
1003bfa_fcs_fabric_vport_lookup(struct bfa_fcs_fabric_s *fabric, wwn_t pwwn)
1004{
1005 struct bfa_fcs_vport_s *vport;
1006 struct list_head *qe;
1007
1008 list_for_each(qe, &fabric->vport_q) {
1009 vport = (struct bfa_fcs_vport_s *)qe;
1010 if (bfa_fcs_port_get_pwwn(&vport->lport) == pwwn)
1011 return vport;
1012 }
1013
1014 return NULL;
1015}
1016
1017/**
1018 * In a given fabric, return the number of lports.
1019 *
1020 * param[in] fabric - Fabric instance. This can be a base fabric or vf.
1021 *
1022* @return : 1 or more.
1023 */
1024u16
1025bfa_fcs_fabric_vport_count(struct bfa_fcs_fabric_s *fabric)
1026{
1027 return fabric->num_vports;
1028}
1029
1030/*
1031 * Get OUI of the attached switch.
1032 *
1033 * Note : Use of this function should be avoided as much as possible.
1034 * This function should be used only if there is any requirement
1035 * to check for FOS version below 6.3.
1036 * To check if the attached fabric is a brocade fabric, use
1037 * bfa_lps_is_brcd_fabric() which works for FOS versions 6.3
1038 * or above only.
1039 */
1040
1041u16
1042bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric)
1043{
1044 wwn_t fab_nwwn;
1045 u8 *tmp;
1046 u16 oui;
1047
1048 fab_nwwn = bfa_lps_get_peer_nwwn(fabric->lps);
1049
1050 tmp = (uint8_t *)&fab_nwwn;
1051 oui = (tmp[3] << 8) | tmp[4];
1052
1053 return oui;
1054}
1055
1056/**
1057 * Unsolicited frame receive handling.
1058 */
1059void
1060bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs,
1061 u16 len)
1062{
1063 u32 pid = fchs->d_id;
1064 struct bfa_fcs_vport_s *vport;
1065 struct list_head *qe;
1066 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
1067 struct fc_logi_s *flogi = (struct fc_logi_s *) els_cmd;
1068
1069 bfa_trc(fabric->fcs, len);
1070 bfa_trc(fabric->fcs, pid);
1071
1072 /**
1073 * Look for our own FLOGI frames being looped back. This means an
1074 * external loopback cable is in place. Our own FLOGI frames are
1075 * sometimes looped back when switch port gets temporarily bypassed.
1076 */
1077 if ((pid == bfa_os_ntoh3b(FC_FABRIC_PORT))
1078 && (els_cmd->els_code == FC_ELS_FLOGI)
1079 && (flogi->port_name == bfa_fcs_port_get_pwwn(&fabric->bport))) {
1080 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LOOPBACK);
1081 return;
1082 }
1083
1084 /**
1085 * FLOGI/EVFP exchanges should be consumed by base fabric.
1086 */
1087 if (fchs->d_id == bfa_os_hton3b(FC_FABRIC_PORT)) {
1088 bfa_trc(fabric->fcs, pid);
1089 bfa_fcs_fabric_process_uf(fabric, fchs, len);
1090 return;
1091 }
1092
1093 if (fabric->bport.pid == pid) {
1094 /**
1095 * All authentication frames should be routed to auth
1096 */
1097 bfa_trc(fabric->fcs, els_cmd->els_code);
1098 if (els_cmd->els_code == FC_ELS_AUTH) {
1099 bfa_trc(fabric->fcs, els_cmd->els_code);
1100 fabric->auth.response = (u8 *) els_cmd;
1101 return;
1102 }
1103
1104 bfa_trc(fabric->fcs, *(u8 *) ((u8 *) fchs));
1105 bfa_fcs_port_uf_recv(&fabric->bport, fchs, len);
1106 return;
1107 }
1108
1109 /**
1110 * look for a matching local port ID
1111 */
1112 list_for_each(qe, &fabric->vport_q) {
1113 vport = (struct bfa_fcs_vport_s *)qe;
1114 if (vport->lport.pid == pid) {
1115 bfa_fcs_port_uf_recv(&vport->lport, fchs, len);
1116 return;
1117 }
1118 }
1119 bfa_trc(fabric->fcs, els_cmd->els_code);
1120 bfa_fcs_port_uf_recv(&fabric->bport, fchs, len);
1121}
1122
1123/**
1124 * Unsolicited frames to be processed by fabric.
1125 */
1126static void
1127bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs,
1128 u16 len)
1129{
1130 struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
1131
1132 bfa_trc(fabric->fcs, els_cmd->els_code);
1133
1134 switch (els_cmd->els_code) {
1135 case FC_ELS_FLOGI:
1136 bfa_fcs_fabric_process_flogi(fabric, fchs, len);
1137 break;
1138
1139 default:
1140 /*
1141 * need to generate a LS_RJT
1142 */
1143 break;
1144 }
1145}
1146
1147/**
1148 * Process incoming FLOGI
1149 */
1150static void
1151bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric,
1152 struct fchs_s *fchs, u16 len)
1153{
1154 struct fc_logi_s *flogi = (struct fc_logi_s *) (fchs + 1);
1155 struct bfa_fcs_port_s *bport = &fabric->bport;
1156
1157 bfa_trc(fabric->fcs, fchs->s_id);
1158
1159 fabric->stats.flogi_rcvd++;
1160 /*
1161 * Check port type. It should be 0 = n-port.
1162 */
1163 if (flogi->csp.port_type) {
1164 /*
1165 * @todo: may need to send a LS_RJT
1166 */
1167 bfa_trc(fabric->fcs, flogi->port_name);
1168 fabric->stats.flogi_rejected++;
1169 return;
1170 }
1171
1172 fabric->bb_credit = bfa_os_ntohs(flogi->csp.bbcred);
1173 bport->port_topo.pn2n.rem_port_wwn = flogi->port_name;
1174 bport->port_topo.pn2n.reply_oxid = fchs->ox_id;
1175
1176 /*
1177 * Send a Flogi Acc
1178 */
1179 bfa_fcs_fabric_send_flogi_acc(fabric);
1180 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC);
1181}
1182
1183static void
1184bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric)
1185{
1186 struct bfa_port_cfg_s *pcfg = &fabric->bport.port_cfg;
1187 struct bfa_fcs_port_n2n_s *n2n_port = &fabric->bport.port_topo.pn2n;
1188 struct bfa_s *bfa = fabric->fcs->bfa;
1189 struct bfa_fcxp_s *fcxp;
1190 u16 reqlen;
1191 struct fchs_s fchs;
1192
1193 fcxp = bfa_fcs_fcxp_alloc(fabric->fcs);
1194 /**
1195 * Do not expect this failure -- expect remote node to retry
1196 */
1197 if (!fcxp)
1198 return;
1199
1200 reqlen = fc_flogi_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
1201 bfa_os_hton3b(FC_FABRIC_PORT),
1202 n2n_port->reply_oxid, pcfg->pwwn,
1203 pcfg->nwwn, bfa_fcport_get_maxfrsize(bfa),
1204 bfa_fcport_get_rx_bbcredit(bfa));
1205
1206 bfa_fcxp_send(fcxp, NULL, fabric->vf_id, bfa_lps_get_tag(fabric->lps),
1207 BFA_FALSE, FC_CLASS_3, reqlen, &fchs,
1208 bfa_fcs_fabric_flogiacc_comp, fabric,
1209 FC_MAX_PDUSZ, 0); /* Timeout 0 indicates no
1210 * response expected
1211 */
1212}
1213
1214/**
1215 * Flogi Acc completion callback.
1216 */
1217static void
1218bfa_fcs_fabric_flogiacc_comp(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
1219 bfa_status_t status, u32 rsp_len,
1220 u32 resid_len, struct fchs_s *rspfchs)
1221{
1222 struct bfa_fcs_fabric_s *fabric = cbarg;
1223
1224 bfa_trc(fabric->fcs, status);
1225}
1226
1227/*
1228 *
1229 * @param[in] fabric - fabric
1230 * @param[in] result - 1
1231 *
1232 * @return - none
1233 */
1234void
1235bfa_fcs_auth_finished(struct bfa_fcs_fabric_s *fabric, enum auth_status status)
1236{
1237 bfa_trc(fabric->fcs, status);
1238
1239 if (status == FC_AUTH_STATE_SUCCESS)
1240 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_AUTH_SUCCESS);
1241 else
1242 bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_AUTH_FAILED);
1243}
1244
1245/**
1246 * Send AEN notification
1247 */
1248static void
1249bfa_fcs_fabric_aen_post(struct bfa_fcs_port_s *port,
1250 enum bfa_port_aen_event event)
1251{
1252 union bfa_aen_data_u aen_data;
1253 struct bfa_log_mod_s *logmod = port->fcs->logm;
1254 wwn_t pwwn = bfa_fcs_port_get_pwwn(port);
1255 wwn_t fwwn = bfa_fcs_port_get_fabric_name(port);
1256 char pwwn_ptr[BFA_STRING_32];
1257 char fwwn_ptr[BFA_STRING_32];
1258
1259 wwn2str(pwwn_ptr, pwwn);
1260 wwn2str(fwwn_ptr, fwwn);
1261
1262 bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, event),
1263 pwwn_ptr, fwwn_ptr);
1264
1265 aen_data.port.pwwn = pwwn;
1266 aen_data.port.fwwn = fwwn;
1267}
1268
1269/*
1270 *
1271 * @param[in] fabric - fabric
1272 * @param[in] wwn_t - new fabric name
1273 *
1274 * @return - none
1275 */
1276void
1277bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
1278 wwn_t fabric_name)
1279{
1280 bfa_trc(fabric->fcs, fabric_name);
1281
1282 if (fabric->fabric_name == 0) {
1283 /*
1284 * With BRCD switches, we don't get Fabric Name in FLOGI.
1285 * Don't generate a fabric name change event in this case.
1286 */
1287 fabric->fabric_name = fabric_name;
1288 } else {
1289 fabric->fabric_name = fabric_name;
1290 /*
1291 * Generate a Event
1292 */
1293 bfa_fcs_fabric_aen_post(&fabric->bport,
1294 BFA_PORT_AEN_FABRIC_NAME_CHANGE);
1295 }
1296
1297}
1298
1299/**
1300 *
1301 * @param[in] fabric - fabric
1302 * @param[in] node_symname -
1303 * Caller allocated buffer to receive the symbolic name
1304 *
1305 * @return - none
1306 */
1307void
1308bfa_fcs_get_sym_name(const struct bfa_fcs_s *fcs, char *node_symname)
1309{
1310 bfa_os_memcpy(node_symname,
1311 fcs->fabric.bport.port_cfg.sym_name.symname,
1312 BFA_SYMNAME_MAXLEN);
1313}
1314
1315/**
1316 * Not used by FCS.
1317 */
1318void
1319bfa_cb_lps_flogo_comp(void *bfad, void *uarg)
1320{
1321}
1322
1323
diff --git a/drivers/scsi/bfa/fcbuild.h b/drivers/scsi/bfa/fcbuild.h
deleted file mode 100644
index 981d98d542b9..000000000000
--- a/drivers/scsi/bfa/fcbuild.h
+++ /dev/null
@@ -1,279 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 * fcbuild.h - FC link service frame building and parsing routines
19 */
20
21#ifndef __FCBUILD_H__
22#define __FCBUILD_H__
23
24#include <bfa_os_inc.h>
25#include <protocol/fc.h>
26#include <protocol/fcp.h>
27#include <protocol/ct.h>
28#include <defs/bfa_defs_port.h>
29#include <defs/bfa_defs_pport.h>
30
31/*
32 * Utility Macros/functions
33 */
34
35#define fcif_sof_set(_ifhdr, _sof) ((_ifhdr)->sof = FC_ ## _sof)
36#define fcif_eof_set(_ifhdr, _eof) ((_ifhdr)->eof = FC_ ## _eof)
37
38#define wwn_is_equal(_wwn1, _wwn2) \
39 (memcmp(&(_wwn1), &(_wwn2), sizeof(wwn_t)) == 0)
40
41#define fc_roundup(_l, _s) (((_l) + ((_s) - 1)) & ~((_s) - 1))
42
43/*
44 * Given the fc response length, this routine will return
45 * the length of the actual payload bytes following the CT header.
46 *
47 * Assumes the input response length does not include the crc, eof, etc.
48 */
49static inline u32
50fc_get_ctresp_pyld_len(u32 resp_len)
51{
52 return resp_len - sizeof(struct ct_hdr_s);
53}
54
55/*
56 * Convert bfa speed to rpsc speed value.
57 */
58static inline enum bfa_pport_speed
59fc_rpsc_operspeed_to_bfa_speed(enum fc_rpsc_op_speed_s speed)
60{
61 switch (speed) {
62
63 case RPSC_OP_SPEED_1G:
64 return BFA_PPORT_SPEED_1GBPS;
65
66 case RPSC_OP_SPEED_2G:
67 return BFA_PPORT_SPEED_2GBPS;
68
69 case RPSC_OP_SPEED_4G:
70 return BFA_PPORT_SPEED_4GBPS;
71
72 case RPSC_OP_SPEED_8G:
73 return BFA_PPORT_SPEED_8GBPS;
74
75 case RPSC_OP_SPEED_10G:
76 return BFA_PPORT_SPEED_10GBPS;
77
78 default:
79 return BFA_PPORT_SPEED_UNKNOWN;
80 }
81}
82
83/*
84 * Convert RPSC speed to bfa speed value.
85 */
86static inline enum fc_rpsc_op_speed_s
87fc_bfa_speed_to_rpsc_operspeed(enum bfa_pport_speed op_speed)
88{
89 switch (op_speed) {
90
91 case BFA_PPORT_SPEED_1GBPS:
92 return RPSC_OP_SPEED_1G;
93
94 case BFA_PPORT_SPEED_2GBPS:
95 return RPSC_OP_SPEED_2G;
96
97 case BFA_PPORT_SPEED_4GBPS:
98 return RPSC_OP_SPEED_4G;
99
100 case BFA_PPORT_SPEED_8GBPS:
101 return RPSC_OP_SPEED_8G;
102
103 case BFA_PPORT_SPEED_10GBPS:
104 return RPSC_OP_SPEED_10G;
105
106 default:
107 return RPSC_OP_SPEED_NOT_EST;
108 }
109}
110enum fc_parse_status {
111 FC_PARSE_OK = 0,
112 FC_PARSE_FAILURE = 1,
113 FC_PARSE_BUSY = 2,
114 FC_PARSE_LEN_INVAL,
115 FC_PARSE_ACC_INVAL,
116 FC_PARSE_PWWN_NOT_EQUAL,
117 FC_PARSE_NWWN_NOT_EQUAL,
118 FC_PARSE_RXSZ_INVAL,
119 FC_PARSE_NOT_FCP,
120 FC_PARSE_OPAFLAG_INVAL,
121 FC_PARSE_RPAFLAG_INVAL,
122 FC_PARSE_OPA_INVAL,
123 FC_PARSE_RPA_INVAL,
124
125};
126
127struct fc_templates_s {
128 struct fchs_s fc_els_req;
129 struct fchs_s fc_bls_req;
130 struct fc_logi_s plogi;
131 struct fc_rrq_s rrq;
132};
133
134void fcbuild_init(void);
135
136u16 fc_flogi_build(struct fchs_s *fchs, struct fc_logi_s *flogi,
137 u32 s_id, u16 ox_id, wwn_t port_name,
138 wwn_t node_name, u16 pdu_size, u8 set_npiv,
139 u8 set_auth, u16 local_bb_credits);
140u16 fc_fdisc_build(struct fchs_s *buf, struct fc_logi_s *flogi,
141 u32 s_id, u16 ox_id, wwn_t port_name,
142 wwn_t node_name, u16 pdu_size);
143u16 fc_flogi_acc_build(struct fchs_s *fchs, struct fc_logi_s *flogi,
144 u32 s_id, u16 ox_id, wwn_t port_name,
145 wwn_t node_name, u16 pdu_size,
146 u16 local_bb_credits);
147u16 fc_plogi_build(struct fchs_s *fchs, void *pld, u32 d_id,
148 u32 s_id, u16 ox_id, wwn_t port_name,
149 wwn_t node_name, u16 pdu_size);
150enum fc_parse_status fc_plogi_parse(struct fchs_s *fchs);
151u16 fc_abts_build(struct fchs_s *buf, u32 d_id, u32 s_id,
152 u16 ox_id);
153enum fc_parse_status fc_abts_rsp_parse(struct fchs_s *buf, int len);
154u16 fc_rrq_build(struct fchs_s *buf, struct fc_rrq_s *rrq, u32 d_id,
155 u32 s_id, u16 ox_id, u16 rrq_oxid);
156enum fc_parse_status fc_rrq_rsp_parse(struct fchs_s *buf, int len);
157u16 fc_rspnid_build(struct fchs_s *fchs, void *pld, u32 s_id,
158 u16 ox_id, u8 *name);
159u16 fc_rftid_build(struct fchs_s *fchs, void *pld, u32 s_id,
160 u16 ox_id, enum bfa_port_role role);
161u16 fc_rftid_build_sol(struct fchs_s *fchs, void *pyld, u32 s_id,
162 u16 ox_id, u8 *fc4_bitmap,
163 u32 bitmap_size);
164u16 fc_rffid_build(struct fchs_s *fchs, void *pyld, u32 s_id,
165 u16 ox_id, u8 fc4_type, u8 fc4_ftrs);
166u16 fc_gidpn_build(struct fchs_s *fchs, void *pyld, u32 s_id,
167 u16 ox_id, wwn_t port_name);
168u16 fc_gpnid_build(struct fchs_s *fchs, void *pld, u32 s_id,
169 u16 ox_id, u32 port_id);
170u16 fc_scr_build(struct fchs_s *fchs, struct fc_scr_s *scr,
171 u8 set_br_reg, u32 s_id, u16 ox_id);
172u16 fc_plogi_acc_build(struct fchs_s *fchs, void *pld, u32 d_id,
173 u32 s_id, u16 ox_id,
174 wwn_t port_name, wwn_t node_name, u16 pdu_size);
175
176u16 fc_adisc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc,
177 u32 d_id, u32 s_id, u16 ox_id,
178 wwn_t port_name, wwn_t node_name);
179enum fc_parse_status fc_adisc_parse(struct fchs_s *fchs, void *pld,
180 u32 host_dap,
181 wwn_t node_name, wwn_t port_name);
182enum fc_parse_status fc_adisc_rsp_parse(struct fc_adisc_s *adisc, int len,
183 wwn_t port_name, wwn_t node_name);
184u16 fc_adisc_acc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc,
185 u32 d_id, u32 s_id, u16 ox_id,
186 wwn_t port_name, wwn_t node_name);
187u16 fc_ls_rjt_build(struct fchs_s *fchs, struct fc_ls_rjt_s *ls_rjt,
188 u32 d_id, u32 s_id, u16 ox_id,
189 u8 reason_code, u8 reason_code_expl);
190u16 fc_ls_acc_build(struct fchs_s *fchs, struct fc_els_cmd_s *els_cmd,
191 u32 d_id, u32 s_id, u16 ox_id);
192u16 fc_prli_build(struct fchs_s *fchs, void *pld, u32 d_id,
193 u32 s_id, u16 ox_id);
194enum fc_parse_status fc_prli_rsp_parse(struct fc_prli_s *prli, int len);
195
196u16 fc_prli_acc_build(struct fchs_s *fchs, void *pld, u32 d_id,
197 u32 s_id, u16 ox_id,
198 enum bfa_port_role role);
199u16 fc_rnid_build(struct fchs_s *fchs, struct fc_rnid_cmd_s *rnid,
200 u32 d_id, u32 s_id, u16 ox_id,
201 u32 data_format);
202u16 fc_rnid_acc_build(struct fchs_s *fchs, struct fc_rnid_acc_s *rnid_acc,
203 u32 d_id, u32 s_id, u16 ox_id,
204 u32 data_format,
205 struct fc_rnid_common_id_data_s *common_id_data,
206 struct fc_rnid_general_topology_data_s *
207 gen_topo_data);
208u16 fc_rpsc2_build(struct fchs_s *fchs, struct fc_rpsc2_cmd_s *rps2c,
209 u32 d_id, u32 s_id,
210 u32 *pid_list, u16 npids);
211u16 fc_rpsc_build(struct fchs_s *fchs, struct fc_rpsc_cmd_s *rpsc,
212 u32 d_id, u32 s_id, u16 ox_id);
213u16 fc_rpsc_acc_build(struct fchs_s *fchs, struct fc_rpsc_acc_s *rpsc_acc,
214 u32 d_id, u32 s_id, u16 ox_id,
215 struct fc_rpsc_speed_info_s *oper_speed);
216u16 fc_gid_ft_build(struct fchs_s *fchs, void *pld, u32 s_id,
217 u8 fc4_type);
218u16 fc_rpnid_build(struct fchs_s *fchs, void *pyld, u32 s_id,
219 u32 port_id, wwn_t port_name);
220u16 fc_rnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id,
221 u32 port_id, wwn_t node_name);
222u16 fc_rcsid_build(struct fchs_s *fchs, void *pyld, u32 s_id,
223 u32 port_id, u32 cos);
224u16 fc_rptid_build(struct fchs_s *fchs, void *pyld, u32 s_id,
225 u32 port_id, u8 port_type);
226u16 fc_ganxt_build(struct fchs_s *fchs, void *pyld, u32 s_id,
227 u32 port_id);
228u16 fc_logo_build(struct fchs_s *fchs, struct fc_logo_s *logo,
229 u32 d_id, u32 s_id, u16 ox_id,
230 wwn_t port_name);
231u16 fc_logo_acc_build(struct fchs_s *fchs, void *pld, u32 d_id,
232 u32 s_id, u16 ox_id);
233u16 fc_fdmi_reqhdr_build(struct fchs_s *fchs, void *pyld, u32 s_id,
234 u16 cmd_code);
235u16 fc_gmal_req_build(struct fchs_s *fchs, void *pyld, u32 s_id,
236 wwn_t wwn);
237u16 fc_gfn_req_build(struct fchs_s *fchs, void *pyld, u32 s_id,
238 wwn_t wwn);
239void fc_get_fc4type_bitmask(u8 fc4_type, u8 *bit_mask);
240void fc_els_req_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
241 u16 ox_id);
242enum fc_parse_status fc_els_rsp_parse(struct fchs_s *fchs, int len);
243enum fc_parse_status fc_plogi_rsp_parse(struct fchs_s *fchs, int len,
244 wwn_t port_name);
245enum fc_parse_status fc_prli_parse(struct fc_prli_s *prli);
246enum fc_parse_status fc_pdisc_parse(struct fchs_s *fchs, wwn_t node_name,
247 wwn_t port_name);
248u16 fc_ba_acc_build(struct fchs_s *fchs, struct fc_ba_acc_s *ba_acc,
249 u32 d_id, u32 s_id, u16 ox_id,
250 u16 rx_id);
251int fc_logout_params_pages(struct fchs_s *fc_frame, u8 els_code);
252u16 fc_tprlo_acc_build(struct fchs_s *fchs,
253 struct fc_tprlo_acc_s *tprlo_acc,
254 u32 d_id, u32 s_id, u16 ox_id,
255 int num_pages);
256u16 fc_prlo_acc_build(struct fchs_s *fchs, struct fc_prlo_acc_s *prlo_acc,
257 u32 d_id, u32 s_id, u16 ox_id,
258 int num_pages);
259u16 fc_logo_rsp_parse(struct fchs_s *fchs, int len);
260u16 fc_pdisc_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
261 u16 ox_id, wwn_t port_name, wwn_t node_name,
262 u16 pdu_size);
263u16 fc_pdisc_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name);
264u16 fc_prlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
265 u16 ox_id, int num_pages);
266u16 fc_prlo_rsp_parse(struct fchs_s *fchs, int len);
267u16 fc_tprlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
268 u16 ox_id, int num_pages,
269 enum fc_tprlo_type tprlo_type, u32 tpr_id);
270u16 fc_tprlo_rsp_parse(struct fchs_s *fchs, int len);
271u16 fc_ba_rjt_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
272 u16 ox_id, u32 reason_code,
273 u32 reason_expl);
274u16 fc_gnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id,
275 u16 ox_id, u32 port_id);
276u16 fc_ct_rsp_parse(struct ct_hdr_s *cthdr);
277u16 fc_rscn_build(struct fchs_s *fchs, struct fc_rscn_pl_s *rscn,
278 u32 s_id, u16 ox_id);
279#endif
diff --git a/drivers/scsi/bfa/fcptm.c b/drivers/scsi/bfa/fcptm.c
deleted file mode 100644
index 8c8b08c72e7a..000000000000
--- a/drivers/scsi/bfa/fcptm.c
+++ /dev/null
@@ -1,68 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * This file contains dummy FCPTM routines to aid in Initiator Mode only
20 * compilation of OS driver.
21 *
22 */
23
24#include "bfa_os_inc.h"
25#include "fcs_rport.h"
26#include "fcs_fcptm.h"
27#include "fcs/bfa_fcs_rport.h"
28
29struct bfa_fcs_tin_s *
30bfa_fcs_tin_create(struct bfa_fcs_rport_s *rport)
31{
32 return NULL;
33}
34
35void
36bfa_fcs_tin_delete(struct bfa_fcs_tin_s *tin)
37{
38}
39
40void
41bfa_fcs_tin_rport_offline(struct bfa_fcs_tin_s *tin)
42{
43}
44
45void
46bfa_fcs_tin_rport_online(struct bfa_fcs_tin_s *tin)
47{
48}
49
50void
51bfa_fcs_tin_rx_prli(struct bfa_fcs_tin_s *tin, struct fchs_s *fchs, u16 len)
52{
53}
54
55void
56bfa_fcs_fcptm_uf_recv(struct bfa_fcs_tin_s *tin, struct fchs_s *fchs, u16 len)
57{
58}
59
60void
61bfa_fcs_tin_pause(struct bfa_fcs_tin_s *tin)
62{
63}
64
65void
66bfa_fcs_tin_resume(struct bfa_fcs_tin_s *tin)
67{
68}
diff --git a/drivers/scsi/bfa/fcs.h b/drivers/scsi/bfa/fcs.h
deleted file mode 100644
index 8d08230e6295..000000000000
--- a/drivers/scsi/bfa/fcs.h
+++ /dev/null
@@ -1,30 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * fcs.h FCS module functions
20 */
21
22
23#ifndef __FCS_H__
24#define __FCS_H__
25
26#define __fcs_min_cfg(__fcs) ((__fcs)->min_cfg)
27
28void bfa_fcs_modexit_comp(struct bfa_fcs_s *fcs);
29
30#endif /* __FCS_H__ */
diff --git a/drivers/scsi/bfa/fcs_auth.h b/drivers/scsi/bfa/fcs_auth.h
deleted file mode 100644
index 65d155fea3d7..000000000000
--- a/drivers/scsi/bfa/fcs_auth.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * fcs_uf.h FCS unsolicited frame receive
20 */
21
22
23#ifndef __FCS_AUTH_H__
24#define __FCS_AUTH_H__
25
26#include <fcs/bfa_fcs.h>
27#include <fcs/bfa_fcs_vport.h>
28#include <fcs/bfa_fcs_lport.h>
29
30/*
31 * fcs friend functions: only between fcs modules
32 */
33void bfa_fcs_auth_uf_recv(struct bfa_fcs_fabric_s *fabric, int len);
34void bfa_fcs_auth_start(struct bfa_fcs_fabric_s *fabric);
35void bfa_fcs_auth_stop(struct bfa_fcs_fabric_s *fabric);
36
37#endif /* __FCS_UF_H__ */
diff --git a/drivers/scsi/bfa/fcs_fabric.h b/drivers/scsi/bfa/fcs_fabric.h
deleted file mode 100644
index 432ab8ab8c3c..000000000000
--- a/drivers/scsi/bfa/fcs_fabric.h
+++ /dev/null
@@ -1,68 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * fcs_lport.h FCS logical port interfaces
20 */
21
22#ifndef __FCS_FABRIC_H__
23#define __FCS_FABRIC_H__
24
25#include <fcs/bfa_fcs.h>
26#include <fcs/bfa_fcs_vport.h>
27#include <fcs/bfa_fcs_lport.h>
28
29#define BFA_FCS_BRCD_SWITCH_OUI 0x051e
30
31/*
32* fcs friend functions: only between fcs modules
33 */
34void bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs);
35void bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs);
36void bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs);
37void bfa_fcs_fabric_modsusp(struct bfa_fcs_s *fcs);
38void bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric);
39void bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric);
40void bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
41 struct bfa_fcs_vport_s *vport);
42void bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
43 struct bfa_fcs_vport_s *vport);
44int bfa_fcs_fabric_is_online(struct bfa_fcs_fabric_s *fabric);
45struct bfa_fcs_vport_s *bfa_fcs_fabric_vport_lookup(
46 struct bfa_fcs_fabric_s *fabric, wwn_t pwwn);
47void bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs);
48void bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric,
49 struct fchs_s *fchs, u16 len);
50u16 bfa_fcs_fabric_vport_count(struct bfa_fcs_fabric_s *fabric);
51bfa_boolean_t bfa_fcs_fabric_is_loopback(struct bfa_fcs_fabric_s *fabric);
52bfa_boolean_t bfa_fcs_fabric_is_auth_failed(struct bfa_fcs_fabric_s *fabric);
53enum bfa_pport_type bfa_fcs_fabric_port_type(struct bfa_fcs_fabric_s *fabric);
54void bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric);
55void bfa_fcs_fabric_port_delete_comp(struct bfa_fcs_fabric_s *fabric);
56
57bfa_status_t bfa_fcs_fabric_addvf(struct bfa_fcs_fabric_s *vf,
58 struct bfa_fcs_s *fcs, struct bfa_port_cfg_s *port_cfg,
59 struct bfad_vf_s *vf_drv);
60void bfa_fcs_auth_finished(struct bfa_fcs_fabric_s *fabric,
61 enum auth_status status);
62
63void bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
64 wwn_t fabric_name);
65u16 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric);
66void bfa_fcs_get_sym_name(const struct bfa_fcs_s *fcs, char *node_symname);
67
68#endif /* __FCS_FABRIC_H__ */
diff --git a/drivers/scsi/bfa/fcs_fcpim.h b/drivers/scsi/bfa/fcs_fcpim.h
deleted file mode 100644
index 11e6e7bce9f6..000000000000
--- a/drivers/scsi/bfa/fcs_fcpim.h
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __FCS_FCPIM_H__
18#define __FCS_FCPIM_H__
19
20#include <defs/bfa_defs_port.h>
21#include <fcs/bfa_fcs_lport.h>
22#include <fcs/bfa_fcs_rport.h>
23
24/*
25 * Following routines are from FCPIM and will be called by rport.
26 */
27struct bfa_fcs_itnim_s *bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport);
28void bfa_fcs_itnim_delete(struct bfa_fcs_itnim_s *itnim);
29void bfa_fcs_itnim_rport_offline(struct bfa_fcs_itnim_s *itnim);
30void bfa_fcs_itnim_rport_online(struct bfa_fcs_itnim_s *itnim);
31bfa_status_t bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim);
32
33void bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s *itnim);
34void bfa_fcs_itnim_pause(struct bfa_fcs_itnim_s *itnim);
35void bfa_fcs_itnim_resume(struct bfa_fcs_itnim_s *itnim);
36
37void bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim, struct fchs_s *fchs,
38 u16 len);
39#endif /* __FCS_FCPIM_H__ */
diff --git a/drivers/scsi/bfa/fcs_fcptm.h b/drivers/scsi/bfa/fcs_fcptm.h
deleted file mode 100644
index ffff0829fd31..000000000000
--- a/drivers/scsi/bfa/fcs_fcptm.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __FCS_FCPTM_H__
19#define __FCS_FCPTM_H__
20
21#include <defs/bfa_defs_port.h>
22#include <fcs/bfa_fcs_lport.h>
23#include <fcs/bfa_fcs_rport.h>
24
25/*
26 * Following routines are from FCPTM and will be called by rport.
27 */
28struct bfa_fcs_tin_s *bfa_fcs_tin_create(struct bfa_fcs_rport_s *rport);
29void bfa_fcs_tin_rport_offline(struct bfa_fcs_tin_s *tin);
30void bfa_fcs_tin_rport_online(struct bfa_fcs_tin_s *tin);
31void bfa_fcs_tin_delete(struct bfa_fcs_tin_s *tin);
32void bfa_fcs_tin_rx_prli(struct bfa_fcs_tin_s *tin, struct fchs_s *fchs,
33 u16 len);
34void bfa_fcs_tin_pause(struct bfa_fcs_tin_s *tin);
35void bfa_fcs_tin_resume(struct bfa_fcs_tin_s *tin);
36
37/*
38 * Modudle init/cleanup routines.
39 */
40void bfa_fcs_fcptm_modinit(struct bfa_fcs_s *fcs);
41void bfa_fcs_fcptm_modexit(struct bfa_fcs_s *fcs);
42void bfa_fcs_fcptm_uf_recv(struct bfa_fcs_tin_s *tin, struct fchs_s *fchs,
43 u16 len);
44
45#endif /* __FCS_FCPTM_H__ */
diff --git a/drivers/scsi/bfa/fcs_fcxp.h b/drivers/scsi/bfa/fcs_fcxp.h
deleted file mode 100644
index 8277fe9c2b70..000000000000
--- a/drivers/scsi/bfa/fcs_fcxp.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * fcs_fcxp.h FCXP helper macros for FCS
20 */
21
22
23#ifndef __FCS_FCXP_H__
24#define __FCS_FCXP_H__
25
26#define bfa_fcs_fcxp_alloc(__fcs) \
27 bfa_fcxp_alloc(NULL, (__fcs)->bfa, 0, 0, NULL, NULL, NULL, NULL)
28
29#endif /* __FCS_FCXP_H__ */
diff --git a/drivers/scsi/bfa/fcs_lport.h b/drivers/scsi/bfa/fcs_lport.h
deleted file mode 100644
index a6508c8ab184..000000000000
--- a/drivers/scsi/bfa/fcs_lport.h
+++ /dev/null
@@ -1,118 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * fcs_lport.h FCS logical port interfaces
20 */
21
22#ifndef __FCS_LPORT_H__
23#define __FCS_LPORT_H__
24
25#define __VPORT_H__
26#include <defs/bfa_defs_port.h>
27#include <bfa_svc.h>
28#include <fcs/bfa_fcs_lport.h>
29#include <fcs/bfa_fcs_rport.h>
30#include <fcs/bfa_fcs_vport.h>
31#include <fcs_fabric.h>
32#include <fcs_ms.h>
33#include <cs/bfa_q.h>
34#include <fcbuild.h>
35
36/*
37 * PID used in P2P/N2N ( In Big Endian)
38 */
39#define N2N_LOCAL_PID 0x010000
40#define N2N_REMOTE_PID 0x020000
41
42/*
43 * Misc Timeouts
44 */
45/*
46 * To be used when spawning a timer before retrying a failed command. Milli
47 * Secs.
48 */
49#define BFA_FCS_RETRY_TIMEOUT 2000
50
51/*
52 * Check for Port/Vport Mode/Role
53 */
54#define BFA_FCS_VPORT_IS_INITIATOR_MODE(port) \
55 (port->port_cfg.roles & BFA_PORT_ROLE_FCP_IM)
56
57#define BFA_FCS_VPORT_IS_TARGET_MODE(port) \
58 (port->port_cfg.roles & BFA_PORT_ROLE_FCP_TM)
59
60#define BFA_FCS_VPORT_IS_IPFC_MODE(port) \
61 (port->port_cfg.roles & BFA_PORT_ROLE_FCP_IPFC)
62
63/*
64 * Is this a Well Known Address
65 */
66#define BFA_FCS_PID_IS_WKA(pid) ((bfa_os_ntoh3b(pid) > 0xFFF000) ? 1 : 0)
67
68/*
69 * Pointer to elements within Port
70 */
71#define BFA_FCS_GET_HAL_FROM_PORT(port) (port->fcs->bfa)
72#define BFA_FCS_GET_NS_FROM_PORT(port) (&port->port_topo.pfab.ns)
73#define BFA_FCS_GET_SCN_FROM_PORT(port) (&port->port_topo.pfab.scn)
74#define BFA_FCS_GET_MS_FROM_PORT(port) (&port->port_topo.pfab.ms)
75#define BFA_FCS_GET_FDMI_FROM_PORT(port) (&port->port_topo.pfab.ms.fdmi)
76
77/*
78 * handler for unsolicied frames
79 */
80void bfa_fcs_port_uf_recv(struct bfa_fcs_port_s *lport, struct fchs_s *fchs,
81 u16 len);
82
83/*
84 * Following routines will be called by Fabric to indicate port
85 * online/offline to vport.
86 */
87void bfa_fcs_lport_attach(struct bfa_fcs_port_s *lport, struct bfa_fcs_s *fcs,
88 uint16_t vf_id, struct bfa_fcs_vport_s *vport);
89void bfa_fcs_lport_init(struct bfa_fcs_port_s *lport,
90 struct bfa_port_cfg_s *port_cfg);
91void bfa_fcs_port_online(struct bfa_fcs_port_s *port);
92void bfa_fcs_port_offline(struct bfa_fcs_port_s *port);
93void bfa_fcs_port_delete(struct bfa_fcs_port_s *port);
94bfa_boolean_t bfa_fcs_port_is_online(struct bfa_fcs_port_s *port);
95
96/*
97 * Lookup rport based on PID
98 */
99struct bfa_fcs_rport_s *bfa_fcs_port_get_rport_by_pid(
100 struct bfa_fcs_port_s *port, u32 pid);
101
102/*
103 * Lookup rport based on PWWN
104 */
105struct bfa_fcs_rport_s *bfa_fcs_port_get_rport_by_pwwn(
106 struct bfa_fcs_port_s *port, wwn_t pwwn);
107struct bfa_fcs_rport_s *bfa_fcs_port_get_rport_by_nwwn(
108 struct bfa_fcs_port_s *port, wwn_t nwwn);
109void bfa_fcs_port_add_rport(struct bfa_fcs_port_s *port,
110 struct bfa_fcs_rport_s *rport);
111void bfa_fcs_port_del_rport(struct bfa_fcs_port_s *port,
112 struct bfa_fcs_rport_s *rport);
113
114void bfa_fcs_port_modinit(struct bfa_fcs_s *fcs);
115void bfa_fcs_port_modexit(struct bfa_fcs_s *fcs);
116void bfa_fcs_port_lip(struct bfa_fcs_port_s *port);
117
118#endif /* __FCS_LPORT_H__ */
diff --git a/drivers/scsi/bfa/fcs_ms.h b/drivers/scsi/bfa/fcs_ms.h
deleted file mode 100644
index b6a8c12876f4..000000000000
--- a/drivers/scsi/bfa/fcs_ms.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * fcs_ms.h FCS ms interfaces
20 */
21#ifndef __FCS_MS_H__
22#define __FCS_MS_H__
23
24/* MS FCS routines */
25void bfa_fcs_port_ms_init(struct bfa_fcs_port_s *port);
26void bfa_fcs_port_ms_offline(struct bfa_fcs_port_s *port);
27void bfa_fcs_port_ms_online(struct bfa_fcs_port_s *port);
28void bfa_fcs_port_ms_fabric_rscn(struct bfa_fcs_port_s *port);
29
30/* FDMI FCS routines */
31void bfa_fcs_port_fdmi_init(struct bfa_fcs_port_ms_s *ms);
32void bfa_fcs_port_fdmi_offline(struct bfa_fcs_port_ms_s *ms);
33void bfa_fcs_port_fdmi_online(struct bfa_fcs_port_ms_s *ms);
34
35#endif
diff --git a/drivers/scsi/bfa/fcs_port.h b/drivers/scsi/bfa/fcs_port.h
deleted file mode 100644
index 408c06a7d164..000000000000
--- a/drivers/scsi/bfa/fcs_port.h
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * fcs_pport.h FCS physical port interfaces
20 */
21
22
23#ifndef __FCS_PPORT_H__
24#define __FCS_PPORT_H__
25
26/*
27 * fcs friend functions: only between fcs modules
28 */
29void bfa_fcs_pport_attach(struct bfa_fcs_s *fcs);
30
31#endif /* __FCS_PPORT_H__ */
diff --git a/drivers/scsi/bfa/fcs_rport.h b/drivers/scsi/bfa/fcs_rport.h
deleted file mode 100644
index e634fb7a69b8..000000000000
--- a/drivers/scsi/bfa/fcs_rport.h
+++ /dev/null
@@ -1,61 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * fcs_rport.h FCS rport interfaces and defines
20 */
21
22#ifndef __FCS_RPORT_H__
23#define __FCS_RPORT_H__
24
25#include <fcs/bfa_fcs_rport.h>
26
27#define BFA_FCS_RPORT_MAX_RETRIES (5)
28
29void bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs,
30 u16 len);
31void bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport);
32
33struct bfa_fcs_rport_s *bfa_fcs_rport_create(struct bfa_fcs_port_s *port,
34 u32 pid);
35void bfa_fcs_rport_delete(struct bfa_fcs_rport_s *rport);
36void bfa_fcs_rport_online(struct bfa_fcs_rport_s *rport);
37void bfa_fcs_rport_offline(struct bfa_fcs_rport_s *rport);
38void bfa_fcs_rport_start(struct bfa_fcs_port_s *port, struct fchs_s *rx_fchs,
39 struct fc_logi_s *plogi_rsp);
40void bfa_fcs_rport_plogi_create(struct bfa_fcs_port_s *port,
41 struct fchs_s *rx_fchs,
42 struct fc_logi_s *plogi);
43void bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs,
44 struct fc_logi_s *plogi);
45void bfa_fcs_rport_logo_imp(struct bfa_fcs_rport_s *rport);
46void bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, uint16_t ox_id);
47void bfa_fcs_rport_itnim_ack(struct bfa_fcs_rport_s *rport);
48void bfa_fcs_rport_itntm_ack(struct bfa_fcs_rport_s *rport);
49void bfa_fcs_rport_tin_ack(struct bfa_fcs_rport_s *rport);
50void bfa_fcs_rport_fcptm_offline_done(struct bfa_fcs_rport_s *rport);
51int bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport);
52struct bfa_fcs_rport_s *bfa_fcs_rport_create_by_wwn(struct bfa_fcs_port_s *port,
53 wwn_t wwn);
54
55
56/* Rport Features */
57void bfa_fcs_rpf_init(struct bfa_fcs_rport_s *rport);
58void bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s *rport);
59void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport);
60
61#endif /* __FCS_RPORT_H__ */
diff --git a/drivers/scsi/bfa/fcs_trcmod.h b/drivers/scsi/bfa/fcs_trcmod.h
deleted file mode 100644
index 41b5ae8d7644..000000000000
--- a/drivers/scsi/bfa/fcs_trcmod.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * fcs_trcmod.h BFA FCS trace modules
20 */
21
22#ifndef __FCS_TRCMOD_H__
23#define __FCS_TRCMOD_H__
24
25#include <cs/bfa_trc.h>
26
27/*
28 * !!! Only append to the enums defined here to avoid any versioning
29 * !!! needed between trace utility and driver version
30 */
31enum {
32 BFA_TRC_FCS_FABRIC = 1,
33 BFA_TRC_FCS_VFAPI = 2,
34 BFA_TRC_FCS_PORT = 3,
35 BFA_TRC_FCS_VPORT = 4,
36 BFA_TRC_FCS_VP_API = 5,
37 BFA_TRC_FCS_VPS = 6,
38 BFA_TRC_FCS_RPORT = 7,
39 BFA_TRC_FCS_FCPIM = 8,
40 BFA_TRC_FCS_FCPTM = 9,
41 BFA_TRC_FCS_NS = 10,
42 BFA_TRC_FCS_SCN = 11,
43 BFA_TRC_FCS_LOOP = 12,
44 BFA_TRC_FCS_UF = 13,
45 BFA_TRC_FCS_PPORT = 14,
46 BFA_TRC_FCS_FCPIP = 15,
47 BFA_TRC_FCS_PORT_API = 16,
48 BFA_TRC_FCS_RPORT_API = 17,
49 BFA_TRC_FCS_AUTH = 18,
50 BFA_TRC_FCS_N2N = 19,
51 BFA_TRC_FCS_MS = 20,
52 BFA_TRC_FCS_FDMI = 21,
53 BFA_TRC_FCS_RPORT_FTRS = 22,
54};
55
56#endif /* __FCS_TRCMOD_H__ */
diff --git a/drivers/scsi/bfa/fcs_uf.h b/drivers/scsi/bfa/fcs_uf.h
deleted file mode 100644
index f591072214fe..000000000000
--- a/drivers/scsi/bfa/fcs_uf.h
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * fcs_uf.h FCS unsolicited frame receive
20 */
21
22
23#ifndef __FCS_UF_H__
24#define __FCS_UF_H__
25
26/*
27 * fcs friend functions: only between fcs modules
28 */
29void bfa_fcs_uf_attach(struct bfa_fcs_s *fcs);
30
31#endif /* __FCS_UF_H__ */
diff --git a/drivers/scsi/bfa/fcs_vport.h b/drivers/scsi/bfa/fcs_vport.h
deleted file mode 100644
index bb647a4a5dde..000000000000
--- a/drivers/scsi/bfa/fcs_vport.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __FCS_VPORT_H__
19#define __FCS_VPORT_H__
20
21#include <fcs/bfa_fcs_lport.h>
22#include <fcs/bfa_fcs_vport.h>
23#include <defs/bfa_defs_pci.h>
24
25void bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s *vport);
26void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport);
27void bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport);
28void bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport);
29void bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s *vport);
30
31#endif /* __FCS_VPORT_H__ */
32
diff --git a/drivers/scsi/bfa/fdmi.c b/drivers/scsi/bfa/fdmi.c
deleted file mode 100644
index 2b50eabf4b1e..000000000000
--- a/drivers/scsi/bfa/fdmi.c
+++ /dev/null
@@ -1,1230 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * port_api.c BFA FCS port
20 */
21
22
23#include <bfa.h>
24#include <bfa_svc.h>
25#include "fcs_lport.h"
26#include "fcs_rport.h"
27#include "lport_priv.h"
28#include "fcs_trcmod.h"
29#include "fcs_fcxp.h"
30#include <fcs/bfa_fcs_fdmi.h>
31
32BFA_TRC_FILE(FCS, FDMI);
33
34#define BFA_FCS_FDMI_CMD_MAX_RETRIES 2
35
36/*
37 * forward declarations
38 */
39static void bfa_fcs_port_fdmi_send_rhba(void *fdmi_cbarg,
40 struct bfa_fcxp_s *fcxp_alloced);
41static void bfa_fcs_port_fdmi_send_rprt(void *fdmi_cbarg,
42 struct bfa_fcxp_s *fcxp_alloced);
43static void bfa_fcs_port_fdmi_send_rpa(void *fdmi_cbarg,
44 struct bfa_fcxp_s *fcxp_alloced);
45static void bfa_fcs_port_fdmi_rhba_response(void *fcsarg,
46 struct bfa_fcxp_s *fcxp,
47 void *cbarg,
48 bfa_status_t req_status,
49 u32 rsp_len,
50 u32 resid_len,
51 struct fchs_s *rsp_fchs);
52static void bfa_fcs_port_fdmi_rprt_response(void *fcsarg,
53 struct bfa_fcxp_s *fcxp,
54 void *cbarg,
55 bfa_status_t req_status,
56 u32 rsp_len,
57 u32 resid_len,
58 struct fchs_s *rsp_fchs);
59static void bfa_fcs_port_fdmi_rpa_response(void *fcsarg,
60 struct bfa_fcxp_s *fcxp,
61 void *cbarg,
62 bfa_status_t req_status,
63 u32 rsp_len,
64 u32 resid_len,
65 struct fchs_s *rsp_fchs);
66static void bfa_fcs_port_fdmi_timeout(void *arg);
67static u16 bfa_fcs_port_fdmi_build_rhba_pyld(
68 struct bfa_fcs_port_fdmi_s *fdmi, u8 *pyld);
69static u16 bfa_fcs_port_fdmi_build_rprt_pyld(
70 struct bfa_fcs_port_fdmi_s *fdmi, u8 *pyld);
71static u16 bfa_fcs_port_fdmi_build_rpa_pyld(
72 struct bfa_fcs_port_fdmi_s *fdmi, u8 *pyld);
73static u16 bfa_fcs_port_fdmi_build_portattr_block(
74 struct bfa_fcs_port_fdmi_s *fdmi, u8 *pyld);
75static void bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_port_fdmi_s *fdmi,
76 struct bfa_fcs_fdmi_hba_attr_s *hba_attr);
77static void bfa_fcs_fdmi_get_portattr(struct bfa_fcs_port_fdmi_s *fdmi,
78 struct bfa_fcs_fdmi_port_attr_s *port_attr);
79/**
80 * fcs_fdmi_sm FCS FDMI state machine
81 */
82
83/**
84 * FDMI State Machine events
85 */
86enum port_fdmi_event {
87 FDMISM_EVENT_PORT_ONLINE = 1,
88 FDMISM_EVENT_PORT_OFFLINE = 2,
89 FDMISM_EVENT_RSP_OK = 4,
90 FDMISM_EVENT_RSP_ERROR = 5,
91 FDMISM_EVENT_TIMEOUT = 6,
92 FDMISM_EVENT_RHBA_SENT = 7,
93 FDMISM_EVENT_RPRT_SENT = 8,
94 FDMISM_EVENT_RPA_SENT = 9,
95};
96
97static void bfa_fcs_port_fdmi_sm_offline(struct bfa_fcs_port_fdmi_s *fdmi,
98 enum port_fdmi_event event);
99static void bfa_fcs_port_fdmi_sm_sending_rhba(struct bfa_fcs_port_fdmi_s *fdmi,
100 enum port_fdmi_event event);
101static void bfa_fcs_port_fdmi_sm_rhba(struct bfa_fcs_port_fdmi_s *fdmi,
102 enum port_fdmi_event event);
103static void bfa_fcs_port_fdmi_sm_rhba_retry(struct bfa_fcs_port_fdmi_s *fdmi,
104 enum port_fdmi_event event);
105static void bfa_fcs_port_fdmi_sm_sending_rprt(struct bfa_fcs_port_fdmi_s *fdmi,
106 enum port_fdmi_event event);
107static void bfa_fcs_port_fdmi_sm_rprt(struct bfa_fcs_port_fdmi_s *fdmi,
108 enum port_fdmi_event event);
109static void bfa_fcs_port_fdmi_sm_rprt_retry(struct bfa_fcs_port_fdmi_s *fdmi,
110 enum port_fdmi_event event);
111static void bfa_fcs_port_fdmi_sm_sending_rpa(struct bfa_fcs_port_fdmi_s *fdmi,
112 enum port_fdmi_event event);
113static void bfa_fcs_port_fdmi_sm_rpa(struct bfa_fcs_port_fdmi_s *fdmi,
114 enum port_fdmi_event event);
115static void bfa_fcs_port_fdmi_sm_rpa_retry(struct bfa_fcs_port_fdmi_s *fdmi,
116 enum port_fdmi_event event);
117static void bfa_fcs_port_fdmi_sm_online(struct bfa_fcs_port_fdmi_s *fdmi,
118 enum port_fdmi_event event);
119static void bfa_fcs_port_fdmi_sm_disabled(struct bfa_fcs_port_fdmi_s *fdmi,
120 enum port_fdmi_event event);
121
122/**
123 * Start in offline state - awaiting MS to send start.
124 */
125static void
126bfa_fcs_port_fdmi_sm_offline(struct bfa_fcs_port_fdmi_s *fdmi,
127 enum port_fdmi_event event)
128{
129 struct bfa_fcs_port_s *port = fdmi->ms->port;
130
131 bfa_trc(port->fcs, port->port_cfg.pwwn);
132 bfa_trc(port->fcs, event);
133
134 fdmi->retry_cnt = 0;
135
136 switch (event) {
137 case FDMISM_EVENT_PORT_ONLINE:
138 if (port->vport) {
139 /*
140 * For Vports, register a new port.
141 */
142 bfa_sm_set_state(fdmi,
143 bfa_fcs_port_fdmi_sm_sending_rprt);
144 bfa_fcs_port_fdmi_send_rprt(fdmi, NULL);
145 } else {
146 /*
147 * For a base port, we should first register the HBA
148 * atribute. The HBA attribute also contains the base
149 * port registration.
150 */
151 bfa_sm_set_state(fdmi,
152 bfa_fcs_port_fdmi_sm_sending_rhba);
153 bfa_fcs_port_fdmi_send_rhba(fdmi, NULL);
154 }
155 break;
156
157 case FDMISM_EVENT_PORT_OFFLINE:
158 break;
159
160 default:
161 bfa_sm_fault(port->fcs, event);
162 }
163}
164
165static void
166bfa_fcs_port_fdmi_sm_sending_rhba(struct bfa_fcs_port_fdmi_s *fdmi,
167 enum port_fdmi_event event)
168{
169 struct bfa_fcs_port_s *port = fdmi->ms->port;
170
171 bfa_trc(port->fcs, port->port_cfg.pwwn);
172 bfa_trc(port->fcs, event);
173
174 switch (event) {
175 case FDMISM_EVENT_RHBA_SENT:
176 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_rhba);
177 break;
178
179 case FDMISM_EVENT_PORT_OFFLINE:
180 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
181 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port),
182 &fdmi->fcxp_wqe);
183 break;
184
185 default:
186 bfa_sm_fault(port->fcs, event);
187 }
188}
189
190static void
191bfa_fcs_port_fdmi_sm_rhba(struct bfa_fcs_port_fdmi_s *fdmi,
192 enum port_fdmi_event event)
193{
194 struct bfa_fcs_port_s *port = fdmi->ms->port;
195
196 bfa_trc(port->fcs, port->port_cfg.pwwn);
197 bfa_trc(port->fcs, event);
198
199 switch (event) {
200 case FDMISM_EVENT_RSP_ERROR:
201 /*
202 * if max retries have not been reached, start timer for a
203 * delayed retry
204 */
205 if (fdmi->retry_cnt++ < BFA_FCS_FDMI_CMD_MAX_RETRIES) {
206 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_rhba_retry);
207 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port),
208 &fdmi->timer, bfa_fcs_port_fdmi_timeout,
209 fdmi, BFA_FCS_RETRY_TIMEOUT);
210 } else {
211 /*
212 * set state to offline
213 */
214 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
215 }
216 break;
217
218 case FDMISM_EVENT_RSP_OK:
219 /*
220 * Initiate Register Port Attributes
221 */
222 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_sending_rpa);
223 fdmi->retry_cnt = 0;
224 bfa_fcs_port_fdmi_send_rpa(fdmi, NULL);
225 break;
226
227 case FDMISM_EVENT_PORT_OFFLINE:
228 bfa_fcxp_discard(fdmi->fcxp);
229 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
230 break;
231
232 default:
233 bfa_sm_fault(port->fcs, event);
234 }
235}
236
237static void
238bfa_fcs_port_fdmi_sm_rhba_retry(struct bfa_fcs_port_fdmi_s *fdmi,
239 enum port_fdmi_event event)
240{
241 struct bfa_fcs_port_s *port = fdmi->ms->port;
242
243 bfa_trc(port->fcs, port->port_cfg.pwwn);
244 bfa_trc(port->fcs, event);
245
246 switch (event) {
247 case FDMISM_EVENT_TIMEOUT:
248 /*
249 * Retry Timer Expired. Re-send
250 */
251 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_sending_rhba);
252 bfa_fcs_port_fdmi_send_rhba(fdmi, NULL);
253 break;
254
255 case FDMISM_EVENT_PORT_OFFLINE:
256 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
257 bfa_timer_stop(&fdmi->timer);
258 break;
259
260 default:
261 bfa_sm_fault(port->fcs, event);
262 }
263}
264
265/*
266* RPRT : Register Port
267 */
268static void
269bfa_fcs_port_fdmi_sm_sending_rprt(struct bfa_fcs_port_fdmi_s *fdmi,
270 enum port_fdmi_event event)
271{
272 struct bfa_fcs_port_s *port = fdmi->ms->port;
273
274 bfa_trc(port->fcs, port->port_cfg.pwwn);
275 bfa_trc(port->fcs, event);
276
277 switch (event) {
278 case FDMISM_EVENT_RPRT_SENT:
279 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_rprt);
280 break;
281
282 case FDMISM_EVENT_PORT_OFFLINE:
283 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
284 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port),
285 &fdmi->fcxp_wqe);
286 break;
287
288 default:
289 bfa_sm_fault(port->fcs, event);
290 }
291}
292
293static void
294bfa_fcs_port_fdmi_sm_rprt(struct bfa_fcs_port_fdmi_s *fdmi,
295 enum port_fdmi_event event)
296{
297 struct bfa_fcs_port_s *port = fdmi->ms->port;
298
299 bfa_trc(port->fcs, port->port_cfg.pwwn);
300 bfa_trc(port->fcs, event);
301
302 switch (event) {
303 case FDMISM_EVENT_RSP_ERROR:
304 /*
305 * if max retries have not been reached, start timer for a
306 * delayed retry
307 */
308 if (fdmi->retry_cnt++ < BFA_FCS_FDMI_CMD_MAX_RETRIES) {
309 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_rprt_retry);
310 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port),
311 &fdmi->timer, bfa_fcs_port_fdmi_timeout,
312 fdmi, BFA_FCS_RETRY_TIMEOUT);
313
314 } else {
315 /*
316 * set state to offline
317 */
318 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
319 fdmi->retry_cnt = 0;
320 }
321 break;
322
323 case FDMISM_EVENT_RSP_OK:
324 fdmi->retry_cnt = 0;
325 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_online);
326 break;
327
328 case FDMISM_EVENT_PORT_OFFLINE:
329 bfa_fcxp_discard(fdmi->fcxp);
330 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
331 break;
332
333 default:
334 bfa_sm_fault(port->fcs, event);
335 }
336}
337
338static void
339bfa_fcs_port_fdmi_sm_rprt_retry(struct bfa_fcs_port_fdmi_s *fdmi,
340 enum port_fdmi_event event)
341{
342 struct bfa_fcs_port_s *port = fdmi->ms->port;
343
344 bfa_trc(port->fcs, port->port_cfg.pwwn);
345 bfa_trc(port->fcs, event);
346
347 switch (event) {
348 case FDMISM_EVENT_TIMEOUT:
349 /*
350 * Retry Timer Expired. Re-send
351 */
352 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_sending_rprt);
353 bfa_fcs_port_fdmi_send_rprt(fdmi, NULL);
354 break;
355
356 case FDMISM_EVENT_PORT_OFFLINE:
357 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
358 bfa_timer_stop(&fdmi->timer);
359 break;
360
361 default:
362 bfa_sm_fault(port->fcs, event);
363 }
364}
365
366/*
367 * Register Port Attributes
368 */
369static void
370bfa_fcs_port_fdmi_sm_sending_rpa(struct bfa_fcs_port_fdmi_s *fdmi,
371 enum port_fdmi_event event)
372{
373 struct bfa_fcs_port_s *port = fdmi->ms->port;
374
375 bfa_trc(port->fcs, port->port_cfg.pwwn);
376 bfa_trc(port->fcs, event);
377
378 switch (event) {
379 case FDMISM_EVENT_RPA_SENT:
380 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_rpa);
381 break;
382
383 case FDMISM_EVENT_PORT_OFFLINE:
384 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
385 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(port),
386 &fdmi->fcxp_wqe);
387 break;
388
389 default:
390 bfa_sm_fault(port->fcs, event);
391 }
392}
393
394static void
395bfa_fcs_port_fdmi_sm_rpa(struct bfa_fcs_port_fdmi_s *fdmi,
396 enum port_fdmi_event event)
397{
398 struct bfa_fcs_port_s *port = fdmi->ms->port;
399
400 bfa_trc(port->fcs, port->port_cfg.pwwn);
401 bfa_trc(port->fcs, event);
402
403 switch (event) {
404 case FDMISM_EVENT_RSP_ERROR:
405 /*
406 * if max retries have not been reached, start timer for a
407 * delayed retry
408 */
409 if (fdmi->retry_cnt++ < BFA_FCS_FDMI_CMD_MAX_RETRIES) {
410 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_rpa_retry);
411 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(port),
412 &fdmi->timer, bfa_fcs_port_fdmi_timeout,
413 fdmi, BFA_FCS_RETRY_TIMEOUT);
414 } else {
415 /*
416 * set state to offline
417 */
418 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
419 fdmi->retry_cnt = 0;
420 }
421 break;
422
423 case FDMISM_EVENT_RSP_OK:
424 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_online);
425 fdmi->retry_cnt = 0;
426 break;
427
428 case FDMISM_EVENT_PORT_OFFLINE:
429 bfa_fcxp_discard(fdmi->fcxp);
430 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
431 break;
432
433 default:
434 bfa_sm_fault(port->fcs, event);
435 }
436}
437
438static void
439bfa_fcs_port_fdmi_sm_rpa_retry(struct bfa_fcs_port_fdmi_s *fdmi,
440 enum port_fdmi_event event)
441{
442 struct bfa_fcs_port_s *port = fdmi->ms->port;
443
444 bfa_trc(port->fcs, port->port_cfg.pwwn);
445 bfa_trc(port->fcs, event);
446
447 switch (event) {
448 case FDMISM_EVENT_TIMEOUT:
449 /*
450 * Retry Timer Expired. Re-send
451 */
452 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_sending_rpa);
453 bfa_fcs_port_fdmi_send_rpa(fdmi, NULL);
454 break;
455
456 case FDMISM_EVENT_PORT_OFFLINE:
457 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
458 bfa_timer_stop(&fdmi->timer);
459 break;
460
461 default:
462 bfa_sm_fault(port->fcs, event);
463 }
464}
465
466static void
467bfa_fcs_port_fdmi_sm_online(struct bfa_fcs_port_fdmi_s *fdmi,
468 enum port_fdmi_event event)
469{
470 struct bfa_fcs_port_s *port = fdmi->ms->port;
471
472 bfa_trc(port->fcs, port->port_cfg.pwwn);
473 bfa_trc(port->fcs, event);
474
475 switch (event) {
476 case FDMISM_EVENT_PORT_OFFLINE:
477 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
478 break;
479
480 default:
481 bfa_sm_fault(port->fcs, event);
482 }
483}
484
485/**
486 * FDMI is disabled state.
487 */
488static void
489bfa_fcs_port_fdmi_sm_disabled(struct bfa_fcs_port_fdmi_s *fdmi,
490 enum port_fdmi_event event)
491{
492 struct bfa_fcs_port_s *port = fdmi->ms->port;
493
494 bfa_trc(port->fcs, port->port_cfg.pwwn);
495 bfa_trc(port->fcs, event);
496
497 /* No op State. It can only be enabled at Driver Init. */
498}
499
500/**
501* RHBA : Register HBA Attributes.
502 */
503static void
504bfa_fcs_port_fdmi_send_rhba(void *fdmi_cbarg, struct bfa_fcxp_s *fcxp_alloced)
505{
506 struct bfa_fcs_port_fdmi_s *fdmi = fdmi_cbarg;
507 struct bfa_fcs_port_s *port = fdmi->ms->port;
508 struct fchs_s fchs;
509 int len, attr_len;
510 struct bfa_fcxp_s *fcxp;
511 u8 *pyld;
512
513 bfa_trc(port->fcs, port->port_cfg.pwwn);
514
515 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
516 if (!fcxp) {
517 bfa_fcxp_alloc_wait(port->fcs->bfa, &fdmi->fcxp_wqe,
518 bfa_fcs_port_fdmi_send_rhba, fdmi);
519 return;
520 }
521 fdmi->fcxp = fcxp;
522
523 pyld = bfa_fcxp_get_reqbuf(fcxp);
524 bfa_os_memset(pyld, 0, FC_MAX_PDUSZ);
525
526 len = fc_fdmi_reqhdr_build(&fchs, pyld, bfa_fcs_port_get_fcid(port),
527 FDMI_RHBA);
528
529 attr_len = bfa_fcs_port_fdmi_build_rhba_pyld(fdmi,
530 (u8 *) ((struct ct_hdr_s *) pyld + 1));
531
532 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
533 FC_CLASS_3, (len + attr_len), &fchs,
534 bfa_fcs_port_fdmi_rhba_response, (void *)fdmi,
535 FC_MAX_PDUSZ, FC_FCCT_TOV);
536
537 bfa_sm_send_event(fdmi, FDMISM_EVENT_RHBA_SENT);
538}
539
540static u16
541bfa_fcs_port_fdmi_build_rhba_pyld(struct bfa_fcs_port_fdmi_s *fdmi,
542 u8 *pyld)
543{
544 struct bfa_fcs_port_s *port = fdmi->ms->port;
545 struct bfa_fcs_fdmi_hba_attr_s hba_attr; /* @todo */
546 struct bfa_fcs_fdmi_hba_attr_s *fcs_hba_attr = &hba_attr; /* @todo */
547 struct fdmi_rhba_s *rhba = (struct fdmi_rhba_s *) pyld;
548 struct fdmi_attr_s *attr;
549 u8 *curr_ptr;
550 u16 len, count;
551
552 /*
553 * get hba attributes
554 */
555 bfa_fcs_fdmi_get_hbaattr(fdmi, fcs_hba_attr);
556
557 rhba->hba_id = bfa_fcs_port_get_pwwn(port);
558 rhba->port_list.num_ports = bfa_os_htonl(1);
559 rhba->port_list.port_entry = bfa_fcs_port_get_pwwn(port);
560
561 len = sizeof(rhba->hba_id) + sizeof(rhba->port_list);
562
563 count = 0;
564 len += sizeof(rhba->hba_attr_blk.attr_count);
565
566 /*
567 * fill out the invididual entries of the HBA attrib Block
568 */
569 curr_ptr = (u8 *) &rhba->hba_attr_blk.hba_attr;
570
571 /*
572 * Node Name
573 */
574 attr = (struct fdmi_attr_s *) curr_ptr;
575 attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_NODENAME);
576 attr->len = sizeof(wwn_t);
577 memcpy(attr->value, &bfa_fcs_port_get_nwwn(port), attr->len);
578 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
579 len += attr->len;
580 count++;
581 attr->len =
582 bfa_os_htons(attr->len + sizeof(attr->type) +
583 sizeof(attr->len));
584
585 /*
586 * Manufacturer
587 */
588 attr = (struct fdmi_attr_s *) curr_ptr;
589 attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_MANUFACTURER);
590 attr->len = (u16) strlen(fcs_hba_attr->manufacturer);
591 memcpy(attr->value, fcs_hba_attr->manufacturer, attr->len);
592 /* variable fields need to be 4 byte aligned */
593 attr->len = fc_roundup(attr->len, sizeof(u32));
594 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
595 len += attr->len;
596 count++;
597 attr->len =
598 bfa_os_htons(attr->len + sizeof(attr->type) +
599 sizeof(attr->len));
600
601 /*
602 * Serial Number
603 */
604 attr = (struct fdmi_attr_s *) curr_ptr;
605 attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_SERIALNUM);
606 attr->len = (u16) strlen(fcs_hba_attr->serial_num);
607 memcpy(attr->value, fcs_hba_attr->serial_num, attr->len);
608 /* variable fields need to be 4 byte aligned */
609 attr->len = fc_roundup(attr->len, sizeof(u32));
610 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
611 len += attr->len;
612 count++;
613 attr->len =
614 bfa_os_htons(attr->len + sizeof(attr->type) +
615 sizeof(attr->len));
616
617 /*
618 * Model
619 */
620 attr = (struct fdmi_attr_s *) curr_ptr;
621 attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_MODEL);
622 attr->len = (u16) strlen(fcs_hba_attr->model);
623 memcpy(attr->value, fcs_hba_attr->model, attr->len);
624 /* variable fields need to be 4 byte aligned */
625 attr->len = fc_roundup(attr->len, sizeof(u32));
626 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
627 len += attr->len;
628 count++;
629 attr->len =
630 bfa_os_htons(attr->len + sizeof(attr->type) +
631 sizeof(attr->len));
632
633 /*
634 * Model Desc
635 */
636 attr = (struct fdmi_attr_s *) curr_ptr;
637 attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_MODEL_DESC);
638 attr->len = (u16) strlen(fcs_hba_attr->model_desc);
639 memcpy(attr->value, fcs_hba_attr->model_desc, attr->len);
640 /* variable fields need to be 4 byte aligned */
641 attr->len = fc_roundup(attr->len, sizeof(u32));
642 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
643 len += attr->len;
644 count++;
645 attr->len =
646 bfa_os_htons(attr->len + sizeof(attr->type) +
647 sizeof(attr->len));
648
649 /*
650 * H/W Version
651 */
652 if (fcs_hba_attr->hw_version[0] != '\0') {
653 attr = (struct fdmi_attr_s *) curr_ptr;
654 attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_HW_VERSION);
655 attr->len = (u16) strlen(fcs_hba_attr->hw_version);
656 memcpy(attr->value, fcs_hba_attr->hw_version, attr->len);
657 /* variable fields need to be 4 byte aligned */
658 attr->len = fc_roundup(attr->len, sizeof(u32));
659 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
660 len += attr->len;
661 count++;
662 attr->len =
663 bfa_os_htons(attr->len + sizeof(attr->type) +
664 sizeof(attr->len));
665 }
666
667 /*
668 * Driver Version
669 */
670 attr = (struct fdmi_attr_s *) curr_ptr;
671 attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_DRIVER_VERSION);
672 attr->len = (u16) strlen(fcs_hba_attr->driver_version);
673 memcpy(attr->value, fcs_hba_attr->driver_version, attr->len);
674 /* variable fields need to be 4 byte aligned */
675 attr->len = fc_roundup(attr->len, sizeof(u32));
676 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
677 len += attr->len;;
678 count++;
679 attr->len =
680 bfa_os_htons(attr->len + sizeof(attr->type) +
681 sizeof(attr->len));
682
683 /*
684 * Option Rom Version
685 */
686 if (fcs_hba_attr->option_rom_ver[0] != '\0') {
687 attr = (struct fdmi_attr_s *) curr_ptr;
688 attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_ROM_VERSION);
689 attr->len = (u16) strlen(fcs_hba_attr->option_rom_ver);
690 memcpy(attr->value, fcs_hba_attr->option_rom_ver, attr->len);
691 /* variable fields need to be 4 byte aligned */
692 attr->len = fc_roundup(attr->len, sizeof(u32));
693 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
694 len += attr->len;
695 count++;
696 attr->len =
697 bfa_os_htons(attr->len + sizeof(attr->type) +
698 sizeof(attr->len));
699 }
700
701 /*
702 * f/w Version = driver version
703 */
704 attr = (struct fdmi_attr_s *) curr_ptr;
705 attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_FW_VERSION);
706 attr->len = (u16) strlen(fcs_hba_attr->driver_version);
707 memcpy(attr->value, fcs_hba_attr->driver_version, attr->len);
708 /* variable fields need to be 4 byte aligned */
709 attr->len = fc_roundup(attr->len, sizeof(u32));
710 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
711 len += attr->len;
712 count++;
713 attr->len =
714 bfa_os_htons(attr->len + sizeof(attr->type) +
715 sizeof(attr->len));
716
717 /*
718 * OS Name
719 */
720 if (fcs_hba_attr->os_name[0] != '\0') {
721 attr = (struct fdmi_attr_s *) curr_ptr;
722 attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_OS_NAME);
723 attr->len = (u16) strlen(fcs_hba_attr->os_name);
724 memcpy(attr->value, fcs_hba_attr->os_name, attr->len);
725 /* variable fields need to be 4 byte aligned */
726 attr->len = fc_roundup(attr->len, sizeof(u32));
727 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
728 len += attr->len;
729 count++;
730 attr->len =
731 bfa_os_htons(attr->len + sizeof(attr->type) +
732 sizeof(attr->len));
733 }
734
735 /*
736 * MAX_CT_PAYLOAD
737 */
738 attr = (struct fdmi_attr_s *) curr_ptr;
739 attr->type = bfa_os_htons(FDMI_HBA_ATTRIB_MAX_CT);
740 attr->len = sizeof(fcs_hba_attr->max_ct_pyld);
741 memcpy(attr->value, &fcs_hba_attr->max_ct_pyld, attr->len);
742 len += attr->len;
743 count++;
744 attr->len =
745 bfa_os_htons(attr->len + sizeof(attr->type) +
746 sizeof(attr->len));
747
748 /*
749 * Update size of payload
750 */
751 len += ((sizeof(attr->type) + sizeof(attr->len)) * count);
752
753 rhba->hba_attr_blk.attr_count = bfa_os_htonl(count);
754 return len;
755}
756
757static void
758bfa_fcs_port_fdmi_rhba_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
759 void *cbarg, bfa_status_t req_status,
760 u32 rsp_len, u32 resid_len,
761 struct fchs_s *rsp_fchs)
762{
763 struct bfa_fcs_port_fdmi_s *fdmi = (struct bfa_fcs_port_fdmi_s *)cbarg;
764 struct bfa_fcs_port_s *port = fdmi->ms->port;
765 struct ct_hdr_s *cthdr = NULL;
766
767 bfa_trc(port->fcs, port->port_cfg.pwwn);
768
769 /*
770 * Sanity Checks
771 */
772 if (req_status != BFA_STATUS_OK) {
773 bfa_trc(port->fcs, req_status);
774 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
775 return;
776 }
777
778 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
779 cthdr->cmd_rsp_code = bfa_os_ntohs(cthdr->cmd_rsp_code);
780
781 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
782 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_OK);
783 return;
784 }
785
786 bfa_trc(port->fcs, cthdr->reason_code);
787 bfa_trc(port->fcs, cthdr->exp_code);
788 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
789}
790
791/**
792* RPRT : Register Port
793 */
794static void
795bfa_fcs_port_fdmi_send_rprt(void *fdmi_cbarg, struct bfa_fcxp_s *fcxp_alloced)
796{
797 struct bfa_fcs_port_fdmi_s *fdmi = fdmi_cbarg;
798 struct bfa_fcs_port_s *port = fdmi->ms->port;
799 struct fchs_s fchs;
800 u16 len, attr_len;
801 struct bfa_fcxp_s *fcxp;
802 u8 *pyld;
803
804 bfa_trc(port->fcs, port->port_cfg.pwwn);
805
806 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
807 if (!fcxp) {
808 bfa_fcxp_alloc_wait(port->fcs->bfa, &fdmi->fcxp_wqe,
809 bfa_fcs_port_fdmi_send_rprt, fdmi);
810 return;
811 }
812 fdmi->fcxp = fcxp;
813
814 pyld = bfa_fcxp_get_reqbuf(fcxp);
815 bfa_os_memset(pyld, 0, FC_MAX_PDUSZ);
816
817 len = fc_fdmi_reqhdr_build(&fchs, pyld, bfa_fcs_port_get_fcid(port),
818 FDMI_RPRT);
819
820 attr_len = bfa_fcs_port_fdmi_build_rprt_pyld(fdmi,
821 (u8 *) ((struct ct_hdr_s *) pyld + 1));
822
823 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
824 FC_CLASS_3, len + attr_len, &fchs,
825 bfa_fcs_port_fdmi_rprt_response, (void *)fdmi,
826 FC_MAX_PDUSZ, FC_FCCT_TOV);
827
828 bfa_sm_send_event(fdmi, FDMISM_EVENT_RPRT_SENT);
829}
830
831/**
832 * This routine builds Port Attribute Block that used in RPA, RPRT commands.
833 */
834static u16
835bfa_fcs_port_fdmi_build_portattr_block(struct bfa_fcs_port_fdmi_s *fdmi,
836 u8 *pyld)
837{
838 struct bfa_fcs_fdmi_port_attr_s fcs_port_attr;
839 struct fdmi_port_attr_s *port_attrib = (struct fdmi_port_attr_s *) pyld;
840 struct fdmi_attr_s *attr;
841 u8 *curr_ptr;
842 u16 len;
843 u8 count = 0;
844
845 /*
846 * get port attributes
847 */
848 bfa_fcs_fdmi_get_portattr(fdmi, &fcs_port_attr);
849
850 len = sizeof(port_attrib->attr_count);
851
852 /*
853 * fill out the invididual entries
854 */
855 curr_ptr = (u8 *) &port_attrib->port_attr;
856
857 /*
858 * FC4 Types
859 */
860 attr = (struct fdmi_attr_s *) curr_ptr;
861 attr->type = bfa_os_htons(FDMI_PORT_ATTRIB_FC4_TYPES);
862 attr->len = sizeof(fcs_port_attr.supp_fc4_types);
863 memcpy(attr->value, fcs_port_attr.supp_fc4_types, attr->len);
864 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
865 len += attr->len;
866 ++count;
867 attr->len =
868 bfa_os_htons(attr->len + sizeof(attr->type) +
869 sizeof(attr->len));
870
871 /*
872 * Supported Speed
873 */
874 attr = (struct fdmi_attr_s *) curr_ptr;
875 attr->type = bfa_os_htons(FDMI_PORT_ATTRIB_SUPP_SPEED);
876 attr->len = sizeof(fcs_port_attr.supp_speed);
877 memcpy(attr->value, &fcs_port_attr.supp_speed, attr->len);
878 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
879 len += attr->len;
880 ++count;
881 attr->len =
882 bfa_os_htons(attr->len + sizeof(attr->type) +
883 sizeof(attr->len));
884
885 /*
886 * current Port Speed
887 */
888 attr = (struct fdmi_attr_s *) curr_ptr;
889 attr->type = bfa_os_htons(FDMI_PORT_ATTRIB_PORT_SPEED);
890 attr->len = sizeof(fcs_port_attr.curr_speed);
891 memcpy(attr->value, &fcs_port_attr.curr_speed, attr->len);
892 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
893 len += attr->len;
894 ++count;
895 attr->len =
896 bfa_os_htons(attr->len + sizeof(attr->type) +
897 sizeof(attr->len));
898
899 /*
900 * max frame size
901 */
902 attr = (struct fdmi_attr_s *) curr_ptr;
903 attr->type = bfa_os_htons(FDMI_PORT_ATTRIB_FRAME_SIZE);
904 attr->len = sizeof(fcs_port_attr.max_frm_size);
905 memcpy(attr->value, &fcs_port_attr.max_frm_size, attr->len);
906 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
907 len += attr->len;
908 ++count;
909 attr->len =
910 bfa_os_htons(attr->len + sizeof(attr->type) +
911 sizeof(attr->len));
912
913 /*
914 * OS Device Name
915 */
916 if (fcs_port_attr.os_device_name[0] != '\0') {
917 attr = (struct fdmi_attr_s *) curr_ptr;
918 attr->type = bfa_os_htons(FDMI_PORT_ATTRIB_DEV_NAME);
919 attr->len = (u16) strlen(fcs_port_attr.os_device_name);
920 memcpy(attr->value, fcs_port_attr.os_device_name, attr->len);
921 /* variable fields need to be 4 byte aligned */
922 attr->len = fc_roundup(attr->len, sizeof(u32));
923 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
924 len += attr->len;
925 ++count;
926 attr->len =
927 bfa_os_htons(attr->len + sizeof(attr->type) +
928 sizeof(attr->len));
929
930 }
931 /*
932 * Host Name
933 */
934 if (fcs_port_attr.host_name[0] != '\0') {
935 attr = (struct fdmi_attr_s *) curr_ptr;
936 attr->type = bfa_os_htons(FDMI_PORT_ATTRIB_HOST_NAME);
937 attr->len = (u16) strlen(fcs_port_attr.host_name);
938 memcpy(attr->value, fcs_port_attr.host_name, attr->len);
939 /* variable fields need to be 4 byte aligned */
940 attr->len = fc_roundup(attr->len, sizeof(u32));
941 curr_ptr += sizeof(attr->type) + sizeof(attr->len) + attr->len;
942 len += attr->len;
943 ++count;
944 attr->len =
945 bfa_os_htons(attr->len + sizeof(attr->type) +
946 sizeof(attr->len));
947
948 }
949
950 /*
951 * Update size of payload
952 */
953 port_attrib->attr_count = bfa_os_htonl(count);
954 len += ((sizeof(attr->type) + sizeof(attr->len)) * count);
955 return len;
956}
957
958static u16
959bfa_fcs_port_fdmi_build_rprt_pyld(struct bfa_fcs_port_fdmi_s *fdmi,
960 u8 *pyld)
961{
962 struct bfa_fcs_port_s *port = fdmi->ms->port;
963 struct fdmi_rprt_s *rprt = (struct fdmi_rprt_s *) pyld;
964 u16 len;
965
966 rprt->hba_id = bfa_fcs_port_get_pwwn(bfa_fcs_get_base_port(port->fcs));
967 rprt->port_name = bfa_fcs_port_get_pwwn(port);
968
969 len = bfa_fcs_port_fdmi_build_portattr_block(fdmi,
970 (u8 *) &rprt->port_attr_blk);
971
972 len += sizeof(rprt->hba_id) + sizeof(rprt->port_name);
973
974 return len;
975}
976
977static void
978bfa_fcs_port_fdmi_rprt_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
979 void *cbarg, bfa_status_t req_status,
980 u32 rsp_len, u32 resid_len,
981 struct fchs_s *rsp_fchs)
982{
983 struct bfa_fcs_port_fdmi_s *fdmi = (struct bfa_fcs_port_fdmi_s *)cbarg;
984 struct bfa_fcs_port_s *port = fdmi->ms->port;
985 struct ct_hdr_s *cthdr = NULL;
986
987 bfa_trc(port->fcs, port->port_cfg.pwwn);
988
989 /*
990 * Sanity Checks
991 */
992 if (req_status != BFA_STATUS_OK) {
993 bfa_trc(port->fcs, req_status);
994 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
995 return;
996 }
997
998 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
999 cthdr->cmd_rsp_code = bfa_os_ntohs(cthdr->cmd_rsp_code);
1000
1001 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
1002 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_OK);
1003 return;
1004 }
1005
1006 bfa_trc(port->fcs, cthdr->reason_code);
1007 bfa_trc(port->fcs, cthdr->exp_code);
1008 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
1009}
1010
1011/**
1012* RPA : Register Port Attributes.
1013 */
1014static void
1015bfa_fcs_port_fdmi_send_rpa(void *fdmi_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1016{
1017 struct bfa_fcs_port_fdmi_s *fdmi = fdmi_cbarg;
1018 struct bfa_fcs_port_s *port = fdmi->ms->port;
1019 struct fchs_s fchs;
1020 u16 len, attr_len;
1021 struct bfa_fcxp_s *fcxp;
1022 u8 *pyld;
1023
1024 bfa_trc(port->fcs, port->port_cfg.pwwn);
1025
1026 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
1027 if (!fcxp) {
1028 bfa_fcxp_alloc_wait(port->fcs->bfa, &fdmi->fcxp_wqe,
1029 bfa_fcs_port_fdmi_send_rpa, fdmi);
1030 return;
1031 }
1032 fdmi->fcxp = fcxp;
1033
1034 pyld = bfa_fcxp_get_reqbuf(fcxp);
1035 bfa_os_memset(pyld, 0, FC_MAX_PDUSZ);
1036
1037 len = fc_fdmi_reqhdr_build(&fchs, pyld, bfa_fcs_port_get_fcid(port),
1038 FDMI_RPA);
1039
1040 attr_len = bfa_fcs_port_fdmi_build_rpa_pyld(fdmi,
1041 (u8 *) ((struct ct_hdr_s *) pyld + 1));
1042
1043 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1044 FC_CLASS_3, len + attr_len, &fchs,
1045 bfa_fcs_port_fdmi_rpa_response, (void *)fdmi,
1046 FC_MAX_PDUSZ, FC_FCCT_TOV);
1047
1048 bfa_sm_send_event(fdmi, FDMISM_EVENT_RPA_SENT);
1049}
1050
1051static u16
1052bfa_fcs_port_fdmi_build_rpa_pyld(struct bfa_fcs_port_fdmi_s *fdmi,
1053 u8 *pyld)
1054{
1055 struct bfa_fcs_port_s *port = fdmi->ms->port;
1056 struct fdmi_rpa_s *rpa = (struct fdmi_rpa_s *) pyld;
1057 u16 len;
1058
1059 rpa->port_name = bfa_fcs_port_get_pwwn(port);
1060
1061 len = bfa_fcs_port_fdmi_build_portattr_block(fdmi,
1062 (u8 *) &rpa->port_attr_blk);
1063
1064 len += sizeof(rpa->port_name);
1065
1066 return len;
1067}
1068
1069static void
1070bfa_fcs_port_fdmi_rpa_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
1071 void *cbarg, bfa_status_t req_status,
1072 u32 rsp_len, u32 resid_len,
1073 struct fchs_s *rsp_fchs)
1074{
1075 struct bfa_fcs_port_fdmi_s *fdmi = (struct bfa_fcs_port_fdmi_s *)cbarg;
1076 struct bfa_fcs_port_s *port = fdmi->ms->port;
1077 struct ct_hdr_s *cthdr = NULL;
1078
1079 bfa_trc(port->fcs, port->port_cfg.pwwn);
1080
1081 /*
1082 * Sanity Checks
1083 */
1084 if (req_status != BFA_STATUS_OK) {
1085 bfa_trc(port->fcs, req_status);
1086 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
1087 return;
1088 }
1089
1090 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
1091 cthdr->cmd_rsp_code = bfa_os_ntohs(cthdr->cmd_rsp_code);
1092
1093 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
1094 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_OK);
1095 return;
1096 }
1097
1098 bfa_trc(port->fcs, cthdr->reason_code);
1099 bfa_trc(port->fcs, cthdr->exp_code);
1100 bfa_sm_send_event(fdmi, FDMISM_EVENT_RSP_ERROR);
1101}
1102
1103static void
1104bfa_fcs_port_fdmi_timeout(void *arg)
1105{
1106 struct bfa_fcs_port_fdmi_s *fdmi = (struct bfa_fcs_port_fdmi_s *)arg;
1107
1108 bfa_sm_send_event(fdmi, FDMISM_EVENT_TIMEOUT);
1109}
1110
1111static void
1112bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_port_fdmi_s *fdmi,
1113 struct bfa_fcs_fdmi_hba_attr_s *hba_attr)
1114{
1115 struct bfa_fcs_port_s *port = fdmi->ms->port;
1116 struct bfa_fcs_driver_info_s *driver_info = &port->fcs->driver_info;
1117
1118 bfa_os_memset(hba_attr, 0, sizeof(struct bfa_fcs_fdmi_hba_attr_s));
1119
1120 bfa_ioc_get_adapter_manufacturer(&port->fcs->bfa->ioc,
1121 hba_attr->manufacturer);
1122 bfa_ioc_get_adapter_serial_num(&port->fcs->bfa->ioc,
1123 hba_attr->serial_num);
1124 bfa_ioc_get_adapter_model(&port->fcs->bfa->ioc, hba_attr->model);
1125 bfa_ioc_get_adapter_model(&port->fcs->bfa->ioc, hba_attr->model_desc);
1126 bfa_ioc_get_pci_chip_rev(&port->fcs->bfa->ioc, hba_attr->hw_version);
1127 bfa_ioc_get_adapter_optrom_ver(&port->fcs->bfa->ioc,
1128 hba_attr->option_rom_ver);
1129 bfa_ioc_get_adapter_fw_ver(&port->fcs->bfa->ioc, hba_attr->fw_version);
1130
1131 strncpy(hba_attr->driver_version, (char *)driver_info->version,
1132 sizeof(hba_attr->driver_version));
1133
1134 strncpy(hba_attr->os_name, driver_info->host_os_name,
1135 sizeof(hba_attr->os_name));
1136
1137 /*
1138 * If there is a patch level, append it to the os name along with a
1139 * separator
1140 */
1141 if (driver_info->host_os_patch[0] != '\0') {
1142 strncat(hba_attr->os_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
1143 sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
1144 strncat(hba_attr->os_name, driver_info->host_os_patch,
1145 sizeof(driver_info->host_os_patch));
1146 }
1147
1148 hba_attr->max_ct_pyld = bfa_os_htonl(FC_MAX_PDUSZ);
1149
1150}
1151
1152static void
1153bfa_fcs_fdmi_get_portattr(struct bfa_fcs_port_fdmi_s *fdmi,
1154 struct bfa_fcs_fdmi_port_attr_s *port_attr)
1155{
1156 struct bfa_fcs_port_s *port = fdmi->ms->port;
1157 struct bfa_fcs_driver_info_s *driver_info = &port->fcs->driver_info;
1158 struct bfa_pport_attr_s pport_attr;
1159
1160 bfa_os_memset(port_attr, 0, sizeof(struct bfa_fcs_fdmi_port_attr_s));
1161
1162 /*
1163 * get pport attributes from hal
1164 */
1165 bfa_fcport_get_attr(port->fcs->bfa, &pport_attr);
1166
1167 /*
1168 * get FC4 type Bitmask
1169 */
1170 fc_get_fc4type_bitmask(FC_TYPE_FCP, port_attr->supp_fc4_types);
1171
1172 /*
1173 * Supported Speeds
1174 */
1175 port_attr->supp_speed = bfa_os_htonl(BFA_FCS_FDMI_SUPORTED_SPEEDS);
1176
1177 /*
1178 * Current Speed
1179 */
1180 port_attr->curr_speed = bfa_os_htonl(pport_attr.speed);
1181
1182 /*
1183 * Max PDU Size.
1184 */
1185 port_attr->max_frm_size = bfa_os_htonl(FC_MAX_PDUSZ);
1186
1187 /*
1188 * OS device Name
1189 */
1190 strncpy(port_attr->os_device_name, (char *)driver_info->os_device_name,
1191 sizeof(port_attr->os_device_name));
1192
1193 /*
1194 * Host name
1195 */
1196 strncpy(port_attr->host_name, (char *)driver_info->host_machine_name,
1197 sizeof(port_attr->host_name));
1198
1199}
1200
1201
1202void
1203bfa_fcs_port_fdmi_init(struct bfa_fcs_port_ms_s *ms)
1204{
1205 struct bfa_fcs_port_fdmi_s *fdmi = &ms->fdmi;
1206
1207 fdmi->ms = ms;
1208 if (ms->port->fcs->fdmi_enabled)
1209 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_offline);
1210 else
1211 bfa_sm_set_state(fdmi, bfa_fcs_port_fdmi_sm_disabled);
1212}
1213
1214void
1215bfa_fcs_port_fdmi_offline(struct bfa_fcs_port_ms_s *ms)
1216{
1217 struct bfa_fcs_port_fdmi_s *fdmi = &ms->fdmi;
1218
1219 fdmi->ms = ms;
1220 bfa_sm_send_event(fdmi, FDMISM_EVENT_PORT_OFFLINE);
1221}
1222
1223void
1224bfa_fcs_port_fdmi_online(struct bfa_fcs_port_ms_s *ms)
1225{
1226 struct bfa_fcs_port_fdmi_s *fdmi = &ms->fdmi;
1227
1228 fdmi->ms = ms;
1229 bfa_sm_send_event(fdmi, FDMISM_EVENT_PORT_ONLINE);
1230}
diff --git a/drivers/scsi/bfa/include/aen/bfa_aen.h b/drivers/scsi/bfa/include/aen/bfa_aen.h
deleted file mode 100644
index 6abbab005db6..000000000000
--- a/drivers/scsi/bfa/include/aen/bfa_aen.h
+++ /dev/null
@@ -1,96 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_AEN_H__
18#define __BFA_AEN_H__
19
20#include "defs/bfa_defs_aen.h"
21#include "defs/bfa_defs_status.h"
22#include "cs/bfa_debug.h"
23
24#define BFA_AEN_MAX_ENTRY 512
25
26extern int bfa_aen_max_cfg_entry;
27struct bfa_aen_s {
28 void *bfad;
29 int max_entry;
30 int write_index;
31 int read_index;
32 int bfad_num;
33 int seq_num;
34 void (*aen_cb_notify)(void *bfad);
35 void (*gettimeofday)(struct bfa_timeval_s *tv);
36 struct bfa_trc_mod_s *trcmod;
37 int app_ri[BFA_AEN_MAX_APP]; /* For multiclient support */
38 struct bfa_aen_entry_s list[BFA_AEN_MAX_ENTRY]; /* Must be the last */
39};
40
41
42/**
43 * Public APIs
44 */
45static inline void
46bfa_aen_set_max_cfg_entry(int max_entry)
47{
48 bfa_aen_max_cfg_entry = max_entry;
49}
50
51static inline int
52bfa_aen_get_max_cfg_entry(void)
53{
54 return bfa_aen_max_cfg_entry;
55}
56
57static inline int
58bfa_aen_get_meminfo(void)
59{
60 return sizeof(struct bfa_aen_entry_s) * bfa_aen_get_max_cfg_entry();
61}
62
63static inline int
64bfa_aen_get_wi(struct bfa_aen_s *aen)
65{
66 return aen->write_index;
67}
68
69static inline int
70bfa_aen_get_ri(struct bfa_aen_s *aen)
71{
72 return aen->read_index;
73}
74
75static inline int
76bfa_aen_fetch_count(struct bfa_aen_s *aen, enum bfa_aen_app app_id)
77{
78 bfa_assert((app_id < BFA_AEN_MAX_APP) && (app_id >= bfa_aen_app_bcu));
79 return ((aen->write_index + aen->max_entry) - aen->app_ri[app_id])
80 % aen->max_entry;
81}
82
83int bfa_aen_init(struct bfa_aen_s *aen, struct bfa_trc_mod_s *trcmod,
84 void *bfad, int bfad_num, void (*aen_cb_notify)(void *),
85 void (*gettimeofday)(struct bfa_timeval_s *));
86
87void bfa_aen_post(struct bfa_aen_s *aen, enum bfa_aen_category aen_category,
88 int aen_type, union bfa_aen_data_u *aen_data);
89
90bfa_status_t bfa_aen_fetch(struct bfa_aen_s *aen,
91 struct bfa_aen_entry_s *aen_entry,
92 int entry_req, enum bfa_aen_app app_id, int *entry_ret);
93
94int bfa_aen_get_inst(struct bfa_aen_s *aen);
95
96#endif /* __BFA_AEN_H__ */
diff --git a/drivers/scsi/bfa/include/aen/bfa_aen_adapter.h b/drivers/scsi/bfa/include/aen/bfa_aen_adapter.h
deleted file mode 100644
index 260d3ea1cab3..000000000000
--- a/drivers/scsi/bfa/include/aen/bfa_aen_adapter.h
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/* messages define for BFA_AEN_CAT_ADAPTER Module */
19#ifndef __bfa_aen_adapter_h__
20#define __bfa_aen_adapter_h__
21
22#include <cs/bfa_log.h>
23#include <defs/bfa_defs_aen.h>
24
25#define BFA_AEN_ADAPTER_ADD \
26 BFA_LOG_CREATE_ID(BFA_AEN_CAT_ADAPTER, BFA_ADAPTER_AEN_ADD)
27#define BFA_AEN_ADAPTER_REMOVE \
28 BFA_LOG_CREATE_ID(BFA_AEN_CAT_ADAPTER, BFA_ADAPTER_AEN_REMOVE)
29
30#endif
31
diff --git a/drivers/scsi/bfa/include/aen/bfa_aen_audit.h b/drivers/scsi/bfa/include/aen/bfa_aen_audit.h
deleted file mode 100644
index 12cd7aab5d53..000000000000
--- a/drivers/scsi/bfa/include/aen/bfa_aen_audit.h
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/* messages define for BFA_AEN_CAT_AUDIT Module */
19#ifndef __bfa_aen_audit_h__
20#define __bfa_aen_audit_h__
21
22#include <cs/bfa_log.h>
23#include <defs/bfa_defs_aen.h>
24
25#define BFA_AEN_AUDIT_AUTH_ENABLE \
26 BFA_LOG_CREATE_ID(BFA_AEN_CAT_AUDIT, BFA_AUDIT_AEN_AUTH_ENABLE)
27#define BFA_AEN_AUDIT_AUTH_DISABLE \
28 BFA_LOG_CREATE_ID(BFA_AEN_CAT_AUDIT, BFA_AUDIT_AEN_AUTH_DISABLE)
29
30#endif
31
diff --git a/drivers/scsi/bfa/include/aen/bfa_aen_ethport.h b/drivers/scsi/bfa/include/aen/bfa_aen_ethport.h
deleted file mode 100644
index 507d0b58d149..000000000000
--- a/drivers/scsi/bfa/include/aen/bfa_aen_ethport.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/* messages define for BFA_AEN_CAT_ETHPORT Module */
19#ifndef __bfa_aen_ethport_h__
20#define __bfa_aen_ethport_h__
21
22#include <cs/bfa_log.h>
23#include <defs/bfa_defs_aen.h>
24
25#define BFA_AEN_ETHPORT_LINKUP \
26 BFA_LOG_CREATE_ID(BFA_AEN_CAT_ETHPORT, BFA_ETHPORT_AEN_LINKUP)
27#define BFA_AEN_ETHPORT_LINKDOWN \
28 BFA_LOG_CREATE_ID(BFA_AEN_CAT_ETHPORT, BFA_ETHPORT_AEN_LINKDOWN)
29#define BFA_AEN_ETHPORT_ENABLE \
30 BFA_LOG_CREATE_ID(BFA_AEN_CAT_ETHPORT, BFA_ETHPORT_AEN_ENABLE)
31#define BFA_AEN_ETHPORT_DISABLE \
32 BFA_LOG_CREATE_ID(BFA_AEN_CAT_ETHPORT, BFA_ETHPORT_AEN_DISABLE)
33
34#endif
35
diff --git a/drivers/scsi/bfa/include/aen/bfa_aen_ioc.h b/drivers/scsi/bfa/include/aen/bfa_aen_ioc.h
deleted file mode 100644
index 4daf96faa266..000000000000
--- a/drivers/scsi/bfa/include/aen/bfa_aen_ioc.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/* messages define for BFA_AEN_CAT_IOC Module */
19#ifndef __bfa_aen_ioc_h__
20#define __bfa_aen_ioc_h__
21
22#include <cs/bfa_log.h>
23#include <defs/bfa_defs_aen.h>
24
25#define BFA_AEN_IOC_HBGOOD \
26 BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, BFA_IOC_AEN_HBGOOD)
27#define BFA_AEN_IOC_HBFAIL \
28 BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, BFA_IOC_AEN_HBFAIL)
29#define BFA_AEN_IOC_ENABLE \
30 BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, BFA_IOC_AEN_ENABLE)
31#define BFA_AEN_IOC_DISABLE \
32 BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, BFA_IOC_AEN_DISABLE)
33#define BFA_AEN_IOC_FWMISMATCH \
34 BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, BFA_IOC_AEN_FWMISMATCH)
35#define BFA_AEN_IOC_FWCFG_ERROR \
36 BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, BFA_IOC_AEN_FWCFG_ERROR)
37#define BFA_AEN_IOC_INVALID_VENDOR \
38 BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, BFA_IOC_AEN_INVALID_VENDOR)
39#define BFA_AEN_IOC_INVALID_NWWN \
40 BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, BFA_IOC_AEN_INVALID_NWWN)
41#define BFA_AEN_IOC_INVALID_PWWN \
42 BFA_LOG_CREATE_ID(BFA_AEN_CAT_IOC, BFA_IOC_AEN_INVALID_PWWN)
43
44#endif
45
diff --git a/drivers/scsi/bfa/include/aen/bfa_aen_itnim.h b/drivers/scsi/bfa/include/aen/bfa_aen_itnim.h
deleted file mode 100644
index a7d8ddcfef99..000000000000
--- a/drivers/scsi/bfa/include/aen/bfa_aen_itnim.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/* messages define for BFA_AEN_CAT_ITNIM Module */
19#ifndef __bfa_aen_itnim_h__
20#define __bfa_aen_itnim_h__
21
22#include <cs/bfa_log.h>
23#include <defs/bfa_defs_aen.h>
24
25#define BFA_AEN_ITNIM_ONLINE \
26 BFA_LOG_CREATE_ID(BFA_AEN_CAT_ITNIM, BFA_ITNIM_AEN_ONLINE)
27#define BFA_AEN_ITNIM_OFFLINE \
28 BFA_LOG_CREATE_ID(BFA_AEN_CAT_ITNIM, BFA_ITNIM_AEN_OFFLINE)
29#define BFA_AEN_ITNIM_DISCONNECT \
30 BFA_LOG_CREATE_ID(BFA_AEN_CAT_ITNIM, BFA_ITNIM_AEN_DISCONNECT)
31
32#endif
33
diff --git a/drivers/scsi/bfa/include/aen/bfa_aen_lport.h b/drivers/scsi/bfa/include/aen/bfa_aen_lport.h
deleted file mode 100644
index 5a8ebb65193f..000000000000
--- a/drivers/scsi/bfa/include/aen/bfa_aen_lport.h
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/* messages define for BFA_AEN_CAT_LPORT Module */
19#ifndef __bfa_aen_lport_h__
20#define __bfa_aen_lport_h__
21
22#include <cs/bfa_log.h>
23#include <defs/bfa_defs_aen.h>
24
25#define BFA_AEN_LPORT_NEW \
26 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_NEW)
27#define BFA_AEN_LPORT_DELETE \
28 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_DELETE)
29#define BFA_AEN_LPORT_ONLINE \
30 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_ONLINE)
31#define BFA_AEN_LPORT_OFFLINE \
32 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_OFFLINE)
33#define BFA_AEN_LPORT_DISCONNECT \
34 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_DISCONNECT)
35#define BFA_AEN_LPORT_NEW_PROP \
36 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_NEW_PROP)
37#define BFA_AEN_LPORT_DELETE_PROP \
38 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_DELETE_PROP)
39#define BFA_AEN_LPORT_NEW_STANDARD \
40 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_NEW_STANDARD)
41#define BFA_AEN_LPORT_DELETE_STANDARD \
42 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_DELETE_STANDARD)
43#define BFA_AEN_LPORT_NPIV_DUP_WWN \
44 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_NPIV_DUP_WWN)
45#define BFA_AEN_LPORT_NPIV_FABRIC_MAX \
46 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_NPIV_FABRIC_MAX)
47#define BFA_AEN_LPORT_NPIV_UNKNOWN \
48 BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, BFA_LPORT_AEN_NPIV_UNKNOWN)
49
50#endif
51
diff --git a/drivers/scsi/bfa/include/aen/bfa_aen_port.h b/drivers/scsi/bfa/include/aen/bfa_aen_port.h
deleted file mode 100644
index 9add905a622d..000000000000
--- a/drivers/scsi/bfa/include/aen/bfa_aen_port.h
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/* messages define for BFA_AEN_CAT_PORT Module */
19#ifndef __bfa_aen_port_h__
20#define __bfa_aen_port_h__
21
22#include <cs/bfa_log.h>
23#include <defs/bfa_defs_aen.h>
24
25#define BFA_AEN_PORT_ONLINE \
26 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_ONLINE)
27#define BFA_AEN_PORT_OFFLINE \
28 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_OFFLINE)
29#define BFA_AEN_PORT_RLIR \
30 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_RLIR)
31#define BFA_AEN_PORT_SFP_INSERT \
32 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_SFP_INSERT)
33#define BFA_AEN_PORT_SFP_REMOVE \
34 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_SFP_REMOVE)
35#define BFA_AEN_PORT_SFP_POM \
36 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_SFP_POM)
37#define BFA_AEN_PORT_ENABLE \
38 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_ENABLE)
39#define BFA_AEN_PORT_DISABLE \
40 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_DISABLE)
41#define BFA_AEN_PORT_AUTH_ON \
42 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_AUTH_ON)
43#define BFA_AEN_PORT_AUTH_OFF \
44 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_AUTH_OFF)
45#define BFA_AEN_PORT_DISCONNECT \
46 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_DISCONNECT)
47#define BFA_AEN_PORT_QOS_NEG \
48 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_QOS_NEG)
49#define BFA_AEN_PORT_FABRIC_NAME_CHANGE \
50 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_FABRIC_NAME_CHANGE)
51#define BFA_AEN_PORT_SFP_ACCESS_ERROR \
52 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_SFP_ACCESS_ERROR)
53#define BFA_AEN_PORT_SFP_UNSUPPORT \
54 BFA_LOG_CREATE_ID(BFA_AEN_CAT_PORT, BFA_PORT_AEN_SFP_UNSUPPORT)
55
56#endif
57
diff --git a/drivers/scsi/bfa/include/aen/bfa_aen_rport.h b/drivers/scsi/bfa/include/aen/bfa_aen_rport.h
deleted file mode 100644
index 7e4be1fd5e15..000000000000
--- a/drivers/scsi/bfa/include/aen/bfa_aen_rport.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/* messages define for BFA_AEN_CAT_RPORT Module */
19#ifndef __bfa_aen_rport_h__
20#define __bfa_aen_rport_h__
21
22#include <cs/bfa_log.h>
23#include <defs/bfa_defs_aen.h>
24
25#define BFA_AEN_RPORT_ONLINE \
26 BFA_LOG_CREATE_ID(BFA_AEN_CAT_RPORT, BFA_RPORT_AEN_ONLINE)
27#define BFA_AEN_RPORT_OFFLINE \
28 BFA_LOG_CREATE_ID(BFA_AEN_CAT_RPORT, BFA_RPORT_AEN_OFFLINE)
29#define BFA_AEN_RPORT_DISCONNECT \
30 BFA_LOG_CREATE_ID(BFA_AEN_CAT_RPORT, BFA_RPORT_AEN_DISCONNECT)
31#define BFA_AEN_RPORT_QOS_PRIO \
32 BFA_LOG_CREATE_ID(BFA_AEN_CAT_RPORT, BFA_RPORT_AEN_QOS_PRIO)
33#define BFA_AEN_RPORT_QOS_FLOWID \
34 BFA_LOG_CREATE_ID(BFA_AEN_CAT_RPORT, BFA_RPORT_AEN_QOS_FLOWID)
35
36#endif
37
diff --git a/drivers/scsi/bfa/include/bfa.h b/drivers/scsi/bfa/include/bfa.h
deleted file mode 100644
index d52b32f5695c..000000000000
--- a/drivers/scsi/bfa/include/bfa.h
+++ /dev/null
@@ -1,203 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_H__
18#define __BFA_H__
19
20#include <bfa_os_inc.h>
21#include <cs/bfa_debug.h>
22#include <cs/bfa_q.h>
23#include <cs/bfa_trc.h>
24#include <cs/bfa_log.h>
25#include <cs/bfa_plog.h>
26#include <defs/bfa_defs_status.h>
27#include <defs/bfa_defs_ioc.h>
28#include <defs/bfa_defs_iocfc.h>
29#include <aen/bfa_aen.h>
30#include <bfi/bfi.h>
31
32struct bfa_s;
33#include <bfa_intr_priv.h>
34
35struct bfa_pcidev_s;
36
37/**
38 * PCI devices supported by the current BFA
39 */
40struct bfa_pciid_s {
41 u16 device_id;
42 u16 vendor_id;
43};
44
45extern char bfa_version[];
46
47/**
48 * BFA Power Mgmt Commands
49 */
50enum bfa_pm_cmd {
51 BFA_PM_CTL_D0 = 0,
52 BFA_PM_CTL_D1 = 1,
53 BFA_PM_CTL_D2 = 2,
54 BFA_PM_CTL_D3 = 3,
55};
56
57/**
58 * BFA memory resources
59 */
60enum bfa_mem_type {
61 BFA_MEM_TYPE_KVA = 1, /*! Kernel Virtual Memory *(non-dma-able) */
62 BFA_MEM_TYPE_DMA = 2, /*! DMA-able memory */
63 BFA_MEM_TYPE_MAX = BFA_MEM_TYPE_DMA,
64};
65
66struct bfa_mem_elem_s {
67 enum bfa_mem_type mem_type; /* see enum bfa_mem_type */
68 u32 mem_len; /* Total Length in Bytes */
69 u8 *kva; /* kernel virtual address */
70 u64 dma; /* dma address if DMA memory */
71 u8 *kva_curp; /* kva allocation cursor */
72 u64 dma_curp; /* dma allocation cursor */
73};
74
75struct bfa_meminfo_s {
76 struct bfa_mem_elem_s meminfo[BFA_MEM_TYPE_MAX];
77};
78#define bfa_meminfo_kva(_m) \
79 ((_m)->meminfo[BFA_MEM_TYPE_KVA - 1].kva_curp)
80#define bfa_meminfo_dma_virt(_m) \
81 ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].kva_curp)
82#define bfa_meminfo_dma_phys(_m) \
83 ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].dma_curp)
84
85/**
86 * Generic Scatter Gather Element used by driver
87 */
88struct bfa_sge_s {
89 u32 sg_len;
90 void *sg_addr;
91};
92
93#define bfa_sge_to_be(__sge) do { \
94 ((u32 *)(__sge))[0] = bfa_os_htonl(((u32 *)(__sge))[0]); \
95 ((u32 *)(__sge))[1] = bfa_os_htonl(((u32 *)(__sge))[1]); \
96 ((u32 *)(__sge))[2] = bfa_os_htonl(((u32 *)(__sge))[2]); \
97} while (0)
98
99
100/*
101 * bfa stats interfaces
102 */
103#define bfa_stats(_mod, _stats) ((_mod)->stats._stats++)
104
105#define bfa_ioc_get_stats(__bfa, __ioc_stats) \
106 bfa_ioc_fetch_stats(&(__bfa)->ioc, __ioc_stats)
107#define bfa_ioc_clear_stats(__bfa) \
108 bfa_ioc_clr_stats(&(__bfa)->ioc)
109#define bfa_get_nports(__bfa) \
110 bfa_ioc_get_nports(&(__bfa)->ioc)
111#define bfa_get_adapter_manufacturer(__bfa, __manufacturer) \
112 bfa_ioc_get_adapter_manufacturer(&(__bfa)->ioc, __manufacturer)
113#define bfa_get_adapter_model(__bfa, __model) \
114 bfa_ioc_get_adapter_model(&(__bfa)->ioc, __model)
115#define bfa_get_adapter_serial_num(__bfa, __serial_num) \
116 bfa_ioc_get_adapter_serial_num(&(__bfa)->ioc, __serial_num)
117#define bfa_get_adapter_fw_ver(__bfa, __fw_ver) \
118 bfa_ioc_get_adapter_fw_ver(&(__bfa)->ioc, __fw_ver)
119#define bfa_get_adapter_optrom_ver(__bfa, __optrom_ver) \
120 bfa_ioc_get_adapter_optrom_ver(&(__bfa)->ioc, __optrom_ver)
121#define bfa_get_pci_chip_rev(__bfa, __chip_rev) \
122 bfa_ioc_get_pci_chip_rev(&(__bfa)->ioc, __chip_rev)
123#define bfa_get_ioc_state(__bfa) \
124 bfa_ioc_get_state(&(__bfa)->ioc)
125#define bfa_get_type(__bfa) \
126 bfa_ioc_get_type(&(__bfa)->ioc)
127#define bfa_get_mac(__bfa) \
128 bfa_ioc_get_mac(&(__bfa)->ioc)
129#define bfa_get_mfg_mac(__bfa) \
130 bfa_ioc_get_mfg_mac(&(__bfa)->ioc)
131#define bfa_get_fw_clock_res(__bfa) \
132 ((__bfa)->iocfc.cfgrsp->fwcfg.fw_tick_res)
133
134/*
135 * bfa API functions
136 */
137void bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids);
138void bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg);
139void bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg);
140void bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg,
141 struct bfa_meminfo_s *meminfo);
142void bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
143 struct bfa_meminfo_s *meminfo,
144 struct bfa_pcidev_s *pcidev);
145void bfa_init_trc(struct bfa_s *bfa, struct bfa_trc_mod_s *trcmod);
146void bfa_init_log(struct bfa_s *bfa, struct bfa_log_mod_s *logmod);
147void bfa_init_aen(struct bfa_s *bfa, struct bfa_aen_s *aen);
148void bfa_init_plog(struct bfa_s *bfa, struct bfa_plog_s *plog);
149void bfa_detach(struct bfa_s *bfa);
150void bfa_init(struct bfa_s *bfa);
151void bfa_start(struct bfa_s *bfa);
152void bfa_stop(struct bfa_s *bfa);
153void bfa_attach_fcs(struct bfa_s *bfa);
154void bfa_cb_init(void *bfad, bfa_status_t status);
155void bfa_cb_stop(void *bfad, bfa_status_t status);
156void bfa_cb_updateq(void *bfad, bfa_status_t status);
157
158bfa_boolean_t bfa_intx(struct bfa_s *bfa);
159void bfa_isr_enable(struct bfa_s *bfa);
160void bfa_isr_disable(struct bfa_s *bfa);
161void bfa_msix_getvecs(struct bfa_s *bfa, u32 *msix_vecs_bmap,
162 u32 *num_vecs, u32 *max_vec_bit);
163#define bfa_msix(__bfa, __vec) ((__bfa)->msix.handler[__vec](__bfa, __vec))
164
165void bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q);
166void bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q);
167void bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q);
168
169typedef void (*bfa_cb_ioc_t) (void *cbarg, enum bfa_status status);
170void bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr);
171bfa_status_t bfa_iocfc_get_stats(struct bfa_s *bfa,
172 struct bfa_iocfc_stats_s *stats,
173 bfa_cb_ioc_t cbfn, void *cbarg);
174bfa_status_t bfa_iocfc_clear_stats(struct bfa_s *bfa,
175 bfa_cb_ioc_t cbfn, void *cbarg);
176void bfa_get_attr(struct bfa_s *bfa, struct bfa_ioc_attr_s *ioc_attr);
177
178void bfa_adapter_get_attr(struct bfa_s *bfa,
179 struct bfa_adapter_attr_s *ad_attr);
180u64 bfa_adapter_get_id(struct bfa_s *bfa);
181
182bfa_status_t bfa_iocfc_israttr_set(struct bfa_s *bfa,
183 struct bfa_iocfc_intr_attr_s *attr);
184
185void bfa_iocfc_enable(struct bfa_s *bfa);
186void bfa_iocfc_disable(struct bfa_s *bfa);
187void bfa_ioc_auto_recover(bfa_boolean_t auto_recover);
188void bfa_chip_reset(struct bfa_s *bfa);
189void bfa_cb_ioc_disable(void *bfad);
190void bfa_timer_tick(struct bfa_s *bfa);
191#define bfa_timer_start(_bfa, _timer, _timercb, _arg, _timeout) \
192 bfa_timer_begin(&(_bfa)->timer_mod, _timer, _timercb, _arg, _timeout)
193
194/*
195 * BFA debug API functions
196 */
197bfa_status_t bfa_debug_fwtrc(struct bfa_s *bfa, void *trcdata, int *trclen);
198bfa_status_t bfa_debug_fwsave(struct bfa_s *bfa, void *trcdata, int *trclen);
199void bfa_debug_fwsave_clear(struct bfa_s *bfa);
200
201#include "bfa_priv.h"
202
203#endif /* __BFA_H__ */
diff --git a/drivers/scsi/bfa/include/bfa_fcpim.h b/drivers/scsi/bfa/include/bfa_fcpim.h
deleted file mode 100644
index 4bc9453081df..000000000000
--- a/drivers/scsi/bfa/include/bfa_fcpim.h
+++ /dev/null
@@ -1,177 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_FCPIM_H__
19#define __BFA_FCPIM_H__
20
21#include <bfa.h>
22#include <bfa_svc.h>
23#include <bfi/bfi_fcpim.h>
24#include <defs/bfa_defs_fcpim.h>
25
26/*
27 * forward declarations
28 */
29struct bfa_itnim_s;
30struct bfa_ioim_s;
31struct bfa_tskim_s;
32struct bfad_ioim_s;
33struct bfad_tskim_s;
34
35/*
36 * bfa fcpim module API functions
37 */
38void bfa_fcpim_path_tov_set(struct bfa_s *bfa, u16 path_tov);
39u16 bfa_fcpim_path_tov_get(struct bfa_s *bfa);
40void bfa_fcpim_qdepth_set(struct bfa_s *bfa, u16 q_depth);
41u16 bfa_fcpim_qdepth_get(struct bfa_s *bfa);
42bfa_status_t bfa_fcpim_get_modstats(struct bfa_s *bfa,
43 struct bfa_fcpim_stats_s *modstats);
44bfa_status_t bfa_fcpim_clr_modstats(struct bfa_s *bfa);
45void bfa_fcpim_set_ioredirect(struct bfa_s *bfa, bfa_boolean_t state);
46void bfa_fcpim_update_ioredirect(struct bfa_s *bfa);
47void bfa_cb_ioredirect_state_change(void *hcb_bfad, bfa_boolean_t ioredirect);
48
49#define bfa_fcpim_ioredirect_enabled(__bfa) \
50 (((struct bfa_fcpim_mod_s *)(BFA_FCPIM_MOD(__bfa)))->ioredirect)
51
52#define bfa_fcpim_get_next_reqq(__bfa, __qid) \
53{ \
54 struct bfa_fcpim_mod_s *__fcpim = BFA_FCPIM_MOD(__bfa); \
55 __fcpim->reqq++; \
56 __fcpim->reqq &= (BFI_IOC_MAX_CQS - 1); \
57 *(__qid) = __fcpim->reqq; \
58}
59
60#define bfa_iocfc_map_msg_to_qid(__msg, __qid) \
61 *(__qid) = (u8)((__msg) & (BFI_IOC_MAX_CQS - 1));
62
63
64/*
65 * bfa itnim API functions
66 */
67struct bfa_itnim_s *bfa_itnim_create(struct bfa_s *bfa,
68 struct bfa_rport_s *rport, void *itnim);
69void bfa_itnim_delete(struct bfa_itnim_s *itnim);
70void bfa_itnim_online(struct bfa_itnim_s *itnim,
71 bfa_boolean_t seq_rec);
72void bfa_itnim_offline(struct bfa_itnim_s *itnim);
73void bfa_itnim_get_stats(struct bfa_itnim_s *itnim,
74 struct bfa_itnim_hal_stats_s *stats);
75void bfa_itnim_clear_stats(struct bfa_itnim_s *itnim);
76
77#define bfa_itnim_get_reqq(__ioim) (((struct bfa_ioim_s *)__ioim)->itnim->reqq)
78
79/**
80 * BFA completion callback for bfa_itnim_online().
81 *
82 * @param[in] itnim FCS or driver itnim instance
83 *
84 * return None
85 */
86void bfa_cb_itnim_online(void *itnim);
87
88/**
89 * BFA completion callback for bfa_itnim_offline().
90 *
91 * @param[in] itnim FCS or driver itnim instance
92 *
93 * return None
94 */
95void bfa_cb_itnim_offline(void *itnim);
96void bfa_cb_itnim_tov_begin(void *itnim);
97void bfa_cb_itnim_tov(void *itnim);
98
99/**
100 * BFA notification to FCS/driver for second level error recovery.
101 *
102 * Atleast one I/O request has timedout and target is unresponsive to
103 * repeated abort requests. Second level error recovery should be initiated
104 * by starting implicit logout and recovery procedures.
105 *
106 * @param[in] itnim FCS or driver itnim instance
107 *
108 * return None
109 */
110void bfa_cb_itnim_sler(void *itnim);
111
112/*
113 * bfa ioim API functions
114 */
115struct bfa_ioim_s *bfa_ioim_alloc(struct bfa_s *bfa,
116 struct bfad_ioim_s *dio,
117 struct bfa_itnim_s *itnim,
118 u16 nsgles);
119
120void bfa_ioim_free(struct bfa_ioim_s *ioim);
121void bfa_ioim_start(struct bfa_ioim_s *ioim);
122void bfa_ioim_abort(struct bfa_ioim_s *ioim);
123void bfa_ioim_delayed_comp(struct bfa_ioim_s *ioim,
124 bfa_boolean_t iotov);
125
126
127/**
128 * I/O completion notification.
129 *
130 * @param[in] dio driver IO structure
131 * @param[in] io_status IO completion status
132 * @param[in] scsi_status SCSI status returned by target
133 * @param[in] sns_len SCSI sense length, 0 if none
134 * @param[in] sns_info SCSI sense data, if any
135 * @param[in] residue Residual length
136 *
137 * @return None
138 */
139void bfa_cb_ioim_done(void *bfad, struct bfad_ioim_s *dio,
140 enum bfi_ioim_status io_status,
141 u8 scsi_status, int sns_len,
142 u8 *sns_info, s32 residue);
143
144/**
145 * I/O good completion notification.
146 *
147 * @param[in] dio driver IO structure
148 *
149 * @return None
150 */
151void bfa_cb_ioim_good_comp(void *bfad, struct bfad_ioim_s *dio);
152
153/**
154 * I/O abort completion notification
155 *
156 * @param[in] dio driver IO that was aborted
157 *
158 * @return None
159 */
160void bfa_cb_ioim_abort(void *bfad, struct bfad_ioim_s *dio);
161void bfa_cb_ioim_resfree(void *hcb_bfad);
162
163void bfa_cb_ioim_resfree(void *hcb_bfad);
164
165/*
166 * bfa tskim API functions
167 */
168struct bfa_tskim_s *bfa_tskim_alloc(struct bfa_s *bfa,
169 struct bfad_tskim_s *dtsk);
170void bfa_tskim_free(struct bfa_tskim_s *tskim);
171void bfa_tskim_start(struct bfa_tskim_s *tskim,
172 struct bfa_itnim_s *itnim, lun_t lun,
173 enum fcp_tm_cmnd tm, u8 t_secs);
174void bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk,
175 enum bfi_tskim_status tsk_status);
176
177#endif /* __BFA_FCPIM_H__ */
diff --git a/drivers/scsi/bfa/include/bfa_fcptm.h b/drivers/scsi/bfa/include/bfa_fcptm.h
deleted file mode 100644
index 5f5ffe0bb1bb..000000000000
--- a/drivers/scsi/bfa/include/bfa_fcptm.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_FCPTM_H__
19#define __BFA_FCPTM_H__
20
21#include <bfa.h>
22#include <bfa_svc.h>
23#include <bfi/bfi_fcptm.h>
24
25/*
26 * forward declarations
27 */
28struct bfa_tin_s;
29struct bfa_iotm_s;
30struct bfa_tsktm_s;
31
32/*
33 * bfa fcptm module API functions
34 */
35void bfa_fcptm_path_tov_set(struct bfa_s *bfa, u16 path_tov);
36u16 bfa_fcptm_path_tov_get(struct bfa_s *bfa);
37void bfa_fcptm_qdepth_set(struct bfa_s *bfa, u16 q_depth);
38u16 bfa_fcptm_qdepth_get(struct bfa_s *bfa);
39
40/*
41 * bfa tin API functions
42 */
43void bfa_tin_get_stats(struct bfa_tin_s *tin, struct bfa_tin_stats_s *stats);
44void bfa_tin_clear_stats(struct bfa_tin_s *tin);
45
46#endif /* __BFA_FCPTM_H__ */
47
diff --git a/drivers/scsi/bfa/include/bfa_svc.h b/drivers/scsi/bfa/include/bfa_svc.h
deleted file mode 100644
index 7840943d73b0..000000000000
--- a/drivers/scsi/bfa/include/bfa_svc.h
+++ /dev/null
@@ -1,338 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_SVC_H__
18#define __BFA_SVC_H__
19
20/*
21 * forward declarations
22 */
23struct bfa_fcxp_s;
24
25#include <defs/bfa_defs_status.h>
26#include <defs/bfa_defs_pport.h>
27#include <defs/bfa_defs_rport.h>
28#include <defs/bfa_defs_qos.h>
29#include <defs/bfa_defs_fcport.h>
30#include <cs/bfa_sm.h>
31#include <bfa.h>
32
33/**
34 * BFA rport information.
35 */
36struct bfa_rport_info_s {
37 u16 max_frmsz; /* max rcv pdu size */
38 u32 pid:24, /* remote port ID */
39 lp_tag:8; /* tag */
40 u32 local_pid:24, /* local port ID */
41 cisc:8; /* CIRO supported */
42 u8 fc_class; /* supported FC classes. enum fc_cos */
43 u8 vf_en; /* virtual fabric enable */
44 u16 vf_id; /* virtual fabric ID */
45 enum bfa_pport_speed speed; /* Rport's current speed */
46};
47
48/**
49 * BFA rport data structure
50 */
51struct bfa_rport_s {
52 struct list_head qe; /* queue element */
53 bfa_sm_t sm; /* state machine */
54 struct bfa_s *bfa; /* backpointer to BFA */
55 void *rport_drv; /* fcs/driver rport object */
56 u16 fw_handle; /* firmware rport handle */
57 u16 rport_tag; /* BFA rport tag */
58 struct bfa_rport_info_s rport_info; /* rport info from fcs/driver */
59 struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
60 struct bfa_cb_qe_s hcb_qe; /* BFA callback qelem */
61 struct bfa_rport_hal_stats_s stats; /* BFA rport statistics */
62 struct bfa_rport_qos_attr_s qos_attr;
63 union a {
64 bfa_status_t status; /* f/w status */
65 void *fw_msg; /* QoS scn event */
66 } event_arg;
67};
68#define BFA_RPORT_FC_COS(_rport) ((_rport)->rport_info.fc_class)
69
70/**
71 * Send completion callback.
72 */
73typedef void (*bfa_cb_fcxp_send_t) (void *bfad_fcxp, struct bfa_fcxp_s *fcxp,
74 void *cbarg, enum bfa_status req_status,
75 u32 rsp_len, u32 resid_len,
76 struct fchs_s *rsp_fchs);
77
78/**
79 * BFA fcxp allocation (asynchronous)
80 */
81typedef void (*bfa_fcxp_alloc_cbfn_t) (void *cbarg, struct bfa_fcxp_s *fcxp);
82
83struct bfa_fcxp_wqe_s {
84 struct list_head qe;
85 bfa_fcxp_alloc_cbfn_t alloc_cbfn;
86 void *alloc_cbarg;
87};
88
89typedef u64 (*bfa_fcxp_get_sgaddr_t) (void *bfad_fcxp, int sgeid);
90typedef u32 (*bfa_fcxp_get_sglen_t) (void *bfad_fcxp, int sgeid);
91
92#define BFA_UF_BUFSZ (2 * 1024 + 256)
93
94/**
95 * @todo private
96 */
97struct bfa_uf_buf_s {
98 u8 d[BFA_UF_BUFSZ];
99};
100
101
102struct bfa_uf_s {
103 struct list_head qe; /* queue element */
104 struct bfa_s *bfa; /* bfa instance */
105 u16 uf_tag; /* identifying tag fw msgs */
106 u16 vf_id;
107 u16 src_rport_handle;
108 u16 rsvd;
109 u8 *data_ptr;
110 u16 data_len; /* actual receive length */
111 u16 pb_len; /* posted buffer length */
112 void *buf_kva; /* buffer virtual address */
113 u64 buf_pa; /* buffer physical address */
114 struct bfa_cb_qe_s hcb_qe; /* comp: BFA comp qelem */
115 struct bfa_sge_s sges[BFI_SGE_INLINE_MAX];
116};
117
118typedef void (*bfa_cb_pport_t) (void *cbarg, enum bfa_status status);
119
120/**
121 * bfa lport login/logout service interface
122 */
123struct bfa_lps_s {
124 struct list_head qe; /* queue element */
125 struct bfa_s *bfa; /* parent bfa instance */
126 bfa_sm_t sm; /* finite state machine */
127 u8 lp_tag; /* lport tag */
128 u8 reqq; /* lport request queue */
129 u8 alpa; /* ALPA for loop topologies */
130 u32 lp_pid; /* lport port ID */
131 bfa_boolean_t fdisc; /* send FDISC instead of FLOGI */
132 bfa_boolean_t auth_en; /* enable authentication */
133 bfa_boolean_t auth_req; /* authentication required */
134 bfa_boolean_t npiv_en; /* NPIV is allowed by peer */
135 bfa_boolean_t fport; /* attached peer is F_PORT */
136 bfa_boolean_t brcd_switch;/* attached peer is brcd switch */
137 bfa_status_t status; /* login status */
138 u16 pdusz; /* max receive PDU size */
139 u16 pr_bbcred; /* BB_CREDIT from peer */
140 u8 lsrjt_rsn; /* LSRJT reason */
141 u8 lsrjt_expl; /* LSRJT explanation */
142 wwn_t pwwn; /* port wwn of lport */
143 wwn_t nwwn; /* node wwn of lport */
144 wwn_t pr_pwwn; /* port wwn of lport peer */
145 wwn_t pr_nwwn; /* node wwn of lport peer */
146 mac_t lp_mac; /* fpma/spma MAC for lport */
147 mac_t fcf_mac; /* FCF MAC of lport */
148 struct bfa_reqq_wait_s wqe; /* request wait queue element */
149 void *uarg; /* user callback arg */
150 struct bfa_cb_qe_s hcb_qe; /* comp: callback qelem */
151 struct bfi_lps_login_rsp_s *loginrsp;
152 bfa_eproto_status_t ext_status;
153};
154
155#define BFA_FCPORT(_bfa) (&((_bfa)->modules.port))
156
157/*
158 * bfa pport API functions
159 */
160bfa_status_t bfa_fcport_enable(struct bfa_s *bfa);
161bfa_status_t bfa_fcport_disable(struct bfa_s *bfa);
162bfa_status_t bfa_fcport_cfg_speed(struct bfa_s *bfa,
163 enum bfa_pport_speed speed);
164enum bfa_pport_speed bfa_fcport_get_speed(struct bfa_s *bfa);
165bfa_status_t bfa_fcport_cfg_topology(struct bfa_s *bfa,
166 enum bfa_pport_topology topo);
167enum bfa_pport_topology bfa_fcport_get_topology(struct bfa_s *bfa);
168bfa_status_t bfa_fcport_cfg_hardalpa(struct bfa_s *bfa, u8 alpa);
169bfa_boolean_t bfa_fcport_get_hardalpa(struct bfa_s *bfa, u8 *alpa);
170u8 bfa_fcport_get_myalpa(struct bfa_s *bfa);
171bfa_status_t bfa_fcport_clr_hardalpa(struct bfa_s *bfa);
172bfa_status_t bfa_fcport_cfg_maxfrsize(struct bfa_s *bfa, u16 maxsize);
173u16 bfa_fcport_get_maxfrsize(struct bfa_s *bfa);
174u32 bfa_fcport_mypid(struct bfa_s *bfa);
175u8 bfa_fcport_get_rx_bbcredit(struct bfa_s *bfa);
176bfa_status_t bfa_fcport_trunk_enable(struct bfa_s *bfa, u8 bitmap);
177bfa_status_t bfa_fcport_trunk_disable(struct bfa_s *bfa);
178bfa_boolean_t bfa_fcport_trunk_query(struct bfa_s *bfa, u32 *bitmap);
179void bfa_fcport_get_attr(struct bfa_s *bfa, struct bfa_pport_attr_s *attr);
180wwn_t bfa_fcport_get_wwn(struct bfa_s *bfa, bfa_boolean_t node);
181void bfa_fcport_event_register(struct bfa_s *bfa,
182 void (*event_cbfn) (void *cbarg,
183 bfa_pport_event_t event), void *event_cbarg);
184bfa_boolean_t bfa_fcport_is_disabled(struct bfa_s *bfa);
185void bfa_fcport_cfg_qos(struct bfa_s *bfa, bfa_boolean_t on_off);
186void bfa_fcport_cfg_ratelim(struct bfa_s *bfa, bfa_boolean_t on_off);
187bfa_status_t bfa_fcport_cfg_ratelim_speed(struct bfa_s *bfa,
188 enum bfa_pport_speed speed);
189enum bfa_pport_speed bfa_fcport_get_ratelim_speed(struct bfa_s *bfa);
190
191void bfa_fcport_set_tx_bbcredit(struct bfa_s *bfa, u16 tx_bbcredit);
192void bfa_fcport_busy(struct bfa_s *bfa, bfa_boolean_t status);
193void bfa_fcport_beacon(struct bfa_s *bfa, bfa_boolean_t beacon,
194 bfa_boolean_t link_e2e_beacon);
195void bfa_cb_pport_event(void *cbarg, bfa_pport_event_t event);
196void bfa_fcport_qos_get_attr(struct bfa_s *bfa,
197 struct bfa_qos_attr_s *qos_attr);
198void bfa_fcport_qos_get_vc_attr(struct bfa_s *bfa,
199 struct bfa_qos_vc_attr_s *qos_vc_attr);
200bfa_status_t bfa_fcport_get_qos_stats(struct bfa_s *bfa,
201 union bfa_fcport_stats_u *stats,
202 bfa_cb_pport_t cbfn, void *cbarg);
203bfa_status_t bfa_fcport_clear_qos_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
204 void *cbarg);
205bfa_status_t bfa_fcport_get_fcoe_stats(struct bfa_s *bfa,
206 union bfa_fcport_stats_u *stats,
207 bfa_cb_pport_t cbfn, void *cbarg);
208bfa_status_t bfa_fcport_clear_fcoe_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
209 void *cbarg);
210
211bfa_boolean_t bfa_fcport_is_ratelim(struct bfa_s *bfa);
212bfa_boolean_t bfa_fcport_is_linkup(struct bfa_s *bfa);
213bfa_status_t bfa_fcport_get_stats(struct bfa_s *bfa,
214 union bfa_fcport_stats_u *stats,
215 bfa_cb_pport_t cbfn, void *cbarg);
216bfa_status_t bfa_fcport_clear_stats(struct bfa_s *bfa, bfa_cb_pport_t cbfn,
217 void *cbarg);
218bfa_boolean_t bfa_fcport_is_qos_enabled(struct bfa_s *bfa);
219
220/*
221 * bfa rport API functions
222 */
223struct bfa_rport_s *bfa_rport_create(struct bfa_s *bfa, void *rport_drv);
224void bfa_rport_delete(struct bfa_rport_s *rport);
225void bfa_rport_online(struct bfa_rport_s *rport,
226 struct bfa_rport_info_s *rport_info);
227void bfa_rport_offline(struct bfa_rport_s *rport);
228void bfa_rport_speed(struct bfa_rport_s *rport, enum bfa_pport_speed speed);
229void bfa_rport_get_stats(struct bfa_rport_s *rport,
230 struct bfa_rport_hal_stats_s *stats);
231void bfa_rport_clear_stats(struct bfa_rport_s *rport);
232void bfa_cb_rport_online(void *rport);
233void bfa_cb_rport_offline(void *rport);
234void bfa_cb_rport_qos_scn_flowid(void *rport,
235 struct bfa_rport_qos_attr_s old_qos_attr,
236 struct bfa_rport_qos_attr_s new_qos_attr);
237void bfa_cb_rport_qos_scn_prio(void *rport,
238 struct bfa_rport_qos_attr_s old_qos_attr,
239 struct bfa_rport_qos_attr_s new_qos_attr);
240void bfa_rport_get_qos_attr(struct bfa_rport_s *rport,
241 struct bfa_rport_qos_attr_s *qos_attr);
242
243/*
244 * bfa fcxp API functions
245 */
246struct bfa_fcxp_s *bfa_fcxp_alloc(void *bfad_fcxp, struct bfa_s *bfa,
247 int nreq_sgles, int nrsp_sgles,
248 bfa_fcxp_get_sgaddr_t get_req_sga,
249 bfa_fcxp_get_sglen_t get_req_sglen,
250 bfa_fcxp_get_sgaddr_t get_rsp_sga,
251 bfa_fcxp_get_sglen_t get_rsp_sglen);
252void bfa_fcxp_alloc_wait(struct bfa_s *bfa, struct bfa_fcxp_wqe_s *wqe,
253 bfa_fcxp_alloc_cbfn_t alloc_cbfn, void *cbarg);
254void bfa_fcxp_walloc_cancel(struct bfa_s *bfa,
255 struct bfa_fcxp_wqe_s *wqe);
256void bfa_fcxp_discard(struct bfa_fcxp_s *fcxp);
257
258void *bfa_fcxp_get_reqbuf(struct bfa_fcxp_s *fcxp);
259void *bfa_fcxp_get_rspbuf(struct bfa_fcxp_s *fcxp);
260
261void bfa_fcxp_free(struct bfa_fcxp_s *fcxp);
262
263void bfa_fcxp_send(struct bfa_fcxp_s *fcxp,
264 struct bfa_rport_s *rport, u16 vf_id, u8 lp_tag,
265 bfa_boolean_t cts, enum fc_cos cos,
266 u32 reqlen, struct fchs_s *fchs,
267 bfa_cb_fcxp_send_t cbfn,
268 void *cbarg,
269 u32 rsp_maxlen, u8 rsp_timeout);
270bfa_status_t bfa_fcxp_abort(struct bfa_fcxp_s *fcxp);
271u32 bfa_fcxp_get_reqbufsz(struct bfa_fcxp_s *fcxp);
272u32 bfa_fcxp_get_maxrsp(struct bfa_s *bfa);
273
274static inline void *
275bfa_uf_get_frmbuf(struct bfa_uf_s *uf)
276{
277 return uf->data_ptr;
278}
279
280static inline u16
281bfa_uf_get_frmlen(struct bfa_uf_s *uf)
282{
283 return uf->data_len;
284}
285
286/**
287 * Callback prototype for unsolicited frame receive handler.
288 *
289 * @param[in] cbarg callback arg for receive handler
290 * @param[in] uf unsolicited frame descriptor
291 *
292 * @return None
293 */
294typedef void (*bfa_cb_uf_recv_t) (void *cbarg, struct bfa_uf_s *uf);
295
296/*
297 * bfa uf API functions
298 */
299void bfa_uf_recv_register(struct bfa_s *bfa, bfa_cb_uf_recv_t ufrecv,
300 void *cbarg);
301void bfa_uf_free(struct bfa_uf_s *uf);
302
303/**
304 * bfa lport service api
305 */
306
307u32 bfa_lps_get_max_vport(struct bfa_s *bfa);
308struct bfa_lps_s *bfa_lps_alloc(struct bfa_s *bfa);
309void bfa_lps_delete(struct bfa_lps_s *lps);
310void bfa_lps_discard(struct bfa_lps_s *lps);
311void bfa_lps_flogi(struct bfa_lps_s *lps, void *uarg, u8 alpa, u16 pdusz,
312 wwn_t pwwn, wwn_t nwwn, bfa_boolean_t auth_en);
313void bfa_lps_fdisc(struct bfa_lps_s *lps, void *uarg, u16 pdusz, wwn_t pwwn,
314 wwn_t nwwn);
315void bfa_lps_flogo(struct bfa_lps_s *lps);
316void bfa_lps_fdisclogo(struct bfa_lps_s *lps);
317u8 bfa_lps_get_tag(struct bfa_lps_s *lps);
318bfa_boolean_t bfa_lps_is_npiv_en(struct bfa_lps_s *lps);
319bfa_boolean_t bfa_lps_is_fport(struct bfa_lps_s *lps);
320bfa_boolean_t bfa_lps_is_brcd_fabric(struct bfa_lps_s *lps);
321bfa_boolean_t bfa_lps_is_authreq(struct bfa_lps_s *lps);
322bfa_eproto_status_t bfa_lps_get_extstatus(struct bfa_lps_s *lps);
323u32 bfa_lps_get_pid(struct bfa_lps_s *lps);
324u8 bfa_lps_get_tag_from_pid(struct bfa_s *bfa, u32 pid);
325u16 bfa_lps_get_peer_bbcredit(struct bfa_lps_s *lps);
326wwn_t bfa_lps_get_peer_pwwn(struct bfa_lps_s *lps);
327wwn_t bfa_lps_get_peer_nwwn(struct bfa_lps_s *lps);
328u8 bfa_lps_get_lsrjt_rsn(struct bfa_lps_s *lps);
329u8 bfa_lps_get_lsrjt_expl(struct bfa_lps_s *lps);
330mac_t bfa_lps_get_lp_mac(struct bfa_lps_s *lps);
331void bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status);
332void bfa_cb_lps_flogo_comp(void *bfad, void *uarg);
333void bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status);
334void bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg);
335void bfa_cb_lps_cvl_event(void *bfad, void *uarg);
336
337#endif /* __BFA_SVC_H__ */
338
diff --git a/drivers/scsi/bfa/include/bfa_timer.h b/drivers/scsi/bfa/include/bfa_timer.h
deleted file mode 100644
index f71087448222..000000000000
--- a/drivers/scsi/bfa/include/bfa_timer.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_TIMER_H__
18#define __BFA_TIMER_H__
19
20#include <bfa_os_inc.h>
21#include <cs/bfa_q.h>
22
23struct bfa_s;
24
25typedef void (*bfa_timer_cbfn_t)(void *);
26
27/**
28 * BFA timer data structure
29 */
30struct bfa_timer_s {
31 struct list_head qe;
32 bfa_timer_cbfn_t timercb;
33 void *arg;
34 int timeout; /**< in millisecs. */
35};
36
37/**
38 * Timer module structure
39 */
40struct bfa_timer_mod_s {
41 struct list_head timer_q;
42};
43
44#define BFA_TIMER_FREQ 200 /**< specified in millisecs */
45
46void bfa_timer_beat(struct bfa_timer_mod_s *mod);
47void bfa_timer_init(struct bfa_timer_mod_s *mod);
48void bfa_timer_begin(struct bfa_timer_mod_s *mod, struct bfa_timer_s *timer,
49 bfa_timer_cbfn_t timercb, void *arg,
50 unsigned int timeout);
51void bfa_timer_stop(struct bfa_timer_s *timer);
52
53#endif /* __BFA_TIMER_H__ */
diff --git a/drivers/scsi/bfa/include/bfi/bfi.h b/drivers/scsi/bfa/include/bfi/bfi.h
deleted file mode 100644
index a550e80cabd2..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi.h
+++ /dev/null
@@ -1,174 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFI_H__
19#define __BFI_H__
20
21#include <bfa_os_inc.h>
22#include <defs/bfa_defs_status.h>
23
24#pragma pack(1)
25
26/**
27 * Msg header common to all msgs
28 */
29struct bfi_mhdr_s {
30 u8 msg_class; /* @ref bfi_mclass_t */
31 u8 msg_id; /* msg opcode with in the class */
32 union {
33 struct {
34 u8 rsvd;
35 u8 lpu_id; /* msg destination */
36 } h2i;
37 u16 i2htok; /* token in msgs to host */
38 } mtag;
39};
40
41#define bfi_h2i_set(_mh, _mc, _op, _lpuid) do { \
42 (_mh).msg_class = (_mc); \
43 (_mh).msg_id = (_op); \
44 (_mh).mtag.h2i.lpu_id = (_lpuid); \
45} while (0)
46
47#define bfi_i2h_set(_mh, _mc, _op, _i2htok) do { \
48 (_mh).msg_class = (_mc); \
49 (_mh).msg_id = (_op); \
50 (_mh).mtag.i2htok = (_i2htok); \
51} while (0)
52
53/*
54 * Message opcodes: 0-127 to firmware, 128-255 to host
55 */
56#define BFI_I2H_OPCODE_BASE 128
57#define BFA_I2HM(_x) ((_x) + BFI_I2H_OPCODE_BASE)
58
59/**
60 ****************************************************************************
61 *
62 * Scatter Gather Element and Page definition
63 *
64 ****************************************************************************
65 */
66
67#define BFI_SGE_INLINE 1
68#define BFI_SGE_INLINE_MAX (BFI_SGE_INLINE + 1)
69
70/**
71 * SG Flags
72 */
73enum {
74 BFI_SGE_DATA = 0, /* data address, not last */
75 BFI_SGE_DATA_CPL = 1, /* data addr, last in current page */
76 BFI_SGE_DATA_LAST = 3, /* data address, last */
77 BFI_SGE_LINK = 2, /* link address */
78 BFI_SGE_PGDLEN = 2, /* cumulative data length for page */
79};
80
81/**
82 * DMA addresses
83 */
84union bfi_addr_u {
85 struct {
86 u32 addr_lo;
87 u32 addr_hi;
88 } a32;
89};
90
91/**
92 * Scatter Gather Element
93 */
94struct bfi_sge_s {
95#ifdef __BIGENDIAN
96 u32 flags:2,
97 rsvd:2,
98 sg_len:28;
99#else
100 u32 sg_len:28,
101 rsvd:2,
102 flags:2;
103#endif
104 union bfi_addr_u sga;
105};
106
107/**
108 * Scatter Gather Page
109 */
110#define BFI_SGPG_DATA_SGES 7
111#define BFI_SGPG_SGES_MAX (BFI_SGPG_DATA_SGES + 1)
112#define BFI_SGPG_RSVD_WD_LEN 8
113struct bfi_sgpg_s {
114 struct bfi_sge_s sges[BFI_SGPG_SGES_MAX];
115 u32 rsvd[BFI_SGPG_RSVD_WD_LEN];
116};
117
118/*
119 * Large Message structure - 128 Bytes size Msgs
120 */
121#define BFI_LMSG_SZ 128
122#define BFI_LMSG_PL_WSZ \
123 ((BFI_LMSG_SZ - sizeof(struct bfi_mhdr_s)) / 4)
124
125struct bfi_msg_s {
126 struct bfi_mhdr_s mhdr;
127 u32 pl[BFI_LMSG_PL_WSZ];
128};
129
130/**
131 * Mailbox message structure
132 */
133#define BFI_MBMSG_SZ 7
134struct bfi_mbmsg_s {
135 struct bfi_mhdr_s mh;
136 u32 pl[BFI_MBMSG_SZ];
137};
138
139/**
140 * Message Classes
141 */
142enum bfi_mclass {
143 BFI_MC_IOC = 1, /* IO Controller (IOC) */
144 BFI_MC_DIAG = 2, /* Diagnostic Msgs */
145 BFI_MC_FLASH = 3, /* Flash message class */
146 BFI_MC_CEE = 4, /* CEE */
147 BFI_MC_FCPORT = 5, /* FC port */
148 BFI_MC_IOCFC = 6, /* FC - IO Controller (IOC) */
149 BFI_MC_LL = 7, /* Link Layer */
150 BFI_MC_UF = 8, /* Unsolicited frame receive */
151 BFI_MC_FCXP = 9, /* FC Transport */
152 BFI_MC_LPS = 10, /* lport fc login services */
153 BFI_MC_RPORT = 11, /* Remote port */
154 BFI_MC_ITNIM = 12, /* I-T nexus (Initiator mode) */
155 BFI_MC_IOIM_READ = 13, /* read IO (Initiator mode) */
156 BFI_MC_IOIM_WRITE = 14, /* write IO (Initiator mode) */
157 BFI_MC_IOIM_IO = 15, /* IO (Initiator mode) */
158 BFI_MC_IOIM = 16, /* IO (Initiator mode) */
159 BFI_MC_IOIM_IOCOM = 17, /* good IO completion */
160 BFI_MC_TSKIM = 18, /* Initiator Task management */
161 BFI_MC_SBOOT = 19, /* SAN boot services */
162 BFI_MC_IPFC = 20, /* IP over FC Msgs */
163 BFI_MC_PORT = 21, /* Physical port */
164 BFI_MC_MAX = 32
165};
166
167#define BFI_IOC_MAX_CQS 4
168#define BFI_IOC_MAX_CQS_ASIC 8
169#define BFI_IOC_MSGLEN_MAX 32 /* 32 bytes */
170
171#pragma pack()
172
173#endif /* __BFI_H__ */
174
diff --git a/drivers/scsi/bfa/include/bfi/bfi_boot.h b/drivers/scsi/bfa/include/bfi/bfi_boot.h
deleted file mode 100644
index 5955afe7d108..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_boot.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 * bfi_boot.h
19 */
20
21#ifndef __BFI_BOOT_H__
22#define __BFI_BOOT_H__
23
24#define BFI_BOOT_TYPE_OFF 8
25#define BFI_BOOT_PARAM_OFF 12
26
27#define BFI_BOOT_TYPE_NORMAL 0 /* param is device id */
28#define BFI_BOOT_TYPE_FLASH 1
29#define BFI_BOOT_TYPE_MEMTEST 2
30
31#define BFI_BOOT_MEMTEST_RES_ADDR 0x900
32#define BFI_BOOT_MEMTEST_RES_SIG 0xA0A1A2A3
33
34#endif
diff --git a/drivers/scsi/bfa/include/bfi/bfi_cee.h b/drivers/scsi/bfa/include/bfi/bfi_cee.h
deleted file mode 100644
index 0970596583ea..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_cee.h
+++ /dev/null
@@ -1,119 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 * Copyright (c) 2006-2009 Brocade Communications Systems, Inc.
19 * All rights reserved.
20 *
21 * bfi_dcbx.h BFI Interface (Mailbox commands and related structures)
22 * between host driver and DCBX/LLDP firmware module.
23 *
24**/
25
26#ifndef __BFI_CEE_H__
27#define __BFI_CEE_H__
28
29#include <bfi/bfi.h>
30
31#pragma pack(1)
32
33
34enum bfi_cee_h2i_msgs_e {
35 BFI_CEE_H2I_GET_CFG_REQ = 1,
36 BFI_CEE_H2I_RESET_STATS = 2,
37 BFI_CEE_H2I_GET_STATS_REQ = 3,
38};
39
40
41enum bfi_cee_i2h_msgs_e {
42 BFI_CEE_I2H_GET_CFG_RSP = BFA_I2HM(1),
43 BFI_CEE_I2H_RESET_STATS_RSP = BFA_I2HM(2),
44 BFI_CEE_I2H_GET_STATS_RSP = BFA_I2HM(3),
45};
46
47
48/* Data structures */
49
50/*
51 * BFI_CEE_H2I_RESET_STATS
52 */
53struct bfi_lldp_reset_stats_s {
54 struct bfi_mhdr_s mh;
55};
56
57/*
58 * BFI_CEE_H2I_RESET_STATS
59 */
60struct bfi_cee_reset_stats_s {
61 struct bfi_mhdr_s mh;
62};
63
64/*
65 * BFI_CEE_H2I_GET_CFG_REQ
66 */
67struct bfi_cee_get_req_s {
68 struct bfi_mhdr_s mh;
69 union bfi_addr_u dma_addr;
70};
71
72
73/*
74 * BFI_CEE_I2H_GET_CFG_RSP
75 */
76struct bfi_cee_get_rsp_s {
77 struct bfi_mhdr_s mh;
78 u8 cmd_status;
79 u8 rsvd[3];
80};
81
82/*
83 * BFI_CEE_H2I_GET_STATS_REQ
84 */
85struct bfi_cee_stats_req_s {
86 struct bfi_mhdr_s mh;
87 union bfi_addr_u dma_addr;
88};
89
90
91/*
92 * BFI_CEE_I2H_GET_STATS_RSP
93 */
94struct bfi_cee_stats_rsp_s {
95 struct bfi_mhdr_s mh;
96 u8 cmd_status;
97 u8 rsvd[3];
98};
99
100
101
102union bfi_cee_h2i_msg_u {
103 struct bfi_mhdr_s mh;
104 struct bfi_cee_get_req_s get_req;
105 struct bfi_cee_stats_req_s stats_req;
106};
107
108
109union bfi_cee_i2h_msg_u {
110 struct bfi_mhdr_s mh;
111 struct bfi_cee_get_rsp_s get_rsp;
112 struct bfi_cee_stats_rsp_s stats_rsp;
113};
114
115#pragma pack()
116
117
118#endif /* __BFI_CEE_H__ */
119
diff --git a/drivers/scsi/bfa/include/bfi/bfi_ctreg.h b/drivers/scsi/bfa/include/bfi/bfi_ctreg.h
deleted file mode 100644
index c0ef5a93b797..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_ctreg.h
+++ /dev/null
@@ -1,640 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/*
19 * bfi_ctreg.h catapult host block register definitions
20 *
21 * !!! Do not edit. Auto generated. !!!
22 */
23
24#ifndef __BFI_CTREG_H__
25#define __BFI_CTREG_H__
26
27
28#define HOSTFN0_LPU_MBOX0_0 0x00019200
29#define HOSTFN1_LPU_MBOX0_8 0x00019260
30#define LPU_HOSTFN0_MBOX0_0 0x00019280
31#define LPU_HOSTFN1_MBOX0_8 0x000192e0
32#define HOSTFN2_LPU_MBOX0_0 0x00019400
33#define HOSTFN3_LPU_MBOX0_8 0x00019460
34#define LPU_HOSTFN2_MBOX0_0 0x00019480
35#define LPU_HOSTFN3_MBOX0_8 0x000194e0
36#define HOSTFN0_INT_STATUS 0x00014000
37#define __HOSTFN0_HALT_OCCURRED 0x01000000
38#define __HOSTFN0_INT_STATUS_LVL_MK 0x00f00000
39#define __HOSTFN0_INT_STATUS_LVL_SH 20
40#define __HOSTFN0_INT_STATUS_LVL(_v) ((_v) << __HOSTFN0_INT_STATUS_LVL_SH)
41#define __HOSTFN0_INT_STATUS_P_MK 0x000f0000
42#define __HOSTFN0_INT_STATUS_P_SH 16
43#define __HOSTFN0_INT_STATUS_P(_v) ((_v) << __HOSTFN0_INT_STATUS_P_SH)
44#define __HOSTFN0_INT_STATUS_F 0x0000ffff
45#define HOSTFN0_INT_MSK 0x00014004
46#define HOST_PAGE_NUM_FN0 0x00014008
47#define __HOST_PAGE_NUM_FN 0x000001ff
48#define HOST_MSIX_ERR_INDEX_FN0 0x0001400c
49#define __MSIX_ERR_INDEX_FN 0x000001ff
50#define HOSTFN1_INT_STATUS 0x00014100
51#define __HOSTFN1_HALT_OCCURRED 0x01000000
52#define __HOSTFN1_INT_STATUS_LVL_MK 0x00f00000
53#define __HOSTFN1_INT_STATUS_LVL_SH 20
54#define __HOSTFN1_INT_STATUS_LVL(_v) ((_v) << __HOSTFN1_INT_STATUS_LVL_SH)
55#define __HOSTFN1_INT_STATUS_P_MK 0x000f0000
56#define __HOSTFN1_INT_STATUS_P_SH 16
57#define __HOSTFN1_INT_STATUS_P(_v) ((_v) << __HOSTFN1_INT_STATUS_P_SH)
58#define __HOSTFN1_INT_STATUS_F 0x0000ffff
59#define HOSTFN1_INT_MSK 0x00014104
60#define HOST_PAGE_NUM_FN1 0x00014108
61#define HOST_MSIX_ERR_INDEX_FN1 0x0001410c
62#define APP_PLL_425_CTL_REG 0x00014204
63#define __P_425_PLL_LOCK 0x80000000
64#define __APP_PLL_425_SRAM_USE_100MHZ 0x00100000
65#define __APP_PLL_425_RESET_TIMER_MK 0x000e0000
66#define __APP_PLL_425_RESET_TIMER_SH 17
67#define __APP_PLL_425_RESET_TIMER(_v) ((_v) << __APP_PLL_425_RESET_TIMER_SH)
68#define __APP_PLL_425_LOGIC_SOFT_RESET 0x00010000
69#define __APP_PLL_425_CNTLMT0_1_MK 0x0000c000
70#define __APP_PLL_425_CNTLMT0_1_SH 14
71#define __APP_PLL_425_CNTLMT0_1(_v) ((_v) << __APP_PLL_425_CNTLMT0_1_SH)
72#define __APP_PLL_425_JITLMT0_1_MK 0x00003000
73#define __APP_PLL_425_JITLMT0_1_SH 12
74#define __APP_PLL_425_JITLMT0_1(_v) ((_v) << __APP_PLL_425_JITLMT0_1_SH)
75#define __APP_PLL_425_HREF 0x00000800
76#define __APP_PLL_425_HDIV 0x00000400
77#define __APP_PLL_425_P0_1_MK 0x00000300
78#define __APP_PLL_425_P0_1_SH 8
79#define __APP_PLL_425_P0_1(_v) ((_v) << __APP_PLL_425_P0_1_SH)
80#define __APP_PLL_425_Z0_2_MK 0x000000e0
81#define __APP_PLL_425_Z0_2_SH 5
82#define __APP_PLL_425_Z0_2(_v) ((_v) << __APP_PLL_425_Z0_2_SH)
83#define __APP_PLL_425_RSEL200500 0x00000010
84#define __APP_PLL_425_ENARST 0x00000008
85#define __APP_PLL_425_BYPASS 0x00000004
86#define __APP_PLL_425_LRESETN 0x00000002
87#define __APP_PLL_425_ENABLE 0x00000001
88#define APP_PLL_312_CTL_REG 0x00014208
89#define __P_312_PLL_LOCK 0x80000000
90#define __ENABLE_MAC_AHB_1 0x00800000
91#define __ENABLE_MAC_AHB_0 0x00400000
92#define __ENABLE_MAC_1 0x00200000
93#define __ENABLE_MAC_0 0x00100000
94#define __APP_PLL_312_RESET_TIMER_MK 0x000e0000
95#define __APP_PLL_312_RESET_TIMER_SH 17
96#define __APP_PLL_312_RESET_TIMER(_v) ((_v) << __APP_PLL_312_RESET_TIMER_SH)
97#define __APP_PLL_312_LOGIC_SOFT_RESET 0x00010000
98#define __APP_PLL_312_CNTLMT0_1_MK 0x0000c000
99#define __APP_PLL_312_CNTLMT0_1_SH 14
100#define __APP_PLL_312_CNTLMT0_1(_v) ((_v) << __APP_PLL_312_CNTLMT0_1_SH)
101#define __APP_PLL_312_JITLMT0_1_MK 0x00003000
102#define __APP_PLL_312_JITLMT0_1_SH 12
103#define __APP_PLL_312_JITLMT0_1(_v) ((_v) << __APP_PLL_312_JITLMT0_1_SH)
104#define __APP_PLL_312_HREF 0x00000800
105#define __APP_PLL_312_HDIV 0x00000400
106#define __APP_PLL_312_P0_1_MK 0x00000300
107#define __APP_PLL_312_P0_1_SH 8
108#define __APP_PLL_312_P0_1(_v) ((_v) << __APP_PLL_312_P0_1_SH)
109#define __APP_PLL_312_Z0_2_MK 0x000000e0
110#define __APP_PLL_312_Z0_2_SH 5
111#define __APP_PLL_312_Z0_2(_v) ((_v) << __APP_PLL_312_Z0_2_SH)
112#define __APP_PLL_312_RSEL200500 0x00000010
113#define __APP_PLL_312_ENARST 0x00000008
114#define __APP_PLL_312_BYPASS 0x00000004
115#define __APP_PLL_312_LRESETN 0x00000002
116#define __APP_PLL_312_ENABLE 0x00000001
117#define MBIST_CTL_REG 0x00014220
118#define __EDRAM_BISTR_START 0x00000004
119#define __MBIST_RESET 0x00000002
120#define __MBIST_START 0x00000001
121#define MBIST_STAT_REG 0x00014224
122#define __EDRAM_BISTR_STATUS 0x00000008
123#define __EDRAM_BISTR_DONE 0x00000004
124#define __MEM_BIT_STATUS 0x00000002
125#define __MBIST_DONE 0x00000001
126#define HOST_SEM0_REG 0x00014230
127#define __HOST_SEMAPHORE 0x00000001
128#define HOST_SEM1_REG 0x00014234
129#define HOST_SEM2_REG 0x00014238
130#define HOST_SEM3_REG 0x0001423c
131#define HOST_SEM0_INFO_REG 0x00014240
132#define HOST_SEM1_INFO_REG 0x00014244
133#define HOST_SEM2_INFO_REG 0x00014248
134#define HOST_SEM3_INFO_REG 0x0001424c
135#define ETH_MAC_SER_REG 0x00014288
136#define __APP_EMS_CKBUFAMPIN 0x00000020
137#define __APP_EMS_REFCLKSEL 0x00000010
138#define __APP_EMS_CMLCKSEL 0x00000008
139#define __APP_EMS_REFCKBUFEN2 0x00000004
140#define __APP_EMS_REFCKBUFEN1 0x00000002
141#define __APP_EMS_CHANNEL_SEL 0x00000001
142#define HOSTFN2_INT_STATUS 0x00014300
143#define __HOSTFN2_HALT_OCCURRED 0x01000000
144#define __HOSTFN2_INT_STATUS_LVL_MK 0x00f00000
145#define __HOSTFN2_INT_STATUS_LVL_SH 20
146#define __HOSTFN2_INT_STATUS_LVL(_v) ((_v) << __HOSTFN2_INT_STATUS_LVL_SH)
147#define __HOSTFN2_INT_STATUS_P_MK 0x000f0000
148#define __HOSTFN2_INT_STATUS_P_SH 16
149#define __HOSTFN2_INT_STATUS_P(_v) ((_v) << __HOSTFN2_INT_STATUS_P_SH)
150#define __HOSTFN2_INT_STATUS_F 0x0000ffff
151#define HOSTFN2_INT_MSK 0x00014304
152#define HOST_PAGE_NUM_FN2 0x00014308
153#define HOST_MSIX_ERR_INDEX_FN2 0x0001430c
154#define HOSTFN3_INT_STATUS 0x00014400
155#define __HALT_OCCURRED 0x01000000
156#define __HOSTFN3_INT_STATUS_LVL_MK 0x00f00000
157#define __HOSTFN3_INT_STATUS_LVL_SH 20
158#define __HOSTFN3_INT_STATUS_LVL(_v) ((_v) << __HOSTFN3_INT_STATUS_LVL_SH)
159#define __HOSTFN3_INT_STATUS_P_MK 0x000f0000
160#define __HOSTFN3_INT_STATUS_P_SH 16
161#define __HOSTFN3_INT_STATUS_P(_v) ((_v) << __HOSTFN3_INT_STATUS_P_SH)
162#define __HOSTFN3_INT_STATUS_F 0x0000ffff
163#define HOSTFN3_INT_MSK 0x00014404
164#define HOST_PAGE_NUM_FN3 0x00014408
165#define HOST_MSIX_ERR_INDEX_FN3 0x0001440c
166#define FNC_ID_REG 0x00014600
167#define __FUNCTION_NUMBER 0x00000007
168#define FNC_PERS_REG 0x00014604
169#define __F3_FUNCTION_ACTIVE 0x80000000
170#define __F3_FUNCTION_MODE 0x40000000
171#define __F3_PORT_MAP_MK 0x30000000
172#define __F3_PORT_MAP_SH 28
173#define __F3_PORT_MAP(_v) ((_v) << __F3_PORT_MAP_SH)
174#define __F3_VM_MODE 0x08000000
175#define __F3_INTX_STATUS_MK 0x07000000
176#define __F3_INTX_STATUS_SH 24
177#define __F3_INTX_STATUS(_v) ((_v) << __F3_INTX_STATUS_SH)
178#define __F2_FUNCTION_ACTIVE 0x00800000
179#define __F2_FUNCTION_MODE 0x00400000
180#define __F2_PORT_MAP_MK 0x00300000
181#define __F2_PORT_MAP_SH 20
182#define __F2_PORT_MAP(_v) ((_v) << __F2_PORT_MAP_SH)
183#define __F2_VM_MODE 0x00080000
184#define __F2_INTX_STATUS_MK 0x00070000
185#define __F2_INTX_STATUS_SH 16
186#define __F2_INTX_STATUS(_v) ((_v) << __F2_INTX_STATUS_SH)
187#define __F1_FUNCTION_ACTIVE 0x00008000
188#define __F1_FUNCTION_MODE 0x00004000
189#define __F1_PORT_MAP_MK 0x00003000
190#define __F1_PORT_MAP_SH 12
191#define __F1_PORT_MAP(_v) ((_v) << __F1_PORT_MAP_SH)
192#define __F1_VM_MODE 0x00000800
193#define __F1_INTX_STATUS_MK 0x00000700
194#define __F1_INTX_STATUS_SH 8
195#define __F1_INTX_STATUS(_v) ((_v) << __F1_INTX_STATUS_SH)
196#define __F0_FUNCTION_ACTIVE 0x00000080
197#define __F0_FUNCTION_MODE 0x00000040
198#define __F0_PORT_MAP_MK 0x00000030
199#define __F0_PORT_MAP_SH 4
200#define __F0_PORT_MAP(_v) ((_v) << __F0_PORT_MAP_SH)
201#define __F0_VM_MODE 0x00000008
202#define __F0_INTX_STATUS 0x00000007
203enum {
204 __F0_INTX_STATUS_MSIX = 0x0,
205 __F0_INTX_STATUS_INTA = 0x1,
206 __F0_INTX_STATUS_INTB = 0x2,
207 __F0_INTX_STATUS_INTC = 0x3,
208 __F0_INTX_STATUS_INTD = 0x4,
209};
210#define OP_MODE 0x0001460c
211#define __APP_ETH_CLK_LOWSPEED 0x00000004
212#define __GLOBAL_CORECLK_HALFSPEED 0x00000002
213#define __GLOBAL_FCOE_MODE 0x00000001
214#define HOST_SEM4_REG 0x00014610
215#define HOST_SEM5_REG 0x00014614
216#define HOST_SEM6_REG 0x00014618
217#define HOST_SEM7_REG 0x0001461c
218#define HOST_SEM4_INFO_REG 0x00014620
219#define HOST_SEM5_INFO_REG 0x00014624
220#define HOST_SEM6_INFO_REG 0x00014628
221#define HOST_SEM7_INFO_REG 0x0001462c
222#define HOSTFN0_LPU0_MBOX0_CMD_STAT 0x00019000
223#define __HOSTFN0_LPU0_MBOX0_INFO_MK 0xfffffffe
224#define __HOSTFN0_LPU0_MBOX0_INFO_SH 1
225#define __HOSTFN0_LPU0_MBOX0_INFO(_v) ((_v) << __HOSTFN0_LPU0_MBOX0_INFO_SH)
226#define __HOSTFN0_LPU0_MBOX0_CMD_STATUS 0x00000001
227#define HOSTFN0_LPU1_MBOX0_CMD_STAT 0x00019004
228#define __HOSTFN0_LPU1_MBOX0_INFO_MK 0xfffffffe
229#define __HOSTFN0_LPU1_MBOX0_INFO_SH 1
230#define __HOSTFN0_LPU1_MBOX0_INFO(_v) ((_v) << __HOSTFN0_LPU1_MBOX0_INFO_SH)
231#define __HOSTFN0_LPU1_MBOX0_CMD_STATUS 0x00000001
232#define LPU0_HOSTFN0_MBOX0_CMD_STAT 0x00019008
233#define __LPU0_HOSTFN0_MBOX0_INFO_MK 0xfffffffe
234#define __LPU0_HOSTFN0_MBOX0_INFO_SH 1
235#define __LPU0_HOSTFN0_MBOX0_INFO(_v) ((_v) << __LPU0_HOSTFN0_MBOX0_INFO_SH)
236#define __LPU0_HOSTFN0_MBOX0_CMD_STATUS 0x00000001
237#define LPU1_HOSTFN0_MBOX0_CMD_STAT 0x0001900c
238#define __LPU1_HOSTFN0_MBOX0_INFO_MK 0xfffffffe
239#define __LPU1_HOSTFN0_MBOX0_INFO_SH 1
240#define __LPU1_HOSTFN0_MBOX0_INFO(_v) ((_v) << __LPU1_HOSTFN0_MBOX0_INFO_SH)
241#define __LPU1_HOSTFN0_MBOX0_CMD_STATUS 0x00000001
242#define HOSTFN1_LPU0_MBOX0_CMD_STAT 0x00019010
243#define __HOSTFN1_LPU0_MBOX0_INFO_MK 0xfffffffe
244#define __HOSTFN1_LPU0_MBOX0_INFO_SH 1
245#define __HOSTFN1_LPU0_MBOX0_INFO(_v) ((_v) << __HOSTFN1_LPU0_MBOX0_INFO_SH)
246#define __HOSTFN1_LPU0_MBOX0_CMD_STATUS 0x00000001
247#define HOSTFN1_LPU1_MBOX0_CMD_STAT 0x00019014
248#define __HOSTFN1_LPU1_MBOX0_INFO_MK 0xfffffffe
249#define __HOSTFN1_LPU1_MBOX0_INFO_SH 1
250#define __HOSTFN1_LPU1_MBOX0_INFO(_v) ((_v) << __HOSTFN1_LPU1_MBOX0_INFO_SH)
251#define __HOSTFN1_LPU1_MBOX0_CMD_STATUS 0x00000001
252#define LPU0_HOSTFN1_MBOX0_CMD_STAT 0x00019018
253#define __LPU0_HOSTFN1_MBOX0_INFO_MK 0xfffffffe
254#define __LPU0_HOSTFN1_MBOX0_INFO_SH 1
255#define __LPU0_HOSTFN1_MBOX0_INFO(_v) ((_v) << __LPU0_HOSTFN1_MBOX0_INFO_SH)
256#define __LPU0_HOSTFN1_MBOX0_CMD_STATUS 0x00000001
257#define LPU1_HOSTFN1_MBOX0_CMD_STAT 0x0001901c
258#define __LPU1_HOSTFN1_MBOX0_INFO_MK 0xfffffffe
259#define __LPU1_HOSTFN1_MBOX0_INFO_SH 1
260#define __LPU1_HOSTFN1_MBOX0_INFO(_v) ((_v) << __LPU1_HOSTFN1_MBOX0_INFO_SH)
261#define __LPU1_HOSTFN1_MBOX0_CMD_STATUS 0x00000001
262#define HOSTFN2_LPU0_MBOX0_CMD_STAT 0x00019150
263#define __HOSTFN2_LPU0_MBOX0_INFO_MK 0xfffffffe
264#define __HOSTFN2_LPU0_MBOX0_INFO_SH 1
265#define __HOSTFN2_LPU0_MBOX0_INFO(_v) ((_v) << __HOSTFN2_LPU0_MBOX0_INFO_SH)
266#define __HOSTFN2_LPU0_MBOX0_CMD_STATUS 0x00000001
267#define HOSTFN2_LPU1_MBOX0_CMD_STAT 0x00019154
268#define __HOSTFN2_LPU1_MBOX0_INFO_MK 0xfffffffe
269#define __HOSTFN2_LPU1_MBOX0_INFO_SH 1
270#define __HOSTFN2_LPU1_MBOX0_INFO(_v) ((_v) << __HOSTFN2_LPU1_MBOX0_INFO_SH)
271#define __HOSTFN2_LPU1_MBOX0BOX0_CMD_STATUS 0x00000001
272#define LPU0_HOSTFN2_MBOX0_CMD_STAT 0x00019158
273#define __LPU0_HOSTFN2_MBOX0_INFO_MK 0xfffffffe
274#define __LPU0_HOSTFN2_MBOX0_INFO_SH 1
275#define __LPU0_HOSTFN2_MBOX0_INFO(_v) ((_v) << __LPU0_HOSTFN2_MBOX0_INFO_SH)
276#define __LPU0_HOSTFN2_MBOX0_CMD_STATUS 0x00000001
277#define LPU1_HOSTFN2_MBOX0_CMD_STAT 0x0001915c
278#define __LPU1_HOSTFN2_MBOX0_INFO_MK 0xfffffffe
279#define __LPU1_HOSTFN2_MBOX0_INFO_SH 1
280#define __LPU1_HOSTFN2_MBOX0_INFO(_v) ((_v) << __LPU1_HOSTFN2_MBOX0_INFO_SH)
281#define __LPU1_HOSTFN2_MBOX0_CMD_STATUS 0x00000001
282#define HOSTFN3_LPU0_MBOX0_CMD_STAT 0x00019160
283#define __HOSTFN3_LPU0_MBOX0_INFO_MK 0xfffffffe
284#define __HOSTFN3_LPU0_MBOX0_INFO_SH 1
285#define __HOSTFN3_LPU0_MBOX0_INFO(_v) ((_v) << __HOSTFN3_LPU0_MBOX0_INFO_SH)
286#define __HOSTFN3_LPU0_MBOX0_CMD_STATUS 0x00000001
287#define HOSTFN3_LPU1_MBOX0_CMD_STAT 0x00019164
288#define __HOSTFN3_LPU1_MBOX0_INFO_MK 0xfffffffe
289#define __HOSTFN3_LPU1_MBOX0_INFO_SH 1
290#define __HOSTFN3_LPU1_MBOX0_INFO(_v) ((_v) << __HOSTFN3_LPU1_MBOX0_INFO_SH)
291#define __HOSTFN3_LPU1_MBOX0_CMD_STATUS 0x00000001
292#define LPU0_HOSTFN3_MBOX0_CMD_STAT 0x00019168
293#define __LPU0_HOSTFN3_MBOX0_INFO_MK 0xfffffffe
294#define __LPU0_HOSTFN3_MBOX0_INFO_SH 1
295#define __LPU0_HOSTFN3_MBOX0_INFO(_v) ((_v) << __LPU0_HOSTFN3_MBOX0_INFO_SH)
296#define __LPU0_HOSTFN3_MBOX0_CMD_STATUS 0x00000001
297#define LPU1_HOSTFN3_MBOX0_CMD_STAT 0x0001916c
298#define __LPU1_HOSTFN3_MBOX0_INFO_MK 0xfffffffe
299#define __LPU1_HOSTFN3_MBOX0_INFO_SH 1
300#define __LPU1_HOSTFN3_MBOX0_INFO(_v) ((_v) << __LPU1_HOSTFN3_MBOX0_INFO_SH)
301#define __LPU1_HOSTFN3_MBOX0_CMD_STATUS 0x00000001
302#define FW_INIT_HALT_P0 0x000191ac
303#define __FW_INIT_HALT_P 0x00000001
304#define FW_INIT_HALT_P1 0x000191bc
305#define CPE_PI_PTR_Q0 0x00038000
306#define __CPE_PI_UNUSED_MK 0xffff0000
307#define __CPE_PI_UNUSED_SH 16
308#define __CPE_PI_UNUSED(_v) ((_v) << __CPE_PI_UNUSED_SH)
309#define __CPE_PI_PTR 0x0000ffff
310#define CPE_PI_PTR_Q1 0x00038040
311#define CPE_CI_PTR_Q0 0x00038004
312#define __CPE_CI_UNUSED_MK 0xffff0000
313#define __CPE_CI_UNUSED_SH 16
314#define __CPE_CI_UNUSED(_v) ((_v) << __CPE_CI_UNUSED_SH)
315#define __CPE_CI_PTR 0x0000ffff
316#define CPE_CI_PTR_Q1 0x00038044
317#define CPE_DEPTH_Q0 0x00038008
318#define __CPE_DEPTH_UNUSED_MK 0xf8000000
319#define __CPE_DEPTH_UNUSED_SH 27
320#define __CPE_DEPTH_UNUSED(_v) ((_v) << __CPE_DEPTH_UNUSED_SH)
321#define __CPE_MSIX_VEC_INDEX_MK 0x07ff0000
322#define __CPE_MSIX_VEC_INDEX_SH 16
323#define __CPE_MSIX_VEC_INDEX(_v) ((_v) << __CPE_MSIX_VEC_INDEX_SH)
324#define __CPE_DEPTH 0x0000ffff
325#define CPE_DEPTH_Q1 0x00038048
326#define CPE_QCTRL_Q0 0x0003800c
327#define __CPE_CTRL_UNUSED30_MK 0xfc000000
328#define __CPE_CTRL_UNUSED30_SH 26
329#define __CPE_CTRL_UNUSED30(_v) ((_v) << __CPE_CTRL_UNUSED30_SH)
330#define __CPE_FUNC_INT_CTRL_MK 0x03000000
331#define __CPE_FUNC_INT_CTRL_SH 24
332#define __CPE_FUNC_INT_CTRL(_v) ((_v) << __CPE_FUNC_INT_CTRL_SH)
333enum {
334 __CPE_FUNC_INT_CTRL_DISABLE = 0x0,
335 __CPE_FUNC_INT_CTRL_F2NF = 0x1,
336 __CPE_FUNC_INT_CTRL_3QUART = 0x2,
337 __CPE_FUNC_INT_CTRL_HALF = 0x3,
338};
339#define __CPE_CTRL_UNUSED20_MK 0x00f00000
340#define __CPE_CTRL_UNUSED20_SH 20
341#define __CPE_CTRL_UNUSED20(_v) ((_v) << __CPE_CTRL_UNUSED20_SH)
342#define __CPE_SCI_TH_MK 0x000f0000
343#define __CPE_SCI_TH_SH 16
344#define __CPE_SCI_TH(_v) ((_v) << __CPE_SCI_TH_SH)
345#define __CPE_CTRL_UNUSED10_MK 0x0000c000
346#define __CPE_CTRL_UNUSED10_SH 14
347#define __CPE_CTRL_UNUSED10(_v) ((_v) << __CPE_CTRL_UNUSED10_SH)
348#define __CPE_ACK_PENDING 0x00002000
349#define __CPE_CTRL_UNUSED40_MK 0x00001c00
350#define __CPE_CTRL_UNUSED40_SH 10
351#define __CPE_CTRL_UNUSED40(_v) ((_v) << __CPE_CTRL_UNUSED40_SH)
352#define __CPE_PCIEID_MK 0x00000300
353#define __CPE_PCIEID_SH 8
354#define __CPE_PCIEID(_v) ((_v) << __CPE_PCIEID_SH)
355#define __CPE_CTRL_UNUSED00_MK 0x000000fe
356#define __CPE_CTRL_UNUSED00_SH 1
357#define __CPE_CTRL_UNUSED00(_v) ((_v) << __CPE_CTRL_UNUSED00_SH)
358#define __CPE_ESIZE 0x00000001
359#define CPE_QCTRL_Q1 0x0003804c
360#define __CPE_CTRL_UNUSED31_MK 0xfc000000
361#define __CPE_CTRL_UNUSED31_SH 26
362#define __CPE_CTRL_UNUSED31(_v) ((_v) << __CPE_CTRL_UNUSED31_SH)
363#define __CPE_CTRL_UNUSED21_MK 0x00f00000
364#define __CPE_CTRL_UNUSED21_SH 20
365#define __CPE_CTRL_UNUSED21(_v) ((_v) << __CPE_CTRL_UNUSED21_SH)
366#define __CPE_CTRL_UNUSED11_MK 0x0000c000
367#define __CPE_CTRL_UNUSED11_SH 14
368#define __CPE_CTRL_UNUSED11(_v) ((_v) << __CPE_CTRL_UNUSED11_SH)
369#define __CPE_CTRL_UNUSED41_MK 0x00001c00
370#define __CPE_CTRL_UNUSED41_SH 10
371#define __CPE_CTRL_UNUSED41(_v) ((_v) << __CPE_CTRL_UNUSED41_SH)
372#define __CPE_CTRL_UNUSED01_MK 0x000000fe
373#define __CPE_CTRL_UNUSED01_SH 1
374#define __CPE_CTRL_UNUSED01(_v) ((_v) << __CPE_CTRL_UNUSED01_SH)
375#define RME_PI_PTR_Q0 0x00038020
376#define __LATENCY_TIME_STAMP_MK 0xffff0000
377#define __LATENCY_TIME_STAMP_SH 16
378#define __LATENCY_TIME_STAMP(_v) ((_v) << __LATENCY_TIME_STAMP_SH)
379#define __RME_PI_PTR 0x0000ffff
380#define RME_PI_PTR_Q1 0x00038060
381#define RME_CI_PTR_Q0 0x00038024
382#define __DELAY_TIME_STAMP_MK 0xffff0000
383#define __DELAY_TIME_STAMP_SH 16
384#define __DELAY_TIME_STAMP(_v) ((_v) << __DELAY_TIME_STAMP_SH)
385#define __RME_CI_PTR 0x0000ffff
386#define RME_CI_PTR_Q1 0x00038064
387#define RME_DEPTH_Q0 0x00038028
388#define __RME_DEPTH_UNUSED_MK 0xf8000000
389#define __RME_DEPTH_UNUSED_SH 27
390#define __RME_DEPTH_UNUSED(_v) ((_v) << __RME_DEPTH_UNUSED_SH)
391#define __RME_MSIX_VEC_INDEX_MK 0x07ff0000
392#define __RME_MSIX_VEC_INDEX_SH 16
393#define __RME_MSIX_VEC_INDEX(_v) ((_v) << __RME_MSIX_VEC_INDEX_SH)
394#define __RME_DEPTH 0x0000ffff
395#define RME_DEPTH_Q1 0x00038068
396#define RME_QCTRL_Q0 0x0003802c
397#define __RME_INT_LATENCY_TIMER_MK 0xff000000
398#define __RME_INT_LATENCY_TIMER_SH 24
399#define __RME_INT_LATENCY_TIMER(_v) ((_v) << __RME_INT_LATENCY_TIMER_SH)
400#define __RME_INT_DELAY_TIMER_MK 0x00ff0000
401#define __RME_INT_DELAY_TIMER_SH 16
402#define __RME_INT_DELAY_TIMER(_v) ((_v) << __RME_INT_DELAY_TIMER_SH)
403#define __RME_INT_DELAY_DISABLE 0x00008000
404#define __RME_DLY_DELAY_DISABLE 0x00004000
405#define __RME_ACK_PENDING 0x00002000
406#define __RME_FULL_INTERRUPT_DISABLE 0x00001000
407#define __RME_CTRL_UNUSED10_MK 0x00000c00
408#define __RME_CTRL_UNUSED10_SH 10
409#define __RME_CTRL_UNUSED10(_v) ((_v) << __RME_CTRL_UNUSED10_SH)
410#define __RME_PCIEID_MK 0x00000300
411#define __RME_PCIEID_SH 8
412#define __RME_PCIEID(_v) ((_v) << __RME_PCIEID_SH)
413#define __RME_CTRL_UNUSED00_MK 0x000000fe
414#define __RME_CTRL_UNUSED00_SH 1
415#define __RME_CTRL_UNUSED00(_v) ((_v) << __RME_CTRL_UNUSED00_SH)
416#define __RME_ESIZE 0x00000001
417#define RME_QCTRL_Q1 0x0003806c
418#define __RME_CTRL_UNUSED11_MK 0x00000c00
419#define __RME_CTRL_UNUSED11_SH 10
420#define __RME_CTRL_UNUSED11(_v) ((_v) << __RME_CTRL_UNUSED11_SH)
421#define __RME_CTRL_UNUSED01_MK 0x000000fe
422#define __RME_CTRL_UNUSED01_SH 1
423#define __RME_CTRL_UNUSED01(_v) ((_v) << __RME_CTRL_UNUSED01_SH)
424#define PSS_CTL_REG 0x00018800
425#define __PSS_I2C_CLK_DIV_MK 0x007f0000
426#define __PSS_I2C_CLK_DIV_SH 16
427#define __PSS_I2C_CLK_DIV(_v) ((_v) << __PSS_I2C_CLK_DIV_SH)
428#define __PSS_LMEM_INIT_DONE 0x00001000
429#define __PSS_LMEM_RESET 0x00000200
430#define __PSS_LMEM_INIT_EN 0x00000100
431#define __PSS_LPU1_RESET 0x00000002
432#define __PSS_LPU0_RESET 0x00000001
433#define PSS_ERR_STATUS_REG 0x00018810
434#define __PSS_LPU1_TCM_READ_ERR 0x00200000
435#define __PSS_LPU0_TCM_READ_ERR 0x00100000
436#define __PSS_LMEM5_CORR_ERR 0x00080000
437#define __PSS_LMEM4_CORR_ERR 0x00040000
438#define __PSS_LMEM3_CORR_ERR 0x00020000
439#define __PSS_LMEM2_CORR_ERR 0x00010000
440#define __PSS_LMEM1_CORR_ERR 0x00008000
441#define __PSS_LMEM0_CORR_ERR 0x00004000
442#define __PSS_LMEM5_UNCORR_ERR 0x00002000
443#define __PSS_LMEM4_UNCORR_ERR 0x00001000
444#define __PSS_LMEM3_UNCORR_ERR 0x00000800
445#define __PSS_LMEM2_UNCORR_ERR 0x00000400
446#define __PSS_LMEM1_UNCORR_ERR 0x00000200
447#define __PSS_LMEM0_UNCORR_ERR 0x00000100
448#define __PSS_BAL_PERR 0x00000080
449#define __PSS_DIP_IF_ERR 0x00000040
450#define __PSS_IOH_IF_ERR 0x00000020
451#define __PSS_TDS_IF_ERR 0x00000010
452#define __PSS_RDS_IF_ERR 0x00000008
453#define __PSS_SGM_IF_ERR 0x00000004
454#define __PSS_LPU1_RAM_ERR 0x00000002
455#define __PSS_LPU0_RAM_ERR 0x00000001
456#define ERR_SET_REG 0x00018818
457#define __PSS_ERR_STATUS_SET 0x003fffff
458#define PMM_1T_RESET_REG_P0 0x0002381c
459#define __PMM_1T_RESET_P 0x00000001
460#define PMM_1T_RESET_REG_P1 0x00023c1c
461#define HQM_QSET0_RXQ_DRBL_P0 0x00038000
462#define __RXQ0_ADD_VECTORS_P 0x80000000
463#define __RXQ0_STOP_P 0x40000000
464#define __RXQ0_PRD_PTR_P 0x0000ffff
465#define HQM_QSET1_RXQ_DRBL_P0 0x00038080
466#define __RXQ1_ADD_VECTORS_P 0x80000000
467#define __RXQ1_STOP_P 0x40000000
468#define __RXQ1_PRD_PTR_P 0x0000ffff
469#define HQM_QSET0_RXQ_DRBL_P1 0x0003c000
470#define HQM_QSET1_RXQ_DRBL_P1 0x0003c080
471#define HQM_QSET0_TXQ_DRBL_P0 0x00038020
472#define __TXQ0_ADD_VECTORS_P 0x80000000
473#define __TXQ0_STOP_P 0x40000000
474#define __TXQ0_PRD_PTR_P 0x0000ffff
475#define HQM_QSET1_TXQ_DRBL_P0 0x000380a0
476#define __TXQ1_ADD_VECTORS_P 0x80000000
477#define __TXQ1_STOP_P 0x40000000
478#define __TXQ1_PRD_PTR_P 0x0000ffff
479#define HQM_QSET0_TXQ_DRBL_P1 0x0003c020
480#define HQM_QSET1_TXQ_DRBL_P1 0x0003c0a0
481#define HQM_QSET0_IB_DRBL_1_P0 0x00038040
482#define __IB1_0_ACK_P 0x80000000
483#define __IB1_0_DISABLE_P 0x40000000
484#define __IB1_0_NUM_OF_ACKED_EVENTS_P 0x0000ffff
485#define HQM_QSET1_IB_DRBL_1_P0 0x000380c0
486#define __IB1_1_ACK_P 0x80000000
487#define __IB1_1_DISABLE_P 0x40000000
488#define __IB1_1_NUM_OF_ACKED_EVENTS_P 0x0000ffff
489#define HQM_QSET0_IB_DRBL_1_P1 0x0003c040
490#define HQM_QSET1_IB_DRBL_1_P1 0x0003c0c0
491#define HQM_QSET0_IB_DRBL_2_P0 0x00038060
492#define __IB2_0_ACK_P 0x80000000
493#define __IB2_0_DISABLE_P 0x40000000
494#define __IB2_0_NUM_OF_ACKED_EVENTS_P 0x0000ffff
495#define HQM_QSET1_IB_DRBL_2_P0 0x000380e0
496#define __IB2_1_ACK_P 0x80000000
497#define __IB2_1_DISABLE_P 0x40000000
498#define __IB2_1_NUM_OF_ACKED_EVENTS_P 0x0000ffff
499#define HQM_QSET0_IB_DRBL_2_P1 0x0003c060
500#define HQM_QSET1_IB_DRBL_2_P1 0x0003c0e0
501
502
503/*
504 * These definitions are either in error/missing in spec. Its auto-generated
505 * from hard coded values in regparse.pl.
506 */
507#define __EMPHPOST_AT_4G_MK_FIX 0x0000001c
508#define __EMPHPOST_AT_4G_SH_FIX 0x00000002
509#define __EMPHPRE_AT_4G_FIX 0x00000003
510#define __SFP_TXRATE_EN_FIX 0x00000100
511#define __SFP_RXRATE_EN_FIX 0x00000080
512
513
514/*
515 * These register definitions are auto-generated from hard coded values
516 * in regparse.pl.
517 */
518
519
520/*
521 * These register mapping definitions are auto-generated from mapping tables
522 * in regparse.pl.
523 */
524#define BFA_IOC0_HBEAT_REG HOST_SEM0_INFO_REG
525#define BFA_IOC0_STATE_REG HOST_SEM1_INFO_REG
526#define BFA_IOC1_HBEAT_REG HOST_SEM2_INFO_REG
527#define BFA_IOC1_STATE_REG HOST_SEM3_INFO_REG
528#define BFA_FW_USE_COUNT HOST_SEM4_INFO_REG
529
530#define CPE_DEPTH_Q(__n) \
531 (CPE_DEPTH_Q0 + (__n) * (CPE_DEPTH_Q1 - CPE_DEPTH_Q0))
532#define CPE_QCTRL_Q(__n) \
533 (CPE_QCTRL_Q0 + (__n) * (CPE_QCTRL_Q1 - CPE_QCTRL_Q0))
534#define CPE_PI_PTR_Q(__n) \
535 (CPE_PI_PTR_Q0 + (__n) * (CPE_PI_PTR_Q1 - CPE_PI_PTR_Q0))
536#define CPE_CI_PTR_Q(__n) \
537 (CPE_CI_PTR_Q0 + (__n) * (CPE_CI_PTR_Q1 - CPE_CI_PTR_Q0))
538#define RME_DEPTH_Q(__n) \
539 (RME_DEPTH_Q0 + (__n) * (RME_DEPTH_Q1 - RME_DEPTH_Q0))
540#define RME_QCTRL_Q(__n) \
541 (RME_QCTRL_Q0 + (__n) * (RME_QCTRL_Q1 - RME_QCTRL_Q0))
542#define RME_PI_PTR_Q(__n) \
543 (RME_PI_PTR_Q0 + (__n) * (RME_PI_PTR_Q1 - RME_PI_PTR_Q0))
544#define RME_CI_PTR_Q(__n) \
545 (RME_CI_PTR_Q0 + (__n) * (RME_CI_PTR_Q1 - RME_CI_PTR_Q0))
546#define HQM_QSET_RXQ_DRBL_P0(__n) \
547 (HQM_QSET0_RXQ_DRBL_P0 + (__n) * (HQM_QSET1_RXQ_DRBL_P0 - \
548 HQM_QSET0_RXQ_DRBL_P0))
549#define HQM_QSET_TXQ_DRBL_P0(__n) \
550 (HQM_QSET0_TXQ_DRBL_P0 + (__n) * (HQM_QSET1_TXQ_DRBL_P0 - \
551 HQM_QSET0_TXQ_DRBL_P0))
552#define HQM_QSET_IB_DRBL_1_P0(__n) \
553 (HQM_QSET0_IB_DRBL_1_P0 + (__n) * (HQM_QSET1_IB_DRBL_1_P0 - \
554 HQM_QSET0_IB_DRBL_1_P0))
555#define HQM_QSET_IB_DRBL_2_P0(__n) \
556 (HQM_QSET0_IB_DRBL_2_P0 + (__n) * (HQM_QSET1_IB_DRBL_2_P0 - \
557 HQM_QSET0_IB_DRBL_2_P0))
558#define HQM_QSET_RXQ_DRBL_P1(__n) \
559 (HQM_QSET0_RXQ_DRBL_P1 + (__n) * (HQM_QSET1_RXQ_DRBL_P1 - \
560 HQM_QSET0_RXQ_DRBL_P1))
561#define HQM_QSET_TXQ_DRBL_P1(__n) \
562 (HQM_QSET0_TXQ_DRBL_P1 + (__n) * (HQM_QSET1_TXQ_DRBL_P1 - \
563 HQM_QSET0_TXQ_DRBL_P1))
564#define HQM_QSET_IB_DRBL_1_P1(__n) \
565 (HQM_QSET0_IB_DRBL_1_P1 + (__n) * (HQM_QSET1_IB_DRBL_1_P1 - \
566 HQM_QSET0_IB_DRBL_1_P1))
567#define HQM_QSET_IB_DRBL_2_P1(__n) \
568 (HQM_QSET0_IB_DRBL_2_P1 + (__n) * (HQM_QSET1_IB_DRBL_2_P1 - \
569 HQM_QSET0_IB_DRBL_2_P1))
570
571#define CPE_Q_NUM(__fn, __q) (((__fn) << 2) + (__q))
572#define RME_Q_NUM(__fn, __q) (((__fn) << 2) + (__q))
573#define CPE_Q_MASK(__q) ((__q) & 0x3)
574#define RME_Q_MASK(__q) ((__q) & 0x3)
575
576
577/*
578 * PCI MSI-X vector defines
579 */
580enum {
581 BFA_MSIX_CPE_Q0 = 0,
582 BFA_MSIX_CPE_Q1 = 1,
583 BFA_MSIX_CPE_Q2 = 2,
584 BFA_MSIX_CPE_Q3 = 3,
585 BFA_MSIX_RME_Q0 = 4,
586 BFA_MSIX_RME_Q1 = 5,
587 BFA_MSIX_RME_Q2 = 6,
588 BFA_MSIX_RME_Q3 = 7,
589 BFA_MSIX_LPU_ERR = 8,
590 BFA_MSIX_CT_MAX = 9,
591};
592
593/*
594 * And corresponding host interrupt status bit field defines
595 */
596#define __HFN_INT_CPE_Q0 0x00000001U
597#define __HFN_INT_CPE_Q1 0x00000002U
598#define __HFN_INT_CPE_Q2 0x00000004U
599#define __HFN_INT_CPE_Q3 0x00000008U
600#define __HFN_INT_CPE_Q4 0x00000010U
601#define __HFN_INT_CPE_Q5 0x00000020U
602#define __HFN_INT_CPE_Q6 0x00000040U
603#define __HFN_INT_CPE_Q7 0x00000080U
604#define __HFN_INT_RME_Q0 0x00000100U
605#define __HFN_INT_RME_Q1 0x00000200U
606#define __HFN_INT_RME_Q2 0x00000400U
607#define __HFN_INT_RME_Q3 0x00000800U
608#define __HFN_INT_RME_Q4 0x00001000U
609#define __HFN_INT_RME_Q5 0x00002000U
610#define __HFN_INT_RME_Q6 0x00004000U
611#define __HFN_INT_RME_Q7 0x00008000U
612#define __HFN_INT_ERR_EMC 0x00010000U
613#define __HFN_INT_ERR_LPU0 0x00020000U
614#define __HFN_INT_ERR_LPU1 0x00040000U
615#define __HFN_INT_ERR_PSS 0x00080000U
616#define __HFN_INT_MBOX_LPU0 0x00100000U
617#define __HFN_INT_MBOX_LPU1 0x00200000U
618#define __HFN_INT_MBOX1_LPU0 0x00400000U
619#define __HFN_INT_MBOX1_LPU1 0x00800000U
620#define __HFN_INT_LL_HALT 0x01000000U
621#define __HFN_INT_CPE_MASK 0x000000ffU
622#define __HFN_INT_RME_MASK 0x0000ff00U
623
624
625/*
626 * catapult memory map.
627 */
628#define LL_PGN_HQM0 0x0096
629#define LL_PGN_HQM1 0x0097
630#define PSS_SMEM_PAGE_START 0x8000
631#define PSS_SMEM_PGNUM(_pg0, _ma) ((_pg0) + ((_ma) >> 15))
632#define PSS_SMEM_PGOFF(_ma) ((_ma) & 0x7fff)
633
634/*
635 * End of catapult memory map
636 */
637
638
639#endif /* __BFI_CTREG_H__ */
640
diff --git a/drivers/scsi/bfa/include/bfi/bfi_fabric.h b/drivers/scsi/bfa/include/bfi/bfi_fabric.h
deleted file mode 100644
index c0669ed41078..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_fabric.h
+++ /dev/null
@@ -1,92 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFI_FABRIC_H__
19#define __BFI_FABRIC_H__
20
21#include <bfi/bfi.h>
22
23#pragma pack(1)
24
25enum bfi_fabric_h2i_msgs {
26 BFI_FABRIC_H2I_CREATE_REQ = 1,
27 BFI_FABRIC_H2I_DELETE_REQ = 2,
28 BFI_FABRIC_H2I_SETAUTH = 3,
29};
30
31enum bfi_fabric_i2h_msgs {
32 BFI_FABRIC_I2H_CREATE_RSP = BFA_I2HM(1),
33 BFI_FABRIC_I2H_DELETE_RSP = BFA_I2HM(2),
34 BFI_FABRIC_I2H_SETAUTH_RSP = BFA_I2HM(3),
35 BFI_FABRIC_I2H_ONLINE = BFA_I2HM(4),
36 BFI_FABRIC_I2H_OFFLINE = BFA_I2HM(5),
37};
38
39struct bfi_fabric_create_req_s {
40 bfi_mhdr_t mh; /* common msg header */
41 u8 vf_en; /* virtual fabric enable */
42 u8 rsvd;
43 u16 vf_id; /* virtual fabric ID */
44 wwn_t pwwn; /* port name */
45 wwn_t nwwn; /* node name */
46};
47
48struct bfi_fabric_create_rsp_s {
49 bfi_mhdr_t mh; /* common msg header */
50 u16 bfa_handle; /* host fabric handle */
51 u8 status; /* fabric create status */
52 u8 rsvd;
53};
54
55struct bfi_fabric_delete_req_s {
56 bfi_mhdr_t mh; /* common msg header */
57 u16 fw_handle; /* firmware fabric handle */
58 u16 rsvd;
59};
60
61struct bfi_fabric_delete_rsp_s {
62 bfi_mhdr_t mh; /* common msg header */
63 u16 bfa_handle; /* host fabric handle */
64 u8 status; /* fabric deletion status */
65 u8 rsvd;
66};
67
68#define BFI_FABRIC_AUTHSECRET_LEN 64
69struct bfi_fabric_setauth_req_s {
70 bfi_mhdr_t mh; /* common msg header */
71 u16 fw_handle; /* f/w handle of fabric */
72 u8 algorithm;
73 u8 group;
74 u8 secret[BFI_FABRIC_AUTHSECRET_LEN];
75};
76
77union bfi_fabric_h2i_msg_u {
78 bfi_msg_t *msg;
79 struct bfi_fabric_create_req_s *create_req;
80 struct bfi_fabric_delete_req_s *delete_req;
81};
82
83union bfi_fabric_i2h_msg_u {
84 bfi_msg_t *msg;
85 struct bfi_fabric_create_rsp_s *create_rsp;
86 struct bfi_fabric_delete_rsp_s *delete_rsp;
87};
88
89#pragma pack()
90
91#endif /* __BFI_FABRIC_H__ */
92
diff --git a/drivers/scsi/bfa/include/bfi/bfi_fcpim.h b/drivers/scsi/bfa/include/bfi/bfi_fcpim.h
deleted file mode 100644
index 52c059fb4c3a..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_fcpim.h
+++ /dev/null
@@ -1,301 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFI_FCPIM_H__
19#define __BFI_FCPIM_H__
20
21#include "bfi.h"
22#include <protocol/fcp.h>
23
24#pragma pack(1)
25
26/*
27 * Initiator mode I-T nexus interface defines.
28 */
29
30enum bfi_itnim_h2i {
31 BFI_ITNIM_H2I_CREATE_REQ = 1, /* i-t nexus creation */
32 BFI_ITNIM_H2I_DELETE_REQ = 2, /* i-t nexus deletion */
33};
34
35enum bfi_itnim_i2h {
36 BFI_ITNIM_I2H_CREATE_RSP = BFA_I2HM(1),
37 BFI_ITNIM_I2H_DELETE_RSP = BFA_I2HM(2),
38 BFI_ITNIM_I2H_SLER_EVENT = BFA_I2HM(3),
39};
40
41struct bfi_itnim_create_req_s {
42 struct bfi_mhdr_s mh; /* common msg header */
43 u16 fw_handle; /* f/w handle for itnim */
44 u8 class; /* FC class for IO */
45 u8 seq_rec; /* sequence recovery support */
46 u8 msg_no; /* seq id of the msg */
47};
48
49struct bfi_itnim_create_rsp_s {
50 struct bfi_mhdr_s mh; /* common msg header */
51 u16 bfa_handle; /* bfa handle for itnim */
52 u8 status; /* fcp request status */
53 u8 seq_id; /* seq id of the msg */
54};
55
56struct bfi_itnim_delete_req_s {
57 struct bfi_mhdr_s mh; /* common msg header */
58 u16 fw_handle; /* f/w itnim handle */
59 u8 seq_id; /* seq id of the msg */
60 u8 rsvd;
61};
62
63struct bfi_itnim_delete_rsp_s {
64 struct bfi_mhdr_s mh; /* common msg header */
65 u16 bfa_handle; /* bfa handle for itnim */
66 u8 status; /* fcp request status */
67 u8 seq_id; /* seq id of the msg */
68};
69
70struct bfi_itnim_sler_event_s {
71 struct bfi_mhdr_s mh; /* common msg header */
72 u16 bfa_handle; /* bfa handle for itnim */
73 u16 rsvd;
74};
75
76union bfi_itnim_h2i_msg_u {
77 struct bfi_itnim_create_req_s *create_req;
78 struct bfi_itnim_delete_req_s *delete_req;
79 struct bfi_msg_s *msg;
80};
81
82union bfi_itnim_i2h_msg_u {
83 struct bfi_itnim_create_rsp_s *create_rsp;
84 struct bfi_itnim_delete_rsp_s *delete_rsp;
85 struct bfi_itnim_sler_event_s *sler_event;
86 struct bfi_msg_s *msg;
87};
88
89/*
90 * Initiator mode IO interface defines.
91 */
92
93enum bfi_ioim_h2i {
94 BFI_IOIM_H2I_IOABORT_REQ = 1, /* IO abort request */
95 BFI_IOIM_H2I_IOCLEANUP_REQ = 2, /* IO cleanup request */
96};
97
98enum bfi_ioim_i2h {
99 BFI_IOIM_I2H_IO_RSP = BFA_I2HM(1), /* non-fp IO response */
100 BFI_IOIM_I2H_IOABORT_RSP = BFA_I2HM(2),/* ABORT rsp */
101};
102
103/**
104 * IO command DIF info
105 */
106struct bfi_ioim_dif_s {
107 u32 dif_info[4];
108};
109
110/**
111 * FCP IO messages overview
112 *
113 * @note
114 * - Max CDB length supported is 64 bytes.
115 * - SCSI Linked commands and SCSI bi-directional Commands not
116 * supported.
117 *
118 */
119struct bfi_ioim_req_s {
120 struct bfi_mhdr_s mh; /* Common msg header */
121 u16 io_tag; /* I/O tag */
122 u16 rport_hdl; /* itnim/rport firmware handle */
123 struct fcp_cmnd_s cmnd; /* IO request info */
124
125 /**
126 * SG elements array within the IO request must be double word
127 * aligned. This aligment is required to optimize SGM setup for the IO.
128 */
129 struct bfi_sge_s sges[BFI_SGE_INLINE_MAX];
130 u8 io_timeout;
131 u8 dif_en;
132 u8 rsvd_a[2];
133 struct bfi_ioim_dif_s dif;
134};
135
136/**
137 * This table shows various IO status codes from firmware and their
138 * meaning. Host driver can use these status codes to further process
139 * IO completions.
140 *
141 * BFI_IOIM_STS_OK : IO completed with error free SCSI &
142 * transport status.
143 * - io-tag can be reused.
144 *
145 * BFA_IOIM_STS_SCSI_ERR : IO completed with scsi error.
146 * - io-tag can be reused.
147 *
148 * BFI_IOIM_STS_HOST_ABORTED : IO was aborted successfully due to
149 * host request.
150 * - io-tag cannot be reused yet.
151 *
152 * BFI_IOIM_STS_ABORTED : IO was aborted successfully
153 * internally by f/w.
154 * - io-tag cannot be reused yet.
155 *
156 * BFI_IOIM_STS_TIMEDOUT : IO timedout and ABTS/RRQ is happening
157 * in the firmware and
158 * - io-tag cannot be reused yet.
159 *
160 * BFI_IOIM_STS_SQER_NEEDED : Firmware could not recover the IO
161 * with sequence level error
162 * logic and hence host needs to retry
163 * this IO with a different IO tag
164 * - io-tag cannot be used yet.
165 *
166 * BFI_IOIM_STS_NEXUS_ABORT : Second Level Error Recovery from host
167 * is required because 2 consecutive ABTS
168 * timedout and host needs logout and
169 * re-login with the target
170 * - io-tag cannot be used yet.
171 *
172 * BFI_IOIM_STS_UNDERRUN : IO completed with SCSI status good,
173 * but the data tranferred is less than
174 * the fcp data length in the command.
175 * ex. SCSI INQUIRY where transferred
176 * data length and residue count in FCP
177 * response accounts for total fcp-dl
178 * - io-tag can be reused.
179 *
180 * BFI_IOIM_STS_OVERRUN : IO completed with SCSI status good,
181 * but the data transerred is more than
182 * fcp data length in the command. ex.
183 * TAPE IOs where blocks can of unequal
184 * lengths.
185 * - io-tag can be reused.
186 *
187 * BFI_IOIM_STS_RES_FREE : Firmware has completed using io-tag
188 * during abort process
189 * - io-tag can be reused.
190 *
191 * BFI_IOIM_STS_PROTO_ERR : Firmware detected a protocol error.
192 * ex target sent more data than
193 * requested, or there was data frame
194 * loss and other reasons
195 * - io-tag cannot be used yet.
196 *
197 * BFI_IOIM_STS_DIF_ERR : Firwmare detected DIF error. ex: DIF
198 * CRC err or Ref Tag err or App tag err.
199 * - io-tag can be reused.
200 *
201 * BFA_IOIM_STS_TSK_MGT_ABORT : IO was aborted because of Task
202 * Management command from the host
203 * - io-tag can be reused.
204 *
205 * BFI_IOIM_STS_UTAG : Firmware does not know about this
206 * io_tag.
207 * - io-tag can be reused.
208 */
209enum bfi_ioim_status {
210 BFI_IOIM_STS_OK = 0,
211 BFI_IOIM_STS_HOST_ABORTED = 1,
212 BFI_IOIM_STS_ABORTED = 2,
213 BFI_IOIM_STS_TIMEDOUT = 3,
214 BFI_IOIM_STS_RES_FREE = 4,
215 BFI_IOIM_STS_SQER_NEEDED = 5,
216 BFI_IOIM_STS_PROTO_ERR = 6,
217 BFI_IOIM_STS_UTAG = 7,
218 BFI_IOIM_STS_PATHTOV = 8,
219};
220
221#define BFI_IOIM_SNSLEN (256)
222/**
223 * I/O response message
224 */
225struct bfi_ioim_rsp_s {
226 struct bfi_mhdr_s mh; /* common msg header */
227 u16 io_tag; /* completed IO tag */
228 u16 bfa_rport_hndl; /* releated rport handle */
229 u8 io_status; /* IO completion status */
230 u8 reuse_io_tag; /* IO tag can be reused */
231 u16 abort_tag; /* host abort request tag */
232 u8 scsi_status; /* scsi status from target */
233 u8 sns_len; /* scsi sense length */
234 u8 resid_flags; /* IO residue flags */
235 u8 rsvd_a;
236 u32 residue; /* IO residual length in bytes */
237 u32 rsvd_b[3];
238};
239
240struct bfi_ioim_abort_req_s {
241 struct bfi_mhdr_s mh; /* Common msg header */
242 u16 io_tag; /* I/O tag */
243 u16 abort_tag; /* unique request tag */
244};
245
246/*
247 * Initiator mode task management command interface defines.
248 */
249
250enum bfi_tskim_h2i {
251 BFI_TSKIM_H2I_TM_REQ = 1, /* task-mgmt command */
252 BFI_TSKIM_H2I_ABORT_REQ = 2, /* task-mgmt command */
253};
254
255enum bfi_tskim_i2h {
256 BFI_TSKIM_I2H_TM_RSP = BFA_I2HM(1),
257};
258
259struct bfi_tskim_req_s {
260 struct bfi_mhdr_s mh; /* Common msg header */
261 u16 tsk_tag; /* task management tag */
262 u16 itn_fhdl; /* itn firmware handle */
263 lun_t lun; /* LU number */
264 u8 tm_flags; /* see fcp_tm_cmnd_t */
265 u8 t_secs; /* Timeout value in seconds */
266 u8 rsvd[2];
267};
268
269struct bfi_tskim_abortreq_s {
270 struct bfi_mhdr_s mh; /* Common msg header */
271 u16 tsk_tag; /* task management tag */
272 u16 rsvd;
273};
274
275enum bfi_tskim_status {
276 /*
277 * Following are FCP-4 spec defined status codes,
278 * **DO NOT CHANGE THEM **
279 */
280 BFI_TSKIM_STS_OK = 0,
281 BFI_TSKIM_STS_NOT_SUPP = 4,
282 BFI_TSKIM_STS_FAILED = 5,
283
284 /**
285 * Defined by BFA
286 */
287 BFI_TSKIM_STS_TIMEOUT = 10, /* TM request timedout */
288 BFI_TSKIM_STS_ABORTED = 11, /* Aborted on host request */
289};
290
291struct bfi_tskim_rsp_s {
292 struct bfi_mhdr_s mh; /* Common msg header */
293 u16 tsk_tag; /* task mgmt cmnd tag */
294 u8 tsk_status; /* @ref bfi_tskim_status */
295 u8 rsvd;
296};
297
298#pragma pack()
299
300#endif /* __BFI_FCPIM_H__ */
301
diff --git a/drivers/scsi/bfa/include/bfi/bfi_fcxp.h b/drivers/scsi/bfa/include/bfi/bfi_fcxp.h
deleted file mode 100644
index e0e995a32828..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_fcxp.h
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFI_FCXP_H__
19#define __BFI_FCXP_H__
20
21#include "bfi.h"
22
23#pragma pack(1)
24
25enum bfi_fcxp_h2i {
26 BFI_FCXP_H2I_SEND_REQ = 1,
27};
28
29enum bfi_fcxp_i2h {
30 BFI_FCXP_I2H_SEND_RSP = BFA_I2HM(1),
31};
32
33#define BFA_FCXP_MAX_SGES 2
34
35/**
36 * FCXP send request structure
37 */
38struct bfi_fcxp_send_req_s {
39 struct bfi_mhdr_s mh; /* Common msg header */
40 u16 fcxp_tag; /* driver request tag */
41 u16 max_frmsz; /* max send frame size */
42 u16 vf_id; /* vsan tag if applicable */
43 u16 rport_fw_hndl; /* FW Handle for the remote port */
44 u8 class; /* FC class used for req/rsp */
45 u8 rsp_timeout; /* timeout in secs, 0-no response */
46 u8 cts; /* continue sequence */
47 u8 lp_tag; /* lport tag */
48 struct fchs_s fchs; /* request FC header structure */
49 u32 req_len; /* request payload length */
50 u32 rsp_maxlen; /* max response length expected */
51 struct bfi_sge_s req_sge[BFA_FCXP_MAX_SGES]; /* request buf */
52 struct bfi_sge_s rsp_sge[BFA_FCXP_MAX_SGES]; /* response buf */
53};
54
55/**
56 * FCXP send response structure
57 */
58struct bfi_fcxp_send_rsp_s {
59 struct bfi_mhdr_s mh; /* Common msg header */
60 u16 fcxp_tag; /* send request tag */
61 u8 req_status; /* request status */
62 u8 rsvd;
63 u32 rsp_len; /* actual response length */
64 u32 residue_len; /* residual response length */
65 struct fchs_s fchs; /* response FC header structure */
66};
67
68#pragma pack()
69
70#endif /* __BFI_FCXP_H__ */
71
diff --git a/drivers/scsi/bfa/include/bfi/bfi_ioc.h b/drivers/scsi/bfa/include/bfi/bfi_ioc.h
deleted file mode 100644
index 450ded6e9bc2..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_ioc.h
+++ /dev/null
@@ -1,208 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFI_IOC_H__
19#define __BFI_IOC_H__
20
21#include "bfi.h"
22#include <defs/bfa_defs_ioc.h>
23
24#pragma pack(1)
25
26enum bfi_ioc_h2i_msgs {
27 BFI_IOC_H2I_ENABLE_REQ = 1,
28 BFI_IOC_H2I_DISABLE_REQ = 2,
29 BFI_IOC_H2I_GETATTR_REQ = 3,
30 BFI_IOC_H2I_DBG_SYNC = 4,
31 BFI_IOC_H2I_DBG_DUMP = 5,
32};
33
34enum bfi_ioc_i2h_msgs {
35 BFI_IOC_I2H_ENABLE_REPLY = BFA_I2HM(1),
36 BFI_IOC_I2H_DISABLE_REPLY = BFA_I2HM(2),
37 BFI_IOC_I2H_GETATTR_REPLY = BFA_I2HM(3),
38 BFI_IOC_I2H_READY_EVENT = BFA_I2HM(4),
39 BFI_IOC_I2H_HBEAT = BFA_I2HM(5),
40};
41
42/**
43 * BFI_IOC_H2I_GETATTR_REQ message
44 */
45struct bfi_ioc_getattr_req_s {
46 struct bfi_mhdr_s mh;
47 union bfi_addr_u attr_addr;
48};
49
50struct bfi_ioc_attr_s {
51 wwn_t mfg_pwwn; /* Mfg port wwn */
52 wwn_t mfg_nwwn; /* Mfg node wwn */
53 mac_t mfg_mac; /* Mfg mac */
54 u16 rsvd_a;
55 wwn_t pwwn;
56 wwn_t nwwn;
57 mac_t mac; /* PBC or Mfg mac */
58 u16 rsvd_b;
59 char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
60 u8 pcie_gen;
61 u8 pcie_lanes_orig;
62 u8 pcie_lanes;
63 u8 rx_bbcredit; /* receive buffer credits */
64 u32 adapter_prop; /* adapter properties */
65 u16 maxfrsize; /* max receive frame size */
66 char asic_rev;
67 u8 rsvd_c;
68 char fw_version[BFA_VERSION_LEN];
69 char optrom_version[BFA_VERSION_LEN];
70 struct bfa_mfg_vpd_s vpd;
71 u32 card_type; /* card type */
72};
73
74/**
75 * BFI_IOC_I2H_GETATTR_REPLY message
76 */
77struct bfi_ioc_getattr_reply_s {
78 struct bfi_mhdr_s mh; /* Common msg header */
79 u8 status; /* cfg reply status */
80 u8 rsvd[3];
81};
82
83/**
84 * Firmware memory page offsets
85 */
86#define BFI_IOC_SMEM_PG0_CB (0x40)
87#define BFI_IOC_SMEM_PG0_CT (0x180)
88
89/**
90 * Firmware trace offset
91 */
92#define BFI_IOC_TRC_OFF (0x4b00)
93#define BFI_IOC_TRC_ENTS 256
94
95#define BFI_IOC_FW_SIGNATURE (0xbfadbfad)
96#define BFI_IOC_MD5SUM_SZ 4
97struct bfi_ioc_image_hdr_s {
98 u32 signature; /* constant signature */
99 u32 rsvd_a;
100 u32 exec; /* exec vector */
101 u32 param; /* parameters */
102 u32 rsvd_b[4];
103 u32 md5sum[BFI_IOC_MD5SUM_SZ];
104};
105
106/**
107 * BFI_IOC_I2H_READY_EVENT message
108 */
109struct bfi_ioc_rdy_event_s {
110 struct bfi_mhdr_s mh; /* common msg header */
111 u8 init_status; /* init event status */
112 u8 rsvd[3];
113};
114
115struct bfi_ioc_hbeat_s {
116 struct bfi_mhdr_s mh; /* common msg header */
117 u32 hb_count; /* current heart beat count */
118};
119
120/**
121 * IOC hardware/firmware state
122 */
123enum bfi_ioc_state {
124 BFI_IOC_UNINIT = 0, /* not initialized */
125 BFI_IOC_INITING = 1, /* h/w is being initialized */
126 BFI_IOC_HWINIT = 2, /* h/w is initialized */
127 BFI_IOC_CFG = 3, /* IOC configuration in progress */
128 BFI_IOC_OP = 4, /* IOC is operational */
129 BFI_IOC_DISABLING = 5, /* IOC is being disabled */
130 BFI_IOC_DISABLED = 6, /* IOC is disabled */
131 BFI_IOC_CFG_DISABLED = 7, /* IOC is being disabled;transient */
132 BFI_IOC_FAIL = 8, /* IOC heart-beat failure */
133 BFI_IOC_MEMTEST = 9, /* IOC is doing memtest */
134};
135
136#define BFI_IOC_ENDIAN_SIG 0x12345678
137
138enum {
139 BFI_ADAPTER_TYPE_FC = 0x01, /* FC adapters */
140 BFI_ADAPTER_TYPE_MK = 0x0f0000, /* adapter type mask */
141 BFI_ADAPTER_TYPE_SH = 16, /* adapter type shift */
142 BFI_ADAPTER_NPORTS_MK = 0xff00, /* number of ports mask */
143 BFI_ADAPTER_NPORTS_SH = 8, /* number of ports shift */
144 BFI_ADAPTER_SPEED_MK = 0xff, /* adapter speed mask */
145 BFI_ADAPTER_SPEED_SH = 0, /* adapter speed shift */
146 BFI_ADAPTER_PROTO = 0x100000, /* prototype adapaters */
147 BFI_ADAPTER_TTV = 0x200000, /* TTV debug capable */
148 BFI_ADAPTER_UNSUPP = 0x400000, /* unknown adapter type */
149};
150
151#define BFI_ADAPTER_GETP(__prop, __adap_prop) \
152 (((__adap_prop) & BFI_ADAPTER_ ## __prop ## _MK) >> \
153 BFI_ADAPTER_ ## __prop ## _SH)
154#define BFI_ADAPTER_SETP(__prop, __val) \
155 ((__val) << BFI_ADAPTER_ ## __prop ## _SH)
156#define BFI_ADAPTER_IS_PROTO(__adap_type) \
157 ((__adap_type) & BFI_ADAPTER_PROTO)
158#define BFI_ADAPTER_IS_TTV(__adap_type) \
159 ((__adap_type) & BFI_ADAPTER_TTV)
160#define BFI_ADAPTER_IS_UNSUPP(__adap_type) \
161 ((__adap_type) & BFI_ADAPTER_UNSUPP)
162#define BFI_ADAPTER_IS_SPECIAL(__adap_type) \
163 ((__adap_type) & (BFI_ADAPTER_TTV | BFI_ADAPTER_PROTO | \
164 BFI_ADAPTER_UNSUPP))
165
166/**
167 * BFI_IOC_H2I_ENABLE_REQ & BFI_IOC_H2I_DISABLE_REQ messages
168 */
169struct bfi_ioc_ctrl_req_s {
170 struct bfi_mhdr_s mh;
171 u8 ioc_class;
172 u8 rsvd[3];
173};
174
175/**
176 * BFI_IOC_I2H_ENABLE_REPLY & BFI_IOC_I2H_DISABLE_REPLY messages
177 */
178struct bfi_ioc_ctrl_reply_s {
179 struct bfi_mhdr_s mh; /* Common msg header */
180 u8 status; /* enable/disable status */
181 u8 rsvd[3];
182};
183
184#define BFI_IOC_MSGSZ 8
185/**
186 * H2I Messages
187 */
188union bfi_ioc_h2i_msg_u {
189 struct bfi_mhdr_s mh;
190 struct bfi_ioc_ctrl_req_s enable_req;
191 struct bfi_ioc_ctrl_req_s disable_req;
192 struct bfi_ioc_getattr_req_s getattr_req;
193 u32 mboxmsg[BFI_IOC_MSGSZ];
194};
195
196/**
197 * I2H Messages
198 */
199union bfi_ioc_i2h_msg_u {
200 struct bfi_mhdr_s mh;
201 struct bfi_ioc_rdy_event_s rdy_event;
202 u32 mboxmsg[BFI_IOC_MSGSZ];
203};
204
205#pragma pack()
206
207#endif /* __BFI_IOC_H__ */
208
diff --git a/drivers/scsi/bfa/include/bfi/bfi_iocfc.h b/drivers/scsi/bfa/include/bfi/bfi_iocfc.h
deleted file mode 100644
index ccdfcc5d7e0b..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_iocfc.h
+++ /dev/null
@@ -1,179 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFI_IOCFC_H__
19#define __BFI_IOCFC_H__
20
21#include "bfi.h"
22#include <bfi/bfi_pbc.h>
23#include <defs/bfa_defs_ioc.h>
24#include <defs/bfa_defs_iocfc.h>
25#include <defs/bfa_defs_boot.h>
26
27#pragma pack(1)
28
29enum bfi_iocfc_h2i_msgs {
30 BFI_IOCFC_H2I_CFG_REQ = 1,
31 BFI_IOCFC_H2I_GET_STATS_REQ = 2,
32 BFI_IOCFC_H2I_CLEAR_STATS_REQ = 3,
33 BFI_IOCFC_H2I_SET_INTR_REQ = 4,
34 BFI_IOCFC_H2I_UPDATEQ_REQ = 5,
35};
36
37enum bfi_iocfc_i2h_msgs {
38 BFI_IOCFC_I2H_CFG_REPLY = BFA_I2HM(1),
39 BFI_IOCFC_I2H_GET_STATS_RSP = BFA_I2HM(2),
40 BFI_IOCFC_I2H_CLEAR_STATS_RSP = BFA_I2HM(3),
41 BFI_IOCFC_I2H_UPDATEQ_RSP = BFA_I2HM(5),
42};
43
44struct bfi_iocfc_cfg_s {
45 u8 num_cqs; /* Number of CQs to be used */
46 u8 sense_buf_len; /* SCSI sense length */
47 u8 trunk_enabled; /* port trunking enabled */
48 u8 trunk_ports; /* trunk ports bit map */
49 u32 endian_sig; /* endian signature of host */
50
51 /**
52 * Request and response circular queue base addresses, size and
53 * shadow index pointers.
54 */
55 union bfi_addr_u req_cq_ba[BFI_IOC_MAX_CQS];
56 union bfi_addr_u req_shadow_ci[BFI_IOC_MAX_CQS];
57 u16 req_cq_elems[BFI_IOC_MAX_CQS];
58 union bfi_addr_u rsp_cq_ba[BFI_IOC_MAX_CQS];
59 union bfi_addr_u rsp_shadow_pi[BFI_IOC_MAX_CQS];
60 u16 rsp_cq_elems[BFI_IOC_MAX_CQS];
61
62 union bfi_addr_u stats_addr; /* DMA-able address for stats */
63 union bfi_addr_u cfgrsp_addr; /* config response dma address */
64 union bfi_addr_u ioim_snsbase; /* IO sense buffer base address */
65 struct bfa_iocfc_intr_attr_s intr_attr; /* IOC interrupt attributes */
66};
67
68/**
69 * Boot target wwn information for this port. This contains either the stored
70 * or discovered boot target port wwns for the port.
71 */
72struct bfi_iocfc_bootwwns {
73 wwn_t wwn[BFA_BOOT_BOOTLUN_MAX];
74 u8 nwwns;
75 u8 rsvd[7];
76};
77
78struct bfi_iocfc_cfgrsp_s {
79 struct bfa_iocfc_fwcfg_s fwcfg;
80 struct bfa_iocfc_intr_attr_s intr_attr;
81 struct bfi_iocfc_bootwwns bootwwns;
82 struct bfi_pbc_s pbc_cfg;
83};
84
85/**
86 * BFI_IOCFC_H2I_CFG_REQ message
87 */
88struct bfi_iocfc_cfg_req_s {
89 struct bfi_mhdr_s mh;
90 union bfi_addr_u ioc_cfg_dma_addr;
91};
92
93/**
94 * BFI_IOCFC_I2H_CFG_REPLY message
95 */
96struct bfi_iocfc_cfg_reply_s {
97 struct bfi_mhdr_s mh; /* Common msg header */
98 u8 cfg_success; /* cfg reply status */
99 u8 lpu_bm; /* LPUs assigned for this IOC */
100 u8 rsvd[2];
101};
102
103/**
104 * BFI_IOCFC_H2I_GET_STATS_REQ & BFI_IOCFC_H2I_CLEAR_STATS_REQ messages
105 */
106struct bfi_iocfc_stats_req_s {
107 struct bfi_mhdr_s mh; /* msg header */
108 u32 msgtag; /* msgtag for reply */
109};
110
111/**
112 * BFI_IOCFC_I2H_GET_STATS_RSP & BFI_IOCFC_I2H_CLEAR_STATS_RSP messages
113 */
114struct bfi_iocfc_stats_rsp_s {
115 struct bfi_mhdr_s mh; /* common msg header */
116 u8 status; /* reply status */
117 u8 rsvd[3];
118 u32 msgtag; /* msgtag for reply */
119};
120
121/**
122 * BFI_IOCFC_H2I_SET_INTR_REQ message
123 */
124struct bfi_iocfc_set_intr_req_s {
125 struct bfi_mhdr_s mh; /* common msg header */
126 u8 coalesce; /* enable intr coalescing*/
127 u8 rsvd[3];
128 u16 delay; /* delay timer 0..1125us */
129 u16 latency; /* latency timer 0..225us */
130};
131
132/**
133 * BFI_IOCFC_H2I_UPDATEQ_REQ message
134 */
135struct bfi_iocfc_updateq_req_s {
136 struct bfi_mhdr_s mh; /* common msg header */
137 u32 reqq_ba; /* reqq base addr */
138 u32 rspq_ba; /* rspq base addr */
139 u32 reqq_sci; /* reqq shadow ci */
140 u32 rspq_spi; /* rspq shadow pi */
141};
142
143/**
144 * BFI_IOCFC_I2H_UPDATEQ_RSP message
145 */
146struct bfi_iocfc_updateq_rsp_s {
147 struct bfi_mhdr_s mh; /* common msg header */
148 u8 status; /* updateq status */
149 u8 rsvd[3];
150};
151
152/**
153 * H2I Messages
154 */
155union bfi_iocfc_h2i_msg_u {
156 struct bfi_mhdr_s mh;
157 struct bfi_iocfc_cfg_req_s cfg_req;
158 struct bfi_iocfc_stats_req_s stats_get;
159 struct bfi_iocfc_stats_req_s stats_clr;
160 struct bfi_iocfc_updateq_req_s updateq_req;
161 u32 mboxmsg[BFI_IOC_MSGSZ];
162};
163
164/**
165 * I2H Messages
166 */
167union bfi_iocfc_i2h_msg_u {
168 struct bfi_mhdr_s mh;
169 struct bfi_iocfc_cfg_reply_s cfg_reply;
170 struct bfi_iocfc_stats_rsp_s stats_get_rsp;
171 struct bfi_iocfc_stats_rsp_s stats_clr_rsp;
172 struct bfi_iocfc_updateq_rsp_s updateq_rsp;
173 u32 mboxmsg[BFI_IOC_MSGSZ];
174};
175
176#pragma pack()
177
178#endif /* __BFI_IOCFC_H__ */
179
diff --git a/drivers/scsi/bfa/include/bfi/bfi_lport.h b/drivers/scsi/bfa/include/bfi/bfi_lport.h
deleted file mode 100644
index 29010614bac9..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_lport.h
+++ /dev/null
@@ -1,89 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFI_LPORT_H__
19#define __BFI_LPORT_H__
20
21#include <bfi/bfi.h>
22
23#pragma pack(1)
24
25enum bfi_lport_h2i_msgs {
26 BFI_LPORT_H2I_CREATE_REQ = 1,
27 BFI_LPORT_H2I_DELETE_REQ = 2,
28};
29
30enum bfi_lport_i2h_msgs {
31 BFI_LPORT_I2H_CREATE_RSP = BFA_I2HM(1),
32 BFI_LPORT_I2H_DELETE_RSP = BFA_I2HM(2),
33 BFI_LPORT_I2H_ONLINE = BFA_I2HM(3),
34 BFI_LPORT_I2H_OFFLINE = BFA_I2HM(4),
35};
36
37#define BFI_LPORT_MAX_SYNNAME 64
38
39enum bfi_lport_role_e {
40 BFI_LPORT_ROLE_FCPIM = 1,
41 BFI_LPORT_ROLE_FCPTM = 2,
42 BFI_LPORT_ROLE_IPFC = 4,
43};
44
45struct bfi_lport_create_req_s {
46 bfi_mhdr_t mh; /* common msg header */
47 u16 fabric_fwhdl; /* parent fabric instance */
48 u8 roles; /* lport FC-4 roles */
49 u8 rsvd;
50 wwn_t pwwn; /* port name */
51 wwn_t nwwn; /* node name */
52 u8 symname[BFI_LPORT_MAX_SYNNAME];
53};
54
55struct bfi_lport_create_rsp_s {
56 bfi_mhdr_t mh; /* common msg header */
57 u8 status; /* lport creation status */
58 u8 rsvd[3];
59};
60
61struct bfi_lport_delete_req_s {
62 bfi_mhdr_t mh; /* common msg header */
63 u16 fw_handle; /* firmware lport handle */
64 u16 rsvd;
65};
66
67struct bfi_lport_delete_rsp_s {
68 bfi_mhdr_t mh; /* common msg header */
69 u16 bfa_handle; /* host lport handle */
70 u8 status; /* lport deletion status */
71 u8 rsvd;
72};
73
74union bfi_lport_h2i_msg_u {
75 bfi_msg_t *msg;
76 struct bfi_lport_create_req_s *create_req;
77 struct bfi_lport_delete_req_s *delete_req;
78};
79
80union bfi_lport_i2h_msg_u {
81 bfi_msg_t *msg;
82 struct bfi_lport_create_rsp_s *create_rsp;
83 struct bfi_lport_delete_rsp_s *delete_rsp;
84};
85
86#pragma pack()
87
88#endif /* __BFI_LPORT_H__ */
89
diff --git a/drivers/scsi/bfa/include/bfi/bfi_lps.h b/drivers/scsi/bfa/include/bfi/bfi_lps.h
deleted file mode 100644
index 7ed31bbb8696..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_lps.h
+++ /dev/null
@@ -1,104 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFI_LPS_H__
19#define __BFI_LPS_H__
20
21#include <bfi/bfi.h>
22
23#pragma pack(1)
24
25enum bfi_lps_h2i_msgs {
26 BFI_LPS_H2I_LOGIN_REQ = 1,
27 BFI_LPS_H2I_LOGOUT_REQ = 2,
28};
29
30enum bfi_lps_i2h_msgs {
31 BFI_LPS_H2I_LOGIN_RSP = BFA_I2HM(1),
32 BFI_LPS_H2I_LOGOUT_RSP = BFA_I2HM(2),
33 BFI_LPS_H2I_CVL_EVENT = BFA_I2HM(3),
34};
35
36struct bfi_lps_login_req_s {
37 struct bfi_mhdr_s mh; /* common msg header */
38 u8 lp_tag;
39 u8 alpa;
40 u16 pdu_size;
41 wwn_t pwwn;
42 wwn_t nwwn;
43 u8 fdisc;
44 u8 auth_en;
45 u8 rsvd[2];
46};
47
48struct bfi_lps_login_rsp_s {
49 struct bfi_mhdr_s mh; /* common msg header */
50 u8 lp_tag;
51 u8 status;
52 u8 lsrjt_rsn;
53 u8 lsrjt_expl;
54 wwn_t port_name;
55 wwn_t node_name;
56 u16 bb_credit;
57 u8 f_port;
58 u8 npiv_en;
59 u32 lp_pid:24;
60 u32 auth_req:8;
61 mac_t lp_mac;
62 mac_t fcf_mac;
63 u8 ext_status;
64 u8 brcd_switch;/* attached peer is brcd switch */
65};
66
67struct bfi_lps_logout_req_s {
68 struct bfi_mhdr_s mh; /* common msg header */
69 u8 lp_tag;
70 u8 rsvd[3];
71 wwn_t port_name;
72};
73
74struct bfi_lps_logout_rsp_s {
75 struct bfi_mhdr_s mh; /* common msg header */
76 u8 lp_tag;
77 u8 status;
78 u8 rsvd[2];
79};
80
81struct bfi_lps_cvl_event_s {
82 struct bfi_mhdr_s mh; /* common msg header */
83 u8 lp_tag;
84 u8 rsvd[3];
85};
86
87union bfi_lps_h2i_msg_u {
88 struct bfi_mhdr_s *msg;
89 struct bfi_lps_login_req_s *login_req;
90 struct bfi_lps_logout_req_s *logout_req;
91};
92
93union bfi_lps_i2h_msg_u {
94 struct bfi_msg_s *msg;
95 struct bfi_lps_login_rsp_s *login_rsp;
96 struct bfi_lps_logout_rsp_s *logout_rsp;
97 struct bfi_lps_cvl_event_s *cvl_event;
98};
99
100#pragma pack()
101
102#endif /* __BFI_LPS_H__ */
103
104
diff --git a/drivers/scsi/bfa/include/bfi/bfi_pbc.h b/drivers/scsi/bfa/include/bfi/bfi_pbc.h
deleted file mode 100644
index 88a4154c30c0..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_pbc.h
+++ /dev/null
@@ -1,62 +0,0 @@
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 __BFI_PBC_H__
19#define __BFI_PBC_H__
20
21#pragma pack(1)
22
23#define BFI_PBC_MAX_BLUNS 8
24#define BFI_PBC_MAX_VPORTS 16
25
26#define BFI_PBC_PORT_DISABLED 2
27/**
28 * PBC boot lun configuration
29 */
30struct bfi_pbc_blun_s {
31 wwn_t tgt_pwwn;
32 lun_t tgt_lun;
33};
34
35/**
36 * PBC virtual port configuration
37 */
38struct bfi_pbc_vport_s {
39 wwn_t vp_pwwn;
40 wwn_t vp_nwwn;
41};
42
43/**
44 * BFI pre-boot configuration information
45 */
46struct bfi_pbc_s {
47 u8 port_enabled;
48 u8 boot_enabled;
49 u8 nbluns;
50 u8 nvports;
51 u8 port_speed;
52 u8 rsvd_a;
53 u16 hss;
54 wwn_t pbc_pwwn;
55 wwn_t pbc_nwwn;
56 struct bfi_pbc_blun_s blun[BFI_PBC_MAX_BLUNS];
57 struct bfi_pbc_vport_s vport[BFI_PBC_MAX_VPORTS];
58};
59
60#pragma pack()
61
62#endif /* __BFI_PBC_H__ */
diff --git a/drivers/scsi/bfa/include/bfi/bfi_port.h b/drivers/scsi/bfa/include/bfi/bfi_port.h
deleted file mode 100644
index 3ec3bea110ba..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_port.h
+++ /dev/null
@@ -1,115 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFI_PORT_H__
18#define __BFI_PORT_H__
19
20#include <bfi/bfi.h>
21#include <defs/bfa_defs_pport.h>
22
23#pragma pack(1)
24
25enum bfi_port_h2i {
26 BFI_PORT_H2I_ENABLE_REQ = (1),
27 BFI_PORT_H2I_DISABLE_REQ = (2),
28 BFI_PORT_H2I_GET_STATS_REQ = (3),
29 BFI_PORT_H2I_CLEAR_STATS_REQ = (4),
30};
31
32enum bfi_port_i2h {
33 BFI_PORT_I2H_ENABLE_RSP = BFA_I2HM(1),
34 BFI_PORT_I2H_DISABLE_RSP = BFA_I2HM(2),
35 BFI_PORT_I2H_GET_STATS_RSP = BFA_I2HM(3),
36 BFI_PORT_I2H_CLEAR_STATS_RSP = BFA_I2HM(4),
37};
38
39/**
40 * Generic REQ type
41 */
42struct bfi_port_generic_req_s {
43 struct bfi_mhdr_s mh; /* msg header */
44 u32 msgtag; /* msgtag for reply */
45 u32 rsvd;
46};
47
48/**
49 * Generic RSP type
50 */
51struct bfi_port_generic_rsp_s {
52 struct bfi_mhdr_s mh; /* common msg header */
53 u8 status; /* port enable status */
54 u8 rsvd[3];
55 u32 msgtag; /* msgtag for reply */
56};
57
58/**
59 * @todo
60 * BFI_PORT_H2I_ENABLE_REQ
61 */
62
63/**
64 * @todo
65 * BFI_PORT_I2H_ENABLE_RSP
66 */
67
68/**
69 * BFI_PORT_H2I_DISABLE_REQ
70 */
71
72/**
73 * BFI_PORT_I2H_DISABLE_RSP
74 */
75
76/**
77 * BFI_PORT_H2I_GET_STATS_REQ
78 */
79struct bfi_port_get_stats_req_s {
80 struct bfi_mhdr_s mh; /* common msg header */
81 union bfi_addr_u dma_addr;
82};
83
84/**
85 * BFI_PORT_I2H_GET_STATS_RSP
86 */
87
88/**
89 * BFI_PORT_H2I_CLEAR_STATS_REQ
90 */
91
92/**
93 * BFI_PORT_I2H_CLEAR_STATS_RSP
94 */
95
96union bfi_port_h2i_msg_u {
97 struct bfi_mhdr_s mh;
98 struct bfi_port_generic_req_s enable_req;
99 struct bfi_port_generic_req_s disable_req;
100 struct bfi_port_get_stats_req_s getstats_req;
101 struct bfi_port_generic_req_s clearstats_req;
102};
103
104union bfi_port_i2h_msg_u {
105 struct bfi_mhdr_s mh;
106 struct bfi_port_generic_rsp_s enable_rsp;
107 struct bfi_port_generic_rsp_s disable_rsp;
108 struct bfi_port_generic_rsp_s getstats_rsp;
109 struct bfi_port_generic_rsp_s clearstats_rsp;
110};
111
112#pragma pack()
113
114#endif /* __BFI_PORT_H__ */
115
diff --git a/drivers/scsi/bfa/include/bfi/bfi_pport.h b/drivers/scsi/bfa/include/bfi/bfi_pport.h
deleted file mode 100644
index 50dcf45c7470..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_pport.h
+++ /dev/null
@@ -1,118 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFI_PPORT_H__
18#define __BFI_PPORT_H__
19
20#include <bfi/bfi.h>
21#include <defs/bfa_defs_pport.h>
22
23#pragma pack(1)
24
25enum bfi_fcport_h2i {
26 BFI_FCPORT_H2I_ENABLE_REQ = (1),
27 BFI_FCPORT_H2I_DISABLE_REQ = (2),
28 BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ = (3),
29 BFI_FCPORT_H2I_STATS_GET_REQ = (4),
30 BFI_FCPORT_H2I_STATS_CLEAR_REQ = (5),
31};
32
33enum bfi_fcport_i2h {
34 BFI_FCPORT_I2H_ENABLE_RSP = BFA_I2HM(1),
35 BFI_FCPORT_I2H_DISABLE_RSP = BFA_I2HM(2),
36 BFI_FCPORT_I2H_SET_SVC_PARAMS_RSP = BFA_I2HM(3),
37 BFI_FCPORT_I2H_STATS_GET_RSP = BFA_I2HM(4),
38 BFI_FCPORT_I2H_STATS_CLEAR_RSP = BFA_I2HM(5),
39 BFI_FCPORT_I2H_EVENT = BFA_I2HM(6),
40};
41
42/**
43 * Generic REQ type
44 */
45struct bfi_fcport_req_s {
46 struct bfi_mhdr_s mh; /* msg header */
47 u32 msgtag; /* msgtag for reply */
48};
49
50/**
51 * Generic RSP type
52 */
53struct bfi_fcport_rsp_s {
54 struct bfi_mhdr_s mh; /* common msg header */
55 u8 status; /* port enable status */
56 u8 rsvd[3];
57 u32 msgtag; /* msgtag for reply */
58};
59
60/**
61 * BFI_FCPORT_H2I_ENABLE_REQ
62 */
63struct bfi_fcport_enable_req_s {
64 struct bfi_mhdr_s mh; /* msg header */
65 u32 rsvd1;
66 wwn_t nwwn; /* node wwn of physical port */
67 wwn_t pwwn; /* port wwn of physical port */
68 struct bfa_pport_cfg_s port_cfg; /* port configuration */
69 union bfi_addr_u stats_dma_addr; /* DMA address for stats */
70 u32 msgtag; /* msgtag for reply */
71 u32 rsvd2;
72};
73
74/**
75 * BFI_FCPORT_H2I_SET_SVC_PARAMS_REQ
76 */
77struct bfi_fcport_set_svc_params_req_s {
78 struct bfi_mhdr_s mh; /* msg header */
79 u16 tx_bbcredit; /* Tx credits */
80 u16 rsvd;
81};
82
83/**
84 * BFI_FCPORT_I2H_EVENT
85 */
86struct bfi_fcport_event_s {
87 struct bfi_mhdr_s mh; /* common msg header */
88 struct bfa_pport_link_s link_state;
89};
90
91/**
92 * fcport H2I message
93 */
94union bfi_fcport_h2i_msg_u {
95 struct bfi_mhdr_s *mhdr;
96 struct bfi_fcport_enable_req_s *penable;
97 struct bfi_fcport_req_s *pdisable;
98 struct bfi_fcport_set_svc_params_req_s *psetsvcparams;
99 struct bfi_fcport_req_s *pstatsget;
100 struct bfi_fcport_req_s *pstatsclear;
101};
102
103/**
104 * fcport I2H message
105 */
106union bfi_fcport_i2h_msg_u {
107 struct bfi_msg_s *msg;
108 struct bfi_fcport_rsp_s *penable_rsp;
109 struct bfi_fcport_rsp_s *pdisable_rsp;
110 struct bfi_fcport_rsp_s *psetsvcparams_rsp;
111 struct bfi_fcport_rsp_s *pstatsget_rsp;
112 struct bfi_fcport_rsp_s *pstatsclear_rsp;
113 struct bfi_fcport_event_s *event;
114};
115
116#pragma pack()
117
118#endif /* __BFI_PPORT_H__ */
diff --git a/drivers/scsi/bfa/include/bfi/bfi_rport.h b/drivers/scsi/bfa/include/bfi/bfi_rport.h
deleted file mode 100644
index e1cd83b56ec6..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_rport.h
+++ /dev/null
@@ -1,104 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFI_RPORT_H__
19#define __BFI_RPORT_H__
20
21#include <bfi/bfi.h>
22
23#pragma pack(1)
24
25enum bfi_rport_h2i_msgs {
26 BFI_RPORT_H2I_CREATE_REQ = 1,
27 BFI_RPORT_H2I_DELETE_REQ = 2,
28 BFI_RPORT_H2I_SET_SPEED_REQ = 3,
29};
30
31enum bfi_rport_i2h_msgs {
32 BFI_RPORT_I2H_CREATE_RSP = BFA_I2HM(1),
33 BFI_RPORT_I2H_DELETE_RSP = BFA_I2HM(2),
34 BFI_RPORT_I2H_QOS_SCN = BFA_I2HM(3),
35};
36
37struct bfi_rport_create_req_s {
38 struct bfi_mhdr_s mh; /* common msg header */
39 u16 bfa_handle; /* host rport handle */
40 u16 max_frmsz; /* max rcv pdu size */
41 u32 pid:24, /* remote port ID */
42 lp_tag:8; /* local port tag */
43 u32 local_pid:24, /* local port ID */
44 cisc:8;
45 u8 fc_class; /* supported FC classes */
46 u8 vf_en; /* virtual fabric enable */
47 u16 vf_id; /* virtual fabric ID */
48};
49
50struct bfi_rport_create_rsp_s {
51 struct bfi_mhdr_s mh; /* common msg header */
52 u8 status; /* rport creation status */
53 u8 rsvd[3];
54 u16 bfa_handle; /* host rport handle */
55 u16 fw_handle; /* firmware rport handle */
56 struct bfa_rport_qos_attr_s qos_attr; /* QoS Attributes */
57};
58
59struct bfa_rport_speed_req_s {
60 struct bfi_mhdr_s mh; /* common msg header */
61 u16 fw_handle; /* firmware rport handle */
62 u8 speed; /*! rport's speed via RPSC */
63 u8 rsvd;
64};
65
66struct bfi_rport_delete_req_s {
67 struct bfi_mhdr_s mh; /* common msg header */
68 u16 fw_handle; /* firmware rport handle */
69 u16 rsvd;
70};
71
72struct bfi_rport_delete_rsp_s {
73 struct bfi_mhdr_s mh; /* common msg header */
74 u16 bfa_handle; /* host rport handle */
75 u8 status; /* rport deletion status */
76 u8 rsvd;
77};
78
79struct bfi_rport_qos_scn_s {
80 struct bfi_mhdr_s mh; /* common msg header */
81 u16 bfa_handle; /* host rport handle */
82 u16 rsvd;
83 struct bfa_rport_qos_attr_s old_qos_attr; /* Old QoS Attributes */
84 struct bfa_rport_qos_attr_s new_qos_attr; /* New QoS Attributes */
85};
86
87union bfi_rport_h2i_msg_u {
88 struct bfi_msg_s *msg;
89 struct bfi_rport_create_req_s *create_req;
90 struct bfi_rport_delete_req_s *delete_req;
91 struct bfi_rport_speed_req_s *speed_req;
92};
93
94union bfi_rport_i2h_msg_u {
95 struct bfi_msg_s *msg;
96 struct bfi_rport_create_rsp_s *create_rsp;
97 struct bfi_rport_delete_rsp_s *delete_rsp;
98 struct bfi_rport_qos_scn_s *qos_scn_evt;
99};
100
101#pragma pack()
102
103#endif /* __BFI_RPORT_H__ */
104
diff --git a/drivers/scsi/bfa/include/bfi/bfi_uf.h b/drivers/scsi/bfa/include/bfi/bfi_uf.h
deleted file mode 100644
index f328a9e7e622..000000000000
--- a/drivers/scsi/bfa/include/bfi/bfi_uf.h
+++ /dev/null
@@ -1,52 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __BFI_UF_H__
19#define __BFI_UF_H__
20
21#include "bfi.h"
22
23#pragma pack(1)
24
25enum bfi_uf_h2i {
26 BFI_UF_H2I_BUF_POST = 1,
27};
28
29enum bfi_uf_i2h {
30 BFI_UF_I2H_FRM_RCVD = BFA_I2HM(1),
31};
32
33#define BFA_UF_MAX_SGES 2
34
35struct bfi_uf_buf_post_s {
36 struct bfi_mhdr_s mh; /* Common msg header */
37 u16 buf_tag; /* buffer tag */
38 u16 buf_len; /* total buffer length */
39 struct bfi_sge_s sge[BFA_UF_MAX_SGES]; /* buffer DMA SGEs */
40};
41
42struct bfi_uf_frm_rcvd_s {
43 struct bfi_mhdr_s mh; /* Common msg header */
44 u16 buf_tag; /* buffer tag */
45 u16 rsvd;
46 u16 frm_len; /* received frame length */
47 u16 xfr_len; /* tranferred length */
48};
49
50#pragma pack()
51
52#endif /* __BFI_UF_H__ */
diff --git a/drivers/scsi/bfa/include/cna/bfa_cna_trcmod.h b/drivers/scsi/bfa/include/cna/bfa_cna_trcmod.h
deleted file mode 100644
index a75a1f3be315..000000000000
--- a/drivers/scsi/bfa/include/cna/bfa_cna_trcmod.h
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_cna_trcmod.h CNA trace modules
20 */
21
22#ifndef __BFA_CNA_TRCMOD_H__
23#define __BFA_CNA_TRCMOD_H__
24
25#include <cs/bfa_trc.h>
26
27/*
28 * !!! Only append to the enums defined here to avoid any versioning
29 * !!! needed between trace utility and driver version
30 */
31enum {
32 BFA_TRC_CNA_CEE = 1,
33 BFA_TRC_CNA_PORT = 2,
34 BFA_TRC_CNA_IOC = 3,
35 BFA_TRC_CNA_DIAG = 4,
36 BFA_TRC_CNA_IOC_CB = 5,
37 BFA_TRC_CNA_IOC_CT = 6,
38};
39
40#endif /* __BFA_CNA_TRCMOD_H__ */
diff --git a/drivers/scsi/bfa/include/cna/cee/bfa_cee.h b/drivers/scsi/bfa/include/cna/cee/bfa_cee.h
deleted file mode 100644
index 77f297f68046..000000000000
--- a/drivers/scsi/bfa/include/cna/cee/bfa_cee.h
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_CEE_H__
19#define __BFA_CEE_H__
20
21#include <defs/bfa_defs_cee.h>
22#include <bfa_ioc.h>
23#include <cs/bfa_trc.h>
24#include <cs/bfa_log.h>
25
26typedef void (*bfa_cee_get_attr_cbfn_t) (void *dev, bfa_status_t status);
27typedef void (*bfa_cee_get_stats_cbfn_t) (void *dev, bfa_status_t status);
28typedef void (*bfa_cee_reset_stats_cbfn_t) (void *dev, bfa_status_t status);
29typedef void (*bfa_cee_hbfail_cbfn_t) (void *dev, bfa_status_t status);
30
31struct bfa_cee_cbfn_s {
32 bfa_cee_get_attr_cbfn_t get_attr_cbfn;
33 void *get_attr_cbarg;
34 bfa_cee_get_stats_cbfn_t get_stats_cbfn;
35 void *get_stats_cbarg;
36 bfa_cee_reset_stats_cbfn_t reset_stats_cbfn;
37 void *reset_stats_cbarg;
38};
39
40struct bfa_cee_s {
41 void *dev;
42 bfa_boolean_t get_attr_pending;
43 bfa_boolean_t get_stats_pending;
44 bfa_boolean_t reset_stats_pending;
45 bfa_status_t get_attr_status;
46 bfa_status_t get_stats_status;
47 bfa_status_t reset_stats_status;
48 struct bfa_cee_cbfn_s cbfn;
49 struct bfa_ioc_hbfail_notify_s hbfail;
50 struct bfa_trc_mod_s *trcmod;
51 struct bfa_log_mod_s *logmod;
52 struct bfa_cee_attr_s *attr;
53 struct bfa_cee_stats_s *stats;
54 struct bfa_dma_s attr_dma;
55 struct bfa_dma_s stats_dma;
56 struct bfa_ioc_s *ioc;
57 struct bfa_mbox_cmd_s get_cfg_mb;
58 struct bfa_mbox_cmd_s get_stats_mb;
59 struct bfa_mbox_cmd_s reset_stats_mb;
60};
61
62u32 bfa_cee_meminfo(void);
63void bfa_cee_mem_claim(struct bfa_cee_s *cee, u8 *dma_kva,
64 u64 dma_pa);
65void bfa_cee_attach(struct bfa_cee_s *cee, struct bfa_ioc_s *ioc, void *dev,
66 struct bfa_trc_mod_s *trcmod,
67 struct bfa_log_mod_s *logmod);
68void bfa_cee_detach(struct bfa_cee_s *cee);
69bfa_status_t bfa_cee_get_attr(struct bfa_cee_s *cee,
70 struct bfa_cee_attr_s *attr,
71 bfa_cee_get_attr_cbfn_t cbfn, void *cbarg);
72bfa_status_t bfa_cee_get_stats(struct bfa_cee_s *cee,
73 struct bfa_cee_stats_s *stats,
74 bfa_cee_get_stats_cbfn_t cbfn, void *cbarg);
75bfa_status_t bfa_cee_reset_stats(struct bfa_cee_s *cee,
76 bfa_cee_reset_stats_cbfn_t cbfn, void *cbarg);
77#endif /* __BFA_CEE_H__ */
diff --git a/drivers/scsi/bfa/include/cna/port/bfa_port.h b/drivers/scsi/bfa/include/cna/port/bfa_port.h
deleted file mode 100644
index d7babaf97848..000000000000
--- a/drivers/scsi/bfa/include/cna/port/bfa_port.h
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_PORT_H__
19#define __BFA_PORT_H__
20
21#include <defs/bfa_defs_port.h>
22#include <bfa_ioc.h>
23#include <cs/bfa_trc.h>
24#include <cs/bfa_log.h>
25
26typedef void (*bfa_port_stats_cbfn_t) (void *dev, bfa_status_t status);
27typedef void (*bfa_port_endis_cbfn_t) (void *dev, bfa_status_t status);
28
29struct bfa_port_s {
30 void *dev;
31 struct bfa_ioc_s *ioc;
32 struct bfa_trc_mod_s *trcmod;
33 struct bfa_log_mod_s *logmod;
34 u32 msgtag;
35 bfa_boolean_t stats_busy;
36 struct bfa_mbox_cmd_s stats_mb;
37 bfa_port_stats_cbfn_t stats_cbfn;
38 void *stats_cbarg;
39 bfa_status_t stats_status;
40 u32 stats_reset_time;
41 union bfa_pport_stats_u *stats;
42 struct bfa_dma_s stats_dma;
43 bfa_boolean_t endis_pending;
44 struct bfa_mbox_cmd_s endis_mb;
45 bfa_port_endis_cbfn_t endis_cbfn;
46 void *endis_cbarg;
47 bfa_status_t endis_status;
48 struct bfa_ioc_hbfail_notify_s hbfail;
49};
50
51void bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc,
52 void *dev, struct bfa_trc_mod_s *trcmod,
53 struct bfa_log_mod_s *logmod);
54void bfa_port_detach(struct bfa_port_s *port);
55void bfa_port_hbfail(void *arg);
56
57bfa_status_t bfa_port_get_stats(struct bfa_port_s *port,
58 union bfa_pport_stats_u *stats,
59 bfa_port_stats_cbfn_t cbfn, void *cbarg);
60bfa_status_t bfa_port_clear_stats(struct bfa_port_s *port,
61 bfa_port_stats_cbfn_t cbfn, void *cbarg);
62bfa_status_t bfa_port_enable(struct bfa_port_s *port,
63 bfa_port_endis_cbfn_t cbfn, void *cbarg);
64bfa_status_t bfa_port_disable(struct bfa_port_s *port,
65 bfa_port_endis_cbfn_t cbfn, void *cbarg);
66u32 bfa_port_meminfo(void);
67void bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva,
68 u64 dma_pa);
69
70#endif /* __BFA_PORT_H__ */
diff --git a/drivers/scsi/bfa/include/cna/pstats/ethport_defs.h b/drivers/scsi/bfa/include/cna/pstats/ethport_defs.h
deleted file mode 100644
index 1563ee512218..000000000000
--- a/drivers/scsi/bfa/include/cna/pstats/ethport_defs.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved.
4 *
5 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License (GPL) Version 2 as
9 * published by the Free Software Foundation
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 */
16
17#ifndef __ETHPORT_DEFS_H__
18#define __ETHPORT_DEFS_H__
19
20struct bnad_drv_stats {
21 u64 netif_queue_stop;
22 u64 netif_queue_wakeup;
23 u64 tso4;
24 u64 tso6;
25 u64 tso_err;
26 u64 tcpcsum_offload;
27 u64 udpcsum_offload;
28 u64 csum_help;
29 u64 csum_help_err;
30
31 u64 hw_stats_updates;
32 u64 netif_rx_schedule;
33 u64 netif_rx_complete;
34 u64 netif_rx_dropped;
35};
36#endif
diff --git a/drivers/scsi/bfa/include/cna/pstats/phyport_defs.h b/drivers/scsi/bfa/include/cna/pstats/phyport_defs.h
deleted file mode 100644
index eb7548030d0f..000000000000
--- a/drivers/scsi/bfa/include/cna/pstats/phyport_defs.h
+++ /dev/null
@@ -1,218 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved.
4 *
5 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License (GPL) Version 2 as
9 * published by the Free Software Foundation
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 */
16
17#ifndef __PHYPORT_DEFS_H__
18#define __PHYPORT_DEFS_H__
19
20#define BNA_TXF_ID_MAX 64
21#define BNA_RXF_ID_MAX 64
22
23/*
24 * Statistics
25 */
26
27/*
28 * TxF Frame Statistics
29 */
30struct bna_stats_txf {
31 u64 ucast_octets;
32 u64 ucast;
33 u64 ucast_vlan;
34
35 u64 mcast_octets;
36 u64 mcast;
37 u64 mcast_vlan;
38
39 u64 bcast_octets;
40 u64 bcast;
41 u64 bcast_vlan;
42
43 u64 errors;
44 u64 filter_vlan; /* frames filtered due to VLAN */
45 u64 filter_mac_sa; /* frames filtered due to SA check */
46};
47
48/*
49 * RxF Frame Statistics
50 */
51struct bna_stats_rxf {
52 u64 ucast_octets;
53 u64 ucast;
54 u64 ucast_vlan;
55
56 u64 mcast_octets;
57 u64 mcast;
58 u64 mcast_vlan;
59
60 u64 bcast_octets;
61 u64 bcast;
62 u64 bcast_vlan;
63 u64 frame_drops;
64};
65
66/*
67 * FC Tx Frame Statistics
68 */
69struct bna_stats_fc_tx {
70 u64 txf_ucast_octets;
71 u64 txf_ucast;
72 u64 txf_ucast_vlan;
73
74 u64 txf_mcast_octets;
75 u64 txf_mcast;
76 u64 txf_mcast_vlan;
77
78 u64 txf_bcast_octets;
79 u64 txf_bcast;
80 u64 txf_bcast_vlan;
81
82 u64 txf_parity_errors;
83 u64 txf_timeout;
84 u64 txf_fid_parity_errors;
85};
86
87/*
88 * FC Rx Frame Statistics
89 */
90struct bna_stats_fc_rx {
91 u64 rxf_ucast_octets;
92 u64 rxf_ucast;
93 u64 rxf_ucast_vlan;
94
95 u64 rxf_mcast_octets;
96 u64 rxf_mcast;
97 u64 rxf_mcast_vlan;
98
99 u64 rxf_bcast_octets;
100 u64 rxf_bcast;
101 u64 rxf_bcast_vlan;
102};
103
104/*
105 * RAD Frame Statistics
106 */
107struct cna_stats_rad {
108 u64 rx_frames;
109 u64 rx_octets;
110 u64 rx_vlan_frames;
111
112 u64 rx_ucast;
113 u64 rx_ucast_octets;
114 u64 rx_ucast_vlan;
115
116 u64 rx_mcast;
117 u64 rx_mcast_octets;
118 u64 rx_mcast_vlan;
119
120 u64 rx_bcast;
121 u64 rx_bcast_octets;
122 u64 rx_bcast_vlan;
123
124 u64 rx_drops;
125};
126
127/*
128 * BPC Tx Registers
129 */
130struct cna_stats_bpc_tx {
131 u64 tx_pause[8];
132 u64 tx_zero_pause[8]; /* Pause cancellation */
133 u64 tx_first_pause[8]; /* Pause initiation rather
134 *than retention */
135};
136
137/*
138 * BPC Rx Registers
139 */
140struct cna_stats_bpc_rx {
141 u64 rx_pause[8];
142 u64 rx_zero_pause[8]; /* Pause cancellation */
143 u64 rx_first_pause[8]; /* Pause initiation rather
144 *than retention */
145};
146
147/*
148 * MAC Rx Statistics
149 */
150struct cna_stats_mac_rx {
151 u64 frame_64; /* both rx and tx counter */
152 u64 frame_65_127; /* both rx and tx counter */
153 u64 frame_128_255; /* both rx and tx counter */
154 u64 frame_256_511; /* both rx and tx counter */
155 u64 frame_512_1023; /* both rx and tx counter */
156 u64 frame_1024_1518; /* both rx and tx counter */
157 u64 frame_1518_1522; /* both rx and tx counter */
158 u64 rx_bytes;
159 u64 rx_packets;
160 u64 rx_fcs_error;
161 u64 rx_multicast;
162 u64 rx_broadcast;
163 u64 rx_control_frames;
164 u64 rx_pause;
165 u64 rx_unknown_opcode;
166 u64 rx_alignment_error;
167 u64 rx_frame_length_error;
168 u64 rx_code_error;
169 u64 rx_carrier_sense_error;
170 u64 rx_undersize;
171 u64 rx_oversize;
172 u64 rx_fragments;
173 u64 rx_jabber;
174 u64 rx_drop;
175};
176
177/*
178 * MAC Tx Statistics
179 */
180struct cna_stats_mac_tx {
181 u64 tx_bytes;
182 u64 tx_packets;
183 u64 tx_multicast;
184 u64 tx_broadcast;
185 u64 tx_pause;
186 u64 tx_deferral;
187 u64 tx_excessive_deferral;
188 u64 tx_single_collision;
189 u64 tx_muliple_collision;
190 u64 tx_late_collision;
191 u64 tx_excessive_collision;
192 u64 tx_total_collision;
193 u64 tx_pause_honored;
194 u64 tx_drop;
195 u64 tx_jabber;
196 u64 tx_fcs_error;
197 u64 tx_control_frame;
198 u64 tx_oversize;
199 u64 tx_undersize;
200 u64 tx_fragments;
201};
202
203/*
204 * Complete statistics
205 */
206struct bna_stats {
207 struct cna_stats_mac_rx mac_rx_stats;
208 struct cna_stats_bpc_rx bpc_rx_stats;
209 struct cna_stats_rad rad_stats;
210 struct bna_stats_fc_rx fc_rx_stats;
211 struct cna_stats_mac_tx mac_tx_stats;
212 struct cna_stats_bpc_tx bpc_tx_stats;
213 struct bna_stats_fc_tx fc_tx_stats;
214 struct bna_stats_rxf rxf_stats[BNA_TXF_ID_MAX];
215 struct bna_stats_txf txf_stats[BNA_RXF_ID_MAX];
216};
217
218#endif
diff --git a/drivers/scsi/bfa/include/cs/bfa_checksum.h b/drivers/scsi/bfa/include/cs/bfa_checksum.h
deleted file mode 100644
index 650f8d0aaff9..000000000000
--- a/drivers/scsi/bfa/include/cs/bfa_checksum.h
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_checksum.h BFA checksum utilities
20 */
21
22#ifndef __BFA_CHECKSUM_H__
23#define __BFA_CHECKSUM_H__
24
25static inline u32
26bfa_checksum_u32(u32 *buf, int sz)
27{
28 int i, m = sz >> 2;
29 u32 sum = 0;
30
31 for (i = 0; i < m; i++)
32 sum ^= buf[i];
33
34 return sum;
35}
36
37static inline u16
38bfa_checksum_u16(u16 *buf, int sz)
39{
40 int i, m = sz >> 1;
41 u16 sum = 0;
42
43 for (i = 0; i < m; i++)
44 sum ^= buf[i];
45
46 return sum;
47}
48
49static inline u8
50bfa_checksum_u8(u8 *buf, int sz)
51{
52 int i;
53 u8 sum = 0;
54
55 for (i = 0; i < sz; i++)
56 sum ^= buf[i];
57
58 return sum;
59}
60#endif
diff --git a/drivers/scsi/bfa/include/cs/bfa_debug.h b/drivers/scsi/bfa/include/cs/bfa_debug.h
deleted file mode 100644
index 75a911ea7936..000000000000
--- a/drivers/scsi/bfa/include/cs/bfa_debug.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_debug.h BFA debug interfaces
20 */
21
22#ifndef __BFA_DEBUG_H__
23#define __BFA_DEBUG_H__
24
25#define bfa_assert(__cond) do { \
26 if (!(__cond)) \
27 bfa_panic(__LINE__, __FILE__, #__cond); \
28} while (0)
29
30#define bfa_sm_fault(__mod, __event) do { \
31 bfa_trc(__mod, (((uint32_t)0xDEAD << 16) | __event)); \
32 bfa_sm_panic((__mod)->logm, __LINE__, __FILE__, __event); \
33} while (0)
34
35#ifndef BFA_PERF_BUILD
36#define bfa_assert_fp(__cond) bfa_assert(__cond)
37#else
38#define bfa_assert_fp(__cond)
39#endif
40
41struct bfa_log_mod_s;
42void bfa_panic(int line, char *file, char *panicstr);
43void bfa_sm_panic(struct bfa_log_mod_s *logm, int line, char *file, int event);
44
45#endif /* __BFA_DEBUG_H__ */
diff --git a/drivers/scsi/bfa/include/cs/bfa_log.h b/drivers/scsi/bfa/include/cs/bfa_log.h
deleted file mode 100644
index bc334e0a93fa..000000000000
--- a/drivers/scsi/bfa/include/cs/bfa_log.h
+++ /dev/null
@@ -1,184 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_log.h BFA log library data structure and function definition
20 */
21
22#ifndef __BFA_LOG_H__
23#define __BFA_LOG_H__
24
25#include <bfa_os_inc.h>
26#include <defs/bfa_defs_status.h>
27#include <defs/bfa_defs_aen.h>
28
29/*
30 * BFA log module definition
31 *
32 * To create a new module id:
33 * Add a #define at the end of the list below. Select a value for your
34 * definition so that it is one (1) greater than the previous
35 * definition. Modify the definition of BFA_LOG_MODULE_ID_MAX to become
36 * your new definition.
37 * Should have no gaps in between the values because this is used in arrays.
38 * IMPORTANT: AEN_IDs must be at the begining, otherwise update bfa_defs_aen.h
39 */
40
41enum bfa_log_module_id {
42 BFA_LOG_UNUSED_ID = 0,
43
44 /* AEN defs begin */
45 BFA_LOG_AEN_MIN = BFA_LOG_UNUSED_ID,
46
47 BFA_LOG_AEN_ID_ADAPTER = BFA_LOG_AEN_MIN + BFA_AEN_CAT_ADAPTER,/* 1 */
48 BFA_LOG_AEN_ID_PORT = BFA_LOG_AEN_MIN + BFA_AEN_CAT_PORT, /* 2 */
49 BFA_LOG_AEN_ID_LPORT = BFA_LOG_AEN_MIN + BFA_AEN_CAT_LPORT, /* 3 */
50 BFA_LOG_AEN_ID_RPORT = BFA_LOG_AEN_MIN + BFA_AEN_CAT_RPORT, /* 4 */
51 BFA_LOG_AEN_ID_ITNIM = BFA_LOG_AEN_MIN + BFA_AEN_CAT_ITNIM, /* 5 */
52 BFA_LOG_AEN_ID_TIN = BFA_LOG_AEN_MIN + BFA_AEN_CAT_TIN, /* 6 */
53 BFA_LOG_AEN_ID_IPFC = BFA_LOG_AEN_MIN + BFA_AEN_CAT_IPFC, /* 7 */
54 BFA_LOG_AEN_ID_AUDIT = BFA_LOG_AEN_MIN + BFA_AEN_CAT_AUDIT, /* 8 */
55 BFA_LOG_AEN_ID_IOC = BFA_LOG_AEN_MIN + BFA_AEN_CAT_IOC, /* 9 */
56 BFA_LOG_AEN_ID_ETHPORT = BFA_LOG_AEN_MIN + BFA_AEN_CAT_ETHPORT,/* 10 */
57
58 BFA_LOG_AEN_MAX = BFA_LOG_AEN_ID_ETHPORT,
59 /* AEN defs end */
60
61 BFA_LOG_MODULE_ID_MIN = BFA_LOG_AEN_MAX,
62
63 BFA_LOG_FW_ID = BFA_LOG_MODULE_ID_MIN + 1,
64 BFA_LOG_HAL_ID = BFA_LOG_MODULE_ID_MIN + 2,
65 BFA_LOG_FCS_ID = BFA_LOG_MODULE_ID_MIN + 3,
66 BFA_LOG_WDRV_ID = BFA_LOG_MODULE_ID_MIN + 4,
67 BFA_LOG_LINUX_ID = BFA_LOG_MODULE_ID_MIN + 5,
68 BFA_LOG_SOLARIS_ID = BFA_LOG_MODULE_ID_MIN + 6,
69
70 BFA_LOG_MODULE_ID_MAX = BFA_LOG_SOLARIS_ID,
71
72 /* Not part of any arrays */
73 BFA_LOG_MODULE_ID_ALL = BFA_LOG_MODULE_ID_MAX + 1,
74 BFA_LOG_AEN_ALL = BFA_LOG_MODULE_ID_MAX + 2,
75 BFA_LOG_DRV_ALL = BFA_LOG_MODULE_ID_MAX + 3,
76};
77
78/*
79 * BFA log catalog name
80 */
81#define BFA_LOG_CAT_NAME "BFA"
82
83/*
84 * bfa log severity values
85 */
86enum bfa_log_severity {
87 BFA_LOG_INVALID = 0,
88 BFA_LOG_CRITICAL = 1,
89 BFA_LOG_ERROR = 2,
90 BFA_LOG_WARNING = 3,
91 BFA_LOG_INFO = 4,
92 BFA_LOG_NONE = 5,
93 BFA_LOG_LEVEL_MAX = BFA_LOG_NONE
94};
95
96#define BFA_LOG_MODID_OFFSET 16
97
98
99struct bfa_log_msgdef_s {
100 u32 msg_id; /* message id */
101 int attributes; /* attributes */
102 int severity; /* severity level */
103 char *msg_value;
104 /* msg string */
105 char *message;
106 /* msg format string */
107 int arg_type; /* argument type */
108 int arg_num; /* number of argument */
109};
110
111/*
112 * supported argument type
113 */
114enum bfa_log_arg_type {
115 BFA_LOG_S = 0, /* string */
116 BFA_LOG_D, /* decimal */
117 BFA_LOG_I, /* integer */
118 BFA_LOG_O, /* oct number */
119 BFA_LOG_U, /* unsigned integer */
120 BFA_LOG_X, /* hex number */
121 BFA_LOG_F, /* floating */
122 BFA_LOG_C, /* character */
123 BFA_LOG_L, /* double */
124 BFA_LOG_P /* pointer */
125};
126
127#define BFA_LOG_ARG_TYPE 2
128#define BFA_LOG_ARG0 (0 * BFA_LOG_ARG_TYPE)
129#define BFA_LOG_ARG1 (1 * BFA_LOG_ARG_TYPE)
130#define BFA_LOG_ARG2 (2 * BFA_LOG_ARG_TYPE)
131#define BFA_LOG_ARG3 (3 * BFA_LOG_ARG_TYPE)
132
133#define BFA_LOG_GET_MOD_ID(msgid) ((msgid >> BFA_LOG_MODID_OFFSET) & 0xff)
134#define BFA_LOG_GET_MSG_IDX(msgid) (msgid & 0xffff)
135#define BFA_LOG_GET_MSG_ID(msgdef) ((msgdef)->msg_id)
136#define BFA_LOG_GET_MSG_FMT_STRING(msgdef) ((msgdef)->message)
137#define BFA_LOG_GET_SEVERITY(msgdef) ((msgdef)->severity)
138
139/*
140 * Event attributes
141 */
142#define BFA_LOG_ATTR_NONE 0
143#define BFA_LOG_ATTR_AUDIT 1
144#define BFA_LOG_ATTR_LOG 2
145#define BFA_LOG_ATTR_FFDC 4
146
147#define BFA_LOG_CREATE_ID(msw, lsw) \
148 (((u32)msw << BFA_LOG_MODID_OFFSET) | lsw)
149
150struct bfa_log_mod_s;
151
152/**
153 * callback function
154 */
155typedef void (*bfa_log_cb_t)(struct bfa_log_mod_s *log_mod, u32 msg_id,
156 const char *format, ...);
157
158
159struct bfa_log_mod_s {
160 char instance_info[BFA_STRING_32]; /* instance info */
161 int log_level[BFA_LOG_MODULE_ID_MAX + 1];
162 /* log level for modules */
163 bfa_log_cb_t cbfn; /* callback function */
164};
165
166extern int bfa_log_init(struct bfa_log_mod_s *log_mod,
167 char *instance_name, bfa_log_cb_t cbfn);
168extern int bfa_log(struct bfa_log_mod_s *log_mod, u32 msg_id, ...);
169extern bfa_status_t bfa_log_set_level(struct bfa_log_mod_s *log_mod,
170 int mod_id, enum bfa_log_severity log_level);
171extern bfa_status_t bfa_log_set_level_all(struct bfa_log_mod_s *log_mod,
172 enum bfa_log_severity log_level);
173extern bfa_status_t bfa_log_set_level_aen(struct bfa_log_mod_s *log_mod,
174 enum bfa_log_severity log_level);
175extern enum bfa_log_severity bfa_log_get_level(struct bfa_log_mod_s *log_mod,
176 int mod_id);
177extern enum bfa_log_severity bfa_log_get_msg_level(
178 struct bfa_log_mod_s *log_mod, u32 msg_id);
179/*
180 * array of messages generated from xml files
181 */
182extern struct bfa_log_msgdef_s bfa_log_msg_array[];
183
184#endif
diff --git a/drivers/scsi/bfa/include/cs/bfa_perf.h b/drivers/scsi/bfa/include/cs/bfa_perf.h
deleted file mode 100644
index 45aa5f978ff5..000000000000
--- a/drivers/scsi/bfa/include/cs/bfa_perf.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFAD_PERF_H__
18#define __BFAD_PERF_H__
19
20#ifdef BFAD_PERF_BUILD
21
22#undef bfa_trc
23#undef bfa_trc32
24#undef bfa_assert
25#undef BFA_TRC_FILE
26
27#define bfa_trc(_trcp, _data)
28#define bfa_trc32(_trcp, _data)
29#define bfa_assert(__cond)
30#define BFA_TRC_FILE(__mod, __submod)
31
32#endif
33
34#endif /* __BFAD_PERF_H__ */
diff --git a/drivers/scsi/bfa/include/cs/bfa_q.h b/drivers/scsi/bfa/include/cs/bfa_q.h
deleted file mode 100644
index ea895facedbc..000000000000
--- a/drivers/scsi/bfa/include/cs/bfa_q.h
+++ /dev/null
@@ -1,81 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_q.h Circular queue definitions.
20 */
21
22#ifndef __BFA_Q_H__
23#define __BFA_Q_H__
24
25#define bfa_q_first(_q) ((void *)(((struct list_head *) (_q))->next))
26#define bfa_q_next(_qe) (((struct list_head *) (_qe))->next)
27#define bfa_q_prev(_qe) (((struct list_head *) (_qe))->prev)
28
29/*
30 * bfa_q_qe_init - to initialize a queue element
31 */
32#define bfa_q_qe_init(_qe) { \
33 bfa_q_next(_qe) = (struct list_head *) NULL; \
34 bfa_q_prev(_qe) = (struct list_head *) NULL; \
35}
36
37/*
38 * bfa_q_deq - dequeue an element from head of the queue
39 */
40#define bfa_q_deq(_q, _qe) { \
41 if (!list_empty(_q)) { \
42 (*((struct list_head **) (_qe))) = bfa_q_next(_q); \
43 bfa_q_prev(bfa_q_next(*((struct list_head **) _qe))) = \
44 (struct list_head *) (_q); \
45 bfa_q_next(_q) = bfa_q_next(*((struct list_head **) _qe)); \
46 BFA_Q_DBG_INIT(*((struct list_head **) _qe)); \
47 } else { \
48 *((struct list_head **) (_qe)) = (struct list_head *) NULL; \
49 } \
50}
51
52/*
53 * bfa_q_deq_tail - dequeue an element from tail of the queue
54 */
55#define bfa_q_deq_tail(_q, _qe) { \
56 if (!list_empty(_q)) { \
57 *((struct list_head **) (_qe)) = bfa_q_prev(_q); \
58 bfa_q_next(bfa_q_prev(*((struct list_head **) _qe))) = \
59 (struct list_head *) (_q); \
60 bfa_q_prev(_q) = bfa_q_prev(*(struct list_head **) _qe); \
61 BFA_Q_DBG_INIT(*((struct list_head **) _qe)); \
62 } else { \
63 *((struct list_head **) (_qe)) = (struct list_head *) NULL; \
64 } \
65}
66
67/*
68 * #ifdef BFA_DEBUG (Using bfa_assert to check for debug_build is not
69 * consistent across modules)
70 */
71#ifndef BFA_PERF_BUILD
72#define BFA_Q_DBG_INIT(_qe) bfa_q_qe_init(_qe)
73#else
74#define BFA_Q_DBG_INIT(_qe)
75#endif
76
77#define bfa_q_is_on_q(_q, _qe) \
78 bfa_q_is_on_q_func(_q, (struct list_head *)(_qe))
79extern int bfa_q_is_on_q_func(struct list_head *q, struct list_head *qe);
80
81#endif
diff --git a/drivers/scsi/bfa/include/cs/bfa_sm.h b/drivers/scsi/bfa/include/cs/bfa_sm.h
deleted file mode 100644
index 11fba9082f05..000000000000
--- a/drivers/scsi/bfa/include/cs/bfa_sm.h
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfasm.h State machine defines
20 */
21
22#ifndef __BFA_SM_H__
23#define __BFA_SM_H__
24
25typedef void (*bfa_sm_t)(void *sm, int event);
26/**
27 * oc - object class eg. bfa_ioc
28 * st - state, eg. reset
29 * otype - object type, eg. struct bfa_ioc_s
30 * etype - object type, eg. enum ioc_event
31 */
32#define bfa_sm_state_decl(oc, st, otype, etype) \
33 static void oc ## _sm_ ## st(otype * fsm, etype event)
34
35#define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (bfa_sm_t)(_state))
36#define bfa_sm_send_event(_sm, _event) ((_sm)->sm((_sm), (_event)))
37#define bfa_sm_get_state(_sm) ((_sm)->sm)
38#define bfa_sm_cmp_state(_sm, _state) ((_sm)->sm == (bfa_sm_t)(_state))
39
40/**
41 * For converting from state machine function to state encoding.
42 */
43struct bfa_sm_table_s {
44 bfa_sm_t sm; /* state machine function */
45 int state; /* state machine encoding */
46 char *name; /* state name for display */
47};
48#define BFA_SM(_sm) ((bfa_sm_t)(_sm))
49
50int bfa_sm_to_state(struct bfa_sm_table_s *smt, bfa_sm_t sm);
51
52/**
53 * State machine with entry actions.
54 */
55typedef void (*bfa_fsm_t)(void *fsm, int event);
56
57/**
58 * oc - object class eg. bfa_ioc
59 * st - state, eg. reset
60 * otype - object type, eg. struct bfa_ioc_s
61 * etype - object type, eg. enum ioc_event
62 */
63#define bfa_fsm_state_decl(oc, st, otype, etype) \
64 static void oc ## _sm_ ## st(otype * fsm, etype event); \
65 static void oc ## _sm_ ## st ## _entry(otype * fsm)
66
67#define bfa_fsm_set_state(_fsm, _state) do { \
68 (_fsm)->fsm = (bfa_fsm_t)(_state); \
69 _state ## _entry(_fsm); \
70} while (0)
71
72#define bfa_fsm_send_event(_fsm, _event) \
73 ((_fsm)->fsm((_fsm), (_event)))
74#define bfa_fsm_cmp_state(_fsm, _state) \
75 ((_fsm)->fsm == (bfa_fsm_t)(_state))
76
77#endif
diff --git a/drivers/scsi/bfa/include/cs/bfa_trc.h b/drivers/scsi/bfa/include/cs/bfa_trc.h
deleted file mode 100644
index 310771c888e7..000000000000
--- a/drivers/scsi/bfa/include/cs/bfa_trc.h
+++ /dev/null
@@ -1,176 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_TRC_H__
18#define __BFA_TRC_H__
19
20#include <bfa_os_inc.h>
21
22#ifndef BFA_TRC_MAX
23#define BFA_TRC_MAX (4 * 1024)
24#endif
25
26#ifndef BFA_TRC_TS
27#define BFA_TRC_TS(_trcm) ((_trcm)->ticks++)
28#endif
29
30struct bfa_trc_s {
31#ifdef __BIGENDIAN
32 u16 fileno;
33 u16 line;
34#else
35 u16 line;
36 u16 fileno;
37#endif
38 u32 timestamp;
39 union {
40 struct {
41 u32 rsvd;
42 u32 u32;
43 } u32;
44 u64 u64;
45 } data;
46};
47
48
49struct bfa_trc_mod_s {
50 u32 head;
51 u32 tail;
52 u32 ntrc;
53 u32 stopped;
54 u32 ticks;
55 u32 rsvd[3];
56 struct bfa_trc_s trc[BFA_TRC_MAX];
57};
58
59
60enum {
61 BFA_TRC_FW = 1, /* firmware modules */
62 BFA_TRC_HAL = 2, /* BFA modules */
63 BFA_TRC_FCS = 3, /* BFA FCS modules */
64 BFA_TRC_LDRV = 4, /* Linux driver modules */
65 BFA_TRC_SDRV = 5, /* Solaris driver modules */
66 BFA_TRC_VDRV = 6, /* vmware driver modules */
67 BFA_TRC_WDRV = 7, /* windows driver modules */
68 BFA_TRC_AEN = 8, /* AEN module */
69 BFA_TRC_BIOS = 9, /* bios driver modules */
70 BFA_TRC_EFI = 10, /* EFI driver modules */
71 BNA_TRC_WDRV = 11, /* BNA windows driver modules */
72 BNA_TRC_VDRV = 12, /* BNA vmware driver modules */
73 BNA_TRC_SDRV = 13, /* BNA Solaris driver modules */
74 BNA_TRC_LDRV = 14, /* BNA Linux driver modules */
75 BNA_TRC_HAL = 15, /* BNA modules */
76 BFA_TRC_CNA = 16, /* Common modules */
77 BNA_TRC_IMDRV = 17 /* BNA windows intermediate driver modules */
78};
79#define BFA_TRC_MOD_SH 10
80#define BFA_TRC_MOD(__mod) ((BFA_TRC_ ## __mod) << BFA_TRC_MOD_SH)
81
82/**
83 * Define a new tracing file (module). Module should match one defined above.
84 */
85#define BFA_TRC_FILE(__mod, __submod) \
86 static int __trc_fileno = ((BFA_TRC_ ## __mod ## _ ## __submod) | \
87 BFA_TRC_MOD(__mod))
88
89
90#define bfa_trc32(_trcp, _data) \
91 __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u32)_data)
92
93
94#ifndef BFA_BOOT_BUILD
95#define bfa_trc(_trcp, _data) \
96 __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u64)_data)
97#else
98void bfa_boot_trc(struct bfa_trc_mod_s *trcmod, u16 fileno,
99 u16 line, u32 data);
100#define bfa_trc(_trcp, _data) \
101 bfa_boot_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u32)_data)
102#endif
103
104
105static inline void
106bfa_trc_init(struct bfa_trc_mod_s *trcm)
107{
108 trcm->head = trcm->tail = trcm->stopped = 0;
109 trcm->ntrc = BFA_TRC_MAX;
110}
111
112
113static inline void
114bfa_trc_stop(struct bfa_trc_mod_s *trcm)
115{
116 trcm->stopped = 1;
117}
118
119#ifdef FWTRC
120extern void dc_flush(void *data);
121#else
122#define dc_flush(data)
123#endif
124
125
126static inline void
127__bfa_trc(struct bfa_trc_mod_s *trcm, int fileno, int line, u64 data)
128{
129 int tail = trcm->tail;
130 struct bfa_trc_s *trc = &trcm->trc[tail];
131
132 if (trcm->stopped)
133 return;
134
135 trc->fileno = (u16) fileno;
136 trc->line = (u16) line;
137 trc->data.u64 = data;
138 trc->timestamp = BFA_TRC_TS(trcm);
139 dc_flush(trc);
140
141 trcm->tail = (trcm->tail + 1) & (BFA_TRC_MAX - 1);
142 if (trcm->tail == trcm->head)
143 trcm->head = (trcm->head + 1) & (BFA_TRC_MAX - 1);
144 dc_flush(trcm);
145}
146
147
148static inline void
149__bfa_trc32(struct bfa_trc_mod_s *trcm, int fileno, int line, u32 data)
150{
151 int tail = trcm->tail;
152 struct bfa_trc_s *trc = &trcm->trc[tail];
153
154 if (trcm->stopped)
155 return;
156
157 trc->fileno = (u16) fileno;
158 trc->line = (u16) line;
159 trc->data.u32.u32 = data;
160 trc->timestamp = BFA_TRC_TS(trcm);
161 dc_flush(trc);
162
163 trcm->tail = (trcm->tail + 1) & (BFA_TRC_MAX - 1);
164 if (trcm->tail == trcm->head)
165 trcm->head = (trcm->head + 1) & (BFA_TRC_MAX - 1);
166 dc_flush(trcm);
167}
168
169#ifndef BFA_PERF_BUILD
170#define bfa_trc_fp(_trcp, _data) bfa_trc(_trcp, _data)
171#else
172#define bfa_trc_fp(_trcp, _data)
173#endif
174
175#endif /* __BFA_TRC_H__ */
176
diff --git a/drivers/scsi/bfa/include/cs/bfa_wc.h b/drivers/scsi/bfa/include/cs/bfa_wc.h
deleted file mode 100644
index 0460bd4fc7c4..000000000000
--- a/drivers/scsi/bfa/include/cs/bfa_wc.h
+++ /dev/null
@@ -1,68 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_wc.h Generic wait counter.
20 */
21
22#ifndef __BFA_WC_H__
23#define __BFA_WC_H__
24
25typedef void (*bfa_wc_resume_t) (void *cbarg);
26
27struct bfa_wc_s {
28 bfa_wc_resume_t wc_resume;
29 void *wc_cbarg;
30 int wc_count;
31};
32
33static inline void
34bfa_wc_up(struct bfa_wc_s *wc)
35{
36 wc->wc_count++;
37}
38
39static inline void
40bfa_wc_down(struct bfa_wc_s *wc)
41{
42 wc->wc_count--;
43 if (wc->wc_count == 0)
44 wc->wc_resume(wc->wc_cbarg);
45}
46
47/**
48 * Initialize a waiting counter.
49 */
50static inline void
51bfa_wc_init(struct bfa_wc_s *wc, bfa_wc_resume_t wc_resume, void *wc_cbarg)
52{
53 wc->wc_resume = wc_resume;
54 wc->wc_cbarg = wc_cbarg;
55 wc->wc_count = 0;
56 bfa_wc_up(wc);
57}
58
59/**
60 * Wait for counter to reach zero
61 */
62static inline void
63bfa_wc_wait(struct bfa_wc_s *wc)
64{
65 bfa_wc_down(wc);
66}
67
68#endif
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_adapter.h b/drivers/scsi/bfa/include/defs/bfa_defs_adapter.h
deleted file mode 100644
index aea0360d67d5..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_adapter.h
+++ /dev/null
@@ -1,83 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_DEFS_ADAPTER_H__
18#define __BFA_DEFS_ADAPTER_H__
19
20#include <protocol/types.h>
21#include <defs/bfa_defs_version.h>
22#include <defs/bfa_defs_mfg.h>
23
24/**
25 * BFA adapter level attributes.
26 */
27enum {
28 BFA_ADAPTER_SERIAL_NUM_LEN = STRSZ(BFA_MFG_SERIALNUM_SIZE),
29 /*
30 *!< adapter serial num length
31 */
32 BFA_ADAPTER_MODEL_NAME_LEN = 16, /* model name length */
33 BFA_ADAPTER_MODEL_DESCR_LEN = 128, /* model description length */
34 BFA_ADAPTER_MFG_NAME_LEN = 8, /* manufacturer name length */
35 BFA_ADAPTER_SYM_NAME_LEN = 64, /* adapter symbolic name length */
36 BFA_ADAPTER_OS_TYPE_LEN = 64, /* adapter os type length */
37};
38
39struct bfa_adapter_attr_s {
40 char manufacturer[BFA_ADAPTER_MFG_NAME_LEN];
41 char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
42 u32 card_type;
43 char model[BFA_ADAPTER_MODEL_NAME_LEN];
44 char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN];
45 wwn_t pwwn;
46 char node_symname[FC_SYMNAME_MAX];
47 char hw_ver[BFA_VERSION_LEN];
48 char fw_ver[BFA_VERSION_LEN];
49 char optrom_ver[BFA_VERSION_LEN];
50 char os_type[BFA_ADAPTER_OS_TYPE_LEN];
51 struct bfa_mfg_vpd_s vpd;
52 struct mac_s mac;
53
54 u8 nports;
55 u8 max_speed;
56 u8 prototype;
57 char asic_rev;
58
59 u8 pcie_gen;
60 u8 pcie_lanes_orig;
61 u8 pcie_lanes;
62 u8 cna_capable;
63 u8 is_mezz;
64};
65
66/**
67 * BFA adapter level events
68 * Arguments below are in BFAL context from Mgmt
69 * BFA_PORT_AEN_ADD: [in]: None [out]: serial_num, pwwn, nports
70 * BFA_PORT_AEN_REMOVE: [in]: pwwn [out]: serial_num, pwwn, nports
71 */
72enum bfa_adapter_aen_event {
73 BFA_ADAPTER_AEN_ADD = 1, /* New Adapter found event */
74 BFA_ADAPTER_AEN_REMOVE = 2, /* Adapter removed event */
75};
76
77struct bfa_adapter_aen_data_s {
78 char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
79 u32 nports; /* Number of NPorts */
80 wwn_t pwwn; /* WWN of one of its physical port */
81};
82
83#endif /* __BFA_DEFS_ADAPTER_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_aen.h b/drivers/scsi/bfa/include/defs/bfa_defs_aen.h
deleted file mode 100644
index 35244698fcdc..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_aen.h
+++ /dev/null
@@ -1,83 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_AEN_H__
19#define __BFA_DEFS_AEN_H__
20
21#include <defs/bfa_defs_types.h>
22#include <defs/bfa_defs_ioc.h>
23#include <defs/bfa_defs_adapter.h>
24#include <defs/bfa_defs_port.h>
25#include <defs/bfa_defs_lport.h>
26#include <defs/bfa_defs_rport.h>
27#include <defs/bfa_defs_itnim.h>
28#include <defs/bfa_defs_tin.h>
29#include <defs/bfa_defs_ipfc.h>
30#include <defs/bfa_defs_audit.h>
31#include <defs/bfa_defs_ethport.h>
32
33#define BFA_AEN_MAX_APP 5
34
35enum bfa_aen_app {
36 bfa_aen_app_bcu = 0, /* No thread for bcu */
37 bfa_aen_app_hcm = 1,
38 bfa_aen_app_cim = 2,
39 bfa_aen_app_snia = 3,
40 bfa_aen_app_test = 4, /* To be removed after unit test */
41};
42
43enum bfa_aen_category {
44 BFA_AEN_CAT_ADAPTER = 1,
45 BFA_AEN_CAT_PORT = 2,
46 BFA_AEN_CAT_LPORT = 3,
47 BFA_AEN_CAT_RPORT = 4,
48 BFA_AEN_CAT_ITNIM = 5,
49 BFA_AEN_CAT_TIN = 6,
50 BFA_AEN_CAT_IPFC = 7,
51 BFA_AEN_CAT_AUDIT = 8,
52 BFA_AEN_CAT_IOC = 9,
53 BFA_AEN_CAT_ETHPORT = 10,
54 BFA_AEN_MAX_CAT = 10
55};
56
57#pragma pack(1)
58union bfa_aen_data_u {
59 struct bfa_adapter_aen_data_s adapter;
60 struct bfa_port_aen_data_s port;
61 struct bfa_lport_aen_data_s lport;
62 struct bfa_rport_aen_data_s rport;
63 struct bfa_itnim_aen_data_s itnim;
64 struct bfa_audit_aen_data_s audit;
65 struct bfa_ioc_aen_data_s ioc;
66 struct bfa_ethport_aen_data_s ethport;
67};
68
69struct bfa_aen_entry_s {
70 enum bfa_aen_category aen_category;
71 int aen_type;
72 union bfa_aen_data_u aen_data;
73 struct bfa_timeval_s aen_tv;
74 s32 seq_num;
75 s32 bfad_num;
76 s32 rsvd[1];
77};
78
79#pragma pack()
80
81#define bfa_aen_event_t int
82
83#endif /* __BFA_DEFS_AEN_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_audit.h b/drivers/scsi/bfa/include/defs/bfa_defs_audit.h
deleted file mode 100644
index 8e3a962bf20c..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_audit.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_AUDIT_H__
19#define __BFA_DEFS_AUDIT_H__
20
21#include <bfa_os_inc.h>
22
23/**
24 * BFA audit events
25 */
26enum bfa_audit_aen_event {
27 BFA_AUDIT_AEN_AUTH_ENABLE = 1,
28 BFA_AUDIT_AEN_AUTH_DISABLE = 2,
29};
30
31/**
32 * audit event data
33 */
34struct bfa_audit_aen_data_s {
35 wwn_t pwwn;
36};
37
38#endif /* __BFA_DEFS_AUDIT_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_auth.h b/drivers/scsi/bfa/include/defs/bfa_defs_auth.h
deleted file mode 100644
index f56ed871bb99..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_auth.h
+++ /dev/null
@@ -1,134 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_DEFS_AUTH_H__
18#define __BFA_DEFS_AUTH_H__
19
20#include <defs/bfa_defs_types.h>
21
22#define PUBLIC_KEY 15409
23#define PRIVATE_KEY 19009
24#define KEY_LEN 32399
25#define BFA_AUTH_SECRET_STRING_LEN 256
26#define BFA_AUTH_FAIL_NO_PASSWORD 0xFE
27#define BFA_AUTH_FAIL_TIMEOUT 0xFF
28
29/**
30 * Authentication status
31 */
32enum bfa_auth_status {
33 BFA_AUTH_STATUS_NONE = 0, /* no authentication */
34 BFA_AUTH_UNINIT = 1, /* state - uninit */
35 BFA_AUTH_NEG_SEND = 2, /* state - negotiate send */
36 BFA_AUTH_CHAL_WAIT = 3, /* state - challenge wait */
37 BFA_AUTH_NEG_RETRY = 4, /* state - negotiate retry */
38 BFA_AUTH_REPLY_SEND = 5, /* state - reply send */
39 BFA_AUTH_STATUS_WAIT = 6, /* state - status wait */
40 BFA_AUTH_SUCCESS = 7, /* state - success */
41 BFA_AUTH_FAILED = 8, /* state - failed */
42 BFA_AUTH_STATUS_UNKNOWN = 9, /* authentication status unknown */
43};
44
45enum bfa_auth_rej_code {
46 BFA_AUTH_RJT_CODE_AUTH_FAILURE = 1, /* auth failure */
47 BFA_AUTH_RJT_CODE_LOGICAL_ERR = 2, /* logical error */
48};
49
50/**
51 * Authentication reject codes
52 */
53enum bfa_auth_rej_code_exp {
54 BFA_AUTH_MECH_NOT_USABLE = 1, /* auth. mechanism not usable */
55 BFA_AUTH_DH_GROUP_NOT_USABLE = 2, /* DH Group not usable */
56 BFA_AUTH_HASH_FUNC_NOT_USABLE = 3, /* hash Function not usable */
57 BFA_AUTH_AUTH_XACT_STARTED = 4, /* auth xact started */
58 BFA_AUTH_AUTH_FAILED = 5, /* auth failed */
59 BFA_AUTH_INCORRECT_PLD = 6, /* incorrect payload */
60 BFA_AUTH_INCORRECT_PROTO_MSG = 7, /* incorrect proto msg */
61 BFA_AUTH_RESTART_AUTH_PROTO = 8, /* restart auth protocol */
62 BFA_AUTH_AUTH_CONCAT_NOT_SUPP = 9, /* auth concat not supported */
63 BFA_AUTH_PROTO_VER_NOT_SUPP = 10,/* proto version not supported */
64};
65
66struct auth_proto_stats_s {
67 u32 auth_rjts;
68 u32 auth_negs;
69 u32 auth_dones;
70
71 u32 dhchap_challenges;
72 u32 dhchap_replies;
73 u32 dhchap_successes;
74};
75
76/**
77 * Authentication related statistics
78 */
79struct bfa_auth_stats_s {
80 u32 auth_failures; /* authentication failures */
81 u32 auth_successes; /* authentication successes*/
82 struct auth_proto_stats_s auth_rx_stats; /* Rx protocol stats */
83 struct auth_proto_stats_s auth_tx_stats; /* Tx protocol stats */
84};
85
86/**
87 * Authentication hash function algorithms
88 */
89enum bfa_auth_algo {
90 BFA_AUTH_ALGO_MD5 = 1, /* Message-Digest algorithm 5 */
91 BFA_AUTH_ALGO_SHA1 = 2, /* Secure Hash Algorithm 1 */
92 BFA_AUTH_ALGO_MS = 3, /* MD5, then SHA-1 */
93 BFA_AUTH_ALGO_SM = 4, /* SHA-1, then MD5 */
94};
95
96/**
97 * DH Groups
98 *
99 * Current value could be combination of one or more of the following values
100 */
101enum bfa_auth_group {
102 BFA_AUTH_GROUP_DHNULL = 0, /* DH NULL (value == 0) */
103 BFA_AUTH_GROUP_DH768 = 1, /* DH group 768 (value == 1) */
104 BFA_AUTH_GROUP_DH1024 = 2, /* DH group 1024 (value == 2) */
105 BFA_AUTH_GROUP_DH1280 = 4, /* DH group 1280 (value == 3) */
106 BFA_AUTH_GROUP_DH1536 = 8, /* DH group 1536 (value == 4) */
107
108 BFA_AUTH_GROUP_ALL = 256 /* Use default DH group order
109 * 0, 1, 2, 3, 4 */
110};
111
112/**
113 * Authentication secret sources
114 */
115enum bfa_auth_secretsource {
116 BFA_AUTH_SECSRC_LOCAL = 1, /* locally configured */
117 BFA_AUTH_SECSRC_RADIUS = 2, /* use radius server */
118 BFA_AUTH_SECSRC_TACACS = 3, /* TACACS server */
119};
120
121/**
122 * Authentication attributes
123 */
124struct bfa_auth_attr_s {
125 enum bfa_auth_status status;
126 enum bfa_auth_algo algo;
127 enum bfa_auth_group dh_grp;
128 enum bfa_auth_rej_code rjt_code;
129 enum bfa_auth_rej_code_exp rjt_code_exp;
130 u8 secret_set;
131 u8 resv[3];
132};
133
134#endif /* __BFA_DEFS_AUTH_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_boot.h b/drivers/scsi/bfa/include/defs/bfa_defs_boot.h
deleted file mode 100644
index 0fca10b6ad10..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_boot.h
+++ /dev/null
@@ -1,81 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_BOOT_H__
19#define __BFA_DEFS_BOOT_H__
20
21#include <protocol/types.h>
22#include <defs/bfa_defs_types.h>
23#include <defs/bfa_defs_pport.h>
24
25enum {
26 BFA_BOOT_BOOTLUN_MAX = 4, /* maximum boot lun per IOC */
27 BFA_PREBOOT_BOOTLUN_MAX = 8, /* maximum preboot lun per IOC */
28
29};
30
31#define BOOT_CFG_REV1 1
32
33/**
34 * Boot options setting. Boot options setting determines from where
35 * to get the boot lun information
36 */
37enum bfa_boot_bootopt {
38 BFA_BOOT_AUTO_DISCOVER = 0, /* Boot from blun provided by fabric */
39 BFA_BOOT_STORED_BLUN = 1, /* Boot from bluns stored in flash */
40 BFA_BOOT_FIRST_LUN = 2, /* Boot from first discovered blun */
41};
42
43/**
44 * Boot lun information.
45 */
46struct bfa_boot_bootlun_s {
47 wwn_t pwwn; /* port wwn of target */
48 lun_t lun; /* 64-bit lun */
49};
50
51/**
52 * BOOT boot configuraton
53 */
54struct bfa_boot_cfg_s {
55 u8 version;
56 u8 rsvd1;
57 u16 chksum;
58
59 u8 enable; /* enable/disable SAN boot */
60 u8 speed; /* boot speed settings */
61 u8 topology; /* boot topology setting */
62 u8 bootopt; /* bfa_boot_bootopt_t */
63
64 u32 nbluns; /* number of boot luns */
65
66 u32 rsvd2;
67
68 struct bfa_boot_bootlun_s blun[BFA_BOOT_BOOTLUN_MAX];
69 struct bfa_boot_bootlun_s blun_disc[BFA_BOOT_BOOTLUN_MAX];
70};
71
72struct bfa_boot_pbc_s {
73 u8 enable; /* enable/disable SAN boot */
74 u8 speed; /* boot speed settings */
75 u8 topology; /* boot topology setting */
76 u8 rsvd1;
77 u32 nbluns; /* number of boot luns */
78 struct bfa_boot_bootlun_s pblun[BFA_PREBOOT_BOOTLUN_MAX];
79};
80
81#endif /* __BFA_DEFS_BOOT_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_cee.h b/drivers/scsi/bfa/include/defs/bfa_defs_cee.h
deleted file mode 100644
index 6eaf519eccdc..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_cee.h
+++ /dev/null
@@ -1,157 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * bfa_defs_cee.h Interface declarations between host based
7 * BFAL and DCBX/LLDP module in Firmware
8 *
9 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License (GPL) Version 2 as
13 * published by the Free Software Foundation
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 */
20#ifndef __BFA_DEFS_CEE_H__
21#define __BFA_DEFS_CEE_H__
22
23#include <defs/bfa_defs_types.h>
24#include <defs/bfa_defs_pport.h>
25#include <protocol/types.h>
26
27#pragma pack(1)
28
29#define BFA_CEE_LLDP_MAX_STRING_LEN (128)
30
31#define BFA_CEE_LLDP_SYS_CAP_OTHER 0x0001
32#define BFA_CEE_LLDP_SYS_CAP_REPEATER 0x0002
33#define BFA_CEE_LLDP_SYS_CAP_MAC_BRIDGE 0x0004
34#define BFA_CEE_LLDP_SYS_CAP_WLAN_AP 0x0008
35#define BFA_CEE_LLDP_SYS_CAP_ROUTER 0x0010
36#define BFA_CEE_LLDP_SYS_CAP_TELEPHONE 0x0020
37#define BFA_CEE_LLDP_SYS_CAP_DOCSIS_CD 0x0040
38#define BFA_CEE_LLDP_SYS_CAP_STATION 0x0080
39#define BFA_CEE_LLDP_SYS_CAP_CVLAN 0x0100
40#define BFA_CEE_LLDP_SYS_CAP_SVLAN 0x0200
41#define BFA_CEE_LLDP_SYS_CAP_TPMR 0x0400
42
43
44/* LLDP string type */
45struct bfa_cee_lldp_str_s {
46 u8 sub_type;
47 u8 len;
48 u8 rsvd[2];
49 u8 value[BFA_CEE_LLDP_MAX_STRING_LEN];
50};
51
52
53/* LLDP parameters */
54struct bfa_cee_lldp_cfg_s {
55 struct bfa_cee_lldp_str_s chassis_id;
56 struct bfa_cee_lldp_str_s port_id;
57 struct bfa_cee_lldp_str_s port_desc;
58 struct bfa_cee_lldp_str_s sys_name;
59 struct bfa_cee_lldp_str_s sys_desc;
60 struct bfa_cee_lldp_str_s mgmt_addr;
61 u16 time_to_interval;
62 u16 enabled_system_cap;
63};
64
65enum bfa_cee_dcbx_version_e {
66 DCBX_PROTOCOL_PRECEE = 1,
67 DCBX_PROTOCOL_CEE = 2,
68};
69
70enum bfa_cee_lls_e {
71 CEE_LLS_DOWN_NO_TLV = 0, /* LLS is down because the TLV not sent by
72 * the peer */
73 CEE_LLS_DOWN = 1, /* LLS is down as advertised by the peer */
74 CEE_LLS_UP = 2,
75};
76
77/* CEE/DCBX parameters */
78struct bfa_cee_dcbx_cfg_s {
79 u8 pgid[8];
80 u8 pg_percentage[8];
81 u8 pfc_enabled; /* bitmap of priorties with PFC enabled */
82 u8 fcoe_user_priority; /* bitmap of priorities used for FcoE
83 * traffic */
84 u8 dcbx_version; /* operating version:CEE or preCEE */
85 u8 lls_fcoe; /* FCoE Logical Link Status */
86 u8 lls_lan; /* LAN Logical Link Status */
87 u8 rsvd[3];
88};
89
90/* CEE status */
91/* Making this to tri-state for the benefit of port list command */
92enum bfa_cee_status_e {
93 CEE_UP = 0,
94 CEE_PHY_UP = 1,
95 CEE_LOOPBACK = 2,
96 CEE_PHY_DOWN = 3,
97};
98
99/* CEE Query */
100struct bfa_cee_attr_s {
101 u8 cee_status;
102 u8 error_reason;
103 struct bfa_cee_lldp_cfg_s lldp_remote;
104 struct bfa_cee_dcbx_cfg_s dcbx_remote;
105 mac_t src_mac;
106 u8 link_speed;
107 u8 nw_priority;
108 u8 filler[2];
109};
110
111
112
113
114/* LLDP/DCBX/CEE Statistics */
115
116struct bfa_cee_lldp_stats_s {
117 u32 frames_transmitted;
118 u32 frames_aged_out;
119 u32 frames_discarded;
120 u32 frames_in_error;
121 u32 frames_rcvd;
122 u32 tlvs_discarded;
123 u32 tlvs_unrecognized;
124};
125
126struct bfa_cee_dcbx_stats_s {
127 u32 subtlvs_unrecognized;
128 u32 negotiation_failed;
129 u32 remote_cfg_changed;
130 u32 tlvs_received;
131 u32 tlvs_invalid;
132 u32 seqno;
133 u32 ackno;
134 u32 recvd_seqno;
135 u32 recvd_ackno;
136};
137
138struct bfa_cee_cfg_stats_s {
139 u32 cee_status_down;
140 u32 cee_status_up;
141 u32 cee_hw_cfg_changed;
142 u32 recvd_invalid_cfg;
143};
144
145
146struct bfa_cee_stats_s {
147 struct bfa_cee_lldp_stats_s lldp_stats;
148 struct bfa_cee_dcbx_stats_s dcbx_stats;
149 struct bfa_cee_cfg_stats_s cfg_stats;
150};
151
152#pragma pack()
153
154
155#endif /* __BFA_DEFS_CEE_H__ */
156
157
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_driver.h b/drivers/scsi/bfa/include/defs/bfa_defs_driver.h
deleted file mode 100644
index 7d00d00d3969..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_driver.h
+++ /dev/null
@@ -1,41 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_DRIVER_H__
19#define __BFA_DEFS_DRIVER_H__
20
21/**
22 * Driver statistics
23 */
24struct bfa_driver_stats_s {
25 u16 tm_io_abort;
26 u16 tm_io_abort_comp;
27 u16 tm_lun_reset;
28 u16 tm_lun_reset_comp;
29 u16 tm_target_reset;
30 u16 tm_bus_reset;
31 u16 ioc_restart; /* IOC restart count */
32 u16 rsvd;
33 u64 control_req;
34 u64 input_req;
35 u64 output_req;
36 u64 input_words;
37 u64 output_words;
38};
39
40
41#endif /* __BFA_DEFS_DRIVER_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_ethport.h b/drivers/scsi/bfa/include/defs/bfa_defs_ethport.h
deleted file mode 100644
index b4fa0923aa89..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_ethport.h
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_ETHPORT_H__
19#define __BFA_DEFS_ETHPORT_H__
20
21#include <defs/bfa_defs_status.h>
22#include <defs/bfa_defs_port.h>
23#include <protocol/types.h>
24#include <cna/pstats/phyport_defs.h>
25#include <cna/pstats/ethport_defs.h>
26
27struct bna_tx_info_s {
28 u32 miniport_state;
29 u32 adapter_state;
30 u64 tx_count;
31 u64 tx_wi;
32 u64 tx_sg;
33 u64 tx_tcp_chksum;
34 u64 tx_udp_chksum;
35 u64 tx_ip_chksum;
36 u64 tx_lsov1;
37 u64 tx_lsov2;
38 u64 tx_max_sg_len ;
39};
40
41struct bna_rx_queue_info_s {
42 u16 q_id ;
43 u16 buf_size ;
44 u16 buf_count ;
45 u16 rsvd ;
46 u64 rx_count ;
47 u64 rx_dropped ;
48 u64 rx_unsupported ;
49 u64 rx_internal_err ;
50 u64 rss_count ;
51 u64 vlan_count ;
52 u64 rx_tcp_chksum ;
53 u64 rx_udp_chksum ;
54 u64 rx_ip_chksum ;
55 u64 rx_hds ;
56};
57
58struct bna_rx_q_set_s {
59 u16 q_set_type;
60 u32 miniport_state;
61 u32 adapter_state;
62 struct bna_rx_queue_info_s rx_queue[2];
63};
64
65struct bna_port_stats_s {
66 struct bna_tx_info_s tx_stats;
67 u16 qset_count ;
68 struct bna_rx_q_set_s rx_qset[8];
69};
70
71struct bfa_ethport_stats_s {
72 struct bna_stats_txf txf_stats[1];
73 struct bna_stats_rxf rxf_stats[1];
74 struct bnad_drv_stats drv_stats;
75};
76
77/**
78 * Ethernet port events
79 * Arguments below are in BFAL context from Mgmt
80 * BFA_PORT_AEN_ETH_LINKUP: [in]: mac [out]: mac
81 * BFA_PORT_AEN_ETH_LINKDOWN: [in]: mac [out]: mac
82 * BFA_PORT_AEN_ETH_ENABLE: [in]: mac [out]: mac
83 * BFA_PORT_AEN_ETH_DISABLE: [in]: mac [out]: mac
84 *
85 */
86enum bfa_ethport_aen_event {
87 BFA_ETHPORT_AEN_LINKUP = 1, /* Base Port Ethernet link up event */
88 BFA_ETHPORT_AEN_LINKDOWN = 2, /* Base Port Ethernet link down event */
89 BFA_ETHPORT_AEN_ENABLE = 3, /* Base Port Ethernet link enable event */
90 BFA_ETHPORT_AEN_DISABLE = 4, /* Base Port Ethernet link disable
91 * event */
92};
93
94struct bfa_ethport_aen_data_s {
95 mac_t mac; /* MAC address of the physical port */
96};
97
98
99#endif /* __BFA_DEFS_ETHPORT_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_fcpim.h b/drivers/scsi/bfa/include/defs/bfa_defs_fcpim.h
deleted file mode 100644
index c08f4f5026ac..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_fcpim.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_DEFS_FCPIM_H__
18#define __BFA_DEFS_FCPIM_H__
19
20struct bfa_fcpim_stats_s {
21 u32 total_ios; /* Total IO count */
22 u32 qresumes; /* IO waiting for CQ space */
23 u32 no_iotags; /* NO IO contexts */
24 u32 io_aborts; /* IO abort requests */
25 u32 no_tskims; /* NO task management contexts */
26 u32 iocomp_ok; /* IO completions with OK status */
27 u32 iocomp_underrun; /* IO underrun (good) */
28 u32 iocomp_overrun; /* IO overrun (good) */
29 u32 iocomp_aborted; /* Aborted IO requests */
30 u32 iocomp_timedout; /* IO timeouts */
31 u32 iocom_nexus_abort; /* IO selection timeouts */
32 u32 iocom_proto_err; /* IO protocol errors */
33 u32 iocom_dif_err; /* IO SBC-3 protection errors */
34 u32 iocom_tm_abort; /* IO aborted by TM requests */
35 u32 iocom_sqer_needed; /* IO retry for SQ error
36 *recovery */
37 u32 iocom_res_free; /* Delayed freeing of IO resources */
38 u32 iocomp_scsierr; /* IO with non-good SCSI status */
39 u32 iocom_hostabrts; /* Host IO abort requests */
40 u32 iocom_utags; /* IO comp with unknown tags */
41 u32 io_cleanups; /* IO implicitly aborted */
42 u32 io_tmaborts; /* IO aborted due to TM commands */
43 u32 rsvd;
44};
45#endif /*__BFA_DEFS_FCPIM_H__*/
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_fcport.h b/drivers/scsi/bfa/include/defs/bfa_defs_fcport.h
deleted file mode 100644
index af86a6396439..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_fcport.h
+++ /dev/null
@@ -1,88 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * bfa_defs_fcport.h
7 *
8 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License (GPL) Version 2 as
12 * published by the Free Software Foundation
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 */
19#ifndef __BFA_DEFS_FCPORT_H__
20#define __BFA_DEFS_FCPORT_H__
21
22#include <defs/bfa_defs_types.h>
23#include <protocol/types.h>
24
25#pragma pack(1)
26
27/**
28 * FCoE statistics
29 */
30struct bfa_fcoe_stats_s {
31 u64 secs_reset; /* Seconds since stats reset */
32 u64 cee_linkups; /* CEE link up */
33 u64 cee_linkdns; /* CEE link down */
34 u64 fip_linkups; /* FIP link up */
35 u64 fip_linkdns; /* FIP link down */
36 u64 fip_fails; /* FIP failures */
37 u64 mac_invalids; /* Invalid mac assignments */
38 u64 vlan_req; /* Vlan requests */
39 u64 vlan_notify; /* Vlan notifications */
40 u64 vlan_err; /* Vlan notification errors */
41 u64 vlan_timeouts; /* Vlan request timeouts */
42 u64 vlan_invalids; /* Vlan invalids */
43 u64 disc_req; /* Discovery requests */
44 u64 disc_rsp; /* Discovery responses */
45 u64 disc_err; /* Discovery error frames */
46 u64 disc_unsol; /* Discovery unsolicited */
47 u64 disc_timeouts; /* Discovery timeouts */
48 u64 disc_fcf_unavail; /* Discovery FCF not avail */
49 u64 linksvc_unsupp; /* FIP link service req unsupp. */
50 u64 linksvc_err; /* FIP link service req errors */
51 u64 logo_req; /* FIP logos received */
52 u64 clrvlink_req; /* Clear virtual link requests */
53 u64 op_unsupp; /* FIP operation unsupp. */
54 u64 untagged; /* FIP untagged frames */
55 u64 txf_ucast; /* Tx FCoE unicast frames */
56 u64 txf_ucast_vlan; /* Tx FCoE unicast vlan frames */
57 u64 txf_ucast_octets; /* Tx FCoE unicast octets */
58 u64 txf_mcast; /* Tx FCoE mutlicast frames */
59 u64 txf_mcast_vlan; /* Tx FCoE mutlicast vlan frames */
60 u64 txf_mcast_octets; /* Tx FCoE multicast octets */
61 u64 txf_bcast; /* Tx FCoE broadcast frames */
62 u64 txf_bcast_vlan; /* Tx FCoE broadcast vlan frames */
63 u64 txf_bcast_octets; /* Tx FCoE broadcast octets */
64 u64 txf_timeout; /* Tx timeouts */
65 u64 txf_parity_errors; /* Transmit parity err */
66 u64 txf_fid_parity_errors; /* Transmit FID parity err */
67 u64 rxf_ucast_octets; /* Rx FCoE unicast octets */
68 u64 rxf_ucast; /* Rx FCoE unicast frames */
69 u64 rxf_ucast_vlan; /* Rx FCoE unicast vlan frames */
70 u64 rxf_mcast_octets; /* Rx FCoE multicast octets */
71 u64 rxf_mcast; /* Rx FCoE multicast frames */
72 u64 rxf_mcast_vlan; /* Rx FCoE multicast vlan frames */
73 u64 rxf_bcast_octets; /* Rx FCoE broadcast octets */
74 u64 rxf_bcast; /* Rx FCoE broadcast frames */
75 u64 rxf_bcast_vlan; /* Rx FCoE broadcast vlan frames */
76};
77
78/**
79 * QoS or FCoE stats (fcport stats excluding physical FC port stats)
80 */
81union bfa_fcport_stats_u {
82 struct bfa_qos_stats_s fcqos;
83 struct bfa_fcoe_stats_s fcoe;
84};
85
86#pragma pack()
87
88#endif /* __BFA_DEFS_FCPORT_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_ioc.h b/drivers/scsi/bfa/include/defs/bfa_defs_ioc.h
deleted file mode 100644
index add0a05d941d..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_ioc.h
+++ /dev/null
@@ -1,158 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_IOC_H__
19#define __BFA_DEFS_IOC_H__
20
21#include <protocol/types.h>
22#include <defs/bfa_defs_types.h>
23#include <defs/bfa_defs_version.h>
24#include <defs/bfa_defs_adapter.h>
25#include <defs/bfa_defs_pm.h>
26
27enum {
28 BFA_IOC_DRIVER_LEN = 16,
29 BFA_IOC_CHIP_REV_LEN = 8,
30};
31
32/**
33 * Driver and firmware versions.
34 */
35struct bfa_ioc_driver_attr_s {
36 char driver[BFA_IOC_DRIVER_LEN]; /* driver name */
37 char driver_ver[BFA_VERSION_LEN]; /* driver version */
38 char fw_ver[BFA_VERSION_LEN]; /* firmware version*/
39 char bios_ver[BFA_VERSION_LEN]; /* bios version */
40 char efi_ver[BFA_VERSION_LEN]; /* EFI version */
41 char ob_ver[BFA_VERSION_LEN]; /* openboot version*/
42};
43
44/**
45 * IOC PCI device attributes
46 */
47struct bfa_ioc_pci_attr_s {
48 u16 vendor_id; /* PCI vendor ID */
49 u16 device_id; /* PCI device ID */
50 u16 ssid; /* subsystem ID */
51 u16 ssvid; /* subsystem vendor ID */
52 u32 pcifn; /* PCI device function */
53 u32 rsvd; /* padding */
54 u8 chip_rev[BFA_IOC_CHIP_REV_LEN]; /* chip revision */
55};
56
57/**
58 * IOC states
59 */
60enum bfa_ioc_state {
61 BFA_IOC_RESET = 1, /* IOC is in reset state */
62 BFA_IOC_SEMWAIT = 2, /* Waiting for IOC hardware semaphore */
63 BFA_IOC_HWINIT = 3, /* IOC hardware is being initialized */
64 BFA_IOC_GETATTR = 4, /* IOC is being configured */
65 BFA_IOC_OPERATIONAL = 5, /* IOC is operational */
66 BFA_IOC_INITFAIL = 6, /* IOC hardware failure */
67 BFA_IOC_HBFAIL = 7, /* IOC heart-beat failure */
68 BFA_IOC_DISABLING = 8, /* IOC is being disabled */
69 BFA_IOC_DISABLED = 9, /* IOC is disabled */
70 BFA_IOC_FWMISMATCH = 10, /* IOC firmware different from drivers */
71};
72
73/**
74 * IOC firmware stats
75 */
76struct bfa_fw_ioc_stats_s {
77 u32 hb_count;
78 u32 cfg_reqs;
79 u32 enable_reqs;
80 u32 disable_reqs;
81 u32 stats_reqs;
82 u32 clrstats_reqs;
83 u32 unknown_reqs;
84 u32 ic_reqs; /* interrupt coalesce reqs */
85};
86
87/**
88 * IOC driver stats
89 */
90struct bfa_ioc_drv_stats_s {
91 u32 ioc_isrs;
92 u32 ioc_enables;
93 u32 ioc_disables;
94 u32 ioc_hbfails;
95 u32 ioc_boots;
96 u32 stats_tmos;
97 u32 hb_count;
98 u32 disable_reqs;
99 u32 enable_reqs;
100 u32 disable_replies;
101 u32 enable_replies;
102};
103
104/**
105 * IOC statistics
106 */
107struct bfa_ioc_stats_s {
108 struct bfa_ioc_drv_stats_s drv_stats; /* driver IOC stats */
109 struct bfa_fw_ioc_stats_s fw_stats; /* firmware IOC stats */
110};
111
112
113enum bfa_ioc_type_e {
114 BFA_IOC_TYPE_FC = 1,
115 BFA_IOC_TYPE_FCoE = 2,
116 BFA_IOC_TYPE_LL = 3,
117};
118
119/**
120 * IOC attributes returned in queries
121 */
122struct bfa_ioc_attr_s {
123 enum bfa_ioc_type_e ioc_type;
124 enum bfa_ioc_state state; /* IOC state */
125 struct bfa_adapter_attr_s adapter_attr; /* HBA attributes */
126 struct bfa_ioc_driver_attr_s driver_attr; /* driver attr */
127 struct bfa_ioc_pci_attr_s pci_attr;
128 u8 port_id; /* port number */
129 u8 rsvd[7]; /* 64bit align */
130};
131
132/**
133 * BFA IOC level events
134 */
135enum bfa_ioc_aen_event {
136 BFA_IOC_AEN_HBGOOD = 1, /* Heart Beat restore event */
137 BFA_IOC_AEN_HBFAIL = 2, /* Heart Beat failure event */
138 BFA_IOC_AEN_ENABLE = 3, /* IOC enabled event */
139 BFA_IOC_AEN_DISABLE = 4, /* IOC disabled event */
140 BFA_IOC_AEN_FWMISMATCH = 5, /* IOC firmware mismatch */
141 BFA_IOC_AEN_FWCFG_ERROR = 6, /* IOC firmware config error */
142 BFA_IOC_AEN_INVALID_VENDOR = 7,
143 BFA_IOC_AEN_INVALID_NWWN = 8, /* Zero NWWN */
144 BFA_IOC_AEN_INVALID_PWWN = 9 /* Zero PWWN */
145
146};
147
148/**
149 * BFA IOC level event data, now just a place holder
150 */
151struct bfa_ioc_aen_data_s {
152 wwn_t pwwn;
153 s16 ioc_type;
154 mac_t mac;
155};
156
157#endif /* __BFA_DEFS_IOC_H__ */
158
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_iocfc.h b/drivers/scsi/bfa/include/defs/bfa_defs_iocfc.h
deleted file mode 100644
index 31e728a631ed..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_iocfc.h
+++ /dev/null
@@ -1,322 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_IOCFC_H__
19#define __BFA_DEFS_IOCFC_H__
20
21#include <protocol/types.h>
22#include <defs/bfa_defs_types.h>
23#include <defs/bfa_defs_version.h>
24#include <defs/bfa_defs_adapter.h>
25#include <defs/bfa_defs_pm.h>
26
27#define BFA_IOCFC_INTR_DELAY 1125
28#define BFA_IOCFC_INTR_LATENCY 225
29#define BFA_IOCFCOE_INTR_DELAY 25
30#define BFA_IOCFCOE_INTR_LATENCY 5
31
32/**
33 * Interrupt coalescing configuration.
34 */
35struct bfa_iocfc_intr_attr_s {
36 bfa_boolean_t coalesce; /* enable/disable coalescing */
37 u16 latency; /* latency in microseconds */
38 u16 delay; /* delay in microseconds */
39};
40
41/**
42 * IOC firmware configuraton
43 */
44struct bfa_iocfc_fwcfg_s {
45 u16 num_fabrics; /* number of fabrics */
46 u16 num_lports; /* number of local lports */
47 u16 num_rports; /* number of remote ports */
48 u16 num_ioim_reqs; /* number of IO reqs */
49 u16 num_tskim_reqs; /* task management requests */
50 u16 num_iotm_reqs; /* number of TM IO reqs */
51 u16 num_tsktm_reqs; /* TM task management requests*/
52 u16 num_fcxp_reqs; /* unassisted FC exchanges */
53 u16 num_uf_bufs; /* unsolicited recv buffers */
54 u8 num_cqs;
55 u8 fw_tick_res; /*!< FW clock resolution in ms */
56 u8 rsvd[4];
57
58};
59
60struct bfa_iocfc_drvcfg_s {
61 u16 num_reqq_elems; /* number of req queue elements */
62 u16 num_rspq_elems; /* number of rsp queue elements */
63 u16 num_sgpgs; /* number of total SG pages */
64 u16 num_sboot_tgts; /* number of SAN boot targets */
65 u16 num_sboot_luns; /* number of SAN boot luns */
66 u16 ioc_recover; /* IOC recovery mode */
67 u16 min_cfg; /* minimum configuration */
68 u16 path_tov; /* device path timeout */
69 bfa_boolean_t delay_comp; /* delay completion of
70 failed inflight IOs */
71 u32 rsvd;
72};
73/**
74 * IOC configuration
75 */
76struct bfa_iocfc_cfg_s {
77 struct bfa_iocfc_fwcfg_s fwcfg; /* firmware side config */
78 struct bfa_iocfc_drvcfg_s drvcfg; /* driver side config */
79};
80
81/**
82 * IOC firmware IO stats
83 */
84struct bfa_fw_io_stats_s {
85 u32 host_abort; /* IO aborted by host driver*/
86 u32 host_cleanup; /* IO clean up by host driver */
87
88 u32 fw_io_timeout; /* IOs timedout */
89 u32 fw_frm_parse; /* frame parsed by f/w */
90 u32 fw_frm_data; /* fcp_data frame parsed by f/w */
91 u32 fw_frm_rsp; /* fcp_rsp frame parsed by f/w */
92 u32 fw_frm_xfer_rdy; /* xfer_rdy frame parsed by f/w */
93 u32 fw_frm_bls_acc; /* BLS ACC frame parsed by f/w */
94 u32 fw_frm_tgt_abort; /* target ABTS parsed by f/w */
95 u32 fw_frm_unknown; /* unknown parsed by f/w */
96 u32 fw_data_dma; /* f/w DMA'ed the data frame */
97 u32 fw_frm_drop; /* f/w drop the frame */
98
99 u32 rec_timeout; /* FW rec timed out */
100 u32 error_rec; /* FW sending rec on
101 * an error condition*/
102 u32 wait_for_si; /* FW wait for SI */
103 u32 rec_rsp_inval; /* REC rsp invalid */
104 u32 seqr_io_abort; /* target does not know cmd so abort */
105 u32 seqr_io_retry; /* SEQR failed so retry IO */
106
107 u32 itn_cisc_upd_rsp; /* ITN cisc updated on fcp_rsp */
108 u32 itn_cisc_upd_data; /* ITN cisc updated on fcp_data */
109 u32 itn_cisc_upd_xfer_rdy; /* ITN cisc updated on fcp_data */
110
111 u32 fcp_data_lost; /* fcp data lost */
112
113 u32 ro_set_in_xfer_rdy; /* Target set RO in Xfer_rdy frame */
114 u32 xfer_rdy_ooo_err; /* Out of order Xfer_rdy received */
115 u32 xfer_rdy_unknown_err; /* unknown error in xfer_rdy frame */
116
117 u32 io_abort_timeout; /* ABTS timedout */
118 u32 sler_initiated; /* SLER initiated */
119
120 u32 unexp_fcp_rsp; /* fcp response in wrong state */
121
122 u32 fcp_rsp_under_run; /* fcp rsp IO underrun */
123 u32 fcp_rsp_under_run_wr; /* fcp rsp IO underrun for write */
124 u32 fcp_rsp_under_run_err; /* fcp rsp IO underrun error */
125 u32 fcp_rsp_resid_inval; /* invalid residue */
126 u32 fcp_rsp_over_run; /* fcp rsp IO overrun */
127 u32 fcp_rsp_over_run_err; /* fcp rsp IO overrun error */
128 u32 fcp_rsp_proto_err; /* protocol error in fcp rsp */
129 u32 fcp_rsp_sense_err; /* error in sense info in fcp rsp */
130 u32 fcp_conf_req; /* FCP conf requested */
131
132 u32 tgt_aborted_io; /* target initiated abort */
133
134 u32 ioh_edtov_timeout_event;/* IOH edtov timer popped */
135 u32 ioh_fcp_rsp_excp_event; /* IOH FCP_RSP exception */
136 u32 ioh_fcp_conf_event; /* IOH FCP_CONF */
137 u32 ioh_mult_frm_rsp_event; /* IOH multi_frame FCP_RSP */
138 u32 ioh_hit_class2_event; /* IOH hit class2 */
139 u32 ioh_miss_other_event; /* IOH miss other */
140 u32 ioh_seq_cnt_err_event; /* IOH seq cnt error */
141 u32 ioh_len_err_event; /* IOH len error - fcp_dl !=
142 * bytes xfered */
143 u32 ioh_seq_len_err_event; /* IOH seq len error */
144 u32 ioh_data_oor_event; /* Data out of range */
145 u32 ioh_ro_ooo_event; /* Relative offset out of range */
146 u32 ioh_cpu_owned_event; /* IOH hit -iost owned by f/w */
147 u32 ioh_unexp_frame_event; /* unexpected frame recieved
148 * count */
149 u32 ioh_err_int; /* IOH error int during data-phase
150 * for scsi write
151 */
152};
153
154/**
155 * IOC port firmware stats
156 */
157
158struct bfa_fw_port_fpg_stats_s {
159 u32 intr_evt;
160 u32 intr;
161 u32 intr_excess;
162 u32 intr_cause0;
163 u32 intr_other;
164 u32 intr_other_ign;
165 u32 sig_lost;
166 u32 sig_regained;
167 u32 sync_lost;
168 u32 sync_to;
169 u32 sync_regained;
170 u32 div2_overflow;
171 u32 div2_underflow;
172 u32 efifo_overflow;
173 u32 efifo_underflow;
174 u32 idle_rx;
175 u32 lrr_rx;
176 u32 lr_rx;
177 u32 ols_rx;
178 u32 nos_rx;
179 u32 lip_rx;
180 u32 arbf0_rx;
181 u32 arb_rx;
182 u32 mrk_rx;
183 u32 const_mrk_rx;
184 u32 prim_unknown;
185};
186
187
188struct bfa_fw_port_lksm_stats_s {
189 u32 hwsm_success; /* hwsm state machine success */
190 u32 hwsm_fails; /* hwsm fails */
191 u32 hwsm_wdtov; /* hwsm timed out */
192 u32 swsm_success; /* swsm success */
193 u32 swsm_fails; /* swsm fails */
194 u32 swsm_wdtov; /* swsm timed out */
195 u32 busybufs; /* link init failed due to busybuf */
196 u32 buf_waits; /* bufwait state entries */
197 u32 link_fails; /* link failures */
198 u32 psp_errors; /* primitive sequence protocol errors */
199 u32 lr_unexp; /* No. of times LR rx-ed unexpectedly */
200 u32 lrr_unexp; /* No. of times LRR rx-ed unexpectedly */
201 u32 lr_tx; /* No. of times LR tx started */
202 u32 lrr_tx; /* No. of times LRR tx started */
203 u32 ols_tx; /* No. of times OLS tx started */
204 u32 nos_tx; /* No. of times NOS tx started */
205 u32 hwsm_lrr_rx; /* No. of times LRR rx-ed by HWSM */
206 u32 hwsm_lr_rx; /* No. of times LR rx-ed by HWSM */
207};
208
209
210struct bfa_fw_port_snsm_stats_s {
211 u32 hwsm_success; /* Successful hwsm terminations */
212 u32 hwsm_fails; /* hwsm fail count */
213 u32 hwsm_wdtov; /* hwsm timed out */
214 u32 swsm_success; /* swsm success */
215 u32 swsm_wdtov; /* swsm timed out */
216 u32 error_resets; /* error resets initiated by upsm */
217 u32 sync_lost; /* Sync loss count */
218 u32 sig_lost; /* Signal loss count */
219};
220
221
222struct bfa_fw_port_physm_stats_s {
223 u32 module_inserts; /* Module insert count */
224 u32 module_xtracts; /* Module extracts count */
225 u32 module_invalids; /* Invalid module inserted count */
226 u32 module_read_ign; /* Module validation status ignored */
227 u32 laser_faults; /* Laser fault count */
228 u32 rsvd;
229};
230
231
232struct bfa_fw_fip_stats_s {
233 u32 vlan_req; /* vlan discovery requests */
234 u32 vlan_notify; /* vlan notifications */
235 u32 vlan_err; /* vlan response error */
236 u32 vlan_timeouts; /* vlan disvoery timeouts */
237 u32 vlan_invalids; /* invalid vlan in discovery advert. */
238 u32 disc_req; /* Discovery solicit requests */
239 u32 disc_rsp; /* Discovery solicit response */
240 u32 disc_err; /* Discovery advt. parse errors */
241 u32 disc_unsol; /* Discovery unsolicited */
242 u32 disc_timeouts; /* Discovery timeouts */
243 u32 disc_fcf_unavail; /* Discovery FCF Not Avail. */
244 u32 linksvc_unsupp; /* Unsupported link service req */
245 u32 linksvc_err; /* Parse error in link service req */
246 u32 logo_req; /* FIP logos received */
247 u32 clrvlink_req; /* Clear virtual link req */
248 u32 op_unsupp; /* Unsupported FIP operation */
249 u32 untagged; /* Untagged frames (ignored) */
250 u32 invalid_version; /*!< Invalid FIP version */
251};
252
253
254struct bfa_fw_lps_stats_s {
255 u32 mac_invalids; /* Invalid mac assigned */
256 u32 rsvd;
257};
258
259
260struct bfa_fw_fcoe_stats_s {
261 u32 cee_linkups; /* CEE link up count */
262 u32 cee_linkdns; /* CEE link down count */
263 u32 fip_linkups; /* FIP link up count */
264 u32 fip_linkdns; /* FIP link up count */
265 u32 fip_fails; /* FIP fail count */
266 u32 mac_invalids; /* Invalid mac assigned */
267};
268
269/**
270 * IOC firmware FCoE port stats
271 */
272struct bfa_fw_fcoe_port_stats_s {
273 struct bfa_fw_fcoe_stats_s fcoe_stats;
274 struct bfa_fw_fip_stats_s fip_stats;
275};
276
277/**
278 * IOC firmware FC port stats
279 */
280struct bfa_fw_fc_port_stats_s {
281 struct bfa_fw_port_fpg_stats_s fpg_stats;
282 struct bfa_fw_port_physm_stats_s physm_stats;
283 struct bfa_fw_port_snsm_stats_s snsm_stats;
284 struct bfa_fw_port_lksm_stats_s lksm_stats;
285};
286
287/**
288 * IOC firmware FC port stats
289 */
290union bfa_fw_port_stats_s {
291 struct bfa_fw_fc_port_stats_s fc_stats;
292 struct bfa_fw_fcoe_port_stats_s fcoe_stats;
293};
294
295/**
296 * IOC firmware stats
297 */
298struct bfa_fw_stats_s {
299 struct bfa_fw_ioc_stats_s ioc_stats;
300 struct bfa_fw_io_stats_s io_stats;
301 union bfa_fw_port_stats_s port_stats;
302};
303
304/**
305 * IOC statistics
306 */
307struct bfa_iocfc_stats_s {
308 struct bfa_fw_stats_s fw_stats; /* firmware IOC stats */
309};
310
311/**
312 * IOC attributes returned in queries
313 */
314struct bfa_iocfc_attr_s {
315 struct bfa_iocfc_cfg_s config; /* IOCFC config */
316 struct bfa_iocfc_intr_attr_s intr_attr; /* interrupt attr */
317};
318
319#define BFA_IOCFC_PATHTOV_MAX 60
320#define BFA_IOCFC_QDEPTH_MAX 2000
321
322#endif /* __BFA_DEFS_IOC_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_ipfc.h b/drivers/scsi/bfa/include/defs/bfa_defs_ipfc.h
deleted file mode 100644
index 7cb63ea98f38..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_ipfc.h
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_DEFS_IPFC_H__
18#define __BFA_DEFS_IPFC_H__
19
20#include <bfa_os_inc.h>
21#include <protocol/types.h>
22#include <defs/bfa_defs_types.h>
23
24/**
25 * FCS ip remote port states
26 */
27enum bfa_iprp_state {
28 BFA_IPRP_UNINIT = 0, /* PORT is not yet initialized */
29 BFA_IPRP_ONLINE = 1, /* process login is complete */
30 BFA_IPRP_OFFLINE = 2, /* iprp is offline */
31};
32
33/**
34 * FCS remote port statistics
35 */
36struct bfa_iprp_stats_s {
37 u32 offlines;
38 u32 onlines;
39 u32 rscns;
40 u32 plogis;
41 u32 logos;
42 u32 plogi_timeouts;
43 u32 plogi_rejects;
44};
45
46/**
47 * FCS iprp attribute returned in queries
48 */
49struct bfa_iprp_attr_s {
50 enum bfa_iprp_state state;
51};
52
53struct bfa_ipfc_stats_s {
54 u32 arp_sent;
55 u32 arp_recv;
56 u32 arp_reply_sent;
57 u32 arp_reply_recv;
58 u32 farp_sent;
59 u32 farp_recv;
60 u32 farp_reply_sent;
61 u32 farp_reply_recv;
62 u32 farp_reject_sent;
63 u32 farp_reject_recv;
64};
65
66struct bfa_ipfc_attr_s {
67 bfa_boolean_t enabled;
68};
69
70#endif /* __BFA_DEFS_IPFC_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_itnim.h b/drivers/scsi/bfa/include/defs/bfa_defs_itnim.h
deleted file mode 100644
index d77788b3999a..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_itnim.h
+++ /dev/null
@@ -1,136 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_DEFS_ITNIM_H__
18#define __BFA_DEFS_ITNIM_H__
19
20#include <bfa_os_inc.h>
21#include <protocol/types.h>
22
23/**
24 * FCS itnim states
25 */
26enum bfa_itnim_state {
27 BFA_ITNIM_OFFLINE = 0, /* offline */
28 BFA_ITNIM_PRLI_SEND = 1, /* prli send */
29 BFA_ITNIM_PRLI_SENT = 2, /* prli sent */
30 BFA_ITNIM_PRLI_RETRY = 3, /* prli retry */
31 BFA_ITNIM_HCB_ONLINE = 4, /* online callback */
32 BFA_ITNIM_ONLINE = 5, /* online */
33 BFA_ITNIM_HCB_OFFLINE = 6, /* offline callback */
34 BFA_ITNIM_INITIATIOR = 7, /* initiator */
35};
36
37struct bfa_itnim_latency_s {
38 u32 min;
39 u32 max;
40 u32 count;
41 u32 clock_res;
42 u32 avg;
43 u32 rsvd;
44};
45
46struct bfa_itnim_hal_stats_s {
47 u32 onlines; /* ITN nexus onlines (PRLI done) */
48 u32 offlines; /* ITN Nexus offlines */
49 u32 creates; /* ITN create requests */
50 u32 deletes; /* ITN delete requests */
51 u32 create_comps; /* ITN create completions */
52 u32 delete_comps; /* ITN delete completions */
53 u32 sler_events; /* SLER (sequence level error
54 * recovery) events */
55 u32 ioc_disabled; /* Num IOC disables */
56 u32 cleanup_comps; /* ITN cleanup completions */
57 u32 tm_cmnds; /* task management(TM) cmnds sent */
58 u32 tm_fw_rsps; /* TM cmds firmware responses */
59 u32 tm_success; /* TM successes */
60 u32 tm_failures; /* TM failures */
61 u32 tm_io_comps; /* TM IO completions */
62 u32 tm_qresumes; /* TM queue resumes (after waiting
63 * for resources)
64 */
65 u32 tm_iocdowns; /* TM cmnds affected by IOC down */
66 u32 tm_cleanups; /* TM cleanups */
67 u32 tm_cleanup_comps;
68 /* TM cleanup completions */
69 u32 ios; /* IO requests */
70 u32 io_comps; /* IO completions */
71 u64 input_reqs; /* INPUT requests */
72 u64 output_reqs; /* OUTPUT requests */
73};
74
75/**
76 * FCS remote port statistics
77 */
78struct bfa_itnim_stats_s {
79 u32 onlines; /* num rport online */
80 u32 offlines; /* num rport offline */
81 u32 prli_sent; /* num prli sent out */
82 u32 fcxp_alloc_wait;/* num fcxp alloc waits */
83 u32 prli_rsp_err; /* num prli rsp errors */
84 u32 prli_rsp_acc; /* num prli rsp accepts */
85 u32 initiator; /* rport is an initiator */
86 u32 prli_rsp_parse_err; /* prli rsp parsing errors */
87 u32 prli_rsp_rjt; /* num prli rsp rejects */
88 u32 timeout; /* num timeouts detected */
89 u32 sler; /* num sler notification from BFA */
90 u32 rsvd;
91 struct bfa_itnim_hal_stats_s hal_stats;
92};
93
94/**
95 * FCS itnim attributes returned in queries
96 */
97struct bfa_itnim_attr_s {
98 enum bfa_itnim_state state; /* FCS itnim state */
99 u8 retry; /* data retransmision support */
100 u8 task_retry_id; /* task retry ident support */
101 u8 rec_support; /* REC supported */
102 u8 conf_comp; /* confirmed completion supp */
103 struct bfa_itnim_latency_s io_latency; /* IO latency */
104};
105
106/**
107 * BFA ITNIM events.
108 * Arguments below are in BFAL context from Mgmt
109 * BFA_ITNIM_AEN_NEW: [in]: None [out]: vf_id, lpwwn
110 * BFA_ITNIM_AEN_DELETE: [in]: vf_id, lpwwn, rpwwn (0 = all fcp4 targets),
111 * [out]: vf_id, ppwwn, lpwwn, rpwwn
112 * BFA_ITNIM_AEN_ONLINE: [in]: vf_id, lpwwn, rpwwn (0 = all fcp4 targets),
113 * [out]: vf_id, ppwwn, lpwwn, rpwwn
114 * BFA_ITNIM_AEN_OFFLINE: [in]: vf_id, lpwwn, rpwwn (0 = all fcp4 targets),
115 * [out]: vf_id, ppwwn, lpwwn, rpwwn
116 * BFA_ITNIM_AEN_DISCONNECT:[in]: vf_id, lpwwn, rpwwn (0 = all fcp4 targets),
117 * [out]: vf_id, ppwwn, lpwwn, rpwwn
118 */
119enum bfa_itnim_aen_event {
120 BFA_ITNIM_AEN_ONLINE = 1, /* Target online */
121 BFA_ITNIM_AEN_OFFLINE = 2, /* Target offline */
122 BFA_ITNIM_AEN_DISCONNECT = 3, /* Target disconnected */
123};
124
125/**
126 * BFA ITNIM event data structure.
127 */
128struct bfa_itnim_aen_data_s {
129 u16 vf_id; /* vf_id of the IT nexus */
130 u16 rsvd[3];
131 wwn_t ppwwn; /* WWN of its physical port */
132 wwn_t lpwwn; /* WWN of logical port */
133 wwn_t rpwwn; /* WWN of remote(target) port */
134};
135
136#endif /* __BFA_DEFS_ITNIM_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_led.h b/drivers/scsi/bfa/include/defs/bfa_defs_led.h
deleted file mode 100644
index 62039273264e..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_led.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_LED_H__
19#define __BFA_DEFS_LED_H__
20
21#define BFA_LED_MAX_NUM 3
22
23enum bfa_led_op {
24 BFA_LED_OFF = 0,
25 BFA_LED_ON = 1,
26 BFA_LED_FLICK = 2,
27 BFA_LED_BLINK = 3,
28};
29
30enum bfa_led_color {
31 BFA_LED_GREEN = 0,
32 BFA_LED_AMBER = 1,
33};
34
35#endif /* __BFA_DEFS_LED_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_lport.h b/drivers/scsi/bfa/include/defs/bfa_defs_lport.h
deleted file mode 100644
index 0952a139c47c..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_lport.h
+++ /dev/null
@@ -1,68 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_LPORT_H__
19#define __BFA_DEFS_LPORT_H__
20
21#include <defs/bfa_defs_types.h>
22#include <defs/bfa_defs_port.h>
23
24/**
25 * BFA AEN logical port events.
26 * Arguments below are in BFAL context from Mgmt
27 * BFA_LPORT_AEN_NEW: [in]: None [out]: vf_id, ppwwn, lpwwn, roles
28 * BFA_LPORT_AEN_DELETE: [in]: lpwwn [out]: vf_id, ppwwn. lpwwn, roles
29 * BFA_LPORT_AEN_ONLINE: [in]: lpwwn [out]: vf_id, ppwwn. lpwwn, roles
30 * BFA_LPORT_AEN_OFFLINE: [in]: lpwwn [out]: vf_id, ppwwn. lpwwn, roles
31 * BFA_LPORT_AEN_DISCONNECT:[in]: lpwwn [out]: vf_id, ppwwn. lpwwn, roles
32 * BFA_LPORT_AEN_NEW_PROP: [in]: None [out]: vf_id, ppwwn. lpwwn, roles
33 * BFA_LPORT_AEN_DELETE_PROP: [in]: lpwwn [out]: vf_id, ppwwn. lpwwn, roles
34 * BFA_LPORT_AEN_NEW_STANDARD: [in]: None [out]: vf_id, ppwwn. lpwwn, roles
35 * BFA_LPORT_AEN_DELETE_STANDARD: [in]: lpwwn [out]: vf_id, ppwwn. lpwwn, roles
36 * BFA_LPORT_AEN_NPIV_DUP_WWN: [in]: lpwwn [out]: vf_id, ppwwn. lpwwn, roles
37 * BFA_LPORT_AEN_NPIV_FABRIC_MAX: [in]: lpwwn [out]: vf_id, ppwwn. lpwwn, roles
38 * BFA_LPORT_AEN_NPIV_UNKNOWN: [in]: lpwwn [out]: vf_id, ppwwn. lpwwn, roles
39 */
40enum bfa_lport_aen_event {
41 BFA_LPORT_AEN_NEW = 1, /* LPort created event */
42 BFA_LPORT_AEN_DELETE = 2, /* LPort deleted event */
43 BFA_LPORT_AEN_ONLINE = 3, /* LPort online event */
44 BFA_LPORT_AEN_OFFLINE = 4, /* LPort offline event */
45 BFA_LPORT_AEN_DISCONNECT = 5, /* LPort disconnect event */
46 BFA_LPORT_AEN_NEW_PROP = 6, /* VPort created event */
47 BFA_LPORT_AEN_DELETE_PROP = 7, /* VPort deleted event */
48 BFA_LPORT_AEN_NEW_STANDARD = 8, /* VPort created event */
49 BFA_LPORT_AEN_DELETE_STANDARD = 9, /* VPort deleted event */
50 BFA_LPORT_AEN_NPIV_DUP_WWN = 10, /* VPort configured with
51 * duplicate WWN event
52 */
53 BFA_LPORT_AEN_NPIV_FABRIC_MAX = 11, /* Max NPIV in fabric/fport */
54 BFA_LPORT_AEN_NPIV_UNKNOWN = 12, /* Unknown NPIV Error code event */
55};
56
57/**
58 * BFA AEN event data structure
59 */
60struct bfa_lport_aen_data_s {
61 u16 vf_id; /* vf_id of this logical port */
62 s16 roles; /* Logical port mode,IM/TM/IP etc */
63 u32 rsvd;
64 wwn_t ppwwn; /* WWN of its physical port */
65 wwn_t lpwwn; /* WWN of this logical port */
66};
67
68#endif /* __BFA_DEFS_LPORT_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_mfg.h b/drivers/scsi/bfa/include/defs/bfa_defs_mfg.h
deleted file mode 100644
index d22fb7909643..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_mfg.h
+++ /dev/null
@@ -1,144 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_DEFS_MFG_H__
18#define __BFA_DEFS_MFG_H__
19
20#include <bfa_os_inc.h>
21
22/**
23 * Manufacturing block version
24 */
25#define BFA_MFG_VERSION 2
26
27/**
28 * Manufacturing block encrypted version
29 */
30#define BFA_MFG_ENC_VER 2
31
32/**
33 * Manufacturing block version 1 length
34 */
35#define BFA_MFG_VER1_LEN 128
36
37/**
38 * Manufacturing block header length
39 */
40#define BFA_MFG_HDR_LEN 4
41
42/**
43 * Checksum size
44 */
45#define BFA_MFG_CHKSUM_SIZE 16
46
47/**
48 * Manufacturing block format
49 */
50#define BFA_MFG_SERIALNUM_SIZE 11
51#define BFA_MFG_PARTNUM_SIZE 14
52#define BFA_MFG_SUPPLIER_ID_SIZE 10
53#define BFA_MFG_SUPPLIER_PARTNUM_SIZE 20
54#define BFA_MFG_SUPPLIER_SERIALNUM_SIZE 20
55#define BFA_MFG_SUPPLIER_REVISION_SIZE 4
56#define STRSZ(_n) (((_n) + 4) & ~3)
57
58/**
59 * Manufacturing card type
60 */
61enum {
62 BFA_MFG_TYPE_CB_MAX = 825, /* Crossbow card type max */
63 BFA_MFG_TYPE_FC8P2 = 825, /* 8G 2port FC card */
64 BFA_MFG_TYPE_FC8P1 = 815, /* 8G 1port FC card */
65 BFA_MFG_TYPE_FC4P2 = 425, /* 4G 2port FC card */
66 BFA_MFG_TYPE_FC4P1 = 415, /* 4G 1port FC card */
67 BFA_MFG_TYPE_CNA10P2 = 1020, /* 10G 2port CNA card */
68 BFA_MFG_TYPE_CNA10P1 = 1010, /* 10G 1port CNA card */
69 BFA_MFG_TYPE_JAYHAWK = 804, /* Jayhawk mezz card */
70 BFA_MFG_TYPE_WANCHESE = 1007, /* Wanchese mezz card */
71 BFA_MFG_TYPE_INVALID = 0, /* Invalid card type */
72};
73
74#pragma pack(1)
75
76/**
77 * Card type to port number conversion
78 */
79#define bfa_mfg_type2port_num(card_type) (((card_type) / 10) % 10)
80
81/**
82 * Check if Mezz card
83 */
84#define bfa_mfg_is_mezz(type) (( \
85 (type) == BFA_MFG_TYPE_JAYHAWK || \
86 (type) == BFA_MFG_TYPE_WANCHESE))
87
88/**
89 * Check if card type valid
90 */
91#define bfa_mfg_is_card_type_valid(type) (( \
92 (type) == BFA_MFG_TYPE_FC8P2 || \
93 (type) == BFA_MFG_TYPE_FC8P1 || \
94 (type) == BFA_MFG_TYPE_FC4P2 || \
95 (type) == BFA_MFG_TYPE_FC4P1 || \
96 (type) == BFA_MFG_TYPE_CNA10P2 || \
97 (type) == BFA_MFG_TYPE_CNA10P1 || \
98 bfa_mfg_is_mezz(type)))
99
100/**
101 * All numerical fields are in big-endian format.
102 */
103struct bfa_mfg_block_s {
104};
105
106/**
107 * VPD data length
108 */
109#define BFA_MFG_VPD_LEN 512
110
111#define BFA_MFG_VPD_PCI_HDR_OFF 137
112#define BFA_MFG_VPD_PCI_VER_MASK 0x07 /* version mask 3 bits */
113#define BFA_MFG_VPD_PCI_VDR_MASK 0xf8 /* vendor mask 5 bits */
114
115/**
116 * VPD vendor tag
117 */
118enum {
119 BFA_MFG_VPD_UNKNOWN = 0, /* vendor unknown */
120 BFA_MFG_VPD_IBM = 1, /* vendor IBM */
121 BFA_MFG_VPD_HP = 2, /* vendor HP */
122 BFA_MFG_VPD_DELL = 3, /* vendor DELL */
123 BFA_MFG_VPD_PCI_IBM = 0x08, /* PCI VPD IBM */
124 BFA_MFG_VPD_PCI_HP = 0x10, /* PCI VPD HP */
125 BFA_MFG_VPD_PCI_DELL = 0x20, /* PCI VPD DELL */
126 BFA_MFG_VPD_PCI_BRCD = 0xf8, /* PCI VPD Brocade */
127};
128
129/**
130 * All numerical fields are in big-endian format.
131 */
132struct bfa_mfg_vpd_s {
133 u8 version; /* vpd data version */
134 u8 vpd_sig[3]; /* characters 'V', 'P', 'D' */
135 u8 chksum; /* u8 checksum */
136 u8 vendor; /* vendor */
137 u8 len; /* vpd data length excluding header */
138 u8 rsv;
139 u8 data[BFA_MFG_VPD_LEN]; /* vpd data */
140};
141
142#pragma pack()
143
144#endif /* __BFA_DEFS_MFG_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_pci.h b/drivers/scsi/bfa/include/defs/bfa_defs_pci.h
deleted file mode 100644
index ea7d89bbc0bb..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_pci.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_PCI_H__
19#define __BFA_DEFS_PCI_H__
20
21/**
22 * PCI device and vendor ID information
23 */
24enum {
25 BFA_PCI_VENDOR_ID_BROCADE = 0x1657,
26 BFA_PCI_DEVICE_ID_FC_8G2P = 0x13,
27 BFA_PCI_DEVICE_ID_FC_8G1P = 0x17,
28 BFA_PCI_DEVICE_ID_CT = 0x14,
29 BFA_PCI_DEVICE_ID_CT_FC = 0x21,
30};
31
32#define bfa_asic_id_ct(devid) \
33 ((devid) == BFA_PCI_DEVICE_ID_CT || \
34 (devid) == BFA_PCI_DEVICE_ID_CT_FC)
35
36/**
37 * PCI sub-system device and vendor ID information
38 */
39enum {
40 BFA_PCI_FCOE_SSDEVICE_ID = 0x14,
41};
42
43/**
44 * Maximum number of device address ranges mapped through different BAR(s)
45 */
46#define BFA_PCI_ACCESS_RANGES 1
47
48#endif /* __BFA_DEFS_PCI_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_pm.h b/drivers/scsi/bfa/include/defs/bfa_defs_pm.h
deleted file mode 100644
index e8d6d959006e..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_pm.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_PM_H__
19#define __BFA_DEFS_PM_H__
20
21#include <bfa_os_inc.h>
22
23/**
24 * BFA power management device states
25 */
26enum bfa_pm_ds {
27 BFA_PM_DS_D0 = 0, /* full power mode */
28 BFA_PM_DS_D1 = 1, /* power save state 1 */
29 BFA_PM_DS_D2 = 2, /* power save state 2 */
30 BFA_PM_DS_D3 = 3, /* power off state */
31};
32
33#endif /* __BFA_DEFS_PM_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_pom.h b/drivers/scsi/bfa/include/defs/bfa_defs_pom.h
deleted file mode 100644
index d9fa278472b7..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_pom.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_DEFS_POM_H__
18#define __BFA_DEFS_POM_H__
19
20#include <bfa_os_inc.h>
21#include <defs/bfa_defs_types.h>
22
23/**
24 * POM health status levels for each attributes.
25 */
26enum bfa_pom_entry_health {
27 BFA_POM_HEALTH_NOINFO = 1, /* no information */
28 BFA_POM_HEALTH_NORMAL = 2, /* health is normal */
29 BFA_POM_HEALTH_WARNING = 3, /* warning level */
30 BFA_POM_HEALTH_ALARM = 4, /* alarming level */
31};
32
33/**
34 * Reading of temperature/voltage/current/power
35 */
36struct bfa_pom_entry_s {
37 enum bfa_pom_entry_health health; /* POM entry health */
38 u32 curr_value; /* current value */
39 u32 thr_warn_high; /* threshold warning high */
40 u32 thr_warn_low; /* threshold warning low */
41 u32 thr_alarm_low; /* threshold alaram low */
42 u32 thr_alarm_high; /* threshold alarm high */
43};
44
45/**
46 * POM attributes
47 */
48struct bfa_pom_attr_s {
49 struct bfa_pom_entry_s temperature; /* centigrade */
50 struct bfa_pom_entry_s voltage; /* volts */
51 struct bfa_pom_entry_s curr; /* milli amps */
52 struct bfa_pom_entry_s txpower; /* micro watts */
53 struct bfa_pom_entry_s rxpower; /* micro watts */
54};
55
56#endif /* __BFA_DEFS_POM_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_port.h b/drivers/scsi/bfa/include/defs/bfa_defs_port.h
deleted file mode 100644
index ebdf0d1731a4..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_port.h
+++ /dev/null
@@ -1,248 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_PORT_H__
19#define __BFA_DEFS_PORT_H__
20
21#include <bfa_os_inc.h>
22#include <protocol/types.h>
23#include <defs/bfa_defs_pport.h>
24#include <defs/bfa_defs_ioc.h>
25
26#define BFA_FCS_FABRIC_IPADDR_SZ 16
27
28/**
29 * symbolic names for base port/virtual port
30 */
31#define BFA_SYMNAME_MAXLEN 128 /* vmware/windows uses 128 bytes */
32struct bfa_port_symname_s {
33 char symname[BFA_SYMNAME_MAXLEN];
34};
35
36/**
37* Roles of FCS port:
38 * - FCP IM and FCP TM roles cannot be enabled together for a FCS port
39 * - Create multiple ports if both IM and TM functions required.
40 * - Atleast one role must be specified.
41 */
42enum bfa_port_role {
43 BFA_PORT_ROLE_FCP_IM = 0x01, /* FCP initiator role */
44 BFA_PORT_ROLE_FCP_TM = 0x02, /* FCP target role */
45 BFA_PORT_ROLE_FCP_IPFC = 0x04, /* IP over FC role */
46 BFA_PORT_ROLE_FCP_MAX = BFA_PORT_ROLE_FCP_IPFC | BFA_PORT_ROLE_FCP_IM
47};
48
49/**
50 * FCS port configuration.
51 */
52struct bfa_port_cfg_s {
53 wwn_t pwwn; /* port wwn */
54 wwn_t nwwn; /* node wwn */
55 struct bfa_port_symname_s sym_name; /* vm port symbolic name */
56 bfa_boolean_t preboot_vp; /* vport created from PBC */
57 enum bfa_port_role roles; /* FCS port roles */
58 u8 tag[16]; /* opaque tag from application */
59};
60
61/**
62 * FCS port states
63 */
64enum bfa_port_state {
65 BFA_PORT_UNINIT = 0, /* PORT is not yet initialized */
66 BFA_PORT_FDISC = 1, /* FDISC is in progress */
67 BFA_PORT_ONLINE = 2, /* login to fabric is complete */
68 BFA_PORT_OFFLINE = 3, /* No login to fabric */
69};
70
71/**
72 * FCS port type. Required for VmWare.
73 */
74enum bfa_port_type {
75 BFA_PORT_TYPE_PHYSICAL = 0,
76 BFA_PORT_TYPE_VIRTUAL,
77};
78
79/**
80 * FCS port offline reason. Required for VmWare.
81 */
82enum bfa_port_offline_reason {
83 BFA_PORT_OFFLINE_UNKNOWN = 0,
84 BFA_PORT_OFFLINE_LINKDOWN,
85 BFA_PORT_OFFLINE_FAB_UNSUPPORTED, /* NPIV not supported by the
86 * fabric */
87 BFA_PORT_OFFLINE_FAB_NORESOURCES,
88 BFA_PORT_OFFLINE_FAB_LOGOUT,
89};
90
91/**
92 * FCS lport info. Required for VmWare.
93 */
94struct bfa_port_info_s {
95 u8 port_type; /* bfa_port_type_t : physical or
96 * virtual */
97 u8 port_state; /* one of bfa_port_state values */
98 u8 offline_reason; /* one of bfa_port_offline_reason_t
99 * values */
100 wwn_t port_wwn;
101 wwn_t node_wwn;
102
103 /*
104 * following 4 feilds are valid for Physical Ports only
105 */
106 u32 max_vports_supp; /* Max supported vports */
107 u32 num_vports_inuse; /* Num of in use vports */
108 u32 max_rports_supp; /* Max supported rports */
109 u32 num_rports_inuse; /* Num of doscovered rports */
110
111};
112
113/**
114 * FCS port statistics
115 */
116struct bfa_port_stats_s {
117 u32 ns_plogi_sent;
118 u32 ns_plogi_rsp_err;
119 u32 ns_plogi_acc_err;
120 u32 ns_plogi_accepts;
121 u32 ns_rejects; /* NS command rejects */
122 u32 ns_plogi_unknown_rsp;
123 u32 ns_plogi_alloc_wait;
124
125 u32 ns_retries; /* NS command retries */
126 u32 ns_timeouts; /* NS command timeouts */
127
128 u32 ns_rspnid_sent;
129 u32 ns_rspnid_accepts;
130 u32 ns_rspnid_rsp_err;
131 u32 ns_rspnid_rejects;
132 u32 ns_rspnid_alloc_wait;
133
134 u32 ns_rftid_sent;
135 u32 ns_rftid_accepts;
136 u32 ns_rftid_rsp_err;
137 u32 ns_rftid_rejects;
138 u32 ns_rftid_alloc_wait;
139
140 u32 ns_rffid_sent;
141 u32 ns_rffid_accepts;
142 u32 ns_rffid_rsp_err;
143 u32 ns_rffid_rejects;
144 u32 ns_rffid_alloc_wait;
145
146 u32 ns_gidft_sent;
147 u32 ns_gidft_accepts;
148 u32 ns_gidft_rsp_err;
149 u32 ns_gidft_rejects;
150 u32 ns_gidft_unknown_rsp;
151 u32 ns_gidft_alloc_wait;
152
153 /*
154 * Mgmt Server stats
155 */
156 u32 ms_retries; /* MS command retries */
157 u32 ms_timeouts; /* MS command timeouts */
158 u32 ms_plogi_sent;
159 u32 ms_plogi_rsp_err;
160 u32 ms_plogi_acc_err;
161 u32 ms_plogi_accepts;
162 u32 ms_rejects; /* MS command rejects */
163 u32 ms_plogi_unknown_rsp;
164 u32 ms_plogi_alloc_wait;
165
166 u32 num_rscn; /* Num of RSCN received */
167 u32 num_portid_rscn;/* Num portid format RSCN
168 * received */
169
170 u32 uf_recvs; /* unsolicited recv frames */
171 u32 uf_recv_drops; /* dropped received frames */
172
173 u32 rsvd; /* padding for 64 bit alignment */
174};
175
176/**
177 * BFA port attribute returned in queries
178 */
179struct bfa_port_attr_s {
180 enum bfa_port_state state; /* port state */
181 u32 pid; /* port ID */
182 struct bfa_port_cfg_s port_cfg; /* port configuration */
183 enum bfa_pport_type port_type; /* current topology */
184 u32 loopback; /* cable is externally looped back */
185 wwn_t fabric_name; /* attached switch's nwwn */
186 u8 fabric_ip_addr[BFA_FCS_FABRIC_IPADDR_SZ]; /* attached
187 * fabric's ip addr */
188 struct mac_s fpma_mac; /* Lport's FPMA Mac address */
189 u16 authfail; /* auth failed state */
190};
191
192/**
193 * BFA physical port Level events
194 * Arguments below are in BFAL context from Mgmt
195 * BFA_PORT_AEN_ONLINE: [in]: pwwn [out]: pwwn
196 * BFA_PORT_AEN_OFFLINE: [in]: pwwn [out]: pwwn
197 * BFA_PORT_AEN_RLIR: [in]: None [out]: pwwn, rlir_data, rlir_len
198 * BFA_PORT_AEN_SFP_INSERT: [in]: pwwn [out]: port_id, pwwn
199 * BFA_PORT_AEN_SFP_REMOVE: [in]: pwwn [out]: port_id, pwwn
200 * BFA_PORT_AEN_SFP_POM: [in]: pwwn [out]: level, port_id, pwwn
201 * BFA_PORT_AEN_ENABLE: [in]: pwwn [out]: pwwn
202 * BFA_PORT_AEN_DISABLE: [in]: pwwn [out]: pwwn
203 * BFA_PORT_AEN_AUTH_ON: [in]: pwwn [out]: pwwn
204 * BFA_PORT_AEN_AUTH_OFF: [in]: pwwn [out]: pwwn
205 * BFA_PORT_AEN_DISCONNECT: [in]: pwwn [out]: pwwn
206 * BFA_PORT_AEN_QOS_NEG: [in]: pwwn [out]: pwwn
207 * BFA_PORT_AEN_FABRIC_NAME_CHANGE: [in]: pwwn, [out]: pwwn, fwwn
208 *
209 */
210enum bfa_port_aen_event {
211 BFA_PORT_AEN_ONLINE = 1, /* Physical Port online event */
212 BFA_PORT_AEN_OFFLINE = 2, /* Physical Port offline event */
213 BFA_PORT_AEN_RLIR = 3, /* RLIR event, not supported */
214 BFA_PORT_AEN_SFP_INSERT = 4, /* SFP inserted event */
215 BFA_PORT_AEN_SFP_REMOVE = 5, /* SFP removed event */
216 BFA_PORT_AEN_SFP_POM = 6, /* SFP POM event */
217 BFA_PORT_AEN_ENABLE = 7, /* Physical Port enable event */
218 BFA_PORT_AEN_DISABLE = 8, /* Physical Port disable event */
219 BFA_PORT_AEN_AUTH_ON = 9, /* Physical Port auth success event */
220 BFA_PORT_AEN_AUTH_OFF = 10, /* Physical Port auth fail event */
221 BFA_PORT_AEN_DISCONNECT = 11, /* Physical Port disconnect event */
222 BFA_PORT_AEN_QOS_NEG = 12, /* Base Port QOS negotiation event */
223 BFA_PORT_AEN_FABRIC_NAME_CHANGE = 13, /* Fabric Name/WWN change
224 * event */
225 BFA_PORT_AEN_SFP_ACCESS_ERROR = 14, /* SFP read error event */
226 BFA_PORT_AEN_SFP_UNSUPPORT = 15, /* Unsupported SFP event */
227};
228
229enum bfa_port_aen_sfp_pom {
230 BFA_PORT_AEN_SFP_POM_GREEN = 1, /* Normal */
231 BFA_PORT_AEN_SFP_POM_AMBER = 2, /* Warning */
232 BFA_PORT_AEN_SFP_POM_RED = 3, /* Critical */
233 BFA_PORT_AEN_SFP_POM_MAX = BFA_PORT_AEN_SFP_POM_RED
234};
235
236struct bfa_port_aen_data_s {
237 wwn_t pwwn; /* WWN of the physical port */
238 wwn_t fwwn; /* WWN of the fabric port */
239 s32 phy_port_num; /*! For SFP related events */
240 s16 ioc_type;
241 s16 level; /* Only transitions will
242 * be informed */
243 struct mac_s mac; /* MAC address of the ethernet port,
244 * applicable to CNA port only */
245 s16 rsvd;
246};
247
248#endif /* __BFA_DEFS_PORT_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_pport.h b/drivers/scsi/bfa/include/defs/bfa_defs_pport.h
deleted file mode 100644
index 2de675839c2f..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_pport.h
+++ /dev/null
@@ -1,393 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_PPORT_H__
19#define __BFA_DEFS_PPORT_H__
20
21#include <bfa_os_inc.h>
22#include <protocol/fc.h>
23#include <defs/bfa_defs_types.h>
24#include <defs/bfa_defs_qos.h>
25#include <cna/pstats/phyport_defs.h>
26
27/* Modify char* port_stt[] in bfal_port.c if a new state was added */
28enum bfa_pport_states {
29 BFA_PPORT_ST_UNINIT = 1,
30 BFA_PPORT_ST_ENABLING_QWAIT = 2,
31 BFA_PPORT_ST_ENABLING = 3,
32 BFA_PPORT_ST_LINKDOWN = 4,
33 BFA_PPORT_ST_LINKUP = 5,
34 BFA_PPORT_ST_DISABLING_QWAIT = 6,
35 BFA_PPORT_ST_DISABLING = 7,
36 BFA_PPORT_ST_DISABLED = 8,
37 BFA_PPORT_ST_STOPPED = 9,
38 BFA_PPORT_ST_IOCDOWN = 10,
39 BFA_PPORT_ST_IOCDIS = 11,
40 BFA_PPORT_ST_FWMISMATCH = 12,
41 BFA_PPORT_ST_PREBOOT_DISABLED = 13,
42 BFA_PPORT_ST_MAX_STATE,
43};
44
45/**
46 * Port speed settings. Each specific speed is a bit field. Use multiple
47 * bits to specify speeds to be selected for auto-negotiation.
48 */
49enum bfa_pport_speed {
50 BFA_PPORT_SPEED_UNKNOWN = 0,
51 BFA_PPORT_SPEED_1GBPS = 1,
52 BFA_PPORT_SPEED_2GBPS = 2,
53 BFA_PPORT_SPEED_4GBPS = 4,
54 BFA_PPORT_SPEED_8GBPS = 8,
55 BFA_PPORT_SPEED_10GBPS = 10,
56 BFA_PPORT_SPEED_AUTO =
57 (BFA_PPORT_SPEED_1GBPS | BFA_PPORT_SPEED_2GBPS |
58 BFA_PPORT_SPEED_4GBPS | BFA_PPORT_SPEED_8GBPS),
59};
60
61/**
62 * Port operational type (in sync with SNIA port type).
63 */
64enum bfa_pport_type {
65 BFA_PPORT_TYPE_UNKNOWN = 1, /* port type is unknown */
66 BFA_PPORT_TYPE_TRUNKED = 2, /* Trunked mode */
67 BFA_PPORT_TYPE_NPORT = 5, /* P2P with switched fabric */
68 BFA_PPORT_TYPE_NLPORT = 6, /* public loop */
69 BFA_PPORT_TYPE_LPORT = 20, /* private loop */
70 BFA_PPORT_TYPE_P2P = 21, /* P2P with no switched fabric */
71 BFA_PPORT_TYPE_VPORT = 22, /* NPIV - virtual port */
72};
73
74/**
75 * Port topology setting. A port's topology and fabric login status
76 * determine its operational type.
77 */
78enum bfa_pport_topology {
79 BFA_PPORT_TOPOLOGY_NONE = 0, /* No valid topology */
80 BFA_PPORT_TOPOLOGY_P2P = 1, /* P2P only */
81 BFA_PPORT_TOPOLOGY_LOOP = 2, /* LOOP topology */
82 BFA_PPORT_TOPOLOGY_AUTO = 3, /* auto topology selection */
83};
84
85/**
86 * Physical port loopback types.
87 */
88enum bfa_pport_opmode {
89 BFA_PPORT_OPMODE_NORMAL = 0x00, /* normal non-loopback mode */
90 BFA_PPORT_OPMODE_LB_INT = 0x01, /* internal loop back */
91 BFA_PPORT_OPMODE_LB_SLW = 0x02, /* serial link wrapback (serdes) */
92 BFA_PPORT_OPMODE_LB_EXT = 0x04, /* external loop back (serdes) */
93 BFA_PPORT_OPMODE_LB_CBL = 0x08, /* cabled loop back */
94 BFA_PPORT_OPMODE_LB_NLINT = 0x20, /* NL_Port internal loopback */
95};
96
97#define BFA_PPORT_OPMODE_LB_HARD(_mode) \
98 ((_mode == BFA_PPORT_OPMODE_LB_INT) || \
99 (_mode == BFA_PPORT_OPMODE_LB_SLW) || \
100 (_mode == BFA_PPORT_OPMODE_LB_EXT))
101
102/**
103 Port State (in sync with SNIA port state).
104 */
105enum bfa_pport_snia_state {
106 BFA_PPORT_STATE_UNKNOWN = 1, /* port is not initialized */
107 BFA_PPORT_STATE_ONLINE = 2, /* port is ONLINE */
108 BFA_PPORT_STATE_DISABLED = 3, /* port is disabled by user */
109 BFA_PPORT_STATE_BYPASSED = 4, /* port is bypassed (in LOOP) */
110 BFA_PPORT_STATE_DIAG = 5, /* port diagnostics is active */
111 BFA_PPORT_STATE_LINKDOWN = 6, /* link is down */
112 BFA_PPORT_STATE_LOOPBACK = 8, /* port is looped back */
113};
114
115/**
116 * Port link state
117 */
118enum bfa_pport_linkstate {
119 BFA_PPORT_LINKUP = 1, /* Physical port/Trunk link up */
120 BFA_PPORT_LINKDOWN = 2, /* Physical port/Trunk link down */
121 BFA_PPORT_TRUNK_LINKDOWN = 3, /* Trunk link down (new tmaster) */
122};
123
124/**
125 * Port link state event
126 */
127#define bfa_pport_event_t enum bfa_pport_linkstate
128
129/**
130 * Port link state reason code
131 */
132enum bfa_pport_linkstate_rsn {
133 BFA_PPORT_LINKSTATE_RSN_NONE = 0,
134 BFA_PPORT_LINKSTATE_RSN_DISABLED = 1,
135 BFA_PPORT_LINKSTATE_RSN_RX_NOS = 2,
136 BFA_PPORT_LINKSTATE_RSN_RX_OLS = 3,
137 BFA_PPORT_LINKSTATE_RSN_RX_LIP = 4,
138 BFA_PPORT_LINKSTATE_RSN_RX_LIPF7 = 5,
139 BFA_PPORT_LINKSTATE_RSN_SFP_REMOVED = 6,
140 BFA_PPORT_LINKSTATE_RSN_PORT_FAULT = 7,
141 BFA_PPORT_LINKSTATE_RSN_RX_LOS = 8,
142 BFA_PPORT_LINKSTATE_RSN_LOCAL_FAULT = 9,
143 BFA_PPORT_LINKSTATE_RSN_REMOTE_FAULT = 10,
144 BFA_PPORT_LINKSTATE_RSN_TIMEOUT = 11,
145
146
147
148 /* CEE related reason codes/errors */
149 CEE_LLDP_INFO_AGED_OUT = 20,
150 CEE_LLDP_SHUTDOWN_TLV_RCVD = 21,
151 CEE_PEER_NOT_ADVERTISE_DCBX = 22,
152 CEE_PEER_NOT_ADVERTISE_PG = 23,
153 CEE_PEER_NOT_ADVERTISE_PFC = 24,
154 CEE_PEER_NOT_ADVERTISE_FCOE = 25,
155 CEE_PG_NOT_COMPATIBLE = 26,
156 CEE_PFC_NOT_COMPATIBLE = 27,
157 CEE_FCOE_NOT_COMPATIBLE = 28,
158 CEE_BAD_PG_RCVD = 29,
159 CEE_BAD_BW_RCVD = 30,
160 CEE_BAD_PFC_RCVD = 31,
161 CEE_BAD_FCOE_PRI_RCVD = 32,
162 CEE_FCOE_PRI_PFC_OFF = 33,
163 CEE_DUP_CONTROL_TLV_RCVD = 34,
164 CEE_DUP_FEAT_TLV_RCVD = 35,
165 CEE_APPLY_NEW_CFG = 36, /* reason, not an error */
166 CEE_PROTOCOL_INIT = 37, /* reason, not an error */
167 CEE_PHY_LINK_DOWN = 38,
168 CEE_LLS_FCOE_ABSENT = 39,
169 CEE_LLS_FCOE_DOWN = 40
170};
171
172/**
173 * Default Target Rate Limiting Speed.
174 */
175#define BFA_PPORT_DEF_TRL_SPEED BFA_PPORT_SPEED_1GBPS
176
177/**
178 * Physical port configuration
179 */
180struct bfa_pport_cfg_s {
181 u8 topology; /* bfa_pport_topology */
182 u8 speed; /* enum bfa_pport_speed */
183 u8 trunked; /* trunked or not */
184 u8 qos_enabled; /* qos enabled or not */
185 u8 trunk_ports; /* bitmap of trunked ports */
186 u8 cfg_hardalpa; /* is hard alpa configured */
187 u16 maxfrsize; /* maximum frame size */
188 u8 hardalpa; /* configured hard alpa */
189 u8 rx_bbcredit; /* receive buffer credits */
190 u8 tx_bbcredit; /* transmit buffer credits */
191 u8 ratelimit; /* ratelimit enabled or not */
192 u8 trl_def_speed; /* ratelimit default speed */
193 u8 rsvd[3];
194 u16 path_tov; /* device path timeout */
195 u16 q_depth; /* SCSI Queue depth */
196};
197
198/**
199 * Port attribute values.
200 */
201struct bfa_pport_attr_s {
202 /*
203 * Static fields
204 */
205 wwn_t nwwn; /* node wwn */
206 wwn_t pwwn; /* port wwn */
207 wwn_t factorynwwn; /* factory node wwn */
208 wwn_t factorypwwn; /* factory port wwn */
209 enum fc_cos cos_supported; /* supported class of services */
210 u32 rsvd;
211 struct fc_symname_s port_symname; /* port symbolic name */
212 enum bfa_pport_speed speed_supported; /* supported speeds */
213 bfa_boolean_t pbind_enabled; /* Will be set if Persistent binding
214 * enabled. Relevant only in Windows
215 */
216
217 /*
218 * Configured values
219 */
220 struct bfa_pport_cfg_s pport_cfg; /* pport cfg */
221
222 /*
223 * Dynamic field - info from BFA
224 */
225 enum bfa_pport_states port_state; /* current port state */
226 enum bfa_pport_speed speed; /* current speed */
227 enum bfa_pport_topology topology; /* current topology */
228 bfa_boolean_t beacon; /* current beacon status */
229 bfa_boolean_t link_e2e_beacon;/* set if link beacon on */
230 bfa_boolean_t plog_enabled; /* set if portlog is enabled*/
231
232 /*
233 * Dynamic field - info from FCS
234 */
235 u32 pid; /* port ID */
236 enum bfa_pport_type port_type; /* current topology */
237 u32 loopback; /* external loopback */
238 u32 authfail; /* auth fail state */
239 u32 rsvd2; /* padding for 64 bit */
240};
241
242/**
243 * FC Port statistics.
244 */
245struct bfa_pport_fc_stats_s {
246 u64 secs_reset; /* Seconds since stats is reset */
247 u64 tx_frames; /* Tx frames */
248 u64 tx_words; /* Tx words */
249 u64 tx_lip; /* Tx LIP */
250 u64 tx_nos; /* Tx NOS */
251 u64 tx_ols; /* Tx OLS */
252 u64 tx_lr; /* Tx LR */
253 u64 tx_lrr; /* Tx LRR */
254 u64 rx_frames; /* Rx frames */
255 u64 rx_words; /* Rx words */
256 u64 lip_count; /* Rx LIP */
257 u64 nos_count; /* Rx NOS */
258 u64 ols_count; /* Rx OLS */
259 u64 lr_count; /* Rx LR */
260 u64 lrr_count; /* Rx LRR */
261 u64 invalid_crcs; /* Rx CRC err frames */
262 u64 invalid_crc_gd_eof; /* Rx CRC err good EOF frames */
263 u64 undersized_frm; /* Rx undersized frames */
264 u64 oversized_frm; /* Rx oversized frames */
265 u64 bad_eof_frm; /* Rx frames with bad EOF */
266 u64 error_frames; /* Errored frames */
267 u64 dropped_frames; /* Dropped frames */
268 u64 link_failures; /* Link Failure (LF) count */
269 u64 loss_of_syncs; /* Loss of sync count */
270 u64 loss_of_signals;/* Loss of signal count */
271 u64 primseq_errs; /* Primitive sequence protocol err. */
272 u64 bad_os_count; /* Invalid ordered sets */
273 u64 err_enc_out; /* Encoding err nonframe_8b10b */
274 u64 err_enc; /* Encoding err frame_8b10b */
275};
276
277/**
278 * Eth Port statistics.
279 */
280struct bfa_pport_eth_stats_s {
281 u64 secs_reset; /* Seconds since stats is reset */
282 u64 frame_64; /* Frames 64 bytes */
283 u64 frame_65_127; /* Frames 65-127 bytes */
284 u64 frame_128_255; /* Frames 128-255 bytes */
285 u64 frame_256_511; /* Frames 256-511 bytes */
286 u64 frame_512_1023; /* Frames 512-1023 bytes */
287 u64 frame_1024_1518; /* Frames 1024-1518 bytes */
288 u64 frame_1519_1522; /* Frames 1519-1522 bytes */
289 u64 tx_bytes; /* Tx bytes */
290 u64 tx_packets; /* Tx packets */
291 u64 tx_mcast_packets; /* Tx multicast packets */
292 u64 tx_bcast_packets; /* Tx broadcast packets */
293 u64 tx_control_frame; /* Tx control frame */
294 u64 tx_drop; /* Tx drops */
295 u64 tx_jabber; /* Tx jabber */
296 u64 tx_fcs_error; /* Tx FCS error */
297 u64 tx_fragments; /* Tx fragments */
298 u64 rx_bytes; /* Rx bytes */
299 u64 rx_packets; /* Rx packets */
300 u64 rx_mcast_packets; /* Rx multicast packets */
301 u64 rx_bcast_packets; /* Rx broadcast packets */
302 u64 rx_control_frames; /* Rx control frames */
303 u64 rx_unknown_opcode; /* Rx unknown opcode */
304 u64 rx_drop; /* Rx drops */
305 u64 rx_jabber; /* Rx jabber */
306 u64 rx_fcs_error; /* Rx FCS errors */
307 u64 rx_alignment_error; /* Rx alignment errors */
308 u64 rx_frame_length_error; /* Rx frame len errors */
309 u64 rx_code_error; /* Rx code errors */
310 u64 rx_fragments; /* Rx fragments */
311 u64 rx_pause; /* Rx pause */
312 u64 rx_zero_pause; /* Rx zero pause */
313 u64 tx_pause; /* Tx pause */
314 u64 tx_zero_pause; /* Tx zero pause */
315 u64 rx_fcoe_pause; /* Rx FCoE pause */
316 u64 rx_fcoe_zero_pause; /* Rx FCoE zero pause */
317 u64 tx_fcoe_pause; /* Tx FCoE pause */
318 u64 tx_fcoe_zero_pause; /* Tx FCoE zero pause */
319};
320
321/**
322 * Port statistics.
323 */
324union bfa_pport_stats_u {
325 struct bfa_pport_fc_stats_s fc;
326 struct bfa_pport_eth_stats_s eth;
327};
328
329/**
330 * Port FCP mappings.
331 */
332struct bfa_pport_fcpmap_s {
333 char osdevname[256];
334 u32 bus;
335 u32 target;
336 u32 oslun;
337 u32 fcid;
338 wwn_t nwwn;
339 wwn_t pwwn;
340 u64 fcplun;
341 char luid[256];
342};
343
344/**
345 * Port RNI */
346struct bfa_pport_rnid_s {
347 wwn_t wwn;
348 u32 unittype;
349 u32 portid;
350 u32 attached_nodes_num;
351 u16 ip_version;
352 u16 udp_port;
353 u8 ipaddr[16];
354 u16 rsvd;
355 u16 topologydiscoveryflags;
356};
357
358struct bfa_fcport_fcf_s {
359 wwn_t name; /* FCF name */
360 wwn_t fabric_name; /* Fabric Name */
361 u8 fipenabled; /* FIP enabled or not */
362 u8 fipfailed; /* FIP failed or not */
363 u8 resv[2];
364 u8 pri; /* FCF priority */
365 u8 version; /* FIP version used */
366 u8 available; /* Available for login */
367 u8 fka_disabled; /* FKA is disabled */
368 u8 maxsz_verified; /* FCoE max size verified */
369 u8 fc_map[3]; /* FC map */
370 u16 vlan; /* FCoE vlan tag/priority */
371 u32 fka_adv_per; /* FIP ka advert. period */
372 struct mac_s mac; /* FCF mac */
373};
374
375/**
376 * Link state information
377 */
378struct bfa_pport_link_s {
379 u8 linkstate; /* Link state bfa_pport_linkstate */
380 u8 linkstate_rsn; /* bfa_pport_linkstate_rsn_t */
381 u8 topology; /* P2P/LOOP bfa_pport_topology */
382 u8 speed; /* Link speed (1/2/4/8 G) */
383 u32 linkstate_opt; /* Linkstate optional data (debug) */
384 u8 trunked; /* Trunked or not (1 or 0) */
385 u8 resvd[3];
386 struct bfa_qos_attr_s qos_attr; /* QoS Attributes */
387 union {
388 struct bfa_qos_vc_attr_s qos_vc_attr; /* VC info from ELP */
389 struct bfa_fcport_fcf_s fcf; /* FCF information (for FCoE) */
390 } vc_fcf;
391};
392
393#endif /* __BFA_DEFS_PPORT_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_qos.h b/drivers/scsi/bfa/include/defs/bfa_defs_qos.h
deleted file mode 100644
index aadbacd1d2d7..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_qos.h
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_QOS_H__
19#define __BFA_DEFS_QOS_H__
20
21/**
22 * QoS states
23 */
24enum bfa_qos_state {
25 BFA_QOS_ONLINE = 1, /* QoS is online */
26 BFA_QOS_OFFLINE = 2, /* QoS is offline */
27};
28
29
30/**
31 * QoS Priority levels.
32 */
33enum bfa_qos_priority {
34 BFA_QOS_UNKNOWN = 0,
35 BFA_QOS_HIGH = 1, /* QoS Priority Level High */
36 BFA_QOS_MED = 2, /* QoS Priority Level Medium */
37 BFA_QOS_LOW = 3, /* QoS Priority Level Low */
38};
39
40
41/**
42 * QoS bandwidth allocation for each priority level
43 */
44enum bfa_qos_bw_alloc {
45 BFA_QOS_BW_HIGH = 60, /* bandwidth allocation for High */
46 BFA_QOS_BW_MED = 30, /* bandwidth allocation for Medium */
47 BFA_QOS_BW_LOW = 10, /* bandwidth allocation for Low */
48};
49
50/**
51 * QoS attribute returned in QoS Query
52 */
53struct bfa_qos_attr_s {
54 enum bfa_qos_state state; /* QoS current state */
55 u32 total_bb_cr; /* Total BB Credits */
56};
57
58/**
59 * These fields should be displayed only from the CLI.
60 * There will be a separate BFAL API (get_qos_vc_attr ?)
61 * to retrieve this.
62 *
63 */
64#define BFA_QOS_MAX_VC 16
65
66struct bfa_qos_vc_info_s {
67 u8 vc_credit;
68 u8 borrow_credit;
69 u8 priority;
70 u8 resvd;
71};
72
73struct bfa_qos_vc_attr_s {
74 u16 total_vc_count; /* Total VC Count */
75 u16 shared_credit;
76 u32 elp_opmode_flags;
77 struct bfa_qos_vc_info_s vc_info[BFA_QOS_MAX_VC]; /* as many as
78 * total_vc_count */
79};
80
81/**
82 * QoS statistics
83 */
84struct bfa_qos_stats_s {
85 u32 flogi_sent; /* QoS Flogi sent */
86 u32 flogi_acc_recvd; /* QoS Flogi Acc received */
87 u32 flogi_rjt_recvd; /* QoS Flogi rejects received */
88 u32 flogi_retries; /* QoS Flogi retries */
89
90 u32 elp_recvd; /* QoS ELP received */
91 u32 elp_accepted; /* QoS ELP Accepted */
92 u32 elp_rejected; /* QoS ELP rejected */
93 u32 elp_dropped; /* QoS ELP dropped */
94
95 u32 qos_rscn_recvd; /* QoS RSCN received */
96 u32 rsvd; /* padding for 64 bit alignment */
97};
98
99#endif /* __BFA_DEFS_QOS_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_rport.h b/drivers/scsi/bfa/include/defs/bfa_defs_rport.h
deleted file mode 100644
index e0af59d6d2f6..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_rport.h
+++ /dev/null
@@ -1,199 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_RPORT_H__
19#define __BFA_DEFS_RPORT_H__
20
21#include <bfa_os_inc.h>
22#include <protocol/types.h>
23#include <defs/bfa_defs_pport.h>
24#include <defs/bfa_defs_port.h>
25#include <defs/bfa_defs_qos.h>
26
27/**
28 * FCS remote port states
29 */
30enum bfa_rport_state {
31 BFA_RPORT_UNINIT = 0, /* PORT is not yet initialized */
32 BFA_RPORT_OFFLINE = 1, /* rport is offline */
33 BFA_RPORT_PLOGI = 2, /* PLOGI to rport is in progress */
34 BFA_RPORT_ONLINE = 3, /* login to rport is complete */
35 BFA_RPORT_PLOGI_RETRY = 4, /* retrying login to rport */
36 BFA_RPORT_NSQUERY = 5, /* nameserver query */
37 BFA_RPORT_ADISC = 6, /* ADISC authentication */
38 BFA_RPORT_LOGO = 7, /* logging out with rport */
39 BFA_RPORT_LOGORCV = 8, /* handling LOGO from rport */
40 BFA_RPORT_NSDISC = 9, /* re-discover rport */
41};
42
43/**
44 * Rport Scsi Function : Initiator/Target.
45 */
46enum bfa_rport_function {
47 BFA_RPORT_INITIATOR = 0x01, /* SCSI Initiator */
48 BFA_RPORT_TARGET = 0x02, /* SCSI Target */
49};
50
51/**
52 * port/node symbolic names for rport
53 */
54#define BFA_RPORT_SYMNAME_MAXLEN 255
55struct bfa_rport_symname_s {
56 char symname[BFA_RPORT_SYMNAME_MAXLEN];
57};
58
59struct bfa_rport_hal_stats_s {
60 u32 sm_un_cr; /* uninit: create events */
61 u32 sm_un_unexp; /* uninit: exception events */
62 u32 sm_cr_on; /* created: online events */
63 u32 sm_cr_del; /* created: delete events */
64 u32 sm_cr_hwf; /* created: IOC down */
65 u32 sm_cr_unexp; /* created: exception events */
66 u32 sm_fwc_rsp; /* fw create: f/w responses */
67 u32 sm_fwc_del; /* fw create: delete events */
68 u32 sm_fwc_off; /* fw create: offline events */
69 u32 sm_fwc_hwf; /* fw create: IOC down */
70 u32 sm_fwc_unexp; /* fw create: exception events*/
71 u32 sm_on_off; /* online: offline events */
72 u32 sm_on_del; /* online: delete events */
73 u32 sm_on_hwf; /* online: IOC down events */
74 u32 sm_on_unexp; /* online: exception events */
75 u32 sm_fwd_rsp; /* fw delete: fw responses */
76 u32 sm_fwd_del; /* fw delete: delete events */
77 u32 sm_fwd_hwf; /* fw delete: IOC down events */
78 u32 sm_fwd_unexp; /* fw delete: exception events*/
79 u32 sm_off_del; /* offline: delete events */
80 u32 sm_off_on; /* offline: online events */
81 u32 sm_off_hwf; /* offline: IOC down events */
82 u32 sm_off_unexp; /* offline: exception events */
83 u32 sm_del_fwrsp; /* delete: fw responses */
84 u32 sm_del_hwf; /* delete: IOC down events */
85 u32 sm_del_unexp; /* delete: exception events */
86 u32 sm_delp_fwrsp; /* delete pend: fw responses */
87 u32 sm_delp_hwf; /* delete pend: IOC downs */
88 u32 sm_delp_unexp; /* delete pend: exceptions */
89 u32 sm_offp_fwrsp; /* off-pending: fw responses */
90 u32 sm_offp_del; /* off-pending: deletes */
91 u32 sm_offp_hwf; /* off-pending: IOC downs */
92 u32 sm_offp_unexp; /* off-pending: exceptions */
93 u32 sm_iocd_off; /* IOC down: offline events */
94 u32 sm_iocd_del; /* IOC down: delete events */
95 u32 sm_iocd_on; /* IOC down: online events */
96 u32 sm_iocd_unexp; /* IOC down: exceptions */
97 u32 rsvd;
98};
99
100/**
101 * FCS remote port statistics
102 */
103struct bfa_rport_stats_s {
104 u32 offlines; /* remote port offline count */
105 u32 onlines; /* remote port online count */
106 u32 rscns; /* RSCN affecting rport */
107 u32 plogis; /* plogis sent */
108 u32 plogi_accs; /* plogi accepts */
109 u32 plogi_timeouts; /* plogi timeouts */
110 u32 plogi_rejects; /* rcvd plogi rejects */
111 u32 plogi_failed; /* local failure */
112 u32 plogi_rcvd; /* plogis rcvd */
113 u32 prli_rcvd; /* inbound PRLIs */
114 u32 adisc_rcvd; /* ADISCs received */
115 u32 adisc_rejects; /* recvd ADISC rejects */
116 u32 adisc_sent; /* ADISC requests sent */
117 u32 adisc_accs; /* ADISC accepted by rport */
118 u32 adisc_failed; /* ADISC failed (no response) */
119 u32 adisc_rejected; /* ADISC rejected by us */
120 u32 logos; /* logos sent */
121 u32 logo_accs; /* LOGO accepts from rport */
122 u32 logo_failed; /* LOGO failures */
123 u32 logo_rejected; /* LOGO rejects from rport */
124 u32 logo_rcvd; /* LOGO from remote port */
125
126 u32 rpsc_rcvd; /* RPSC received */
127 u32 rpsc_rejects; /* recvd RPSC rejects */
128 u32 rpsc_sent; /* RPSC requests sent */
129 u32 rpsc_accs; /* RPSC accepted by rport */
130 u32 rpsc_failed; /* RPSC failed (no response) */
131 u32 rpsc_rejected; /* RPSC rejected by us */
132
133 u32 rsvd;
134 struct bfa_rport_hal_stats_s hal_stats; /* BFA rport stats */
135};
136
137/**
138 * Rport's QoS attributes
139 */
140struct bfa_rport_qos_attr_s {
141 enum bfa_qos_priority qos_priority; /* rport's QoS priority */
142 u32 qos_flow_id; /* QoS flow Id */
143};
144
145/**
146 * FCS remote port attributes returned in queries
147 */
148struct bfa_rport_attr_s {
149 wwn_t nwwn; /* node wwn */
150 wwn_t pwwn; /* port wwn */
151 enum fc_cos cos_supported; /* supported class of services */
152 u32 pid; /* port ID */
153 u32 df_sz; /* Max payload size */
154 enum bfa_rport_state state; /* Rport State machine state */
155 enum fc_cos fc_cos; /* FC classes of services */
156 bfa_boolean_t cisc; /* CISC capable device */
157 struct bfa_rport_symname_s symname; /* Symbolic Name */
158 enum bfa_rport_function scsi_function; /* Initiator/Target */
159 struct bfa_rport_qos_attr_s qos_attr; /* qos attributes */
160 enum bfa_pport_speed curr_speed; /* operating speed got from
161 * RPSC ELS. UNKNOWN, if RPSC
162 * is not supported */
163 bfa_boolean_t trl_enforced; /* TRL enforced ? TRUE/FALSE */
164 enum bfa_pport_speed assigned_speed; /* Speed assigned by the user.
165 * will be used if RPSC is not
166 * supported by the rport */
167};
168
169#define bfa_rport_aen_qos_data_t struct bfa_rport_qos_attr_s
170
171/**
172 * BFA remote port events
173 * Arguments below are in BFAL context from Mgmt
174 * BFA_RPORT_AEN_ONLINE: [in]: lpwwn [out]: vf_id, lpwwn, rpwwn
175 * BFA_RPORT_AEN_OFFLINE: [in]: lpwwn [out]: vf_id, lpwwn, rpwwn
176 * BFA_RPORT_AEN_DISCONNECT:[in]: lpwwn [out]: vf_id, lpwwn, rpwwn
177 * BFA_RPORT_AEN_QOS_PRIO: [in]: lpwwn [out]: vf_id, lpwwn, rpwwn, prio
178 * BFA_RPORT_AEN_QOS_FLOWID:[in]: lpwwn [out]: vf_id, lpwwn, rpwwn, flow_id
179 */
180enum bfa_rport_aen_event {
181 BFA_RPORT_AEN_ONLINE = 1, /* RPort online event */
182 BFA_RPORT_AEN_OFFLINE = 2, /* RPort offline event */
183 BFA_RPORT_AEN_DISCONNECT = 3, /* RPort disconnect event */
184 BFA_RPORT_AEN_QOS_PRIO = 4, /* QOS priority change event */
185 BFA_RPORT_AEN_QOS_FLOWID = 5, /* QOS flow Id change event */
186};
187
188struct bfa_rport_aen_data_s {
189 u16 vf_id; /* vf_id of this logical port */
190 u16 rsvd[3];
191 wwn_t ppwwn; /* WWN of its physical port */
192 wwn_t lpwwn; /* WWN of this logical port */
193 wwn_t rpwwn; /* WWN of this remote port */
194 union {
195 bfa_rport_aen_qos_data_t qos;
196 } priv;
197};
198
199#endif /* __BFA_DEFS_RPORT_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_status.h b/drivers/scsi/bfa/include/defs/bfa_defs_status.h
deleted file mode 100644
index 6eb4e62096fc..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_status.h
+++ /dev/null
@@ -1,282 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_DEFS_STATUS_H__
18#define __BFA_DEFS_STATUS_H__
19
20/**
21 * API status return values
22 *
23 * NOTE: The error msgs are auto generated from the comments. Only singe line
24 * comments are supported
25 */
26enum bfa_status {
27 BFA_STATUS_OK = 0, /* Success */
28 BFA_STATUS_FAILED = 1, /* Operation failed */
29 BFA_STATUS_EINVAL = 2, /* Invalid params Check input
30 * parameters */
31 BFA_STATUS_ENOMEM = 3, /* Out of resources */
32 BFA_STATUS_ENOSYS = 4, /* Function not implemented */
33 BFA_STATUS_ETIMER = 5, /* Timer expired - Retry, if
34 * persists, contact support */
35 BFA_STATUS_EPROTOCOL = 6, /* Protocol error */
36 BFA_STATUS_ENOFCPORTS = 7, /* No FC ports resources */
37 BFA_STATUS_NOFLASH = 8, /* Flash not present */
38 BFA_STATUS_BADFLASH = 9, /* Flash is corrupted or bad */
39 BFA_STATUS_SFP_UNSUPP = 10, /* Unsupported SFP - Replace SFP */
40 BFA_STATUS_UNKNOWN_VFID = 11, /* VF_ID not found */
41 BFA_STATUS_DATACORRUPTED = 12, /* Diag returned data corrupted
42 * contact support */
43 BFA_STATUS_DEVBUSY = 13, /* Device busy - Retry operation */
44 BFA_STATUS_ABORTED = 14, /* Operation aborted */
45 BFA_STATUS_NODEV = 15, /* Dev is not present */
46 BFA_STATUS_HDMA_FAILED = 16, /* Host dma failed contact support */
47 BFA_STATUS_FLASH_BAD_LEN = 17, /* Flash bad length */
48 BFA_STATUS_UNKNOWN_LWWN = 18, /* LPORT PWWN not found */
49 BFA_STATUS_UNKNOWN_RWWN = 19, /* RPORT PWWN not found */
50 BFA_STATUS_FCPT_LS_RJT = 20, /* Got LS_RJT for FC Pass
51 * through Req */
52 BFA_STATUS_VPORT_EXISTS = 21, /* VPORT already exists */
53 BFA_STATUS_VPORT_MAX = 22, /* Reached max VPORT supported
54 * limit */
55 BFA_STATUS_UNSUPP_SPEED = 23, /* Invalid Speed Check speed
56 * setting */
57 BFA_STATUS_INVLD_DFSZ = 24, /* Invalid Max data field size */
58 BFA_STATUS_CNFG_FAILED = 25, /* Setting can not be persisted */
59 BFA_STATUS_CMD_NOTSUPP = 26, /* Command/API not supported */
60 BFA_STATUS_NO_ADAPTER = 27, /* No Brocade Adapter Found */
61 BFA_STATUS_LINKDOWN = 28, /* Link is down - Check or replace
62 * SFP/cable */
63 BFA_STATUS_FABRIC_RJT = 29, /* Reject from attached fabric */
64 BFA_STATUS_UNKNOWN_VWWN = 30, /* VPORT PWWN not found */
65 BFA_STATUS_NSLOGIN_FAILED = 31, /* Nameserver login failed */
66 BFA_STATUS_NO_RPORTS = 32, /* No remote ports found */
67 BFA_STATUS_NSQUERY_FAILED = 33, /* Nameserver query failed */
68 BFA_STATUS_PORT_OFFLINE = 34, /* Port is not online */
69 BFA_STATUS_RPORT_OFFLINE = 35, /* RPORT is not online */
70 BFA_STATUS_TGTOPEN_FAILED = 36, /* Remote SCSI target open failed */
71 BFA_STATUS_BAD_LUNS = 37, /* No valid LUNs found */
72 BFA_STATUS_IO_FAILURE = 38, /* SCSI target IO failure */
73 BFA_STATUS_NO_FABRIC = 39, /* No switched fabric present */
74 BFA_STATUS_EBADF = 40, /* Bad file descriptor */
75 BFA_STATUS_EINTR = 41, /* A signal was caught during ioctl */
76 BFA_STATUS_EIO = 42, /* I/O error */
77 BFA_STATUS_ENOTTY = 43, /* Inappropriate I/O control
78 * operation */
79 BFA_STATUS_ENXIO = 44, /* No such device or address */
80 BFA_STATUS_EFOPEN = 45, /* Failed to open file */
81 BFA_STATUS_VPORT_WWN_BP = 46, /* WWN is same as base port's WWN */
82 BFA_STATUS_PORT_NOT_DISABLED = 47, /* Port not disabled disable port
83 * first */
84 BFA_STATUS_BADFRMHDR = 48, /* Bad frame header */
85 BFA_STATUS_BADFRMSZ = 49, /* Bad frame size check and replace
86 * SFP/cable */
87 BFA_STATUS_MISSINGFRM = 50, /* Missing frame check and replace
88 * SFP/cable or for Mezz card check and
89 * replace pass through module */
90 BFA_STATUS_LINKTIMEOUT = 51, /* Link timeout check and replace
91 * SFP/cable */
92 BFA_STATUS_NO_FCPIM_NEXUS = 52, /* No FCP Nexus exists with the
93 * rport */
94 BFA_STATUS_CHECKSUM_FAIL = 53, /* checksum failure */
95 BFA_STATUS_GZME_FAILED = 54, /* Get zone member query failed */
96 BFA_STATUS_SCSISTART_REQD = 55, /* SCSI disk require START command */
97 BFA_STATUS_IOC_FAILURE = 56, /* IOC failure - Retry, if persists
98 * contact support */
99 BFA_STATUS_INVALID_WWN = 57, /* Invalid WWN */
100 BFA_STATUS_MISMATCH = 58, /* Version mismatch */
101 BFA_STATUS_IOC_ENABLED = 59, /* IOC is already enabled */
102 BFA_STATUS_ADAPTER_ENABLED = 60, /* Adapter is not disabled disable
103 * adapter first */
104 BFA_STATUS_IOC_NON_OP = 61, /* IOC is not operational. Enable IOC
105 * and if it still fails,
106 * contact support */
107 BFA_STATUS_ADDR_MAP_FAILURE = 62, /* PCI base address not mapped
108 * in OS */
109 BFA_STATUS_SAME_NAME = 63, /* Name exists! use a different
110 * name */
111 BFA_STATUS_PENDING = 64, /* API completes asynchronously */
112 BFA_STATUS_8G_SPD = 65, /* Speed setting not valid for
113 * 8G HBA */
114 BFA_STATUS_4G_SPD = 66, /* Speed setting not valid for
115 * 4G HBA */
116 BFA_STATUS_AD_IS_ENABLE = 67, /* Adapter is already enabled */
117 BFA_STATUS_EINVAL_TOV = 68, /* Invalid path failover TOV */
118 BFA_STATUS_EINVAL_QDEPTH = 69, /* Invalid queue depth value */
119 BFA_STATUS_VERSION_FAIL = 70, /* Application/Driver version
120 * mismatch */
121 BFA_STATUS_DIAG_BUSY = 71, /* diag busy */
122 BFA_STATUS_BEACON_ON = 72, /* Port Beacon already on */
123 BFA_STATUS_BEACON_OFF = 73, /* Port Beacon already off */
124 BFA_STATUS_LBEACON_ON = 74, /* Link End-to-End Beacon already
125 * on */
126 BFA_STATUS_LBEACON_OFF = 75, /* Link End-to-End Beacon already
127 * off */
128 BFA_STATUS_PORT_NOT_INITED = 76, /* Port not initialized */
129 BFA_STATUS_RPSC_ENABLED = 77, /* Target has a valid speed */
130 BFA_STATUS_ENOFSAVE = 78, /* No saved firmware trace */
131 BFA_STATUS_BAD_FILE = 79, /* Not a valid Brocade Boot Code
132 * file */
133 BFA_STATUS_RLIM_EN = 80, /* Target rate limiting is already
134 * enabled */
135 BFA_STATUS_RLIM_DIS = 81, /* Target rate limiting is already
136 * disabled */
137 BFA_STATUS_IOC_DISABLED = 82, /* IOC is already disabled */
138 BFA_STATUS_ADAPTER_DISABLED = 83, /* Adapter is already disabled */
139 BFA_STATUS_BIOS_DISABLED = 84, /* Bios is already disabled */
140 BFA_STATUS_AUTH_ENABLED = 85, /* Authentication is already
141 * enabled */
142 BFA_STATUS_AUTH_DISABLED = 86, /* Authentication is already
143 * disabled */
144 BFA_STATUS_ERROR_TRL_ENABLED = 87, /* Target rate limiting is
145 * enabled */
146 BFA_STATUS_ERROR_QOS_ENABLED = 88, /* QoS is enabled */
147 BFA_STATUS_NO_SFP_DEV = 89, /* No SFP device check or replace SFP */
148 BFA_STATUS_MEMTEST_FAILED = 90, /* Memory test failed contact
149 * support */
150 BFA_STATUS_INVALID_DEVID = 91, /* Invalid device id provided */
151 BFA_STATUS_QOS_ENABLED = 92, /* QOS is already enabled */
152 BFA_STATUS_QOS_DISABLED = 93, /* QOS is already disabled */
153 BFA_STATUS_INCORRECT_DRV_CONFIG = 94, /* Check configuration
154 * key/value pair */
155 BFA_STATUS_REG_FAIL = 95, /* Can't read windows registry */
156 BFA_STATUS_IM_INV_CODE = 96, /* Invalid IOCTL code */
157 BFA_STATUS_IM_INV_VLAN = 97, /* Invalid VLAN ID */
158 BFA_STATUS_IM_INV_ADAPT_NAME = 98, /* Invalid adapter name */
159 BFA_STATUS_IM_LOW_RESOURCES = 99, /* Memory allocation failure in
160 * driver */
161 BFA_STATUS_IM_VLANID_IS_PVID = 100, /* Given VLAN id same as PVID */
162 BFA_STATUS_IM_VLANID_EXISTS = 101, /* Given VLAN id already exists */
163 BFA_STATUS_IM_FW_UPDATE_FAIL = 102, /* Updating firmware with new
164 * VLAN ID failed */
165 BFA_STATUS_PORTLOG_ENABLED = 103, /* Port Log is already enabled */
166 BFA_STATUS_PORTLOG_DISABLED = 104, /* Port Log is already disabled */
167 BFA_STATUS_FILE_NOT_FOUND = 105, /* Specified file could not be
168 * found */
169 BFA_STATUS_QOS_FC_ONLY = 106, /* QOS can be enabled for FC mode
170 * only */
171 BFA_STATUS_RLIM_FC_ONLY = 107, /* RATELIM can be enabled for FC mode
172 * only */
173 BFA_STATUS_CT_SPD = 108, /* Invalid speed selection for Catapult. */
174 BFA_STATUS_LEDTEST_OP = 109, /* LED test is operating */
175 BFA_STATUS_CEE_NOT_DN = 110, /* eth port is not at down state, please
176 * bring down first */
177 BFA_STATUS_10G_SPD = 111, /* Speed setting not valid for 10G CNA */
178 BFA_STATUS_IM_INV_TEAM_NAME = 112, /* Invalid team name */
179 BFA_STATUS_IM_DUP_TEAM_NAME = 113, /* Given team name already
180 * exists */
181 BFA_STATUS_IM_ADAPT_ALREADY_IN_TEAM = 114, /* Given adapter is part
182 * of another team */
183 BFA_STATUS_IM_ADAPT_HAS_VLANS = 115, /* Adapter has VLANs configured.
184 * Delete all VLANs to become
185 * part of the team */
186 BFA_STATUS_IM_PVID_MISMATCH = 116, /* Mismatching PVIDs configured
187 * for adapters */
188 BFA_STATUS_IM_LINK_SPEED_MISMATCH = 117, /* Mismatching link speeds
189 * configured for adapters */
190 BFA_STATUS_IM_MTU_MISMATCH = 118, /* Mismatching MTUs configured for
191 * adapters */
192 BFA_STATUS_IM_RSS_MISMATCH = 119, /* Mismatching RSS parameters
193 * configured for adapters */
194 BFA_STATUS_IM_HDS_MISMATCH = 120, /* Mismatching HDS parameters
195 * configured for adapters */
196 BFA_STATUS_IM_OFFLOAD_MISMATCH = 121, /* Mismatching offload
197 * parameters configured for
198 * adapters */
199 BFA_STATUS_IM_PORT_PARAMS = 122, /* Error setting port parameters */
200 BFA_STATUS_IM_PORT_NOT_IN_TEAM = 123, /* Port is not part of team */
201 BFA_STATUS_IM_CANNOT_REM_PRI = 124, /* Primary adapter cannot be
202 * removed. Change primary before
203 * removing */
204 BFA_STATUS_IM_MAX_PORTS_REACHED = 125, /* Exceeding maximum ports
205 * per team */
206 BFA_STATUS_IM_LAST_PORT_DELETE = 126, /* Last port in team being
207 * deleted */
208 BFA_STATUS_IM_NO_DRIVER = 127, /* IM driver is not installed */
209 BFA_STATUS_IM_MAX_VLANS_REACHED = 128, /* Exceeding maximum VLANs
210 * per port */
211 BFA_STATUS_TOMCAT_SPD_NOT_ALLOWED = 129, /* Bios speed config not
212 * allowed for CNA */
213 BFA_STATUS_NO_MINPORT_DRIVER = 130, /* Miniport driver is not
214 * loaded */
215 BFA_STATUS_CARD_TYPE_MISMATCH = 131, /* Card type mismatch */
216 BFA_STATUS_BAD_ASICBLK = 132, /* Bad ASIC block */
217 BFA_STATUS_NO_DRIVER = 133, /* Brocade adapter/driver not installed
218 * or loaded */
219 BFA_STATUS_INVALID_MAC = 134, /* Invalid MAC address */
220 BFA_STATUS_IM_NO_VLAN = 135, /* No VLANs configured on the adapter */
221 BFA_STATUS_IM_ETH_LB_FAILED = 136, /* Ethernet loopback test failed */
222 BFA_STATUS_IM_PVID_REMOVE = 137, /* Cannot remove port VLAN (PVID) */
223 BFA_STATUS_IM_PVID_EDIT = 138, /* Cannot edit port VLAN (PVID) */
224 BFA_STATUS_CNA_NO_BOOT = 139, /* Boot upload not allowed for CNA */
225 BFA_STATUS_IM_PVID_NON_ZERO = 140, /* Port VLAN ID (PVID) is Set to
226 * Non-Zero Value */
227 BFA_STATUS_IM_INETCFG_LOCK_FAILED = 141, /* Acquiring Network
228 * Subsystem Lock Failed.Please
229 * try after some time */
230 BFA_STATUS_IM_GET_INETCFG_FAILED = 142, /* Acquiring Network Subsystem
231 * handle Failed. Please try
232 * after some time */
233 BFA_STATUS_IM_NOT_BOUND = 143, /* IM driver is not active */
234 BFA_STATUS_INSUFFICIENT_PERMS = 144, /* User doesn't have sufficient
235 * permissions to execute the BCU
236 * application */
237 BFA_STATUS_IM_INV_VLAN_NAME = 145, /* Invalid/Reserved VLAN name
238 * string. The name is not allowed
239 * for the normal VLAN */
240 BFA_STATUS_CMD_NOTSUPP_CNA = 146, /* Command not supported for CNA */
241 BFA_STATUS_IM_PASSTHRU_EDIT = 147, /* Can not edit passthrough VLAN
242 * id */
243 BFA_STATUS_IM_BIND_FAILED = 148, /* IM Driver bind operation
244 * failed */
245 BFA_STATUS_IM_UNBIND_FAILED = 149, /* IM Driver unbind operation
246 * failed */
247 BFA_STATUS_IM_PORT_IN_TEAM = 150, /* Port is already part of the
248 * team */
249 BFA_STATUS_IM_VLAN_NOT_FOUND = 151, /* VLAN ID doesn't exists */
250 BFA_STATUS_IM_TEAM_NOT_FOUND = 152, /* Teaming configuration doesn't
251 * exists */
252 BFA_STATUS_IM_TEAM_CFG_NOT_ALLOWED = 153, /* Given settings are not
253 * allowed for the current
254 * Teaming mode */
255 BFA_STATUS_PBC = 154, /* Operation not allowed for pre-boot
256 * configuration */
257 BFA_STATUS_DEVID_MISSING = 155, /* Boot image is not for the adapter(s)
258 * installed */
259 BFA_STATUS_BAD_FWCFG = 156, /* Bad firmware configuration */
260 BFA_STATUS_CREATE_FILE = 157, /* Failed to create temporary file */
261 BFA_STATUS_INVALID_VENDOR = 158, /* Invalid switch vendor */
262 BFA_STATUS_SFP_NOT_READY = 159, /* SFP info is not ready. Retry */
263 BFA_STATUS_NO_TOPOLOGY_FOR_CNA = 160, /* Topology command not
264 * applicable to CNA */
265 BFA_STATUS_BOOT_CODE_UPDATED = 161, /* reboot -- -r is needed after
266 * boot code updated */
267 BFA_STATUS_BOOT_VERSION = 162, /* Boot code version not compatible with
268 * the driver installed */
269 BFA_STATUS_CARDTYPE_MISSING = 163, /* Boot image is not for the
270 * adapter(s) installed */
271 BFA_STATUS_INVALID_CARDTYPE = 164, /* Invalid card type provided */
272 BFA_STATUS_MAX_VAL /* Unknown error code */
273};
274#define bfa_status_t enum bfa_status
275
276enum bfa_eproto_status {
277 BFA_EPROTO_BAD_ACCEPT = 0,
278 BFA_EPROTO_UNKNOWN_RSP = 1
279};
280#define bfa_eproto_status_t enum bfa_eproto_status
281
282#endif /* __BFA_DEFS_STATUS_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_tin.h b/drivers/scsi/bfa/include/defs/bfa_defs_tin.h
deleted file mode 100644
index e05a2db7abed..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_tin.h
+++ /dev/null
@@ -1,118 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_TIN_H__
19#define __BFA_DEFS_TIN_H__
20
21#include <protocol/types.h>
22#include <protocol/fc.h>
23
24/**
25 * FCS tin states
26 */
27enum bfa_tin_state_e {
28 BFA_TIN_SM_OFFLINE = 0, /* tin is offline */
29 BFA_TIN_SM_WOS_LOGIN = 1, /* Waiting PRLI ACC/RJT from ULP */
30 BFA_TIN_SM_WFW_ONLINE = 2, /* Waiting ACK to PRLI ACC from FW */
31 BFA_TIN_SM_ONLINE = 3, /* tin login is complete */
32 BFA_TIN_SM_WIO_RELOGIN = 4, /* tin relogin is in progress */
33 BFA_TIN_SM_WIO_LOGOUT = 5, /* Processing of PRLO req from
34 * Initiator is in progress
35 */
36 BFA_TIN_SM_WOS_LOGOUT = 6, /* Processing of PRLO req from
37 * Initiator is in progress
38 */
39 BFA_TIN_SM_WIO_CLEAN = 7, /* Waiting for IO cleanup before tin
40 * is offline. This can be triggered
41 * by RPORT LOGO (rcvd/sent) or by
42 * PRLO (rcvd/sent)
43 */
44};
45
46struct bfa_prli_req_s {
47 struct fchs_s fchs;
48 struct fc_prli_s prli_payload;
49};
50
51struct bfa_prlo_req_s {
52 struct fchs_s fchs;
53 struct fc_prlo_s prlo_payload;
54};
55
56void bfa_tin_send_login_rsp(void *bfa_tin, u32 login_rsp,
57 struct fc_ls_rjt_s rjt_payload);
58void bfa_tin_send_logout_rsp(void *bfa_tin, u32 logout_rsp,
59 struct fc_ls_rjt_s rjt_payload);
60/**
61 * FCS target port statistics
62 */
63struct bfa_tin_stats_s {
64 u32 onlines; /* ITN nexus onlines (PRLI done) */
65 u32 offlines; /* ITN Nexus offlines */
66 u32 prli_req_parse_err; /* prli req parsing errors */
67 u32 prli_rsp_rjt; /* num prli rsp rejects sent */
68 u32 prli_rsp_acc; /* num prli rsp accepts sent */
69 u32 cleanup_comps; /* ITN cleanup completions */
70};
71
72/**
73 * FCS tin attributes returned in queries
74 */
75struct bfa_tin_attr_s {
76 enum bfa_tin_state_e state;
77 u8 seq_retry; /* Sequence retry supported */
78 u8 rsvd[3];
79};
80
81/**
82 * BFA TIN async event data structure for BFAL
83 */
84enum bfa_tin_aen_event {
85 BFA_TIN_AEN_ONLINE = 1, /* Target online */
86 BFA_TIN_AEN_OFFLINE = 2, /* Target offline */
87 BFA_TIN_AEN_DISCONNECT = 3, /* Target disconnected */
88};
89
90/**
91 * BFA TIN event data structure.
92 */
93struct bfa_tin_aen_data_s {
94 u16 vf_id; /* vf_id of the IT nexus */
95 u16 rsvd[3];
96 wwn_t lpwwn; /* WWN of logical port */
97 wwn_t rpwwn; /* WWN of remote(target) port */
98};
99
100/**
101 * Below APIs are needed from BFA driver
102 * Move these to BFA driver public header file?
103 */
104/* TIN rcvd new PRLI & gets bfad_tin_t ptr from driver this callback */
105void *bfad_tin_rcvd_login_req(void *bfad_tm_port, void *bfa_tin,
106 wwn_t rp_wwn, u32 rp_fcid,
107 struct bfa_prli_req_s prli_req);
108/* TIN rcvd new PRLO */
109void bfad_tin_rcvd_logout_req(void *bfad_tin, wwn_t rp_wwn, u32 rp_fcid,
110 struct bfa_prlo_req_s prlo_req);
111/* TIN is online and ready for IO */
112void bfad_tin_online(void *bfad_tin);
113/* TIN is offline and BFA driver can shutdown its upper stack */
114void bfad_tin_offline(void *bfad_tin);
115/* TIN does not need this BFA driver tin tag anymore, so can be freed */
116void bfad_tin_res_free(void *bfad_tin);
117
118#endif /* __BFA_DEFS_TIN_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_tsensor.h b/drivers/scsi/bfa/include/defs/bfa_defs_tsensor.h
deleted file mode 100644
index ade763dbc8ce..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_tsensor.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_TSENSOR_H__
19#define __BFA_DEFS_TSENSOR_H__
20
21#include <bfa_os_inc.h>
22#include <defs/bfa_defs_types.h>
23
24/**
25 * Temperature sensor status values
26 */
27enum bfa_tsensor_status {
28 BFA_TSENSOR_STATUS_UNKNOWN = 1, /* unknown status */
29 BFA_TSENSOR_STATUS_FAULTY = 2, /* sensor is faulty */
30 BFA_TSENSOR_STATUS_BELOW_MIN = 3, /* temperature below mininum */
31 BFA_TSENSOR_STATUS_NOMINAL = 4, /* normal temperature */
32 BFA_TSENSOR_STATUS_ABOVE_MAX = 5, /* temperature above maximum */
33};
34
35/**
36 * Temperature sensor attribute
37 */
38struct bfa_tsensor_attr_s {
39 enum bfa_tsensor_status status; /* temperature sensor status */
40 u32 value; /* current temperature in celsius */
41};
42
43#endif /* __BFA_DEFS_TSENSOR_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_types.h b/drivers/scsi/bfa/include/defs/bfa_defs_types.h
deleted file mode 100644
index 4348332b107a..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_types.h
+++ /dev/null
@@ -1,30 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_DEFS_TYPES_H__
18#define __BFA_DEFS_TYPES_H__
19
20#include <bfa_os_inc.h>
21
22enum bfa_boolean {
23 BFA_FALSE = 0,
24 BFA_TRUE = 1
25};
26#define bfa_boolean_t enum bfa_boolean
27
28#define BFA_STRING_32 32
29
30#endif /* __BFA_DEFS_TYPES_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_version.h b/drivers/scsi/bfa/include/defs/bfa_defs_version.h
deleted file mode 100644
index f8902a2c9aad..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_version.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#ifndef __BFA_DEFS_VERSION_H__
18#define __BFA_DEFS_VERSION_H__
19
20#define BFA_VERSION_LEN 64
21
22#endif
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_vf.h b/drivers/scsi/bfa/include/defs/bfa_defs_vf.h
deleted file mode 100644
index 3235be5e9423..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_vf.h
+++ /dev/null
@@ -1,74 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_VF_H__
19#define __BFA_DEFS_VF_H__
20
21#include <bfa_os_inc.h>
22#include <defs/bfa_defs_port.h>
23#include <protocol/types.h>
24
25/**
26 * VF states
27 */
28enum bfa_vf_state {
29 BFA_VF_UNINIT = 0, /* fabric is not yet initialized */
30 BFA_VF_LINK_DOWN = 1, /* link is down */
31 BFA_VF_FLOGI = 2, /* flogi is in progress */
32 BFA_VF_AUTH = 3, /* authentication in progress */
33 BFA_VF_NOFABRIC = 4, /* fabric is not present */
34 BFA_VF_ONLINE = 5, /* login to fabric is complete */
35 BFA_VF_EVFP = 6, /* EVFP is in progress */
36 BFA_VF_ISOLATED = 7, /* port isolated due to vf_id mismatch */
37};
38
39/**
40 * VF statistics
41 */
42struct bfa_vf_stats_s {
43 u32 flogi_sent; /* Num FLOGIs sent */
44 u32 flogi_rsp_err; /* FLOGI response errors */
45 u32 flogi_acc_err; /* FLOGI accept errors */
46 u32 flogi_accepts; /* FLOGI accepts received */
47 u32 flogi_rejects; /* FLOGI rejects received */
48 u32 flogi_unknown_rsp; /* Unknown responses for FLOGI */
49 u32 flogi_alloc_wait; /* Allocation waits prior to
50 * sending FLOGI
51 */
52 u32 flogi_rcvd; /* FLOGIs received */
53 u32 flogi_rejected; /* Incoming FLOGIs rejected */
54 u32 fabric_onlines; /* Internal fabric online
55 * notification sent to other
56 * modules
57 */
58 u32 fabric_offlines; /* Internal fabric offline
59 * notification sent to other
60 * modules
61 */
62 u32 resvd;
63};
64
65/**
66 * VF attributes returned in queries
67 */
68struct bfa_vf_attr_s {
69 enum bfa_vf_state state; /* VF state */
70 u32 rsvd;
71 wwn_t fabric_name; /* fabric name */
72};
73
74#endif /* __BFA_DEFS_VF_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_vport.h b/drivers/scsi/bfa/include/defs/bfa_defs_vport.h
deleted file mode 100644
index 9f021f43b3b4..000000000000
--- a/drivers/scsi/bfa/include/defs/bfa_defs_vport.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_DEFS_VPORT_H__
19#define __BFA_DEFS_VPORT_H__
20
21#include <bfa_os_inc.h>
22#include <defs/bfa_defs_port.h>
23#include <protocol/types.h>
24
25/**
26 * VPORT states
27 */
28enum bfa_vport_state {
29 BFA_FCS_VPORT_UNINIT = 0,
30 BFA_FCS_VPORT_CREATED = 1,
31 BFA_FCS_VPORT_OFFLINE = 1,
32 BFA_FCS_VPORT_FDISC_SEND = 2,
33 BFA_FCS_VPORT_FDISC = 3,
34 BFA_FCS_VPORT_FDISC_RETRY = 4,
35 BFA_FCS_VPORT_ONLINE = 5,
36 BFA_FCS_VPORT_DELETING = 6,
37 BFA_FCS_VPORT_CLEANUP = 6,
38 BFA_FCS_VPORT_LOGO_SEND = 7,
39 BFA_FCS_VPORT_LOGO = 8,
40 BFA_FCS_VPORT_ERROR = 9,
41 BFA_FCS_VPORT_MAX_STATE,
42};
43
44/**
45 * vport statistics
46 */
47struct bfa_vport_stats_s {
48 struct bfa_port_stats_s port_stats; /* base class (port) stats */
49 /*
50 * TODO - remove
51 */
52
53 u32 fdisc_sent; /* num fdisc sent */
54 u32 fdisc_accepts; /* fdisc accepts */
55 u32 fdisc_retries; /* fdisc retries */
56 u32 fdisc_timeouts; /* fdisc timeouts */
57 u32 fdisc_rsp_err; /* fdisc response error */
58 u32 fdisc_acc_bad; /* bad fdisc accepts */
59 u32 fdisc_rejects; /* fdisc rejects */
60 u32 fdisc_unknown_rsp;
61 /*
62 *!< fdisc rsp unknown error
63 */
64 u32 fdisc_alloc_wait;/* fdisc req (fcxp)alloc wait */
65
66 u32 logo_alloc_wait;/* logo req (fcxp) alloc wait */
67 u32 logo_sent; /* logo sent */
68 u32 logo_accepts; /* logo accepts */
69 u32 logo_rejects; /* logo rejects */
70 u32 logo_rsp_err; /* logo rsp errors */
71 u32 logo_unknown_rsp;
72 /* logo rsp unknown errors */
73
74 u32 fab_no_npiv; /* fabric does not support npiv */
75
76 u32 fab_offline; /* offline events from fab SM */
77 u32 fab_online; /* online events from fab SM */
78 u32 fab_cleanup; /* cleanup request from fab SM */
79 u32 rsvd;
80};
81
82/**
83 * BFA vport attribute returned in queries
84 */
85struct bfa_vport_attr_s {
86 struct bfa_port_attr_s port_attr; /* base class (port) attributes */
87 enum bfa_vport_state vport_state; /* vport state */
88 u32 rsvd;
89};
90
91#endif /* __BFA_DEFS_VPORT_H__ */
diff --git a/drivers/scsi/bfa/include/fcb/bfa_fcb.h b/drivers/scsi/bfa/include/fcb/bfa_fcb.h
deleted file mode 100644
index 2963b0bc30e7..000000000000
--- a/drivers/scsi/bfa/include/fcb/bfa_fcb.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcb.h BFA FCS callback interfaces
20 */
21
22#ifndef __BFA_FCB_H__
23#define __BFA_FCB_H__
24
25/**
26 * fcb Main fcs callbacks
27 */
28
29void bfa_fcb_exit(struct bfad_s *bfad);
30
31
32
33#endif /* __BFA_FCB_H__ */
diff --git a/drivers/scsi/bfa/include/fcb/bfa_fcb_fcpim.h b/drivers/scsi/bfa/include/fcb/bfa_fcb_fcpim.h
deleted file mode 100644
index 52585d3dd891..000000000000
--- a/drivers/scsi/bfa/include/fcb/bfa_fcb_fcpim.h
+++ /dev/null
@@ -1,75 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19* : bfad_fcpim.h - BFA FCS initiator mode remote port callbacks
20 */
21
22#ifndef __BFAD_FCB_FCPIM_H__
23#define __BFAD_FCB_FCPIM_H__
24
25struct bfad_itnim_s;
26
27/*
28 * RPIM callbacks
29 */
30
31/**
32 * Memory allocation for remote port instance. Called before PRLI is
33 * initiated to the remote target port.
34 *
35 * @param[in] bfad - driver instance
36 * @param[out] itnim - FCS remote port (IM) instance
37 * @param[out] itnim_drv - driver remote port (IM) instance
38 *
39 * @return None
40 */
41void bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
42 struct bfad_itnim_s **itnim_drv);
43
44/**
45 * Free remote port (IM) instance.
46 *
47 * @param[in] bfad - driver instance
48 * @param[in] itnim_drv - driver remote port instance
49 *
50 * @return None
51 */
52void bfa_fcb_itnim_free(struct bfad_s *bfad,
53 struct bfad_itnim_s *itnim_drv);
54
55/**
56 * Notification of when login with a remote target device is complete.
57 *
58 * @param[in] itnim_drv - driver remote port instance
59 *
60 * @return None
61 */
62void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv);
63
64/**
65 * Notification when login with the remote device is severed.
66 *
67 * @param[in] itnim_drv - driver remote port instance
68 *
69 * @return None
70 */
71void bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv);
72
73void bfa_fcb_itnim_tov(struct bfad_itnim_s *itnim_drv);
74
75#endif /* __BFAD_FCB_FCPIM_H__ */
diff --git a/drivers/scsi/bfa/include/fcb/bfa_fcb_port.h b/drivers/scsi/bfa/include/fcb/bfa_fcb_port.h
deleted file mode 100644
index 5fd7f986fa32..000000000000
--- a/drivers/scsi/bfa/include/fcb/bfa_fcb_port.h
+++ /dev/null
@@ -1,113 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcb_port.h BFA FCS virtual port driver interfaces
20 */
21
22#ifndef __BFA_FCB_PORT_H__
23#define __BFA_FCB_PORT_H__
24
25#include <fcb/bfa_fcb_vport.h>
26/**
27 * fcs_port_fcb FCS port driver interfaces
28 */
29
30/*
31 * Forward declarations
32 */
33struct bfad_port_s;
34
35/*
36 * Callback functions from BFA FCS to driver
37 */
38
39/**
40 * Call from FCS to driver module when a port is instantiated. The port
41 * can be a base port or a virtual port with in the base fabric or
42 * a virtual fabric.
43 *
44 * On this callback, driver is supposed to create scsi_host, scsi_tgt or
45 * network interfaces bases on ports personality/roles.
46 *
47 * base port of base fabric: vf_drv == NULL && vp_drv == NULL
48 * vport of base fabric: vf_drv == NULL && vp_drv != NULL
49 * base port of VF: vf_drv != NULL && vp_drv == NULL
50 * vport of VF: vf_drv != NULL && vp_drv != NULL
51 *
52 * @param[in] bfad - driver instance
53 * @param[in] port - FCS port instance
54 * @param[in] roles - port roles: IM, TM, IP
55 * @param[in] vf_drv - VF driver instance, NULL if base fabric (no VF)
56 * @param[in] vp_drv - vport driver instance, NULL if base port
57 *
58 * @return None
59 */
60struct bfad_port_s *bfa_fcb_port_new(struct bfad_s *bfad,
61 struct bfa_fcs_port_s *port,
62 enum bfa_port_role roles, struct bfad_vf_s *vf_drv,
63 struct bfad_vport_s *vp_drv);
64
65/**
66 * Call from FCS to driver module when a port is deleted. The port
67 * can be a base port or a virtual port with in the base fabric or
68 * a virtual fabric.
69 *
70 * @param[in] bfad - driver instance
71 * @param[in] roles - port roles: IM, TM, IP
72 * @param[in] vf_drv - VF driver instance, NULL if base fabric (no VF)
73 * @param[in] vp_drv - vport driver instance, NULL if base port
74 *
75 * @return None
76 */
77void bfa_fcb_port_delete(struct bfad_s *bfad, enum bfa_port_role roles,
78 struct bfad_vf_s *vf_drv, struct bfad_vport_s *vp_drv);
79
80/**
81 * Notification when port transitions to ONLINE state.
82 *
83 * Online notification is a logical link up for the local port. This
84 * notification is sent after a successfull FLOGI, or a successful
85 * link initialization in proviate-loop or N2N topologies.
86 *
87 * @param[in] bfad - driver instance
88 * @param[in] roles - port roles: IM, TM, IP
89 * @param[in] vf_drv - VF driver instance, NULL if base fabric (no VF)
90 * @param[in] vp_drv - vport driver instance, NULL if base port
91 *
92 * @return None
93 */
94void bfa_fcb_port_online(struct bfad_s *bfad, enum bfa_port_role roles,
95 struct bfad_vf_s *vf_drv, struct bfad_vport_s *vp_drv);
96
97/**
98 * Notification when port transitions to OFFLINE state.
99 *
100 * Offline notification is a logical link down for the local port.
101 *
102 * @param[in] bfad - driver instance
103 * @param[in] roles - port roles: IM, TM, IP
104 * @param[in] vf_drv - VF driver instance, NULL if base fabric (no VF)
105 * @param[in] vp_drv - vport driver instance, NULL if base port
106 *
107 * @return None
108 */
109void bfa_fcb_port_offline(struct bfad_s *bfad, enum bfa_port_role roles,
110 struct bfad_vf_s *vf_drv, struct bfad_vport_s *vp_drv);
111
112
113#endif /* __BFA_FCB_PORT_H__ */
diff --git a/drivers/scsi/bfa/include/fcb/bfa_fcb_rport.h b/drivers/scsi/bfa/include/fcb/bfa_fcb_rport.h
deleted file mode 100644
index e0261bb6d1c1..000000000000
--- a/drivers/scsi/bfa/include/fcb/bfa_fcb_rport.h
+++ /dev/null
@@ -1,80 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcb_rport.h BFA FCS rport driver interfaces
20 */
21
22#ifndef __BFA_FCB_RPORT_H__
23#define __BFA_FCB_RPORT_H__
24
25/**
26 * fcs_rport_fcb Remote port driver interfaces
27 */
28
29
30struct bfad_rport_s;
31
32/*
33 * Callback functions from BFA FCS to driver
34 */
35
36/**
37 * Completion callback for bfa_fcs_rport_add().
38 *
39 * @param[in] rport_drv - driver instance of rport
40 *
41 * @return None
42 */
43void bfa_fcb_rport_add(struct bfad_rport_s *rport_drv);
44
45/**
46 * Completion callback for bfa_fcs_rport_remove().
47 *
48 * @param[in] rport_drv - driver instance of rport
49 *
50 * @return None
51 */
52void bfa_fcb_rport_remove(struct bfad_rport_s *rport_drv);
53
54/**
55 * Call to allocate a rport instance.
56 *
57 * @param[in] bfad - driver instance
58 * @param[out] rport - BFA FCS instance of rport
59 * @param[out] rport_drv - driver instance of rport
60 *
61 * @retval BFA_STATUS_OK - successfully allocated
62 * @retval BFA_STATUS_ENOMEM - cannot allocate
63 */
64bfa_status_t bfa_fcb_rport_alloc(struct bfad_s *bfad,
65 struct bfa_fcs_rport_s **rport,
66 struct bfad_rport_s **rport_drv);
67
68/**
69 * Call to free rport memory resources.
70 *
71 * @param[in] bfad - driver instance
72 * @param[in] rport_drv - driver instance of rport
73 *
74 * @return None
75 */
76void bfa_fcb_rport_free(struct bfad_s *bfad, struct bfad_rport_s **rport_drv);
77
78
79
80#endif /* __BFA_FCB_RPORT_H__ */
diff --git a/drivers/scsi/bfa/include/fcb/bfa_fcb_vf.h b/drivers/scsi/bfa/include/fcb/bfa_fcb_vf.h
deleted file mode 100644
index cfd3fac0a4e2..000000000000
--- a/drivers/scsi/bfa/include/fcb/bfa_fcb_vf.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcb_vf.h BFA FCS virtual fabric driver interfaces
20 */
21
22#ifndef __BFA_FCB_VF_H__
23#define __BFA_FCB_VF_H__
24
25/**
26 * fcs_vf_fcb Virtual fabric driver intrefaces
27 */
28
29
30struct bfad_vf_s;
31
32/*
33 * Callback functions from BFA FCS to driver
34 */
35
36/**
37 * Completion callback for bfa_fcs_vf_stop().
38 *
39 * @param[in] vf_drv - driver instance of vf
40 *
41 * @return None
42 */
43void bfa_fcb_vf_stop(struct bfad_vf_s *vf_drv);
44
45
46
47#endif /* __BFA_FCB_VF_H__ */
diff --git a/drivers/scsi/bfa/include/fcb/bfa_fcb_vport.h b/drivers/scsi/bfa/include/fcb/bfa_fcb_vport.h
deleted file mode 100644
index cfd6ba7c47ec..000000000000
--- a/drivers/scsi/bfa/include/fcb/bfa_fcb_vport.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcb_vport.h BFA FCS virtual port driver interfaces
20 */
21
22#ifndef __BFA_FCB_VPORT_H__
23#define __BFA_FCB_VPORT_H__
24
25/**
26 * fcs_vport_fcb Virtual port driver interfaces
27 */
28
29
30struct bfad_vport_s;
31
32/*
33 * Callback functions from BFA FCS to driver
34 */
35
36/**
37 * Completion callback for bfa_fcs_vport_delete().
38 *
39 * @param[in] vport_drv - driver instance of vport
40 *
41 * @return None
42 */
43void bfa_fcb_vport_delete(struct bfad_vport_s *vport_drv);
44void bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s);
45
46
47
48#endif /* __BFA_FCB_VPORT_H__ */
diff --git a/drivers/scsi/bfa/include/fcs/bfa_fcs.h b/drivers/scsi/bfa/include/fcs/bfa_fcs.h
deleted file mode 100644
index 54e5b81ab2a3..000000000000
--- a/drivers/scsi/bfa/include/fcs/bfa_fcs.h
+++ /dev/null
@@ -1,76 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 <cs/bfa_debug.h>
22#include <defs/bfa_defs_status.h>
23#include <defs/bfa_defs_version.h>
24#include <bfa.h>
25#include <fcs/bfa_fcs_fabric.h>
26
27#define BFA_FCS_OS_STR_LEN 64
28
29struct bfa_fcs_stats_s {
30 struct {
31 u32 untagged; /* untagged receive frames */
32 u32 tagged; /* tagged receive frames */
33 u32 vfid_unknown; /* VF id is unknown */
34 } uf;
35};
36
37struct bfa_fcs_driver_info_s {
38 u8 version[BFA_VERSION_LEN]; /* Driver Version */
39 u8 host_machine_name[BFA_FCS_OS_STR_LEN];
40 u8 host_os_name[BFA_FCS_OS_STR_LEN]; /* OS name and version */
41 u8 host_os_patch[BFA_FCS_OS_STR_LEN];/* patch or service pack */
42 u8 os_device_name[BFA_FCS_OS_STR_LEN]; /* Driver Device Name */
43};
44
45struct bfa_fcs_s {
46 struct bfa_s *bfa; /* corresponding BFA bfa instance */
47 struct bfad_s *bfad; /* corresponding BDA driver instance */
48 struct bfa_log_mod_s *logm; /* driver logging module instance */
49 struct bfa_trc_mod_s *trcmod; /* tracing module */
50 struct bfa_aen_s *aen; /* aen component */
51 bfa_boolean_t vf_enabled; /* VF mode is enabled */
52 bfa_boolean_t fdmi_enabled; /*!< FDMI is enabled */
53 bfa_boolean_t min_cfg; /* min cfg enabled/disabled */
54 u16 port_vfid; /* port default VF ID */
55 struct bfa_fcs_driver_info_s driver_info;
56 struct bfa_fcs_fabric_s fabric; /* base fabric state machine */
57 struct bfa_fcs_stats_s stats; /* FCS statistics */
58 struct bfa_wc_s wc; /* waiting counter */
59};
60
61/*
62 * bfa fcs API functions
63 */
64void bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa,
65 struct bfad_s *bfad, bfa_boolean_t min_cfg);
66void bfa_fcs_init(struct bfa_fcs_s *fcs);
67void bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
68 struct bfa_fcs_driver_info_s *driver_info);
69void bfa_fcs_set_fdmi_param(struct bfa_fcs_s *fcs, bfa_boolean_t fdmi_enable);
70void bfa_fcs_exit(struct bfa_fcs_s *fcs);
71void bfa_fcs_trc_init(struct bfa_fcs_s *fcs, struct bfa_trc_mod_s *trcmod);
72void bfa_fcs_log_init(struct bfa_fcs_s *fcs, struct bfa_log_mod_s *logmod);
73void bfa_fcs_aen_init(struct bfa_fcs_s *fcs, struct bfa_aen_s *aen);
74void bfa_fcs_start(struct bfa_fcs_s *fcs);
75
76#endif /* __BFA_FCS_H__ */
diff --git a/drivers/scsi/bfa/include/fcs/bfa_fcs_auth.h b/drivers/scsi/bfa/include/fcs/bfa_fcs_auth.h
deleted file mode 100644
index 28c4c9ff08b3..000000000000
--- a/drivers/scsi/bfa/include/fcs/bfa_fcs_auth.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_AUTH_H__
19#define __BFA_FCS_AUTH_H__
20
21struct bfa_fcs_s;
22
23#include <defs/bfa_defs_status.h>
24#include <defs/bfa_defs_auth.h>
25#include <defs/bfa_defs_vf.h>
26#include <cs/bfa_q.h>
27#include <cs/bfa_sm.h>
28#include <defs/bfa_defs_pport.h>
29#include <fcs/bfa_fcs_lport.h>
30#include <protocol/fc_sp.h>
31
32struct bfa_fcs_fabric_s;
33
34
35
36struct bfa_fcs_auth_s {
37 bfa_sm_t sm; /* state machine */
38 bfa_boolean_t policy; /* authentication enabled/disabled */
39 enum bfa_auth_status status; /* authentication status */
40 enum auth_rjt_codes rjt_code; /* auth reject status */
41 enum auth_rjt_code_exps rjt_code_exp; /* auth reject reason */
42 enum bfa_auth_algo algo; /* Authentication algorithm */
43 struct bfa_auth_stats_s stats; /* Statistics */
44 enum auth_dh_gid group; /* DH(diffie-hellman) Group */
45 enum bfa_auth_secretsource source; /* Secret source */
46 char secret[BFA_AUTH_SECRET_STRING_LEN];
47 /* secret string */
48 u8 secret_len;
49 /* secret string length */
50 u8 nretries;
51 /* number of retries */
52 struct bfa_fcs_fabric_s *fabric;/* pointer to fabric */
53 u8 sentcode; /* pointer to response data */
54 u8 *response; /* pointer to response data */
55 struct bfa_timer_s delay_timer; /* delay timer */
56 struct bfa_fcxp_s *fcxp; /* pointer to fcxp */
57 struct bfa_fcxp_wqe_s fcxp_wqe;
58};
59
60/**
61 * bfa fcs authentication public functions
62 */
63bfa_status_t bfa_fcs_auth_get_attr(struct bfa_fcs_s *port,
64 struct bfa_auth_attr_s *attr);
65bfa_status_t bfa_fcs_auth_set_policy(struct bfa_fcs_s *port,
66 bfa_boolean_t policy);
67enum bfa_auth_status bfa_fcs_auth_get_status(struct bfa_fcs_s *port);
68bfa_status_t bfa_fcs_auth_set_algo(struct bfa_fcs_s *port,
69 enum bfa_auth_algo algo);
70bfa_status_t bfa_fcs_auth_get_stats(struct bfa_fcs_s *port,
71 struct bfa_auth_stats_s *stats);
72bfa_status_t bfa_fcs_auth_set_dh_group(struct bfa_fcs_s *port, int group);
73bfa_status_t bfa_fcs_auth_set_secretstring(struct bfa_fcs_s *port,
74 char *secret);
75bfa_status_t bfa_fcs_auth_set_secretstring_encrypt(struct bfa_fcs_s *port,
76 u32 secret[], u32 len);
77bfa_status_t bfa_fcs_auth_set_secretsource(struct bfa_fcs_s *port,
78 enum bfa_auth_secretsource src);
79bfa_status_t bfa_fcs_auth_reset_stats(struct bfa_fcs_s *port);
80bfa_status_t bfa_fcs_auth_reinit(struct bfa_fcs_s *port);
81
82#endif /* __BFA_FCS_AUTH_H__ */
diff --git a/drivers/scsi/bfa/include/fcs/bfa_fcs_fabric.h b/drivers/scsi/bfa/include/fcs/bfa_fcs_fabric.h
deleted file mode 100644
index 08b79d5e46f3..000000000000
--- a/drivers/scsi/bfa/include/fcs/bfa_fcs_fabric.h
+++ /dev/null
@@ -1,112 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_FABRIC_H__
19#define __BFA_FCS_FABRIC_H__
20
21struct bfa_fcs_s;
22
23#include <defs/bfa_defs_status.h>
24#include <defs/bfa_defs_vf.h>
25#include <cs/bfa_q.h>
26#include <cs/bfa_sm.h>
27#include <defs/bfa_defs_pport.h>
28#include <fcs/bfa_fcs_lport.h>
29#include <protocol/fc_sp.h>
30#include <fcs/bfa_fcs_auth.h>
31
32/*
33 * forward declaration
34 */
35struct bfad_vf_s;
36
37enum bfa_fcs_fabric_type {
38 BFA_FCS_FABRIC_UNKNOWN = 0,
39 BFA_FCS_FABRIC_SWITCHED = 1,
40 BFA_FCS_FABRIC_PLOOP = 2,
41 BFA_FCS_FABRIC_N2N = 3,
42};
43
44
45struct bfa_fcs_fabric_s {
46 struct list_head qe; /* queue element */
47 bfa_sm_t sm; /* state machine */
48 struct bfa_fcs_s *fcs; /* FCS instance */
49 struct bfa_fcs_port_s bport; /* base logical port */
50 enum bfa_fcs_fabric_type fab_type; /* fabric type */
51 enum bfa_pport_type oper_type; /* current link topology */
52 u8 is_vf; /* is virtual fabric? */
53 u8 is_npiv; /* is NPIV supported ? */
54 u8 is_auth; /* is Security/Auth supported ? */
55 u16 bb_credit; /* BB credit from fabric */
56 u16 vf_id; /* virtual fabric ID */
57 u16 num_vports; /* num vports */
58 u16 rsvd;
59 struct list_head vport_q; /* queue of virtual ports */
60 struct list_head vf_q; /* queue of virtual fabrics */
61 struct bfad_vf_s *vf_drv; /* driver vf structure */
62 struct bfa_timer_s link_timer; /* Link Failure timer. Vport */
63 wwn_t fabric_name; /* attached fabric name */
64 bfa_boolean_t auth_reqd; /* authentication required */
65 struct bfa_timer_s delay_timer; /* delay timer */
66 union {
67 u16 swp_vfid;/* switch port VF id */
68 } event_arg;
69 struct bfa_fcs_auth_s auth; /* authentication config */
70 struct bfa_wc_s wc; /* wait counter for delete */
71 struct bfa_vf_stats_s stats; /* fabric/vf stats */
72 struct bfa_lps_s *lps; /* lport login services */
73 u8 fabric_ip_addr[BFA_FCS_FABRIC_IPADDR_SZ]; /* attached
74 * fabric's ip addr
75 */
76};
77
78#define bfa_fcs_fabric_npiv_capable(__f) ((__f)->is_npiv)
79#define bfa_fcs_fabric_is_switched(__f) \
80 ((__f)->fab_type == BFA_FCS_FABRIC_SWITCHED)
81
82/**
83 * The design calls for a single implementation of base fabric and vf.
84 */
85#define bfa_fcs_vf_t struct bfa_fcs_fabric_s
86
87struct bfa_vf_event_s {
88 u32 undefined;
89};
90
91/**
92 * bfa fcs vf public functions
93 */
94bfa_status_t bfa_fcs_vf_mode_enable(struct bfa_fcs_s *fcs, u16 vf_id);
95bfa_status_t bfa_fcs_vf_mode_disable(struct bfa_fcs_s *fcs);
96bfa_status_t bfa_fcs_vf_create(bfa_fcs_vf_t *vf, struct bfa_fcs_s *fcs,
97 u16 vf_id, struct bfa_port_cfg_s *port_cfg,
98 struct bfad_vf_s *vf_drv);
99bfa_status_t bfa_fcs_vf_delete(bfa_fcs_vf_t *vf);
100void bfa_fcs_vf_start(bfa_fcs_vf_t *vf);
101bfa_status_t bfa_fcs_vf_stop(bfa_fcs_vf_t *vf);
102void bfa_fcs_vf_list(struct bfa_fcs_s *fcs, u16 *vf_ids, int *nvfs);
103void bfa_fcs_vf_list_all(struct bfa_fcs_s *fcs, u16 *vf_ids, int *nvfs);
104void bfa_fcs_vf_get_attr(bfa_fcs_vf_t *vf, struct bfa_vf_attr_s *vf_attr);
105void bfa_fcs_vf_get_stats(bfa_fcs_vf_t *vf,
106 struct bfa_vf_stats_s *vf_stats);
107void bfa_fcs_vf_clear_stats(bfa_fcs_vf_t *vf);
108void bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t vpwwn[], int *nports);
109bfa_fcs_vf_t *bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id);
110struct bfad_vf_s *bfa_fcs_vf_get_drv_vf(bfa_fcs_vf_t *vf);
111
112#endif /* __BFA_FCS_FABRIC_H__ */
diff --git a/drivers/scsi/bfa/include/fcs/bfa_fcs_fcpim.h b/drivers/scsi/bfa/include/fcs/bfa_fcs_fcpim.h
deleted file mode 100644
index 9a35ecf5cdf0..000000000000
--- a/drivers/scsi/bfa/include/fcs/bfa_fcs_fcpim.h
+++ /dev/null
@@ -1,132 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcs_fcpim.h BFA FCS FCP Initiator Mode interfaces/defines.
20 */
21
22#ifndef __BFA_FCS_FCPIM_H__
23#define __BFA_FCS_FCPIM_H__
24
25#include <defs/bfa_defs_status.h>
26#include <defs/bfa_defs_itnim.h>
27#include <fcs/bfa_fcs.h>
28#include <fcs/bfa_fcs_rport.h>
29#include <fcs/bfa_fcs_lport.h>
30#include <bfa_fcpim.h>
31
32/*
33 * forward declarations
34 */
35struct bfad_itnim_s;
36
37struct bfa_fcs_itnim_s {
38 bfa_sm_t sm; /* state machine */
39 struct bfa_fcs_rport_s *rport; /* parent remote rport */
40 struct bfad_itnim_s *itnim_drv; /* driver peer instance */
41 struct bfa_fcs_s *fcs; /* fcs instance */
42 struct bfa_timer_s timer; /* timer functions */
43 struct bfa_itnim_s *bfa_itnim; /* BFA itnim struct */
44 u32 prli_retries; /* max prli retry attempts */
45 bfa_boolean_t seq_rec; /* seq recovery support */
46 bfa_boolean_t rec_support; /* REC supported */
47 bfa_boolean_t conf_comp; /* FCP_CONF support */
48 bfa_boolean_t task_retry_id; /* task retry id supp */
49 struct bfa_fcxp_wqe_s fcxp_wqe; /* wait qelem for fcxp */
50 struct bfa_fcxp_s *fcxp; /* FCXP in use */
51 struct bfa_itnim_stats_s stats; /* itn statistics */
52};
53
54
55static inline struct bfad_port_s *
56bfa_fcs_itnim_get_drvport(struct bfa_fcs_itnim_s *itnim)
57{
58 return itnim->rport->port->bfad_port;
59}
60
61
62static inline struct bfa_fcs_port_s *
63bfa_fcs_itnim_get_port(struct bfa_fcs_itnim_s *itnim)
64{
65 return itnim->rport->port;
66}
67
68
69static inline wwn_t
70bfa_fcs_itnim_get_nwwn(struct bfa_fcs_itnim_s *itnim)
71{
72 return itnim->rport->nwwn;
73}
74
75
76static inline wwn_t
77bfa_fcs_itnim_get_pwwn(struct bfa_fcs_itnim_s *itnim)
78{
79 return itnim->rport->pwwn;
80}
81
82
83static inline u32
84bfa_fcs_itnim_get_fcid(struct bfa_fcs_itnim_s *itnim)
85{
86 return itnim->rport->pid;
87}
88
89
90static inline u32
91bfa_fcs_itnim_get_maxfrsize(struct bfa_fcs_itnim_s *itnim)
92{
93 return itnim->rport->maxfrsize;
94}
95
96
97static inline enum fc_cos
98bfa_fcs_itnim_get_cos(struct bfa_fcs_itnim_s *itnim)
99{
100 return itnim->rport->fc_cos;
101}
102
103
104static inline struct bfad_itnim_s *
105bfa_fcs_itnim_get_drvitn(struct bfa_fcs_itnim_s *itnim)
106{
107 return itnim->itnim_drv;
108}
109
110
111static inline struct bfa_itnim_s *
112bfa_fcs_itnim_get_halitn(struct bfa_fcs_itnim_s *itnim)
113{
114 return itnim->bfa_itnim;
115}
116
117/**
118 * bfa fcs FCP Initiator mode API functions
119 */
120void bfa_fcs_itnim_get_attr(struct bfa_fcs_itnim_s *itnim,
121 struct bfa_itnim_attr_s *attr);
122void bfa_fcs_itnim_get_stats(struct bfa_fcs_itnim_s *itnim,
123 struct bfa_itnim_stats_s *stats);
124struct bfa_fcs_itnim_s *bfa_fcs_itnim_lookup(struct bfa_fcs_port_s *port,
125 wwn_t rpwwn);
126bfa_status_t bfa_fcs_itnim_attr_get(struct bfa_fcs_port_s *port, wwn_t rpwwn,
127 struct bfa_itnim_attr_s *attr);
128bfa_status_t bfa_fcs_itnim_stats_get(struct bfa_fcs_port_s *port, wwn_t rpwwn,
129 struct bfa_itnim_stats_s *stats);
130bfa_status_t bfa_fcs_itnim_stats_clear(struct bfa_fcs_port_s *port,
131 wwn_t rpwwn);
132#endif /* __BFA_FCS_FCPIM_H__ */
diff --git a/drivers/scsi/bfa/include/fcs/bfa_fcs_fdmi.h b/drivers/scsi/bfa/include/fcs/bfa_fcs_fdmi.h
deleted file mode 100644
index 4441fffc9c82..000000000000
--- a/drivers/scsi/bfa/include/fcs/bfa_fcs_fdmi.h
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcs_fdmi.h BFA fcs fdmi module public interface
20 */
21
22#ifndef __BFA_FCS_FDMI_H__
23#define __BFA_FCS_FDMI_H__
24#include <bfa_os_inc.h>
25#include <protocol/fdmi.h>
26
27#define BFA_FCS_FDMI_SUPORTED_SPEEDS (FDMI_TRANS_SPEED_1G | \
28 FDMI_TRANS_SPEED_2G | \
29 FDMI_TRANS_SPEED_4G | \
30 FDMI_TRANS_SPEED_8G)
31
32/*
33* HBA Attribute Block : BFA internal representation. Note : Some variable
34* sizes have been trimmed to suit BFA For Ex : Model will be "Brocade". Based
35 * on this the size has been reduced to 16 bytes from the standard's 64 bytes.
36 */
37struct bfa_fcs_fdmi_hba_attr_s {
38 wwn_t node_name;
39 u8 manufacturer[64];
40 u8 serial_num[64];
41 u8 model[16];
42 u8 model_desc[256];
43 u8 hw_version[8];
44 u8 driver_version[8];
45 u8 option_rom_ver[BFA_VERSION_LEN];
46 u8 fw_version[8];
47 u8 os_name[256];
48 u32 max_ct_pyld;
49};
50
51/*
52 * Port Attribute Block
53 */
54struct bfa_fcs_fdmi_port_attr_s {
55 u8 supp_fc4_types[32]; /* supported FC4 types */
56 u32 supp_speed; /* supported speed */
57 u32 curr_speed; /* current Speed */
58 u32 max_frm_size; /* max frame size */
59 u8 os_device_name[256]; /* OS device Name */
60 u8 host_name[256]; /* host name */
61};
62
63#endif /* __BFA_FCS_FDMI_H__ */
diff --git a/drivers/scsi/bfa/include/fcs/bfa_fcs_lport.h b/drivers/scsi/bfa/include/fcs/bfa_fcs_lport.h
deleted file mode 100644
index ceaefd3060f4..000000000000
--- a/drivers/scsi/bfa/include/fcs/bfa_fcs_lport.h
+++ /dev/null
@@ -1,219 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcs_port.h BFA fcs port module public interface
20 */
21
22#ifndef __BFA_FCS_PORT_H__
23#define __BFA_FCS_PORT_H__
24
25#include <defs/bfa_defs_status.h>
26#include <defs/bfa_defs_port.h>
27#include <defs/bfa_defs_pport.h>
28#include <defs/bfa_defs_rport.h>
29#include <cs/bfa_q.h>
30#include <bfa_svc.h>
31#include <cs/bfa_wc.h>
32
33struct bfa_fcs_s;
34struct bfa_fcs_fabric_s;
35
36/*
37 * Maximum Rports supported per port (physical/logical).
38 */
39#define BFA_FCS_MAX_RPORTS_SUPP 256 /* @todo : tentative value */
40
41
42struct bfa_fcs_port_ns_s {
43 bfa_sm_t sm; /* state machine */
44 struct bfa_timer_s timer;
45 struct bfa_fcs_port_s *port; /* parent port */
46 struct bfa_fcxp_s *fcxp;
47 struct bfa_fcxp_wqe_s fcxp_wqe;
48};
49
50
51struct bfa_fcs_port_scn_s {
52 bfa_sm_t sm; /* state machine */
53 struct bfa_timer_s timer;
54 struct bfa_fcs_port_s *port; /* parent port */
55 struct bfa_fcxp_s *fcxp;
56 struct bfa_fcxp_wqe_s fcxp_wqe;
57};
58
59
60struct bfa_fcs_port_fdmi_s {
61 bfa_sm_t sm; /* state machine */
62 struct bfa_timer_s timer;
63 struct bfa_fcs_port_ms_s *ms; /* parent ms */
64 struct bfa_fcxp_s *fcxp;
65 struct bfa_fcxp_wqe_s fcxp_wqe;
66 u8 retry_cnt; /* retry count */
67 u8 rsvd[3];
68};
69
70
71struct bfa_fcs_port_ms_s {
72 bfa_sm_t sm; /* state machine */
73 struct bfa_timer_s timer;
74 struct bfa_fcs_port_s *port; /* parent port */
75 struct bfa_fcxp_s *fcxp;
76 struct bfa_fcxp_wqe_s fcxp_wqe;
77 struct bfa_fcs_port_fdmi_s fdmi; /* FDMI component of MS */
78 u8 retry_cnt; /* retry count */
79 u8 rsvd[3];
80};
81
82
83struct bfa_fcs_port_fab_s {
84 struct bfa_fcs_port_ns_s ns; /* NS component of port */
85 struct bfa_fcs_port_scn_s scn; /* scn component of port */
86 struct bfa_fcs_port_ms_s ms; /* MS component of port */
87};
88
89
90
91#define MAX_ALPA_COUNT 127
92
93struct bfa_fcs_port_loop_s {
94 u8 num_alpa; /* Num of ALPA entries in the map */
95 u8 alpa_pos_map[MAX_ALPA_COUNT]; /* ALPA Positional
96 *Map */
97 struct bfa_fcs_port_s *port; /* parent port */
98};
99
100
101
102struct bfa_fcs_port_n2n_s {
103 u32 rsvd;
104 u16 reply_oxid; /* ox_id from the req flogi to be
105 *used in flogi acc */
106 wwn_t rem_port_wwn; /* Attached port's wwn */
107};
108
109
110union bfa_fcs_port_topo_u {
111 struct bfa_fcs_port_fab_s pfab;
112 struct bfa_fcs_port_loop_s ploop;
113 struct bfa_fcs_port_n2n_s pn2n;
114};
115
116
117struct bfa_fcs_port_s {
118 struct list_head qe; /* used by port/vport */
119 bfa_sm_t sm; /* state machine */
120 struct bfa_fcs_fabric_s *fabric;/* parent fabric */
121 struct bfa_port_cfg_s port_cfg;/* port configuration */
122 struct bfa_timer_s link_timer; /* timer for link offline */
123 u32 pid:24; /* FC address */
124 u8 lp_tag; /* lport tag */
125 u16 num_rports; /* Num of r-ports */
126 struct list_head rport_q; /* queue of discovered r-ports */
127 struct bfa_fcs_s *fcs; /* FCS instance */
128 union bfa_fcs_port_topo_u port_topo; /* fabric/loop/n2n details */
129 struct bfad_port_s *bfad_port; /* driver peer instance */
130 struct bfa_fcs_vport_s *vport; /* NULL for base ports */
131 struct bfa_fcxp_s *fcxp;
132 struct bfa_fcxp_wqe_s fcxp_wqe;
133 struct bfa_port_stats_s stats;
134 struct bfa_wc_s wc; /* waiting counter for events */
135};
136
137#define bfa_fcs_lport_t struct bfa_fcs_port_s
138
139/**
140 * Symbolic Name related defines
141 * Total bytes 255.
142 * Physical Port's symbolic name 128 bytes.
143 * For Vports, Vport's symbolic name is appended to the Physical port's
144 * Symbolic Name.
145 *
146 * Physical Port's symbolic name Format : (Total 128 bytes)
147 * Adapter Model number/name : 12 bytes
148 * Driver Version : 10 bytes
149 * Host Machine Name : 30 bytes
150 * Host OS Info : 48 bytes
151 * Host OS PATCH Info : 16 bytes
152 * ( remaining 12 bytes reserved to be used for separator)
153 */
154#define BFA_FCS_PORT_SYMBNAME_SEPARATOR " | "
155
156#define BFA_FCS_PORT_SYMBNAME_MODEL_SZ 12
157#define BFA_FCS_PORT_SYMBNAME_VERSION_SZ 10
158#define BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ 30
159#define BFA_FCS_PORT_SYMBNAME_OSINFO_SZ 48
160#define BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ 16
161
162/**
163 * Get FC port ID for a logical port.
164 */
165#define bfa_fcs_port_get_fcid(_lport) ((_lport)->pid)
166#define bfa_fcs_port_get_pwwn(_lport) ((_lport)->port_cfg.pwwn)
167#define bfa_fcs_port_get_nwwn(_lport) ((_lport)->port_cfg.nwwn)
168#define bfa_fcs_port_get_psym_name(_lport) ((_lport)->port_cfg.sym_name)
169#define bfa_fcs_port_is_initiator(_lport) \
170 ((_lport)->port_cfg.roles & BFA_PORT_ROLE_FCP_IM)
171#define bfa_fcs_port_is_target(_lport) \
172 ((_lport)->port_cfg.roles & BFA_PORT_ROLE_FCP_TM)
173#define bfa_fcs_port_get_nrports(_lport) \
174 ((_lport) ? (_lport)->num_rports : 0)
175
176static inline struct bfad_port_s *
177bfa_fcs_port_get_drvport(struct bfa_fcs_port_s *port)
178{
179 return port->bfad_port;
180}
181
182
183#define bfa_fcs_port_get_opertype(_lport) ((_lport)->fabric->oper_type)
184
185
186#define bfa_fcs_port_get_fabric_name(_lport) ((_lport)->fabric->fabric_name)
187
188
189#define bfa_fcs_port_get_fabric_ipaddr(_lport) \
190 ((_lport)->fabric->fabric_ip_addr)
191
192/**
193 * bfa fcs port public functions
194 */
195void bfa_fcs_cfg_base_port(struct bfa_fcs_s *fcs,
196 struct bfa_port_cfg_s *port_cfg);
197struct bfa_fcs_port_s *bfa_fcs_get_base_port(struct bfa_fcs_s *fcs);
198void bfa_fcs_port_get_rports(struct bfa_fcs_port_s *port,
199 wwn_t rport_wwns[], int *nrports);
200
201wwn_t bfa_fcs_port_get_rport(struct bfa_fcs_port_s *port, wwn_t wwn,
202 int index, int nrports, bfa_boolean_t bwwn);
203
204struct bfa_fcs_port_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs,
205 u16 vf_id, wwn_t lpwwn);
206
207void bfa_fcs_port_get_info(struct bfa_fcs_port_s *port,
208 struct bfa_port_info_s *port_info);
209void bfa_fcs_port_get_attr(struct bfa_fcs_port_s *port,
210 struct bfa_port_attr_s *port_attr);
211void bfa_fcs_port_get_stats(struct bfa_fcs_port_s *fcs_port,
212 struct bfa_port_stats_s *port_stats);
213void bfa_fcs_port_clear_stats(struct bfa_fcs_port_s *fcs_port);
214enum bfa_pport_speed bfa_fcs_port_get_rport_max_speed(
215 struct bfa_fcs_port_s *port);
216void bfa_fcs_port_enable_ipfc_roles(struct bfa_fcs_port_s *fcs_port);
217void bfa_fcs_port_disable_ipfc_roles(struct bfa_fcs_port_s *fcs_port);
218
219#endif /* __BFA_FCS_PORT_H__ */
diff --git a/drivers/scsi/bfa/include/fcs/bfa_fcs_rport.h b/drivers/scsi/bfa/include/fcs/bfa_fcs_rport.h
deleted file mode 100644
index 3027fc6c7722..000000000000
--- a/drivers/scsi/bfa/include/fcs/bfa_fcs_rport.h
+++ /dev/null
@@ -1,105 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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_RPORT_H__
19#define __BFA_FCS_RPORT_H__
20
21#include <defs/bfa_defs_status.h>
22#include <cs/bfa_q.h>
23#include <fcs/bfa_fcs.h>
24#include <defs/bfa_defs_rport.h>
25
26#define BFA_FCS_RPORT_DEF_DEL_TIMEOUT 90 /* in secs */
27/*
28 * forward declarations
29 */
30struct bfad_rport_s;
31
32struct bfa_fcs_itnim_s;
33struct bfa_fcs_tin_s;
34struct bfa_fcs_iprp_s;
35
36/* Rport Features (RPF) */
37struct bfa_fcs_rpf_s {
38 bfa_sm_t sm; /* state machine */
39 struct bfa_fcs_rport_s *rport; /* parent rport */
40 struct bfa_timer_s timer; /* general purpose timer */
41 struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
42 struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
43 int rpsc_retries; /* max RPSC retry attempts */
44 enum bfa_pport_speed rpsc_speed; /* Current Speed from RPSC.
45 * O if RPSC fails */
46 enum bfa_pport_speed assigned_speed; /* Speed assigned by the user.
47 * will be used if RPSC is not
48 * supported by the rport */
49};
50
51struct bfa_fcs_rport_s {
52 struct list_head qe; /* used by port/vport */
53 struct bfa_fcs_port_s *port; /* parent FCS port */
54 struct bfa_fcs_s *fcs; /* fcs instance */
55 struct bfad_rport_s *rp_drv; /* driver peer instance */
56 u32 pid; /* port ID of rport */
57 u16 maxfrsize; /* maximum frame size */
58 u16 reply_oxid; /* OX_ID of inbound requests */
59 enum fc_cos fc_cos; /* FC classes of service supp */
60 bfa_boolean_t cisc; /* CISC capable device */
61 bfa_boolean_t prlo; /* processing prlo or LOGO */
62 wwn_t pwwn; /* port wwn of rport */
63 wwn_t nwwn; /* node wwn of rport */
64 struct bfa_rport_symname_s psym_name; /* port symbolic name */
65 bfa_sm_t sm; /* state machine */
66 struct bfa_timer_s timer; /* general purpose timer */
67 struct bfa_fcs_itnim_s *itnim; /* ITN initiator mode role */
68 struct bfa_fcs_tin_s *tin; /* ITN initiator mode role */
69 struct bfa_fcs_iprp_s *iprp; /* IP/FC role */
70 struct bfa_rport_s *bfa_rport; /* BFA Rport */
71 struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
72 int plogi_retries; /* max plogi retry attempts */
73 int ns_retries; /* max NS query retry attempts */
74 struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
75 struct bfa_rport_stats_s stats; /* rport stats */
76 enum bfa_rport_function scsi_function; /* Initiator/Target */
77 struct bfa_fcs_rpf_s rpf; /* Rport features module */
78};
79
80static inline struct bfa_rport_s *
81bfa_fcs_rport_get_halrport(struct bfa_fcs_rport_s *rport)
82{
83 return rport->bfa_rport;
84}
85
86/**
87 * bfa fcs rport API functions
88 */
89bfa_status_t bfa_fcs_rport_add(struct bfa_fcs_port_s *port, wwn_t *pwwn,
90 struct bfa_fcs_rport_s *rport,
91 struct bfad_rport_s *rport_drv);
92bfa_status_t bfa_fcs_rport_remove(struct bfa_fcs_rport_s *rport);
93void bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
94 struct bfa_rport_attr_s *attr);
95void bfa_fcs_rport_get_stats(struct bfa_fcs_rport_s *rport,
96 struct bfa_rport_stats_s *stats);
97void bfa_fcs_rport_clear_stats(struct bfa_fcs_rport_s *rport);
98struct bfa_fcs_rport_s *bfa_fcs_rport_lookup(struct bfa_fcs_port_s *port,
99 wwn_t rpwwn);
100struct bfa_fcs_rport_s *bfa_fcs_rport_lookup_by_nwwn(
101 struct bfa_fcs_port_s *port, wwn_t rnwwn);
102void bfa_fcs_rport_set_del_timeout(u8 rport_tmo);
103void bfa_fcs_rport_set_speed(struct bfa_fcs_rport_s *rport,
104 enum bfa_pport_speed speed);
105#endif /* __BFA_FCS_RPORT_H__ */
diff --git a/drivers/scsi/bfa/include/fcs/bfa_fcs_vport.h b/drivers/scsi/bfa/include/fcs/bfa_fcs_vport.h
deleted file mode 100644
index 0af262430860..000000000000
--- a/drivers/scsi/bfa/include/fcs/bfa_fcs_vport.h
+++ /dev/null
@@ -1,67 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcs_vport.h BFA fcs vport module public interface
20 */
21
22#ifndef __BFA_FCS_VPORT_H__
23#define __BFA_FCS_VPORT_H__
24
25#include <defs/bfa_defs_status.h>
26#include <defs/bfa_defs_port.h>
27#include <defs/bfa_defs_vport.h>
28#include <fcs/bfa_fcs.h>
29#include <fcb/bfa_fcb_vport.h>
30
31struct bfa_fcs_vport_s {
32 struct list_head qe; /* queue elem */
33 bfa_sm_t sm; /* state machine */
34 bfa_fcs_lport_t lport; /* logical port */
35 struct bfa_timer_s timer; /* general purpose timer */
36 struct bfad_vport_s *vport_drv; /* Driver private */
37 struct bfa_vport_stats_s vport_stats; /* vport statistics */
38 struct bfa_lps_s *lps; /* Lport login service */
39 int fdisc_retries;
40};
41
42#define bfa_fcs_vport_get_port(vport) \
43 ((struct bfa_fcs_port_s *)(&vport->port))
44
45/**
46 * bfa fcs vport public functions
47 */
48bfa_status_t bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport,
49 struct bfa_fcs_s *fcs, u16 vf_id,
50 struct bfa_port_cfg_s *port_cfg,
51 struct bfad_vport_s *vport_drv);
52bfa_status_t bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s *vport,
53 struct bfa_fcs_s *fcs, uint16_t vf_id,
54 struct bfa_port_cfg_s *port_cfg,
55 struct bfad_vport_s *vport_drv);
56bfa_status_t bfa_fcs_vport_delete(struct bfa_fcs_vport_s *vport);
57bfa_status_t bfa_fcs_vport_start(struct bfa_fcs_vport_s *vport);
58bfa_status_t bfa_fcs_vport_stop(struct bfa_fcs_vport_s *vport);
59void bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport,
60 struct bfa_vport_attr_s *vport_attr);
61void bfa_fcs_vport_get_stats(struct bfa_fcs_vport_s *vport,
62 struct bfa_vport_stats_s *vport_stats);
63void bfa_fcs_vport_clr_stats(struct bfa_fcs_vport_s *vport);
64struct bfa_fcs_vport_s *bfa_fcs_vport_lookup(struct bfa_fcs_s *fcs,
65 u16 vf_id, wwn_t vpwwn);
66
67#endif /* __BFA_FCS_VPORT_H__ */
diff --git a/drivers/scsi/bfa/include/log/bfa_log_fcs.h b/drivers/scsi/bfa/include/log/bfa_log_fcs.h
deleted file mode 100644
index b6f5df8827f8..000000000000
--- a/drivers/scsi/bfa/include/log/bfa_log_fcs.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/*
19 * messages define for FCS Module
20 */
21#ifndef __BFA_LOG_FCS_H__
22#define __BFA_LOG_FCS_H__
23#include <cs/bfa_log.h>
24#define BFA_LOG_FCS_FABRIC_NOSWITCH \
25 (((u32) BFA_LOG_FCS_ID << BFA_LOG_MODID_OFFSET) | 1)
26#define BFA_LOG_FCS_FABRIC_ISOLATED \
27 (((u32) BFA_LOG_FCS_ID << BFA_LOG_MODID_OFFSET) | 2)
28#endif
diff --git a/drivers/scsi/bfa/include/log/bfa_log_hal.h b/drivers/scsi/bfa/include/log/bfa_log_hal.h
deleted file mode 100644
index 5f8f5e30b9e8..000000000000
--- a/drivers/scsi/bfa/include/log/bfa_log_hal.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/* messages define for HAL Module */
19#ifndef __BFA_LOG_HAL_H__
20#define __BFA_LOG_HAL_H__
21#include <cs/bfa_log.h>
22#define BFA_LOG_HAL_ASSERT \
23 (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 1)
24#define BFA_LOG_HAL_HEARTBEAT_FAILURE \
25 (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 2)
26#define BFA_LOG_HAL_FCPIM_PARM_INVALID \
27 (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 3)
28#define BFA_LOG_HAL_SM_ASSERT \
29 (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 4)
30#define BFA_LOG_HAL_DRIVER_ERROR \
31 (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 5)
32#define BFA_LOG_HAL_DRIVER_CONFIG_ERROR \
33 (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 6)
34#define BFA_LOG_HAL_MBOX_ERROR \
35 (((u32) BFA_LOG_HAL_ID << BFA_LOG_MODID_OFFSET) | 7)
36#endif
diff --git a/drivers/scsi/bfa/include/log/bfa_log_linux.h b/drivers/scsi/bfa/include/log/bfa_log_linux.h
deleted file mode 100644
index 44bc89768bda..000000000000
--- a/drivers/scsi/bfa/include/log/bfa_log_linux.h
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/* messages define for LINUX Module */
19#ifndef __BFA_LOG_LINUX_H__
20#define __BFA_LOG_LINUX_H__
21#include <cs/bfa_log.h>
22#define BFA_LOG_LINUX_DEVICE_CLAIMED \
23 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 1)
24#define BFA_LOG_LINUX_HASH_INIT_FAILED \
25 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 2)
26#define BFA_LOG_LINUX_SYSFS_FAILED \
27 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 3)
28#define BFA_LOG_LINUX_MEM_ALLOC_FAILED \
29 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 4)
30#define BFA_LOG_LINUX_DRIVER_REGISTRATION_FAILED \
31 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 5)
32#define BFA_LOG_LINUX_ITNIM_FREE \
33 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 6)
34#define BFA_LOG_LINUX_ITNIM_ONLINE \
35 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 7)
36#define BFA_LOG_LINUX_ITNIM_OFFLINE \
37 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 8)
38#define BFA_LOG_LINUX_SCSI_HOST_FREE \
39 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 9)
40#define BFA_LOG_LINUX_SCSI_ABORT \
41 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 10)
42#define BFA_LOG_LINUX_SCSI_ABORT_COMP \
43 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 11)
44#define BFA_LOG_LINUX_DRIVER_CONFIG_ERROR \
45 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 12)
46#define BFA_LOG_LINUX_BNA_STATE_MACHINE \
47 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 13)
48#define BFA_LOG_LINUX_IOC_ERROR \
49 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 14)
50#define BFA_LOG_LINUX_RESOURCE_ALLOC_ERROR \
51 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 15)
52#define BFA_LOG_LINUX_RING_BUFFER_ERROR \
53 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 16)
54#define BFA_LOG_LINUX_DRIVER_ERROR \
55 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 17)
56#define BFA_LOG_LINUX_DRIVER_INFO \
57 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 18)
58#define BFA_LOG_LINUX_DRIVER_DIAG \
59 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 19)
60#define BFA_LOG_LINUX_DRIVER_AEN \
61 (((u32) BFA_LOG_LINUX_ID << BFA_LOG_MODID_OFFSET) | 20)
62#endif
diff --git a/drivers/scsi/bfa/include/log/bfa_log_wdrv.h b/drivers/scsi/bfa/include/log/bfa_log_wdrv.h
deleted file mode 100644
index 809a95f7afe2..000000000000
--- a/drivers/scsi/bfa/include/log/bfa_log_wdrv.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/*
19 * messages define for WDRV Module
20 */
21#ifndef __BFA_LOG_WDRV_H__
22#define __BFA_LOG_WDRV_H__
23#include <cs/bfa_log.h>
24#define BFA_LOG_WDRV_IOC_INIT_ERROR \
25 (((u32) BFA_LOG_WDRV_ID << BFA_LOG_MODID_OFFSET) | 1)
26#define BFA_LOG_WDRV_IOC_INTERNAL_ERROR \
27 (((u32) BFA_LOG_WDRV_ID << BFA_LOG_MODID_OFFSET) | 2)
28#define BFA_LOG_WDRV_IOC_START_ERROR \
29 (((u32) BFA_LOG_WDRV_ID << BFA_LOG_MODID_OFFSET) | 3)
30#define BFA_LOG_WDRV_IOC_STOP_ERROR \
31 (((u32) BFA_LOG_WDRV_ID << BFA_LOG_MODID_OFFSET) | 4)
32#define BFA_LOG_WDRV_INSUFFICIENT_RESOURCES \
33 (((u32) BFA_LOG_WDRV_ID << BFA_LOG_MODID_OFFSET) | 5)
34#define BFA_LOG_WDRV_BASE_ADDRESS_MAP_ERROR \
35 (((u32) BFA_LOG_WDRV_ID << BFA_LOG_MODID_OFFSET) | 6)
36#endif
diff --git a/drivers/scsi/bfa/include/protocol/ct.h b/drivers/scsi/bfa/include/protocol/ct.h
deleted file mode 100644
index b82540a230c4..000000000000
--- a/drivers/scsi/bfa/include/protocol/ct.h
+++ /dev/null
@@ -1,492 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __CT_H__
19#define __CT_H__
20
21#include <protocol/types.h>
22
23#pragma pack(1)
24
25struct ct_hdr_s{
26 u32 rev_id:8; /* Revision of the CT */
27 u32 in_id:24; /* Initiator Id */
28 u32 gs_type:8; /* Generic service Type */
29 u32 gs_sub_type:8; /* Generic service sub type */
30 u32 options:8; /* options */
31 u32 rsvrd:8; /* reserved */
32 u32 cmd_rsp_code:16;/* ct command/response code */
33 u32 max_res_size:16;/* maximum/residual size */
34 u32 frag_id:8; /* fragment ID */
35 u32 reason_code:8; /* reason code */
36 u32 exp_code:8; /* explanation code */
37 u32 vendor_unq:8; /* vendor unique */
38};
39
40/*
41 * defines for the Revision
42 */
43enum {
44 CT_GS3_REVISION = 0x01,
45};
46
47/*
48 * defines for gs_type
49 */
50enum {
51 CT_GSTYPE_KEYSERVICE = 0xF7,
52 CT_GSTYPE_ALIASSERVICE = 0xF8,
53 CT_GSTYPE_MGMTSERVICE = 0xFA,
54 CT_GSTYPE_TIMESERVICE = 0xFB,
55 CT_GSTYPE_DIRSERVICE = 0xFC,
56};
57
58/*
59 * defines for gs_sub_type for gs type directory service
60 */
61enum {
62 CT_GSSUBTYPE_NAMESERVER = 0x02,
63};
64
65/*
66 * defines for gs_sub_type for gs type management service
67 */
68enum {
69 CT_GSSUBTYPE_CFGSERVER = 0x01,
70 CT_GSSUBTYPE_UNZONED_NS = 0x02,
71 CT_GSSUBTYPE_ZONESERVER = 0x03,
72 CT_GSSUBTYPE_LOCKSERVER = 0x04,
73 CT_GSSUBTYPE_HBA_MGMTSERVER = 0x10, /* for FDMI */
74};
75
76/*
77 * defines for CT response code field
78 */
79enum {
80 CT_RSP_REJECT = 0x8001,
81 CT_RSP_ACCEPT = 0x8002,
82};
83
84/*
85 * definitions for CT reason code
86 */
87enum {
88 CT_RSN_INV_CMD = 0x01,
89 CT_RSN_INV_VER = 0x02,
90 CT_RSN_LOGIC_ERR = 0x03,
91 CT_RSN_INV_SIZE = 0x04,
92 CT_RSN_LOGICAL_BUSY = 0x05,
93 CT_RSN_PROTO_ERR = 0x07,
94 CT_RSN_UNABLE_TO_PERF = 0x09,
95 CT_RSN_NOT_SUPP = 0x0B,
96 CT_RSN_SERVER_NOT_AVBL = 0x0D,
97 CT_RSN_SESSION_COULD_NOT_BE_ESTBD = 0x0E,
98 CT_RSN_VENDOR_SPECIFIC = 0xFF,
99
100};
101
102/*
103 * definitions for explanations code for Name server
104 */
105enum {
106 CT_NS_EXP_NOADDITIONAL = 0x00,
107 CT_NS_EXP_ID_NOT_REG = 0x01,
108 CT_NS_EXP_PN_NOT_REG = 0x02,
109 CT_NS_EXP_NN_NOT_REG = 0x03,
110 CT_NS_EXP_CS_NOT_REG = 0x04,
111 CT_NS_EXP_IPN_NOT_REG = 0x05,
112 CT_NS_EXP_IPA_NOT_REG = 0x06,
113 CT_NS_EXP_FT_NOT_REG = 0x07,
114 CT_NS_EXP_SPN_NOT_REG = 0x08,
115 CT_NS_EXP_SNN_NOT_REG = 0x09,
116 CT_NS_EXP_PT_NOT_REG = 0x0A,
117 CT_NS_EXP_IPP_NOT_REG = 0x0B,
118 CT_NS_EXP_FPN_NOT_REG = 0x0C,
119 CT_NS_EXP_HA_NOT_REG = 0x0D,
120 CT_NS_EXP_FD_NOT_REG = 0x0E,
121 CT_NS_EXP_FF_NOT_REG = 0x0F,
122 CT_NS_EXP_ACCESSDENIED = 0x10,
123 CT_NS_EXP_UNACCEPTABLE_ID = 0x11,
124 CT_NS_EXP_DATABASEEMPTY = 0x12,
125 CT_NS_EXP_NOT_REG_IN_SCOPE = 0x13,
126 CT_NS_EXP_DOM_ID_NOT_PRESENT = 0x14,
127 CT_NS_EXP_PORT_NUM_NOT_PRESENT = 0x15,
128 CT_NS_EXP_NO_DEVICE_ATTACHED = 0x16
129};
130
131/*
132 * definitions for the explanation code for all servers
133 */
134enum {
135 CT_EXP_AUTH_EXCEPTION = 0xF1,
136 CT_EXP_DB_FULL = 0xF2,
137 CT_EXP_DB_EMPTY = 0xF3,
138 CT_EXP_PROCESSING_REQ = 0xF4,
139 CT_EXP_UNABLE_TO_VERIFY_CONN = 0xF5,
140 CT_EXP_DEVICES_NOT_IN_CMN_ZONE = 0xF6
141};
142
143/*
144 * Command codes for Name server
145 */
146enum {
147 GS_GID_PN = 0x0121, /* Get Id on port name */
148 GS_GPN_ID = 0x0112, /* Get port name on ID */
149 GS_GNN_ID = 0x0113, /* Get node name on ID */
150 GS_GID_FT = 0x0171, /* Get Id on FC4 type */
151 GS_GSPN_ID = 0x0118, /* Get symbolic PN on ID */
152 GS_RFT_ID = 0x0217, /* Register fc4type on ID */
153 GS_RSPN_ID = 0x0218, /* Register symbolic PN on ID */
154 GS_RPN_ID = 0x0212, /* Register port name */
155 GS_RNN_ID = 0x0213, /* Register node name */
156 GS_RCS_ID = 0x0214, /* Register class of service */
157 GS_RPT_ID = 0x021A, /* Register port type */
158 GS_GA_NXT = 0x0100, /* Get all next */
159 GS_RFF_ID = 0x021F, /* Register FC4 Feature */
160};
161
162struct fcgs_id_req_s{
163 u32 rsvd:8;
164 u32 dap:24; /* port identifier */
165};
166#define fcgs_gpnid_req_t struct fcgs_id_req_s
167#define fcgs_gnnid_req_t struct fcgs_id_req_s
168#define fcgs_gspnid_req_t struct fcgs_id_req_s
169
170struct fcgs_gidpn_req_s{
171 wwn_t port_name; /* port wwn */
172};
173
174struct fcgs_gidpn_resp_s{
175 u32 rsvd:8;
176 u32 dap:24; /* port identifier */
177};
178
179/**
180 * RFT_ID
181 */
182struct fcgs_rftid_req_s {
183 u32 rsvd:8;
184 u32 dap:24; /* port identifier */
185 u32 fc4_type[8]; /* fc4 types */
186};
187
188/**
189 * RFF_ID : Register FC4 features.
190 */
191
192#define FC_GS_FCP_FC4_FEATURE_INITIATOR 0x02
193#define FC_GS_FCP_FC4_FEATURE_TARGET 0x01
194
195struct fcgs_rffid_req_s{
196 u32 rsvd:8;
197 u32 dap:24; /* port identifier */
198 u32 rsvd1:16;
199 u32 fc4ftr_bits:8; /* fc4 feature bits */
200 u32 fc4_type:8; /* corresponding FC4 Type */
201};
202
203/**
204 * GID_FT Request
205 */
206struct fcgs_gidft_req_s{
207 u8 reserved;
208 u8 domain_id; /* domain, 0 - all fabric */
209 u8 area_id; /* area, 0 - whole domain */
210 u8 fc4_type; /* FC_TYPE_FCP for SCSI devices */
211}; /* GID_FT Request */
212
213/**
214 * GID_FT Response
215 */
216struct fcgs_gidft_resp_s {
217 u8 last:1; /* last port identifier flag */
218 u8 reserved:7;
219 u32 pid:24; /* port identifier */
220}; /* GID_FT Response */
221
222/**
223 * RSPN_ID
224 */
225struct fcgs_rspnid_req_s{
226 u32 rsvd:8;
227 u32 dap:24; /* port identifier */
228 u8 spn_len; /* symbolic port name length */
229 u8 spn[256]; /* symbolic port name */
230};
231
232/**
233 * RPN_ID
234 */
235struct fcgs_rpnid_req_s{
236 u32 rsvd:8;
237 u32 port_id:24;
238 wwn_t port_name;
239};
240
241/**
242 * RNN_ID
243 */
244struct fcgs_rnnid_req_s{
245 u32 rsvd:8;
246 u32 port_id:24;
247 wwn_t node_name;
248};
249
250/**
251 * RCS_ID
252 */
253struct fcgs_rcsid_req_s{
254 u32 rsvd:8;
255 u32 port_id:24;
256 u32 cos;
257};
258
259/**
260 * RPT_ID
261 */
262struct fcgs_rptid_req_s{
263 u32 rsvd:8;
264 u32 port_id:24;
265 u32 port_type:8;
266 u32 rsvd1:24;
267};
268
269/**
270 * GA_NXT Request
271 */
272struct fcgs_ganxt_req_s{
273 u32 rsvd:8;
274 u32 port_id:24;
275};
276
277/**
278 * GA_NXT Response
279 */
280struct fcgs_ganxt_rsp_s{
281 u32 port_type:8; /* Port Type */
282 u32 port_id:24; /* Port Identifier */
283 wwn_t port_name; /* Port Name */
284 u8 spn_len; /* Length of Symbolic Port Name */
285 char spn[255]; /* Symbolic Port Name */
286 wwn_t node_name; /* Node Name */
287 u8 snn_len; /* Length of Symbolic Node Name */
288 char snn[255]; /* Symbolic Node Name */
289 u8 ipa[8]; /* Initial Process Associator */
290 u8 ip[16]; /* IP Address */
291 u32 cos; /* Class of Service */
292 u32 fc4types[8]; /* FC-4 TYPEs */
293 wwn_t fabric_port_name;
294 /* Fabric Port Name */
295 u32 rsvd:8; /* Reserved */
296 u32 hard_addr:24; /* Hard Address */
297};
298
299/*
300 * Fabric Config Server
301 */
302
303/*
304 * Command codes for Fabric Configuration Server
305 */
306enum {
307 GS_FC_GFN_CMD = 0x0114, /* GS FC Get Fabric Name */
308 GS_FC_GMAL_CMD = 0x0116, /* GS FC GMAL */
309 GS_FC_TRACE_CMD = 0x0400, /* GS FC Trace Route */
310 GS_FC_PING_CMD = 0x0401, /* GS FC Ping */
311};
312
313/*
314 * Source or Destination Port Tags.
315 */
316enum {
317 GS_FTRACE_TAG_NPORT_ID = 1,
318 GS_FTRACE_TAG_NPORT_NAME = 2,
319};
320
321/*
322* Port Value : Could be a Port id or wwn
323 */
324union fcgs_port_val_u{
325 u32 nport_id;
326 wwn_t nport_wwn;
327};
328
329#define GS_FTRACE_MAX_HOP_COUNT 20
330#define GS_FTRACE_REVISION 1
331
332/*
333 * Ftrace Related Structures.
334 */
335
336/*
337 * STR (Switch Trace) Reject Reason Codes. From FC-SW.
338 */
339enum {
340 GS_FTRACE_STR_CMD_COMPLETED_SUCC = 0,
341 GS_FTRACE_STR_CMD_NOT_SUPP_IN_NEXT_SWITCH,
342 GS_FTRACE_STR_NO_RESP_FROM_NEXT_SWITCH,
343 GS_FTRACE_STR_MAX_HOP_CNT_REACHED,
344 GS_FTRACE_STR_SRC_PORT_NOT_FOUND,
345 GS_FTRACE_STR_DST_PORT_NOT_FOUND,
346 GS_FTRACE_STR_DEVICES_NOT_IN_COMMON_ZONE,
347 GS_FTRACE_STR_NO_ROUTE_BW_PORTS,
348 GS_FTRACE_STR_NO_ADDL_EXPLN,
349 GS_FTRACE_STR_FABRIC_BUSY,
350 GS_FTRACE_STR_FABRIC_BUILD_IN_PROGRESS,
351 GS_FTRACE_STR_VENDOR_SPECIFIC_ERR_START = 0xf0,
352 GS_FTRACE_STR_VENDOR_SPECIFIC_ERR_END = 0xff,
353};
354
355/*
356 * Ftrace Request
357 */
358struct fcgs_ftrace_req_s{
359 u32 revision;
360 u16 src_port_tag; /* Source Port tag */
361 u16 src_port_len; /* Source Port len */
362 union fcgs_port_val_u src_port_val; /* Source Port value */
363 u16 dst_port_tag; /* Destination Port tag */
364 u16 dst_port_len; /* Destination Port len */
365 union fcgs_port_val_u dst_port_val; /* Destination Port value */
366 u32 token;
367 u8 vendor_id[8]; /* T10 Vendor Identifier */
368 u8 vendor_info[8]; /* Vendor specific Info */
369 u32 max_hop_cnt; /* Max Hop Count */
370};
371
372/*
373 * Path info structure
374 */
375struct fcgs_ftrace_path_info_s{
376 wwn_t switch_name; /* Switch WWN */
377 u32 domain_id;
378 wwn_t ingress_port_name; /* Ingress ports wwn */
379 u32 ingress_phys_port_num; /* Ingress ports physical port
380 * number
381 */
382 wwn_t egress_port_name; /* Ingress ports wwn */
383 u32 egress_phys_port_num; /* Ingress ports physical port
384 * number
385 */
386};
387
388/*
389 * Ftrace Acc Response
390 */
391struct fcgs_ftrace_resp_s{
392 u32 revision;
393 u32 token;
394 u8 vendor_id[8]; /* T10 Vendor Identifier */
395 u8 vendor_info[8]; /* Vendor specific Info */
396 u32 str_rej_reason_code; /* STR Reject Reason Code */
397 u32 num_path_info_entries; /* No. of path info entries */
398 /*
399 * path info entry/entries.
400 */
401 struct fcgs_ftrace_path_info_s path_info[1];
402
403};
404
405/*
406* Fabric Config Server : FCPing
407 */
408
409/*
410 * FC Ping Request
411 */
412struct fcgs_fcping_req_s{
413 u32 revision;
414 u16 port_tag;
415 u16 port_len; /* Port len */
416 union fcgs_port_val_u port_val; /* Port value */
417 u32 token;
418};
419
420/*
421 * FC Ping Response
422 */
423struct fcgs_fcping_resp_s{
424 u32 token;
425};
426
427/*
428 * Command codes for zone server query.
429 */
430enum {
431 ZS_GZME = 0x0124, /* Get zone member extended */
432};
433
434/*
435 * ZS GZME request
436 */
437#define ZS_GZME_ZNAMELEN 32
438struct zs_gzme_req_s{
439 u8 znamelen;
440 u8 rsvd[3];
441 u8 zname[ZS_GZME_ZNAMELEN];
442};
443
444enum zs_mbr_type{
445 ZS_MBR_TYPE_PWWN = 1,
446 ZS_MBR_TYPE_DOMPORT = 2,
447 ZS_MBR_TYPE_PORTID = 3,
448 ZS_MBR_TYPE_NWWN = 4,
449};
450
451struct zs_mbr_wwn_s{
452 u8 mbr_type;
453 u8 rsvd[3];
454 wwn_t wwn;
455};
456
457struct zs_query_resp_s{
458 u32 nmbrs; /* number of zone members */
459 struct zs_mbr_wwn_s mbr[1];
460};
461
462/*
463 * GMAL Command ( Get ( interconnect Element) Management Address List)
464 * To retrieve the IP Address of a Switch.
465 */
466
467#define CT_GMAL_RESP_PREFIX_TELNET "telnet://"
468#define CT_GMAL_RESP_PREFIX_HTTP "http://"
469
470/* GMAL/GFN request */
471struct fcgs_req_s {
472 wwn_t wwn; /* PWWN/NWWN */
473};
474
475#define fcgs_gmal_req_t struct fcgs_req_s
476#define fcgs_gfn_req_t struct fcgs_req_s
477
478/* Accept Response to GMAL */
479struct fcgs_gmal_resp_s {
480 u32 ms_len; /* Num of entries */
481 u8 ms_ma[256];
482};
483
484struct fc_gmal_entry_s {
485 u8 len;
486 u8 prefix[7]; /* like "http://" */
487 u8 ip_addr[248];
488};
489
490#pragma pack()
491
492#endif
diff --git a/drivers/scsi/bfa/include/protocol/fc_sp.h b/drivers/scsi/bfa/include/protocol/fc_sp.h
deleted file mode 100644
index 55bb0b31d04b..000000000000
--- a/drivers/scsi/bfa/include/protocol/fc_sp.h
+++ /dev/null
@@ -1,224 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __FC_SP_H__
19#define __FC_SP_H__
20
21#include <protocol/types.h>
22
23#pragma pack(1)
24
25enum auth_els_flags{
26 FC_AUTH_ELS_MORE_FRAGS_FLAG = 0x80, /*! bit-7. More Fragments
27 * Follow
28 */
29 FC_AUTH_ELS_CONCAT_FLAG = 0x40, /*! bit-6. Concatenation Flag */
30 FC_AUTH_ELS_SEQ_NUM_FLAG = 0x01 /*! bit-0. Sequence Number */
31};
32
33enum auth_msg_codes{
34 FC_AUTH_MC_AUTH_RJT = 0x0A, /*! Auth Reject */
35 FC_AUTH_MC_AUTH_NEG = 0x0B, /*! Auth Negotiate */
36 FC_AUTH_MC_AUTH_DONE = 0x0C, /*! Auth Done */
37
38 FC_AUTH_MC_DHCHAP_CHAL = 0x10, /*! DHCHAP Challenge */
39 FC_AUTH_MC_DHCHAP_REPLY = 0x11, /*! DHCHAP Reply */
40 FC_AUTH_MC_DHCHAP_SUCC = 0x12, /*! DHCHAP Success */
41
42 FC_AUTH_MC_FCAP_REQ = 0x13, /*! FCAP Request */
43 FC_AUTH_MC_FCAP_ACK = 0x14, /*! FCAP Acknowledge */
44 FC_AUTH_MC_FCAP_CONF = 0x15, /*! FCAP Confirm */
45
46 FC_AUTH_MC_FCPAP_INIT = 0x16, /*! FCPAP Init */
47 FC_AUTH_MC_FCPAP_ACC = 0x17, /*! FCPAP Accept */
48 FC_AUTH_MC_FCPAP_COMP = 0x18, /*! FCPAP Complete */
49
50 FC_AUTH_MC_IKE_SA_INIT = 0x22, /*! IKE SA INIT */
51 FC_AUTH_MC_IKE_SA_AUTH = 0x23, /*! IKE SA Auth */
52 FC_AUTH_MC_IKE_CREATE_CHILD_SA = 0x24, /*! IKE Create Child SA */
53 FC_AUTH_MC_IKE_INFO = 0x25, /*! IKE informational */
54};
55
56enum auth_proto_version{
57 FC_AUTH_PROTO_VER_1 = 1, /*! Protocol Version 1 */
58};
59
60enum {
61 FC_AUTH_ELS_COMMAND_CODE = 0x90,/*! Authentication ELS Command code */
62 FC_AUTH_PROTO_PARAM_LEN_SZ = 4, /*! Size of Proto Parameter Len Field */
63 FC_AUTH_PROTO_PARAM_VAL_SZ = 4, /*! Size of Proto Parameter Val Field */
64 FC_MAX_AUTH_SECRET_LEN = 256,
65 /*! Maximum secret string length */
66 FC_AUTH_NUM_USABLE_PROTO_LEN_SZ = 4,
67 /*! Size of usable protocols field */
68 FC_AUTH_RESP_VALUE_LEN_SZ = 4,
69 /*! Size of response value length */
70 FC_MAX_CHAP_KEY_LEN = 256, /*! Maximum md5 digest length */
71 FC_MAX_AUTH_RETRIES = 3, /*! Maximum number of retries */
72 FC_MD5_DIGEST_LEN = 16, /*! MD5 digest length */
73 FC_SHA1_DIGEST_LEN = 20, /*! SHA1 digest length */
74 FC_MAX_DHG_SUPPORTED = 1, /*! Maximum DH Groups supported */
75 FC_MAX_ALG_SUPPORTED = 1, /*! Maximum algorithms supported */
76 FC_MAX_PROTO_SUPPORTED = 1, /*! Maximum protocols supported */
77 FC_START_TXN_ID = 2, /*! Starting transaction ID */
78};
79
80enum auth_proto_id{
81 FC_AUTH_PROTO_DHCHAP = 0x00000001,
82 FC_AUTH_PROTO_FCAP = 0x00000002,
83 FC_AUTH_PROTO_FCPAP = 0x00000003,
84 FC_AUTH_PROTO_IKEv2 = 0x00000004,
85 FC_AUTH_PROTO_IKEv2_AUTH = 0x00000005,
86};
87
88struct auth_name_s{
89 u16 name_tag; /*! Name Tag = 1 for Authentication */
90 u16 name_len; /*! Name Length = 8 for Authentication
91 */
92 wwn_t name; /*! Name. TODO - is this PWWN */
93};
94
95
96enum auth_hash_func{
97 FC_AUTH_HASH_FUNC_MD5 = 0x00000005,
98 FC_AUTH_HASH_FUNC_SHA_1 = 0x00000006,
99};
100
101enum auth_dh_gid{
102 FC_AUTH_DH_GID_0_DHG_NULL = 0x00000000,
103 FC_AUTH_DH_GID_1_DHG_1024 = 0x00000001,
104 FC_AUTH_DH_GID_2_DHG_1280 = 0x00000002,
105 FC_AUTH_DH_GID_3_DHG_1536 = 0x00000003,
106 FC_AUTH_DH_GID_4_DHG_2048 = 0x00000004,
107 FC_AUTH_DH_GID_6_DHG_3072 = 0x00000006,
108 FC_AUTH_DH_GID_7_DHG_4096 = 0x00000007,
109 FC_AUTH_DH_GID_8_DHG_6144 = 0x00000008,
110 FC_AUTH_DH_GID_9_DHG_8192 = 0x00000009,
111};
112
113struct auth_els_msg_s {
114 u8 auth_els_code; /* Authentication ELS Code (0x90) */
115 u8 auth_els_flag; /* Authentication ELS Flags */
116 u8 auth_msg_code; /* Authentication Message Code */
117 u8 proto_version; /* Protocol Version */
118 u32 msg_len; /* Message Length */
119 u32 trans_id; /* Transaction Identifier (T_ID) */
120
121 /* Msg payload follows... */
122};
123
124
125enum auth_neg_param_tags {
126 FC_AUTH_NEG_DHCHAP_HASHLIST = 0x0001,
127 FC_AUTH_NEG_DHCHAP_DHG_ID_LIST = 0x0002,
128};
129
130
131struct dhchap_param_format_s {
132 u16 tag; /*! Parameter Tag. See
133 * auth_neg_param_tags_t
134 */
135 u16 word_cnt;
136
137 /* followed by variable length parameter value... */
138};
139
140struct auth_proto_params_s {
141 u32 proto_param_len;
142 u32 proto_id;
143
144 /*
145 * Followed by variable length Protocol specific parameters. DH-CHAP
146 * uses dhchap_param_format_t
147 */
148};
149
150struct auth_neg_msg_s {
151 struct auth_name_s auth_ini_name;
152 u32 usable_auth_protos;
153 struct auth_proto_params_s proto_params[1]; /*! (1..usable_auth_proto)
154 * protocol params
155 */
156};
157
158struct auth_dh_val_s {
159 u32 dh_val_len;
160 u32 dh_val[1];
161};
162
163struct auth_dhchap_chal_msg_s {
164 struct auth_els_msg_s hdr;
165 struct auth_name_s auth_responder_name; /* TODO VRK - is auth_name_t
166 * type OK?
167 */
168 u32 hash_id;
169 u32 dh_grp_id;
170 u32 chal_val_len;
171 char chal_val[1];
172
173 /* ...followed by variable Challenge length/value and DH length/value */
174};
175
176
177enum auth_rjt_codes {
178 FC_AUTH_RJT_CODE_AUTH_FAILURE = 0x01,
179 FC_AUTH_RJT_CODE_LOGICAL_ERR = 0x02,
180};
181
182enum auth_rjt_code_exps {
183 FC_AUTH_CEXP_AUTH_MECH_NOT_USABLE = 0x01,
184 FC_AUTH_CEXP_DH_GROUP_NOT_USABLE = 0x02,
185 FC_AUTH_CEXP_HASH_FUNC_NOT_USABLE = 0x03,
186 FC_AUTH_CEXP_AUTH_XACT_STARTED = 0x04,
187 FC_AUTH_CEXP_AUTH_FAILED = 0x05,
188 FC_AUTH_CEXP_INCORRECT_PLD = 0x06,
189 FC_AUTH_CEXP_INCORRECT_PROTO_MSG = 0x07,
190 FC_AUTH_CEXP_RESTART_AUTH_PROTO = 0x08,
191 FC_AUTH_CEXP_AUTH_CONCAT_NOT_SUPP = 0x09,
192 FC_AUTH_CEXP_PROTO_VER_NOT_SUPP = 0x0A,
193};
194
195enum auth_status {
196 FC_AUTH_STATE_INPROGRESS = 0, /*! authentication in progress */
197 FC_AUTH_STATE_FAILED = 1, /*! authentication failed */
198 FC_AUTH_STATE_SUCCESS = 2 /*! authentication successful */
199};
200
201struct auth_rjt_msg_s {
202 struct auth_els_msg_s hdr;
203 u8 reason_code;
204 u8 reason_code_exp;
205 u8 rsvd[2];
206};
207
208
209struct auth_dhchap_neg_msg_s {
210 struct auth_els_msg_s hdr;
211 struct auth_neg_msg_s nego;
212};
213
214struct auth_dhchap_reply_msg_s {
215 struct auth_els_msg_s hdr;
216
217 /*
218 * followed by response value length & Value + DH Value Length & Value
219 */
220};
221
222#pragma pack()
223
224#endif /* __FC_SP_H__ */
diff --git a/drivers/scsi/bfa/include/protocol/fcp.h b/drivers/scsi/bfa/include/protocol/fcp.h
deleted file mode 100644
index 74ea63ce84b7..000000000000
--- a/drivers/scsi/bfa/include/protocol/fcp.h
+++ /dev/null
@@ -1,184 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __FCPPROTO_H__
19#define __FCPPROTO_H__
20
21#include <linux/bitops.h>
22#include <protocol/scsi.h>
23
24#pragma pack(1)
25
26enum {
27 FCP_RJT = 0x01000000, /* SRR reject */
28 FCP_SRR_ACCEPT = 0x02000000, /* SRR accept */
29 FCP_SRR = 0x14000000, /* Sequence Retransmission Request */
30};
31
32/*
33 * SRR FC-4 LS payload
34 */
35struct fc_srr_s{
36 u32 ls_cmd;
37 u32 ox_id:16; /* ox-id */
38 u32 rx_id:16; /* rx-id */
39 u32 ro; /* relative offset */
40 u32 r_ctl:8; /* R_CTL for I.U. */
41 u32 res:24;
42};
43
44
45/*
46 * FCP_CMND definitions
47 */
48#define FCP_CMND_CDB_LEN 16
49#define FCP_CMND_LUN_LEN 8
50
51struct fcp_cmnd_s{
52 lun_t lun; /* 64-bit LU number */
53 u8 crn; /* command reference number */
54#ifdef __BIGENDIAN
55 u8 resvd:1,
56 priority:4, /* FCP-3: SAM-3 priority */
57 taskattr:3; /* scsi task attribute */
58#else
59 u8 taskattr:3, /* scsi task attribute */
60 priority:4, /* FCP-3: SAM-3 priority */
61 resvd:1;
62#endif
63 u8 tm_flags; /* task management flags */
64#ifdef __BIGENDIAN
65 u8 addl_cdb_len:6, /* additional CDB length words */
66 iodir:2; /* read/write FCP_DATA IUs */
67#else
68 u8 iodir:2, /* read/write FCP_DATA IUs */
69 addl_cdb_len:6; /* additional CDB length */
70#endif
71 struct scsi_cdb_s cdb;
72
73 /*
74 * !!! additional cdb bytes follows here!!!
75 */
76 u32 fcp_dl; /* bytes to be transferred */
77};
78
79#define fcp_cmnd_cdb_len(_cmnd) ((_cmnd)->addl_cdb_len * 4 + FCP_CMND_CDB_LEN)
80#define fcp_cmnd_fcpdl(_cmnd) ((&(_cmnd)->fcp_dl)[(_cmnd)->addl_cdb_len])
81
82/*
83 * fcp_cmnd_t.iodir field values
84 */
85enum fcp_iodir{
86 FCP_IODIR_NONE = 0,
87 FCP_IODIR_WRITE = 1,
88 FCP_IODIR_READ = 2,
89 FCP_IODIR_RW = 3,
90};
91
92/*
93 * Task attribute field
94 */
95enum {
96 FCP_TASK_ATTR_SIMPLE = 0,
97 FCP_TASK_ATTR_HOQ = 1,
98 FCP_TASK_ATTR_ORDERED = 2,
99 FCP_TASK_ATTR_ACA = 4,
100 FCP_TASK_ATTR_UNTAGGED = 5, /* obsolete in FCP-3 */
101};
102
103/*
104 * Task management flags field - only one bit shall be set
105 */
106enum fcp_tm_cmnd{
107 FCP_TM_ABORT_TASK_SET = BIT(1),
108 FCP_TM_CLEAR_TASK_SET = BIT(2),
109 FCP_TM_LUN_RESET = BIT(4),
110 FCP_TM_TARGET_RESET = BIT(5), /* obsolete in FCP-3 */
111 FCP_TM_CLEAR_ACA = BIT(6),
112};
113
114/*
115 * FCP_XFER_RDY IU defines
116 */
117struct fcp_xfer_rdy_s{
118 u32 data_ro;
119 u32 burst_len;
120 u32 reserved;
121};
122
123/*
124 * FCP_RSP residue flags
125 */
126enum fcp_residue{
127 FCP_NO_RESIDUE = 0, /* no residue */
128 FCP_RESID_OVER = 1, /* more data left that was not sent */
129 FCP_RESID_UNDER = 2, /* less data than requested */
130};
131
132enum {
133 FCP_RSPINFO_GOOD = 0,
134 FCP_RSPINFO_DATALEN_MISMATCH = 1,
135 FCP_RSPINFO_CMND_INVALID = 2,
136 FCP_RSPINFO_ROLEN_MISMATCH = 3,
137 FCP_RSPINFO_TM_NOT_SUPP = 4,
138 FCP_RSPINFO_TM_FAILED = 5,
139};
140
141struct fcp_rspinfo_s{
142 u32 res0:24;
143 u32 rsp_code:8; /* response code (as above) */
144 u32 res1;
145};
146
147struct fcp_resp_s{
148 u32 reserved[2]; /* 2 words reserved */
149 u16 reserved2;
150#ifdef __BIGENDIAN
151 u8 reserved3:3;
152 u8 fcp_conf_req:1; /* FCP_CONF is requested */
153 u8 resid_flags:2; /* underflow/overflow */
154 u8 sns_len_valid:1;/* sense len is valid */
155 u8 rsp_len_valid:1;/* response len is valid */
156#else
157 u8 rsp_len_valid:1;/* response len is valid */
158 u8 sns_len_valid:1;/* sense len is valid */
159 u8 resid_flags:2; /* underflow/overflow */
160 u8 fcp_conf_req:1; /* FCP_CONF is requested */
161 u8 reserved3:3;
162#endif
163 u8 scsi_status; /* one byte SCSI status */
164 u32 residue; /* residual data bytes */
165 u32 sns_len; /* length od sense info */
166 u32 rsp_len; /* length of response info */
167};
168
169#define fcp_snslen(__fcprsp) ((__fcprsp)->sns_len_valid ? \
170 (__fcprsp)->sns_len : 0)
171#define fcp_rsplen(__fcprsp) ((__fcprsp)->rsp_len_valid ? \
172 (__fcprsp)->rsp_len : 0)
173#define fcp_rspinfo(__fcprsp) ((struct fcp_rspinfo_s *)((__fcprsp) + 1))
174#define fcp_snsinfo(__fcprsp) (((u8 *)fcp_rspinfo(__fcprsp)) + \
175 fcp_rsplen(__fcprsp))
176
177struct fcp_cmnd_fr_s{
178 struct fchs_s fchs;
179 struct fcp_cmnd_s fcp;
180};
181
182#pragma pack()
183
184#endif
diff --git a/drivers/scsi/bfa/include/protocol/fdmi.h b/drivers/scsi/bfa/include/protocol/fdmi.h
deleted file mode 100644
index 6c05c268c71b..000000000000
--- a/drivers/scsi/bfa/include/protocol/fdmi.h
+++ /dev/null
@@ -1,163 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __FDMI_H__
19#define __FDMI_H__
20
21#include <protocol/types.h>
22#include <protocol/fc.h>
23#include <protocol/ct.h>
24
25#pragma pack(1)
26
27/*
28 * FDMI Command Codes
29 */
30#define FDMI_GRHL 0x0100
31#define FDMI_GHAT 0x0101
32#define FDMI_GRPL 0x0102
33#define FDMI_GPAT 0x0110
34#define FDMI_RHBA 0x0200
35#define FDMI_RHAT 0x0201
36#define FDMI_RPRT 0x0210
37#define FDMI_RPA 0x0211
38#define FDMI_DHBA 0x0300
39#define FDMI_DPRT 0x0310
40
41/*
42 * FDMI reason codes
43 */
44#define FDMI_NO_ADDITIONAL_EXP 0x00
45#define FDMI_HBA_ALREADY_REG 0x10
46#define FDMI_HBA_ATTRIB_NOT_REG 0x11
47#define FDMI_HBA_ATTRIB_MULTIPLE 0x12
48#define FDMI_HBA_ATTRIB_LENGTH_INVALID 0x13
49#define FDMI_HBA_ATTRIB_NOT_PRESENT 0x14
50#define FDMI_PORT_ORIG_NOT_IN_LIST 0x15
51#define FDMI_PORT_HBA_NOT_IN_LIST 0x16
52#define FDMI_PORT_ATTRIB_NOT_REG 0x20
53#define FDMI_PORT_NOT_REG 0x21
54#define FDMI_PORT_ATTRIB_MULTIPLE 0x22
55#define FDMI_PORT_ATTRIB_LENGTH_INVALID 0x23
56#define FDMI_PORT_ALREADY_REGISTEREED 0x24
57
58/*
59 * FDMI Transmission Speed Mask values
60 */
61#define FDMI_TRANS_SPEED_1G 0x00000001
62#define FDMI_TRANS_SPEED_2G 0x00000002
63#define FDMI_TRANS_SPEED_10G 0x00000004
64#define FDMI_TRANS_SPEED_4G 0x00000008
65#define FDMI_TRANS_SPEED_8G 0x00000010
66#define FDMI_TRANS_SPEED_16G 0x00000020
67#define FDMI_TRANS_SPEED_UNKNOWN 0x00008000
68
69/*
70 * FDMI HBA attribute types
71 */
72enum fdmi_hba_attribute_type {
73 FDMI_HBA_ATTRIB_NODENAME = 1, /* 0x0001 */
74 FDMI_HBA_ATTRIB_MANUFACTURER, /* 0x0002 */
75 FDMI_HBA_ATTRIB_SERIALNUM, /* 0x0003 */
76 FDMI_HBA_ATTRIB_MODEL, /* 0x0004 */
77 FDMI_HBA_ATTRIB_MODEL_DESC, /* 0x0005 */
78 FDMI_HBA_ATTRIB_HW_VERSION, /* 0x0006 */
79 FDMI_HBA_ATTRIB_DRIVER_VERSION, /* 0x0007 */
80 FDMI_HBA_ATTRIB_ROM_VERSION, /* 0x0008 */
81 FDMI_HBA_ATTRIB_FW_VERSION, /* 0x0009 */
82 FDMI_HBA_ATTRIB_OS_NAME, /* 0x000A */
83 FDMI_HBA_ATTRIB_MAX_CT, /* 0x000B */
84
85 FDMI_HBA_ATTRIB_MAX_TYPE
86};
87
88/*
89 * FDMI Port attribute types
90 */
91enum fdmi_port_attribute_type {
92 FDMI_PORT_ATTRIB_FC4_TYPES = 1, /* 0x0001 */
93 FDMI_PORT_ATTRIB_SUPP_SPEED, /* 0x0002 */
94 FDMI_PORT_ATTRIB_PORT_SPEED, /* 0x0003 */
95 FDMI_PORT_ATTRIB_FRAME_SIZE, /* 0x0004 */
96 FDMI_PORT_ATTRIB_DEV_NAME, /* 0x0005 */
97 FDMI_PORT_ATTRIB_HOST_NAME, /* 0x0006 */
98
99 FDMI_PORT_ATTR_MAX_TYPE
100};
101
102/*
103 * FDMI attribute
104 */
105struct fdmi_attr_s {
106 u16 type;
107 u16 len;
108 u8 value[1];
109};
110
111/*
112 * HBA Attribute Block
113 */
114struct fdmi_hba_attr_s {
115 u32 attr_count; /* # of attributes */
116 struct fdmi_attr_s hba_attr; /* n attributes */
117};
118
119/*
120 * Registered Port List
121 */
122struct fdmi_port_list_s {
123 u32 num_ports; /* number Of Port Entries */
124 wwn_t port_entry; /* one or more */
125};
126
127/*
128 * Port Attribute Block
129 */
130struct fdmi_port_attr_s {
131 u32 attr_count; /* # of attributes */
132 struct fdmi_attr_s port_attr; /* n attributes */
133};
134
135/*
136 * FDMI Register HBA Attributes
137 */
138struct fdmi_rhba_s {
139 wwn_t hba_id; /* HBA Identifier */
140 struct fdmi_port_list_s port_list; /* Registered Port List */
141 struct fdmi_hba_attr_s hba_attr_blk; /* HBA attribute block */
142};
143
144/*
145 * FDMI Register Port
146 */
147struct fdmi_rprt_s {
148 wwn_t hba_id; /* HBA Identifier */
149 wwn_t port_name; /* Port wwn */
150 struct fdmi_port_attr_s port_attr_blk; /* Port Attr Block */
151};
152
153/*
154 * FDMI Register Port Attributes
155 */
156struct fdmi_rpa_s {
157 wwn_t port_name; /* port wwn */
158 struct fdmi_port_attr_s port_attr_blk; /* Port Attr Block */
159};
160
161#pragma pack()
162
163#endif
diff --git a/drivers/scsi/bfa/include/protocol/scsi.h b/drivers/scsi/bfa/include/protocol/scsi.h
deleted file mode 100644
index b220e6b4f6e1..000000000000
--- a/drivers/scsi/bfa/include/protocol/scsi.h
+++ /dev/null
@@ -1,1648 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __SCSI_H__
19#define __SCSI_H__
20
21#include <protocol/types.h>
22
23#pragma pack(1)
24
25/*
26 * generic SCSI cdb definition
27 */
28#define SCSI_MAX_CDBLEN 16
29struct scsi_cdb_s{
30 u8 scsi_cdb[SCSI_MAX_CDBLEN];
31};
32
33/*
34 * scsi lun serial number definition
35 */
36#define SCSI_LUN_SN_LEN 32
37struct scsi_lun_sn_s{
38 u8 lun_sn[SCSI_LUN_SN_LEN];
39};
40
41/*
42 * SCSI Direct Access Commands
43 */
44enum {
45 SCSI_OP_TEST_UNIT_READY = 0x00,
46 SCSI_OP_REQUEST_SENSE = 0x03,
47 SCSI_OP_FORMAT_UNIT = 0x04,
48 SCSI_OP_READ6 = 0x08,
49 SCSI_OP_WRITE6 = 0x0A,
50 SCSI_OP_WRITE_FILEMARKS = 0x10,
51 SCSI_OP_INQUIRY = 0x12,
52 SCSI_OP_MODE_SELECT6 = 0x15,
53 SCSI_OP_RESERVE6 = 0x16,
54 SCSI_OP_RELEASE6 = 0x17,
55 SCSI_OP_MODE_SENSE6 = 0x1A,
56 SCSI_OP_START_STOP_UNIT = 0x1B,
57 SCSI_OP_SEND_DIAGNOSTIC = 0x1D,
58 SCSI_OP_READ_CAPACITY = 0x25,
59 SCSI_OP_READ10 = 0x28,
60 SCSI_OP_WRITE10 = 0x2A,
61 SCSI_OP_VERIFY10 = 0x2F,
62 SCSI_OP_READ_DEFECT_DATA = 0x37,
63 SCSI_OP_LOG_SELECT = 0x4C,
64 SCSI_OP_LOG_SENSE = 0x4D,
65 SCSI_OP_MODE_SELECT10 = 0x55,
66 SCSI_OP_RESERVE10 = 0x56,
67 SCSI_OP_RELEASE10 = 0x57,
68 SCSI_OP_MODE_SENSE10 = 0x5A,
69 SCSI_OP_PER_RESERVE_IN = 0x5E,
70 SCSI_OP_PER_RESERVE_OUR = 0x5E,
71 SCSI_OP_READ16 = 0x88,
72 SCSI_OP_WRITE16 = 0x8A,
73 SCSI_OP_VERIFY16 = 0x8F,
74 SCSI_OP_READ_CAPACITY16 = 0x9E,
75 SCSI_OP_REPORT_LUNS = 0xA0,
76 SCSI_OP_READ12 = 0xA8,
77 SCSI_OP_WRITE12 = 0xAA,
78 SCSI_OP_UNDEF = 0xFF,
79};
80
81/*
82 * SCSI START_STOP_UNIT command
83 */
84struct scsi_start_stop_unit_s{
85 u8 opcode;
86#ifdef __BIGENDIAN
87 u8 lun:3;
88 u8 reserved1:4;
89 u8 immed:1;
90#else
91 u8 immed:1;
92 u8 reserved1:4;
93 u8 lun:3;
94#endif
95 u8 reserved2;
96 u8 reserved3;
97#ifdef __BIGENDIAN
98 u8 power_conditions:4;
99 u8 reserved4:2;
100 u8 loEj:1;
101 u8 start:1;
102#else
103 u8 start:1;
104 u8 loEj:1;
105 u8 reserved4:2;
106 u8 power_conditions:4;
107#endif
108 u8 control;
109};
110
111/*
112 * SCSI SEND_DIAGNOSTIC command
113 */
114struct scsi_send_diagnostic_s{
115 u8 opcode;
116#ifdef __BIGENDIAN
117 u8 self_test_code:3;
118 u8 pf:1;
119 u8 reserved1:1;
120 u8 self_test:1;
121 u8 dev_offl:1;
122 u8 unit_offl:1;
123#else
124 u8 unit_offl:1;
125 u8 dev_offl:1;
126 u8 self_test:1;
127 u8 reserved1:1;
128 u8 pf:1;
129 u8 self_test_code:3;
130#endif
131 u8 reserved2;
132
133 u8 param_list_length[2]; /* MSB first */
134 u8 control;
135
136};
137
138/*
139 * SCSI READ10/WRITE10 commands
140 */
141struct scsi_rw10_s{
142 u8 opcode;
143#ifdef __BIGENDIAN
144 u8 lun:3;
145 u8 dpo:1; /* Disable Page Out */
146 u8 fua:1; /* Force Unit Access */
147 u8 reserved1:2;
148 u8 rel_adr:1; /* relative address */
149#else
150 u8 rel_adr:1;
151 u8 reserved1:2;
152 u8 fua:1;
153 u8 dpo:1;
154 u8 lun:3;
155#endif
156 u8 lba0; /* logical block address - MSB */
157 u8 lba1;
158 u8 lba2;
159 u8 lba3; /* LSB */
160 u8 reserved3;
161 u8 xfer_length0; /* transfer length in blocks - MSB */
162 u8 xfer_length1; /* LSB */
163 u8 control;
164};
165
166#define SCSI_CDB10_GET_LBA(cdb) \
167 (((cdb)->lba0 << 24) | ((cdb)->lba1 << 16) | \
168 ((cdb)->lba2 << 8) | (cdb)->lba3)
169
170#define SCSI_CDB10_SET_LBA(cdb, lba) { \
171 (cdb)->lba0 = lba >> 24; \
172 (cdb)->lba1 = (lba >> 16) & 0xFF; \
173 (cdb)->lba2 = (lba >> 8) & 0xFF; \
174 (cdb)->lba3 = lba & 0xFF; \
175}
176
177#define SCSI_CDB10_GET_TL(cdb) \
178 ((cdb)->xfer_length0 << 8 | (cdb)->xfer_length1)
179#define SCSI_CDB10_SET_TL(cdb, tl) { \
180 (cdb)->xfer_length0 = tl >> 8; \
181 (cdb)->xfer_length1 = tl & 0xFF; \
182}
183
184/*
185 * SCSI READ6/WRITE6 commands
186 */
187struct scsi_rw6_s{
188 u8 opcode;
189#ifdef __BIGENDIAN
190 u8 lun:3;
191 u8 lba0:5; /* MSb */
192#else
193 u8 lba0:5; /* MSb */
194 u8 lun:3;
195#endif
196 u8 lba1;
197 u8 lba2; /* LSB */
198 u8 xfer_length;
199 u8 control;
200};
201
202#define SCSI_TAPE_CDB6_GET_TL(cdb) \
203 (((cdb)->tl0 << 16) | ((cdb)->tl1 << 8) | (cdb)->tl2)
204
205#define SCSI_TAPE_CDB6_SET_TL(cdb, tl) { \
206 (cdb)->tl0 = tl >> 16; \
207 (cdb)->tl1 = (tl >> 8) & 0xFF; \
208 (cdb)->tl2 = tl & 0xFF; \
209}
210
211/*
212 * SCSI sequential (TAPE) wrtie command
213 */
214struct scsi_tape_wr_s{
215 u8 opcode;
216#ifdef __BIGENDIAN
217 u8 rsvd:7;
218 u8 fixed:1; /* MSb */
219#else
220 u8 fixed:1; /* MSb */
221 u8 rsvd:7;
222#endif
223 u8 tl0; /* Msb */
224 u8 tl1;
225 u8 tl2; /* Lsb */
226
227 u8 control;
228};
229
230#define SCSI_CDB6_GET_LBA(cdb) \
231 (((cdb)->lba0 << 16) | ((cdb)->lba1 << 8) | (cdb)->lba2)
232
233#define SCSI_CDB6_SET_LBA(cdb, lba) { \
234 (cdb)->lba0 = lba >> 16; \
235 (cdb)->lba1 = (lba >> 8) & 0xFF; \
236 (cdb)->lba2 = lba & 0xFF; \
237}
238
239#define SCSI_CDB6_GET_TL(cdb) ((cdb)->xfer_length)
240#define SCSI_CDB6_SET_TL(cdb, tl) { \
241 (cdb)->xfer_length = tl; \
242}
243
244/*
245 * SCSI sense data format
246 */
247struct scsi_sense_s{
248#ifdef __BIGENDIAN
249 u8 valid:1;
250 u8 rsp_code:7;
251#else
252 u8 rsp_code:7;
253 u8 valid:1;
254#endif
255 u8 seg_num;
256#ifdef __BIGENDIAN
257 u8 file_mark:1;
258 u8 eom:1; /* end of media */
259 u8 ili:1; /* incorrect length indicator */
260 u8 reserved:1;
261 u8 sense_key:4;
262#else
263 u8 sense_key:4;
264 u8 reserved:1;
265 u8 ili:1; /* incorrect length indicator */
266 u8 eom:1; /* end of media */
267 u8 file_mark:1;
268#endif
269 u8 information[4]; /* device-type or command specific info
270 */
271 u8 add_sense_length;
272 /* additional sense length */
273 u8 command_info[4];/* command specific information
274 */
275 u8 asc; /* additional sense code */
276 u8 ascq; /* additional sense code qualifier */
277 u8 fru_code; /* field replaceable unit code */
278#ifdef __BIGENDIAN
279 u8 sksv:1; /* sense key specific valid */
280 u8 c_d:1; /* command/data bit */
281 u8 res1:2;
282 u8 bpv:1; /* bit pointer valid */
283 u8 bpointer:3; /* bit pointer */
284#else
285 u8 bpointer:3; /* bit pointer */
286 u8 bpv:1; /* bit pointer valid */
287 u8 res1:2;
288 u8 c_d:1; /* command/data bit */
289 u8 sksv:1; /* sense key specific valid */
290#endif
291 u8 fpointer[2]; /* field pointer */
292};
293
294#define SCSI_SENSE_CUR_ERR 0x70
295#define SCSI_SENSE_DEF_ERR 0x71
296
297/*
298 * SCSI sense key values
299 */
300#define SCSI_SK_NO_SENSE 0x0
301#define SCSI_SK_REC_ERR 0x1 /* recovered error */
302#define SCSI_SK_NOT_READY 0x2
303#define SCSI_SK_MED_ERR 0x3 /* medium error */
304#define SCSI_SK_HW_ERR 0x4 /* hardware error */
305#define SCSI_SK_ILLEGAL_REQ 0x5
306#define SCSI_SK_UNIT_ATT 0x6 /* unit attention */
307#define SCSI_SK_DATA_PROTECT 0x7
308#define SCSI_SK_BLANK_CHECK 0x8
309#define SCSI_SK_VENDOR_SPEC 0x9
310#define SCSI_SK_COPY_ABORTED 0xA
311#define SCSI_SK_ABORTED_CMND 0xB
312#define SCSI_SK_VOL_OVERFLOW 0xD
313#define SCSI_SK_MISCOMPARE 0xE
314
315/*
316 * SCSI additional sense codes
317 */
318#define SCSI_ASC_NO_ADD_SENSE 0x00
319#define SCSI_ASC_LUN_NOT_READY 0x04
320#define SCSI_ASC_LUN_COMMUNICATION 0x08
321#define SCSI_ASC_WRITE_ERROR 0x0C
322#define SCSI_ASC_INVALID_CMND_CODE 0x20
323#define SCSI_ASC_BAD_LBA 0x21
324#define SCSI_ASC_INVALID_FIELD_IN_CDB 0x24
325#define SCSI_ASC_LUN_NOT_SUPPORTED 0x25
326#define SCSI_ASC_LUN_WRITE_PROTECT 0x27
327#define SCSI_ASC_POWERON_BDR 0x29 /* power on reset, bus reset,
328 * bus device reset
329 */
330#define SCSI_ASC_PARAMS_CHANGED 0x2A
331#define SCSI_ASC_CMND_CLEARED_BY_A_I 0x2F
332#define SCSI_ASC_SAVING_PARAM_NOTSUPP 0x39
333#define SCSI_ASC_TOCC 0x3F /* target operating condtions
334 * changed
335 */
336#define SCSI_ASC_PARITY_ERROR 0x47
337#define SCSI_ASC_CMND_PHASE_ERROR 0x4A
338#define SCSI_ASC_DATA_PHASE_ERROR 0x4B
339#define SCSI_ASC_VENDOR_SPEC 0x7F
340
341/*
342 * SCSI additional sense code qualifiers
343 */
344#define SCSI_ASCQ_CAUSE_NOT_REPORT 0x00
345#define SCSI_ASCQ_BECOMING_READY 0x01
346#define SCSI_ASCQ_INIT_CMD_REQ 0x02
347#define SCSI_ASCQ_FORMAT_IN_PROGRESS 0x04
348#define SCSI_ASCQ_OPERATION_IN_PROGRESS 0x07
349#define SCSI_ASCQ_SELF_TEST_IN_PROGRESS 0x09
350#define SCSI_ASCQ_WR_UNEXP_UNSOL_DATA 0x0C
351#define SCSI_ASCQ_WR_NOTENG_UNSOL_DATA 0x0D
352
353#define SCSI_ASCQ_LBA_OUT_OF_RANGE 0x00
354#define SCSI_ASCQ_INVALID_ELEMENT_ADDR 0x01
355
356#define SCSI_ASCQ_LUN_WRITE_PROTECTED 0x00
357#define SCSI_ASCQ_LUN_HW_WRITE_PROTECTED 0x01
358#define SCSI_ASCQ_LUN_SW_WRITE_PROTECTED 0x02
359
360#define SCSI_ASCQ_POR 0x01 /* power on reset */
361#define SCSI_ASCQ_SBR 0x02 /* scsi bus reset */
362#define SCSI_ASCQ_BDR 0x03 /* bus device reset */
363#define SCSI_ASCQ_DIR 0x04 /* device internal reset */
364
365#define SCSI_ASCQ_MODE_PARAMS_CHANGED 0x01
366#define SCSI_ASCQ_LOG_PARAMS_CHANGED 0x02
367#define SCSI_ASCQ_RESERVATIONS_PREEMPTED 0x03
368#define SCSI_ASCQ_RESERVATIONS_RELEASED 0x04
369#define SCSI_ASCQ_REGISTRATIONS_PREEMPTED 0x05
370
371#define SCSI_ASCQ_MICROCODE_CHANGED 0x01
372#define SCSI_ASCQ_CHANGED_OPER_COND 0x02
373#define SCSI_ASCQ_INQ_CHANGED 0x03 /* inquiry data changed */
374#define SCSI_ASCQ_DI_CHANGED 0x05 /* device id changed */
375#define SCSI_ASCQ_RL_DATA_CHANGED 0x0E /* report luns data changed */
376
377#define SCSI_ASCQ_DP_CRC_ERR 0x01 /* data phase crc error */
378#define SCSI_ASCQ_DP_SCSI_PARITY_ERR 0x02 /* data phase scsi parity error
379 */
380#define SCSI_ASCQ_IU_CRC_ERR 0x03 /* information unit crc error */
381#define SCSI_ASCQ_PROTO_SERV_CRC_ERR 0x05
382
383#define SCSI_ASCQ_LUN_TIME_OUT 0x01
384
385/* ------------------------------------------------------------
386 * SCSI INQUIRY
387 * ------------------------------------------------------------*/
388
389struct scsi_inquiry_s{
390 u8 opcode;
391#ifdef __BIGENDIAN
392 u8 lun:3;
393 u8 reserved1:3;
394 u8 cmd_dt:1;
395 u8 evpd:1;
396#else
397 u8 evpd:1;
398 u8 cmd_dt:1;
399 u8 reserved1:3;
400 u8 lun:3;
401#endif
402 u8 page_code;
403 u8 reserved2;
404 u8 alloc_length;
405 u8 control;
406};
407
408struct scsi_inquiry_vendor_s{
409 u8 vendor_id[8];
410};
411
412struct scsi_inquiry_prodid_s{
413 u8 product_id[16];
414};
415
416struct scsi_inquiry_prodrev_s{
417 u8 product_rev[4];
418};
419
420struct scsi_inquiry_data_s{
421#ifdef __BIGENDIAN
422 u8 peripheral_qual:3; /* peripheral qualifier */
423 u8 device_type:5; /* peripheral device type */
424
425 u8 rmb:1; /* removable medium bit */
426 u8 device_type_mod:7; /* device type modifier */
427
428 u8 version;
429
430 u8 aenc:1; /* async event notification capability
431 */
432 u8 trm_iop:1; /* terminate I/O process */
433 u8 norm_aca:1; /* normal ACA supported */
434 u8 hi_support:1; /* SCSI-3: supports REPORT LUNS */
435 u8 rsp_data_format:4;
436
437 u8 additional_len;
438 u8 sccs:1;
439 u8 reserved1:7;
440
441 u8 reserved2:1;
442 u8 enc_serv:1; /* enclosure service component */
443 u8 reserved3:1;
444 u8 multi_port:1; /* multi-port device */
445 u8 m_chngr:1; /* device in medium transport element */
446 u8 ack_req_q:1; /* SIP specific bit */
447 u8 addr32:1; /* SIP specific bit */
448 u8 addr16:1; /* SIP specific bit */
449
450 u8 rel_adr:1; /* relative address */
451 u8 w_bus32:1;
452 u8 w_bus16:1;
453 u8 synchronous:1;
454 u8 linked_commands:1;
455 u8 trans_dis:1;
456 u8 cmd_queue:1; /* command queueing supported */
457 u8 soft_reset:1; /* soft reset alternative (VS) */
458#else
459 u8 device_type:5; /* peripheral device type */
460 u8 peripheral_qual:3;
461 /* peripheral qualifier */
462
463 u8 device_type_mod:7;
464 /* device type modifier */
465 u8 rmb:1; /* removable medium bit */
466
467 u8 version;
468
469 u8 rsp_data_format:4;
470 u8 hi_support:1; /* SCSI-3: supports REPORT LUNS */
471 u8 norm_aca:1; /* normal ACA supported */
472 u8 terminate_iop:1;/* terminate I/O process */
473 u8 aenc:1; /* async event notification capability
474 */
475
476 u8 additional_len;
477 u8 reserved1:7;
478 u8 sccs:1;
479
480 u8 addr16:1; /* SIP specific bit */
481 u8 addr32:1; /* SIP specific bit */
482 u8 ack_req_q:1; /* SIP specific bit */
483 u8 m_chngr:1; /* device in medium transport element */
484 u8 multi_port:1; /* multi-port device */
485 u8 reserved3:1; /* TBD - Vendor Specific */
486 u8 enc_serv:1; /* enclosure service component */
487 u8 reserved2:1;
488
489 u8 soft_seset:1; /* soft reset alternative (VS) */
490 u8 cmd_queue:1; /* command queueing supported */
491 u8 trans_dis:1;
492 u8 linked_commands:1;
493 u8 synchronous:1;
494 u8 w_bus16:1;
495 u8 w_bus32:1;
496 u8 rel_adr:1; /* relative address */
497#endif
498 struct scsi_inquiry_vendor_s vendor_id;
499 struct scsi_inquiry_prodid_s product_id;
500 struct scsi_inquiry_prodrev_s product_rev;
501 u8 vendor_specific[20];
502 u8 reserved4[40];
503};
504
505/*
506 * inquiry.peripheral_qual field values
507 */
508#define SCSI_DEVQUAL_DEFAULT 0
509#define SCSI_DEVQUAL_NOT_CONNECTED 1
510#define SCSI_DEVQUAL_NOT_SUPPORTED 3
511
512/*
513 * inquiry.device_type field values
514 */
515#define SCSI_DEVICE_DIRECT_ACCESS 0x00
516#define SCSI_DEVICE_SEQ_ACCESS 0x01
517#define SCSI_DEVICE_ARRAY_CONTROLLER 0x0C
518#define SCSI_DEVICE_UNKNOWN 0x1F
519
520/*
521 * inquiry.version
522 */
523#define SCSI_VERSION_ANSI_X3131 2 /* ANSI X3.131 SCSI-2 */
524#define SCSI_VERSION_SPC 3 /* SPC (SCSI-3), ANSI X3.301:1997 */
525#define SCSI_VERSION_SPC_2 4 /* SPC-2 */
526
527/*
528 * response data format
529 */
530#define SCSI_RSP_DATA_FORMAT 2 /* SCSI-2 & SPC */
531
532/*
533 * SCSI inquiry page codes
534 */
535#define SCSI_INQ_PAGE_VPD_PAGES 0x00 /* supported vpd pages */
536#define SCSI_INQ_PAGE_USN_PAGE 0x80 /* unit serial number page */
537#define SCSI_INQ_PAGE_DEV_IDENT 0x83 /* device indentification page
538 */
539#define SCSI_INQ_PAGES_MAX 3
540
541/*
542 * supported vital product data pages
543 */
544struct scsi_inq_page_vpd_pages_s{
545#ifdef __BIGENDIAN
546 u8 peripheral_qual:3;
547 u8 device_type:5;
548#else
549 u8 device_type:5;
550 u8 peripheral_qual:3;
551#endif
552 u8 page_code;
553 u8 reserved;
554 u8 page_length;
555 u8 pages[SCSI_INQ_PAGES_MAX];
556};
557
558/*
559 * Unit serial number page
560 */
561#define SCSI_INQ_USN_LEN 32
562
563struct scsi_inq_usn_s{
564 char usn[SCSI_INQ_USN_LEN];
565};
566
567struct scsi_inq_page_usn_s{
568#ifdef __BIGENDIAN
569 u8 peripheral_qual:3;
570 u8 device_type:5;
571#else
572 u8 device_type:5;
573 u8 peripheral_qual:3;
574#endif
575 u8 page_code;
576 u8 reserved1;
577 u8 page_length;
578 struct scsi_inq_usn_s usn;
579};
580
581enum {
582 SCSI_INQ_DIP_CODE_BINARY = 1, /* identifier has binary value */
583 SCSI_INQ_DIP_CODE_ASCII = 2, /* identifier has ascii value */
584};
585
586enum {
587 SCSI_INQ_DIP_ASSOC_LUN = 0, /* id is associated with device */
588 SCSI_INQ_DIP_ASSOC_PORT = 1, /* id is associated with port that
589 * received the request
590 */
591};
592
593enum {
594 SCSI_INQ_ID_TYPE_VENDOR = 1,
595 SCSI_INQ_ID_TYPE_IEEE = 2,
596 SCSI_INQ_ID_TYPE_FC_FS = 3,
597 SCSI_INQ_ID_TYPE_OTHER = 4,
598};
599
600struct scsi_inq_dip_desc_s{
601#ifdef __BIGENDIAN
602 u8 res0:4;
603 u8 code_set:4;
604 u8 res1:2;
605 u8 association:2;
606 u8 id_type:4;
607#else
608 u8 code_set:4;
609 u8 res0:4;
610 u8 id_type:4;
611 u8 association:2;
612 u8 res1:2;
613#endif
614 u8 res2;
615 u8 id_len;
616 struct scsi_lun_sn_s id;
617};
618
619/*
620 * Device indentification page
621 */
622struct scsi_inq_page_dev_ident_s{
623#ifdef __BIGENDIAN
624 u8 peripheral_qual:3;
625 u8 device_type:5;
626#else
627 u8 device_type:5;
628 u8 peripheral_qual:3;
629#endif
630 u8 page_code;
631 u8 reserved1;
632 u8 page_length;
633 struct scsi_inq_dip_desc_s desc;
634};
635
636/* ------------------------------------------------------------
637 * READ CAPACITY
638 * ------------------------------------------------------------
639 */
640
641struct scsi_read_capacity_s{
642 u8 opcode;
643#ifdef __BIGENDIAN
644 u8 lun:3;
645 u8 reserved1:4;
646 u8 rel_adr:1;
647#else
648 u8 rel_adr:1;
649 u8 reserved1:4;
650 u8 lun:3;
651#endif
652 u8 lba0; /* MSB */
653 u8 lba1;
654 u8 lba2;
655 u8 lba3; /* LSB */
656 u8 reserved2;
657 u8 reserved3;
658#ifdef __BIGENDIAN
659 u8 reserved4:7;
660 u8 pmi:1; /* partial medium indicator */
661#else
662 u8 pmi:1; /* partial medium indicator */
663 u8 reserved4:7;
664#endif
665 u8 control;
666};
667
668struct scsi_read_capacity_data_s{
669 u32 max_lba; /* maximum LBA available */
670 u32 block_length; /* in bytes */
671};
672
673struct scsi_read_capacity16_data_s{
674 u64 lba; /* maximum LBA available */
675 u32 block_length; /* in bytes */
676#ifdef __BIGENDIAN
677 u8 reserved1:4,
678 p_type:3,
679 prot_en:1;
680 u8 reserved2:4,
681 lb_pbe:4; /* logical blocks per physical block
682 * exponent */
683 u16 reserved3:2,
684 lba_align:14; /* lowest aligned logical block
685 * address */
686#else
687 u16 lba_align:14, /* lowest aligned logical block
688 * address */
689 reserved3:2;
690 u8 lb_pbe:4, /* logical blocks per physical block
691 * exponent */
692 reserved2:4;
693 u8 prot_en:1,
694 p_type:3,
695 reserved1:4;
696#endif
697 u64 reserved4;
698 u64 reserved5;
699};
700
701/* ------------------------------------------------------------
702 * REPORT LUNS command
703 * ------------------------------------------------------------
704 */
705
706struct scsi_report_luns_s{
707 u8 opcode; /* A0h - REPORT LUNS opCode */
708 u8 reserved1[5];
709 u8 alloc_length[4];/* allocation length MSB first */
710 u8 reserved2;
711 u8 control;
712};
713
714#define SCSI_REPORT_LUN_ALLOC_LENGTH(rl) \
715 ((rl->alloc_length[0] << 24) | (rl->alloc_length[1] << 16) | \
716 (rl->alloc_length[2] << 8) | (rl->alloc_length[3]))
717
718#define SCSI_REPORT_LUNS_SET_ALLOCLEN(rl, alloc_len) { \
719 (rl)->alloc_length[0] = (alloc_len) >> 24; \
720 (rl)->alloc_length[1] = ((alloc_len) >> 16) & 0xFF; \
721 (rl)->alloc_length[2] = ((alloc_len) >> 8) & 0xFF; \
722 (rl)->alloc_length[3] = (alloc_len) & 0xFF; \
723}
724
725struct scsi_report_luns_data_s{
726 u32 lun_list_length; /* length of LUN list length */
727 u32 reserved;
728 lun_t lun[1]; /* first LUN in lun list */
729};
730
731/* -------------------------------------------------------------
732 * SCSI mode parameters
733 * -----------------------------------------------------------
734 */
735enum {
736 SCSI_DA_MEDIUM_DEF = 0, /* direct access default medium type */
737 SCSI_DA_MEDIUM_SS = 1, /* direct access single sided */
738 SCSI_DA_MEDIUM_DS = 2, /* direct access double sided */
739};
740
741/*
742 * SCSI Mode Select(6) cdb
743 */
744struct scsi_mode_select6_s{
745 u8 opcode;
746#ifdef __BIGENDIAN
747 u8 reserved1:3;
748 u8 pf:1; /* page format */
749 u8 reserved2:3;
750 u8 sp:1; /* save pages if set to 1 */
751#else
752 u8 sp:1; /* save pages if set to 1 */
753 u8 reserved2:3;
754 u8 pf:1; /* page format */
755 u8 reserved1:3;
756#endif
757 u8 reserved3[2];
758 u8 alloc_len;
759 u8 control;
760};
761
762/*
763 * SCSI Mode Select(10) cdb
764 */
765struct scsi_mode_select10_s{
766 u8 opcode;
767#ifdef __BIGENDIAN
768 u8 reserved1:3;
769 u8 pf:1; /* page format */
770 u8 reserved2:3;
771 u8 sp:1; /* save pages if set to 1 */
772#else
773 u8 sp:1; /* save pages if set to 1 */
774 u8 reserved2:3;
775 u8 pf:1; /* page format */
776 u8 reserved1:3;
777#endif
778 u8 reserved3[5];
779 u8 alloc_len_msb;
780 u8 alloc_len_lsb;
781 u8 control;
782};
783
784/*
785 * SCSI Mode Sense(6) cdb
786 */
787struct scsi_mode_sense6_s{
788 u8 opcode;
789#ifdef __BIGENDIAN
790 u8 reserved1:4;
791 u8 dbd:1; /* disable block discriptors if set to 1 */
792 u8 reserved2:3;
793
794 u8 pc:2; /* page control */
795 u8 page_code:6;
796#else
797 u8 reserved2:3;
798 u8 dbd:1; /* disable block descriptors if set to 1 */
799 u8 reserved1:4;
800
801 u8 page_code:6;
802 u8 pc:2; /* page control */
803#endif
804 u8 reserved3;
805 u8 alloc_len;
806 u8 control;
807};
808
809/*
810 * SCSI Mode Sense(10) cdb
811 */
812struct scsi_mode_sense10_s{
813 u8 opcode;
814#ifdef __BIGENDIAN
815 u8 reserved1:3;
816 u8 LLBAA:1; /* long LBA accepted if set to 1 */
817 u8 dbd:1; /* disable block descriptors if set
818 * to 1
819 */
820 u8 reserved2:3;
821
822 u8 pc:2; /* page control */
823 u8 page_code:6;
824#else
825 u8 reserved2:3;
826 u8 dbd:1; /* disable block descriptors if set to
827 * 1
828 */
829 u8 LLBAA:1; /* long LBA accepted if set to 1 */
830 u8 reserved1:3;
831
832 u8 page_code:6;
833 u8 pc:2; /* page control */
834#endif
835 u8 reserved3[4];
836 u8 alloc_len_msb;
837 u8 alloc_len_lsb;
838 u8 control;
839};
840
841#define SCSI_CDB10_GET_AL(cdb) \
842 ((cdb)->alloc_len_msb << 8 | (cdb)->alloc_len_lsb)
843
844#define SCSI_CDB10_SET_AL(cdb, al) { \
845 (cdb)->alloc_len_msb = al >> 8; \
846 (cdb)->alloc_len_lsb = al & 0xFF; \
847}
848
849#define SCSI_CDB6_GET_AL(cdb) ((cdb)->alloc_len)
850
851#define SCSI_CDB6_SET_AL(cdb, al) { \
852 (cdb)->alloc_len = al; \
853}
854
855/*
856 * page control field values
857 */
858#define SCSI_PC_CURRENT_VALUES 0x0
859#define SCSI_PC_CHANGEABLE_VALUES 0x1
860#define SCSI_PC_DEFAULT_VALUES 0x2
861#define SCSI_PC_SAVED_VALUES 0x3
862
863/*
864 * SCSI mode page codes
865 */
866#define SCSI_MP_VENDOR_SPEC 0x00
867#define SCSI_MP_DISC_RECN 0x02 /* disconnect-reconnect page */
868#define SCSI_MP_FORMAT_DEVICE 0x03
869#define SCSI_MP_RDG 0x04 /* rigid disk geometry page */
870#define SCSI_MP_FDP 0x05 /* flexible disk page */
871#define SCSI_MP_CACHING 0x08 /* caching page */
872#define SCSI_MP_CONTROL 0x0A /* control mode page */
873#define SCSI_MP_MED_TYPES_SUP 0x0B /* medium types supported page */
874#define SCSI_MP_INFO_EXCP_CNTL 0x1C /* informational exception control */
875#define SCSI_MP_ALL 0x3F /* return all pages - mode sense only */
876
877/*
878 * mode parameter header
879 */
880struct scsi_mode_param_header6_s{
881 u8 mode_datalen;
882 u8 medium_type;
883
884 /*
885 * device specific parameters expanded for direct access devices
886 */
887#ifdef __BIGENDIAN
888 u32 wp:1; /* write protected */
889 u32 reserved1:2;
890 u32 dpofua:1; /* disable page out + force unit access
891 */
892 u32 reserved2:4;
893#else
894 u32 reserved2:4;
895 u32 dpofua:1; /* disable page out + force unit access
896 */
897 u32 reserved1:2;
898 u32 wp:1; /* write protected */
899#endif
900
901 u8 block_desclen;
902};
903
904struct scsi_mode_param_header10_s{
905 u32 mode_datalen:16;
906 u32 medium_type:8;
907
908 /*
909 * device specific parameters expanded for direct access devices
910 */
911#ifdef __BIGENDIAN
912 u32 wp:1; /* write protected */
913 u32 reserved1:2;
914 u32 dpofua:1; /* disable page out + force unit access
915 */
916 u32 reserved2:4;
917#else
918 u32 reserved2:4;
919 u32 dpofua:1; /* disable page out + force unit access
920 */
921 u32 reserved1:2;
922 u32 wp:1; /* write protected */
923#endif
924
925#ifdef __BIGENDIAN
926 u32 reserved3:7;
927 u32 longlba:1;
928#else
929 u32 longlba:1;
930 u32 reserved3:7;
931#endif
932 u32 reserved4:8;
933 u32 block_desclen:16;
934};
935
936/*
937 * mode parameter block descriptor
938 */
939struct scsi_mode_param_desc_s{
940 u32 nblks;
941 u32 density_code:8;
942 u32 block_length:24;
943};
944
945/*
946 * Disconnect-reconnect mode page format
947 */
948struct scsi_mp_disc_recn_s{
949#ifdef __BIGENDIAN
950 u8 ps:1;
951 u8 reserved1:1;
952 u8 page_code:6;
953#else
954 u8 page_code:6;
955 u8 reserved1:1;
956 u8 ps:1;
957#endif
958 u8 page_len;
959 u8 buf_full_ratio;
960 u8 buf_empty_ratio;
961
962 u8 bil_msb; /* bus inactivity limit -MSB */
963 u8 bil_lsb; /* bus inactivity limit -LSB */
964
965 u8 dtl_msb; /* disconnect time limit - MSB */
966 u8 dtl_lsb; /* disconnect time limit - LSB */
967
968 u8 ctl_msb; /* connect time limit - MSB */
969 u8 ctl_lsb; /* connect time limit - LSB */
970
971 u8 max_burst_len_msb;
972 u8 max_burst_len_lsb;
973#ifdef __BIGENDIAN
974 u8 emdp:1; /* enable modify data pointers */
975 u8 fa:3; /* fair arbitration */
976 u8 dimm:1; /* disconnect immediate */
977 u8 dtdc:3; /* data transfer disconnect control */
978#else
979 u8 dtdc:3; /* data transfer disconnect control */
980 u8 dimm:1; /* disconnect immediate */
981 u8 fa:3; /* fair arbitration */
982 u8 emdp:1; /* enable modify data pointers */
983#endif
984
985 u8 reserved3;
986
987 u8 first_burst_len_msb;
988 u8 first_burst_len_lsb;
989};
990
991/*
992 * SCSI format device mode page
993 */
994struct scsi_mp_format_device_s{
995#ifdef __BIGENDIAN
996 u32 ps:1;
997 u32 reserved1:1;
998 u32 page_code:6;
999#else
1000 u32 page_code:6;
1001 u32 reserved1:1;
1002 u32 ps:1;
1003#endif
1004 u32 page_len:8;
1005 u32 tracks_per_zone:16;
1006
1007 u32 a_sec_per_zone:16;
1008 u32 a_tracks_per_zone:16;
1009
1010 u32 a_tracks_per_lun:16; /* alternate tracks/lun-MSB */
1011 u32 sec_per_track:16; /* sectors/track-MSB */
1012
1013 u32 bytes_per_sector:16;
1014 u32 interleave:16;
1015
1016 u32 tsf:16; /* track skew factor-MSB */
1017 u32 csf:16; /* cylinder skew factor-MSB */
1018
1019#ifdef __BIGENDIAN
1020 u32 ssec:1; /* soft sector formatting */
1021 u32 hsec:1; /* hard sector formatting */
1022 u32 rmb:1; /* removable media */
1023 u32 surf:1; /* surface */
1024 u32 reserved2:4;
1025#else
1026 u32 reserved2:4;
1027 u32 surf:1; /* surface */
1028 u32 rmb:1; /* removable media */
1029 u32 hsec:1; /* hard sector formatting */
1030 u32 ssec:1; /* soft sector formatting */
1031#endif
1032 u32 reserved3:24;
1033};
1034
1035/*
1036 * SCSI rigid disk device geometry page
1037 */
1038struct scsi_mp_rigid_device_geometry_s{
1039#ifdef __BIGENDIAN
1040 u32 ps:1;
1041 u32 reserved1:1;
1042 u32 page_code:6;
1043#else
1044 u32 page_code:6;
1045 u32 reserved1:1;
1046 u32 ps:1;
1047#endif
1048 u32 page_len:8;
1049 u32 num_cylinders0:8;
1050 u32 num_cylinders1:8;
1051
1052 u32 num_cylinders2:8;
1053 u32 num_heads:8;
1054 u32 scwp0:8;
1055 u32 scwp1:8;
1056
1057 u32 scwp2:8;
1058 u32 scrwc0:8;
1059 u32 scrwc1:8;
1060 u32 scrwc2:8;
1061
1062 u32 dsr:16;
1063 u32 lscyl0:8;
1064 u32 lscyl1:8;
1065
1066 u32 lscyl2:8;
1067#ifdef __BIGENDIAN
1068 u32 reserved2:6;
1069 u32 rpl:2; /* rotational position locking */
1070#else
1071 u32 rpl:2; /* rotational position locking */
1072 u32 reserved2:6;
1073#endif
1074 u32 rot_off:8;
1075 u32 reserved3:8;
1076
1077 u32 med_rot_rate:16;
1078 u32 reserved4:16;
1079};
1080
1081/*
1082 * SCSI caching mode page
1083 */
1084struct scsi_mp_caching_s{
1085#ifdef __BIGENDIAN
1086 u8 ps:1;
1087 u8 res1:1;
1088 u8 page_code:6;
1089#else
1090 u8 page_code:6;
1091 u8 res1:1;
1092 u8 ps:1;
1093#endif
1094 u8 page_len;
1095#ifdef __BIGENDIAN
1096 u8 ic:1; /* initiator control */
1097 u8 abpf:1; /* abort pre-fetch */
1098 u8 cap:1; /* caching analysis permitted */
1099 u8 disc:1; /* discontinuity */
1100 u8 size:1; /* size enable */
1101 u8 wce:1; /* write cache enable */
1102 u8 mf:1; /* multiplication factor */
1103 u8 rcd:1; /* read cache disable */
1104
1105 u8 drrp:4; /* demand read retention priority */
1106 u8 wrp:4; /* write retention priority */
1107#else
1108 u8 rcd:1; /* read cache disable */
1109 u8 mf:1; /* multiplication factor */
1110 u8 wce:1; /* write cache enable */
1111 u8 size:1; /* size enable */
1112 u8 disc:1; /* discontinuity */
1113 u8 cap:1; /* caching analysis permitted */
1114 u8 abpf:1; /* abort pre-fetch */
1115 u8 ic:1; /* initiator control */
1116
1117 u8 wrp:4; /* write retention priority */
1118 u8 drrp:4; /* demand read retention priority */
1119#endif
1120 u8 dptl[2];/* disable pre-fetch transfer length */
1121 u8 min_prefetch[2];
1122 u8 max_prefetch[2];
1123 u8 max_prefetch_limit[2];
1124#ifdef __BIGENDIAN
1125 u8 fsw:1; /* force sequential write */
1126 u8 lbcss:1;/* logical block cache segment size */
1127 u8 dra:1; /* disable read ahead */
1128 u8 vs:2; /* vendor specific */
1129 u8 res2:3;
1130#else
1131 u8 res2:3;
1132 u8 vs:2; /* vendor specific */
1133 u8 dra:1; /* disable read ahead */
1134 u8 lbcss:1;/* logical block cache segment size */
1135 u8 fsw:1; /* force sequential write */
1136#endif
1137 u8 num_cache_segs;
1138
1139 u8 cache_seg_size[2];
1140 u8 res3;
1141 u8 non_cache_seg_size[3];
1142};
1143
1144/*
1145 * SCSI control mode page
1146 */
1147struct scsi_mp_control_page_s{
1148#ifdef __BIGENDIAN
1149u8 ps:1;
1150u8 reserved1:1;
1151u8 page_code:6;
1152#else
1153u8 page_code:6;
1154u8 reserved1:1;
1155u8 ps:1;
1156#endif
1157 u8 page_len;
1158#ifdef __BIGENDIAN
1159 u8 tst:3; /* task set type */
1160 u8 reserved3:3;
1161 u8 gltsd:1; /* global logging target save disable */
1162 u8 rlec:1; /* report log exception condition */
1163
1164 u8 qalgo_mod:4; /* queue alogorithm modifier */
1165 u8 reserved4:1;
1166 u8 qerr:2; /* queue error management */
1167 u8 dque:1; /* disable queuing */
1168
1169 u8 reserved5:1;
1170 u8 rac:1; /* report a check */
1171 u8 reserved6:2;
1172 u8 swp:1; /* software write protect */
1173 u8 raerp:1; /* ready AER permission */
1174 u8 uaaerp:1; /* unit attenstion AER permission */
1175 u8 eaerp:1; /* error AER permission */
1176
1177 u8 reserved7:5;
1178 u8 autoload_mod:3;
1179#else
1180 u8 rlec:1; /* report log exception condition */
1181 u8 gltsd:1; /* global logging target save disable */
1182 u8 reserved3:3;
1183 u8 tst:3; /* task set type */
1184
1185 u8 dque:1; /* disable queuing */
1186 u8 qerr:2; /* queue error management */
1187 u8 reserved4:1;
1188 u8 qalgo_mod:4; /* queue alogorithm modifier */
1189
1190 u8 eaerp:1; /* error AER permission */
1191 u8 uaaerp:1; /* unit attenstion AER permission */
1192 u8 raerp:1; /* ready AER permission */
1193 u8 swp:1; /* software write protect */
1194 u8 reserved6:2;
1195 u8 rac:1; /* report a check */
1196 u8 reserved5:1;
1197
1198 u8 autoload_mod:3;
1199 u8 reserved7:5;
1200#endif
1201 u8 rahp_msb; /* ready AER holdoff period - MSB */
1202 u8 rahp_lsb; /* ready AER holdoff period - LSB */
1203
1204 u8 busy_timeout_period_msb;
1205 u8 busy_timeout_period_lsb;
1206
1207 u8 ext_selftest_compl_time_msb;
1208 u8 ext_selftest_compl_time_lsb;
1209};
1210
1211/*
1212 * SCSI medium types supported mode page
1213 */
1214struct scsi_mp_medium_types_sup_s{
1215#ifdef __BIGENDIAN
1216 u8 ps:1;
1217 u8 reserved1:1;
1218 u8 page_code:6;
1219#else
1220 u8 page_code:6;
1221 u8 reserved1:1;
1222 u8 ps:1;
1223#endif
1224 u8 page_len;
1225
1226 u8 reserved3[2];
1227 u8 med_type1_sup; /* medium type one supported */
1228 u8 med_type2_sup; /* medium type two supported */
1229 u8 med_type3_sup; /* medium type three supported */
1230 u8 med_type4_sup; /* medium type four supported */
1231};
1232
1233/*
1234 * SCSI informational exception control mode page
1235 */
1236struct scsi_mp_info_excpt_cntl_s{
1237#ifdef __BIGENDIAN
1238 u8 ps:1;
1239 u8 reserved1:1;
1240 u8 page_code:6;
1241#else
1242 u8 page_code:6;
1243 u8 reserved1:1;
1244 u8 ps:1;
1245#endif
1246 u8 page_len;
1247#ifdef __BIGENDIAN
1248 u8 perf:1; /* performance */
1249 u8 reserved3:1;
1250 u8 ebf:1; /* enable background fucntion */
1251 u8 ewasc:1; /* enable warning */
1252 u8 dexcpt:1; /* disable exception control */
1253 u8 test:1; /* enable test device failure
1254 * notification
1255 */
1256 u8 reserved4:1;
1257 u8 log_error:1;
1258
1259 u8 reserved5:4;
1260 u8 mrie:4; /* method of reporting info
1261 * exceptions
1262 */
1263#else
1264 u8 log_error:1;
1265 u8 reserved4:1;
1266 u8 test:1; /* enable test device failure
1267 * notification
1268 */
1269 u8 dexcpt:1; /* disable exception control */
1270 u8 ewasc:1; /* enable warning */
1271 u8 ebf:1; /* enable background fucntion */
1272 u8 reserved3:1;
1273 u8 perf:1; /* performance */
1274
1275 u8 mrie:4; /* method of reporting info
1276 * exceptions
1277 */
1278 u8 reserved5:4;
1279#endif
1280 u8 interval_timer_msb;
1281 u8 interval_timer_lsb;
1282
1283 u8 report_count_msb;
1284 u8 report_count_lsb;
1285};
1286
1287/*
1288 * Methods of reporting informational exceptions
1289 */
1290#define SCSI_MP_IEC_NO_REPORT 0x0 /* no reporting of exceptions */
1291#define SCSI_MP_IEC_AER 0x1 /* async event reporting */
1292#define SCSI_MP_IEC_UNIT_ATTN 0x2 /* generate unit attenstion */
1293#define SCSI_MO_IEC_COND_REC_ERR 0x3 /* conditionally generate recovered
1294 * error
1295 */
1296#define SCSI_MP_IEC_UNCOND_REC_ERR 0x4 /* unconditionally generate recovered
1297 * error
1298 */
1299#define SCSI_MP_IEC_NO_SENSE 0x5 /* generate no sense */
1300#define SCSI_MP_IEC_ON_REQUEST 0x6 /* only report exceptions on request */
1301
1302/*
1303 * SCSI flexible disk page
1304 */
1305struct scsi_mp_flexible_disk_s{
1306#ifdef __BIGENDIAN
1307 u8 ps:1;
1308 u8 reserved1:1;
1309 u8 page_code:6;
1310#else
1311 u8 page_code:6;
1312 u8 reserved1:1;
1313 u8 ps:1;
1314#endif
1315 u8 page_len;
1316
1317 u8 transfer_rate_msb;
1318 u8 transfer_rate_lsb;
1319
1320 u8 num_heads;
1321 u8 num_sectors;
1322
1323 u8 bytes_per_sector_msb;
1324 u8 bytes_per_sector_lsb;
1325
1326 u8 num_cylinders_msb;
1327 u8 num_cylinders_lsb;
1328
1329 u8 sc_wpc_msb; /* starting cylinder-write
1330 * precompensation msb
1331 */
1332 u8 sc_wpc_lsb; /* starting cylinder-write
1333 * precompensation lsb
1334 */
1335 u8 sc_rwc_msb; /* starting cylinder-reduced write
1336 * current msb
1337 */
1338 u8 sc_rwc_lsb; /* starting cylinder-reduced write
1339 * current lsb
1340 */
1341
1342 u8 dev_step_rate_msb;
1343 u8 dev_step_rate_lsb;
1344
1345 u8 dev_step_pulse_width;
1346
1347 u8 head_sd_msb; /* head settle delay msb */
1348 u8 head_sd_lsb; /* head settle delay lsb */
1349
1350 u8 motor_on_delay;
1351 u8 motor_off_delay;
1352#ifdef __BIGENDIAN
1353 u8 trdy:1; /* true ready bit */
1354 u8 ssn:1; /* start sector number bit */
1355 u8 mo:1; /* motor on bit */
1356 u8 reserved3:5;
1357
1358 u8 reserved4:4;
1359 u8 spc:4; /* step pulse per cylinder */
1360#else
1361 u8 reserved3:5;
1362 u8 mo:1; /* motor on bit */
1363 u8 ssn:1; /* start sector number bit */
1364 u8 trdy:1; /* true ready bit */
1365
1366 u8 spc:4; /* step pulse per cylinder */
1367 u8 reserved4:4;
1368#endif
1369 u8 write_comp;
1370 u8 head_load_delay;
1371 u8 head_unload_delay;
1372#ifdef __BIGENDIAN
1373 u8 pin34:4; /* pin34 usage */
1374 u8 pin2:4; /* pin2 usage */
1375
1376 u8 pin4:4; /* pin4 usage */
1377 u8 pin1:4; /* pin1 usage */
1378#else
1379 u8 pin2:4; /* pin2 usage */
1380 u8 pin34:4; /* pin34 usage */
1381
1382 u8 pin1:4; /* pin1 usage */
1383 u8 pin4:4; /* pin4 usage */
1384#endif
1385 u8 med_rot_rate_msb;
1386 u8 med_rot_rate_lsb;
1387
1388 u8 reserved5[2];
1389};
1390
1391struct scsi_mode_page_format_data6_s{
1392 struct scsi_mode_param_header6_s mph; /* mode page header */
1393 struct scsi_mode_param_desc_s desc; /* block descriptor */
1394 struct scsi_mp_format_device_s format; /* format device data */
1395};
1396
1397struct scsi_mode_page_format_data10_s{
1398 struct scsi_mode_param_header10_s mph; /* mode page header */
1399 struct scsi_mode_param_desc_s desc; /* block descriptor */
1400 struct scsi_mp_format_device_s format; /* format device data */
1401};
1402
1403struct scsi_mode_page_rdg_data6_s{
1404 struct scsi_mode_param_header6_s mph; /* mode page header */
1405 struct scsi_mode_param_desc_s desc; /* block descriptor */
1406 struct scsi_mp_rigid_device_geometry_s rdg;
1407 /* rigid geometry data */
1408};
1409
1410struct scsi_mode_page_rdg_data10_s{
1411 struct scsi_mode_param_header10_s mph; /* mode page header */
1412 struct scsi_mode_param_desc_s desc; /* block descriptor */
1413 struct scsi_mp_rigid_device_geometry_s rdg;
1414 /* rigid geometry data */
1415};
1416
1417struct scsi_mode_page_cache6_s{
1418 struct scsi_mode_param_header6_s mph; /* mode page header */
1419 struct scsi_mode_param_desc_s desc; /* block descriptor */
1420 struct scsi_mp_caching_s cache; /* cache page data */
1421};
1422
1423struct scsi_mode_page_cache10_s{
1424 struct scsi_mode_param_header10_s mph; /* mode page header */
1425 struct scsi_mode_param_desc_s desc; /* block descriptor */
1426 struct scsi_mp_caching_s cache; /* cache page data */
1427};
1428
1429/* --------------------------------------------------------------
1430 * Format Unit command
1431 * ------------------------------------------------------------
1432 */
1433
1434/*
1435 * Format Unit CDB
1436 */
1437struct scsi_format_unit_s{
1438 u8 opcode;
1439#ifdef __BIGENDIAN
1440 u8 res1:3;
1441 u8 fmtdata:1; /* if set, data out phase has format
1442 * data
1443 */
1444 u8 cmplst:1; /* if set, defect list is complete */
1445 u8 def_list:3; /* format of defect descriptor is
1446 * fmtdata =1
1447 */
1448#else
1449 u8 def_list:3; /* format of defect descriptor is
1450 * fmtdata = 1
1451 */
1452 u8 cmplst:1; /* if set, defect list is complete */
1453 u8 fmtdata:1; /* if set, data out phase has format
1454 * data
1455 */
1456 u8 res1:3;
1457#endif
1458 u8 interleave_msb;
1459 u8 interleave_lsb;
1460 u8 vendor_spec;
1461 u8 control;
1462};
1463
1464/*
1465 * h
1466 */
1467struct scsi_reserve6_s{
1468 u8 opcode;
1469#ifdef __BIGENDIAN
1470 u8 reserved:3;
1471 u8 obsolete:4;
1472 u8 extent:1;
1473#else
1474 u8 extent:1;
1475 u8 obsolete:4;
1476 u8 reserved:3;
1477#endif
1478 u8 reservation_id;
1479 u16 param_list_len;
1480 u8 control;
1481};
1482
1483/*
1484 * h
1485 */
1486struct scsi_release6_s{
1487 u8 opcode;
1488#ifdef __BIGENDIAN
1489 u8 reserved1:3;
1490 u8 obsolete:4;
1491 u8 extent:1;
1492#else
1493 u8 extent:1;
1494 u8 obsolete:4;
1495 u8 reserved1:3;
1496#endif
1497 u8 reservation_id;
1498 u16 reserved2;
1499 u8 control;
1500};
1501
1502/*
1503 * h
1504 */
1505struct scsi_reserve10_s{
1506 u8 opcode;
1507#ifdef __BIGENDIAN
1508 u8 reserved1:3;
1509 u8 third_party:1;
1510 u8 reserved2:2;
1511 u8 long_id:1;
1512 u8 extent:1;
1513#else
1514 u8 extent:1;
1515 u8 long_id:1;
1516 u8 reserved2:2;
1517 u8 third_party:1;
1518 u8 reserved1:3;
1519#endif
1520 u8 reservation_id;
1521 u8 third_pty_dev_id;
1522 u8 reserved3;
1523 u8 reserved4;
1524 u8 reserved5;
1525 u16 param_list_len;
1526 u8 control;
1527};
1528
1529struct scsi_release10_s{
1530 u8 opcode;
1531#ifdef __BIGENDIAN
1532 u8 reserved1:3;
1533 u8 third_party:1;
1534 u8 reserved2:2;
1535 u8 long_id:1;
1536 u8 extent:1;
1537#else
1538 u8 extent:1;
1539 u8 long_id:1;
1540 u8 reserved2:2;
1541 u8 third_party:1;
1542 u8 reserved1:3;
1543#endif
1544 u8 reservation_id;
1545 u8 third_pty_dev_id;
1546 u8 reserved3;
1547 u8 reserved4;
1548 u8 reserved5;
1549 u16 param_list_len;
1550 u8 control;
1551};
1552
1553struct scsi_verify10_s{
1554 u8 opcode;
1555#ifdef __BIGENDIAN
1556 u8 lun:3;
1557 u8 dpo:1;
1558 u8 reserved:2;
1559 u8 bytchk:1;
1560 u8 reladdr:1;
1561#else
1562 u8 reladdr:1;
1563 u8 bytchk:1;
1564 u8 reserved:2;
1565 u8 dpo:1;
1566 u8 lun:3;
1567#endif
1568 u8 lba0;
1569 u8 lba1;
1570 u8 lba2;
1571 u8 lba3;
1572 u8 reserved1;
1573 u8 verification_len0;
1574 u8 verification_len1;
1575 u8 control_byte;
1576};
1577
1578struct scsi_request_sense_s{
1579 u8 opcode;
1580#ifdef __BIGENDIAN
1581 u8 lun:3;
1582 u8 reserved:5;
1583#else
1584 u8 reserved:5;
1585 u8 lun:3;
1586#endif
1587 u8 reserved0;
1588 u8 reserved1;
1589 u8 alloc_len;
1590 u8 control_byte;
1591};
1592
1593/* ------------------------------------------------------------
1594 * SCSI status byte values
1595 * ------------------------------------------------------------
1596 */
1597#define SCSI_STATUS_GOOD 0x00
1598#define SCSI_STATUS_CHECK_CONDITION 0x02
1599#define SCSI_STATUS_CONDITION_MET 0x04
1600#define SCSI_STATUS_BUSY 0x08
1601#define SCSI_STATUS_INTERMEDIATE 0x10
1602#define SCSI_STATUS_ICM 0x14 /* intermediate condition met */
1603#define SCSI_STATUS_RESERVATION_CONFLICT 0x18
1604#define SCSI_STATUS_COMMAND_TERMINATED 0x22
1605#define SCSI_STATUS_QUEUE_FULL 0x28
1606#define SCSI_STATUS_ACA_ACTIVE 0x30
1607
1608#define SCSI_MAX_ALLOC_LEN 0xFF /* maximum allocarion length
1609 * in CDBs
1610 */
1611
1612#define SCSI_OP_WRITE_VERIFY10 0x2E
1613#define SCSI_OP_WRITE_VERIFY12 0xAE
1614#define SCSI_OP_UNDEF 0xFF
1615
1616/*
1617 * SCSI WRITE-VERIFY(10) command
1618 */
1619struct scsi_write_verify10_s{
1620 u8 opcode;
1621#ifdef __BIGENDIAN
1622 u8 reserved1:3;
1623 u8 dpo:1; /* Disable Page Out */
1624 u8 reserved2:1;
1625 u8 ebp:1; /* erse by-pass */
1626 u8 bytchk:1; /* byte check */
1627 u8 rel_adr:1; /* relative address */
1628#else
1629 u8 rel_adr:1; /* relative address */
1630 u8 bytchk:1; /* byte check */
1631 u8 ebp:1; /* erse by-pass */
1632 u8 reserved2:1;
1633 u8 dpo:1; /* Disable Page Out */
1634 u8 reserved1:3;
1635#endif
1636 u8 lba0; /* logical block address - MSB */
1637 u8 lba1;
1638 u8 lba2;
1639 u8 lba3; /* LSB */
1640 u8 reserved3;
1641 u8 xfer_length0; /* transfer length in blocks - MSB */
1642 u8 xfer_length1; /* LSB */
1643 u8 control;
1644};
1645
1646#pragma pack()
1647
1648#endif /* __SCSI_H__ */
diff --git a/drivers/scsi/bfa/include/protocol/types.h b/drivers/scsi/bfa/include/protocol/types.h
deleted file mode 100644
index 2875a6cced3b..000000000000
--- a/drivers/scsi/bfa/include/protocol/types.h
+++ /dev/null
@@ -1,42 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * types.h Protocol defined base types
20 */
21
22#ifndef __TYPES_H__
23#define __TYPES_H__
24
25#include <bfa_os_inc.h>
26
27#define wwn_t u64
28#define lun_t u64
29
30#define WWN_NULL (0)
31#define FC_SYMNAME_MAX 256 /* max name server symbolic name size */
32#define FC_ALPA_MAX 128
33
34#pragma pack(1)
35
36#define MAC_ADDRLEN (6)
37struct mac_s { u8 mac[MAC_ADDRLEN]; };
38#define mac_t struct mac_s
39
40#pragma pack()
41
42#endif
diff --git a/drivers/scsi/bfa/loop.c b/drivers/scsi/bfa/loop.c
deleted file mode 100644
index f6342efb6a90..000000000000
--- a/drivers/scsi/bfa/loop.c
+++ /dev/null
@@ -1,213 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * port_loop.c vport private loop implementation.
20 */
21#include <bfa.h>
22#include <bfa_svc.h>
23#include "fcs_lport.h"
24#include "fcs_rport.h"
25#include "fcs_trcmod.h"
26#include "lport_priv.h"
27
28BFA_TRC_FILE(FCS, LOOP);
29
30/**
31 * ALPA to LIXA bitmap mapping
32 *
33 * ALPA 0x00 (Word 0, Bit 30) is invalid for N_Ports. Also Word 0 Bit 31
34 * is for L_bit (login required) and is filled as ALPA 0x00 here.
35 */
36static const u8 port_loop_alpa_map[] = {
37 0xEF, 0xE8, 0xE4, 0xE2, 0xE1, 0xE0, 0xDC, 0xDA, /* Word 3 Bits 0..7 */
38 0xD9, 0xD6, 0xD5, 0xD4, 0xD3, 0xD2, 0xD1, 0xCE, /* Word 3 Bits 8..15 */
39 0xCD, 0xCC, 0xCB, 0xCA, 0xC9, 0xC7, 0xC6, 0xC5, /* Word 3 Bits 16..23 */
40 0xC3, 0xBC, 0xBA, 0xB9, 0xB6, 0xB5, 0xB4, 0xB3, /* Word 3 Bits 24..31 */
41
42 0xB2, 0xB1, 0xAE, 0xAD, 0xAC, 0xAB, 0xAA, 0xA9, /* Word 2 Bits 0..7 */
43 0xA7, 0xA6, 0xA5, 0xA3, 0x9F, 0x9E, 0x9D, 0x9B, /* Word 2 Bits 8..15 */
44 0x98, 0x97, 0x90, 0x8F, 0x88, 0x84, 0x82, 0x81, /* Word 2 Bits 16..23 */
45 0x80, 0x7C, 0x7A, 0x79, 0x76, 0x75, 0x74, 0x73, /* Word 2 Bits 24..31 */
46
47 0x72, 0x71, 0x6E, 0x6D, 0x6C, 0x6B, 0x6A, 0x69, /* Word 1 Bits 0..7 */
48 0x67, 0x66, 0x65, 0x63, 0x5C, 0x5A, 0x59, 0x56, /* Word 1 Bits 8..15 */
49 0x55, 0x54, 0x53, 0x52, 0x51, 0x4E, 0x4D, 0x4C, /* Word 1 Bits 16..23 */
50 0x4B, 0x4A, 0x49, 0x47, 0x46, 0x45, 0x43, 0x3C, /* Word 1 Bits 24..31 */
51
52 0x3A, 0x39, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, /* Word 0 Bits 0..7 */
53 0x2E, 0x2D, 0x2C, 0x2B, 0x2A, 0x29, 0x27, 0x26, /* Word 0 Bits 8..15 */
54 0x25, 0x23, 0x1F, 0x1E, 0x1D, 0x1B, 0x18, 0x17, /* Word 0 Bits 16..23 */
55 0x10, 0x0F, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00, /* Word 0 Bits 24..31 */
56};
57
58/*
59 * Local Functions
60 */
61static bfa_status_t bfa_fcs_port_loop_send_plogi(struct bfa_fcs_port_s *port,
62 u8 alpa);
63
64static void bfa_fcs_port_loop_plogi_response(void *fcsarg,
65 struct bfa_fcxp_s *fcxp,
66 void *cbarg,
67 bfa_status_t req_status,
68 u32 rsp_len,
69 u32 resid_len,
70 struct fchs_s *rsp_fchs);
71/**
72 * Called by port to initializar in provate LOOP topology.
73 */
74void
75bfa_fcs_port_loop_init(struct bfa_fcs_port_s *port)
76{
77}
78
79/**
80 * Called by port to notify transition to online state.
81 */
82void
83bfa_fcs_port_loop_online(struct bfa_fcs_port_s *port)
84{
85
86 u8 num_alpa = port->port_topo.ploop.num_alpa;
87 u8 *alpa_pos_map = port->port_topo.ploop.alpa_pos_map;
88 struct bfa_fcs_rport_s *r_port;
89 int ii = 0;
90
91 /*
92 * If the port role is Initiator Mode, create Rports.
93 */
94 if (port->port_cfg.roles == BFA_PORT_ROLE_FCP_IM) {
95 /*
96 * Check if the ALPA positional bitmap is available.
97 * if not, we send PLOGI to all possible ALPAs.
98 */
99 if (num_alpa > 0) {
100 for (ii = 0; ii < num_alpa; ii++) {
101 /*
102 * ignore ALPA of bfa port
103 */
104 if (alpa_pos_map[ii] != port->pid) {
105 r_port = bfa_fcs_rport_create(port,
106 alpa_pos_map[ii]);
107 }
108 }
109 } else {
110 for (ii = 0; ii < MAX_ALPA_COUNT; ii++) {
111 /*
112 * ignore ALPA of bfa port
113 */
114 if ((port_loop_alpa_map[ii] > 0)
115 && (port_loop_alpa_map[ii] != port->pid))
116 bfa_fcs_port_loop_send_plogi(port,
117 port_loop_alpa_map[ii]);
118 /**TBD */
119 }
120 }
121 } else {
122 /*
123 * TBD Target Mode ??
124 */
125 }
126
127}
128
129/**
130 * Called by port to notify transition to offline state.
131 */
132void
133bfa_fcs_port_loop_offline(struct bfa_fcs_port_s *port)
134{
135
136}
137
138/**
139 * Called by port to notify a LIP on the loop.
140 */
141void
142bfa_fcs_port_loop_lip(struct bfa_fcs_port_s *port)
143{
144}
145
146/**
147 * Local Functions.
148 */
149static bfa_status_t
150bfa_fcs_port_loop_send_plogi(struct bfa_fcs_port_s *port, u8 alpa)
151{
152 struct fchs_s fchs;
153 struct bfa_fcxp_s *fcxp = NULL;
154 int len;
155
156 bfa_trc(port->fcs, alpa);
157
158 fcxp = bfa_fcxp_alloc(NULL, port->fcs->bfa, 0, 0, NULL, NULL, NULL,
159 NULL);
160 bfa_assert(fcxp);
161
162 len = fc_plogi_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), alpa,
163 bfa_fcs_port_get_fcid(port), 0,
164 port->port_cfg.pwwn, port->port_cfg.nwwn,
165 bfa_fcport_get_maxfrsize(port->fcs->bfa));
166
167 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
168 FC_CLASS_3, len, &fchs,
169 bfa_fcs_port_loop_plogi_response, (void *)port,
170 FC_MAX_PDUSZ, FC_RA_TOV);
171
172 return BFA_STATUS_OK;
173}
174
175/**
176 * Called by fcxp to notify the Plogi response
177 */
178static void
179bfa_fcs_port_loop_plogi_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
180 void *cbarg, bfa_status_t req_status,
181 u32 rsp_len, u32 resid_len,
182 struct fchs_s *rsp_fchs)
183{
184 struct bfa_fcs_port_s *port = (struct bfa_fcs_port_s *) cbarg;
185 struct fc_logi_s *plogi_resp;
186 struct fc_els_cmd_s *els_cmd;
187
188 bfa_trc(port->fcs, req_status);
189
190 /*
191 * Sanity Checks
192 */
193 if (req_status != BFA_STATUS_OK) {
194 bfa_trc(port->fcs, req_status);
195 /*
196 * @todo
197 * This could mean that the device with this APLA does not
198 * exist on the loop.
199 */
200
201 return;
202 }
203
204 els_cmd = (struct fc_els_cmd_s *) BFA_FCXP_RSP_PLD(fcxp);
205 plogi_resp = (struct fc_logi_s *) els_cmd;
206
207 if (els_cmd->els_code == FC_ELS_ACC) {
208 bfa_fcs_rport_start(port, rsp_fchs, plogi_resp);
209 } else {
210 bfa_trc(port->fcs, plogi_resp->els_cmd.els_code);
211 bfa_assert(0);
212 }
213}
diff --git a/drivers/scsi/bfa/lport_api.c b/drivers/scsi/bfa/lport_api.c
deleted file mode 100644
index 72b3f508d0e9..000000000000
--- a/drivers/scsi/bfa/lport_api.c
+++ /dev/null
@@ -1,303 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * port_api.c BFA FCS port
20 */
21
22#include <fcs/bfa_fcs.h>
23#include <fcs/bfa_fcs_lport.h>
24#include <fcs/bfa_fcs_rport.h>
25#include "fcs_rport.h"
26#include "fcs_fabric.h"
27#include "fcs_trcmod.h"
28#include "fcs_vport.h"
29
30BFA_TRC_FILE(FCS, PORT_API);
31
32
33
34/**
35 * fcs_port_api BFA FCS port API
36 */
37
38void
39bfa_fcs_cfg_base_port(struct bfa_fcs_s *fcs, struct bfa_port_cfg_s *port_cfg)
40{
41}
42
43struct bfa_fcs_port_s *
44bfa_fcs_get_base_port(struct bfa_fcs_s *fcs)
45{
46 return &fcs->fabric.bport;
47}
48
49wwn_t
50bfa_fcs_port_get_rport(struct bfa_fcs_port_s *port, wwn_t wwn, int index,
51 int nrports, bfa_boolean_t bwwn)
52{
53 struct list_head *qh, *qe;
54 struct bfa_fcs_rport_s *rport = NULL;
55 int i;
56 struct bfa_fcs_s *fcs;
57
58 if (port == NULL || nrports == 0)
59 return (wwn_t) 0;
60
61 fcs = port->fcs;
62 bfa_trc(fcs, (u32) nrports);
63
64 i = 0;
65 qh = &port->rport_q;
66 qe = bfa_q_first(qh);
67
68 while ((qe != qh) && (i < nrports)) {
69 rport = (struct bfa_fcs_rport_s *)qe;
70 if (bfa_os_ntoh3b(rport->pid) > 0xFFF000) {
71 qe = bfa_q_next(qe);
72 bfa_trc(fcs, (u32) rport->pwwn);
73 bfa_trc(fcs, rport->pid);
74 bfa_trc(fcs, i);
75 continue;
76 }
77
78 if (bwwn) {
79 if (!memcmp(&wwn, &rport->pwwn, 8))
80 break;
81 } else {
82 if (i == index)
83 break;
84 }
85
86 i++;
87 qe = bfa_q_next(qe);
88 }
89
90 bfa_trc(fcs, i);
91 if (rport)
92 return rport->pwwn;
93 else
94 return (wwn_t) 0;
95}
96
97void
98bfa_fcs_port_get_rports(struct bfa_fcs_port_s *port, wwn_t rport_wwns[],
99 int *nrports)
100{
101 struct list_head *qh, *qe;
102 struct bfa_fcs_rport_s *rport = NULL;
103 int i;
104 struct bfa_fcs_s *fcs;
105
106 if (port == NULL || rport_wwns == NULL || *nrports == 0)
107 return;
108
109 fcs = port->fcs;
110 bfa_trc(fcs, (u32) *nrports);
111
112 i = 0;
113 qh = &port->rport_q;
114 qe = bfa_q_first(qh);
115
116 while ((qe != qh) && (i < *nrports)) {
117 rport = (struct bfa_fcs_rport_s *)qe;
118 if (bfa_os_ntoh3b(rport->pid) > 0xFFF000) {
119 qe = bfa_q_next(qe);
120 bfa_trc(fcs, (u32) rport->pwwn);
121 bfa_trc(fcs, rport->pid);
122 bfa_trc(fcs, i);
123 continue;
124 }
125
126 rport_wwns[i] = rport->pwwn;
127
128 i++;
129 qe = bfa_q_next(qe);
130 }
131
132 bfa_trc(fcs, i);
133 *nrports = i;
134 return;
135}
136
137/*
138 * Iterate's through all the rport's in the given port to
139 * determine the maximum operating speed.
140 *
141 * To be used in TRL Functionality only
142 */
143enum bfa_pport_speed
144bfa_fcs_port_get_rport_max_speed(struct bfa_fcs_port_s *port)
145{
146 struct list_head *qh, *qe;
147 struct bfa_fcs_rport_s *rport = NULL;
148 struct bfa_fcs_s *fcs;
149 enum bfa_pport_speed max_speed = 0;
150 struct bfa_pport_attr_s pport_attr;
151 enum bfa_pport_speed pport_speed, rport_speed;
152 bfa_boolean_t trl_enabled = bfa_fcport_is_ratelim(port->fcs->bfa);
153
154 if (port == NULL)
155 return 0;
156
157 fcs = port->fcs;
158
159 /*
160 * Get Physical port's current speed
161 */
162 bfa_fcport_get_attr(port->fcs->bfa, &pport_attr);
163 pport_speed = pport_attr.speed;
164 bfa_trc(fcs, pport_speed);
165
166 qh = &port->rport_q;
167 qe = bfa_q_first(qh);
168
169 while (qe != qh) {
170 rport = (struct bfa_fcs_rport_s *) qe;
171 if ((bfa_os_ntoh3b(rport->pid) > 0xFFF000) ||
172 (bfa_fcs_rport_get_state(rport) ==
173 BFA_RPORT_OFFLINE)) {
174 qe = bfa_q_next(qe);
175 continue;
176 }
177
178 rport_speed = rport->rpf.rpsc_speed;
179 if ((trl_enabled) && (rport_speed ==
180 BFA_PPORT_SPEED_UNKNOWN)) {
181 /* Use default ratelim speed setting */
182 rport_speed =
183 bfa_fcport_get_ratelim_speed(port->fcs->bfa);
184 }
185
186 if ((rport_speed == BFA_PPORT_SPEED_8GBPS) ||
187 (rport_speed > pport_speed)) {
188 max_speed = rport_speed;
189 break;
190 } else if (rport_speed > max_speed) {
191 max_speed = rport_speed;
192 }
193
194 qe = bfa_q_next(qe);
195 }
196
197 bfa_trc(fcs, max_speed);
198 return max_speed;
199}
200
201struct bfa_fcs_port_s *
202bfa_fcs_lookup_port(struct bfa_fcs_s *fcs, u16 vf_id, wwn_t lpwwn)
203{
204 struct bfa_fcs_vport_s *vport;
205 bfa_fcs_vf_t *vf;
206
207 bfa_assert(fcs != NULL);
208
209 vf = bfa_fcs_vf_lookup(fcs, vf_id);
210 if (vf == NULL) {
211 bfa_trc(fcs, vf_id);
212 return NULL;
213 }
214
215 if (!lpwwn || (vf->bport.port_cfg.pwwn == lpwwn))
216 return &vf->bport;
217
218 vport = bfa_fcs_fabric_vport_lookup(vf, lpwwn);
219 if (vport)
220 return &vport->lport;
221
222 return NULL;
223}
224
225/*
226 * API corresponding to VmWare's NPIV_VPORT_GETINFO.
227 */
228void
229bfa_fcs_port_get_info(struct bfa_fcs_port_s *port,
230 struct bfa_port_info_s *port_info)
231{
232
233 bfa_trc(port->fcs, port->fabric->fabric_name);
234
235 if (port->vport == NULL) {
236 /*
237 * This is a Physical port
238 */
239 port_info->port_type = BFA_PORT_TYPE_PHYSICAL;
240
241 /*
242 * @todo : need to fix the state & reason
243 */
244 port_info->port_state = 0;
245 port_info->offline_reason = 0;
246
247 port_info->port_wwn = bfa_fcs_port_get_pwwn(port);
248 port_info->node_wwn = bfa_fcs_port_get_nwwn(port);
249
250 port_info->max_vports_supp =
251 bfa_lps_get_max_vport(port->fcs->bfa);
252 port_info->num_vports_inuse =
253 bfa_fcs_fabric_vport_count(port->fabric);
254 port_info->max_rports_supp = BFA_FCS_MAX_RPORTS_SUPP;
255 port_info->num_rports_inuse = port->num_rports;
256 } else {
257 /*
258 * This is a virtual port
259 */
260 port_info->port_type = BFA_PORT_TYPE_VIRTUAL;
261
262 /*
263 * @todo : need to fix the state & reason
264 */
265 port_info->port_state = 0;
266 port_info->offline_reason = 0;
267
268 port_info->port_wwn = bfa_fcs_port_get_pwwn(port);
269 port_info->node_wwn = bfa_fcs_port_get_nwwn(port);
270 }
271}
272
273void
274bfa_fcs_port_get_stats(struct bfa_fcs_port_s *fcs_port,
275 struct bfa_port_stats_s *port_stats)
276{
277 bfa_os_memcpy(port_stats, &fcs_port->stats,
278 sizeof(struct bfa_port_stats_s));
279 return;
280}
281
282void
283bfa_fcs_port_clear_stats(struct bfa_fcs_port_s *fcs_port)
284{
285 bfa_os_memset(&fcs_port->stats, 0, sizeof(struct bfa_port_stats_s));
286 return;
287}
288
289void
290bfa_fcs_port_enable_ipfc_roles(struct bfa_fcs_port_s *fcs_port)
291{
292 fcs_port->port_cfg.roles |= BFA_PORT_ROLE_FCP_IPFC;
293 return;
294}
295
296void
297bfa_fcs_port_disable_ipfc_roles(struct bfa_fcs_port_s *fcs_port)
298{
299 fcs_port->port_cfg.roles &= ~BFA_PORT_ROLE_FCP_IPFC;
300 return;
301}
302
303
diff --git a/drivers/scsi/bfa/lport_priv.h b/drivers/scsi/bfa/lport_priv.h
deleted file mode 100644
index dbae370a599a..000000000000
--- a/drivers/scsi/bfa/lport_priv.h
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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 __VP_PRIV_H__
19#define __VP_PRIV_H__
20
21#include <fcs/bfa_fcs_lport.h>
22#include <fcs/bfa_fcs_vport.h>
23
24/*
25 * Functions exported by vps
26 */
27void bfa_fcs_vport_init(struct bfa_fcs_vport_s *vport);
28
29/*
30 * Functions exported by vps
31 */
32void bfa_fcs_vps_online(struct bfa_fcs_port_s *port);
33void bfa_fcs_vps_offline(struct bfa_fcs_port_s *port);
34void bfa_fcs_vps_lip(struct bfa_fcs_port_s *port);
35
36/*
37 * Functions exported by port_fab
38 */
39void bfa_fcs_port_fab_init(struct bfa_fcs_port_s *vport);
40void bfa_fcs_port_fab_online(struct bfa_fcs_port_s *vport);
41void bfa_fcs_port_fab_offline(struct bfa_fcs_port_s *vport);
42void bfa_fcs_port_fab_rx_frame(struct bfa_fcs_port_s *port,
43 u8 *rx_frame, u32 len);
44
45/*
46 * Functions exported by VP-NS.
47 */
48void bfa_fcs_port_ns_init(struct bfa_fcs_port_s *vport);
49void bfa_fcs_port_ns_offline(struct bfa_fcs_port_s *vport);
50void bfa_fcs_port_ns_online(struct bfa_fcs_port_s *vport);
51void bfa_fcs_port_ns_query(struct bfa_fcs_port_s *port);
52
53/*
54 * Functions exported by VP-SCN
55 */
56void bfa_fcs_port_scn_init(struct bfa_fcs_port_s *vport);
57void bfa_fcs_port_scn_offline(struct bfa_fcs_port_s *vport);
58void bfa_fcs_port_scn_online(struct bfa_fcs_port_s *vport);
59void bfa_fcs_port_scn_process_rscn(struct bfa_fcs_port_s *port,
60 struct fchs_s *rx_frame, u32 len);
61
62/*
63 * Functions exported by VP-N2N
64 */
65
66void bfa_fcs_port_n2n_init(struct bfa_fcs_port_s *port);
67void bfa_fcs_port_n2n_online(struct bfa_fcs_port_s *port);
68void bfa_fcs_port_n2n_offline(struct bfa_fcs_port_s *port);
69void bfa_fcs_port_n2n_rx_frame(struct bfa_fcs_port_s *port,
70 u8 *rx_frame, u32 len);
71
72/*
73 * Functions exported by VP-LOOP
74 */
75void bfa_fcs_port_loop_init(struct bfa_fcs_port_s *port);
76void bfa_fcs_port_loop_online(struct bfa_fcs_port_s *port);
77void bfa_fcs_port_loop_offline(struct bfa_fcs_port_s *port);
78void bfa_fcs_port_loop_lip(struct bfa_fcs_port_s *port);
79void bfa_fcs_port_loop_rx_frame(struct bfa_fcs_port_s *port,
80 u8 *rx_frame, u32 len);
81
82#endif /* __VP_PRIV_H__ */
diff --git a/drivers/scsi/bfa/ms.c b/drivers/scsi/bfa/ms.c
deleted file mode 100644
index 1d579ef26122..000000000000
--- a/drivers/scsi/bfa/ms.c
+++ /dev/null
@@ -1,759 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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
19#include <bfa.h>
20#include <bfa_svc.h>
21#include "fcs_lport.h"
22#include "fcs_rport.h"
23#include "fcs_trcmod.h"
24#include "fcs_fcxp.h"
25#include "lport_priv.h"
26
27BFA_TRC_FILE(FCS, MS);
28
29#define BFA_FCS_MS_CMD_MAX_RETRIES 2
30/*
31 * forward declarations
32 */
33static void bfa_fcs_port_ms_send_plogi(void *ms_cbarg,
34 struct bfa_fcxp_s *fcxp_alloced);
35static void bfa_fcs_port_ms_timeout(void *arg);
36static void bfa_fcs_port_ms_plogi_response(void *fcsarg,
37 struct bfa_fcxp_s *fcxp,
38 void *cbarg,
39 bfa_status_t req_status,
40 u32 rsp_len,
41 u32 resid_len,
42 struct fchs_s *rsp_fchs);
43
44static void bfa_fcs_port_ms_send_gmal(void *ms_cbarg,
45 struct bfa_fcxp_s *fcxp_alloced);
46static void bfa_fcs_port_ms_gmal_response(void *fcsarg,
47 struct bfa_fcxp_s *fcxp,
48 void *cbarg,
49 bfa_status_t req_status,
50 u32 rsp_len,
51 u32 resid_len,
52 struct fchs_s *rsp_fchs);
53static void bfa_fcs_port_ms_send_gfn(void *ms_cbarg,
54 struct bfa_fcxp_s *fcxp_alloced);
55static void bfa_fcs_port_ms_gfn_response(void *fcsarg,
56 struct bfa_fcxp_s *fcxp,
57 void *cbarg,
58 bfa_status_t req_status,
59 u32 rsp_len,
60 u32 resid_len,
61 struct fchs_s *rsp_fchs);
62/**
63 * fcs_ms_sm FCS MS state machine
64 */
65
66/**
67 * MS State Machine events
68 */
69enum port_ms_event {
70 MSSM_EVENT_PORT_ONLINE = 1,
71 MSSM_EVENT_PORT_OFFLINE = 2,
72 MSSM_EVENT_RSP_OK = 3,
73 MSSM_EVENT_RSP_ERROR = 4,
74 MSSM_EVENT_TIMEOUT = 5,
75 MSSM_EVENT_FCXP_SENT = 6,
76 MSSM_EVENT_PORT_FABRIC_RSCN = 7
77};
78
79static void bfa_fcs_port_ms_sm_offline(struct bfa_fcs_port_ms_s *ms,
80 enum port_ms_event event);
81static void bfa_fcs_port_ms_sm_plogi_sending(struct bfa_fcs_port_ms_s *ms,
82 enum port_ms_event event);
83static void bfa_fcs_port_ms_sm_plogi(struct bfa_fcs_port_ms_s *ms,
84 enum port_ms_event event);
85static void bfa_fcs_port_ms_sm_plogi_retry(struct bfa_fcs_port_ms_s *ms,
86 enum port_ms_event event);
87static void bfa_fcs_port_ms_sm_gmal_sending(struct bfa_fcs_port_ms_s *ms,
88 enum port_ms_event event);
89static void bfa_fcs_port_ms_sm_gmal(struct bfa_fcs_port_ms_s *ms,
90 enum port_ms_event event);
91static void bfa_fcs_port_ms_sm_gmal_retry(struct bfa_fcs_port_ms_s *ms,
92 enum port_ms_event event);
93static void bfa_fcs_port_ms_sm_gfn_sending(struct bfa_fcs_port_ms_s *ms,
94 enum port_ms_event event);
95static void bfa_fcs_port_ms_sm_gfn(struct bfa_fcs_port_ms_s *ms,
96 enum port_ms_event event);
97static void bfa_fcs_port_ms_sm_gfn_retry(struct bfa_fcs_port_ms_s *ms,
98 enum port_ms_event event);
99static void bfa_fcs_port_ms_sm_online(struct bfa_fcs_port_ms_s *ms,
100 enum port_ms_event event);
101/**
102 * Start in offline state - awaiting NS to send start.
103 */
104static void
105bfa_fcs_port_ms_sm_offline(struct bfa_fcs_port_ms_s *ms,
106 enum port_ms_event event)
107{
108 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
109 bfa_trc(ms->port->fcs, event);
110
111 switch (event) {
112 case MSSM_EVENT_PORT_ONLINE:
113 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_plogi_sending);
114 bfa_fcs_port_ms_send_plogi(ms, NULL);
115 break;
116
117 case MSSM_EVENT_PORT_OFFLINE:
118 break;
119
120 default:
121 bfa_sm_fault(ms->port->fcs, event);
122 }
123}
124
125static void
126bfa_fcs_port_ms_sm_plogi_sending(struct bfa_fcs_port_ms_s *ms,
127 enum port_ms_event event)
128{
129 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
130 bfa_trc(ms->port->fcs, event);
131
132 switch (event) {
133 case MSSM_EVENT_FCXP_SENT:
134 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_plogi);
135 break;
136
137 case MSSM_EVENT_PORT_OFFLINE:
138 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline);
139 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms->port),
140 &ms->fcxp_wqe);
141 break;
142
143 default:
144 bfa_sm_fault(ms->port->fcs, event);
145 }
146}
147
148static void
149bfa_fcs_port_ms_sm_plogi(struct bfa_fcs_port_ms_s *ms, enum port_ms_event event)
150{
151 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
152 bfa_trc(ms->port->fcs, event);
153
154 switch (event) {
155 case MSSM_EVENT_RSP_ERROR:
156 /*
157 * Start timer for a delayed retry
158 */
159 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_plogi_retry);
160 ms->port->stats.ms_retries++;
161 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms->port), &ms->timer,
162 bfa_fcs_port_ms_timeout, ms,
163 BFA_FCS_RETRY_TIMEOUT);
164 break;
165
166 case MSSM_EVENT_RSP_OK:
167 /*
168 * since plogi is done, now invoke MS related sub-modules
169 */
170 bfa_fcs_port_fdmi_online(ms);
171
172 /**
173 * if this is a Vport, go to online state.
174 */
175 if (ms->port->vport) {
176 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_online);
177 break;
178 }
179
180 /*
181 * For a base port we need to get the
182 * switch's IP address.
183 */
184 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_gmal_sending);
185 bfa_fcs_port_ms_send_gmal(ms, NULL);
186 break;
187
188 case MSSM_EVENT_PORT_OFFLINE:
189 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline);
190 bfa_fcxp_discard(ms->fcxp);
191 break;
192
193 default:
194 bfa_sm_fault(ms->port->fcs, event);
195 }
196}
197
198static void
199bfa_fcs_port_ms_sm_plogi_retry(struct bfa_fcs_port_ms_s *ms,
200 enum port_ms_event event)
201{
202 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
203 bfa_trc(ms->port->fcs, event);
204
205 switch (event) {
206 case MSSM_EVENT_TIMEOUT:
207 /*
208 * Retry Timer Expired. Re-send
209 */
210 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_plogi_sending);
211 bfa_fcs_port_ms_send_plogi(ms, NULL);
212 break;
213
214 case MSSM_EVENT_PORT_OFFLINE:
215 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline);
216 bfa_timer_stop(&ms->timer);
217 break;
218
219 default:
220 bfa_sm_fault(ms->port->fcs, event);
221 }
222}
223
224static void
225bfa_fcs_port_ms_sm_online(struct bfa_fcs_port_ms_s *ms,
226 enum port_ms_event event)
227{
228 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
229 bfa_trc(ms->port->fcs, event);
230
231 switch (event) {
232 case MSSM_EVENT_PORT_OFFLINE:
233 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline);
234 break;
235
236 case MSSM_EVENT_PORT_FABRIC_RSCN:
237 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_gfn_sending);
238 ms->retry_cnt = 0;
239 bfa_fcs_port_ms_send_gfn(ms, NULL);
240 break;
241
242 default:
243 bfa_sm_fault(ms->port->fcs, event);
244 }
245}
246
247static void
248bfa_fcs_port_ms_sm_gmal_sending(struct bfa_fcs_port_ms_s *ms,
249 enum port_ms_event event)
250{
251 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
252 bfa_trc(ms->port->fcs, event);
253
254 switch (event) {
255 case MSSM_EVENT_FCXP_SENT:
256 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_gmal);
257 break;
258
259 case MSSM_EVENT_PORT_OFFLINE:
260 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline);
261 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms->port),
262 &ms->fcxp_wqe);
263 break;
264
265 default:
266 bfa_sm_fault(ms->port->fcs, event);
267 }
268}
269
270static void
271bfa_fcs_port_ms_sm_gmal(struct bfa_fcs_port_ms_s *ms, enum port_ms_event event)
272{
273 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
274 bfa_trc(ms->port->fcs, event);
275
276 switch (event) {
277 case MSSM_EVENT_RSP_ERROR:
278 /*
279 * Start timer for a delayed retry
280 */
281 if (ms->retry_cnt++ < BFA_FCS_MS_CMD_MAX_RETRIES) {
282 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_gmal_retry);
283 ms->port->stats.ms_retries++;
284 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms->port),
285 &ms->timer, bfa_fcs_port_ms_timeout, ms,
286 BFA_FCS_RETRY_TIMEOUT);
287 } else {
288 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_gfn_sending);
289 bfa_fcs_port_ms_send_gfn(ms, NULL);
290 ms->retry_cnt = 0;
291 }
292 break;
293
294 case MSSM_EVENT_RSP_OK:
295 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_gfn_sending);
296 bfa_fcs_port_ms_send_gfn(ms, NULL);
297 break;
298
299 case MSSM_EVENT_PORT_OFFLINE:
300 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline);
301 bfa_fcxp_discard(ms->fcxp);
302 break;
303
304 default:
305 bfa_sm_fault(ms->port->fcs, event);
306 }
307}
308
309static void
310bfa_fcs_port_ms_sm_gmal_retry(struct bfa_fcs_port_ms_s *ms,
311 enum port_ms_event event)
312{
313 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
314 bfa_trc(ms->port->fcs, event);
315
316 switch (event) {
317 case MSSM_EVENT_TIMEOUT:
318 /*
319 * Retry Timer Expired. Re-send
320 */
321 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_gmal_sending);
322 bfa_fcs_port_ms_send_gmal(ms, NULL);
323 break;
324
325 case MSSM_EVENT_PORT_OFFLINE:
326 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline);
327 bfa_timer_stop(&ms->timer);
328 break;
329
330 default:
331 bfa_sm_fault(ms->port->fcs, event);
332 }
333}
334
335/**
336 * ms_pvt MS local functions
337 */
338
339static void
340bfa_fcs_port_ms_send_gmal(void *ms_cbarg, struct bfa_fcxp_s *fcxp_alloced)
341{
342 struct bfa_fcs_port_ms_s *ms = ms_cbarg;
343 struct bfa_fcs_port_s *port = ms->port;
344 struct fchs_s fchs;
345 int len;
346 struct bfa_fcxp_s *fcxp;
347
348 bfa_trc(port->fcs, port->pid);
349
350 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
351 if (!fcxp) {
352 bfa_fcxp_alloc_wait(port->fcs->bfa, &ms->fcxp_wqe,
353 bfa_fcs_port_ms_send_gmal, ms);
354 return;
355 }
356 ms->fcxp = fcxp;
357
358 len = fc_gmal_req_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
359 bfa_fcs_port_get_fcid(port),
360 bfa_lps_get_peer_nwwn(port->fabric->lps));
361
362 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
363 FC_CLASS_3, len, &fchs, bfa_fcs_port_ms_gmal_response,
364 (void *)ms, FC_MAX_PDUSZ, FC_FCCT_TOV);
365
366 bfa_sm_send_event(ms, MSSM_EVENT_FCXP_SENT);
367}
368
369static void
370bfa_fcs_port_ms_gmal_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
371 void *cbarg, bfa_status_t req_status,
372 u32 rsp_len, u32 resid_len,
373 struct fchs_s *rsp_fchs)
374{
375 struct bfa_fcs_port_ms_s *ms = (struct bfa_fcs_port_ms_s *)cbarg;
376 struct bfa_fcs_port_s *port = ms->port;
377 struct ct_hdr_s *cthdr = NULL;
378 struct fcgs_gmal_resp_s *gmal_resp;
379 struct fc_gmal_entry_s *gmal_entry;
380 u32 num_entries;
381 u8 *rsp_str;
382
383 bfa_trc(port->fcs, req_status);
384 bfa_trc(port->fcs, port->port_cfg.pwwn);
385
386 /*
387 * Sanity Checks
388 */
389 if (req_status != BFA_STATUS_OK) {
390 bfa_trc(port->fcs, req_status);
391 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
392 return;
393 }
394
395 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
396 cthdr->cmd_rsp_code = bfa_os_ntohs(cthdr->cmd_rsp_code);
397
398 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
399 gmal_resp = (struct fcgs_gmal_resp_s *)(cthdr + 1);
400 num_entries = bfa_os_ntohl(gmal_resp->ms_len);
401 if (num_entries == 0) {
402 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
403 return;
404 }
405 /*
406 * The response could contain multiple Entries.
407 * Entries for SNMP interface, etc.
408 * We look for the entry with a telnet prefix.
409 * First "http://" entry refers to IP addr
410 */
411
412 gmal_entry = (struct fc_gmal_entry_s *)gmal_resp->ms_ma;
413 while (num_entries > 0) {
414 if (strncmp
415 (gmal_entry->prefix, CT_GMAL_RESP_PREFIX_HTTP,
416 sizeof(gmal_entry->prefix)) == 0) {
417
418 /*
419 * if the IP address is terminating with a '/',
420 * remove it. *Byte 0 consists of the length
421 * of the string.
422 */
423 rsp_str = &(gmal_entry->prefix[0]);
424 if (rsp_str[gmal_entry->len - 1] == '/')
425 rsp_str[gmal_entry->len - 1] = 0;
426 /*
427 * copy IP Address to fabric
428 */
429 strncpy(bfa_fcs_port_get_fabric_ipaddr(port),
430 gmal_entry->ip_addr,
431 BFA_FCS_FABRIC_IPADDR_SZ);
432 break;
433 } else {
434 --num_entries;
435 ++gmal_entry;
436 }
437 }
438
439 bfa_sm_send_event(ms, MSSM_EVENT_RSP_OK);
440 return;
441 }
442
443 bfa_trc(port->fcs, cthdr->reason_code);
444 bfa_trc(port->fcs, cthdr->exp_code);
445 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
446}
447
448static void
449bfa_fcs_port_ms_sm_gfn_sending(struct bfa_fcs_port_ms_s *ms,
450 enum port_ms_event event)
451{
452 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
453 bfa_trc(ms->port->fcs, event);
454
455 switch (event) {
456 case MSSM_EVENT_FCXP_SENT:
457 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_gfn);
458 break;
459
460 case MSSM_EVENT_PORT_OFFLINE:
461 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline);
462 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ms->port),
463 &ms->fcxp_wqe);
464 break;
465
466 default:
467 bfa_sm_fault(ms->port->fcs, event);
468 }
469}
470
471static void
472bfa_fcs_port_ms_sm_gfn(struct bfa_fcs_port_ms_s *ms, enum port_ms_event event)
473{
474 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
475 bfa_trc(ms->port->fcs, event);
476
477 switch (event) {
478 case MSSM_EVENT_RSP_ERROR:
479 /*
480 * Start timer for a delayed retry
481 */
482 if (ms->retry_cnt++ < BFA_FCS_MS_CMD_MAX_RETRIES) {
483 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_gfn_retry);
484 ms->port->stats.ms_retries++;
485 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ms->port),
486 &ms->timer, bfa_fcs_port_ms_timeout, ms,
487 BFA_FCS_RETRY_TIMEOUT);
488 } else {
489 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_online);
490 ms->retry_cnt = 0;
491 }
492 break;
493
494 case MSSM_EVENT_RSP_OK:
495 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_online);
496 break;
497
498 case MSSM_EVENT_PORT_OFFLINE:
499 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline);
500 bfa_fcxp_discard(ms->fcxp);
501 break;
502
503 default:
504 bfa_sm_fault(ms->port->fcs, event);
505 }
506}
507
508static void
509bfa_fcs_port_ms_sm_gfn_retry(struct bfa_fcs_port_ms_s *ms,
510 enum port_ms_event event)
511{
512 bfa_trc(ms->port->fcs, ms->port->port_cfg.pwwn);
513 bfa_trc(ms->port->fcs, event);
514
515 switch (event) {
516 case MSSM_EVENT_TIMEOUT:
517 /*
518 * Retry Timer Expired. Re-send
519 */
520 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_gfn_sending);
521 bfa_fcs_port_ms_send_gfn(ms, NULL);
522 break;
523
524 case MSSM_EVENT_PORT_OFFLINE:
525 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline);
526 bfa_timer_stop(&ms->timer);
527 break;
528
529 default:
530 bfa_sm_fault(ms->port->fcs, event);
531 }
532}
533
534/**
535 * ms_pvt MS local functions
536 */
537
538static void
539bfa_fcs_port_ms_send_gfn(void *ms_cbarg, struct bfa_fcxp_s *fcxp_alloced)
540{
541 struct bfa_fcs_port_ms_s *ms = ms_cbarg;
542 struct bfa_fcs_port_s *port = ms->port;
543 struct fchs_s fchs;
544 int len;
545 struct bfa_fcxp_s *fcxp;
546
547 bfa_trc(port->fcs, port->pid);
548
549 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
550 if (!fcxp) {
551 bfa_fcxp_alloc_wait(port->fcs->bfa, &ms->fcxp_wqe,
552 bfa_fcs_port_ms_send_gfn, ms);
553 return;
554 }
555 ms->fcxp = fcxp;
556
557 len = fc_gfn_req_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
558 bfa_fcs_port_get_fcid(port),
559 bfa_lps_get_peer_nwwn(port->fabric->lps));
560
561 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
562 FC_CLASS_3, len, &fchs, bfa_fcs_port_ms_gfn_response,
563 (void *)ms, FC_MAX_PDUSZ, FC_FCCT_TOV);
564
565 bfa_sm_send_event(ms, MSSM_EVENT_FCXP_SENT);
566}
567
568static void
569bfa_fcs_port_ms_gfn_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
570 bfa_status_t req_status, u32 rsp_len,
571 u32 resid_len, struct fchs_s *rsp_fchs)
572{
573 struct bfa_fcs_port_ms_s *ms = (struct bfa_fcs_port_ms_s *)cbarg;
574 struct bfa_fcs_port_s *port = ms->port;
575 struct ct_hdr_s *cthdr = NULL;
576 wwn_t *gfn_resp;
577
578 bfa_trc(port->fcs, req_status);
579 bfa_trc(port->fcs, port->port_cfg.pwwn);
580
581 /*
582 * Sanity Checks
583 */
584 if (req_status != BFA_STATUS_OK) {
585 bfa_trc(port->fcs, req_status);
586 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
587 return;
588 }
589
590 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
591 cthdr->cmd_rsp_code = bfa_os_ntohs(cthdr->cmd_rsp_code);
592
593 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
594 gfn_resp = (wwn_t *) (cthdr + 1);
595 /*
596 * check if it has actually changed
597 */
598 if ((memcmp
599 ((void *)&bfa_fcs_port_get_fabric_name(port), gfn_resp,
600 sizeof(wwn_t)) != 0))
601 bfa_fcs_fabric_set_fabric_name(port->fabric, *gfn_resp);
602 bfa_sm_send_event(ms, MSSM_EVENT_RSP_OK);
603 return;
604 }
605
606 bfa_trc(port->fcs, cthdr->reason_code);
607 bfa_trc(port->fcs, cthdr->exp_code);
608 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
609}
610
611/**
612 * ms_pvt MS local functions
613 */
614
615static void
616bfa_fcs_port_ms_send_plogi(void *ms_cbarg, struct bfa_fcxp_s *fcxp_alloced)
617{
618 struct bfa_fcs_port_ms_s *ms = ms_cbarg;
619 struct bfa_fcs_port_s *port = ms->port;
620 struct fchs_s fchs;
621 int len;
622 struct bfa_fcxp_s *fcxp;
623
624 bfa_trc(port->fcs, port->pid);
625
626 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
627 if (!fcxp) {
628 port->stats.ms_plogi_alloc_wait++;
629 bfa_fcxp_alloc_wait(port->fcs->bfa, &ms->fcxp_wqe,
630 bfa_fcs_port_ms_send_plogi, ms);
631 return;
632 }
633 ms->fcxp = fcxp;
634
635 len = fc_plogi_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
636 bfa_os_hton3b(FC_MGMT_SERVER),
637 bfa_fcs_port_get_fcid(port), 0,
638 port->port_cfg.pwwn, port->port_cfg.nwwn,
639 bfa_fcport_get_maxfrsize(port->fcs->bfa));
640
641 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
642 FC_CLASS_3, len, &fchs, bfa_fcs_port_ms_plogi_response,
643 (void *)ms, FC_MAX_PDUSZ, FC_ELS_TOV);
644
645 port->stats.ms_plogi_sent++;
646 bfa_sm_send_event(ms, MSSM_EVENT_FCXP_SENT);
647}
648
649static void
650bfa_fcs_port_ms_plogi_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
651 void *cbarg, bfa_status_t req_status,
652 u32 rsp_len, u32 resid_len,
653 struct fchs_s *rsp_fchs)
654{
655 struct bfa_fcs_port_ms_s *ms = (struct bfa_fcs_port_ms_s *)cbarg;
656
657 struct bfa_fcs_port_s *port = ms->port;
658 struct fc_els_cmd_s *els_cmd;
659 struct fc_ls_rjt_s *ls_rjt;
660
661 bfa_trc(port->fcs, req_status);
662 bfa_trc(port->fcs, port->port_cfg.pwwn);
663
664 /*
665 * Sanity Checks
666 */
667 if (req_status != BFA_STATUS_OK) {
668 port->stats.ms_plogi_rsp_err++;
669 bfa_trc(port->fcs, req_status);
670 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
671 return;
672 }
673
674 els_cmd = (struct fc_els_cmd_s *) BFA_FCXP_RSP_PLD(fcxp);
675
676 switch (els_cmd->els_code) {
677
678 case FC_ELS_ACC:
679 if (rsp_len < sizeof(struct fc_logi_s)) {
680 bfa_trc(port->fcs, rsp_len);
681 port->stats.ms_plogi_acc_err++;
682 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
683 break;
684 }
685 port->stats.ms_plogi_accepts++;
686 bfa_sm_send_event(ms, MSSM_EVENT_RSP_OK);
687 break;
688
689 case FC_ELS_LS_RJT:
690 ls_rjt = (struct fc_ls_rjt_s *) BFA_FCXP_RSP_PLD(fcxp);
691
692 bfa_trc(port->fcs, ls_rjt->reason_code);
693 bfa_trc(port->fcs, ls_rjt->reason_code_expl);
694
695 port->stats.ms_rejects++;
696 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
697 break;
698
699 default:
700 port->stats.ms_plogi_unknown_rsp++;
701 bfa_trc(port->fcs, els_cmd->els_code);
702 bfa_sm_send_event(ms, MSSM_EVENT_RSP_ERROR);
703 }
704}
705
706static void
707bfa_fcs_port_ms_timeout(void *arg)
708{
709 struct bfa_fcs_port_ms_s *ms = (struct bfa_fcs_port_ms_s *)arg;
710
711 ms->port->stats.ms_timeouts++;
712 bfa_sm_send_event(ms, MSSM_EVENT_TIMEOUT);
713}
714
715
716void
717bfa_fcs_port_ms_init(struct bfa_fcs_port_s *port)
718{
719 struct bfa_fcs_port_ms_s *ms = BFA_FCS_GET_MS_FROM_PORT(port);
720
721 ms->port = port;
722 bfa_sm_set_state(ms, bfa_fcs_port_ms_sm_offline);
723
724 /*
725 * Invoke init routines of sub modules.
726 */
727 bfa_fcs_port_fdmi_init(ms);
728}
729
730void
731bfa_fcs_port_ms_offline(struct bfa_fcs_port_s *port)
732{
733 struct bfa_fcs_port_ms_s *ms = BFA_FCS_GET_MS_FROM_PORT(port);
734
735 ms->port = port;
736 bfa_sm_send_event(ms, MSSM_EVENT_PORT_OFFLINE);
737 bfa_fcs_port_fdmi_offline(ms);
738}
739
740void
741bfa_fcs_port_ms_online(struct bfa_fcs_port_s *port)
742{
743 struct bfa_fcs_port_ms_s *ms = BFA_FCS_GET_MS_FROM_PORT(port);
744
745 ms->port = port;
746 bfa_sm_send_event(ms, MSSM_EVENT_PORT_ONLINE);
747}
748
749void
750bfa_fcs_port_ms_fabric_rscn(struct bfa_fcs_port_s *port)
751{
752 struct bfa_fcs_port_ms_s *ms = BFA_FCS_GET_MS_FROM_PORT(port);
753
754 /*
755 * @todo. Handle this only when in Online state
756 */
757 if (bfa_sm_cmp_state(ms, bfa_fcs_port_ms_sm_online))
758 bfa_sm_send_event(ms, MSSM_EVENT_PORT_FABRIC_RSCN);
759}
diff --git a/drivers/scsi/bfa/n2n.c b/drivers/scsi/bfa/n2n.c
deleted file mode 100644
index 735456824346..000000000000
--- a/drivers/scsi/bfa/n2n.c
+++ /dev/null
@@ -1,105 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * n2n.c n2n implementation.
20 */
21#include <bfa.h>
22#include <bfa_svc.h>
23#include "fcs_lport.h"
24#include "fcs_rport.h"
25#include "fcs_trcmod.h"
26#include "lport_priv.h"
27
28BFA_TRC_FILE(FCS, N2N);
29
30/**
31 * Called by fcs/port to initialize N2N topology.
32 */
33void
34bfa_fcs_port_n2n_init(struct bfa_fcs_port_s *port)
35{
36}
37
38/**
39 * Called by fcs/port to notify transition to online state.
40 */
41void
42bfa_fcs_port_n2n_online(struct bfa_fcs_port_s *port)
43{
44 struct bfa_fcs_port_n2n_s *n2n_port = &port->port_topo.pn2n;
45 struct bfa_port_cfg_s *pcfg = &port->port_cfg;
46 struct bfa_fcs_rport_s *rport;
47
48 bfa_trc(port->fcs, pcfg->pwwn);
49
50 /*
51 * If our PWWN is > than that of the r-port, we have to initiate PLOGI
52 * and assign an Address. if not, we need to wait for its PLOGI.
53 *
54 * If our PWWN is < than that of the remote port, it will send a PLOGI
55 * with the PIDs assigned. The rport state machine take care of this
56 * incoming PLOGI.
57 */
58 if (memcmp
59 ((void *)&pcfg->pwwn, (void *)&n2n_port->rem_port_wwn,
60 sizeof(wwn_t)) > 0) {
61 port->pid = N2N_LOCAL_PID;
62 /**
63 * First, check if we know the device by pwwn.
64 */
65 rport = bfa_fcs_port_get_rport_by_pwwn(port,
66 n2n_port->rem_port_wwn);
67 if (rport) {
68 bfa_trc(port->fcs, rport->pid);
69 bfa_trc(port->fcs, rport->pwwn);
70 rport->pid = N2N_REMOTE_PID;
71 bfa_fcs_rport_online(rport);
72 return;
73 }
74
75 /*
76 * In n2n there can be only one rport. Delete the old one whose
77 * pid should be zero, because it is offline.
78 */
79 if (port->num_rports > 0) {
80 rport = bfa_fcs_port_get_rport_by_pid(port, 0);
81 bfa_assert(rport != NULL);
82 if (rport) {
83 bfa_trc(port->fcs, rport->pwwn);
84 bfa_fcs_rport_delete(rport);
85 }
86 }
87 bfa_fcs_rport_create(port, N2N_REMOTE_PID);
88 }
89}
90
91/**
92 * Called by fcs/port to notify transition to offline state.
93 */
94void
95bfa_fcs_port_n2n_offline(struct bfa_fcs_port_s *port)
96{
97 struct bfa_fcs_port_n2n_s *n2n_port = &port->port_topo.pn2n;
98
99 bfa_trc(port->fcs, port->pid);
100 port->pid = 0;
101 n2n_port->rem_port_wwn = 0;
102 n2n_port->reply_oxid = 0;
103}
104
105
diff --git a/drivers/scsi/bfa/ns.c b/drivers/scsi/bfa/ns.c
deleted file mode 100644
index ae0edcc86ed5..000000000000
--- a/drivers/scsi/bfa/ns.c
+++ /dev/null
@@ -1,1242 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * @page ns_sm_info VPORT NS State Machine
20 *
21 * @section ns_sm_interactions VPORT NS State Machine Interactions
22 *
23 * @section ns_sm VPORT NS State Machine
24 * img ns_sm.jpg
25 */
26#include <bfa.h>
27#include <bfa_svc.h>
28#include <bfa_iocfc.h>
29#include "fcs_lport.h"
30#include "fcs_rport.h"
31#include "fcs_trcmod.h"
32#include "fcs_fcxp.h"
33#include "fcs.h"
34#include "lport_priv.h"
35
36BFA_TRC_FILE(FCS, NS);
37
38/*
39 * forward declarations
40 */
41static void bfa_fcs_port_ns_send_plogi(void *ns_cbarg,
42 struct bfa_fcxp_s *fcxp_alloced);
43static void bfa_fcs_port_ns_send_rspn_id(void *ns_cbarg,
44 struct bfa_fcxp_s *fcxp_alloced);
45static void bfa_fcs_port_ns_send_rft_id(void *ns_cbarg,
46 struct bfa_fcxp_s *fcxp_alloced);
47static void bfa_fcs_port_ns_send_rff_id(void *ns_cbarg,
48 struct bfa_fcxp_s *fcxp_alloced);
49static void bfa_fcs_port_ns_send_gid_ft(void *ns_cbarg,
50 struct bfa_fcxp_s *fcxp_alloced);
51static void bfa_fcs_port_ns_timeout(void *arg);
52static void bfa_fcs_port_ns_plogi_response(void *fcsarg,
53 struct bfa_fcxp_s *fcxp,
54 void *cbarg,
55 bfa_status_t req_status,
56 u32 rsp_len,
57 u32 resid_len,
58 struct fchs_s *rsp_fchs);
59static void bfa_fcs_port_ns_rspn_id_response(void *fcsarg,
60 struct bfa_fcxp_s *fcxp,
61 void *cbarg,
62 bfa_status_t req_status,
63 u32 rsp_len,
64 u32 resid_len,
65 struct fchs_s *rsp_fchs);
66static void bfa_fcs_port_ns_rft_id_response(void *fcsarg,
67 struct bfa_fcxp_s *fcxp,
68 void *cbarg,
69 bfa_status_t req_status,
70 u32 rsp_len,
71 u32 resid_len,
72 struct fchs_s *rsp_fchs);
73static void bfa_fcs_port_ns_rff_id_response(void *fcsarg,
74 struct bfa_fcxp_s *fcxp,
75 void *cbarg,
76 bfa_status_t req_status,
77 u32 rsp_len,
78 u32 resid_len,
79 struct fchs_s *rsp_fchs);
80static void bfa_fcs_port_ns_gid_ft_response(void *fcsarg,
81 struct bfa_fcxp_s *fcxp,
82 void *cbarg,
83 bfa_status_t req_status,
84 u32 rsp_len,
85 u32 resid_len,
86 struct fchs_s *rsp_fchs);
87static void bfa_fcs_port_ns_process_gidft_pids(struct bfa_fcs_port_s *port,
88 u32 *pid_buf,
89 u32 n_pids);
90
91static void bfa_fcs_port_ns_boot_target_disc(struct bfa_fcs_port_s *port);
92/**
93 * fcs_ns_sm FCS nameserver interface state machine
94 */
95
96/**
97 * VPort NS State Machine events
98 */
99enum vport_ns_event {
100 NSSM_EVENT_PORT_ONLINE = 1,
101 NSSM_EVENT_PORT_OFFLINE = 2,
102 NSSM_EVENT_PLOGI_SENT = 3,
103 NSSM_EVENT_RSP_OK = 4,
104 NSSM_EVENT_RSP_ERROR = 5,
105 NSSM_EVENT_TIMEOUT = 6,
106 NSSM_EVENT_NS_QUERY = 7,
107 NSSM_EVENT_RSPNID_SENT = 8,
108 NSSM_EVENT_RFTID_SENT = 9,
109 NSSM_EVENT_RFFID_SENT = 10,
110 NSSM_EVENT_GIDFT_SENT = 11,
111};
112
113static void bfa_fcs_port_ns_sm_offline(struct bfa_fcs_port_ns_s *ns,
114 enum vport_ns_event event);
115static void bfa_fcs_port_ns_sm_plogi_sending(struct bfa_fcs_port_ns_s *ns,
116 enum vport_ns_event event);
117static void bfa_fcs_port_ns_sm_plogi(struct bfa_fcs_port_ns_s *ns,
118 enum vport_ns_event event);
119static void bfa_fcs_port_ns_sm_plogi_retry(struct bfa_fcs_port_ns_s *ns,
120 enum vport_ns_event event);
121static void bfa_fcs_port_ns_sm_sending_rspn_id(struct bfa_fcs_port_ns_s *ns,
122 enum vport_ns_event event);
123static void bfa_fcs_port_ns_sm_rspn_id(struct bfa_fcs_port_ns_s *ns,
124 enum vport_ns_event event);
125static void bfa_fcs_port_ns_sm_rspn_id_retry(struct bfa_fcs_port_ns_s *ns,
126 enum vport_ns_event event);
127static void bfa_fcs_port_ns_sm_sending_rft_id(struct bfa_fcs_port_ns_s *ns,
128 enum vport_ns_event event);
129static void bfa_fcs_port_ns_sm_rft_id_retry(struct bfa_fcs_port_ns_s *ns,
130 enum vport_ns_event event);
131static void bfa_fcs_port_ns_sm_rft_id(struct bfa_fcs_port_ns_s *ns,
132 enum vport_ns_event event);
133static void bfa_fcs_port_ns_sm_sending_rff_id(struct bfa_fcs_port_ns_s *ns,
134 enum vport_ns_event event);
135static void bfa_fcs_port_ns_sm_rff_id_retry(struct bfa_fcs_port_ns_s *ns,
136 enum vport_ns_event event);
137static void bfa_fcs_port_ns_sm_rff_id(struct bfa_fcs_port_ns_s *ns,
138 enum vport_ns_event event);
139static void bfa_fcs_port_ns_sm_sending_gid_ft(struct bfa_fcs_port_ns_s *ns,
140 enum vport_ns_event event);
141static void bfa_fcs_port_ns_sm_gid_ft(struct bfa_fcs_port_ns_s *ns,
142 enum vport_ns_event event);
143static void bfa_fcs_port_ns_sm_gid_ft_retry(struct bfa_fcs_port_ns_s *ns,
144 enum vport_ns_event event);
145static void bfa_fcs_port_ns_sm_online(struct bfa_fcs_port_ns_s *ns,
146 enum vport_ns_event event);
147/**
148 * Start in offline state - awaiting linkup
149 */
150static void
151bfa_fcs_port_ns_sm_offline(struct bfa_fcs_port_ns_s *ns,
152 enum vport_ns_event event)
153{
154 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
155 bfa_trc(ns->port->fcs, event);
156
157 switch (event) {
158 case NSSM_EVENT_PORT_ONLINE:
159 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_plogi_sending);
160 bfa_fcs_port_ns_send_plogi(ns, NULL);
161 break;
162
163 case NSSM_EVENT_PORT_OFFLINE:
164 break;
165
166 default:
167 bfa_sm_fault(ns->port->fcs, event);
168 }
169}
170
171static void
172bfa_fcs_port_ns_sm_plogi_sending(struct bfa_fcs_port_ns_s *ns,
173 enum vport_ns_event event)
174{
175 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
176 bfa_trc(ns->port->fcs, event);
177
178 switch (event) {
179 case NSSM_EVENT_PLOGI_SENT:
180 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_plogi);
181 break;
182
183 case NSSM_EVENT_PORT_OFFLINE:
184 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
185 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
186 &ns->fcxp_wqe);
187 break;
188
189 default:
190 bfa_sm_fault(ns->port->fcs, event);
191 }
192}
193
194static void
195bfa_fcs_port_ns_sm_plogi(struct bfa_fcs_port_ns_s *ns,
196 enum vport_ns_event event)
197{
198 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
199 bfa_trc(ns->port->fcs, event);
200
201 switch (event) {
202 case NSSM_EVENT_RSP_ERROR:
203 /*
204 * Start timer for a delayed retry
205 */
206 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_plogi_retry);
207 ns->port->stats.ns_retries++;
208 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), &ns->timer,
209 bfa_fcs_port_ns_timeout, ns,
210 BFA_FCS_RETRY_TIMEOUT);
211 break;
212
213 case NSSM_EVENT_RSP_OK:
214 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_sending_rspn_id);
215 bfa_fcs_port_ns_send_rspn_id(ns, NULL);
216 break;
217
218 case NSSM_EVENT_PORT_OFFLINE:
219 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
220 bfa_fcxp_discard(ns->fcxp);
221 break;
222
223 default:
224 bfa_sm_fault(ns->port->fcs, event);
225 }
226}
227
228static void
229bfa_fcs_port_ns_sm_plogi_retry(struct bfa_fcs_port_ns_s *ns,
230 enum vport_ns_event event)
231{
232 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
233 bfa_trc(ns->port->fcs, event);
234
235 switch (event) {
236 case NSSM_EVENT_TIMEOUT:
237 /*
238 * Retry Timer Expired. Re-send
239 */
240 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_plogi_sending);
241 bfa_fcs_port_ns_send_plogi(ns, NULL);
242 break;
243
244 case NSSM_EVENT_PORT_OFFLINE:
245 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
246 bfa_timer_stop(&ns->timer);
247 break;
248
249 default:
250 bfa_sm_fault(ns->port->fcs, event);
251 }
252}
253
254static void
255bfa_fcs_port_ns_sm_sending_rspn_id(struct bfa_fcs_port_ns_s *ns,
256 enum vport_ns_event event)
257{
258 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
259 bfa_trc(ns->port->fcs, event);
260
261 switch (event) {
262 case NSSM_EVENT_RSPNID_SENT:
263 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_rspn_id);
264 break;
265
266 case NSSM_EVENT_PORT_OFFLINE:
267 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
268 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
269 &ns->fcxp_wqe);
270 break;
271
272 default:
273 bfa_sm_fault(ns->port->fcs, event);
274 }
275}
276
277static void
278bfa_fcs_port_ns_sm_rspn_id(struct bfa_fcs_port_ns_s *ns,
279 enum vport_ns_event event)
280{
281 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
282 bfa_trc(ns->port->fcs, event);
283
284 switch (event) {
285 case NSSM_EVENT_RSP_ERROR:
286 /*
287 * Start timer for a delayed retry
288 */
289 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_rspn_id_retry);
290 ns->port->stats.ns_retries++;
291 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), &ns->timer,
292 bfa_fcs_port_ns_timeout, ns,
293 BFA_FCS_RETRY_TIMEOUT);
294 break;
295
296 case NSSM_EVENT_RSP_OK:
297 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_sending_rft_id);
298 bfa_fcs_port_ns_send_rft_id(ns, NULL);
299 break;
300
301 case NSSM_EVENT_PORT_OFFLINE:
302 bfa_fcxp_discard(ns->fcxp);
303 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
304 break;
305
306 default:
307 bfa_sm_fault(ns->port->fcs, event);
308 }
309}
310
311static void
312bfa_fcs_port_ns_sm_rspn_id_retry(struct bfa_fcs_port_ns_s *ns,
313 enum vport_ns_event event)
314{
315 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
316 bfa_trc(ns->port->fcs, event);
317
318 switch (event) {
319 case NSSM_EVENT_TIMEOUT:
320 /*
321 * Retry Timer Expired. Re-send
322 */
323 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_sending_rspn_id);
324 bfa_fcs_port_ns_send_rspn_id(ns, NULL);
325 break;
326
327 case NSSM_EVENT_PORT_OFFLINE:
328 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
329 bfa_timer_stop(&ns->timer);
330 break;
331
332 default:
333 bfa_sm_fault(ns->port->fcs, event);
334 }
335}
336
337static void
338bfa_fcs_port_ns_sm_sending_rft_id(struct bfa_fcs_port_ns_s *ns,
339 enum vport_ns_event event)
340{
341 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
342 bfa_trc(ns->port->fcs, event);
343
344 switch (event) {
345 case NSSM_EVENT_RFTID_SENT:
346 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_rft_id);
347 break;
348
349 case NSSM_EVENT_PORT_OFFLINE:
350 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
351 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
352 &ns->fcxp_wqe);
353 break;
354
355 default:
356 bfa_sm_fault(ns->port->fcs, event);
357 }
358}
359
360static void
361bfa_fcs_port_ns_sm_rft_id(struct bfa_fcs_port_ns_s *ns,
362 enum vport_ns_event event)
363{
364 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
365 bfa_trc(ns->port->fcs, event);
366
367 switch (event) {
368 case NSSM_EVENT_RSP_OK:
369 /*
370 * Now move to register FC4 Features
371 */
372 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_sending_rff_id);
373 bfa_fcs_port_ns_send_rff_id(ns, NULL);
374 break;
375
376 case NSSM_EVENT_RSP_ERROR:
377 /*
378 * Start timer for a delayed retry
379 */
380 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_rft_id_retry);
381 ns->port->stats.ns_retries++;
382 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), &ns->timer,
383 bfa_fcs_port_ns_timeout, ns,
384 BFA_FCS_RETRY_TIMEOUT);
385 break;
386
387 case NSSM_EVENT_PORT_OFFLINE:
388 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
389 bfa_fcxp_discard(ns->fcxp);
390 break;
391
392 default:
393 bfa_sm_fault(ns->port->fcs, event);
394 }
395}
396
397static void
398bfa_fcs_port_ns_sm_rft_id_retry(struct bfa_fcs_port_ns_s *ns,
399 enum vport_ns_event event)
400{
401 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
402 bfa_trc(ns->port->fcs, event);
403
404 switch (event) {
405 case NSSM_EVENT_TIMEOUT:
406 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_sending_rft_id);
407 bfa_fcs_port_ns_send_rft_id(ns, NULL);
408 break;
409
410 case NSSM_EVENT_PORT_OFFLINE:
411 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
412 bfa_timer_stop(&ns->timer);
413 break;
414
415 default:
416 bfa_sm_fault(ns->port->fcs, event);
417 }
418}
419
420static void
421bfa_fcs_port_ns_sm_sending_rff_id(struct bfa_fcs_port_ns_s *ns,
422 enum vport_ns_event event)
423{
424 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
425 bfa_trc(ns->port->fcs, event);
426
427 switch (event) {
428 case NSSM_EVENT_RFFID_SENT:
429 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_rff_id);
430 break;
431
432 case NSSM_EVENT_PORT_OFFLINE:
433 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
434 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
435 &ns->fcxp_wqe);
436 break;
437
438 default:
439 bfa_sm_fault(ns->port->fcs, event);
440 }
441}
442
443static void
444bfa_fcs_port_ns_sm_rff_id(struct bfa_fcs_port_ns_s *ns,
445 enum vport_ns_event event)
446{
447 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
448 bfa_trc(ns->port->fcs, event);
449
450 switch (event) {
451 case NSSM_EVENT_RSP_OK:
452
453 /*
454 * If min cfg mode is enabled, we donot initiate rport
455 * discovery with the fabric. Instead, we will retrieve the
456 * boot targets from HAL/FW.
457 */
458 if (__fcs_min_cfg(ns->port->fcs)) {
459 bfa_fcs_port_ns_boot_target_disc(ns->port);
460 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_online);
461 return;
462 }
463
464 /*
465 * If the port role is Initiator Mode issue NS query.
466 * If it is Target Mode, skip this and go to online.
467 */
468 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns->port)) {
469 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_sending_gid_ft);
470 bfa_fcs_port_ns_send_gid_ft(ns, NULL);
471 } else if (BFA_FCS_VPORT_IS_TARGET_MODE(ns->port)) {
472 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_online);
473 }
474 /*
475 * kick off mgmt srvr state machine
476 */
477 bfa_fcs_port_ms_online(ns->port);
478 break;
479
480 case NSSM_EVENT_RSP_ERROR:
481 /*
482 * Start timer for a delayed retry
483 */
484 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_rff_id_retry);
485 ns->port->stats.ns_retries++;
486 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), &ns->timer,
487 bfa_fcs_port_ns_timeout, ns,
488 BFA_FCS_RETRY_TIMEOUT);
489 break;
490
491 case NSSM_EVENT_PORT_OFFLINE:
492 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
493 bfa_fcxp_discard(ns->fcxp);
494 break;
495
496 default:
497 bfa_sm_fault(ns->port->fcs, event);
498 }
499}
500
501static void
502bfa_fcs_port_ns_sm_rff_id_retry(struct bfa_fcs_port_ns_s *ns,
503 enum vport_ns_event event)
504{
505 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
506 bfa_trc(ns->port->fcs, event);
507
508 switch (event) {
509 case NSSM_EVENT_TIMEOUT:
510 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_sending_rff_id);
511 bfa_fcs_port_ns_send_rff_id(ns, NULL);
512 break;
513
514 case NSSM_EVENT_PORT_OFFLINE:
515 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
516 bfa_timer_stop(&ns->timer);
517 break;
518
519 default:
520 bfa_sm_fault(ns->port->fcs, event);
521 }
522}
523static void
524bfa_fcs_port_ns_sm_sending_gid_ft(struct bfa_fcs_port_ns_s *ns,
525 enum vport_ns_event event)
526{
527 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
528 bfa_trc(ns->port->fcs, event);
529
530 switch (event) {
531 case NSSM_EVENT_GIDFT_SENT:
532 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_gid_ft);
533 break;
534
535 case NSSM_EVENT_PORT_OFFLINE:
536 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
537 bfa_fcxp_walloc_cancel(BFA_FCS_GET_HAL_FROM_PORT(ns->port),
538 &ns->fcxp_wqe);
539 break;
540
541 default:
542 bfa_sm_fault(ns->port->fcs, event);
543 }
544}
545
546static void
547bfa_fcs_port_ns_sm_gid_ft(struct bfa_fcs_port_ns_s *ns,
548 enum vport_ns_event event)
549{
550 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
551 bfa_trc(ns->port->fcs, event);
552
553 switch (event) {
554 case NSSM_EVENT_RSP_OK:
555 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_online);
556 break;
557
558 case NSSM_EVENT_RSP_ERROR:
559 /*
560 * TBD: for certain reject codes, we don't need to retry
561 */
562 /*
563 * Start timer for a delayed retry
564 */
565 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_gid_ft_retry);
566 ns->port->stats.ns_retries++;
567 bfa_timer_start(BFA_FCS_GET_HAL_FROM_PORT(ns->port), &ns->timer,
568 bfa_fcs_port_ns_timeout, ns,
569 BFA_FCS_RETRY_TIMEOUT);
570 break;
571
572 case NSSM_EVENT_PORT_OFFLINE:
573 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
574 bfa_fcxp_discard(ns->fcxp);
575 break;
576
577 default:
578 bfa_sm_fault(ns->port->fcs, event);
579 }
580}
581
582static void
583bfa_fcs_port_ns_sm_gid_ft_retry(struct bfa_fcs_port_ns_s *ns,
584 enum vport_ns_event event)
585{
586 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
587 bfa_trc(ns->port->fcs, event);
588
589 switch (event) {
590 case NSSM_EVENT_TIMEOUT:
591 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_sending_gid_ft);
592 bfa_fcs_port_ns_send_gid_ft(ns, NULL);
593 break;
594
595 case NSSM_EVENT_PORT_OFFLINE:
596 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
597 bfa_timer_stop(&ns->timer);
598 break;
599
600 default:
601 bfa_sm_fault(ns->port->fcs, event);
602 }
603}
604
605static void
606bfa_fcs_port_ns_sm_online(struct bfa_fcs_port_ns_s *ns,
607 enum vport_ns_event event)
608{
609 bfa_trc(ns->port->fcs, ns->port->port_cfg.pwwn);
610 bfa_trc(ns->port->fcs, event);
611
612 switch (event) {
613 case NSSM_EVENT_PORT_OFFLINE:
614 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
615 break;
616
617 case NSSM_EVENT_NS_QUERY:
618 /*
619 * If the port role is Initiator Mode issue NS query.
620 * If it is Target Mode, skip this and go to online.
621 */
622 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns->port)) {
623 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_sending_gid_ft);
624 bfa_fcs_port_ns_send_gid_ft(ns, NULL);
625 };
626 break;
627
628 default:
629 bfa_sm_fault(ns->port->fcs, event);
630 }
631}
632
633
634
635/**
636 * ns_pvt Nameserver local functions
637 */
638
639static void
640bfa_fcs_port_ns_send_plogi(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
641{
642 struct bfa_fcs_port_ns_s *ns = ns_cbarg;
643 struct bfa_fcs_port_s *port = ns->port;
644 struct fchs_s fchs;
645 int len;
646 struct bfa_fcxp_s *fcxp;
647
648 bfa_trc(port->fcs, port->pid);
649
650 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
651 if (!fcxp) {
652 port->stats.ns_plogi_alloc_wait++;
653 bfa_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe,
654 bfa_fcs_port_ns_send_plogi, ns);
655 return;
656 }
657 ns->fcxp = fcxp;
658
659 len = fc_plogi_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
660 bfa_os_hton3b(FC_NAME_SERVER),
661 bfa_fcs_port_get_fcid(port), 0,
662 port->port_cfg.pwwn, port->port_cfg.nwwn,
663 bfa_fcport_get_maxfrsize(port->fcs->bfa));
664
665 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
666 FC_CLASS_3, len, &fchs, bfa_fcs_port_ns_plogi_response,
667 (void *)ns, FC_MAX_PDUSZ, FC_ELS_TOV);
668 port->stats.ns_plogi_sent++;
669
670 bfa_sm_send_event(ns, NSSM_EVENT_PLOGI_SENT);
671}
672
673static void
674bfa_fcs_port_ns_plogi_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
675 void *cbarg, bfa_status_t req_status,
676 u32 rsp_len, u32 resid_len,
677 struct fchs_s *rsp_fchs)
678{
679 struct bfa_fcs_port_ns_s *ns = (struct bfa_fcs_port_ns_s *)cbarg;
680 struct bfa_fcs_port_s *port = ns->port;
681 /* struct fc_logi_s *plogi_resp; */
682 struct fc_els_cmd_s *els_cmd;
683 struct fc_ls_rjt_s *ls_rjt;
684
685 bfa_trc(port->fcs, req_status);
686 bfa_trc(port->fcs, port->port_cfg.pwwn);
687
688 /*
689 * Sanity Checks
690 */
691 if (req_status != BFA_STATUS_OK) {
692 bfa_trc(port->fcs, req_status);
693 port->stats.ns_plogi_rsp_err++;
694 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
695 return;
696 }
697
698 els_cmd = (struct fc_els_cmd_s *) BFA_FCXP_RSP_PLD(fcxp);
699
700 switch (els_cmd->els_code) {
701
702 case FC_ELS_ACC:
703 if (rsp_len < sizeof(struct fc_logi_s)) {
704 bfa_trc(port->fcs, rsp_len);
705 port->stats.ns_plogi_acc_err++;
706 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
707 break;
708 }
709 port->stats.ns_plogi_accepts++;
710 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
711 break;
712
713 case FC_ELS_LS_RJT:
714 ls_rjt = (struct fc_ls_rjt_s *) BFA_FCXP_RSP_PLD(fcxp);
715
716 bfa_trc(port->fcs, ls_rjt->reason_code);
717 bfa_trc(port->fcs, ls_rjt->reason_code_expl);
718
719 port->stats.ns_rejects++;
720
721 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
722 break;
723
724 default:
725 port->stats.ns_plogi_unknown_rsp++;
726 bfa_trc(port->fcs, els_cmd->els_code);
727 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
728 }
729}
730
731/**
732 * Register the symbolic port name.
733 */
734static void
735bfa_fcs_port_ns_send_rspn_id(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
736{
737 struct bfa_fcs_port_ns_s *ns = ns_cbarg;
738 struct bfa_fcs_port_s *port = ns->port;
739 struct fchs_s fchs;
740 int len;
741 struct bfa_fcxp_s *fcxp;
742 u8 symbl[256];
743 u8 *psymbl = &symbl[0];
744
745 bfa_os_memset(symbl, 0, sizeof(symbl));
746
747 bfa_trc(port->fcs, port->port_cfg.pwwn);
748
749 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
750 if (!fcxp) {
751 port->stats.ns_rspnid_alloc_wait++;
752 bfa_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe,
753 bfa_fcs_port_ns_send_rspn_id, ns);
754 return;
755 }
756 ns->fcxp = fcxp;
757
758 /*
759 * for V-Port, form a Port Symbolic Name
760 */
761 if (port->vport) {
762 /**For Vports,
763 * we append the vport's port symbolic name to that of the base port.
764 */
765
766 strncpy((char *)psymbl,
767 (char *)
768 &(bfa_fcs_port_get_psym_name
769 (bfa_fcs_get_base_port(port->fcs))),
770 strlen((char *)
771 &bfa_fcs_port_get_psym_name(bfa_fcs_get_base_port
772 (port->fcs))));
773
774 /*
775 * Ensure we have a null terminating string.
776 */
777 ((char *)
778 psymbl)[strlen((char *)
779 &bfa_fcs_port_get_psym_name
780 (bfa_fcs_get_base_port(port->fcs)))] = 0;
781
782 strncat((char *)psymbl,
783 (char *)&(bfa_fcs_port_get_psym_name(port)),
784 strlen((char *)&bfa_fcs_port_get_psym_name(port)));
785 } else {
786 psymbl = (u8 *) &(bfa_fcs_port_get_psym_name(port));
787 }
788
789 len = fc_rspnid_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
790 bfa_fcs_port_get_fcid(port), 0, psymbl);
791
792 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
793 FC_CLASS_3, len, &fchs, bfa_fcs_port_ns_rspn_id_response,
794 (void *)ns, FC_MAX_PDUSZ, FC_FCCT_TOV);
795
796 port->stats.ns_rspnid_sent++;
797
798 bfa_sm_send_event(ns, NSSM_EVENT_RSPNID_SENT);
799}
800
801static void
802bfa_fcs_port_ns_rspn_id_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
803 void *cbarg, bfa_status_t req_status,
804 u32 rsp_len, u32 resid_len,
805 struct fchs_s *rsp_fchs)
806{
807 struct bfa_fcs_port_ns_s *ns = (struct bfa_fcs_port_ns_s *)cbarg;
808 struct bfa_fcs_port_s *port = ns->port;
809 struct ct_hdr_s *cthdr = NULL;
810
811 bfa_trc(port->fcs, port->port_cfg.pwwn);
812
813 /*
814 * Sanity Checks
815 */
816 if (req_status != BFA_STATUS_OK) {
817 bfa_trc(port->fcs, req_status);
818 port->stats.ns_rspnid_rsp_err++;
819 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
820 return;
821 }
822
823 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
824 cthdr->cmd_rsp_code = bfa_os_ntohs(cthdr->cmd_rsp_code);
825
826 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
827 port->stats.ns_rspnid_accepts++;
828 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
829 return;
830 }
831
832 port->stats.ns_rspnid_rejects++;
833 bfa_trc(port->fcs, cthdr->reason_code);
834 bfa_trc(port->fcs, cthdr->exp_code);
835 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
836}
837
838/**
839 * Register FC4-Types
840 * TBD, Need to retrieve this from the OS driver, in case IPFC is enabled ?
841 */
842static void
843bfa_fcs_port_ns_send_rft_id(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
844{
845 struct bfa_fcs_port_ns_s *ns = ns_cbarg;
846 struct bfa_fcs_port_s *port = ns->port;
847 struct fchs_s fchs;
848 int len;
849 struct bfa_fcxp_s *fcxp;
850
851 bfa_trc(port->fcs, port->port_cfg.pwwn);
852
853 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
854 if (!fcxp) {
855 port->stats.ns_rftid_alloc_wait++;
856 bfa_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe,
857 bfa_fcs_port_ns_send_rft_id, ns);
858 return;
859 }
860 ns->fcxp = fcxp;
861
862 len = fc_rftid_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
863 bfa_fcs_port_get_fcid(port), 0,
864 port->port_cfg.roles);
865
866 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
867 FC_CLASS_3, len, &fchs, bfa_fcs_port_ns_rft_id_response,
868 (void *)ns, FC_MAX_PDUSZ, FC_FCCT_TOV);
869
870 port->stats.ns_rftid_sent++;
871 bfa_sm_send_event(ns, NSSM_EVENT_RFTID_SENT);
872}
873
874static void
875bfa_fcs_port_ns_rft_id_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
876 void *cbarg, bfa_status_t req_status,
877 u32 rsp_len, u32 resid_len,
878 struct fchs_s *rsp_fchs)
879{
880 struct bfa_fcs_port_ns_s *ns = (struct bfa_fcs_port_ns_s *)cbarg;
881 struct bfa_fcs_port_s *port = ns->port;
882 struct ct_hdr_s *cthdr = NULL;
883
884 bfa_trc(port->fcs, port->port_cfg.pwwn);
885
886 /*
887 * Sanity Checks
888 */
889 if (req_status != BFA_STATUS_OK) {
890 bfa_trc(port->fcs, req_status);
891 port->stats.ns_rftid_rsp_err++;
892 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
893 return;
894 }
895
896 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
897 cthdr->cmd_rsp_code = bfa_os_ntohs(cthdr->cmd_rsp_code);
898
899 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
900 port->stats.ns_rftid_accepts++;
901 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
902 return;
903 }
904
905 port->stats.ns_rftid_rejects++;
906 bfa_trc(port->fcs, cthdr->reason_code);
907 bfa_trc(port->fcs, cthdr->exp_code);
908 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
909}
910
911/**
912* Register FC4-Features : Should be done after RFT_ID
913 */
914static void
915bfa_fcs_port_ns_send_rff_id(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
916{
917 struct bfa_fcs_port_ns_s *ns = ns_cbarg;
918 struct bfa_fcs_port_s *port = ns->port;
919 struct fchs_s fchs;
920 int len;
921 struct bfa_fcxp_s *fcxp;
922 u8 fc4_ftrs = 0;
923
924 bfa_trc(port->fcs, port->port_cfg.pwwn);
925
926 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
927 if (!fcxp) {
928 port->stats.ns_rffid_alloc_wait++;
929 bfa_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe,
930 bfa_fcs_port_ns_send_rff_id, ns);
931 return;
932 }
933 ns->fcxp = fcxp;
934
935 if (BFA_FCS_VPORT_IS_INITIATOR_MODE(ns->port))
936 fc4_ftrs = FC_GS_FCP_FC4_FEATURE_INITIATOR;
937 else if (BFA_FCS_VPORT_IS_TARGET_MODE(ns->port))
938 fc4_ftrs = FC_GS_FCP_FC4_FEATURE_TARGET;
939
940 len = fc_rffid_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
941 bfa_fcs_port_get_fcid(port), 0, FC_TYPE_FCP,
942 fc4_ftrs);
943
944 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
945 FC_CLASS_3, len, &fchs, bfa_fcs_port_ns_rff_id_response,
946 (void *)ns, FC_MAX_PDUSZ, FC_FCCT_TOV);
947
948 port->stats.ns_rffid_sent++;
949 bfa_sm_send_event(ns, NSSM_EVENT_RFFID_SENT);
950}
951
952static void
953bfa_fcs_port_ns_rff_id_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
954 void *cbarg, bfa_status_t req_status,
955 u32 rsp_len, u32 resid_len,
956 struct fchs_s *rsp_fchs)
957{
958 struct bfa_fcs_port_ns_s *ns = (struct bfa_fcs_port_ns_s *)cbarg;
959 struct bfa_fcs_port_s *port = ns->port;
960 struct ct_hdr_s *cthdr = NULL;
961
962 bfa_trc(port->fcs, port->port_cfg.pwwn);
963
964 /*
965 * Sanity Checks
966 */
967 if (req_status != BFA_STATUS_OK) {
968 bfa_trc(port->fcs, req_status);
969 port->stats.ns_rffid_rsp_err++;
970 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
971 return;
972 }
973
974 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
975 cthdr->cmd_rsp_code = bfa_os_ntohs(cthdr->cmd_rsp_code);
976
977 if (cthdr->cmd_rsp_code == CT_RSP_ACCEPT) {
978 port->stats.ns_rffid_accepts++;
979 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
980 return;
981 }
982
983 port->stats.ns_rffid_rejects++;
984 bfa_trc(port->fcs, cthdr->reason_code);
985 bfa_trc(port->fcs, cthdr->exp_code);
986
987 if (cthdr->reason_code == CT_RSN_NOT_SUPP) {
988 /*
989 * if this command is not supported, we don't retry
990 */
991 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
992 } else {
993 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
994 }
995}
996
997/**
998 * Query Fabric for FC4-Types Devices.
999 *
1000* TBD : Need to use a local (FCS private) response buffer, since the response
1001 * can be larger than 2K.
1002 */
1003static void
1004bfa_fcs_port_ns_send_gid_ft(void *ns_cbarg, struct bfa_fcxp_s *fcxp_alloced)
1005{
1006 struct bfa_fcs_port_ns_s *ns = ns_cbarg;
1007 struct bfa_fcs_port_s *port = ns->port;
1008 struct fchs_s fchs;
1009 int len;
1010 struct bfa_fcxp_s *fcxp;
1011
1012 bfa_trc(port->fcs, port->pid);
1013
1014 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
1015 if (!fcxp) {
1016 port->stats.ns_gidft_alloc_wait++;
1017 bfa_fcxp_alloc_wait(port->fcs->bfa, &ns->fcxp_wqe,
1018 bfa_fcs_port_ns_send_gid_ft, ns);
1019 return;
1020 }
1021 ns->fcxp = fcxp;
1022
1023 /*
1024 * This query is only initiated for FCP initiator mode.
1025 */
1026 len = fc_gid_ft_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), ns->port->pid,
1027 FC_TYPE_FCP);
1028
1029 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
1030 FC_CLASS_3, len, &fchs, bfa_fcs_port_ns_gid_ft_response,
1031 (void *)ns, bfa_fcxp_get_maxrsp(port->fcs->bfa),
1032 FC_FCCT_TOV);
1033
1034 port->stats.ns_gidft_sent++;
1035
1036 bfa_sm_send_event(ns, NSSM_EVENT_GIDFT_SENT);
1037}
1038
1039static void
1040bfa_fcs_port_ns_gid_ft_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
1041 void *cbarg, bfa_status_t req_status,
1042 u32 rsp_len, u32 resid_len,
1043 struct fchs_s *rsp_fchs)
1044{
1045 struct bfa_fcs_port_ns_s *ns = (struct bfa_fcs_port_ns_s *)cbarg;
1046 struct bfa_fcs_port_s *port = ns->port;
1047 struct ct_hdr_s *cthdr = NULL;
1048 u32 n_pids;
1049
1050 bfa_trc(port->fcs, port->port_cfg.pwwn);
1051
1052 /*
1053 * Sanity Checks
1054 */
1055 if (req_status != BFA_STATUS_OK) {
1056 bfa_trc(port->fcs, req_status);
1057 port->stats.ns_gidft_rsp_err++;
1058 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
1059 return;
1060 }
1061
1062 if (resid_len != 0) {
1063 /*
1064 * TBD : we will need to allocate a larger buffer & retry the
1065 * command
1066 */
1067 bfa_trc(port->fcs, rsp_len);
1068 bfa_trc(port->fcs, resid_len);
1069 return;
1070 }
1071
1072 cthdr = (struct ct_hdr_s *) BFA_FCXP_RSP_PLD(fcxp);
1073 cthdr->cmd_rsp_code = bfa_os_ntohs(cthdr->cmd_rsp_code);
1074
1075 switch (cthdr->cmd_rsp_code) {
1076
1077 case CT_RSP_ACCEPT:
1078
1079 port->stats.ns_gidft_accepts++;
1080 n_pids = (fc_get_ctresp_pyld_len(rsp_len) / sizeof(u32));
1081 bfa_trc(port->fcs, n_pids);
1082 bfa_fcs_port_ns_process_gidft_pids(port,
1083 (u32 *) (cthdr + 1),
1084 n_pids);
1085 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
1086 break;
1087
1088 case CT_RSP_REJECT:
1089
1090 /*
1091 * Check the reason code & explanation.
1092 * There may not have been any FC4 devices in the fabric
1093 */
1094 port->stats.ns_gidft_rejects++;
1095 bfa_trc(port->fcs, cthdr->reason_code);
1096 bfa_trc(port->fcs, cthdr->exp_code);
1097
1098 if ((cthdr->reason_code == CT_RSN_UNABLE_TO_PERF)
1099 && (cthdr->exp_code == CT_NS_EXP_FT_NOT_REG)) {
1100
1101 bfa_sm_send_event(ns, NSSM_EVENT_RSP_OK);
1102 } else {
1103 /*
1104 * for all other errors, retry
1105 */
1106 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
1107 }
1108 break;
1109
1110 default:
1111 port->stats.ns_gidft_unknown_rsp++;
1112 bfa_trc(port->fcs, cthdr->cmd_rsp_code);
1113 bfa_sm_send_event(ns, NSSM_EVENT_RSP_ERROR);
1114 }
1115}
1116
1117/**
1118 * This routine will be called by bfa_timer on timer timeouts.
1119 *
1120 * param[in] port - pointer to bfa_fcs_port_t.
1121 *
1122 * return
1123 * void
1124 *
1125* Special Considerations:
1126 *
1127 * note
1128 */
1129static void
1130bfa_fcs_port_ns_timeout(void *arg)
1131{
1132 struct bfa_fcs_port_ns_s *ns = (struct bfa_fcs_port_ns_s *)arg;
1133
1134 ns->port->stats.ns_timeouts++;
1135 bfa_sm_send_event(ns, NSSM_EVENT_TIMEOUT);
1136}
1137
1138/*
1139 * Process the PID list in GID_FT response
1140 */
1141static void
1142bfa_fcs_port_ns_process_gidft_pids(struct bfa_fcs_port_s *port,
1143 u32 *pid_buf, u32 n_pids)
1144{
1145 struct fcgs_gidft_resp_s *gidft_entry;
1146 struct bfa_fcs_rport_s *rport;
1147 u32 ii;
1148
1149 for (ii = 0; ii < n_pids; ii++) {
1150 gidft_entry = (struct fcgs_gidft_resp_s *) &pid_buf[ii];
1151
1152 if (gidft_entry->pid == port->pid)
1153 continue;
1154
1155 /*
1156 * Check if this rport already exists
1157 */
1158 rport = bfa_fcs_port_get_rport_by_pid(port, gidft_entry->pid);
1159 if (rport == NULL) {
1160 /*
1161 * this is a new device. create rport
1162 */
1163 rport = bfa_fcs_rport_create(port, gidft_entry->pid);
1164 } else {
1165 /*
1166 * this rport already exists
1167 */
1168 bfa_fcs_rport_scn(rport);
1169 }
1170
1171 bfa_trc(port->fcs, gidft_entry->pid);
1172
1173 /*
1174 * if the last entry bit is set, bail out.
1175 */
1176 if (gidft_entry->last)
1177 return;
1178 }
1179}
1180
1181/**
1182 * fcs_ns_public FCS nameserver public interfaces
1183 */
1184
1185/*
1186 * Functions called by port/fab.
1187 * These will send relevant Events to the ns state machine.
1188 */
1189void
1190bfa_fcs_port_ns_init(struct bfa_fcs_port_s *port)
1191{
1192 struct bfa_fcs_port_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port);
1193
1194 ns->port = port;
1195 bfa_sm_set_state(ns, bfa_fcs_port_ns_sm_offline);
1196}
1197
1198void
1199bfa_fcs_port_ns_offline(struct bfa_fcs_port_s *port)
1200{
1201 struct bfa_fcs_port_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port);
1202
1203 ns->port = port;
1204 bfa_sm_send_event(ns, NSSM_EVENT_PORT_OFFLINE);
1205}
1206
1207void
1208bfa_fcs_port_ns_online(struct bfa_fcs_port_s *port)
1209{
1210 struct bfa_fcs_port_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port);
1211
1212 ns->port = port;
1213 bfa_sm_send_event(ns, NSSM_EVENT_PORT_ONLINE);
1214}
1215
1216void
1217bfa_fcs_port_ns_query(struct bfa_fcs_port_s *port)
1218{
1219 struct bfa_fcs_port_ns_s *ns = BFA_FCS_GET_NS_FROM_PORT(port);
1220
1221 bfa_trc(port->fcs, port->pid);
1222 bfa_sm_send_event(ns, NSSM_EVENT_NS_QUERY);
1223}
1224
1225static void
1226bfa_fcs_port_ns_boot_target_disc(struct bfa_fcs_port_s *port)
1227{
1228
1229 struct bfa_fcs_rport_s *rport;
1230 u8 nwwns;
1231 wwn_t wwns[BFA_PREBOOT_BOOTLUN_MAX];
1232 int ii;
1233
1234 bfa_iocfc_get_bootwwns(port->fcs->bfa, &nwwns, wwns);
1235
1236 for (ii = 0; ii < nwwns; ++ii) {
1237 rport = bfa_fcs_rport_create_by_wwn(port, wwns[ii]);
1238 bfa_assert(rport);
1239 }
1240}
1241
1242
diff --git a/drivers/scsi/bfa/plog.c b/drivers/scsi/bfa/plog.c
deleted file mode 100644
index fcb8864d3276..000000000000
--- a/drivers/scsi/bfa/plog.c
+++ /dev/null
@@ -1,184 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa_os_inc.h>
19#include <cs/bfa_plog.h>
20#include <cs/bfa_debug.h>
21
22static int
23plkd_validate_logrec(struct bfa_plog_rec_s *pl_rec)
24{
25 if ((pl_rec->log_type != BFA_PL_LOG_TYPE_INT)
26 && (pl_rec->log_type != BFA_PL_LOG_TYPE_STRING))
27 return 1;
28
29 if ((pl_rec->log_type != BFA_PL_LOG_TYPE_INT)
30 && (pl_rec->log_num_ints > BFA_PL_INT_LOG_SZ))
31 return 1;
32
33 return 0;
34}
35
36static void
37bfa_plog_add(struct bfa_plog_s *plog, struct bfa_plog_rec_s *pl_rec)
38{
39 u16 tail;
40 struct bfa_plog_rec_s *pl_recp;
41
42 if (plog->plog_enabled == 0)
43 return;
44
45 if (plkd_validate_logrec(pl_rec)) {
46 bfa_assert(0);
47 return;
48 }
49
50 tail = plog->tail;
51
52 pl_recp = &(plog->plog_recs[tail]);
53
54 bfa_os_memcpy(pl_recp, pl_rec, sizeof(struct bfa_plog_rec_s));
55
56 pl_recp->tv = BFA_TRC_TS(plog);
57 BFA_PL_LOG_REC_INCR(plog->tail);
58
59 if (plog->head == plog->tail)
60 BFA_PL_LOG_REC_INCR(plog->head);
61}
62
63void
64bfa_plog_init(struct bfa_plog_s *plog)
65{
66 bfa_os_memset((char *)plog, 0, sizeof(struct bfa_plog_s));
67
68 bfa_os_memcpy(plog->plog_sig, BFA_PL_SIG_STR, BFA_PL_SIG_LEN);
69 plog->head = plog->tail = 0;
70 plog->plog_enabled = 1;
71}
72
73void
74bfa_plog_str(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
75 enum bfa_plog_eid event,
76 u16 misc, char *log_str)
77{
78 struct bfa_plog_rec_s lp;
79
80 if (plog->plog_enabled) {
81 bfa_os_memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
82 lp.mid = mid;
83 lp.eid = event;
84 lp.log_type = BFA_PL_LOG_TYPE_STRING;
85 lp.misc = misc;
86 strncpy(lp.log_entry.string_log, log_str,
87 BFA_PL_STRING_LOG_SZ - 1);
88 lp.log_entry.string_log[BFA_PL_STRING_LOG_SZ - 1] = '\0';
89 bfa_plog_add(plog, &lp);
90 }
91}
92
93void
94bfa_plog_intarr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
95 enum bfa_plog_eid event,
96 u16 misc, u32 *intarr, u32 num_ints)
97{
98 struct bfa_plog_rec_s lp;
99 u32 i;
100
101 if (num_ints > BFA_PL_INT_LOG_SZ)
102 num_ints = BFA_PL_INT_LOG_SZ;
103
104 if (plog->plog_enabled) {
105 bfa_os_memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
106 lp.mid = mid;
107 lp.eid = event;
108 lp.log_type = BFA_PL_LOG_TYPE_INT;
109 lp.misc = misc;
110
111 for (i = 0; i < num_ints; i++)
112 bfa_os_assign(lp.log_entry.int_log[i],
113 intarr[i]);
114
115 lp.log_num_ints = (u8) num_ints;
116
117 bfa_plog_add(plog, &lp);
118 }
119}
120
121void
122bfa_plog_fchdr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
123 enum bfa_plog_eid event,
124 u16 misc, struct fchs_s *fchdr)
125{
126 struct bfa_plog_rec_s lp;
127 u32 *tmp_int = (u32 *) fchdr;
128 u32 ints[BFA_PL_INT_LOG_SZ];
129
130 if (plog->plog_enabled) {
131 bfa_os_memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
132
133 ints[0] = tmp_int[0];
134 ints[1] = tmp_int[1];
135 ints[2] = tmp_int[4];
136
137 bfa_plog_intarr(plog, mid, event, misc, ints, 3);
138 }
139}
140
141void
142bfa_plog_fchdr_and_pl(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
143 enum bfa_plog_eid event, u16 misc, struct fchs_s *fchdr,
144 u32 pld_w0)
145{
146 struct bfa_plog_rec_s lp;
147 u32 *tmp_int = (u32 *) fchdr;
148 u32 ints[BFA_PL_INT_LOG_SZ];
149
150 if (plog->plog_enabled) {
151 bfa_os_memset(&lp, 0, sizeof(struct bfa_plog_rec_s));
152
153 ints[0] = tmp_int[0];
154 ints[1] = tmp_int[1];
155 ints[2] = tmp_int[4];
156 ints[3] = pld_w0;
157
158 bfa_plog_intarr(plog, mid, event, misc, ints, 4);
159 }
160}
161
162void
163bfa_plog_clear(struct bfa_plog_s *plog)
164{
165 plog->head = plog->tail = 0;
166}
167
168void
169bfa_plog_enable(struct bfa_plog_s *plog)
170{
171 plog->plog_enabled = 1;
172}
173
174void
175bfa_plog_disable(struct bfa_plog_s *plog)
176{
177 plog->plog_enabled = 0;
178}
179
180bfa_boolean_t
181bfa_plog_get_setting(struct bfa_plog_s *plog)
182{
183 return (bfa_boolean_t)plog->plog_enabled;
184}
diff --git a/drivers/scsi/bfa/rport_api.c b/drivers/scsi/bfa/rport_api.c
deleted file mode 100644
index 15e0c470afd9..000000000000
--- a/drivers/scsi/bfa/rport_api.c
+++ /dev/null
@@ -1,185 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
18#include <bfa_svc.h>
19#include "fcs_vport.h"
20#include "fcs_lport.h"
21#include "fcs_rport.h"
22#include "fcs_trcmod.h"
23
24BFA_TRC_FILE(FCS, RPORT_API);
25
26/**
27 * rport_api.c Remote port implementation.
28 */
29
30/**
31 * fcs_rport_api FCS rport API.
32 */
33
34/**
35 * Direct API to add a target by port wwn. This interface is used, for
36 * example, by bios when target pwwn is known from boot lun configuration.
37 */
38bfa_status_t
39bfa_fcs_rport_add(struct bfa_fcs_port_s *port, wwn_t *pwwn,
40 struct bfa_fcs_rport_s *rport,
41 struct bfad_rport_s *rport_drv)
42{
43 bfa_trc(port->fcs, *pwwn);
44
45 return BFA_STATUS_OK;
46}
47
48/**
49 * Direct API to remove a target and its associated resources. This
50 * interface is used, for example, by vmware driver to remove target
51 * ports from the target list for a VM.
52 */
53bfa_status_t
54bfa_fcs_rport_remove(struct bfa_fcs_rport_s *rport_in)
55{
56
57 struct bfa_fcs_rport_s *rport;
58
59 bfa_trc(rport_in->fcs, rport_in->pwwn);
60
61 rport = bfa_fcs_port_get_rport_by_pwwn(rport_in->port, rport_in->pwwn);
62 if (rport == NULL) {
63 /*
64 * TBD Error handling
65 */
66 bfa_trc(rport_in->fcs, rport_in->pid);
67 return BFA_STATUS_UNKNOWN_RWWN;
68 }
69
70 /*
71 * TBD if this remote port is online, send a logo
72 */
73 return BFA_STATUS_OK;
74
75}
76
77/**
78 * Remote device status for display/debug.
79 */
80void
81bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
82 struct bfa_rport_attr_s *rport_attr)
83{
84 struct bfa_rport_qos_attr_s qos_attr;
85 struct bfa_fcs_port_s *port = rport->port;
86 enum bfa_pport_speed rport_speed = rport->rpf.rpsc_speed;
87
88 bfa_os_memset(rport_attr, 0, sizeof(struct bfa_rport_attr_s));
89
90 rport_attr->pid = rport->pid;
91 rport_attr->pwwn = rport->pwwn;
92 rport_attr->nwwn = rport->nwwn;
93 rport_attr->cos_supported = rport->fc_cos;
94 rport_attr->df_sz = rport->maxfrsize;
95 rport_attr->state = bfa_fcs_rport_get_state(rport);
96 rport_attr->fc_cos = rport->fc_cos;
97 rport_attr->cisc = rport->cisc;
98 rport_attr->scsi_function = rport->scsi_function;
99 rport_attr->curr_speed = rport->rpf.rpsc_speed;
100 rport_attr->assigned_speed = rport->rpf.assigned_speed;
101
102 bfa_rport_get_qos_attr(rport->bfa_rport, &qos_attr);
103 rport_attr->qos_attr = qos_attr;
104
105 rport_attr->trl_enforced = BFA_FALSE;
106
107 if (bfa_fcport_is_ratelim(port->fcs->bfa)) {
108 if (rport_speed == BFA_PPORT_SPEED_UNKNOWN) {
109 /* Use default ratelim speed setting */
110 rport_speed =
111 bfa_fcport_get_ratelim_speed(rport->fcs->bfa);
112 }
113 if (rport_speed < bfa_fcs_port_get_rport_max_speed(port))
114 rport_attr->trl_enforced = BFA_TRUE;
115 }
116
117 /*
118 * TODO
119 * rport->symname
120 */
121}
122
123/**
124 * Per remote device statistics.
125 */
126void
127bfa_fcs_rport_get_stats(struct bfa_fcs_rport_s *rport,
128 struct bfa_rport_stats_s *stats)
129{
130 *stats = rport->stats;
131}
132
133void
134bfa_fcs_rport_clear_stats(struct bfa_fcs_rport_s *rport)
135{
136 bfa_os_memset((char *)&rport->stats, 0,
137 sizeof(struct bfa_rport_stats_s));
138}
139
140struct bfa_fcs_rport_s *
141bfa_fcs_rport_lookup(struct bfa_fcs_port_s *port, wwn_t rpwwn)
142{
143 struct bfa_fcs_rport_s *rport;
144
145 rport = bfa_fcs_port_get_rport_by_pwwn(port, rpwwn);
146 if (rport == NULL) {
147 /*
148 * TBD Error handling
149 */
150 }
151
152 return rport;
153}
154
155struct bfa_fcs_rport_s *
156bfa_fcs_rport_lookup_by_nwwn(struct bfa_fcs_port_s *port, wwn_t rnwwn)
157{
158 struct bfa_fcs_rport_s *rport;
159
160 rport = bfa_fcs_port_get_rport_by_nwwn(port, rnwwn);
161 if (rport == NULL) {
162 /*
163 * TBD Error handling
164 */
165 }
166
167 return rport;
168}
169
170/*
171 * This API is to set the Rport's speed. Should be used when RPSC is not
172 * supported by the rport.
173 */
174void
175bfa_fcs_rport_set_speed(struct bfa_fcs_rport_s *rport,
176 enum bfa_pport_speed speed)
177{
178 rport->rpf.assigned_speed = speed;
179
180 /* Set this speed in f/w only if the RPSC speed is not available */
181 if (rport->rpf.rpsc_speed == BFA_PPORT_SPEED_UNKNOWN)
182 bfa_rport_speed(rport->bfa_rport, speed);
183}
184
185
diff --git a/drivers/scsi/bfa/rport_ftrs.c b/drivers/scsi/bfa/rport_ftrs.c
deleted file mode 100644
index f2a9361ce9a4..000000000000
--- a/drivers/scsi/bfa/rport_ftrs.c
+++ /dev/null
@@ -1,379 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * rport_ftrs.c Remote port features (RPF) implementation.
20 */
21
22#include <bfa.h>
23#include <bfa_svc.h>
24#include "fcbuild.h"
25#include "fcs_rport.h"
26#include "fcs_lport.h"
27#include "fcs_trcmod.h"
28#include "fcs_fcxp.h"
29#include "fcs.h"
30
31BFA_TRC_FILE(FCS, RPORT_FTRS);
32
33#define BFA_FCS_RPF_RETRIES (3)
34#define BFA_FCS_RPF_RETRY_TIMEOUT (1000) /* 1 sec (In millisecs) */
35
36static void bfa_fcs_rpf_send_rpsc2(void *rport_cbarg,
37 struct bfa_fcxp_s *fcxp_alloced);
38static void bfa_fcs_rpf_rpsc2_response(void *fcsarg,
39 struct bfa_fcxp_s *fcxp, void *cbarg,
40 bfa_status_t req_status, u32 rsp_len,
41 u32 resid_len,
42 struct fchs_s *rsp_fchs);
43static void bfa_fcs_rpf_timeout(void *arg);
44
45/**
46 * fcs_rport_ftrs_sm FCS rport state machine events
47 */
48
49enum rpf_event {
50 RPFSM_EVENT_RPORT_OFFLINE = 1, /* Rport offline */
51 RPFSM_EVENT_RPORT_ONLINE = 2, /* Rport online */
52 RPFSM_EVENT_FCXP_SENT = 3, /* Frame from has been sent */
53 RPFSM_EVENT_TIMEOUT = 4, /* Rport SM timeout event */
54 RPFSM_EVENT_RPSC_COMP = 5,
55 RPFSM_EVENT_RPSC_FAIL = 6,
56 RPFSM_EVENT_RPSC_ERROR = 7,
57};
58
59static void bfa_fcs_rpf_sm_uninit(struct bfa_fcs_rpf_s *rpf,
60 enum rpf_event event);
61static void bfa_fcs_rpf_sm_rpsc_sending(struct bfa_fcs_rpf_s *rpf,
62 enum rpf_event event);
63static void bfa_fcs_rpf_sm_rpsc(struct bfa_fcs_rpf_s *rpf,
64 enum rpf_event event);
65static void bfa_fcs_rpf_sm_rpsc_retry(struct bfa_fcs_rpf_s *rpf,
66 enum rpf_event event);
67static void bfa_fcs_rpf_sm_offline(struct bfa_fcs_rpf_s *rpf,
68 enum rpf_event event);
69static void bfa_fcs_rpf_sm_online(struct bfa_fcs_rpf_s *rpf,
70 enum rpf_event event);
71
72static void
73bfa_fcs_rpf_sm_uninit(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
74{
75 struct bfa_fcs_rport_s *rport = rpf->rport;
76 struct bfa_fcs_fabric_s *fabric = &rport->fcs->fabric;
77
78 bfa_trc(rport->fcs, rport->pwwn);
79 bfa_trc(rport->fcs, rport->pid);
80 bfa_trc(rport->fcs, event);
81
82 switch (event) {
83 case RPFSM_EVENT_RPORT_ONLINE:
84 /* Send RPSC2 to a Brocade fabric only. */
85 if ((!BFA_FCS_PID_IS_WKA(rport->pid)) &&
86 ((bfa_lps_is_brcd_fabric(rport->port->fabric->lps)) ||
87 (bfa_fcs_fabric_get_switch_oui(fabric) ==
88 BFA_FCS_BRCD_SWITCH_OUI))) {
89 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_rpsc_sending);
90 rpf->rpsc_retries = 0;
91 bfa_fcs_rpf_send_rpsc2(rpf, NULL);
92 }
93 break;
94
95 case RPFSM_EVENT_RPORT_OFFLINE:
96 break;
97
98 default:
99 bfa_sm_fault(rport->fcs, event);
100 }
101}
102
103static void
104bfa_fcs_rpf_sm_rpsc_sending(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
105{
106 struct bfa_fcs_rport_s *rport = rpf->rport;
107
108 bfa_trc(rport->fcs, event);
109
110 switch (event) {
111 case RPFSM_EVENT_FCXP_SENT:
112 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_rpsc);
113 break;
114
115 case RPFSM_EVENT_RPORT_OFFLINE:
116 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_offline);
117 bfa_fcxp_walloc_cancel(rport->fcs->bfa, &rpf->fcxp_wqe);
118 rpf->rpsc_retries = 0;
119 break;
120
121 default:
122 bfa_sm_fault(rport->fcs, event);
123 }
124}
125
126static void
127bfa_fcs_rpf_sm_rpsc(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
128{
129 struct bfa_fcs_rport_s *rport = rpf->rport;
130
131 bfa_trc(rport->fcs, rport->pid);
132 bfa_trc(rport->fcs, event);
133
134 switch (event) {
135 case RPFSM_EVENT_RPSC_COMP:
136 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_online);
137 /* Update speed info in f/w via BFA */
138 if (rpf->rpsc_speed != BFA_PPORT_SPEED_UNKNOWN)
139 bfa_rport_speed(rport->bfa_rport, rpf->rpsc_speed);
140 else if (rpf->assigned_speed != BFA_PPORT_SPEED_UNKNOWN)
141 bfa_rport_speed(rport->bfa_rport, rpf->assigned_speed);
142 break;
143
144 case RPFSM_EVENT_RPSC_FAIL:
145 /* RPSC not supported by rport */
146 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_online);
147 break;
148
149 case RPFSM_EVENT_RPSC_ERROR:
150 /* need to retry...delayed a bit. */
151 if (rpf->rpsc_retries++ < BFA_FCS_RPF_RETRIES) {
152 bfa_timer_start(rport->fcs->bfa, &rpf->timer,
153 bfa_fcs_rpf_timeout, rpf,
154 BFA_FCS_RPF_RETRY_TIMEOUT);
155 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_rpsc_retry);
156 } else {
157 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_online);
158 }
159 break;
160
161 case RPFSM_EVENT_RPORT_OFFLINE:
162 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_offline);
163 bfa_fcxp_discard(rpf->fcxp);
164 rpf->rpsc_retries = 0;
165 break;
166
167 default:
168 bfa_sm_fault(rport->fcs, event);
169 }
170}
171
172static void
173bfa_fcs_rpf_sm_rpsc_retry(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
174{
175 struct bfa_fcs_rport_s *rport = rpf->rport;
176
177 bfa_trc(rport->fcs, rport->pid);
178 bfa_trc(rport->fcs, event);
179
180 switch (event) {
181 case RPFSM_EVENT_TIMEOUT:
182 /* re-send the RPSC */
183 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_rpsc_sending);
184 bfa_fcs_rpf_send_rpsc2(rpf, NULL);
185 break;
186
187 case RPFSM_EVENT_RPORT_OFFLINE:
188 bfa_timer_stop(&rpf->timer);
189 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_offline);
190 rpf->rpsc_retries = 0;
191 break;
192
193 default:
194 bfa_sm_fault(rport->fcs, event);
195 }
196}
197
198static void
199bfa_fcs_rpf_sm_online(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
200{
201 struct bfa_fcs_rport_s *rport = rpf->rport;
202
203 bfa_trc(rport->fcs, rport->pwwn);
204 bfa_trc(rport->fcs, rport->pid);
205 bfa_trc(rport->fcs, event);
206
207 switch (event) {
208 case RPFSM_EVENT_RPORT_OFFLINE:
209 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_offline);
210 rpf->rpsc_retries = 0;
211 break;
212
213 default:
214 bfa_sm_fault(rport->fcs, event);
215 }
216}
217
218static void
219bfa_fcs_rpf_sm_offline(struct bfa_fcs_rpf_s *rpf, enum rpf_event event)
220{
221 struct bfa_fcs_rport_s *rport = rpf->rport;
222
223 bfa_trc(rport->fcs, rport->pwwn);
224 bfa_trc(rport->fcs, rport->pid);
225 bfa_trc(rport->fcs, event);
226
227 switch (event) {
228 case RPFSM_EVENT_RPORT_ONLINE:
229 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_rpsc_sending);
230 bfa_fcs_rpf_send_rpsc2(rpf, NULL);
231 break;
232
233 case RPFSM_EVENT_RPORT_OFFLINE:
234 break;
235
236 default:
237 bfa_sm_fault(rport->fcs, event);
238 }
239}
240/**
241 * Called when Rport is created.
242 */
243void bfa_fcs_rpf_init(struct bfa_fcs_rport_s *rport)
244{
245 struct bfa_fcs_rpf_s *rpf = &rport->rpf;
246
247 bfa_trc(rport->fcs, rport->pid);
248 rpf->rport = rport;
249
250 bfa_sm_set_state(rpf, bfa_fcs_rpf_sm_uninit);
251}
252
253/**
254 * Called when Rport becomes online
255 */
256void bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s *rport)
257{
258 bfa_trc(rport->fcs, rport->pid);
259
260 if (__fcs_min_cfg(rport->port->fcs))
261 return;
262
263 if (bfa_fcs_fabric_is_switched(rport->port->fabric))
264 bfa_sm_send_event(&rport->rpf, RPFSM_EVENT_RPORT_ONLINE);
265}
266
267/**
268 * Called when Rport becomes offline
269 */
270void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport)
271{
272 bfa_trc(rport->fcs, rport->pid);
273
274 if (__fcs_min_cfg(rport->port->fcs))
275 return;
276
277 rport->rpf.rpsc_speed = 0;
278 bfa_sm_send_event(&rport->rpf, RPFSM_EVENT_RPORT_OFFLINE);
279}
280
281static void
282bfa_fcs_rpf_timeout(void *arg)
283{
284 struct bfa_fcs_rpf_s *rpf = (struct bfa_fcs_rpf_s *) arg;
285 struct bfa_fcs_rport_s *rport = rpf->rport;
286
287 bfa_trc(rport->fcs, rport->pid);
288 bfa_sm_send_event(rpf, RPFSM_EVENT_TIMEOUT);
289}
290
291static void
292bfa_fcs_rpf_send_rpsc2(void *rpf_cbarg, struct bfa_fcxp_s *fcxp_alloced)
293{
294 struct bfa_fcs_rpf_s *rpf = (struct bfa_fcs_rpf_s *)rpf_cbarg;
295 struct bfa_fcs_rport_s *rport = rpf->rport;
296 struct bfa_fcs_port_s *port = rport->port;
297 struct fchs_s fchs;
298 int len;
299 struct bfa_fcxp_s *fcxp;
300
301 bfa_trc(rport->fcs, rport->pwwn);
302
303 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
304 if (!fcxp) {
305 bfa_fcxp_alloc_wait(port->fcs->bfa, &rpf->fcxp_wqe,
306 bfa_fcs_rpf_send_rpsc2, rpf);
307 return;
308 }
309 rpf->fcxp = fcxp;
310
311 len = fc_rpsc2_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rport->pid,
312 bfa_fcs_port_get_fcid(port), &rport->pid, 1);
313
314 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
315 FC_CLASS_3, len, &fchs, bfa_fcs_rpf_rpsc2_response,
316 rpf, FC_MAX_PDUSZ, FC_ELS_TOV);
317 rport->stats.rpsc_sent++;
318 bfa_sm_send_event(rpf, RPFSM_EVENT_FCXP_SENT);
319
320}
321
322static void
323bfa_fcs_rpf_rpsc2_response(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
324 bfa_status_t req_status, u32 rsp_len,
325 u32 resid_len, struct fchs_s *rsp_fchs)
326{
327 struct bfa_fcs_rpf_s *rpf = (struct bfa_fcs_rpf_s *) cbarg;
328 struct bfa_fcs_rport_s *rport = rpf->rport;
329 struct fc_ls_rjt_s *ls_rjt;
330 struct fc_rpsc2_acc_s *rpsc2_acc;
331 u16 num_ents;
332
333 bfa_trc(rport->fcs, req_status);
334
335 if (req_status != BFA_STATUS_OK) {
336 bfa_trc(rport->fcs, req_status);
337 if (req_status == BFA_STATUS_ETIMER)
338 rport->stats.rpsc_failed++;
339 bfa_sm_send_event(rpf, RPFSM_EVENT_RPSC_ERROR);
340 return;
341 }
342
343 rpsc2_acc = (struct fc_rpsc2_acc_s *) BFA_FCXP_RSP_PLD(fcxp);
344 if (rpsc2_acc->els_cmd == FC_ELS_ACC) {
345 rport->stats.rpsc_accs++;
346 num_ents = bfa_os_ntohs(rpsc2_acc->num_pids);
347 bfa_trc(rport->fcs, num_ents);
348 if (num_ents > 0) {
349 bfa_assert(rpsc2_acc->port_info[0].pid != rport->pid);
350 bfa_trc(rport->fcs,
351 bfa_os_ntohs(rpsc2_acc->port_info[0].pid));
352 bfa_trc(rport->fcs,
353 bfa_os_ntohs(rpsc2_acc->port_info[0].speed));
354 bfa_trc(rport->fcs,
355 bfa_os_ntohs(rpsc2_acc->port_info[0].index));
356 bfa_trc(rport->fcs,
357 rpsc2_acc->port_info[0].type);
358
359 if (rpsc2_acc->port_info[0].speed == 0) {
360 bfa_sm_send_event(rpf, RPFSM_EVENT_RPSC_ERROR);
361 return;
362 }
363
364 rpf->rpsc_speed = fc_rpsc_operspeed_to_bfa_speed(
365 bfa_os_ntohs(rpsc2_acc->port_info[0].speed));
366
367 bfa_sm_send_event(rpf, RPFSM_EVENT_RPSC_COMP);
368 }
369 } else {
370 ls_rjt = (struct fc_ls_rjt_s *) BFA_FCXP_RSP_PLD(fcxp);
371 bfa_trc(rport->fcs, ls_rjt->reason_code);
372 bfa_trc(rport->fcs, ls_rjt->reason_code_expl);
373 rport->stats.rpsc_rejects++;
374 if (ls_rjt->reason_code == FC_LS_RJT_RSN_CMD_NOT_SUPP)
375 bfa_sm_send_event(rpf, RPFSM_EVENT_RPSC_FAIL);
376 else
377 bfa_sm_send_event(rpf, RPFSM_EVENT_RPSC_ERROR);
378 }
379}
diff --git a/drivers/scsi/bfa/scn.c b/drivers/scsi/bfa/scn.c
deleted file mode 100644
index 8a60129e6307..000000000000
--- a/drivers/scsi/bfa/scn.c
+++ /dev/null
@@ -1,482 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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#include <bfa.h>
19#include <bfa_svc.h>
20#include "fcs_lport.h"
21#include "fcs_rport.h"
22#include "fcs_ms.h"
23#include "fcs_trcmod.h"
24#include "fcs_fcxp.h"
25#include "fcs.h"
26#include "lport_priv.h"
27
28BFA_TRC_FILE(FCS, SCN);
29
30#define FC_QOS_RSCN_EVENT 0x0c
31#define FC_FABRIC_NAME_RSCN_EVENT 0x0d
32
33/*
34 * forward declarations
35 */
36static void bfa_fcs_port_scn_send_scr(void *scn_cbarg,
37 struct bfa_fcxp_s *fcxp_alloced);
38static void bfa_fcs_port_scn_scr_response(void *fcsarg,
39 struct bfa_fcxp_s *fcxp,
40 void *cbarg,
41 bfa_status_t req_status,
42 u32 rsp_len,
43 u32 resid_len,
44 struct fchs_s *rsp_fchs);
45static void bfa_fcs_port_scn_send_ls_acc(struct bfa_fcs_port_s *port,
46 struct fchs_s *rx_fchs);
47static void bfa_fcs_port_scn_timeout(void *arg);
48
49/**
50 * fcs_scm_sm FCS SCN state machine
51 */
52
53/**
54 * VPort SCN State Machine events
55 */
56enum port_scn_event {
57 SCNSM_EVENT_PORT_ONLINE = 1,
58 SCNSM_EVENT_PORT_OFFLINE = 2,
59 SCNSM_EVENT_RSP_OK = 3,
60 SCNSM_EVENT_RSP_ERROR = 4,
61 SCNSM_EVENT_TIMEOUT = 5,
62 SCNSM_EVENT_SCR_SENT = 6,
63};
64
65static void bfa_fcs_port_scn_sm_offline(struct bfa_fcs_port_scn_s *scn,
66 enum port_scn_event event);
67static void bfa_fcs_port_scn_sm_sending_scr(struct bfa_fcs_port_scn_s *scn,
68 enum port_scn_event event);
69static void bfa_fcs_port_scn_sm_scr(struct bfa_fcs_port_scn_s *scn,
70 enum port_scn_event event);
71static void bfa_fcs_port_scn_sm_scr_retry(struct bfa_fcs_port_scn_s *scn,
72 enum port_scn_event event);
73static void bfa_fcs_port_scn_sm_online(struct bfa_fcs_port_scn_s *scn,
74 enum port_scn_event event);
75
76/**
77 * Starting state - awaiting link up.
78 */
79static void
80bfa_fcs_port_scn_sm_offline(struct bfa_fcs_port_scn_s *scn,
81 enum port_scn_event event)
82{
83 switch (event) {
84 case SCNSM_EVENT_PORT_ONLINE:
85 bfa_sm_set_state(scn, bfa_fcs_port_scn_sm_sending_scr);
86 bfa_fcs_port_scn_send_scr(scn, NULL);
87 break;
88
89 case SCNSM_EVENT_PORT_OFFLINE:
90 break;
91
92 default:
93 bfa_sm_fault(scn->port->fcs, event);
94 }
95}
96
97static void
98bfa_fcs_port_scn_sm_sending_scr(struct bfa_fcs_port_scn_s *scn,
99 enum port_scn_event event)
100{
101 switch (event) {
102 case SCNSM_EVENT_SCR_SENT:
103 bfa_sm_set_state(scn, bfa_fcs_port_scn_sm_scr);
104 break;
105
106 case SCNSM_EVENT_PORT_OFFLINE:
107 bfa_sm_set_state(scn, bfa_fcs_port_scn_sm_offline);
108 bfa_fcxp_walloc_cancel(scn->port->fcs->bfa, &scn->fcxp_wqe);
109 break;
110
111 default:
112 bfa_sm_fault(scn->port->fcs, event);
113 }
114}
115
116static void
117bfa_fcs_port_scn_sm_scr(struct bfa_fcs_port_scn_s *scn,
118 enum port_scn_event event)
119{
120 struct bfa_fcs_port_s *port = scn->port;
121
122 switch (event) {
123 case SCNSM_EVENT_RSP_OK:
124 bfa_sm_set_state(scn, bfa_fcs_port_scn_sm_online);
125 break;
126
127 case SCNSM_EVENT_RSP_ERROR:
128 bfa_sm_set_state(scn, bfa_fcs_port_scn_sm_scr_retry);
129 bfa_timer_start(port->fcs->bfa, &scn->timer,
130 bfa_fcs_port_scn_timeout, scn,
131 BFA_FCS_RETRY_TIMEOUT);
132 break;
133
134 case SCNSM_EVENT_PORT_OFFLINE:
135 bfa_sm_set_state(scn, bfa_fcs_port_scn_sm_offline);
136 bfa_fcxp_discard(scn->fcxp);
137 break;
138
139 default:
140 bfa_sm_fault(scn->port->fcs, event);
141 }
142}
143
144static void
145bfa_fcs_port_scn_sm_scr_retry(struct bfa_fcs_port_scn_s *scn,
146 enum port_scn_event event)
147{
148 switch (event) {
149 case SCNSM_EVENT_TIMEOUT:
150 bfa_sm_set_state(scn, bfa_fcs_port_scn_sm_sending_scr);
151 bfa_fcs_port_scn_send_scr(scn, NULL);
152 break;
153
154 case SCNSM_EVENT_PORT_OFFLINE:
155 bfa_sm_set_state(scn, bfa_fcs_port_scn_sm_offline);
156 bfa_timer_stop(&scn->timer);
157 break;
158
159 default:
160 bfa_sm_fault(scn->port->fcs, event);
161 }
162}
163
164static void
165bfa_fcs_port_scn_sm_online(struct bfa_fcs_port_scn_s *scn,
166 enum port_scn_event event)
167{
168 switch (event) {
169 case SCNSM_EVENT_PORT_OFFLINE:
170 bfa_sm_set_state(scn, bfa_fcs_port_scn_sm_offline);
171 break;
172
173 default:
174 bfa_sm_fault(scn->port->fcs, event);
175 }
176}
177
178
179
180/**
181 * fcs_scn_private FCS SCN private functions
182 */
183
184/**
185 * This routine will be called to send a SCR command.
186 */
187static void
188bfa_fcs_port_scn_send_scr(void *scn_cbarg, struct bfa_fcxp_s *fcxp_alloced)
189{
190 struct bfa_fcs_port_scn_s *scn = scn_cbarg;
191 struct bfa_fcs_port_s *port = scn->port;
192 struct fchs_s fchs;
193 int len;
194 struct bfa_fcxp_s *fcxp;
195
196 bfa_trc(port->fcs, port->pid);
197 bfa_trc(port->fcs, port->port_cfg.pwwn);
198
199 fcxp = fcxp_alloced ? fcxp_alloced : bfa_fcs_fcxp_alloc(port->fcs);
200 if (!fcxp) {
201 bfa_fcxp_alloc_wait(port->fcs->bfa, &scn->fcxp_wqe,
202 bfa_fcs_port_scn_send_scr, scn);
203 return;
204 }
205 scn->fcxp = fcxp;
206
207 /*
208 * Handle VU registrations for Base port only
209 */
210 if ((!port->vport) && bfa_ioc_get_fcmode(&port->fcs->bfa->ioc)) {
211 len = fc_scr_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
212 bfa_lps_is_brcd_fabric(port->fabric->lps),
213 port->pid, 0);
214 } else {
215 len = fc_scr_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), BFA_FALSE,
216 port->pid, 0);
217 }
218
219 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
220 FC_CLASS_3, len, &fchs, bfa_fcs_port_scn_scr_response,
221 (void *)scn, FC_MAX_PDUSZ, FC_ELS_TOV);
222
223 bfa_sm_send_event(scn, SCNSM_EVENT_SCR_SENT);
224}
225
226static void
227bfa_fcs_port_scn_scr_response(void *fcsarg, struct bfa_fcxp_s *fcxp,
228 void *cbarg, bfa_status_t req_status,
229 u32 rsp_len, u32 resid_len,
230 struct fchs_s *rsp_fchs)
231{
232 struct bfa_fcs_port_scn_s *scn = (struct bfa_fcs_port_scn_s *)cbarg;
233 struct bfa_fcs_port_s *port = scn->port;
234 struct fc_els_cmd_s *els_cmd;
235 struct fc_ls_rjt_s *ls_rjt;
236
237 bfa_trc(port->fcs, port->port_cfg.pwwn);
238
239 /*
240 * Sanity Checks
241 */
242 if (req_status != BFA_STATUS_OK) {
243 bfa_trc(port->fcs, req_status);
244 bfa_sm_send_event(scn, SCNSM_EVENT_RSP_ERROR);
245 return;
246 }
247
248 els_cmd = (struct fc_els_cmd_s *) BFA_FCXP_RSP_PLD(fcxp);
249
250 switch (els_cmd->els_code) {
251
252 case FC_ELS_ACC:
253 bfa_sm_send_event(scn, SCNSM_EVENT_RSP_OK);
254 break;
255
256 case FC_ELS_LS_RJT:
257
258 ls_rjt = (struct fc_ls_rjt_s *) BFA_FCXP_RSP_PLD(fcxp);
259
260 bfa_trc(port->fcs, ls_rjt->reason_code);
261 bfa_trc(port->fcs, ls_rjt->reason_code_expl);
262
263 bfa_sm_send_event(scn, SCNSM_EVENT_RSP_ERROR);
264 break;
265
266 default:
267 bfa_sm_send_event(scn, SCNSM_EVENT_RSP_ERROR);
268 }
269}
270
271/*
272 * Send a LS Accept
273 */
274static void
275bfa_fcs_port_scn_send_ls_acc(struct bfa_fcs_port_s *port,
276 struct fchs_s *rx_fchs)
277{
278 struct fchs_s fchs;
279 struct bfa_fcxp_s *fcxp;
280 struct bfa_rport_s *bfa_rport = NULL;
281 int len;
282
283 bfa_trc(port->fcs, rx_fchs->s_id);
284
285 fcxp = bfa_fcs_fcxp_alloc(port->fcs);
286 if (!fcxp)
287 return;
288
289 len = fc_ls_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp), rx_fchs->s_id,
290 bfa_fcs_port_get_fcid(port), rx_fchs->ox_id);
291
292 bfa_fcxp_send(fcxp, bfa_rport, port->fabric->vf_id, port->lp_tag,
293 BFA_FALSE, FC_CLASS_3, len, &fchs, NULL, NULL,
294 FC_MAX_PDUSZ, 0);
295}
296
297/**
298 * This routine will be called by bfa_timer on timer timeouts.
299 *
300 * param[in] vport - pointer to bfa_fcs_port_t.
301 * param[out] vport_status - pointer to return vport status in
302 *
303 * return
304 * void
305 *
306* Special Considerations:
307 *
308 * note
309 */
310static void
311bfa_fcs_port_scn_timeout(void *arg)
312{
313 struct bfa_fcs_port_scn_s *scn = (struct bfa_fcs_port_scn_s *)arg;
314
315 bfa_sm_send_event(scn, SCNSM_EVENT_TIMEOUT);
316}
317
318
319
320/**
321 * fcs_scn_public FCS state change notification public interfaces
322 */
323
324/*
325 * Functions called by port/fab
326 */
327void
328bfa_fcs_port_scn_init(struct bfa_fcs_port_s *port)
329{
330 struct bfa_fcs_port_scn_s *scn = BFA_FCS_GET_SCN_FROM_PORT(port);
331
332 scn->port = port;
333 bfa_sm_set_state(scn, bfa_fcs_port_scn_sm_offline);
334}
335
336void
337bfa_fcs_port_scn_offline(struct bfa_fcs_port_s *port)
338{
339 struct bfa_fcs_port_scn_s *scn = BFA_FCS_GET_SCN_FROM_PORT(port);
340
341 scn->port = port;
342 bfa_sm_send_event(scn, SCNSM_EVENT_PORT_OFFLINE);
343}
344
345void
346bfa_fcs_port_scn_online(struct bfa_fcs_port_s *port)
347{
348 struct bfa_fcs_port_scn_s *scn = BFA_FCS_GET_SCN_FROM_PORT(port);
349
350 scn->port = port;
351 bfa_sm_send_event(scn, SCNSM_EVENT_PORT_ONLINE);
352}
353
354static void
355bfa_fcs_port_scn_portid_rscn(struct bfa_fcs_port_s *port, u32 rpid)
356{
357 struct bfa_fcs_rport_s *rport;
358
359 bfa_trc(port->fcs, rpid);
360
361 /**
362 * If this is an unknown device, then it just came online.
363 * Otherwise let rport handle the RSCN event.
364 */
365 rport = bfa_fcs_port_get_rport_by_pid(port, rpid);
366 if (rport == NULL) {
367 /*
368 * If min cfg mode is enabled, we donot need to
369 * discover any new rports.
370 */
371 if (!__fcs_min_cfg(port->fcs))
372 rport = bfa_fcs_rport_create(port, rpid);
373 } else {
374 bfa_fcs_rport_scn(rport);
375 }
376}
377
378/**
379 * rscn format based PID comparison
380 */
381#define __fc_pid_match(__c0, __c1, __fmt) \
382 (((__fmt) == FC_RSCN_FORMAT_FABRIC) || \
383 (((__fmt) == FC_RSCN_FORMAT_DOMAIN) && \
384 ((__c0)[0] == (__c1)[0])) || \
385 (((__fmt) == FC_RSCN_FORMAT_AREA) && \
386 ((__c0)[0] == (__c1)[0]) && \
387 ((__c0)[1] == (__c1)[1])))
388
389static void
390bfa_fcs_port_scn_multiport_rscn(struct bfa_fcs_port_s *port,
391 enum fc_rscn_format format, u32 rscn_pid)
392{
393 struct bfa_fcs_rport_s *rport;
394 struct list_head *qe, *qe_next;
395 u8 *c0, *c1;
396
397 bfa_trc(port->fcs, format);
398 bfa_trc(port->fcs, rscn_pid);
399
400 c0 = (u8 *) &rscn_pid;
401
402 list_for_each_safe(qe, qe_next, &port->rport_q) {
403 rport = (struct bfa_fcs_rport_s *)qe;
404 c1 = (u8 *) &rport->pid;
405 if (__fc_pid_match(c0, c1, format))
406 bfa_fcs_rport_scn(rport);
407 }
408}
409
410void
411bfa_fcs_port_scn_process_rscn(struct bfa_fcs_port_s *port, struct fchs_s *fchs,
412 u32 len)
413{
414 struct fc_rscn_pl_s *rscn = (struct fc_rscn_pl_s *) (fchs + 1);
415 int num_entries;
416 u32 rscn_pid;
417 bfa_boolean_t nsquery = BFA_FALSE;
418 int i = 0;
419
420 num_entries =
421 (bfa_os_ntohs(rscn->payldlen) -
422 sizeof(u32)) / sizeof(rscn->event[0]);
423
424 bfa_trc(port->fcs, num_entries);
425
426 port->stats.num_rscn++;
427
428 bfa_fcs_port_scn_send_ls_acc(port, fchs);
429
430 for (i = 0; i < num_entries; i++) {
431 rscn_pid = rscn->event[i].portid;
432
433 bfa_trc(port->fcs, rscn->event[i].format);
434 bfa_trc(port->fcs, rscn_pid);
435
436 switch (rscn->event[i].format) {
437 case FC_RSCN_FORMAT_PORTID:
438 if (rscn->event[i].qualifier == FC_QOS_RSCN_EVENT) {
439 /*
440 * Ignore this event. f/w would have processed
441 * it
442 */
443 bfa_trc(port->fcs, rscn_pid);
444 } else {
445 port->stats.num_portid_rscn++;
446 bfa_fcs_port_scn_portid_rscn(port, rscn_pid);
447 }
448 break;
449
450 case FC_RSCN_FORMAT_FABRIC:
451 if (rscn->event[i].qualifier ==
452 FC_FABRIC_NAME_RSCN_EVENT) {
453 bfa_fcs_port_ms_fabric_rscn(port);
454 break;
455 }
456 /*
457 * !!!!!!!!! Fall Through !!!!!!!!!!!!!
458 */
459
460 case FC_RSCN_FORMAT_AREA:
461 case FC_RSCN_FORMAT_DOMAIN:
462 nsquery = BFA_TRUE;
463 bfa_fcs_port_scn_multiport_rscn(port,
464 rscn->event[i].format,
465 rscn_pid);
466 break;
467
468 default:
469 bfa_assert(0);
470 nsquery = BFA_TRUE;
471 }
472 }
473
474 /**
475 * If any of area, domain or fabric RSCN is received, do a fresh discovery
476 * to find new devices.
477 */
478 if (nsquery)
479 bfa_fcs_port_ns_query(port);
480}
481
482
diff --git a/drivers/scsi/bfa/vfapi.c b/drivers/scsi/bfa/vfapi.c
deleted file mode 100644
index 391a4790bebd..000000000000
--- a/drivers/scsi/bfa/vfapi.c
+++ /dev/null
@@ -1,292 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * vfapi.c Fabric module implementation.
20 */
21
22#include "fcs_fabric.h"
23#include "fcs_trcmod.h"
24
25BFA_TRC_FILE(FCS, VFAPI);
26
27/**
28 * fcs_vf_api virtual fabrics API
29 */
30
31/**
32 * Enable VF mode.
33 *
34 * @param[in] fcs fcs module instance
35 * @param[in] vf_id default vf_id of port, FC_VF_ID_NULL
36 * to use standard default vf_id of 1.
37 *
38 * @retval BFA_STATUS_OK vf mode is enabled
39 * @retval BFA_STATUS_BUSY Port is active. Port must be disabled
40 * before VF mode can be enabled.
41 */
42bfa_status_t
43bfa_fcs_vf_mode_enable(struct bfa_fcs_s *fcs, u16 vf_id)
44{
45 return BFA_STATUS_OK;
46}
47
48/**
49 * Disable VF mode.
50 *
51 * @param[in] fcs fcs module instance
52 *
53 * @retval BFA_STATUS_OK vf mode is disabled
54 * @retval BFA_STATUS_BUSY VFs are present and being used. All
55 * VFs must be deleted before disabling
56 * VF mode.
57 */
58bfa_status_t
59bfa_fcs_vf_mode_disable(struct bfa_fcs_s *fcs)
60{
61 return BFA_STATUS_OK;
62}
63
64/**
65 * Create a new VF instance.
66 *
67 * A new VF is created using the given VF configuration. A VF is identified
68 * by VF id. No duplicate VF creation is allowed with the same VF id. Once
69 * a VF is created, VF is automatically started after link initialization
70 * and EVFP exchange is completed.
71 *
72 * param[in] vf - FCS vf data structure. Memory is
73 * allocated by caller (driver)
74 * param[in] fcs - FCS module
75 * param[in] vf_cfg - VF configuration
76 * param[in] vf_drv - Opaque handle back to the driver's
77 * virtual vf structure
78 *
79 * retval BFA_STATUS_OK VF creation is successful
80 * retval BFA_STATUS_FAILED VF creation failed
81 * retval BFA_STATUS_EEXIST A VF exists with the given vf_id
82 */
83bfa_status_t
84bfa_fcs_vf_create(bfa_fcs_vf_t *vf, struct bfa_fcs_s *fcs, u16 vf_id,
85 struct bfa_port_cfg_s *port_cfg, struct bfad_vf_s *vf_drv)
86{
87 bfa_trc(fcs, vf_id);
88 return BFA_STATUS_OK;
89}
90
91/**
92 * Use this function to delete a BFA VF object. VF object should
93 * be stopped before this function call.
94 *
95 * param[in] vf - pointer to bfa_vf_t.
96 *
97 * retval BFA_STATUS_OK On vf deletion success
98 * retval BFA_STATUS_BUSY VF is not in a stopped state
99 * retval BFA_STATUS_INPROGRESS VF deletion in in progress
100 */
101bfa_status_t
102bfa_fcs_vf_delete(bfa_fcs_vf_t *vf)
103{
104 bfa_trc(vf->fcs, vf->vf_id);
105 return BFA_STATUS_OK;
106}
107
108/**
109 * Start participation in VF. This triggers login to the virtual fabric.
110 *
111 * param[in] vf - pointer to bfa_vf_t.
112 *
113 * return None
114 */
115void
116bfa_fcs_vf_start(bfa_fcs_vf_t *vf)
117{
118 bfa_trc(vf->fcs, vf->vf_id);
119}
120
121/**
122 * Logout with the virtual fabric.
123 *
124 * param[in] vf - pointer to bfa_vf_t.
125 *
126 * retval BFA_STATUS_OK On success.
127 * retval BFA_STATUS_INPROGRESS VF is being stopped.
128 */
129bfa_status_t
130bfa_fcs_vf_stop(bfa_fcs_vf_t *vf)
131{
132 bfa_trc(vf->fcs, vf->vf_id);
133 return BFA_STATUS_OK;
134}
135
136/**
137 * Returns attributes of the given VF.
138 *
139 * param[in] vf pointer to bfa_vf_t.
140 * param[out] vf_attr vf attributes returned
141 *
142 * return None
143 */
144void
145bfa_fcs_vf_get_attr(bfa_fcs_vf_t *vf, struct bfa_vf_attr_s *vf_attr)
146{
147 bfa_trc(vf->fcs, vf->vf_id);
148}
149
150/**
151 * Return statistics associated with the given vf.
152 *
153 * param[in] vf pointer to bfa_vf_t.
154 * param[out] vf_stats vf statistics returned
155 *
156 * @return None
157 */
158void
159bfa_fcs_vf_get_stats(bfa_fcs_vf_t *vf, struct bfa_vf_stats_s *vf_stats)
160{
161 bfa_os_memcpy(vf_stats, &vf->stats, sizeof(struct bfa_vf_stats_s));
162 return;
163}
164
165void
166/**
167 * clear statistics associated with the given vf.
168 *
169 * param[in] vf pointer to bfa_vf_t.
170 *
171 * @return None
172 */
173bfa_fcs_vf_clear_stats(bfa_fcs_vf_t *vf)
174{
175 bfa_os_memset(&vf->stats, 0, sizeof(struct bfa_vf_stats_s));
176 return;
177}
178
179/**
180 * Returns FCS vf structure for a given vf_id.
181 *
182 * param[in] vf_id - VF_ID
183 *
184 * return
185 * If lookup succeeds, retuns fcs vf object, otherwise returns NULL
186 */
187bfa_fcs_vf_t *
188bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id)
189{
190 bfa_trc(fcs, vf_id);
191 if (vf_id == FC_VF_ID_NULL)
192 return &fcs->fabric;
193
194 /**
195 * @todo vf support
196 */
197
198 return NULL;
199}
200
201/**
202 * Returns driver VF structure for a given FCS vf.
203 *
204 * param[in] vf - pointer to bfa_vf_t
205 *
206 * return Driver VF structure
207 */
208struct bfad_vf_s *
209bfa_fcs_vf_get_drv_vf(bfa_fcs_vf_t *vf)
210{
211 bfa_assert(vf);
212 bfa_trc(vf->fcs, vf->vf_id);
213 return vf->vf_drv;
214}
215
216/**
217 * Return the list of VFs configured.
218 *
219 * param[in] fcs fcs module instance
220 * param[out] vf_ids returned list of vf_ids
221 * param[in,out] nvfs in:size of vf_ids array,
222 * out:total elements present,
223 * actual elements returned is limited by the size
224 *
225 * return Driver VF structure
226 */
227void
228bfa_fcs_vf_list(struct bfa_fcs_s *fcs, u16 *vf_ids, int *nvfs)
229{
230 bfa_trc(fcs, *nvfs);
231}
232
233/**
234 * Return the list of all VFs visible from fabric.
235 *
236 * param[in] fcs fcs module instance
237 * param[out] vf_ids returned list of vf_ids
238 * param[in,out] nvfs in:size of vf_ids array,
239 * out:total elements present,
240 * actual elements returned is limited by the size
241 *
242 * return Driver VF structure
243 */
244void
245bfa_fcs_vf_list_all(struct bfa_fcs_s *fcs, u16 *vf_ids, int *nvfs)
246{
247 bfa_trc(fcs, *nvfs);
248}
249
250/**
251 * Return the list of local logical ports present in the given VF.
252 *
253 * param[in] vf vf for which logical ports are returned
254 * param[out] lpwwn returned logical port wwn list
255 * param[in,out] nlports in:size of lpwwn list;
256 * out:total elements present,
257 * actual elements returned is limited by the size
258 *
259 */
260void
261bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t lpwwn[], int *nlports)
262{
263 struct list_head *qe;
264 struct bfa_fcs_vport_s *vport;
265 int i;
266 struct bfa_fcs_s *fcs;
267
268 if (vf == NULL || lpwwn == NULL || *nlports == 0)
269 return;
270
271 fcs = vf->fcs;
272
273 bfa_trc(fcs, vf->vf_id);
274 bfa_trc(fcs, (u32) *nlports);
275
276 i = 0;
277 lpwwn[i++] = vf->bport.port_cfg.pwwn;
278
279 list_for_each(qe, &vf->vport_q) {
280 if (i >= *nlports)
281 break;
282
283 vport = (struct bfa_fcs_vport_s *) qe;
284 lpwwn[i++] = vport->lport.port_cfg.pwwn;
285 }
286
287 bfa_trc(fcs, i);
288 *nlports = i;
289 return;
290}
291
292
diff --git a/drivers/scsi/bfa/vport.c b/drivers/scsi/bfa/vport.c
deleted file mode 100644
index b378ec79d386..000000000000
--- a/drivers/scsi/bfa/vport.c
+++ /dev/null
@@ -1,903 +0,0 @@
1/*
2 * Copyright (c) 2005-2009 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/**
19 * bfa_fcs_vport.c FCS virtual port state machine
20 */
21
22#include <bfa.h>
23#include <bfa_svc.h>
24#include <fcbuild.h>
25#include "fcs_fabric.h"
26#include "fcs_lport.h"
27#include "fcs_vport.h"
28#include "fcs_trcmod.h"
29#include "fcs.h"
30#include <aen/bfa_aen_lport.h>
31
32BFA_TRC_FILE(FCS, VPORT);
33
34#define __vport_fcs(__vp) ((__vp)->lport.fcs)
35#define __vport_pwwn(__vp) ((__vp)->lport.port_cfg.pwwn)
36#define __vport_nwwn(__vp) ((__vp)->lport.port_cfg.nwwn)
37#define __vport_bfa(__vp) ((__vp)->lport.fcs->bfa)
38#define __vport_fcid(__vp) ((__vp)->lport.pid)
39#define __vport_fabric(__vp) ((__vp)->lport.fabric)
40#define __vport_vfid(__vp) ((__vp)->lport.fabric->vf_id)
41
42#define BFA_FCS_VPORT_MAX_RETRIES 5
43/*
44 * Forward declarations
45 */
46static void bfa_fcs_vport_do_fdisc(struct bfa_fcs_vport_s *vport);
47static void bfa_fcs_vport_timeout(void *vport_arg);
48static void bfa_fcs_vport_do_logo(struct bfa_fcs_vport_s *vport);
49static void bfa_fcs_vport_free(struct bfa_fcs_vport_s *vport);
50
51/**
52 * fcs_vport_sm FCS virtual port state machine
53 */
54
55/**
56 * VPort State Machine events
57 */
58enum bfa_fcs_vport_event {
59 BFA_FCS_VPORT_SM_CREATE = 1, /* vport create event */
60 BFA_FCS_VPORT_SM_DELETE = 2, /* vport delete event */
61 BFA_FCS_VPORT_SM_START = 3, /* vport start request */
62 BFA_FCS_VPORT_SM_STOP = 4, /* stop: unsupported */
63 BFA_FCS_VPORT_SM_ONLINE = 5, /* fabric online */
64 BFA_FCS_VPORT_SM_OFFLINE = 6, /* fabric offline event */
65 BFA_FCS_VPORT_SM_FRMSENT = 7, /* fdisc/logo sent events */
66 BFA_FCS_VPORT_SM_RSP_OK = 8, /* good response */
67 BFA_FCS_VPORT_SM_RSP_ERROR = 9, /* error/bad response */
68 BFA_FCS_VPORT_SM_TIMEOUT = 10, /* delay timer event */
69 BFA_FCS_VPORT_SM_DELCOMP = 11, /* lport delete completion */
70 BFA_FCS_VPORT_SM_RSP_DUP_WWN = 12, /* Dup wnn error */
71 BFA_FCS_VPORT_SM_RSP_FAILED = 13, /* non-retryable failure */
72};
73
74static void bfa_fcs_vport_sm_uninit(struct bfa_fcs_vport_s *vport,
75 enum bfa_fcs_vport_event event);
76static void bfa_fcs_vport_sm_created(struct bfa_fcs_vport_s *vport,
77 enum bfa_fcs_vport_event event);
78static void bfa_fcs_vport_sm_offline(struct bfa_fcs_vport_s *vport,
79 enum bfa_fcs_vport_event event);
80static void bfa_fcs_vport_sm_fdisc(struct bfa_fcs_vport_s *vport,
81 enum bfa_fcs_vport_event event);
82static void bfa_fcs_vport_sm_fdisc_retry(struct bfa_fcs_vport_s *vport,
83 enum bfa_fcs_vport_event event);
84static void bfa_fcs_vport_sm_online(struct bfa_fcs_vport_s *vport,
85 enum bfa_fcs_vport_event event);
86static void bfa_fcs_vport_sm_deleting(struct bfa_fcs_vport_s *vport,
87 enum bfa_fcs_vport_event event);
88static void bfa_fcs_vport_sm_cleanup(struct bfa_fcs_vport_s *vport,
89 enum bfa_fcs_vport_event event);
90static void bfa_fcs_vport_sm_logo(struct bfa_fcs_vport_s *vport,
91 enum bfa_fcs_vport_event event);
92static void bfa_fcs_vport_sm_error(struct bfa_fcs_vport_s *vport,
93 enum bfa_fcs_vport_event event);
94
95static struct bfa_sm_table_s vport_sm_table[] = {
96 {BFA_SM(bfa_fcs_vport_sm_uninit), BFA_FCS_VPORT_UNINIT},
97 {BFA_SM(bfa_fcs_vport_sm_created), BFA_FCS_VPORT_CREATED},
98 {BFA_SM(bfa_fcs_vport_sm_offline), BFA_FCS_VPORT_OFFLINE},
99 {BFA_SM(bfa_fcs_vport_sm_fdisc), BFA_FCS_VPORT_FDISC},
100 {BFA_SM(bfa_fcs_vport_sm_fdisc_retry), BFA_FCS_VPORT_FDISC_RETRY},
101 {BFA_SM(bfa_fcs_vport_sm_online), BFA_FCS_VPORT_ONLINE},
102 {BFA_SM(bfa_fcs_vport_sm_deleting), BFA_FCS_VPORT_DELETING},
103 {BFA_SM(bfa_fcs_vport_sm_cleanup), BFA_FCS_VPORT_CLEANUP},
104 {BFA_SM(bfa_fcs_vport_sm_logo), BFA_FCS_VPORT_LOGO},
105 {BFA_SM(bfa_fcs_vport_sm_error), BFA_FCS_VPORT_ERROR}
106};
107
108/**
109 * Beginning state.
110 */
111static void
112bfa_fcs_vport_sm_uninit(struct bfa_fcs_vport_s *vport,
113 enum bfa_fcs_vport_event event)
114{
115 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
116 bfa_trc(__vport_fcs(vport), event);
117
118 switch (event) {
119 case BFA_FCS_VPORT_SM_CREATE:
120 bfa_sm_set_state(vport, bfa_fcs_vport_sm_created);
121 bfa_fcs_fabric_addvport(__vport_fabric(vport), vport);
122 break;
123
124 default:
125 bfa_sm_fault(__vport_fcs(vport), event);
126 }
127}
128
129/**
130 * Created state - a start event is required to start up the state machine.
131 */
132static void
133bfa_fcs_vport_sm_created(struct bfa_fcs_vport_s *vport,
134 enum bfa_fcs_vport_event event)
135{
136 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
137 bfa_trc(__vport_fcs(vport), event);
138
139 switch (event) {
140 case BFA_FCS_VPORT_SM_START:
141 if (bfa_fcs_fabric_is_online(__vport_fabric(vport))
142 && bfa_fcs_fabric_npiv_capable(__vport_fabric(vport))) {
143 bfa_sm_set_state(vport, bfa_fcs_vport_sm_fdisc);
144 bfa_fcs_vport_do_fdisc(vport);
145 } else {
146 /**
147 * Fabric is offline or not NPIV capable, stay in
148 * offline state.
149 */
150 vport->vport_stats.fab_no_npiv++;
151 bfa_sm_set_state(vport, bfa_fcs_vport_sm_offline);
152 }
153 break;
154
155 case BFA_FCS_VPORT_SM_DELETE:
156 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
157 bfa_fcs_port_delete(&vport->lport);
158 break;
159
160 case BFA_FCS_VPORT_SM_ONLINE:
161 case BFA_FCS_VPORT_SM_OFFLINE:
162 /**
163 * Ignore ONLINE/OFFLINE events from fabric till vport is started.
164 */
165 break;
166
167 default:
168 bfa_sm_fault(__vport_fcs(vport), event);
169 }
170}
171
172/**
173 * Offline state - awaiting ONLINE event from fabric SM.
174 */
175static void
176bfa_fcs_vport_sm_offline(struct bfa_fcs_vport_s *vport,
177 enum bfa_fcs_vport_event event)
178{
179 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
180 bfa_trc(__vport_fcs(vport), event);
181
182 switch (event) {
183 case BFA_FCS_VPORT_SM_DELETE:
184 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
185 bfa_fcs_port_delete(&vport->lport);
186 break;
187
188 case BFA_FCS_VPORT_SM_ONLINE:
189 bfa_sm_set_state(vport, bfa_fcs_vport_sm_fdisc);
190 vport->fdisc_retries = 0;
191 bfa_fcs_vport_do_fdisc(vport);
192 break;
193
194 case BFA_FCS_VPORT_SM_OFFLINE:
195 /*
196 * This can happen if the vport couldn't be initialzied due
197 * the fact that the npiv was not enabled on the switch. In
198 * that case we will put the vport in offline state. However,
199 * the link can go down and cause the this event to be sent when
200 * we are already offline. Ignore it.
201 */
202 break;
203
204 default:
205 bfa_sm_fault(__vport_fcs(vport), event);
206 }
207}
208
209/**
210 * FDISC is sent and awaiting reply from fabric.
211 */
212static void
213bfa_fcs_vport_sm_fdisc(struct bfa_fcs_vport_s *vport,
214 enum bfa_fcs_vport_event event)
215{
216 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
217 bfa_trc(__vport_fcs(vport), event);
218
219 switch (event) {
220 case BFA_FCS_VPORT_SM_DELETE:
221 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
222 bfa_lps_discard(vport->lps);
223 bfa_fcs_port_delete(&vport->lport);
224 break;
225
226 case BFA_FCS_VPORT_SM_OFFLINE:
227 bfa_sm_set_state(vport, bfa_fcs_vport_sm_offline);
228 bfa_lps_discard(vport->lps);
229 break;
230
231 case BFA_FCS_VPORT_SM_RSP_OK:
232 bfa_sm_set_state(vport, bfa_fcs_vport_sm_online);
233 bfa_fcs_port_online(&vport->lport);
234 break;
235
236 case BFA_FCS_VPORT_SM_RSP_ERROR:
237 bfa_sm_set_state(vport, bfa_fcs_vport_sm_fdisc_retry);
238 bfa_timer_start(__vport_bfa(vport), &vport->timer,
239 bfa_fcs_vport_timeout, vport,
240 BFA_FCS_RETRY_TIMEOUT);
241 break;
242
243 case BFA_FCS_VPORT_SM_RSP_FAILED:
244 bfa_sm_set_state(vport, bfa_fcs_vport_sm_offline);
245 break;
246
247 case BFA_FCS_VPORT_SM_RSP_DUP_WWN:
248 bfa_sm_set_state(vport, bfa_fcs_vport_sm_error);
249 break;
250
251 default:
252 bfa_sm_fault(__vport_fcs(vport), event);
253 }
254}
255
256/**
257 * FDISC attempt failed - a timer is active to retry FDISC.
258 */
259static void
260bfa_fcs_vport_sm_fdisc_retry(struct bfa_fcs_vport_s *vport,
261 enum bfa_fcs_vport_event event)
262{
263 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
264 bfa_trc(__vport_fcs(vport), event);
265
266 switch (event) {
267 case BFA_FCS_VPORT_SM_DELETE:
268 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
269 bfa_timer_stop(&vport->timer);
270 bfa_fcs_port_delete(&vport->lport);
271 break;
272
273 case BFA_FCS_VPORT_SM_OFFLINE:
274 bfa_sm_set_state(vport, bfa_fcs_vport_sm_offline);
275 bfa_timer_stop(&vport->timer);
276 break;
277
278 case BFA_FCS_VPORT_SM_TIMEOUT:
279 bfa_sm_set_state(vport, bfa_fcs_vport_sm_fdisc);
280 vport->vport_stats.fdisc_retries++;
281 vport->fdisc_retries++;
282 bfa_fcs_vport_do_fdisc(vport);
283 break;
284
285 default:
286 bfa_sm_fault(__vport_fcs(vport), event);
287 }
288}
289
290/**
291 * Vport is online (FDISC is complete).
292 */
293static void
294bfa_fcs_vport_sm_online(struct bfa_fcs_vport_s *vport,
295 enum bfa_fcs_vport_event event)
296{
297 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
298 bfa_trc(__vport_fcs(vport), event);
299
300 switch (event) {
301 case BFA_FCS_VPORT_SM_DELETE:
302 bfa_sm_set_state(vport, bfa_fcs_vport_sm_deleting);
303 bfa_fcs_port_delete(&vport->lport);
304 break;
305
306 case BFA_FCS_VPORT_SM_OFFLINE:
307 bfa_sm_set_state(vport, bfa_fcs_vport_sm_offline);
308 bfa_lps_discard(vport->lps);
309 bfa_fcs_port_offline(&vport->lport);
310 break;
311
312 default:
313 bfa_sm_fault(__vport_fcs(vport), event);
314 }
315}
316
317/**
318 * Vport is being deleted - awaiting lport delete completion to send
319 * LOGO to fabric.
320 */
321static void
322bfa_fcs_vport_sm_deleting(struct bfa_fcs_vport_s *vport,
323 enum bfa_fcs_vport_event event)
324{
325 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
326 bfa_trc(__vport_fcs(vport), event);
327
328 switch (event) {
329 case BFA_FCS_VPORT_SM_DELETE:
330 break;
331
332 case BFA_FCS_VPORT_SM_DELCOMP:
333 bfa_sm_set_state(vport, bfa_fcs_vport_sm_logo);
334 bfa_fcs_vport_do_logo(vport);
335 break;
336
337 case BFA_FCS_VPORT_SM_OFFLINE:
338 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
339 break;
340
341 default:
342 bfa_sm_fault(__vport_fcs(vport), event);
343 }
344}
345
346/**
347 * Error State.
348 * This state will be set when the Vport Creation fails due to errors like
349 * Dup WWN. In this state only operation allowed is a Vport Delete.
350 */
351static void
352bfa_fcs_vport_sm_error(struct bfa_fcs_vport_s *vport,
353 enum bfa_fcs_vport_event event)
354{
355 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
356 bfa_trc(__vport_fcs(vport), event);
357
358 switch (event) {
359 case BFA_FCS_VPORT_SM_DELETE:
360 bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
361 bfa_fcs_port_delete(&vport->lport);
362
363 break;
364
365 default:
366 bfa_trc(__vport_fcs(vport), event);
367 }
368}
369
370/**
371 * Lport cleanup is in progress since vport is being deleted. Fabric is
372 * offline, so no LOGO is needed to complete vport deletion.
373 */
374static void
375bfa_fcs_vport_sm_cleanup(struct bfa_fcs_vport_s *vport,
376 enum bfa_fcs_vport_event event)
377{
378 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
379 bfa_trc(__vport_fcs(vport), event);
380
381 switch (event) {
382 case BFA_FCS_VPORT_SM_DELCOMP:
383 bfa_sm_set_state(vport, bfa_fcs_vport_sm_uninit);
384 bfa_fcs_vport_free(vport);
385 break;
386
387 case BFA_FCS_VPORT_SM_DELETE:
388 break;
389
390 default:
391 bfa_sm_fault(__vport_fcs(vport), event);
392 }
393}
394
395/**
396 * LOGO is sent to fabric. Vport delete is in progress. Lport delete cleanup
397 * is done.
398 */
399static void
400bfa_fcs_vport_sm_logo(struct bfa_fcs_vport_s *vport,
401 enum bfa_fcs_vport_event event)
402{
403 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
404 bfa_trc(__vport_fcs(vport), event);
405
406 switch (event) {
407 case BFA_FCS_VPORT_SM_OFFLINE:
408 bfa_lps_discard(vport->lps);
409 /*
410 * !!! fall through !!!
411 */
412
413 case BFA_FCS_VPORT_SM_RSP_OK:
414 case BFA_FCS_VPORT_SM_RSP_ERROR:
415 bfa_sm_set_state(vport, bfa_fcs_vport_sm_uninit);
416 bfa_fcs_vport_free(vport);
417 break;
418
419 case BFA_FCS_VPORT_SM_DELETE:
420 break;
421
422 default:
423 bfa_sm_fault(__vport_fcs(vport), event);
424 }
425}
426
427
428
429/**
430 * fcs_vport_private FCS virtual port private functions
431 */
432
433/**
434 * Send AEN notification
435 */
436static void
437bfa_fcs_vport_aen_post(bfa_fcs_lport_t *port, enum bfa_lport_aen_event event)
438{
439 union bfa_aen_data_u aen_data;
440 struct bfa_log_mod_s *logmod = port->fcs->logm;
441 enum bfa_port_role role = port->port_cfg.roles;
442 wwn_t lpwwn = bfa_fcs_port_get_pwwn(port);
443 char lpwwn_ptr[BFA_STRING_32];
444 char *role_str[BFA_PORT_ROLE_FCP_MAX / 2 + 1] =
445 { "Initiator", "Target", "IPFC" };
446
447 wwn2str(lpwwn_ptr, lpwwn);
448
449 bfa_assert(role <= BFA_PORT_ROLE_FCP_MAX);
450
451 bfa_log(logmod, BFA_LOG_CREATE_ID(BFA_AEN_CAT_LPORT, event), lpwwn_ptr,
452 role_str[role/2]);
453
454 aen_data.lport.vf_id = port->fabric->vf_id;
455 aen_data.lport.roles = role;
456 aen_data.lport.ppwwn =
457 bfa_fcs_port_get_pwwn(bfa_fcs_get_base_port(port->fcs));
458 aen_data.lport.lpwwn = lpwwn;
459}
460
461/**
462 * This routine will be called to send a FDISC command.
463 */
464static void
465bfa_fcs_vport_do_fdisc(struct bfa_fcs_vport_s *vport)
466{
467 bfa_lps_fdisc(vport->lps, vport,
468 bfa_fcport_get_maxfrsize(__vport_bfa(vport)),
469 __vport_pwwn(vport), __vport_nwwn(vport));
470 vport->vport_stats.fdisc_sent++;
471}
472
473static void
474bfa_fcs_vport_fdisc_rejected(struct bfa_fcs_vport_s *vport)
475{
476 u8 lsrjt_rsn = bfa_lps_get_lsrjt_rsn(vport->lps);
477 u8 lsrjt_expl = bfa_lps_get_lsrjt_expl(vport->lps);
478
479 bfa_trc(__vport_fcs(vport), lsrjt_rsn);
480 bfa_trc(__vport_fcs(vport), lsrjt_expl);
481
482 /*
483 * For certain reason codes, we don't want to retry.
484 */
485 switch (bfa_lps_get_lsrjt_expl(vport->lps)) {
486 case FC_LS_RJT_EXP_INV_PORT_NAME: /* by brocade */
487 case FC_LS_RJT_EXP_INVALID_NPORT_ID: /* by Cisco */
488 if (vport->fdisc_retries < BFA_FCS_VPORT_MAX_RETRIES)
489 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
490 else {
491 bfa_fcs_vport_aen_post(&vport->lport,
492 BFA_LPORT_AEN_NPIV_DUP_WWN);
493 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_DUP_WWN);
494 }
495 break;
496
497 case FC_LS_RJT_EXP_INSUFF_RES:
498 /*
499 * This means max logins per port/switch setting on the
500 * switch was exceeded.
501 */
502 if (vport->fdisc_retries < BFA_FCS_VPORT_MAX_RETRIES)
503 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
504 else {
505 bfa_fcs_vport_aen_post(&vport->lport,
506 BFA_LPORT_AEN_NPIV_FABRIC_MAX);
507 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_FAILED);
508 }
509 break;
510
511 default:
512 if (vport->fdisc_retries == 0) /* Print only once */
513 bfa_fcs_vport_aen_post(&vport->lport,
514 BFA_LPORT_AEN_NPIV_UNKNOWN);
515 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
516 }
517}
518
519/**
520 * Called to send a logout to the fabric. Used when a V-Port is
521 * deleted/stopped.
522 */
523static void
524bfa_fcs_vport_do_logo(struct bfa_fcs_vport_s *vport)
525{
526 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
527
528 vport->vport_stats.logo_sent++;
529 bfa_lps_fdisclogo(vport->lps);
530}
531
532/**
533 * This routine will be called by bfa_timer on timer timeouts.
534 *
535 * param[in] vport - pointer to bfa_fcs_vport_t.
536 * param[out] vport_status - pointer to return vport status in
537 *
538 * return
539 * void
540 *
541* Special Considerations:
542 *
543 * note
544 */
545static void
546bfa_fcs_vport_timeout(void *vport_arg)
547{
548 struct bfa_fcs_vport_s *vport = (struct bfa_fcs_vport_s *)vport_arg;
549
550 vport->vport_stats.fdisc_timeouts++;
551 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_TIMEOUT);
552}
553
554static void
555bfa_fcs_vport_free(struct bfa_fcs_vport_s *vport)
556{
557 bfa_fcs_fabric_delvport(__vport_fabric(vport), vport);
558 bfa_fcb_vport_delete(vport->vport_drv);
559 bfa_lps_delete(vport->lps);
560}
561
562
563
564/**
565 * fcs_vport_public FCS virtual port public interfaces
566 */
567
568/**
569 * Online notification from fabric SM.
570 */
571void
572bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport)
573{
574 vport->vport_stats.fab_online++;
575 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_ONLINE);
576}
577
578/**
579 * Offline notification from fabric SM.
580 */
581void
582bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport)
583{
584 vport->vport_stats.fab_offline++;
585 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_OFFLINE);
586}
587
588/**
589 * Cleanup notification from fabric SM on link timer expiry.
590 */
591void
592bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s *vport)
593{
594 vport->vport_stats.fab_cleanup++;
595}
596
597/**
598 * delete notification from fabric SM. To be invoked from within FCS.
599 */
600void
601bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s *vport)
602{
603 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_DELETE);
604}
605
606/**
607 * Delete completion callback from associated lport
608 */
609void
610bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport)
611{
612 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_DELCOMP);
613}
614
615/**
616 * fcs_vport_api Virtual port API
617 */
618
619/**
620 * Use this function to instantiate a new FCS vport object. This
621 * function will not trigger any HW initialization process (which will be
622 * done in vport_start() call)
623 *
624 * param[in] vport - pointer to bfa_fcs_vport_t. This space
625 * needs to be allocated by the driver.
626 * param[in] fcs - FCS instance
627 * param[in] vport_cfg - vport configuration
628 * param[in] vf_id - VF_ID if vport is created within a VF.
629 * FC_VF_ID_NULL to specify base fabric.
630 * param[in] vport_drv - Opaque handle back to the driver's vport
631 * structure
632 *
633 * retval BFA_STATUS_OK - on success.
634 * retval BFA_STATUS_FAILED - on failure.
635 */
636bfa_status_t
637bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport, struct bfa_fcs_s *fcs,
638 u16 vf_id, struct bfa_port_cfg_s *vport_cfg,
639 struct bfad_vport_s *vport_drv)
640{
641 if (vport_cfg->pwwn == 0)
642 return BFA_STATUS_INVALID_WWN;
643
644 if (bfa_fcs_port_get_pwwn(&fcs->fabric.bport) == vport_cfg->pwwn)
645 return BFA_STATUS_VPORT_WWN_BP;
646
647 if (bfa_fcs_vport_lookup(fcs, vf_id, vport_cfg->pwwn) != NULL)
648 return BFA_STATUS_VPORT_EXISTS;
649
650 if (bfa_fcs_fabric_vport_count(&fcs->fabric) ==
651 bfa_lps_get_max_vport(fcs->bfa))
652 return BFA_STATUS_VPORT_MAX;
653
654 vport->lps = bfa_lps_alloc(fcs->bfa);
655 if (!vport->lps)
656 return BFA_STATUS_VPORT_MAX;
657
658 vport->vport_drv = vport_drv;
659 vport_cfg->preboot_vp = BFA_FALSE;
660 bfa_sm_set_state(vport, bfa_fcs_vport_sm_uninit);
661
662 bfa_fcs_lport_attach(&vport->lport, fcs, vf_id, vport);
663 bfa_fcs_lport_init(&vport->lport, vport_cfg);
664
665 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_CREATE);
666
667 return BFA_STATUS_OK;
668}
669
670/**
671 * Use this function to instantiate a new FCS PBC vport object. This
672 * function will not trigger any HW initialization process (which will be
673 * done in vport_start() call)
674 *
675 * param[in] vport - pointer to bfa_fcs_vport_t. This space
676 * needs to be allocated by the driver.
677 * param[in] fcs - FCS instance
678 * param[in] vport_cfg - vport configuration
679 * param[in] vf_id - VF_ID if vport is created within a VF.
680 * FC_VF_ID_NULL to specify base fabric.
681 * param[in] vport_drv - Opaque handle back to the driver's vport
682 * structure
683 *
684 * retval BFA_STATUS_OK - on success.
685 * retval BFA_STATUS_FAILED - on failure.
686 */
687bfa_status_t
688bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s *vport, struct bfa_fcs_s *fcs,
689 uint16_t vf_id, struct bfa_port_cfg_s *vport_cfg,
690 struct bfad_vport_s *vport_drv)
691{
692 bfa_status_t rc;
693
694 rc = bfa_fcs_vport_create(vport, fcs, vf_id, vport_cfg, vport_drv);
695 vport->lport.port_cfg.preboot_vp = BFA_TRUE;
696
697 return rc;
698}
699
700/**
701 * Use this function initialize the vport.
702 *
703 * @param[in] vport - pointer to bfa_fcs_vport_t.
704 *
705 * @returns None
706 */
707bfa_status_t
708bfa_fcs_vport_start(struct bfa_fcs_vport_s *vport)
709{
710 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_START);
711
712 return BFA_STATUS_OK;
713}
714
715/**
716 * Use this function quiese the vport object. This function will return
717 * immediately, when the vport is actually stopped, the
718 * bfa_drv_vport_stop_cb() will be called.
719 *
720 * param[in] vport - pointer to bfa_fcs_vport_t.
721 *
722 * return None
723 */
724bfa_status_t
725bfa_fcs_vport_stop(struct bfa_fcs_vport_s *vport)
726{
727 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_STOP);
728
729 return BFA_STATUS_OK;
730}
731
732/**
733 * Use this function to delete a vport object. Fabric object should
734 * be stopped before this function call.
735 *
736 * Donot invoke this from within FCS
737 *
738 * param[in] vport - pointer to bfa_fcs_vport_t.
739 *
740 * return None
741 */
742bfa_status_t
743bfa_fcs_vport_delete(struct bfa_fcs_vport_s *vport)
744{
745 if (vport->lport.port_cfg.preboot_vp)
746 return BFA_STATUS_PBC;
747
748 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_DELETE);
749
750 return BFA_STATUS_OK;
751}
752
753/**
754 * Use this function to get vport's current status info.
755 *
756 * param[in] vport pointer to bfa_fcs_vport_t.
757 * param[out] attr pointer to return vport attributes
758 *
759 * return None
760 */
761void
762bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport,
763 struct bfa_vport_attr_s *attr)
764{
765 if (vport == NULL || attr == NULL)
766 return;
767
768 bfa_os_memset(attr, 0, sizeof(struct bfa_vport_attr_s));
769
770 bfa_fcs_port_get_attr(&vport->lport, &attr->port_attr);
771 attr->vport_state = bfa_sm_to_state(vport_sm_table, vport->sm);
772}
773
774/**
775 * Use this function to get vport's statistics.
776 *
777 * param[in] vport pointer to bfa_fcs_vport_t.
778 * param[out] stats pointer to return vport statistics in
779 *
780 * return None
781 */
782void
783bfa_fcs_vport_get_stats(struct bfa_fcs_vport_s *vport,
784 struct bfa_vport_stats_s *stats)
785{
786 *stats = vport->vport_stats;
787}
788
789/**
790 * Use this function to clear vport's statistics.
791 *
792 * param[in] vport pointer to bfa_fcs_vport_t.
793 *
794 * return None
795 */
796void
797bfa_fcs_vport_clr_stats(struct bfa_fcs_vport_s *vport)
798{
799 bfa_os_memset(&vport->vport_stats, 0, sizeof(struct bfa_vport_stats_s));
800}
801
802/**
803 * Lookup a virtual port. Excludes base port from lookup.
804 */
805struct bfa_fcs_vport_s *
806bfa_fcs_vport_lookup(struct bfa_fcs_s *fcs, u16 vf_id, wwn_t vpwwn)
807{
808 struct bfa_fcs_vport_s *vport;
809 struct bfa_fcs_fabric_s *fabric;
810
811 bfa_trc(fcs, vf_id);
812 bfa_trc(fcs, vpwwn);
813
814 fabric = bfa_fcs_vf_lookup(fcs, vf_id);
815 if (!fabric) {
816 bfa_trc(fcs, vf_id);
817 return NULL;
818 }
819
820 vport = bfa_fcs_fabric_vport_lookup(fabric, vpwwn);
821 return vport;
822}
823
824/**
825 * FDISC Response
826 */
827void
828bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, bfa_status_t status)
829{
830 struct bfa_fcs_vport_s *vport = uarg;
831
832 bfa_trc(__vport_fcs(vport), __vport_pwwn(vport));
833 bfa_trc(__vport_fcs(vport), status);
834
835 switch (status) {
836 case BFA_STATUS_OK:
837 /*
838 * Initialize the V-Port fields
839 */
840 __vport_fcid(vport) = bfa_lps_get_pid(vport->lps);
841 vport->vport_stats.fdisc_accepts++;
842 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_OK);
843 break;
844
845 case BFA_STATUS_INVALID_MAC:
846 /*
847 * Only for CNA
848 */
849 vport->vport_stats.fdisc_acc_bad++;
850 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
851
852 break;
853
854 case BFA_STATUS_EPROTOCOL:
855 switch (bfa_lps_get_extstatus(vport->lps)) {
856 case BFA_EPROTO_BAD_ACCEPT:
857 vport->vport_stats.fdisc_acc_bad++;
858 break;
859
860 case BFA_EPROTO_UNKNOWN_RSP:
861 vport->vport_stats.fdisc_unknown_rsp++;
862 break;
863
864 default:
865 break;
866 }
867
868 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
869 break;
870
871 case BFA_STATUS_FABRIC_RJT:
872 vport->vport_stats.fdisc_rejects++;
873 bfa_fcs_vport_fdisc_rejected(vport);
874 break;
875
876 default:
877 vport->vport_stats.fdisc_rsp_err++;
878 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
879 }
880}
881
882/**
883 * LOGO response
884 */
885void
886bfa_cb_lps_fdisclogo_comp(void *bfad, void *uarg)
887{
888 struct bfa_fcs_vport_s *vport = uarg;
889 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_OK);
890}
891
892/**
893 * Received clear virtual link
894 */
895void
896bfa_cb_lps_cvl_event(void *bfad, void *uarg)
897{
898 struct bfa_fcs_vport_s *vport = uarg;
899
900 /* Send an Offline followed by an ONLINE */
901 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_OFFLINE);
902 bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_ONLINE);
903}