[SCSI] bfa: cleanup driver
Krishna Gudipati [Wed, 15 Sep 2010 18:50:55 +0000 (11:50 -0700)]
We have flattened the BFA hierarchy and also reduced the number of
source and header files we used to have earlier.

Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>

212 files changed:
drivers/scsi/bfa/Makefile
drivers/scsi/bfa/bfa.h [new file with mode: 0644]
drivers/scsi/bfa/bfa_callback_priv.h [deleted file]
drivers/scsi/bfa/bfa_cb_ioim.h [moved from drivers/scsi/bfa/bfa_cb_ioim_macros.h with 85% similarity]
drivers/scsi/bfa/bfa_cee.c [deleted file]
drivers/scsi/bfa/bfa_core.c
drivers/scsi/bfa/bfa_cs.h [new file with mode: 0644]
drivers/scsi/bfa/bfa_csdebug.c [deleted file]
drivers/scsi/bfa/bfa_defs.h [new file with mode: 0644]
drivers/scsi/bfa/bfa_defs_fcs.h [new file with mode: 0644]
drivers/scsi/bfa/bfa_defs_svc.h [new file with mode: 0644]
drivers/scsi/bfa/bfa_drv.c [moved from drivers/scsi/bfa/bfa_module.c with 76% similarity]
drivers/scsi/bfa/bfa_fc.h [new file with mode: 0644]
drivers/scsi/bfa/bfa_fcbuild.c [moved from drivers/scsi/bfa/fcbuild.c with 82% similarity]
drivers/scsi/bfa/bfa_fcbuild.h [new file with mode: 0644]
drivers/scsi/bfa/bfa_fcpim.c
drivers/scsi/bfa/bfa_fcpim.h [new file with mode: 0644]
drivers/scsi/bfa/bfa_fcpim_priv.h [deleted file]
drivers/scsi/bfa/bfa_fcport.c [deleted file]
drivers/scsi/bfa/bfa_fcs.c
drivers/scsi/bfa/bfa_fcs.h [new file with mode: 0644]
drivers/scsi/bfa/bfa_fcs_fcpim.c [moved from drivers/scsi/bfa/fcpim.c with 75% similarity]
drivers/scsi/bfa/bfa_fcs_lport.c
drivers/scsi/bfa/bfa_fcs_port.c [deleted file]
drivers/scsi/bfa/bfa_fcs_rport.c [moved from drivers/scsi/bfa/rport.c with 58% similarity]
drivers/scsi/bfa/bfa_fcs_uf.c [deleted file]
drivers/scsi/bfa/bfa_fcxp.c [deleted file]
drivers/scsi/bfa/bfa_fcxp_priv.h [deleted file]
drivers/scsi/bfa/bfa_fwimg_priv.h [deleted file]
drivers/scsi/bfa/bfa_hw_cb.c
drivers/scsi/bfa/bfa_hw_ct.c
drivers/scsi/bfa/bfa_intr.c [deleted file]
drivers/scsi/bfa/bfa_intr_priv.h [deleted file]
drivers/scsi/bfa/bfa_ioc.c
drivers/scsi/bfa/bfa_ioc.h
drivers/scsi/bfa/bfa_ioc_cb.c
drivers/scsi/bfa/bfa_ioc_ct.c
drivers/scsi/bfa/bfa_iocfc.c [deleted file]
drivers/scsi/bfa/bfa_iocfc.h [deleted file]
drivers/scsi/bfa/bfa_iocfc_q.c [deleted file]
drivers/scsi/bfa/bfa_ioim.c [deleted file]
drivers/scsi/bfa/bfa_itnim.c [deleted file]
drivers/scsi/bfa/bfa_log.c [deleted file]
drivers/scsi/bfa/bfa_log_module.c [deleted file]
drivers/scsi/bfa/bfa_lps.c [deleted file]
drivers/scsi/bfa/bfa_lps_priv.h [deleted file]
drivers/scsi/bfa/bfa_modules.h [moved from drivers/scsi/bfa/bfa_priv.h with 69% similarity]
drivers/scsi/bfa/bfa_modules_priv.h [deleted file]
drivers/scsi/bfa/bfa_os_inc.h
drivers/scsi/bfa/bfa_plog.h [moved from drivers/scsi/bfa/include/cs/bfa_plog.h with 59% similarity]
drivers/scsi/bfa/bfa_port.c
drivers/scsi/bfa/bfa_port.h [new file with mode: 0644]
drivers/scsi/bfa/bfa_port_priv.h [deleted file]
drivers/scsi/bfa/bfa_rport.c [deleted file]
drivers/scsi/bfa/bfa_rport_priv.h [deleted file]
drivers/scsi/bfa/bfa_sgpg.c [deleted file]
drivers/scsi/bfa/bfa_sgpg_priv.h [deleted file]
drivers/scsi/bfa/bfa_sm.c [deleted file]
drivers/scsi/bfa/bfa_svc.c [new file with mode: 0644]
drivers/scsi/bfa/bfa_svc.h [new file with mode: 0644]
drivers/scsi/bfa/bfa_timer.c [deleted file]
drivers/scsi/bfa/bfa_trcmod_priv.h [deleted file]
drivers/scsi/bfa/bfa_tskim.c [deleted file]
drivers/scsi/bfa/bfa_uf.c [deleted file]
drivers/scsi/bfa/bfa_uf_priv.h [deleted file]
drivers/scsi/bfa/bfad.c
drivers/scsi/bfa/bfad_attr.c
drivers/scsi/bfa/bfad_attr.h [deleted file]
drivers/scsi/bfa/bfad_debugfs.c
drivers/scsi/bfa/bfad_drv.h
drivers/scsi/bfa/bfad_fwimg.c [deleted file]
drivers/scsi/bfa/bfad_im.c
drivers/scsi/bfa/bfad_im.h
drivers/scsi/bfa/bfad_im_compat.h [deleted file]
drivers/scsi/bfa/bfad_intr.c [deleted file]
drivers/scsi/bfa/bfad_ipfc.h [deleted file]
drivers/scsi/bfa/bfad_os.c [deleted file]
drivers/scsi/bfa/bfad_tm.h [deleted file]
drivers/scsi/bfa/bfad_trcmod.h [deleted file]
drivers/scsi/bfa/bfi.h [new file with mode: 0644]
drivers/scsi/bfa/bfi_cbreg.h [moved from drivers/scsi/bfa/include/bfi/bfi_cbreg.h with 94% similarity]
drivers/scsi/bfa/bfi_ctreg.h [new file with mode: 0644]
drivers/scsi/bfa/bfi_ms.h [new file with mode: 0644]
drivers/scsi/bfa/fab.c [deleted file]
drivers/scsi/bfa/fabric.c [deleted file]
drivers/scsi/bfa/fcbuild.h [deleted file]
drivers/scsi/bfa/fcptm.c [deleted file]
drivers/scsi/bfa/fcs.h [deleted file]
drivers/scsi/bfa/fcs_auth.h [deleted file]
drivers/scsi/bfa/fcs_fabric.h [deleted file]
drivers/scsi/bfa/fcs_fcpim.h [deleted file]
drivers/scsi/bfa/fcs_fcptm.h [deleted file]
drivers/scsi/bfa/fcs_fcxp.h [deleted file]
drivers/scsi/bfa/fcs_lport.h [deleted file]
drivers/scsi/bfa/fcs_ms.h [deleted file]
drivers/scsi/bfa/fcs_port.h [deleted file]
drivers/scsi/bfa/fcs_rport.h [deleted file]
drivers/scsi/bfa/fcs_trcmod.h [deleted file]
drivers/scsi/bfa/fcs_uf.h [deleted file]
drivers/scsi/bfa/fcs_vport.h [deleted file]
drivers/scsi/bfa/fdmi.c [deleted file]
drivers/scsi/bfa/include/aen/bfa_aen.h [deleted file]
drivers/scsi/bfa/include/aen/bfa_aen_adapter.h [deleted file]
drivers/scsi/bfa/include/aen/bfa_aen_audit.h [deleted file]
drivers/scsi/bfa/include/aen/bfa_aen_ethport.h [deleted file]
drivers/scsi/bfa/include/aen/bfa_aen_ioc.h [deleted file]
drivers/scsi/bfa/include/aen/bfa_aen_itnim.h [deleted file]
drivers/scsi/bfa/include/aen/bfa_aen_lport.h [deleted file]
drivers/scsi/bfa/include/aen/bfa_aen_port.h [deleted file]
drivers/scsi/bfa/include/aen/bfa_aen_rport.h [deleted file]
drivers/scsi/bfa/include/bfa.h [deleted file]
drivers/scsi/bfa/include/bfa_fcpim.h [deleted file]
drivers/scsi/bfa/include/bfa_fcptm.h [deleted file]
drivers/scsi/bfa/include/bfa_svc.h [deleted file]
drivers/scsi/bfa/include/bfa_timer.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_boot.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_cee.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_ctreg.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_fabric.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_fcpim.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_fcxp.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_ioc.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_iocfc.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_lport.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_lps.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_pbc.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_port.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_pport.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_rport.h [deleted file]
drivers/scsi/bfa/include/bfi/bfi_uf.h [deleted file]
drivers/scsi/bfa/include/cna/bfa_cna_trcmod.h [deleted file]
drivers/scsi/bfa/include/cna/cee/bfa_cee.h [deleted file]
drivers/scsi/bfa/include/cna/port/bfa_port.h [deleted file]
drivers/scsi/bfa/include/cna/pstats/ethport_defs.h [deleted file]
drivers/scsi/bfa/include/cna/pstats/phyport_defs.h [deleted file]
drivers/scsi/bfa/include/cs/bfa_checksum.h [deleted file]
drivers/scsi/bfa/include/cs/bfa_debug.h [deleted file]
drivers/scsi/bfa/include/cs/bfa_log.h [deleted file]
drivers/scsi/bfa/include/cs/bfa_perf.h [deleted file]
drivers/scsi/bfa/include/cs/bfa_q.h [deleted file]
drivers/scsi/bfa/include/cs/bfa_sm.h [deleted file]
drivers/scsi/bfa/include/cs/bfa_trc.h [deleted file]
drivers/scsi/bfa/include/cs/bfa_wc.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_adapter.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_aen.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_audit.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_auth.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_boot.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_cee.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_driver.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_ethport.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_fcpim.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_fcport.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_ioc.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_iocfc.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_ipfc.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_itnim.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_led.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_lport.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_mfg.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_pci.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_pm.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_pom.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_port.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_pport.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_qos.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_rport.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_status.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_tin.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_tsensor.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_types.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_version.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_vf.h [deleted file]
drivers/scsi/bfa/include/defs/bfa_defs_vport.h [deleted file]
drivers/scsi/bfa/include/fcb/bfa_fcb.h [deleted file]
drivers/scsi/bfa/include/fcb/bfa_fcb_fcpim.h [deleted file]
drivers/scsi/bfa/include/fcb/bfa_fcb_port.h [deleted file]
drivers/scsi/bfa/include/fcb/bfa_fcb_rport.h [deleted file]
drivers/scsi/bfa/include/fcb/bfa_fcb_vf.h [deleted file]
drivers/scsi/bfa/include/fcb/bfa_fcb_vport.h [deleted file]
drivers/scsi/bfa/include/fcs/bfa_fcs.h [deleted file]
drivers/scsi/bfa/include/fcs/bfa_fcs_auth.h [deleted file]
drivers/scsi/bfa/include/fcs/bfa_fcs_fabric.h [deleted file]
drivers/scsi/bfa/include/fcs/bfa_fcs_fcpim.h [deleted file]
drivers/scsi/bfa/include/fcs/bfa_fcs_fdmi.h [deleted file]
drivers/scsi/bfa/include/fcs/bfa_fcs_lport.h [deleted file]
drivers/scsi/bfa/include/fcs/bfa_fcs_rport.h [deleted file]
drivers/scsi/bfa/include/fcs/bfa_fcs_vport.h [deleted file]
drivers/scsi/bfa/include/log/bfa_log_fcs.h [deleted file]
drivers/scsi/bfa/include/log/bfa_log_hal.h [deleted file]
drivers/scsi/bfa/include/log/bfa_log_linux.h [deleted file]
drivers/scsi/bfa/include/log/bfa_log_wdrv.h [deleted file]
drivers/scsi/bfa/include/protocol/ct.h [deleted file]
drivers/scsi/bfa/include/protocol/fc.h [deleted file]
drivers/scsi/bfa/include/protocol/fc_sp.h [deleted file]
drivers/scsi/bfa/include/protocol/fcp.h [deleted file]
drivers/scsi/bfa/include/protocol/fdmi.h [deleted file]
drivers/scsi/bfa/include/protocol/scsi.h [deleted file]
drivers/scsi/bfa/include/protocol/types.h [deleted file]
drivers/scsi/bfa/loop.c [deleted file]
drivers/scsi/bfa/lport_api.c [deleted file]
drivers/scsi/bfa/lport_priv.h [deleted file]
drivers/scsi/bfa/ms.c [deleted file]
drivers/scsi/bfa/n2n.c [deleted file]
drivers/scsi/bfa/ns.c [deleted file]
drivers/scsi/bfa/plog.c [deleted file]
drivers/scsi/bfa/rport_api.c [deleted file]
drivers/scsi/bfa/rport_ftrs.c [deleted file]
drivers/scsi/bfa/scn.c [deleted file]
drivers/scsi/bfa/vfapi.c [deleted file]
drivers/scsi/bfa/vport.c [deleted file]

index ac3fdf0..d2eefd3 100644 (file)
@@ -1,15 +1,8 @@
 obj-$(CONFIG_SCSI_BFA_FC) := bfa.o
 
-bfa-y := bfad.o bfad_intr.o bfad_os.o bfad_im.o bfad_attr.o bfad_fwimg.o
-bfa-y += bfad_debugfs.o
-bfa-y += bfa_core.o bfa_ioc.o bfa_ioc_ct.o bfa_ioc_cb.o bfa_iocfc.o bfa_fcxp.o
-bfa-y += bfa_lps.o bfa_hw_cb.o bfa_hw_ct.o bfa_intr.o bfa_timer.o bfa_rport.o
-bfa-y += bfa_fcport.o bfa_port.o bfa_uf.o bfa_sgpg.o bfa_module.o bfa_ioim.o
-bfa-y += bfa_itnim.o bfa_fcpim.o bfa_tskim.o bfa_log.o bfa_log_module.o
-bfa-y += bfa_csdebug.o bfa_sm.o plog.o
+bfa-y := bfad.o bfad_im.o bfad_attr.o bfad_debugfs.o
+bfa-y += bfa_ioc.o bfa_ioc_cb.o bfa_ioc_ct.o bfa_hw_cb.o bfa_hw_ct.o
+bfa-y += bfa_fcs.o bfa_fcs_lport.o bfa_fcs_rport.o bfa_fcs_fcpim.o bfa_fcbuild.o
+bfa-y += bfa_port.o bfa_fcpim.o bfa_core.o bfa_drv.o bfa_svc.o
 
-bfa-y += fcbuild.o fabric.o fcpim.o vfapi.o fcptm.o bfa_fcs.o bfa_fcs_port.o
-bfa-y += bfa_fcs_uf.o bfa_fcs_lport.o fab.o fdmi.o ms.o ns.o scn.o loop.o
-bfa-y += lport_api.o n2n.o rport.o rport_api.o rport_ftrs.o vport.o
-
-ccflags-y := -I$(obj) -I$(obj)/include -I$(obj)/include/cna -DBFA_PERF_BUILD
+ccflags-y := -DBFA_PERF_BUILD
diff --git a/drivers/scsi/bfa/bfa.h b/drivers/scsi/bfa/bfa.h
new file mode 100644 (file)
index 0000000..ceaac65
--- /dev/null
@@ -0,0 +1,438 @@
+/*
+ * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * All rights reserved
+ * www.brocade.com
+ *
+ * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License (GPL) Version 2 as
+ * published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+#ifndef __BFA_H__
+#define __BFA_H__
+
+#include "bfa_os_inc.h"
+#include "bfa_cs.h"
+#include "bfa_plog.h"
+#include "bfa_defs_svc.h"
+#include "bfi.h"
+#include "bfa_ioc.h"
+
+struct bfa_s;
+
+typedef void (*bfa_isr_func_t) (struct bfa_s *bfa, struct bfi_msg_s *m);
+typedef void    (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete);
+
+/**
+ * Interrupt message handlers
+ */
+void bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m);
+void bfa_isr_bind(enum bfi_mclass mc, bfa_isr_func_t isr_func);
+
+/**
+ * Request and response queue related defines
+ */
+#define BFA_REQQ_NELEMS_MIN    (4)
+#define BFA_RSPQ_NELEMS_MIN    (4)
+
+#define bfa_reqq_pi(__bfa, __reqq)     ((__bfa)->iocfc.req_cq_pi[__reqq])
+#define bfa_reqq_ci(__bfa, __reqq)                                     \
+       (*(u32 *)((__bfa)->iocfc.req_cq_shadow_ci[__reqq].kva))
+
+#define bfa_reqq_full(__bfa, __reqq)                           \
+       (((bfa_reqq_pi(__bfa, __reqq) + 1) &                    \
+         ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1)) ==    \
+        bfa_reqq_ci(__bfa, __reqq))
+
+#define bfa_reqq_next(__bfa, __reqq)                                   \
+       (bfa_reqq_full(__bfa, __reqq) ? NULL :                          \
+        ((void *)((struct bfi_msg_s *)((__bfa)->iocfc.req_cq_ba[__reqq].kva) \
+                  + bfa_reqq_pi((__bfa), (__reqq)))))
+
+#define bfa_reqq_produce(__bfa, __reqq)        do {                            \
+               (__bfa)->iocfc.req_cq_pi[__reqq]++;                     \
+               (__bfa)->iocfc.req_cq_pi[__reqq] &=                     \
+                       ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1);      \
+               bfa_reg_write((__bfa)->iocfc.bfa_regs.cpe_q_pi[__reqq], \
+                             (__bfa)->iocfc.req_cq_pi[__reqq]);      \
+               mmiowb();      \
+       } while (0)
+
+#define bfa_rspq_pi(__bfa, __rspq)                                     \
+       (*(u32 *)((__bfa)->iocfc.rsp_cq_shadow_pi[__rspq].kva))
+
+#define bfa_rspq_ci(__bfa, __rspq)     ((__bfa)->iocfc.rsp_cq_ci[__rspq])
+#define bfa_rspq_elem(__bfa, __rspq, __ci)                             \
+       (&((struct bfi_msg_s *)((__bfa)->iocfc.rsp_cq_ba[__rspq].kva))[__ci])
+
+#define CQ_INCR(__index, __size) do {                  \
+       (__index)++;                                    \
+       (__index) &= ((__size) - 1);                    \
+} while (0)
+
+/**
+ * Queue element to wait for room in request queue. FIFO order is
+ * maintained when fullfilling requests.
+ */
+struct bfa_reqq_wait_s {
+       struct list_head        qe;
+       void            (*qresume) (void *cbarg);
+       void            *cbarg;
+};
+
+/**
+ * Circular queue usage assignments
+ */
+enum {
+       BFA_REQQ_IOC    = 0,    /*  all low-priority IOC msgs   */
+       BFA_REQQ_FCXP   = 0,    /*  all FCXP messages           */
+       BFA_REQQ_LPS    = 0,    /*  all lport service msgs      */
+       BFA_REQQ_PORT   = 0,    /*  all port messages           */
+       BFA_REQQ_FLASH  = 0,    /*  for flash module            */
+       BFA_REQQ_DIAG   = 0,    /*  for diag module             */
+       BFA_REQQ_RPORT  = 0,    /*  all port messages           */
+       BFA_REQQ_SBOOT  = 0,    /*  all san boot messages       */
+       BFA_REQQ_QOS_LO = 1,    /*  all low priority IO */
+       BFA_REQQ_QOS_MD = 2,    /*  all medium priority IO      */
+       BFA_REQQ_QOS_HI = 3,    /*  all high priority IO        */
+};
+
+static inline void
+bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
+              void *cbarg)
+{
+       wqe->qresume = qresume;
+       wqe->cbarg = cbarg;
+}
+
+#define bfa_reqq(__bfa, __reqq)        (&(__bfa)->reqq_waitq[__reqq])
+
+/**
+ * static inline void
+ * bfa_reqq_wait(struct bfa_s *bfa, int reqq, struct bfa_reqq_wait_s *wqe)
+ */
+#define bfa_reqq_wait(__bfa, __reqq, __wqe) do {                       \
+                                                                       \
+               struct list_head *waitq = bfa_reqq(__bfa, __reqq);      \
+                                                                       \
+               bfa_assert(((__reqq) < BFI_IOC_MAX_CQS));      \
+               bfa_assert((__wqe)->qresume && (__wqe)->cbarg);      \
+                                                                       \
+               list_add_tail(&(__wqe)->qe, waitq);      \
+       } while (0)
+
+#define bfa_reqq_wcancel(__wqe)        list_del(&(__wqe)->qe)
+
+
+/**
+ * Generic BFA callback element.
+ */
+struct bfa_cb_qe_s {
+       struct list_head         qe;
+       bfa_cb_cbfn_t  cbfn;
+       bfa_boolean_t   once;
+       u32             rsvd;
+       void           *cbarg;
+};
+
+#define bfa_cb_queue(__bfa, __hcb_qe, __cbfn, __cbarg) do {    \
+               (__hcb_qe)->cbfn  = (__cbfn);      \
+               (__hcb_qe)->cbarg = (__cbarg);      \
+               list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q);      \
+       } while (0)
+
+#define bfa_cb_dequeue(__hcb_qe)       list_del(&(__hcb_qe)->qe)
+
+#define bfa_cb_queue_once(__bfa, __hcb_qe, __cbfn, __cbarg) do {       \
+               (__hcb_qe)->cbfn  = (__cbfn);      \
+               (__hcb_qe)->cbarg = (__cbarg);      \
+               if (!(__hcb_qe)->once) {      \
+                       list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q);      \
+                       (__hcb_qe)->once = BFA_TRUE;                    \
+               }                                                       \
+       } while (0)
+
+#define bfa_cb_queue_done(__hcb_qe) do {       \
+               (__hcb_qe)->once = BFA_FALSE;   \
+       } while (0)
+
+
+/**
+ * PCI devices supported by the current BFA
+ */
+struct bfa_pciid_s {
+       u16     device_id;
+       u16     vendor_id;
+};
+
+extern char     bfa_version[];
+
+/**
+ * BFA memory resources
+ */
+enum bfa_mem_type {
+       BFA_MEM_TYPE_KVA = 1,   /*  Kernel Virtual Memory *(non-dma-able) */
+       BFA_MEM_TYPE_DMA = 2,   /*  DMA-able memory */
+       BFA_MEM_TYPE_MAX = BFA_MEM_TYPE_DMA,
+};
+
+struct bfa_mem_elem_s {
+       enum bfa_mem_type mem_type;     /* see enum bfa_mem_type */
+       u32     mem_len;        /*  Total Length in Bytes       */
+       u8              *kva;           /*  kernel virtual address      */
+       u64     dma;            /*  dma address if DMA memory   */
+       u8              *kva_curp;      /*  kva allocation cursor       */
+       u64     dma_curp;       /*  dma allocation cursor       */
+};
+
+struct bfa_meminfo_s {
+       struct bfa_mem_elem_s meminfo[BFA_MEM_TYPE_MAX];
+};
+#define bfa_meminfo_kva(_m)                            \
+       ((_m)->meminfo[BFA_MEM_TYPE_KVA - 1].kva_curp)
+#define bfa_meminfo_dma_virt(_m)                       \
+       ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].kva_curp)
+#define bfa_meminfo_dma_phys(_m)                       \
+       ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].dma_curp)
+
+struct bfa_iocfc_regs_s {
+       bfa_os_addr_t   intr_status;
+       bfa_os_addr_t   intr_mask;
+       bfa_os_addr_t   cpe_q_pi[BFI_IOC_MAX_CQS];
+       bfa_os_addr_t   cpe_q_ci[BFI_IOC_MAX_CQS];
+       bfa_os_addr_t   cpe_q_depth[BFI_IOC_MAX_CQS];
+       bfa_os_addr_t   cpe_q_ctrl[BFI_IOC_MAX_CQS];
+       bfa_os_addr_t   rme_q_ci[BFI_IOC_MAX_CQS];
+       bfa_os_addr_t   rme_q_pi[BFI_IOC_MAX_CQS];
+       bfa_os_addr_t   rme_q_depth[BFI_IOC_MAX_CQS];
+       bfa_os_addr_t   rme_q_ctrl[BFI_IOC_MAX_CQS];
+};
+
+/**
+ * MSIX vector handlers
+ */
+#define BFA_MSIX_MAX_VECTORS   22
+typedef void (*bfa_msix_handler_t)(struct bfa_s *bfa, int vec);
+struct bfa_msix_s {
+       int     nvecs;
+       bfa_msix_handler_t handler[BFA_MSIX_MAX_VECTORS];
+};
+
+/**
+ * Chip specific interfaces
+ */
+struct bfa_hwif_s {
+       void (*hw_reginit)(struct bfa_s *bfa);
+       void (*hw_reqq_ack)(struct bfa_s *bfa, int reqq);
+       void (*hw_rspq_ack)(struct bfa_s *bfa, int rspq);
+       void (*hw_msix_init)(struct bfa_s *bfa, int nvecs);
+       void (*hw_msix_install)(struct bfa_s *bfa);
+       void (*hw_msix_uninstall)(struct bfa_s *bfa);
+       void (*hw_isr_mode_set)(struct bfa_s *bfa, bfa_boolean_t msix);
+       void (*hw_msix_getvecs)(struct bfa_s *bfa, u32 *vecmap,
+                               u32 *nvecs, u32 *maxvec);
+       void (*hw_msix_get_rme_range) (struct bfa_s *bfa, u32 *start,
+                                      u32 *end);
+};
+typedef void (*bfa_cb_iocfc_t) (void *cbarg, enum bfa_status status);
+
+struct bfa_iocfc_s {
+       struct bfa_s            *bfa;
+       struct bfa_iocfc_cfg_s  cfg;
+       int                     action;
+       u32             req_cq_pi[BFI_IOC_MAX_CQS];
+       u32             rsp_cq_ci[BFI_IOC_MAX_CQS];
+       struct bfa_cb_qe_s      init_hcb_qe;
+       struct bfa_cb_qe_s      stop_hcb_qe;
+       struct bfa_cb_qe_s      dis_hcb_qe;
+       struct bfa_cb_qe_s      stats_hcb_qe;
+       bfa_boolean_t           cfgdone;
+
+       struct bfa_dma_s        cfg_info;
+       struct bfi_iocfc_cfg_s *cfginfo;
+       struct bfa_dma_s        cfgrsp_dma;
+       struct bfi_iocfc_cfgrsp_s *cfgrsp;
+       struct bfi_iocfc_cfg_reply_s *cfg_reply;
+       struct bfa_dma_s        req_cq_ba[BFI_IOC_MAX_CQS];
+       struct bfa_dma_s        req_cq_shadow_ci[BFI_IOC_MAX_CQS];
+       struct bfa_dma_s        rsp_cq_ba[BFI_IOC_MAX_CQS];
+       struct bfa_dma_s        rsp_cq_shadow_pi[BFI_IOC_MAX_CQS];
+       struct bfa_iocfc_regs_s bfa_regs;       /*  BFA device registers */
+       struct bfa_hwif_s       hwif;
+       bfa_cb_iocfc_t          updateq_cbfn; /*  bios callback function */
+       void                    *updateq_cbarg; /*  bios callback arg */
+       u32     intr_mask;
+};
+
+#define bfa_lpuid(__bfa)                                               \
+       bfa_ioc_portid(&(__bfa)->ioc)
+#define bfa_msix_init(__bfa, __nvecs)                                  \
+       ((__bfa)->iocfc.hwif.hw_msix_init(__bfa, __nvecs))
+#define bfa_msix_install(__bfa)                                                \
+       ((__bfa)->iocfc.hwif.hw_msix_install(__bfa))
+#define bfa_msix_uninstall(__bfa)                                      \
+       ((__bfa)->iocfc.hwif.hw_msix_uninstall(__bfa))
+#define bfa_isr_mode_set(__bfa, __msix)                                        \
+       ((__bfa)->iocfc.hwif.hw_isr_mode_set(__bfa, __msix))
+#define bfa_msix_getvecs(__bfa, __vecmap, __nvecs, __maxvec)           \
+       ((__bfa)->iocfc.hwif.hw_msix_getvecs(__bfa, __vecmap,           \
+                                       __nvecs, __maxvec))
+#define bfa_msix_get_rme_range(__bfa, __start, __end)                  \
+       ((__bfa)->iocfc.hwif.hw_msix_get_rme_range(__bfa, __start, __end))
+#define bfa_msix(__bfa, __vec)                                         \
+       ((__bfa)->msix.handler[__vec](__bfa, __vec))
+
+/*
+ * FC specific IOC functions.
+ */
+void bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
+                      u32 *dm_len);
+void bfa_iocfc_attach(struct bfa_s *bfa, void *bfad,
+                     struct bfa_iocfc_cfg_s *cfg,
+                     struct bfa_meminfo_s *meminfo,
+                     struct bfa_pcidev_s *pcidev);
+void bfa_iocfc_detach(struct bfa_s *bfa);
+void bfa_iocfc_init(struct bfa_s *bfa);
+void bfa_iocfc_start(struct bfa_s *bfa);
+void bfa_iocfc_stop(struct bfa_s *bfa);
+void bfa_iocfc_isr(void *bfa, struct bfi_mbmsg_s *msg);
+void bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa);
+bfa_boolean_t bfa_iocfc_is_operational(struct bfa_s *bfa);
+void bfa_iocfc_reset_queues(struct bfa_s *bfa);
+
+void bfa_msix_all(struct bfa_s *bfa, int vec);
+void bfa_msix_reqq(struct bfa_s *bfa, int vec);
+void bfa_msix_rspq(struct bfa_s *bfa, int vec);
+void bfa_msix_lpu_err(struct bfa_s *bfa, int vec);
+
+void bfa_hwcb_reginit(struct bfa_s *bfa);
+void bfa_hwcb_reqq_ack(struct bfa_s *bfa, int rspq);
+void bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq);
+void bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs);
+void bfa_hwcb_msix_install(struct bfa_s *bfa);
+void bfa_hwcb_msix_uninstall(struct bfa_s *bfa);
+void bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
+void bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *vecmap, u32 *nvecs,
+                          u32 *maxvec);
+void bfa_hwcb_msix_get_rme_range(struct bfa_s *bfa, u32 *start,
+                                u32 *end);
+void bfa_hwct_reginit(struct bfa_s *bfa);
+void bfa_hwct_reqq_ack(struct bfa_s *bfa, int rspq);
+void bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq);
+void bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs);
+void bfa_hwct_msix_install(struct bfa_s *bfa);
+void bfa_hwct_msix_uninstall(struct bfa_s *bfa);
+void bfa_hwct_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
+void bfa_hwct_msix_getvecs(struct bfa_s *bfa, u32 *vecmap, u32 *nvecs,
+                          u32 *maxvec);
+void bfa_hwct_msix_get_rme_range(struct bfa_s *bfa, u32 *start,
+                                u32 *end);
+void bfa_com_port_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi);
+void bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns);
+wwn_t bfa_iocfc_get_pwwn(struct bfa_s *bfa);
+wwn_t bfa_iocfc_get_nwwn(struct bfa_s *bfa);
+void bfa_iocfc_get_pbc_boot_cfg(struct bfa_s *bfa,
+                               struct bfa_boot_pbc_s *pbcfg);
+int bfa_iocfc_get_pbc_vports(struct bfa_s *bfa,
+                               struct bfi_pbc_vport_s *pbc_vport);
+
+
+/**
+ *----------------------------------------------------------------------
+ *             BFA public interfaces
+ *----------------------------------------------------------------------
+ */
+#define bfa_stats(_mod, _stats)        ((_mod)->stats._stats++)
+#define bfa_ioc_get_stats(__bfa, __ioc_stats)          \
+       bfa_ioc_fetch_stats(&(__bfa)->ioc, __ioc_stats)
+#define bfa_ioc_clear_stats(__bfa)             \
+       bfa_ioc_clr_stats(&(__bfa)->ioc)
+#define bfa_get_nports(__bfa)                  \
+       bfa_ioc_get_nports(&(__bfa)->ioc)
+#define bfa_get_adapter_manufacturer(__bfa, __manufacturer)            \
+       bfa_ioc_get_adapter_manufacturer(&(__bfa)->ioc, __manufacturer)
+#define bfa_get_adapter_model(__bfa, __model)                  \
+       bfa_ioc_get_adapter_model(&(__bfa)->ioc, __model)
+#define bfa_get_adapter_serial_num(__bfa, __serial_num)                        \
+       bfa_ioc_get_adapter_serial_num(&(__bfa)->ioc, __serial_num)
+#define bfa_get_adapter_fw_ver(__bfa, __fw_ver)                        \
+       bfa_ioc_get_adapter_fw_ver(&(__bfa)->ioc, __fw_ver)
+#define bfa_get_adapter_optrom_ver(__bfa, __optrom_ver)                        \
+       bfa_ioc_get_adapter_optrom_ver(&(__bfa)->ioc, __optrom_ver)
+#define bfa_get_pci_chip_rev(__bfa, __chip_rev)                        \
+       bfa_ioc_get_pci_chip_rev(&(__bfa)->ioc, __chip_rev)
+#define bfa_get_ioc_state(__bfa)               \
+       bfa_ioc_get_state(&(__bfa)->ioc)
+#define bfa_get_type(__bfa)                    \
+       bfa_ioc_get_type(&(__bfa)->ioc)
+#define bfa_get_mac(__bfa)                     \
+       bfa_ioc_get_mac(&(__bfa)->ioc)
+#define bfa_get_mfg_mac(__bfa)                 \
+       bfa_ioc_get_mfg_mac(&(__bfa)->ioc)
+#define bfa_get_fw_clock_res(__bfa)            \
+       ((__bfa)->iocfc.cfgrsp->fwcfg.fw_tick_res)
+
+void bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids);
+void bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg);
+void bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg);
+void bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg,
+                        struct bfa_meminfo_s *meminfo);
+void bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
+               struct bfa_meminfo_s *meminfo,
+               struct bfa_pcidev_s *pcidev);
+void bfa_init_trc(struct bfa_s *bfa, struct bfa_trc_mod_s *trcmod);
+void bfa_init_plog(struct bfa_s *bfa, struct bfa_plog_s *plog);
+void bfa_detach(struct bfa_s *bfa);
+void bfa_init(struct bfa_s *bfa);
+void bfa_start(struct bfa_s *bfa);
+void bfa_stop(struct bfa_s *bfa);
+void bfa_attach_fcs(struct bfa_s *bfa);
+void bfa_cb_init(void *bfad, bfa_status_t status);
+void bfa_cb_updateq(void *bfad, bfa_status_t status);
+
+bfa_boolean_t bfa_intx(struct bfa_s *bfa);
+void bfa_intx_disable(struct bfa_s *bfa);
+void bfa_intx_enable(struct bfa_s *bfa);
+void bfa_isr_enable(struct bfa_s *bfa);
+void bfa_isr_disable(struct bfa_s *bfa);
+
+void bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q);
+void bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q);
+void bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q);
+
+typedef void (*bfa_cb_ioc_t) (void *cbarg, enum bfa_status status);
+void bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr);
+void bfa_get_attr(struct bfa_s *bfa, struct bfa_ioc_attr_s *ioc_attr);
+
+void bfa_adapter_get_attr(struct bfa_s *bfa,
+                         struct bfa_adapter_attr_s *ad_attr);
+u64 bfa_adapter_get_id(struct bfa_s *bfa);
+
+bfa_status_t bfa_iocfc_israttr_set(struct bfa_s *bfa,
+                                  struct bfa_iocfc_intr_attr_s *attr);
+
+void bfa_iocfc_enable(struct bfa_s *bfa);
+void bfa_iocfc_disable(struct bfa_s *bfa);
+void bfa_chip_reset(struct bfa_s *bfa);
+void bfa_timer_tick(struct bfa_s *bfa);
+#define bfa_timer_start(_bfa, _timer, _timercb, _arg, _timeout)                \
+       bfa_timer_begin(&(_bfa)->timer_mod, _timer, _timercb, _arg, _timeout)
+
+/*
+ * BFA debug API functions
+ */
+bfa_status_t bfa_debug_fwtrc(struct bfa_s *bfa, void *trcdata, int *trclen);
+bfa_status_t bfa_debug_fwsave(struct bfa_s *bfa, void *trcdata, int *trclen);
+bfa_status_t bfa_debug_fwcore(struct bfa_s *bfa, void *buf,
+                             u32 *offset, int *buflen);
+void bfa_debug_fwsave_clear(struct bfa_s *bfa);
+bfa_status_t bfa_fw_stats_get(struct bfa_s *bfa, void *data);
+bfa_status_t bfa_fw_stats_clear(struct bfa_s *bfa);
+
+#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 (file)
index 1e3265c..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
- * All rights reserved
- * www.brocade.com
- *
- * Linux driver for Brocade Fibre Channel Host Bus Adapter.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License (GPL) Version 2 as
- * published by the Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- */
-
-#ifndef __BFA_CALLBACK_PRIV_H__
-#define __BFA_CALLBACK_PRIV_H__
-
-#include <cs/bfa_q.h>
-
-typedef void    (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete);
-
-/**
- * Generic BFA callback element.
- */
-struct bfa_cb_qe_s {
-       struct list_head         qe;
-       bfa_cb_cbfn_t  cbfn;
-       bfa_boolean_t   once;
-       u32             rsvd;
-       void           *cbarg;
-};
-
-#define bfa_cb_queue(__bfa, __hcb_qe, __cbfn, __cbarg) do {            \
-       (__hcb_qe)->cbfn  = (__cbfn);      \
-       (__hcb_qe)->cbarg = (__cbarg);      \
-       list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q);      \
-} while (0)
-
-#define bfa_cb_dequeue(__hcb_qe)       list_del(&(__hcb_qe)->qe)
-
-#define bfa_cb_queue_once(__bfa, __hcb_qe, __cbfn, __cbarg) do {       \
-       (__hcb_qe)->cbfn  = (__cbfn);      \
-       (__hcb_qe)->cbarg = (__cbarg);      \
-       if (!(__hcb_qe)->once) {      \
-               list_add_tail((__hcb_qe), &(__bfa)->comp_q);      \
-               (__hcb_qe)->once = BFA_TRUE;                            \
-       }                                                               \
-} while (0)
-
-#define bfa_cb_queue_done(__hcb_qe) do {                               \
-       (__hcb_qe)->once = BFA_FALSE;                                   \
-} while (0)
-
-#endif /* __BFA_CALLBACK_PRIV_H__ */
similarity index 85%
rename from drivers/scsi/bfa/bfa_cb_ioim_macros.h
rename to drivers/scsi/bfa/bfa_cb_ioim.h
index 3906ed9..a989a94 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
+ * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
  * All rights reserved
  * www.brocade.com
  *
  * General Public License for more details.
  */
 
-/**
- *  bfa_cb_ioim_macros.h BFA IOIM driver interface macros.
- */
-
-#ifndef __BFA_HCB_IOIM_MACROS_H__
-#define __BFA_HCB_IOIM_MACROS_H__
-
-#include <bfa_os_inc.h>
-/*
- * #include <linux/dma-mapping.h>
- *
- * #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h> #include
- * <scsi/scsi_device.h> #include <scsi/scsi_host.h>
- */
-#include "bfad_im_compat.h"
+#ifndef __BFA_HCB_IOIM_H__
+#define __BFA_HCB_IOIM_H__
 
+#include "bfa_os_inc.h"
 /*
  * task attribute values in FCP-2 FCP_CMND IU
  */
 #define SIMPLE_Q    0
 #define HEAD_OF_Q   1
 #define ORDERED_Q   2
-#define ACA_Q       4
+#define ACA_Q      4
 #define UNTAGGED    5
 
 static inline lun_t
 bfad_int_to_lun(u32 luno)
 {
        union {
-               u16        scsi_lun[4];
-               lun_t           bfa_lun;
+               u16     scsi_lun[4];
+               lun_t           bfa_lun;
        } lun;
 
        lun.bfa_lun     = 0;
@@ -141,7 +129,7 @@ static inline u8
 bfa_cb_ioim_get_taskattr(struct bfad_ioim_s *dio)
 {
        struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dio;
-       u8         task_attr = UNTAGGED;
+       u8      task_attr = UNTAGGED;
 
        if (cmnd->device->tagged_supported) {
                switch (cmnd->tag) {
@@ -178,4 +166,4 @@ bfa_cb_ioim_get_cdblen(struct bfad_ioim_s *dio)
  */
 #define bfa_cb_ioim_get_reqq(__dio) BFA_FALSE
 
-#endif /* __BFA_HCB_IOIM_MACROS_H__ */
+#endif /* __BFA_HCB_IOIM_H__ */
diff --git a/drivers/scsi/bfa/bfa_cee.c b/drivers/scsi/bfa/bfa_cee.c
deleted file mode 100644 (file)
index 2b91779..0000000
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
- * All rights reserved
- * www.brocade.com
- *
- * Linux driver for Brocade Fibre Channel Host Bus Adapter.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License (GPL) Version 2 as
- * published by the Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- */
-
-#include <defs/bfa_defs_cee.h>
-#include <cs/bfa_trc.h>
-#include <cs/bfa_log.h>
-#include <cs/bfa_debug.h>
-#include <cee/bfa_cee.h>
-#include <bfi/bfi_cee.h>
-#include <bfi/bfi.h>
-#include <bfa_ioc.h>
-#include <cna/bfa_cna_trcmod.h>
-
-BFA_TRC_FILE(CNA, CEE);
-
-#define bfa_ioc_portid(__ioc) ((__ioc)->port_id)
-#define bfa_lpuid(__arg) bfa_ioc_portid(&(__arg)->ioc)
-
-static void     bfa_cee_format_lldp_cfg(struct bfa_cee_lldp_cfg_s *lldp_cfg);
-static void     bfa_cee_format_dcbcx_stats(struct bfa_cee_dcbx_stats_s
-                                          *dcbcx_stats);
-static void     bfa_cee_format_lldp_stats(struct bfa_cee_lldp_stats_s
-                                         *lldp_stats);
-static void     bfa_cee_format_cfg_stats(struct bfa_cee_cfg_stats_s *cfg_stats);
-static void     bfa_cee_format_cee_cfg(void *buffer);
-static void     bfa_cee_format_cee_stats(void *buffer);
-
-static void
-bfa_cee_format_cee_stats(void *buffer)
-{
-       struct bfa_cee_stats_s *cee_stats = buffer;
-       bfa_cee_format_dcbcx_stats(&cee_stats->dcbx_stats);
-       bfa_cee_format_lldp_stats(&cee_stats->lldp_stats);
-       bfa_cee_format_cfg_stats(&cee_stats->cfg_stats);
-}
-
-static void
-bfa_cee_format_cee_cfg(void *buffer)
-{
-       struct bfa_cee_attr_s *cee_cfg = buffer;
-       bfa_cee_format_lldp_cfg(&cee_cfg->lldp_remote);
-}
-
-static void
-bfa_cee_format_dcbcx_stats(struct bfa_cee_dcbx_stats_s *dcbcx_stats)
-{
-       dcbcx_stats->subtlvs_unrecognized =
-               bfa_os_ntohl(dcbcx_stats->subtlvs_unrecognized);
-       dcbcx_stats->negotiation_failed =
-               bfa_os_ntohl(dcbcx_stats->negotiation_failed);
-       dcbcx_stats->remote_cfg_changed =
-               bfa_os_ntohl(dcbcx_stats->remote_cfg_changed);
-       dcbcx_stats->tlvs_received = bfa_os_ntohl(dcbcx_stats->tlvs_received);
-       dcbcx_stats->tlvs_invalid = bfa_os_ntohl(dcbcx_stats->tlvs_invalid);
-       dcbcx_stats->seqno = bfa_os_ntohl(dcbcx_stats->seqno);
-       dcbcx_stats->ackno = bfa_os_ntohl(dcbcx_stats->ackno);
-       dcbcx_stats->recvd_seqno = bfa_os_ntohl(dcbcx_stats->recvd_seqno);
-       dcbcx_stats->recvd_ackno = bfa_os_ntohl(dcbcx_stats->recvd_ackno);
-}
-
-static void
-bfa_cee_format_lldp_stats(struct bfa_cee_lldp_stats_s *lldp_stats)
-{
-       lldp_stats->frames_transmitted =
-               bfa_os_ntohl(lldp_stats->frames_transmitted);
-       lldp_stats->frames_aged_out = bfa_os_ntohl(lldp_stats->frames_aged_out);
-       lldp_stats->frames_discarded =
-               bfa_os_ntohl(lldp_stats->frames_discarded);
-       lldp_stats->frames_in_error = bfa_os_ntohl(lldp_stats->frames_in_error);
-       lldp_stats->frames_rcvd = bfa_os_ntohl(lldp_stats->frames_rcvd);
-       lldp_stats->tlvs_discarded = bfa_os_ntohl(lldp_stats->tlvs_discarded);
-       lldp_stats->tlvs_unrecognized =
-               bfa_os_ntohl(lldp_stats->tlvs_unrecognized);
-}
-
-static void
-bfa_cee_format_cfg_stats(struct bfa_cee_cfg_stats_s *cfg_stats)
-{
-       cfg_stats->cee_status_down = bfa_os_ntohl(cfg_stats->cee_status_down);
-       cfg_stats->cee_status_up = bfa_os_ntohl(cfg_stats->cee_status_up);
-       cfg_stats->cee_hw_cfg_changed =
-               bfa_os_ntohl(cfg_stats->cee_hw_cfg_changed);
-       cfg_stats->recvd_invalid_cfg =
-               bfa_os_ntohl(cfg_stats->recvd_invalid_cfg);
-}
-
-static void
-bfa_cee_format_lldp_cfg(struct bfa_cee_lldp_cfg_s *lldp_cfg)
-{
-       lldp_cfg->time_to_interval = bfa_os_ntohs(lldp_cfg->time_to_interval);
-       lldp_cfg->enabled_system_cap =
-               bfa_os_ntohs(lldp_cfg->enabled_system_cap);
-}
-
-/**
- * bfa_cee_attr_meminfo()
- *
- *
- * @param[in] void
- *
- * @return Size of DMA region
- */
-static          u32
-bfa_cee_attr_meminfo(void)
-{
-       return BFA_ROUNDUP(sizeof(struct bfa_cee_attr_s), BFA_DMA_ALIGN_SZ);
-}
-
-/**
- * bfa_cee_stats_meminfo()
- *
- *
- * @param[in] void
- *
- * @return Size of DMA region
- */
-static          u32
-bfa_cee_stats_meminfo(void)
-{
-       return BFA_ROUNDUP(sizeof(struct bfa_cee_stats_s), BFA_DMA_ALIGN_SZ);
-}
-
-/**
- * bfa_cee_get_attr_isr()
- *
- *
- * @param[in] cee - Pointer to the CEE module
- *            status - Return status from the f/w
- *
- * @return void
- */
-static void
-bfa_cee_get_attr_isr(struct bfa_cee_s *cee, bfa_status_t status)
-{
-       cee->get_attr_status = status;
-       bfa_trc(cee, 0);
-       if (status == BFA_STATUS_OK) {
-               bfa_trc(cee, 0);
-               /*
-                * The requested data has been copied to the DMA area, *process
-                * it.
-                */
-               memcpy(cee->attr, cee->attr_dma.kva,
-                      sizeof(struct bfa_cee_attr_s));
-               bfa_cee_format_cee_cfg(cee->attr);
-       }
-       cee->get_attr_pending = BFA_FALSE;
-       if (cee->cbfn.get_attr_cbfn) {
-               bfa_trc(cee, 0);
-               cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg, status);
-       }
-       bfa_trc(cee, 0);
-}
-
-/**
- * bfa_cee_get_attr_isr()
- *
- *
- * @param[in] cee - Pointer to the CEE module
- *            status - Return status from the f/w
- *
- * @return void
- */
-static void
-bfa_cee_get_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
-{
-       cee->get_stats_status = status;
-       bfa_trc(cee, 0);
-       if (status == BFA_STATUS_OK) {
-               bfa_trc(cee, 0);
-               /*
-                * The requested data has been copied to the DMA area, process
-                * it.
-                */
-               memcpy(cee->stats, cee->stats_dma.kva,
-                      sizeof(struct bfa_cee_stats_s));
-               bfa_cee_format_cee_stats(cee->stats);
-       }
-       cee->get_stats_pending = BFA_FALSE;
-       bfa_trc(cee, 0);
-       if (cee->cbfn.get_stats_cbfn) {
-               bfa_trc(cee, 0);
-               cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg, status);
-       }
-       bfa_trc(cee, 0);
-}
-
-/**
- * bfa_cee_get_attr_isr()
- *
- *
- * @param[in] cee - Pointer to the CEE module
- *            status - Return status from the f/w
- *
- * @return void
- */
-static void
-bfa_cee_reset_stats_isr(struct bfa_cee_s *cee, bfa_status_t status)
-{
-       cee->reset_stats_status = status;
-       cee->reset_stats_pending = BFA_FALSE;
-       if (cee->cbfn.reset_stats_cbfn)
-               cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg, status);
-}
-
-/**
- * bfa_cee_meminfo()
- *
- *
- * @param[in] void
- *
- * @return Size of DMA region
- */
-u32
-bfa_cee_meminfo(void)
-{
-       return bfa_cee_attr_meminfo() + bfa_cee_stats_meminfo();
-}
-
-/**
- * bfa_cee_mem_claim()
- *
- *
- * @param[in] cee CEE module pointer
- *           dma_kva Kernel Virtual Address of CEE DMA Memory
- *           dma_pa  Physical Address of CEE DMA Memory
- *
- * @return void
- */
-void
-bfa_cee_mem_claim(struct bfa_cee_s *cee, u8 *dma_kva, u64 dma_pa)
-{
-       cee->attr_dma.kva = dma_kva;
-       cee->attr_dma.pa = dma_pa;
-       cee->stats_dma.kva = dma_kva + bfa_cee_attr_meminfo();
-       cee->stats_dma.pa = dma_pa + bfa_cee_attr_meminfo();
-       cee->attr = (struct bfa_cee_attr_s *)dma_kva;
-       cee->stats =
-               (struct bfa_cee_stats_s *)(dma_kva + bfa_cee_attr_meminfo());
-}
-
-/**
- * bfa_cee_get_attr()
- *
- *   Send the request to the f/w to fetch CEE attributes.
- *
- * @param[in] Pointer to the CEE module data structure.
- *
- * @return Status
- */
-
-bfa_status_t
-bfa_cee_get_attr(struct bfa_cee_s *cee, struct bfa_cee_attr_s *attr,
-                bfa_cee_get_attr_cbfn_t cbfn, void *cbarg)
-{
-       struct bfi_cee_get_req_s *cmd;
-
-       bfa_assert((cee != NULL) && (cee->ioc != NULL));
-       bfa_trc(cee, 0);
-       if (!bfa_ioc_is_operational(cee->ioc)) {
-               bfa_trc(cee, 0);
-               return BFA_STATUS_IOC_FAILURE;
-       }
-       if (cee->get_attr_pending == BFA_TRUE) {
-               bfa_trc(cee, 0);
-               return BFA_STATUS_DEVBUSY;
-       }
-       cee->get_attr_pending = BFA_TRUE;
-       cmd = (struct bfi_cee_get_req_s *)cee->get_cfg_mb.msg;
-       cee->attr = attr;
-       cee->cbfn.get_attr_cbfn = cbfn;
-       cee->cbfn.get_attr_cbarg = cbarg;
-       bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_CFG_REQ,
-                   bfa_ioc_portid(cee->ioc));
-       bfa_dma_be_addr_set(cmd->dma_addr, cee->attr_dma.pa);
-       bfa_ioc_mbox_queue(cee->ioc, &cee->get_cfg_mb);
-       bfa_trc(cee, 0);
-
-       return BFA_STATUS_OK;
-}
-
-/**
- * bfa_cee_get_stats()
- *
- *   Send the request to the f/w to fetch CEE statistics.
- *
- * @param[in] Pointer to the CEE module data structure.
- *
- * @return Status
- */
-
-bfa_status_t
-bfa_cee_get_stats(struct bfa_cee_s *cee, struct bfa_cee_stats_s *stats,
-                 bfa_cee_get_stats_cbfn_t cbfn, void *cbarg)
-{
-       struct bfi_cee_get_req_s *cmd;
-
-       bfa_assert((cee != NULL) && (cee->ioc != NULL));
-
-       if (!bfa_ioc_is_operational(cee->ioc)) {
-               bfa_trc(cee, 0);
-               return BFA_STATUS_IOC_FAILURE;
-       }
-       if (cee->get_stats_pending == BFA_TRUE) {
-               bfa_trc(cee, 0);
-               return BFA_STATUS_DEVBUSY;
-       }
-       cee->get_stats_pending = BFA_TRUE;
-       cmd = (struct bfi_cee_get_req_s *)cee->get_stats_mb.msg;
-       cee->stats = stats;
-       cee->cbfn.get_stats_cbfn = cbfn;
-       cee->cbfn.get_stats_cbarg = cbarg;
-       bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_GET_STATS_REQ,
-                   bfa_ioc_portid(cee->ioc));
-       bfa_dma_be_addr_set(cmd->dma_addr, cee->stats_dma.pa);
-       bfa_ioc_mbox_queue(cee->ioc, &cee->get_stats_mb);
-       bfa_trc(cee, 0);
-
-       return BFA_STATUS_OK;
-}
-
-/**
- * bfa_cee_reset_stats()
- *
- *
- * @param[in] Pointer to the CEE module data structure.
- *
- * @return Status
- */
-
-bfa_status_t
-bfa_cee_reset_stats(struct bfa_cee_s *cee, bfa_cee_reset_stats_cbfn_t cbfn,
-                   void *cbarg)
-{
-       struct bfi_cee_reset_stats_s *cmd;
-
-       bfa_assert((cee != NULL) && (cee->ioc != NULL));
-       if (!bfa_ioc_is_operational(cee->ioc)) {
-               bfa_trc(cee, 0);
-               return BFA_STATUS_IOC_FAILURE;
-       }
-       if (cee->reset_stats_pending == BFA_TRUE) {
-               bfa_trc(cee, 0);
-               return BFA_STATUS_DEVBUSY;
-       }
-       cee->reset_stats_pending = BFA_TRUE;
-       cmd = (struct bfi_cee_reset_stats_s *)cee->reset_stats_mb.msg;
-       cee->cbfn.reset_stats_cbfn = cbfn;
-       cee->cbfn.reset_stats_cbarg = cbarg;
-       bfi_h2i_set(cmd->mh, BFI_MC_CEE, BFI_CEE_H2I_RESET_STATS,
-                   bfa_ioc_portid(cee->ioc));
-       bfa_ioc_mbox_queue(cee->ioc, &cee->reset_stats_mb);
-       bfa_trc(cee, 0);
-       return BFA_STATUS_OK;
-}
-
-/**
- * bfa_cee_isrs()
- *
- *
- * @param[in] Pointer to the CEE module data structure.
- *
- * @return void
- */
-
-void
-bfa_cee_isr(void *cbarg, struct bfi_mbmsg_s *m)
-{
-       union bfi_cee_i2h_msg_u *msg;
-       struct bfi_cee_get_rsp_s *get_rsp;
-       struct bfa_cee_s *cee = (struct bfa_cee_s *)cbarg;
-       msg = (union bfi_cee_i2h_msg_u *)m;
-       get_rsp = (struct bfi_cee_get_rsp_s *)m;
-       bfa_trc(cee, msg->mh.msg_id);
-       switch (msg->mh.msg_id) {
-       case BFI_CEE_I2H_GET_CFG_RSP:
-               bfa_trc(cee, get_rsp->cmd_status);
-               bfa_cee_get_attr_isr(cee, get_rsp->cmd_status);
-               break;
-       case BFI_CEE_I2H_GET_STATS_RSP:
-               bfa_cee_get_stats_isr(cee, get_rsp->cmd_status);
-               break;
-       case BFI_CEE_I2H_RESET_STATS_RSP:
-               bfa_cee_reset_stats_isr(cee, get_rsp->cmd_status);
-               break;
-       default:
-               bfa_assert(0);
-       }
-}
-
-/**
- * bfa_cee_hbfail()
- *
- *
- * @param[in] Pointer to the CEE module data structure.
- *
- * @return void
- */
-
-void
-bfa_cee_hbfail(void *arg)
-{
-       struct bfa_cee_s *cee;
-       cee = (struct bfa_cee_s *)arg;
-
-       if (cee->get_attr_pending == BFA_TRUE) {
-               cee->get_attr_status = BFA_STATUS_FAILED;
-               cee->get_attr_pending = BFA_FALSE;
-               if (cee->cbfn.get_attr_cbfn) {
-                       cee->cbfn.get_attr_cbfn(cee->cbfn.get_attr_cbarg,
-                                               BFA_STATUS_FAILED);
-               }
-       }
-       if (cee->get_stats_pending == BFA_TRUE) {
-               cee->get_stats_status = BFA_STATUS_FAILED;
-               cee->get_stats_pending = BFA_FALSE;
-               if (cee->cbfn.get_stats_cbfn) {
-                       cee->cbfn.get_stats_cbfn(cee->cbfn.get_stats_cbarg,
-                                                BFA_STATUS_FAILED);
-               }
-       }
-       if (cee->reset_stats_pending == BFA_TRUE) {
-               cee->reset_stats_status = BFA_STATUS_FAILED;
-               cee->reset_stats_pending = BFA_FALSE;
-               if (cee->cbfn.reset_stats_cbfn) {
-                       cee->cbfn.reset_stats_cbfn(cee->cbfn.reset_stats_cbarg,
-                                                  BFA_STATUS_FAILED);
-               }
-       }
-}
-
-/**
- * bfa_cee_attach()
- *
- *
- * @param[in] cee - Pointer to the CEE module data structure
- *            ioc - Pointer to the ioc module data structure
- *            dev - Pointer to the device driver module data structure
- *                  The device driver specific mbox ISR functions have
- *                  this pointer as one of the parameters.
- *            trcmod -
- *            logmod -
- *
- * @return void
- */
-void
-bfa_cee_attach(struct bfa_cee_s *cee, struct bfa_ioc_s *ioc, void *dev,
-              struct bfa_trc_mod_s *trcmod, struct bfa_log_mod_s *logmod)
-{
-       bfa_assert(cee != NULL);
-       cee->dev = dev;
-       cee->trcmod = trcmod;
-       cee->logmod = logmod;
-       cee->ioc = ioc;
-
-       bfa_ioc_mbox_regisr(cee->ioc, BFI_MC_CEE, bfa_cee_isr, cee);
-       bfa_ioc_hbfail_init(&cee->hbfail, bfa_cee_hbfail, cee);
-       bfa_ioc_hbfail_register(cee->ioc, &cee->hbfail);
-       bfa_trc(cee, 0);
-}
-
-/**
- * bfa_cee_detach()
- *
- *
- * @param[in] cee - Pointer to the CEE module data structure
- *
- * @return void
- */
-void
-bfa_cee_detach(struct bfa_cee_s *cee)
-{
-       /*
-        * For now, just check if there is some ioctl pending and mark that as
-        * failed?
-        */
-       /* bfa_cee_hbfail(cee); */
-}
index 76fa5c5..c2fa07f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
+ * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
  * All rights reserved
  * www.brocade.com
  *
  * General Public License for more details.
  */
 
-#include <bfa.h>
-#include <defs/bfa_defs_pci.h>
-#include <cs/bfa_debug.h>
-#include <bfa_iocfc.h>
+#include "bfa_modules.h"
+#include "bfi_ctreg.h"
+#include "bfad_drv.h"
 
-#define DEF_CFG_NUM_FABRICS         1
-#define DEF_CFG_NUM_LPORTS          256
-#define DEF_CFG_NUM_CQS             4
-#define DEF_CFG_NUM_IOIM_REQS       (BFA_IOIM_MAX)
-#define DEF_CFG_NUM_TSKIM_REQS      128
-#define DEF_CFG_NUM_FCXP_REQS       64
-#define DEF_CFG_NUM_UF_BUFS         64
-#define DEF_CFG_NUM_RPORTS          1024
-#define DEF_CFG_NUM_ITNIMS          (DEF_CFG_NUM_RPORTS)
-#define DEF_CFG_NUM_TINS            256
+BFA_TRC_FILE(HAL, CORE);
 
-#define DEF_CFG_NUM_SGPGS           2048
-#define DEF_CFG_NUM_REQQ_ELEMS      256
-#define DEF_CFG_NUM_RSPQ_ELEMS      64
-#define DEF_CFG_NUM_SBOOT_TGTS      16
-#define DEF_CFG_NUM_SBOOT_LUNS      16
+/**
+ * BFA IOC FC related definitions
+ */
+
+/**
+ * IOC local definitions
+ */
+#define BFA_IOCFC_TOV          5000    /* msecs */
+
+enum {
+       BFA_IOCFC_ACT_NONE      = 0,
+       BFA_IOCFC_ACT_INIT      = 1,
+       BFA_IOCFC_ACT_STOP      = 2,
+       BFA_IOCFC_ACT_DISABLE   = 3,
+};
+
+#define DEF_CFG_NUM_FABRICS            1
+#define DEF_CFG_NUM_LPORTS             256
+#define DEF_CFG_NUM_CQS                        4
+#define DEF_CFG_NUM_IOIM_REQS          (BFA_IOIM_MAX)
+#define DEF_CFG_NUM_TSKIM_REQS         128
+#define DEF_CFG_NUM_FCXP_REQS          64
+#define DEF_CFG_NUM_UF_BUFS            64
+#define DEF_CFG_NUM_RPORTS             1024
+#define DEF_CFG_NUM_ITNIMS             (DEF_CFG_NUM_RPORTS)
+#define DEF_CFG_NUM_TINS               256
+
+#define DEF_CFG_NUM_SGPGS              2048
+#define DEF_CFG_NUM_REQQ_ELEMS         256
+#define DEF_CFG_NUM_RSPQ_ELEMS         64
+#define DEF_CFG_NUM_SBOOT_TGTS         16
+#define DEF_CFG_NUM_SBOOT_LUNS         16
+
+/**
+ * forward declaration for IOC FC functions
+ */
+static void bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status);
+static void bfa_iocfc_disable_cbfn(void *bfa_arg);
+static void bfa_iocfc_hbfail_cbfn(void *bfa_arg);
+static void bfa_iocfc_reset_cbfn(void *bfa_arg);
+static struct bfa_ioc_cbfn_s bfa_iocfc_cbfn;
+
+/**
+ * BFA Interrupt handling functions
+ */
+static void
+bfa_msix_errint(struct bfa_s *bfa, u32 intr)
+{
+       bfa_ioc_error_isr(&bfa->ioc);
+}
+
+static void
+bfa_msix_lpu(struct bfa_s *bfa)
+{
+       bfa_ioc_mbox_isr(&bfa->ioc);
+}
+
+static void
+bfa_reqq_resume(struct bfa_s *bfa, int qid)
+{
+       struct list_head *waitq, *qe, *qen;
+       struct bfa_reqq_wait_s *wqe;
+
+       waitq = bfa_reqq(bfa, qid);
+       list_for_each_safe(qe, qen, waitq) {
+               /**
+                * Callback only as long as there is room in request queue
+                */
+               if (bfa_reqq_full(bfa, qid))
+                       break;
+
+               list_del(qe);
+               wqe = (struct bfa_reqq_wait_s *) qe;
+               wqe->qresume(wqe->cbarg);
+       }
+}
+
+void
+bfa_msix_all(struct bfa_s *bfa, int vec)
+{
+       bfa_intx(bfa);
+}
+
+/**
+ *  hal_intr_api
+ */
+bfa_boolean_t
+bfa_intx(struct bfa_s *bfa)
+{
+       u32 intr, qintr;
+       int queue;
+
+       intr = bfa_reg_read(bfa->iocfc.bfa_regs.intr_status);
+       if (!intr)
+               return BFA_FALSE;
+
+       /**
+        * RME completion queue interrupt
+        */
+       qintr = intr & __HFN_INT_RME_MASK;
+       bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, qintr);
+
+       for (queue = 0; queue < BFI_IOC_MAX_CQS_ASIC; queue++) {
+               if (intr & (__HFN_INT_RME_Q0 << queue))
+                       bfa_msix_rspq(bfa, queue & (BFI_IOC_MAX_CQS - 1));
+       }
+       intr &= ~qintr;
+       if (!intr)
+               return BFA_TRUE;
+
+       /**
+        * CPE completion queue interrupt
+        */
+       qintr = intr & __HFN_INT_CPE_MASK;
+       bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, qintr);
+
+       for (queue = 0; queue < BFI_IOC_MAX_CQS_ASIC; queue++) {
+               if (intr & (__HFN_INT_CPE_Q0 << queue))
+                       bfa_msix_reqq(bfa, queue & (BFI_IOC_MAX_CQS - 1));
+       }
+       intr &= ~qintr;
+       if (!intr)
+               return BFA_TRUE;
+
+       bfa_msix_lpu_err(bfa, intr);
+
+       return BFA_TRUE;
+}
+
+void
+bfa_intx_enable(struct bfa_s *bfa)
+{
+       bfa_reg_write(bfa->iocfc.bfa_regs.intr_mask, bfa->iocfc.intr_mask);
+}
+
+void
+bfa_intx_disable(struct bfa_s *bfa)
+{
+       bfa_reg_write(bfa->iocfc.bfa_regs.intr_mask, -1L);
+}
+
+void
+bfa_isr_enable(struct bfa_s *bfa)
+{
+       u32 intr_unmask;
+       int pci_func = bfa_ioc_pcifn(&bfa->ioc);
+
+       bfa_trc(bfa, pci_func);
+
+       bfa_msix_install(bfa);
+       intr_unmask = (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 |
+                      __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS |
+                      __HFN_INT_LL_HALT);
+
+       if (pci_func == 0)
+               intr_unmask |= (__HFN_INT_CPE_Q0 | __HFN_INT_CPE_Q1 |
+                               __HFN_INT_CPE_Q2 | __HFN_INT_CPE_Q3 |
+                               __HFN_INT_RME_Q0 | __HFN_INT_RME_Q1 |
+                               __HFN_INT_RME_Q2 | __HFN_INT_RME_Q3 |
+                               __HFN_INT_MBOX_LPU0);
+       else
+               intr_unmask |= (__HFN_INT_CPE_Q4 | __HFN_INT_CPE_Q5 |
+                               __HFN_INT_CPE_Q6 | __HFN_INT_CPE_Q7 |
+                               __HFN_INT_RME_Q4 | __HFN_INT_RME_Q5 |
+                               __HFN_INT_RME_Q6 | __HFN_INT_RME_Q7 |
+                               __HFN_INT_MBOX_LPU1);
+
+       bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, intr_unmask);
+       bfa_reg_write(bfa->iocfc.bfa_regs.intr_mask, ~intr_unmask);
+       bfa->iocfc.intr_mask = ~intr_unmask;
+       bfa_isr_mode_set(bfa, bfa->msix.nvecs != 0);
+}
+
+void
+bfa_isr_disable(struct bfa_s *bfa)
+{
+       bfa_isr_mode_set(bfa, BFA_FALSE);
+       bfa_reg_write(bfa->iocfc.bfa_regs.intr_mask, -1L);
+       bfa_msix_uninstall(bfa);
+}
+
+void
+bfa_msix_reqq(struct bfa_s *bfa, int qid)
+{
+       struct list_head *waitq;
+
+       qid &= (BFI_IOC_MAX_CQS - 1);
+
+       bfa->iocfc.hwif.hw_reqq_ack(bfa, qid);
+
+       /**
+        * Resume any pending requests in the corresponding reqq.
+        */
+       waitq = bfa_reqq(bfa, qid);
+       if (!list_empty(waitq))
+               bfa_reqq_resume(bfa, qid);
+}
+
+void
+bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m)
+{
+       bfa_trc(bfa, m->mhdr.msg_class);
+       bfa_trc(bfa, m->mhdr.msg_id);
+       bfa_trc(bfa, m->mhdr.mtag.i2htok);
+       bfa_assert(0);
+       bfa_trc_stop(bfa->trcmod);
+}
+
+void
+bfa_msix_rspq(struct bfa_s *bfa, int qid)
+{
+       struct bfi_msg_s *m;
+       u32 pi, ci;
+       struct list_head *waitq;
+
+       bfa_trc_fp(bfa, qid);
+
+       qid &= (BFI_IOC_MAX_CQS - 1);
+
+       bfa->iocfc.hwif.hw_rspq_ack(bfa, qid);
+
+       ci = bfa_rspq_ci(bfa, qid);
+       pi = bfa_rspq_pi(bfa, qid);
+
+       bfa_trc_fp(bfa, ci);
+       bfa_trc_fp(bfa, pi);
+
+       if (bfa->rme_process) {
+               while (ci != pi) {
+                       m = bfa_rspq_elem(bfa, qid, ci);
+                       bfa_assert_fp(m->mhdr.msg_class < BFI_MC_MAX);
+
+                       bfa_isrs[m->mhdr.msg_class] (bfa, m);
+
+                       CQ_INCR(ci, bfa->iocfc.cfg.drvcfg.num_rspq_elems);
+               }
+       }
+
+       /**
+        * update CI
+        */
+       bfa_rspq_ci(bfa, qid) = pi;
+       bfa_reg_write(bfa->iocfc.bfa_regs.rme_q_ci[qid], pi);
+       mmiowb();
+
+       /**
+        * Resume any pending requests in the corresponding reqq.
+        */
+       waitq = bfa_reqq(bfa, qid);
+       if (!list_empty(waitq))
+               bfa_reqq_resume(bfa, qid);
+}
+
+void
+bfa_msix_lpu_err(struct bfa_s *bfa, int vec)
+{
+       u32 intr, curr_value;
+
+       intr = bfa_reg_read(bfa->iocfc.bfa_regs.intr_status);
+
+       if (intr & (__HFN_INT_MBOX_LPU0 | __HFN_INT_MBOX_LPU1))
+               bfa_msix_lpu(bfa);
+
+       intr &= (__HFN_INT_ERR_EMC | __HFN_INT_ERR_LPU0 |
+               __HFN_INT_ERR_LPU1 | __HFN_INT_ERR_PSS | __HFN_INT_LL_HALT);
+
+       if (intr) {
+               if (intr & __HFN_INT_LL_HALT) {
+                       /**
+                        * If LL_HALT bit is set then FW Init Halt LL Port
+                        * Register needs to be cleared as well so Interrupt
+                        * Status Register will be cleared.
+                        */
+                       curr_value = bfa_reg_read(bfa->ioc.ioc_regs.ll_halt);
+                       curr_value &= ~__FW_INIT_HALT_P;
+                       bfa_reg_write(bfa->ioc.ioc_regs.ll_halt, curr_value);
+               }
+
+               if (intr & __HFN_INT_ERR_PSS) {
+                       /**
+                        * ERR_PSS bit needs to be cleared as well in case
+                        * interrups are shared so driver's interrupt handler is
+                        * still called eventhough it is already masked out.
+                        */
+                       curr_value = bfa_reg_read(
+                                       bfa->ioc.ioc_regs.pss_err_status_reg);
+                       curr_value &= __PSS_ERR_STATUS_SET;
+                       bfa_reg_write(bfa->ioc.ioc_regs.pss_err_status_reg,
+                                       curr_value);
+               }
+
+               bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, intr);
+               bfa_msix_errint(bfa, intr);
+       }
+}
+
+void
+bfa_isr_bind(enum bfi_mclass mc, bfa_isr_func_t isr_func)
+{
+       bfa_isrs[mc] = isr_func;
+}
+
+/**
+ * BFA IOC FC related functions
+ */
+
+/**
+ *  hal_ioc_pvt BFA IOC private functions
+ */
+
+static void
+bfa_iocfc_cqs_sz(struct bfa_iocfc_cfg_s *cfg, u32 *dm_len)
+{
+       int             i, per_reqq_sz, per_rspq_sz;
+
+       per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ),
+                                 BFA_DMA_ALIGN_SZ);
+       per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ),
+                                 BFA_DMA_ALIGN_SZ);
+
+       /*
+        * Calculate CQ size
+        */
+       for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
+               *dm_len = *dm_len + per_reqq_sz;
+               *dm_len = *dm_len + per_rspq_sz;
+       }
+
+       /*
+        * Calculate Shadow CI/PI size
+        */
+       for (i = 0; i < cfg->fwcfg.num_cqs; i++)
+               *dm_len += (2 * BFA_CACHELINE_SZ);
+}
+
+static void
+bfa_iocfc_fw_cfg_sz(struct bfa_iocfc_cfg_s *cfg, u32 *dm_len)
+{
+       *dm_len +=
+               BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
+       *dm_len +=
+               BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
+                           BFA_CACHELINE_SZ);
+}
+
+/**
+ * Use the Mailbox interface to send BFI_IOCFC_H2I_CFG_REQ
+ */
+static void
+bfa_iocfc_send_cfg(void *bfa_arg)
+{
+       struct bfa_s *bfa = bfa_arg;
+       struct bfa_iocfc_s *iocfc = &bfa->iocfc;
+       struct bfi_iocfc_cfg_req_s cfg_req;
+       struct bfi_iocfc_cfg_s *cfg_info = iocfc->cfginfo;
+       struct bfa_iocfc_cfg_s  *cfg = &iocfc->cfg;
+       int             i;
+
+       bfa_assert(cfg->fwcfg.num_cqs <= BFI_IOC_MAX_CQS);
+       bfa_trc(bfa, cfg->fwcfg.num_cqs);
+
+       bfa_iocfc_reset_queues(bfa);
+
+       /**
+        * initialize IOC configuration info
+        */
+       cfg_info->endian_sig = BFI_IOC_ENDIAN_SIG;
+       cfg_info->num_cqs = cfg->fwcfg.num_cqs;
+
+       bfa_dma_be_addr_set(cfg_info->cfgrsp_addr, iocfc->cfgrsp_dma.pa);
+       /**
+        * dma map REQ and RSP circular queues and shadow pointers
+        */
+       for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
+               bfa_dma_be_addr_set(cfg_info->req_cq_ba[i],
+                                   iocfc->req_cq_ba[i].pa);
+               bfa_dma_be_addr_set(cfg_info->req_shadow_ci[i],
+                                   iocfc->req_cq_shadow_ci[i].pa);
+               cfg_info->req_cq_elems[i] =
+                       bfa_os_htons(cfg->drvcfg.num_reqq_elems);
+
+               bfa_dma_be_addr_set(cfg_info->rsp_cq_ba[i],
+                                   iocfc->rsp_cq_ba[i].pa);
+               bfa_dma_be_addr_set(cfg_info->rsp_shadow_pi[i],
+                                   iocfc->rsp_cq_shadow_pi[i].pa);
+               cfg_info->rsp_cq_elems[i] =
+                       bfa_os_htons(cfg->drvcfg.num_rspq_elems);
+       }
+
+       /**
+        * Enable interrupt coalescing if it is driver init path
+        * and not ioc disable/enable path.
+        */
+       if (!iocfc->cfgdone)
+               cfg_info->intr_attr.coalesce = BFA_TRUE;
+
+       iocfc->cfgdone = BFA_FALSE;
+
+       /**
+        * dma map IOC configuration itself
+        */
+       bfi_h2i_set(cfg_req.mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_CFG_REQ,
+                   bfa_lpuid(bfa));
+       bfa_dma_be_addr_set(cfg_req.ioc_cfg_dma_addr, iocfc->cfg_info.pa);
+
+       bfa_ioc_mbox_send(&bfa->ioc, &cfg_req,
+                         sizeof(struct bfi_iocfc_cfg_req_s));
+}
+
+static void
+bfa_iocfc_init_mem(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
+                  struct bfa_pcidev_s *pcidev)
+{
+       struct bfa_iocfc_s      *iocfc = &bfa->iocfc;
+
+       bfa->bfad = bfad;
+       iocfc->bfa = bfa;
+       iocfc->action = BFA_IOCFC_ACT_NONE;
+
+       bfa_os_assign(iocfc->cfg, *cfg);
+
+       /**
+        * Initialize chip specific handlers.
+        */
+       if (bfa_asic_id_ct(bfa_ioc_devid(&bfa->ioc))) {
+               iocfc->hwif.hw_reginit = bfa_hwct_reginit;
+               iocfc->hwif.hw_reqq_ack = bfa_hwct_reqq_ack;
+               iocfc->hwif.hw_rspq_ack = bfa_hwct_rspq_ack;
+               iocfc->hwif.hw_msix_init = bfa_hwct_msix_init;
+               iocfc->hwif.hw_msix_install = bfa_hwct_msix_install;
+               iocfc->hwif.hw_msix_uninstall = bfa_hwct_msix_uninstall;
+               iocfc->hwif.hw_isr_mode_set = bfa_hwct_isr_mode_set;
+               iocfc->hwif.hw_msix_getvecs = bfa_hwct_msix_getvecs;
+               iocfc->hwif.hw_msix_get_rme_range = bfa_hwct_msix_get_rme_range;
+       } else {
+               iocfc->hwif.hw_reginit = bfa_hwcb_reginit;
+               iocfc->hwif.hw_reqq_ack = bfa_hwcb_reqq_ack;
+               iocfc->hwif.hw_rspq_ack = bfa_hwcb_rspq_ack;
+               iocfc->hwif.hw_msix_init = bfa_hwcb_msix_init;
+               iocfc->hwif.hw_msix_install = bfa_hwcb_msix_install;
+               iocfc->hwif.hw_msix_uninstall = bfa_hwcb_msix_uninstall;
+               iocfc->hwif.hw_isr_mode_set = bfa_hwcb_isr_mode_set;
+               iocfc->hwif.hw_msix_getvecs = bfa_hwcb_msix_getvecs;
+               iocfc->hwif.hw_msix_get_rme_range = bfa_hwcb_msix_get_rme_range;
+       }
+
+       iocfc->hwif.hw_reginit(bfa);
+       bfa->msix.nvecs = 0;
+}
+
+static void
+bfa_iocfc_mem_claim(struct bfa_s *bfa, struct bfa_iocfc_cfg_s *cfg,
+                   struct bfa_meminfo_s *meminfo)
+{
+       u8             *dm_kva;
+       u64     dm_pa;
+       int             i, per_reqq_sz, per_rspq_sz;
+       struct bfa_iocfc_s  *iocfc = &bfa->iocfc;
+       int             dbgsz;
+
+       dm_kva = bfa_meminfo_dma_virt(meminfo);
+       dm_pa = bfa_meminfo_dma_phys(meminfo);
+
+       /*
+        * First allocate dma memory for IOC.
+        */
+       bfa_ioc_mem_claim(&bfa->ioc, dm_kva, dm_pa);
+       dm_kva += bfa_ioc_meminfo();
+       dm_pa  += bfa_ioc_meminfo();
+
+       /*
+        * Claim DMA-able memory for the request/response queues and for shadow
+        * ci/pi registers
+        */
+       per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ),
+                                 BFA_DMA_ALIGN_SZ);
+       per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ),
+                                 BFA_DMA_ALIGN_SZ);
+
+       for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
+               iocfc->req_cq_ba[i].kva = dm_kva;
+               iocfc->req_cq_ba[i].pa = dm_pa;
+               bfa_os_memset(dm_kva, 0, per_reqq_sz);
+               dm_kva += per_reqq_sz;
+               dm_pa += per_reqq_sz;
+
+               iocfc->rsp_cq_ba[i].kva = dm_kva;
+               iocfc->rsp_cq_ba[i].pa = dm_pa;
+               bfa_os_memset(dm_kva, 0, per_rspq_sz);
+               dm_kva += per_rspq_sz;
+               dm_pa += per_rspq_sz;
+       }
+
+       for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
+               iocfc->req_cq_shadow_ci[i].kva = dm_kva;
+               iocfc->req_cq_shadow_ci[i].pa = dm_pa;
+               dm_kva += BFA_CACHELINE_SZ;
+               dm_pa += BFA_CACHELINE_SZ;
+
+               iocfc->rsp_cq_shadow_pi[i].kva = dm_kva;
+               iocfc->rsp_cq_shadow_pi[i].pa = dm_pa;
+               dm_kva += BFA_CACHELINE_SZ;
+               dm_pa += BFA_CACHELINE_SZ;
+       }
+
+       /*
+        * Claim DMA-able memory for the config info page
+        */
+       bfa->iocfc.cfg_info.kva = dm_kva;
+       bfa->iocfc.cfg_info.pa = dm_pa;
+       bfa->iocfc.cfginfo = (struct bfi_iocfc_cfg_s *) dm_kva;
+       dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
+       dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
+
+       /*
+        * Claim DMA-able memory for the config response
+        */
+       bfa->iocfc.cfgrsp_dma.kva = dm_kva;
+       bfa->iocfc.cfgrsp_dma.pa = dm_pa;
+       bfa->iocfc.cfgrsp = (struct bfi_iocfc_cfgrsp_s *) dm_kva;
+
+       dm_kva +=
+               BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
+                           BFA_CACHELINE_SZ);
+       dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
+                            BFA_CACHELINE_SZ);
+
+
+       bfa_meminfo_dma_virt(meminfo) = dm_kva;
+       bfa_meminfo_dma_phys(meminfo) = dm_pa;
+
+       dbgsz = bfa_ioc_debug_trcsz(bfa_auto_recover);
+       if (dbgsz > 0) {
+               bfa_ioc_debug_memclaim(&bfa->ioc, bfa_meminfo_kva(meminfo));
+               bfa_meminfo_kva(meminfo) += dbgsz;
+       }
+}
+
+/**
+ * Start BFA submodules.
+ */
+static void
+bfa_iocfc_start_submod(struct bfa_s *bfa)
+{
+       int             i;
+
+       bfa->rme_process = BFA_TRUE;
+
+       for (i = 0; hal_mods[i]; i++)
+               hal_mods[i]->start(bfa);
+}
+
+/**
+ * Disable BFA submodules.
+ */
+static void
+bfa_iocfc_disable_submod(struct bfa_s *bfa)
+{
+       int             i;
+
+       for (i = 0; hal_mods[i]; i++)
+               hal_mods[i]->iocdisable(bfa);
+}
+
+static void
+bfa_iocfc_init_cb(void *bfa_arg, bfa_boolean_t complete)
+{
+       struct bfa_s    *bfa = bfa_arg;
+
+       if (complete) {
+               if (bfa->iocfc.cfgdone)
+                       bfa_cb_init(bfa->bfad, BFA_STATUS_OK);
+               else
+                       bfa_cb_init(bfa->bfad, BFA_STATUS_FAILED);
+       } else {
+               if (bfa->iocfc.cfgdone)
+                       bfa->iocfc.action = BFA_IOCFC_ACT_NONE;
+       }
+}
+
+static void
+bfa_iocfc_stop_cb(void *bfa_arg, bfa_boolean_t compl)
+{
+       struct bfa_s  *bfa = bfa_arg;
+       struct bfad_s *bfad = bfa->bfad;
+
+       if (compl)
+               complete(&bfad->comp);
+       else
+               bfa->iocfc.action = BFA_IOCFC_ACT_NONE;
+}
+
+static void
+bfa_iocfc_disable_cb(void *bfa_arg, bfa_boolean_t compl)
+{
+       struct bfa_s  *bfa = bfa_arg;
+       struct bfad_s *bfad = bfa->bfad;
+
+       if (compl)
+               complete(&bfad->disable_comp);
+}
+
+/**
+ * Update BFA configuration from firmware configuration.
+ */
+static void
+bfa_iocfc_cfgrsp(struct bfa_s *bfa)
+{
+       struct bfa_iocfc_s              *iocfc   = &bfa->iocfc;
+       struct bfi_iocfc_cfgrsp_s       *cfgrsp  = iocfc->cfgrsp;
+       struct bfa_iocfc_fwcfg_s        *fwcfg   = &cfgrsp->fwcfg;
+
+       fwcfg->num_cqs        = fwcfg->num_cqs;
+       fwcfg->num_ioim_reqs  = bfa_os_ntohs(fwcfg->num_ioim_reqs);
+       fwcfg->num_tskim_reqs = bfa_os_ntohs(fwcfg->num_tskim_reqs);
+       fwcfg->num_fcxp_reqs  = bfa_os_ntohs(fwcfg->num_fcxp_reqs);
+       fwcfg->num_uf_bufs    = bfa_os_ntohs(fwcfg->num_uf_bufs);
+       fwcfg->num_rports     = bfa_os_ntohs(fwcfg->num_rports);
+
+       iocfc->cfgdone = BFA_TRUE;
+
+       /**
+        * Configuration is complete - initialize/start submodules
+        */
+       bfa_fcport_init(bfa);
+
+       if (iocfc->action == BFA_IOCFC_ACT_INIT)
+               bfa_cb_queue(bfa, &iocfc->init_hcb_qe, bfa_iocfc_init_cb, bfa);
+       else
+               bfa_iocfc_start_submod(bfa);
+}
+void
+bfa_iocfc_reset_queues(struct bfa_s *bfa)
+{
+       int             q;
+
+       for (q = 0; q < BFI_IOC_MAX_CQS; q++) {
+               bfa_reqq_ci(bfa, q) = 0;
+               bfa_reqq_pi(bfa, q) = 0;
+               bfa_rspq_ci(bfa, q) = 0;
+               bfa_rspq_pi(bfa, q) = 0;
+       }
+}
+
+/**
+ * IOC enable request is complete
+ */
+static void
+bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status)
+{
+       struct bfa_s    *bfa = bfa_arg;
+
+       if (status != BFA_STATUS_OK) {
+               bfa_isr_disable(bfa);
+               if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
+                       bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe,
+                                    bfa_iocfc_init_cb, bfa);
+               return;
+       }
+
+       bfa_iocfc_send_cfg(bfa);
+}
+
+/**
+ * IOC disable request is complete
+ */
+static void
+bfa_iocfc_disable_cbfn(void *bfa_arg)
+{
+       struct bfa_s    *bfa = bfa_arg;
+
+       bfa_isr_disable(bfa);
+       bfa_iocfc_disable_submod(bfa);
+
+       if (bfa->iocfc.action == BFA_IOCFC_ACT_STOP)
+               bfa_cb_queue(bfa, &bfa->iocfc.stop_hcb_qe, bfa_iocfc_stop_cb,
+                            bfa);
+       else {
+               bfa_assert(bfa->iocfc.action == BFA_IOCFC_ACT_DISABLE);
+               bfa_cb_queue(bfa, &bfa->iocfc.dis_hcb_qe, bfa_iocfc_disable_cb,
+                            bfa);
+       }
+}
+
+/**
+ * Notify sub-modules of hardware failure.
+ */
+static void
+bfa_iocfc_hbfail_cbfn(void *bfa_arg)
+{
+       struct bfa_s    *bfa = bfa_arg;
+
+       bfa->rme_process = BFA_FALSE;
+
+       bfa_isr_disable(bfa);
+       bfa_iocfc_disable_submod(bfa);
+
+       if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
+               bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe, bfa_iocfc_init_cb,
+                            bfa);
+}
+
+/**
+ * Actions on chip-reset completion.
+ */
+static void
+bfa_iocfc_reset_cbfn(void *bfa_arg)
+{
+       struct bfa_s    *bfa = bfa_arg;
+
+       bfa_iocfc_reset_queues(bfa);
+       bfa_isr_enable(bfa);
+}
+
+/**
+ *  hal_ioc_public
+ */
+
+/**
+ * Query IOC memory requirement information.
+ */
+void
+bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
+                 u32 *dm_len)
+{
+       /* dma memory for IOC */
+       *dm_len += bfa_ioc_meminfo();
+
+       bfa_iocfc_fw_cfg_sz(cfg, dm_len);
+       bfa_iocfc_cqs_sz(cfg, dm_len);
+       *km_len += bfa_ioc_debug_trcsz(bfa_auto_recover);
+}
+
+/**
+ * Query IOC memory requirement information.
+ */
+void
+bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
+                struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
+{
+       int             i;
+       struct bfa_ioc_s *ioc = &bfa->ioc;
+
+       bfa_iocfc_cbfn.enable_cbfn = bfa_iocfc_enable_cbfn;
+       bfa_iocfc_cbfn.disable_cbfn = bfa_iocfc_disable_cbfn;
+       bfa_iocfc_cbfn.hbfail_cbfn = bfa_iocfc_hbfail_cbfn;
+       bfa_iocfc_cbfn.reset_cbfn = bfa_iocfc_reset_cbfn;
+
+       ioc->trcmod = bfa->trcmod;
+       bfa_ioc_attach(&bfa->ioc, bfa, &bfa_iocfc_cbfn, &bfa->timer_mod);
+
+       /**
+        * Set FC mode for BFA_PCI_DEVICE_ID_CT_FC.
+        */
+       if (pcidev->device_id == BFA_PCI_DEVICE_ID_CT_FC)
+               bfa_ioc_set_fcmode(&bfa->ioc);
+
+       bfa_ioc_pci_init(&bfa->ioc, pcidev, BFI_MC_IOCFC);
+       bfa_ioc_mbox_register(&bfa->ioc, bfa_mbox_isrs);
+
+       bfa_iocfc_init_mem(bfa, bfad, cfg, pcidev);
+       bfa_iocfc_mem_claim(bfa, cfg, meminfo);
+       bfa_timer_init(&bfa->timer_mod);
+
+       INIT_LIST_HEAD(&bfa->comp_q);
+       for (i = 0; i < BFI_IOC_MAX_CQS; i++)
+               INIT_LIST_HEAD(&bfa->reqq_waitq[i]);
+}
+
+/**
+ * Query IOC memory requirement information.
+ */
+void
+bfa_iocfc_detach(struct bfa_s *bfa)
+{
+       bfa_ioc_detach(&bfa->ioc);
+}
+
+/**
+ * Query IOC memory requirement information.
+ */
+void
+bfa_iocfc_init(struct bfa_s *bfa)
+{
+       bfa->iocfc.action = BFA_IOCFC_ACT_INIT;
+       bfa_ioc_enable(&bfa->ioc);
+}
+
+/**
+ * IOC start called from bfa_start(). Called to start IOC operations
+ * at driver instantiation for this instance.
+ */
+void
+bfa_iocfc_start(struct bfa_s *bfa)
+{
+       if (bfa->iocfc.cfgdone)
+               bfa_iocfc_start_submod(bfa);
+}
+
+/**
+ * IOC stop called from bfa_stop(). Called only when driver is unloaded
+ * for this instance.
+ */
+void
+bfa_iocfc_stop(struct bfa_s *bfa)
+{
+       bfa->iocfc.action = BFA_IOCFC_ACT_STOP;
+
+       bfa->rme_process = BFA_FALSE;
+       bfa_ioc_disable(&bfa->ioc);
+}
+
+void
+bfa_iocfc_isr(void *bfaarg, struct bfi_mbmsg_s *m)
+{
+       struct bfa_s            *bfa = bfaarg;
+       struct bfa_iocfc_s      *iocfc = &bfa->iocfc;
+       union bfi_iocfc_i2h_msg_u       *msg;
+
+       msg = (union bfi_iocfc_i2h_msg_u *) m;
+       bfa_trc(bfa, msg->mh.msg_id);
+
+       switch (msg->mh.msg_id) {
+       case BFI_IOCFC_I2H_CFG_REPLY:
+               iocfc->cfg_reply = &msg->cfg_reply;
+               bfa_iocfc_cfgrsp(bfa);
+               break;
+       case BFI_IOCFC_I2H_UPDATEQ_RSP:
+               iocfc->updateq_cbfn(iocfc->updateq_cbarg, BFA_STATUS_OK);
+               break;
+       default:
+               bfa_assert(0);
+       }
+}
+
+void
+bfa_adapter_get_attr(struct bfa_s *bfa, struct bfa_adapter_attr_s *ad_attr)
+{
+       bfa_ioc_get_adapter_attr(&bfa->ioc, ad_attr);
+}
+
+u64
+bfa_adapter_get_id(struct bfa_s *bfa)
+{
+       return bfa_ioc_get_adid(&bfa->ioc);
+}
+
+void
+bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr)
+{
+       struct bfa_iocfc_s      *iocfc = &bfa->iocfc;
+
+       attr->intr_attr.coalesce = iocfc->cfginfo->intr_attr.coalesce;
+
+       attr->intr_attr.delay = iocfc->cfginfo->intr_attr.delay ?
+                               bfa_os_ntohs(iocfc->cfginfo->intr_attr.delay) :
+                               bfa_os_ntohs(iocfc->cfgrsp->intr_attr.delay);
+
+       attr->intr_attr.latency = iocfc->cfginfo->intr_attr.latency ?
+                       bfa_os_ntohs(iocfc->cfginfo->intr_attr.latency) :
+                       bfa_os_ntohs(iocfc->cfgrsp->intr_attr.latency);
+
+       attr->config    = iocfc->cfg;
+}
+
+bfa_status_t
+bfa_iocfc_israttr_set(struct bfa_s *bfa, struct bfa_iocfc_intr_attr_s *attr)
+{
+       struct bfa_iocfc_s              *iocfc = &bfa->iocfc;
+       struct bfi_iocfc_set_intr_req_s *m;
+
+       iocfc->cfginfo->intr_attr.coalesce = attr->coalesce;
+       iocfc->cfginfo->intr_attr.delay = bfa_os_htons(attr->delay);
+       iocfc->cfginfo->intr_attr.latency = bfa_os_htons(attr->latency);
+
+       if (!bfa_iocfc_is_operational(bfa))
+               return BFA_STATUS_OK;
+
+       m = bfa_reqq_next(bfa, BFA_REQQ_IOC);
+       if (!m)
+               return BFA_STATUS_DEVBUSY;
+
+       bfi_h2i_set(m->mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_SET_INTR_REQ,
+                   bfa_lpuid(bfa));
+       m->coalesce = iocfc->cfginfo->intr_attr.coalesce;
+       m->delay    = iocfc->cfginfo->intr_attr.delay;
+       m->latency  = iocfc->cfginfo->intr_attr.latency;
+
+       bfa_trc(bfa, attr->delay);
+       bfa_trc(bfa, attr->latency);
+
+       bfa_reqq_produce(bfa, BFA_REQQ_IOC);
+       return BFA_STATUS_OK;
+}
+
+void
+bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa)
+{
+       struct bfa_iocfc_s      *iocfc = &bfa->iocfc;
+
+       iocfc->cfginfo->sense_buf_len = (BFI_IOIM_SNSLEN - 1);
+       bfa_dma_be_addr_set(iocfc->cfginfo->ioim_snsbase, snsbase_pa);
+}
+/**
+ * Enable IOC after it is disabled.
+ */
+void
+bfa_iocfc_enable(struct bfa_s *bfa)
+{
+       bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
+                    "IOC Enable");
+       bfa_ioc_enable(&bfa->ioc);
+}
+
+void
+bfa_iocfc_disable(struct bfa_s *bfa)
+{
+       bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
+                    "IOC Disable");
+       bfa->iocfc.action = BFA_IOCFC_ACT_DISABLE;
+
+       bfa->rme_process = BFA_FALSE;
+       bfa_ioc_disable(&bfa->ioc);
+}
+
+
+bfa_boolean_t
+bfa_iocfc_is_operational(struct bfa_s *bfa)
+{
+       return bfa_ioc_is_operational(&bfa->ioc) && bfa->iocfc.cfgdone;
+}
+
+/**
+ * Return boot target port wwns -- read from boot information in flash.
+ */
+void
+bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns)
+{
+       struct bfa_iocfc_s *iocfc = &bfa->iocfc;
+       struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
+       int i;
+
+       if (cfgrsp->pbc_cfg.boot_enabled && cfgrsp->pbc_cfg.nbluns) {
+               bfa_trc(bfa, cfgrsp->pbc_cfg.nbluns);
+               *nwwns = cfgrsp->pbc_cfg.nbluns;
+               for (i = 0; i < cfgrsp->pbc_cfg.nbluns; i++)
+                       wwns[i] = cfgrsp->pbc_cfg.blun[i].tgt_pwwn;
+
+               return;
+       }
+
+       *nwwns = cfgrsp->bootwwns.nwwns;
+       memcpy(wwns, cfgrsp->bootwwns.wwn, sizeof(cfgrsp->bootwwns.wwn));
+}
+
+void
+bfa_iocfc_get_pbc_boot_cfg(struct bfa_s *bfa, struct bfa_boot_pbc_s *pbcfg)
+{
+       struct bfa_iocfc_s *iocfc = &bfa->iocfc;
+       struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
+
+       pbcfg->enable = cfgrsp->pbc_cfg.boot_enabled;
+       pbcfg->nbluns = cfgrsp->pbc_cfg.nbluns;
+       pbcfg->speed = cfgrsp->pbc_cfg.port_speed;
+       memcpy(pbcfg->pblun, cfgrsp->pbc_cfg.blun, sizeof(pbcfg->pblun));
+}
+
+int
+bfa_iocfc_get_pbc_vports(struct bfa_s *bfa, struct bfi_pbc_vport_s *pbc_vport)
+{
+       struct bfa_iocfc_s *iocfc = &bfa->iocfc;
+       struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
+
+       memcpy(pbc_vport, cfgrsp->pbc_cfg.vport, sizeof(cfgrsp->pbc_cfg.vport));
+       return cfgrsp->pbc_cfg.nvports;
+}
+
+/**
+ *  hal_api
+ */
 
 /**
  * Use this function query the memory requirement of the BFA library.
  * This call will fail, if the cap is out of range compared to pre-defined
  * values within the BFA library
  *
- * @param[in] cfg -    pointer to bfa_ioc_cfg_t. Driver layer should indicate
- *                     its configuration in this structure.
+ * @param[in] cfg -    pointer to bfa_ioc_cfg_t. Driver layer should indicate
+ *                     its configuration in this structure.
  *                     The default values for struct bfa_iocfc_cfg_s can be
  *                     fetched using bfa_cfg_get_default() API.
  *
- *                     If cap's boundary check fails, the library will use
+ *                     If cap's boundary check fails, the library will use
  *                     the default bfa_cap_t values (and log a warning msg).
  *
  * @param[out] meminfo - pointer to bfa_meminfo_t. This content
- *                     indicates the memory type (see bfa_mem_type_t) and
+ *                     indicates the memory type (see bfa_mem_type_t) and
  *                     amount of memory required.
  *
  *                     Driver should allocate the memory, populate the
 void
 bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo)
 {
-       int             i;
-       u32        km_len = 0, dm_len = 0;
+       int             i;
+       u32     km_len = 0, dm_len = 0;
 
        bfa_assert((cfg != NULL) && (meminfo != NULL));
 
@@ -90,26 +1055,6 @@ bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo)
        meminfo->meminfo[BFA_MEM_TYPE_DMA - 1].mem_len = dm_len;
 }
 
-static void
-bfa_com_port_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi)
-{
-       struct bfa_port_s       *port = &bfa->modules.port;
-       uint32_t                dm_len;
-       uint8_t                 *dm_kva;
-       uint64_t                dm_pa;
-
-       dm_len = bfa_port_meminfo();
-       dm_kva = bfa_meminfo_dma_virt(mi);
-       dm_pa  = bfa_meminfo_dma_phys(mi);
-
-       memset(port, 0, sizeof(struct bfa_port_s));
-       bfa_port_attach(port, &bfa->ioc, bfa, bfa->trcmod, bfa->logm);
-       bfa_port_mem_claim(port, dm_kva, dm_pa);
-
-       bfa_meminfo_dma_virt(mi) = dm_kva + dm_len;
-       bfa_meminfo_dma_phys(mi) = dm_pa + dm_len;
-}
-
 /**
  * Use this function to do attach the driver instance with the BFA
  * library. This function will not trigger any HW initialization
@@ -119,14 +1064,14 @@ bfa_com_port_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi)
  * pre-defined values within the BFA library
  *
  * @param[out] bfa     Pointer to bfa_t.
- * @param[in]  bfad    Opaque handle back to the driver's IOC structure
+ * @param[in]  bfad    Opaque handle back to the driver's IOC structure
  * @param[in]  cfg     Pointer to bfa_ioc_cfg_t. Should be same structure
- *                     that was used in bfa_cfg_get_meminfo().
- * @param[in]  meminfo Pointer to bfa_meminfo_t. The driver should
- *                     use the bfa_cfg_get_meminfo() call to
- *                     find the memory blocks required, allocate the
- *                     required memory and provide the starting addresses.
- * @param[in]  pcidev  pointer to struct bfa_pcidev_s
+ *                     that was used in bfa_cfg_get_meminfo().
+ * @param[in]  meminfo Pointer to bfa_meminfo_t. The driver should
+ *                     use the bfa_cfg_get_meminfo() call to
+ *                     find the memory blocks required, allocate the
+ *                     required memory and provide the starting addresses.
+ * @param[in]  pcidev  pointer to struct bfa_pcidev_s
  *
  * @return
  * void
@@ -140,8 +1085,8 @@ void
 bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
               struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
 {
-       int             i;
-       struct bfa_mem_elem_s *melem;
+       int                     i;
+       struct bfa_mem_elem_s   *melem;
 
        bfa->fcs = BFA_FALSE;
 
@@ -195,20 +1140,6 @@ bfa_init_trc(struct bfa_s *bfa, struct bfa_trc_mod_s *trcmod)
        bfa->trcmod = trcmod;
 }
 
-
-void
-bfa_init_log(struct bfa_s *bfa, struct bfa_log_mod_s *logmod)
-{
-       bfa->logm = logmod;
-}
-
-
-void
-bfa_init_aen(struct bfa_s *bfa, struct bfa_aen_s *aen)
-{
-       bfa->aen = aen;
-}
-
 void
 bfa_init_plog(struct bfa_s *bfa, struct bfa_plog_s *plog)
 {
@@ -254,14 +1185,14 @@ bfa_start(struct bfa_s *bfa)
 
 /**
  * Use this function quiese the IOC. This function will return immediately,
- * when the IOC is actually stopped, the bfa_cb_stop() will be called.
+ * when the IOC is actually stopped, the bfad->comp will be set.
  *
- * @param[in]  bfa - pointer to bfa_t.
+ * @param[in]bfa - pointer to bfa_t.
  *
  * @return None
  *
  * Special Considerations:
- * bfa_cb_stop() could be called before or after bfa_stop() returns.
+ * bfad->comp can be set before or after bfa_stop() returns.
  *
  * @note
  * In case of any failure, we could handle it automatically by doing a
@@ -283,9 +1214,9 @@ bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q)
 void
 bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q)
 {
-       struct list_head        *qe;
-       struct list_head        *qen;
-       struct bfa_cb_qe_s   *hcb_qe;
+       struct list_head                *qe;
+       struct list_head                *qen;
+       struct bfa_cb_qe_s      *hcb_qe;
 
        list_for_each_safe(qe, qen, comp_q) {
                hcb_qe = (struct bfa_cb_qe_s *) qe;
@@ -296,8 +1227,8 @@ bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q)
 void
 bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q)
 {
-       struct list_head        *qe;
-       struct bfa_cb_qe_s   *hcb_qe;
+       struct list_head                *qe;
+       struct bfa_cb_qe_s      *hcb_qe;
 
        while (!list_empty(comp_q)) {
                bfa_q_deq(comp_q, &qe);
@@ -321,7 +1252,6 @@ bfa_timer_tick(struct bfa_s *bfa)
        bfa_timer_beat(&bfa->timer_mod);
 }
 
-#ifndef BFA_BIOS_BUILD
 /**
  * Return the list of PCI vendor/device id lists supported by this
  * BFA instance.
@@ -336,7 +1266,7 @@ bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids)
                {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT_FC},
        };
 
-       *npciids = ARRAY_SIZE(__pciids);
+       *npciids = sizeof(__pciids) / sizeof(__pciids[0]);
        *pciids = __pciids;
 }
 
@@ -351,7 +1281,7 @@ bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids)
  *     void
  *
  * Special Considerations:
- *     note
+ * note
  */
 void
 bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg)
@@ -389,7 +1319,7 @@ bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg)
        cfg->drvcfg.num_sgpgs      = BFA_SGPG_MIN;
        cfg->drvcfg.num_reqq_elems = BFA_REQQ_NELEMS_MIN;
        cfg->drvcfg.num_rspq_elems = BFA_RSPQ_NELEMS_MIN;
-       cfg->drvcfg.min_cfg        = BFA_TRUE;
+       cfg->drvcfg.min_cfg        = BFA_TRUE;
 }
 
 void
@@ -417,7 +1347,7 @@ bfa_debug_fwsave_clear(struct bfa_s *bfa)
 }
 
 /**
- *             Fetch firmware trace data.
+ * Fetch firmware trace data.
  *
  * @param[in]          bfa                     BFA instance
  * @param[out]         trcdata         Firmware trace buffer
@@ -433,6 +1363,22 @@ bfa_debug_fwtrc(struct bfa_s *bfa, void *trcdata, int *trclen)
 }
 
 /**
+ * Dump firmware memory.
+ *
+ * @param[in]          bfa             BFA instance
+ * @param[out]         buf             buffer for dump
+ * @param[in,out]      offset          smem offset to start read
+ * @param[in,out]      buflen          length of buffer
+ *
+ * @retval BFA_STATUS_OK               Firmware memory is dumped.
+ * @retval BFA_STATUS_INPROGRESS       Firmware memory dump is in progress.
+ */
+bfa_status_t
+bfa_debug_fwcore(struct bfa_s *bfa, void *buf, u32 *offset, int *buflen)
+{
+       return bfa_ioc_debug_fwcore(&bfa->ioc, buf, offset, buflen);
+}
+/**
  * Reset hw semaphore & usage cnt regs and initialize.
  */
 void
@@ -441,4 +1387,23 @@ bfa_chip_reset(struct bfa_s *bfa)
        bfa_ioc_ownership_reset(&bfa->ioc);
        bfa_ioc_pll_init(&bfa->ioc);
 }
-#endif
+
+/**
+ * Fetch firmware statistics data.
+ *
+ * @param[in]          bfa             BFA instance
+ * @param[out]         data            Firmware stats buffer
+ *
+ * @retval BFA_STATUS_OK               Firmware trace is fetched.
+ */
+bfa_status_t
+bfa_fw_stats_get(struct bfa_s *bfa, void *data)
+{
+       return bfa_ioc_fw_stats_get(&bfa->ioc, data);
+}
+
+bfa_status_t
+bfa_fw_stats_clear(struct bfa_s *bfa)
+{
+       return bfa_ioc_fw_stats_clear(&bfa->ioc);
+}
diff --git a/drivers/scsi/bfa/bfa_cs.h b/drivers/scsi/bfa/bfa_cs.h
new file mode 100644 (file)
index 0000000..7260c74
--- /dev/null
@@ -0,0 +1,364 @@
+/*
+ * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * All rights reserved
+ * www.brocade.com
+ *
+ * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License (GPL) Version 2 as
+ * published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+/**
+ *  bfa_cs.h BFA common services
+ */
+
+#ifndef __BFA_CS_H__
+#define __BFA_CS_H__
+
+#include "bfa_os_inc.h"
+
+/**
+ * BFA TRC
+ */
+
+#ifndef BFA_TRC_MAX
+#define BFA_TRC_MAX    (4 * 1024)
+#endif
+
+#ifndef BFA_TRC_TS
+#define BFA_TRC_TS(_trcm)      ((_trcm)->ticks++)
+#endif
+
+struct bfa_trc_s {
+#ifdef __BIGENDIAN
+       u16     fileno;
+       u16     line;
+#else
+       u16     line;
+       u16     fileno;
+#endif
+       u32     timestamp;
+       union {
+               struct {
+                       u32     rsvd;
+                       u32     u32;
+               } u32;
+               u64     u64;
+       } data;
+};
+
+struct bfa_trc_mod_s {
+       u32     head;
+       u32     tail;
+       u32     ntrc;
+       u32     stopped;
+       u32     ticks;
+       u32     rsvd[3];
+       struct bfa_trc_s trc[BFA_TRC_MAX];
+};
+
+enum {
+       BFA_TRC_HAL  = 1,       /*  BFA modules */
+       BFA_TRC_FCS  = 2,       /*  BFA FCS modules */
+       BFA_TRC_LDRV = 3,       /*  Linux driver modules */
+       BFA_TRC_CNA  = 4,       /*  Common modules */
+};
+#define BFA_TRC_MOD_SH 10
+#define BFA_TRC_MOD(__mod)     ((BFA_TRC_ ## __mod) << BFA_TRC_MOD_SH)
+
+/**
+ * Define a new tracing file (module). Module should match one defined above.
+ */
+#define BFA_TRC_FILE(__mod, __submod)                                  \
+       static int __trc_fileno = ((BFA_TRC_ ## __mod ## _ ## __submod) | \
+                                                BFA_TRC_MOD(__mod))
+
+
+#define bfa_trc32(_trcp, _data)        \
+       __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u32)_data)
+#define bfa_trc(_trcp, _data)  \
+       __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u64)_data)
+
+static inline void
+bfa_trc_init(struct bfa_trc_mod_s *trcm)
+{
+       trcm->head = trcm->tail = trcm->stopped = 0;
+       trcm->ntrc = BFA_TRC_MAX;
+}
+
+static inline void
+bfa_trc_stop(struct bfa_trc_mod_s *trcm)
+{
+       trcm->stopped = 1;
+}
+
+#ifdef FWTRC
+extern void dc_flush(void *data);
+#else
+#define dc_flush(data)
+#endif
+
+
+static inline void
+__bfa_trc(struct bfa_trc_mod_s *trcm, int fileno, int line, u64 data)
+{
+       int             tail = trcm->tail;
+       struct bfa_trc_s        *trc = &trcm->trc[tail];
+
+       if (trcm->stopped)
+               return;
+
+       trc->fileno = (u16) fileno;
+       trc->line = (u16) line;
+       trc->data.u64 = data;
+       trc->timestamp = BFA_TRC_TS(trcm);
+       dc_flush(trc);
+
+       trcm->tail = (trcm->tail + 1) & (BFA_TRC_MAX - 1);
+       if (trcm->tail == trcm->head)
+               trcm->head = (trcm->head + 1) & (BFA_TRC_MAX - 1);
+       dc_flush(trcm);
+}
+
+
+static inline void
+__bfa_trc32(struct bfa_trc_mod_s *trcm, int fileno, int line, u32 data)
+{
+       int             tail = trcm->tail;
+       struct bfa_trc_s *trc = &trcm->trc[tail];
+
+       if (trcm->stopped)
+               return;
+
+       trc->fileno = (u16) fileno;
+       trc->line = (u16) line;
+       trc->data.u32.u32 = data;
+       trc->timestamp = BFA_TRC_TS(trcm);
+       dc_flush(trc);
+
+       trcm->tail = (trcm->tail + 1) & (BFA_TRC_MAX - 1);
+       if (trcm->tail == trcm->head)
+               trcm->head = (trcm->head + 1) & (BFA_TRC_MAX - 1);
+       dc_flush(trcm);
+}
+
+#ifndef BFA_PERF_BUILD
+#define bfa_trc_fp(_trcp, _data)       bfa_trc(_trcp, _data)
+#else
+#define bfa_trc_fp(_trcp, _data)
+#endif
+
+/**
+ * @ BFA LOG interfaces
+ */
+#define bfa_assert(__cond)     do {                                    \
+       if (!(__cond)) {                                                \
+               printk(KERN_ERR "assert(%s) failed at %s:%d\\n",         \
+               #__cond, __FILE__, __LINE__);                           \
+       }                                                               \
+} while (0)
+
+#define bfa_sm_fault(__mod, __event)   do {                            \
+       bfa_trc(__mod, (((u32)0xDEAD << 16) | __event));                \
+       printk(KERN_ERR "Assertion failure: %s:%d: %d",                 \
+               __FILE__, __LINE__, (__event));                         \
+} while (0)
+
+#ifndef BFA_PERF_BUILD
+#define bfa_assert_fp(__cond)  bfa_assert(__cond)
+#else
+#define bfa_assert_fp(__cond)
+#endif
+
+/* BFA queue definitions */
+#define bfa_q_first(_q) ((void *)(((struct list_head *) (_q))->next))
+#define bfa_q_next(_qe) (((struct list_head *) (_qe))->next)
+#define bfa_q_prev(_qe) (((struct list_head *) (_qe))->prev)
+
+/*
+ * bfa_q_qe_init - to initialize a queue element
+ */
+#define bfa_q_qe_init(_qe) {                           \
+       bfa_q_next(_qe) = (struct list_head *) NULL;    \
+       bfa_q_prev(_qe) = (struct list_head *) NULL;    \
+}
+
+/*
+ * bfa_q_deq - dequeue an element from head of the queue
+ */
+#define bfa_q_deq(_q, _qe) {                                           \
+       if (!list_empty(_q)) {                                          \
+               (*((struct list_head **) (_qe))) = bfa_q_next(_q);      \
+               bfa_q_prev(bfa_q_next(*((struct list_head **) _qe))) =  \
+                               (struct list_head *) (_q);              \
+               bfa_q_next(_q) = bfa_q_next(*((struct list_head **) _qe));\
+               BFA_Q_DBG_INIT(*((struct list_head **) _qe));           \
+       } else {                                                        \
+               *((struct list_head **) (_qe)) = (struct list_head *) NULL;\
+       }                                                               \
+}
+
+/*
+ * bfa_q_deq_tail - dequeue an element from tail of the queue
+ */
+#define bfa_q_deq_tail(_q, _qe) {                                      \
+       if (!list_empty(_q)) {                                          \
+               *((struct list_head **) (_qe)) = bfa_q_prev(_q);        \
+               bfa_q_next(bfa_q_prev(*((struct list_head **) _qe))) =  \
+                       (struct list_head *) (_q);                      \
+               bfa_q_prev(_q) = bfa_q_prev(*(struct list_head **) _qe);\
+               BFA_Q_DBG_INIT(*((struct list_head **) _qe));           \
+       } else {                                                        \
+               *((struct list_head **) (_qe)) = (struct list_head *) NULL;\
+       }                                                               \
+}
+
+static inline int
+bfa_q_is_on_q_func(struct list_head *q, struct list_head *qe)
+{
+       struct list_head        *tqe;
+
+       tqe = bfa_q_next(q);
+       while (tqe != q) {
+               if (tqe == qe)
+                       return 1;
+               tqe = bfa_q_next(tqe);
+               if (tqe == NULL)
+                       break;
+       }
+       return 0;
+}
+
+/*
+ * #ifdef BFA_DEBUG (Using bfa_assert to check for debug_build is not
+ * consistent across modules)
+ */
+#ifndef BFA_PERF_BUILD
+#define BFA_Q_DBG_INIT(_qe) bfa_q_qe_init(_qe)
+#else
+#define BFA_Q_DBG_INIT(_qe)
+#endif
+
+#define bfa_q_is_on_q(_q, _qe)      \
+       bfa_q_is_on_q_func(_q, (struct list_head *)(_qe))
+
+/**
+ * @ BFA state machine interfaces
+ */
+
+typedef void (*bfa_sm_t)(void *sm, int event);
+
+/**
+ * oc - object class eg. bfa_ioc
+ * st - state, eg. reset
+ * otype - object type, eg. struct bfa_ioc_s
+ * etype - object type, eg. enum ioc_event
+ */
+#define bfa_sm_state_decl(oc, st, otype, etype)                \
+       static void oc ## _sm_ ## st(otype * fsm, etype event)
+
+#define bfa_sm_set_state(_sm, _state)  ((_sm)->sm = (bfa_sm_t)(_state))
+#define bfa_sm_send_event(_sm, _event) ((_sm)->sm((_sm), (_event)))
+#define bfa_sm_get_state(_sm)          ((_sm)->sm)
+#define bfa_sm_cmp_state(_sm, _state)  ((_sm)->sm == (bfa_sm_t)(_state))
+
+/**
+ * For converting from state machine function to state encoding.
+ */
+struct bfa_sm_table_s {
+       bfa_sm_t        sm;     /*  state machine function      */
+       int             state;  /*  state machine encoding      */
+       char            *name;  /*  state name for display      */
+};
+#define BFA_SM(_sm)    ((bfa_sm_t)(_sm))
+
+/**
+ * State machine with entry actions.
+ */
+typedef void (*bfa_fsm_t)(void *fsm, int event);
+
+/**
+ * oc - object class eg. bfa_ioc
+ * st - state, eg. reset
+ * otype - object type, eg. struct bfa_ioc_s
+ * etype - object type, eg. enum ioc_event
+ */
+#define bfa_fsm_state_decl(oc, st, otype, etype)               \
+       static void oc ## _sm_ ## st(otype * fsm, etype event);      \
+       static void oc ## _sm_ ## st ## _entry(otype * fsm)
+
+#define bfa_fsm_set_state(_fsm, _state) do {   \
+       (_fsm)->fsm = (bfa_fsm_t)(_state);      \
+       _state ## _entry(_fsm);      \
+} while (0)
+
+#define bfa_fsm_send_event(_fsm, _event)       ((_fsm)->fsm((_fsm), (_event)))
+#define bfa_fsm_get_state(_fsm)                        ((_fsm)->fsm)
+#define bfa_fsm_cmp_state(_fsm, _state)                \
+       ((_fsm)->fsm == (bfa_fsm_t)(_state))
+
+static inline int
+bfa_sm_to_state(struct bfa_sm_table_s *smt, bfa_sm_t sm)
+{
+       int     i = 0;
+
+       while (smt[i].sm && smt[i].sm != sm)
+               i++;
+       return smt[i].state;
+}
+
+/**
+ * @ Generic wait counter.
+ */
+
+typedef void (*bfa_wc_resume_t) (void *cbarg);
+
+struct bfa_wc_s {
+       bfa_wc_resume_t wc_resume;
+       void            *wc_cbarg;
+       int             wc_count;
+};
+
+static inline void
+bfa_wc_up(struct bfa_wc_s *wc)
+{
+       wc->wc_count++;
+}
+
+static inline void
+bfa_wc_down(struct bfa_wc_s *wc)
+{
+       wc->wc_count--;
+       if (wc->wc_count == 0)
+               wc->wc_resume(wc->wc_cbarg);
+}
+
+/**
+ * Initialize a waiting counter.
+ */
+static inline void
+bfa_wc_init(struct bfa_wc_s *wc, bfa_wc_resume_t wc_resume, void *wc_cbarg)
+{
+       wc->wc_resume = wc_resume;
+       wc->wc_cbarg = wc_cbarg;
+       wc->wc_count = 0;
+       bfa_wc_up(wc);
+}
+
+/**
+ * Wait for counter to reach zero
+ */
+static inline void
+bfa_wc_wait(struct bfa_wc_s *wc)
+{
+       bfa_wc_down(wc);
+}
+
+#endif /* __BFA_CS_H__ */
diff --git a/drivers/scsi/bfa/bfa_csdebug.c b/drivers/scsi/bfa/bfa_csdebug.c
deleted file mode 100644 (file)
index caeb114..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
- * All rights reserved
- * www.brocade.com
- *
- * Linux driver for Brocade Fibre Channel Host Bus Adapter.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License (GPL) Version 2 as
- * published by the Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- */
-
-#include <cs/bfa_debug.h>
-#include <bfa_os_inc.h>
-#include <cs/bfa_q.h>
-#include <log/bfa_log_hal.h>
-
-/**
- *  cs_debug_api
- */
-
-
-void
-bfa_panic(int line, char *file, char *panicstr)
-{
-       bfa_log(NULL, BFA_LOG_HAL_ASSERT, file, line, panicstr);
-       bfa_os_panic();
-}
-
-void
-bfa_sm_panic(struct bfa_log_mod_s *logm, int line, char *file, int event)
-{
-       bfa_log(logm, BFA_LOG_HAL_SM_ASSERT, file, line, event);
-       bfa_os_panic();
-}
-
-int
-bfa_q_is_on_q_func(struct list_head *q, struct list_head *qe)
-{
-       struct list_head        *tqe;
-
-       tqe = bfa_q_next(q);
-       while (tqe != q) {
-               if (tqe == qe)
-                       return 1;
-               tqe = bfa_q_next(tqe);
-               if (tqe == NULL)
-                       break;
-       }
-       return 0;
-}
-
-
diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
new file mode 100644 (file)
index 0000000..d49877f
--- /dev/null
@@ -0,0 +1,466 @@
+/*
+ * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * All rights reserved
+ * www.brocade.com
+ *
+ * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License (GPL) Version 2 as
+ * published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef __BFA_DEFS_H__
+#define __BFA_DEFS_H__
+
+#include "bfa_fc.h"
+#include "bfa_os_inc.h"
+
+#define BFA_MFG_SERIALNUM_SIZE                  11
+#define STRSZ(_n)                               (((_n) + 4) & ~3)
+
+/**
+ * Manufacturing card type
+ */
+enum {
+       BFA_MFG_TYPE_CB_MAX  = 825,      /*  Crossbow card type max     */
+       BFA_MFG_TYPE_FC8P2   = 825,      /*  8G 2port FC card           */
+       BFA_MFG_TYPE_FC8P1   = 815,      /*  8G 1port FC card           */
+       BFA_MFG_TYPE_FC4P2   = 425,      /*  4G 2port FC card           */
+       BFA_MFG_TYPE_FC4P1   = 415,      /*  4G 1port FC card           */
+       BFA_MFG_TYPE_CNA10P2 = 1020,     /*  10G 2port CNA card */
+       BFA_MFG_TYPE_CNA10P1 = 1010,     /*  10G 1port CNA card */
+       BFA_MFG_TYPE_JAYHAWK = 804,      /*  Jayhawk mezz card          */
+       BFA_MFG_TYPE_WANCHESE = 1007,    /*  Wanchese mezz card */
+       BFA_MFG_TYPE_ASTRA    = 807,     /*  Astra mezz card            */
+       BFA_MFG_TYPE_LIGHTNING_P0 = 902, /*  Lightning mezz card - old  */
+       BFA_MFG_TYPE_LIGHTNING = 1741,   /*  Lightning mezz card        */
+       BFA_MFG_TYPE_INVALID = 0,        /*  Invalid card type          */
+};
+
+#pragma pack(1)
+
+/**
+ * Check if Mezz card
+ */
+#define bfa_mfg_is_mezz(type) (( \
+       (type) == BFA_MFG_TYPE_JAYHAWK || \
+       (type) == BFA_MFG_TYPE_WANCHESE || \
+       (type) == BFA_MFG_TYPE_ASTRA || \
+       (type) == BFA_MFG_TYPE_LIGHTNING_P0 || \
+       (type) == BFA_MFG_TYPE_LIGHTNING))
+
+/**
+ * Check if the card having old wwn/mac handling
+ */
+#define bfa_mfg_is_old_wwn_mac_model(type) (( \
+       (type) == BFA_MFG_TYPE_FC8P2 || \
+       (type) == BFA_MFG_TYPE_FC8P1 || \
+       (type) == BFA_MFG_TYPE_FC4P2 || \
+       (type) == BFA_MFG_TYPE_FC4P1 || \
+       (type) == BFA_MFG_TYPE_CNA10P2 || \
+       (type) == BFA_MFG_TYPE_CNA10P1 || \
+       (type) == BFA_MFG_TYPE_JAYHAWK || \
+       (type) == BFA_MFG_TYPE_WANCHESE))
+
+#define bfa_mfg_increment_wwn_mac(m, i)                         \
+do {                                                            \
+       u32 t = ((u32)(m)[0] << 16) | ((u32)(m)[1] << 8) | \
+               (u32)(m)[2];  \
+       t += (i);      \
+       (m)[0] = (t >> 16) & 0xFF;                              \
+       (m)[1] = (t >> 8) & 0xFF;                               \
+       (m)[2] = t & 0xFF;                                      \
+} while (0)
+
+/**
+ * VPD data length
+ */
+#define BFA_MFG_VPD_LEN                 512
+
+/**
+ * VPD vendor tag
+ */
+enum {
+       BFA_MFG_VPD_UNKNOWN     = 0,     /*  vendor unknown             */
+       BFA_MFG_VPD_IBM         = 1,     /*  vendor IBM                 */
+       BFA_MFG_VPD_HP          = 2,     /*  vendor HP                  */
+       BFA_MFG_VPD_DELL        = 3,     /*  vendor DELL                */
+       BFA_MFG_VPD_PCI_IBM     = 0x08,  /*  PCI VPD IBM                */
+       BFA_MFG_VPD_PCI_HP      = 0x10,  /*  PCI VPD HP         */
+       BFA_MFG_VPD_PCI_DELL    = 0x20,  /*  PCI VPD DELL               */
+       BFA_MFG_VPD_PCI_BRCD    = 0xf8,  /*  PCI VPD Brocade            */
+};
+
+/**
+ * All numerical fields are in big-endian format.
+ */
+struct bfa_mfg_vpd_s {
+       u8              version;        /*  vpd data version */
+       u8              vpd_sig[3];     /*  characters 'V', 'P', 'D' */
+       u8              chksum;         /*  u8 checksum */
+       u8              vendor;         /*  vendor */
+       u8      len;            /*  vpd data length excluding header */
+       u8      rsv;
+       u8              data[BFA_MFG_VPD_LEN];  /*  vpd data */
+};
+
+#pragma pack()
+
+/**
+ * Status return values
+ */
+enum bfa_status {
+       BFA_STATUS_OK           = 0,    /*  Success */
+       BFA_STATUS_FAILED       = 1,    /*  Operation failed */
+       BFA_STATUS_EINVAL       = 2,    /*  Invalid params Check input
+                                        *  parameters */
+       BFA_STATUS_ENOMEM       = 3,    /*  Out of resources */
+       BFA_STATUS_ETIMER       = 5,    /*  Timer expired - Retry, if persists,
+                                        *  contact support */
+       BFA_STATUS_EPROTOCOL    = 6,    /*  Protocol error */
+       BFA_STATUS_DEVBUSY      = 13,   /*  Device busy - Retry operation */
+       BFA_STATUS_UNKNOWN_LWWN = 18,   /*  LPORT PWWN not found */
+       BFA_STATUS_UNKNOWN_RWWN = 19,   /*  RPORT PWWN not found */
+       BFA_STATUS_VPORT_EXISTS = 21,   /*  VPORT already exists */
+       BFA_STATUS_VPORT_MAX    = 22,   /*  Reached max VPORT supported limit */
+       BFA_STATUS_UNSUPP_SPEED = 23,   /*  Invalid Speed Check speed setting */
+       BFA_STATUS_INVLD_DFSZ   = 24,   /*  Invalid Max data field size */
+       BFA_STATUS_FABRIC_RJT   = 29,   /*  Reject from attached fabric */
+       BFA_STATUS_VPORT_WWN_BP = 46,   /*  WWN is same as base port's WWN */
+       BFA_STATUS_NO_FCPIM_NEXUS = 52, /* No FCP Nexus exists with the rport */
+       BFA_STATUS_IOC_FAILURE  = 56,   /* IOC failure - Retry, if persists
+                                        * contact support */
+       BFA_STATUS_INVALID_WWN  = 57,   /*  Invalid WWN */
+       BFA_STATUS_DIAG_BUSY    = 71,   /*  diag busy */
+       BFA_STATUS_ENOFSAVE     = 78,   /*  No saved firmware trace */
+       BFA_STATUS_IOC_DISABLED = 82,   /* IOC is already disabled */
+       BFA_STATUS_INVALID_MAC  = 134, /*  Invalid MAC address */
+       BFA_STATUS_PBC          = 154, /*  Operation not allowed for pre-boot
+                                       *  configuration */
+       BFA_STATUS_TRUNK_ENABLED = 164, /* Trunk is already enabled on
+                                        * this adapter */
+       BFA_STATUS_TRUNK_DISABLED  = 165, /* Trunking is disabled on
+                                          * the adapter */
+       BFA_STATUS_IOPROFILE_OFF = 175, /* IO profile OFF */
+       BFA_STATUS_MAX_VAL              /* Unknown error code */
+};
+#define bfa_status_t enum bfa_status
+
+enum bfa_eproto_status {
+       BFA_EPROTO_BAD_ACCEPT = 0,
+       BFA_EPROTO_UNKNOWN_RSP = 1
+};
+#define bfa_eproto_status_t enum bfa_eproto_status
+
+enum bfa_boolean {
+       BFA_FALSE = 0,
+       BFA_TRUE  = 1
+};
+#define bfa_boolean_t enum bfa_boolean
+
+#define BFA_STRING_32  32
+#define BFA_VERSION_LEN 64
+
+/**
+ * ---------------------- adapter definitions ------------
+ */
+
+/**
+ * BFA adapter level attributes.
+ */
+enum {
+       BFA_ADAPTER_SERIAL_NUM_LEN = STRSZ(BFA_MFG_SERIALNUM_SIZE),
+                                       /*
+                                        *!< adapter serial num length
+                                        */
+       BFA_ADAPTER_MODEL_NAME_LEN  = 16,  /*  model name length */
+       BFA_ADAPTER_MODEL_DESCR_LEN = 128, /*  model description length */
+       BFA_ADAPTER_MFG_NAME_LEN    = 8,   /*  manufacturer name length */
+       BFA_ADAPTER_SYM_NAME_LEN    = 64,  /*  adapter symbolic name length */
+       BFA_ADAPTER_OS_TYPE_LEN     = 64,  /*  adapter os type length */
+};
+
+struct bfa_adapter_attr_s {
+       char            manufacturer[BFA_ADAPTER_MFG_NAME_LEN];
+       char            serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
+       u32     card_type;
+       char            model[BFA_ADAPTER_MODEL_NAME_LEN];
+       char            model_descr[BFA_ADAPTER_MODEL_DESCR_LEN];
+       wwn_t           pwwn;
+       char            node_symname[FC_SYMNAME_MAX];
+       char            hw_ver[BFA_VERSION_LEN];
+       char            fw_ver[BFA_VERSION_LEN];
+       char            optrom_ver[BFA_VERSION_LEN];
+       char            os_type[BFA_ADAPTER_OS_TYPE_LEN];
+       struct bfa_mfg_vpd_s    vpd;
+       struct mac_s    mac;
+
+       u8              nports;
+       u8              max_speed;
+       u8              prototype;
+       char            asic_rev;
+
+       u8              pcie_gen;
+       u8              pcie_lanes_orig;
+       u8              pcie_lanes;
+       u8              cna_capable;
+
+       u8              is_mezz;
+       u8              trunk_capable;
+};
+
+/**
+ * ---------------------- IOC definitions ------------
+ */
+
+enum {
+       BFA_IOC_DRIVER_LEN      = 16,
+       BFA_IOC_CHIP_REV_LEN    = 8,
+};
+
+/**
+ * Driver and firmware versions.
+ */
+struct bfa_ioc_driver_attr_s {
+       char            driver[BFA_IOC_DRIVER_LEN];     /*  driver name */
+       char            driver_ver[BFA_VERSION_LEN];    /*  driver version */
+       char            fw_ver[BFA_VERSION_LEN];        /*  firmware version */
+       char            bios_ver[BFA_VERSION_LEN];      /*  bios version */
+       char            efi_ver[BFA_VERSION_LEN];       /*  EFI version */
+       char            ob_ver[BFA_VERSION_LEN];        /*  openboot version */
+};
+
+/**
+ * IOC PCI device attributes
+ */
+struct bfa_ioc_pci_attr_s {
+       u16     vendor_id;      /*  PCI vendor ID */
+       u16     device_id;      /*  PCI device ID */
+       u16     ssid;           /*  subsystem ID */
+       u16     ssvid;          /*  subsystem vendor ID */
+       u32     pcifn;          /*  PCI device function */
+       u32     rsvd;           /* padding */
+       char            chip_rev[BFA_IOC_CHIP_REV_LEN];  /*  chip revision */
+};
+
+/**
+ * IOC states
+ */
+enum bfa_ioc_state {
+       BFA_IOC_UNINIT          = 1,    /*  IOC is in uninit state */
+       BFA_IOC_RESET           = 2,    /*  IOC is in reset state */
+       BFA_IOC_SEMWAIT         = 3,    /*  Waiting for IOC h/w semaphore */
+       BFA_IOC_HWINIT          = 4,    /*  IOC h/w is being initialized */
+       BFA_IOC_GETATTR         = 5,    /*  IOC is being configured */
+       BFA_IOC_OPERATIONAL     = 6,    /*  IOC is operational */
+       BFA_IOC_INITFAIL        = 7,    /*  IOC hardware failure */
+       BFA_IOC_FAIL            = 8,    /*  IOC heart-beat failure */
+       BFA_IOC_DISABLING       = 9,    /*  IOC is being disabled */
+       BFA_IOC_DISABLED        = 10,   /*  IOC is disabled */
+       BFA_IOC_FWMISMATCH      = 11,   /*  IOC f/w different from drivers */
+       BFA_IOC_ENABLING        = 12,   /*  IOC is being enabled */
+};
+
+/**
+ * IOC firmware stats
+ */
+struct bfa_fw_ioc_stats_s {
+       u32     enable_reqs;
+       u32     disable_reqs;
+       u32     get_attr_reqs;
+       u32     dbg_sync;
+       u32     dbg_dump;
+       u32     unknown_reqs;
+};
+
+/**
+ * IOC driver stats
+ */
+struct bfa_ioc_drv_stats_s {
+       u32     ioc_isrs;
+       u32     ioc_enables;
+       u32     ioc_disables;
+       u32     ioc_hbfails;
+       u32     ioc_boots;
+       u32     stats_tmos;
+       u32     hb_count;
+       u32     disable_reqs;
+       u32     enable_reqs;
+       u32     disable_replies;
+       u32     enable_replies;
+};
+
+/**
+ * IOC statistics
+ */
+struct bfa_ioc_stats_s {
+       struct bfa_ioc_drv_stats_s      drv_stats; /*  driver IOC stats */
+       struct bfa_fw_ioc_stats_s       fw_stats;  /*  firmware IOC stats */
+};
+
+enum bfa_ioc_type_e {
+       BFA_IOC_TYPE_FC         = 1,
+       BFA_IOC_TYPE_FCoE       = 2,
+       BFA_IOC_TYPE_LL         = 3,
+};
+
+/**
+ * IOC attributes returned in queries
+ */
+struct bfa_ioc_attr_s {
+       enum bfa_ioc_type_e             ioc_type;
+       enum bfa_ioc_state              state;          /*  IOC state      */
+       struct bfa_adapter_attr_s       adapter_attr;   /*  HBA attributes */
+       struct bfa_ioc_driver_attr_s    driver_attr;    /*  driver attr    */
+       struct bfa_ioc_pci_attr_s       pci_attr;
+       u8                              port_id;        /*  port number    */
+       u8                              rsvd[7];        /*  64bit align    */
+};
+
+/**
+ * ---------------------- mfg definitions ------------
+ */
+
+/**
+ * Checksum size
+ */
+#define BFA_MFG_CHKSUM_SIZE                    16
+
+#define BFA_MFG_PARTNUM_SIZE                   14
+#define BFA_MFG_SUPPLIER_ID_SIZE               10
+#define BFA_MFG_SUPPLIER_PARTNUM_SIZE          20
+#define BFA_MFG_SUPPLIER_SERIALNUM_SIZE                20
+#define BFA_MFG_SUPPLIER_REVISION_SIZE         4
+
+#pragma pack(1)
+
+/**
+ * All numerical fields are in big-endian format.
+ */
+struct bfa_mfg_block_s {
+       u8              version;        /*  manufacturing block version */
+       u8              mfg_sig[3];     /*  characters 'M', 'F', 'G' */
+       u16     mfgsize;        /*  mfg block size */
+       u16     u16_chksum;     /*  old u16 checksum */
+       char            brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
+       char            brcd_partnum[STRSZ(BFA_MFG_PARTNUM_SIZE)];
+       u8              mfg_day;        /*  manufacturing day */
+       u8              mfg_month;      /*  manufacturing month */
+       u16     mfg_year;       /*  manufacturing year */
+       wwn_t           mfg_wwn;        /*  wwn base for this adapter */
+       u8              num_wwn;        /*  number of wwns assigned */
+       u8              mfg_speeds;     /*  speeds allowed for this adapter */
+       u8              rsv[2];
+       char            supplier_id[STRSZ(BFA_MFG_SUPPLIER_ID_SIZE)];
+       char            supplier_partnum[STRSZ(BFA_MFG_SUPPLIER_PARTNUM_SIZE)];
+       char
+               supplier_serialnum[STRSZ(BFA_MFG_SUPPLIER_SERIALNUM_SIZE)];
+       char
+               supplier_revision[STRSZ(BFA_MFG_SUPPLIER_REVISION_SIZE)];
+       mac_t           mfg_mac;        /*  mac address */
+       u8              num_mac;        /*  number of mac addresses */
+       u8              rsv2;
+       u32     mfg_type;       /*  card type */
+       u8              rsv3[108];
+       u8              md5_chksum[BFA_MFG_CHKSUM_SIZE]; /*  md5 checksum */
+};
+
+#pragma pack()
+
+/**
+ * ---------------------- pci definitions ------------
+ */
+
+/**
+ * PCI device and vendor ID information
+ */
+enum {
+       BFA_PCI_VENDOR_ID_BROCADE       = 0x1657,
+       BFA_PCI_DEVICE_ID_FC_8G2P       = 0x13,
+       BFA_PCI_DEVICE_ID_FC_8G1P       = 0x17,
+       BFA_PCI_DEVICE_ID_CT            = 0x14,
+       BFA_PCI_DEVICE_ID_CT_FC         = 0x21,
+};
+
+#define bfa_asic_id_ct(devid)                  \
+       ((devid) == BFA_PCI_DEVICE_ID_CT ||     \
+        (devid) == BFA_PCI_DEVICE_ID_CT_FC)
+
+/**
+ * PCI sub-system device and vendor ID information
+ */
+enum {
+       BFA_PCI_FCOE_SSDEVICE_ID        = 0x14,
+};
+
+/**
+ * Maximum number of device address ranges mapped through different BAR(s)
+ */
+#define BFA_PCI_ACCESS_RANGES 1
+
+/*
+ *     Port speed settings. Each specific speed is a bit field. Use multiple
+ *     bits to specify speeds to be selected for auto-negotiation.
+ */
+enum bfa_port_speed {
+       BFA_PORT_SPEED_UNKNOWN = 0,
+       BFA_PORT_SPEED_1GBPS    = 1,
+       BFA_PORT_SPEED_2GBPS    = 2,
+       BFA_PORT_SPEED_4GBPS    = 4,
+       BFA_PORT_SPEED_8GBPS    = 8,
+       BFA_PORT_SPEED_10GBPS   = 10,
+       BFA_PORT_SPEED_16GBPS   = 16,
+       BFA_PORT_SPEED_AUTO =
+               (BFA_PORT_SPEED_1GBPS | BFA_PORT_SPEED_2GBPS |
+                BFA_PORT_SPEED_4GBPS | BFA_PORT_SPEED_8GBPS),
+};
+#define bfa_port_speed_t enum bfa_port_speed
+
+enum {
+       BFA_BOOT_BOOTLUN_MAX = 4,       /*  maximum boot lun per IOC */
+       BFA_PREBOOT_BOOTLUN_MAX = 8,    /*  maximum preboot lun per IOC */
+};
+
+#define BOOT_CFG_REV1   1
+#define BOOT_CFG_VLAN   1
+
+/**
+ *      Boot options setting. Boot options setting determines from where
+ *      to get the boot lun information
+ */
+enum bfa_boot_bootopt {
+       BFA_BOOT_AUTO_DISCOVER  = 0, /*  Boot from blun provided by fabric */
+       BFA_BOOT_STORED_BLUN = 1, /*  Boot from bluns stored in flash */
+       BFA_BOOT_FIRST_LUN      = 2, /*  Boot from first discovered blun */
+       BFA_BOOT_PBC    = 3, /*  Boot from pbc configured blun  */
+};
+
+#pragma pack(1)
+/**
+ * Boot lun information.
+ */
+struct bfa_boot_bootlun_s {
+       wwn_t   pwwn;   /*  port wwn of target */
+       lun_t   lun;    /*  64-bit lun */
+};
+#pragma pack()
+
+/**
+ * BOOT boot configuraton
+ */
+struct bfa_boot_pbc_s {
+       u8              enable;         /*  enable/disable SAN boot */
+       u8              speed;          /*  boot speed settings */
+       u8              topology;       /*  boot topology setting */
+       u8              rsvd1;
+       u32     nbluns;         /*  number of boot luns */
+       struct bfa_boot_bootlun_s pblun[BFA_PREBOOT_BOOTLUN_MAX];
+};
+
+#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 (file)
index 0000000..96905d3
--- /dev/null
@@ -0,0 +1,457 @@
+/*
+ * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * All rights reserved
+ * www.brocade.com
+ *
+ * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License (GPL) Version 2 as
+ * published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef __BFA_DEFS_FCS_H__
+#define __BFA_DEFS_FCS_H__
+
+#include "bfa_fc.h"
+#include "bfa_defs_svc.h"
+
+/**
+ * VF states
+ */
+enum bfa_vf_state {
+       BFA_VF_UNINIT    = 0,   /*  fabric is not yet initialized */
+       BFA_VF_LINK_DOWN = 1,   /*  link is down */
+       BFA_VF_FLOGI     = 2,   /*  flogi is in progress */
+       BFA_VF_AUTH      = 3,   /*  authentication in progress */
+       BFA_VF_NOFABRIC  = 4,   /*  fabric is not present */
+       BFA_VF_ONLINE    = 5,   /*  login to fabric is complete */
+       BFA_VF_EVFP      = 6,   /*  EVFP is in progress */
+       BFA_VF_ISOLATED  = 7,   /*  port isolated due to vf_id mismatch */
+};
+
+/**
+ * VF statistics
+ */
+struct bfa_vf_stats_s {
+       u32     flogi_sent;     /*  Num FLOGIs sent */
+       u32     flogi_rsp_err;  /*  FLOGI response errors */
+       u32     flogi_acc_err;  /*  FLOGI accept errors */
+       u32     flogi_accepts;  /*  FLOGI accepts received */
+       u32     flogi_rejects;  /*  FLOGI rejects received */
+       u32     flogi_unknown_rsp; /*  Unknown responses for FLOGI */
+       u32     flogi_alloc_wait; /*  Allocation waits prior to sending FLOGI */
+       u32     flogi_rcvd;     /*  FLOGIs received */
+       u32     flogi_rejected; /*  Incoming FLOGIs rejected */
+       u32     fabric_onlines; /*  Internal fabric online notification sent
+                                *  to other modules */
+       u32     fabric_offlines; /* Internal fabric offline notification sent
+                                 * to other modules */
+       u32     resvd; /*  padding for 64 bit alignment */
+};
+
+/**
+ * VF attributes returned in queries
+ */
+struct bfa_vf_attr_s {
+       enum bfa_vf_state  state;               /*  VF state */
+       u32        rsvd;
+       wwn_t           fabric_name;    /*  fabric name */
+};
+
+#define BFA_FCS_MAX_LPORTS 256
+#define BFA_FCS_FABRIC_IPADDR_SZ  16
+
+/**
+ * symbolic names for base port/virtual port
+ */
+#define BFA_SYMNAME_MAXLEN     128     /* 128 bytes */
+struct bfa_lport_symname_s {
+       char        symname[BFA_SYMNAME_MAXLEN];
+};
+
+/**
+* Roles of FCS port:
+ *     - FCP IM and FCP TM roles cannot be enabled together for a FCS port
+ *     - Create multiple ports if both IM and TM functions required.
+ *     - Atleast one role must be specified.
+ */
+enum bfa_lport_role {
+       BFA_LPORT_ROLE_FCP_IM   = 0x01, /*  FCP initiator role */
+       BFA_LPORT_ROLE_FCP_MAX  = BFA_LPORT_ROLE_FCP_IM,
+};
+
+/**
+ * FCS port configuration.
+ */
+struct bfa_lport_cfg_s {
+    wwn_t             pwwn;       /*  port wwn */
+    wwn_t             nwwn;       /*  node wwn */
+    struct bfa_lport_symname_s  sym_name;   /*  vm port symbolic name */
+       bfa_boolean_t       preboot_vp;  /*  vport created from PBC */
+    enum bfa_lport_role     roles;      /*  FCS port roles */
+    u8      tag[16];   /*  opaque tag from application */
+};
+
+/**
+ * FCS port states
+ */
+enum bfa_lport_state {
+       BFA_LPORT_UNINIT  = 0,  /*  PORT is not yet initialized */
+       BFA_LPORT_FDISC   = 1,  /*  FDISC is in progress */
+       BFA_LPORT_ONLINE  = 2,  /*  login to fabric is complete */
+       BFA_LPORT_OFFLINE = 3,  /*  No login to fabric */
+};
+
+/**
+ * FCS port type.
+ */
+enum bfa_lport_type {
+       BFA_LPORT_TYPE_PHYSICAL = 0,
+       BFA_LPORT_TYPE_VIRTUAL,
+};
+
+/**
+ * FCS port offline reason.
+ */
+enum bfa_lport_offline_reason {
+       BFA_LPORT_OFFLINE_UNKNOWN = 0,
+       BFA_LPORT_OFFLINE_LINKDOWN,
+       BFA_LPORT_OFFLINE_FAB_UNSUPPORTED,      /*  NPIV not supported by the
+        *    fabric */
+       BFA_LPORT_OFFLINE_FAB_NORESOURCES,
+       BFA_LPORT_OFFLINE_FAB_LOGOUT,
+};
+
+/**
+ * FCS lport info.
+ */
+struct bfa_lport_info_s {
+       u8       port_type;     /* bfa_lport_type_t : physical or
+        * virtual */
+       u8       port_state;    /* one of bfa_lport_state values */
+       u8       offline_reason;        /* one of bfa_lport_offline_reason_t
+        * values */
+       wwn_t      port_wwn;
+       wwn_t      node_wwn;
+
+       /*
+        * following 4 feilds are valid for Physical Ports only
+        */
+       u32     max_vports_supp;        /* Max supported vports */
+       u32     num_vports_inuse;       /* Num of in use vports */
+       u32     max_rports_supp;        /* Max supported rports */
+       u32     num_rports_inuse;       /* Num of doscovered rports */
+
+};
+
+/**
+ * FCS port statistics
+ */
+struct bfa_lport_stats_s {
+       u32     ns_plogi_sent;
+       u32     ns_plogi_rsp_err;
+       u32     ns_plogi_acc_err;
+       u32     ns_plogi_accepts;
+       u32     ns_rejects;     /* NS command rejects */
+       u32     ns_plogi_unknown_rsp;
+       u32     ns_plogi_alloc_wait;
+
+       u32     ns_retries;     /* NS command retries */
+       u32     ns_timeouts;    /* NS command timeouts */
+
+       u32     ns_rspnid_sent;
+       u32     ns_rspnid_accepts;
+       u32     ns_rspnid_rsp_err;
+       u32     ns_rspnid_rejects;
+       u32     ns_rspnid_alloc_wait;
+
+       u32     ns_rftid_sent;
+       u32     ns_rftid_accepts;
+       u32     ns_rftid_rsp_err;
+       u32     ns_rftid_rejects;
+       u32     ns_rftid_alloc_wait;
+
+       u32     ns_rffid_sent;
+       u32     ns_rffid_accepts;
+       u32     ns_rffid_rsp_err;
+       u32     ns_rffid_rejects;
+       u32     ns_rffid_alloc_wait;
+
+       u32     ns_gidft_sent;
+       u32     ns_gidft_accepts;
+       u32     ns_gidft_rsp_err;
+       u32     ns_gidft_rejects;
+       u32     ns_gidft_unknown_rsp;
+       u32     ns_gidft_alloc_wait;
+
+       /*
+        * Mgmt Server stats
+        */
+       u32     ms_retries;     /* MS command retries */
+       u32     ms_timeouts;    /* MS command timeouts */
+       u32     ms_plogi_sent;
+       u32     ms_plogi_rsp_err;
+       u32     ms_plogi_acc_err;
+       u32     ms_plogi_accepts;
+       u32     ms_rejects;     /* MS command rejects */
+       u32     ms_plogi_unknown_rsp;
+       u32     ms_plogi_alloc_wait;
+
+       u32     num_rscn;       /* Num of RSCN received */
+       u32     num_portid_rscn;/* Num portid format RSCN
+       * received */
+
+       u32     uf_recvs;       /* Unsolicited recv frames      */
+       u32     uf_recv_drops;  /* Dropped received frames      */
+
+       u32     plogi_rcvd;     /* Received plogi       */
+       u32     prli_rcvd;      /* Received prli        */
+       u32     adisc_rcvd;     /* Received adisc       */
+       u32     prlo_rcvd;      /* Received prlo        */
+       u32     logo_rcvd;      /* Received logo        */
+       u32     rpsc_rcvd;      /* Received rpsc        */
+       u32     un_handled_els_rcvd;    /* Received unhandled ELS       */
+       u32     rport_plogi_timeouts; /* Rport plogi retry timeout count */
+       u32     rport_del_max_plogi_retry; /* Deleted rport
+                                           * (max retry of plogi) */
+};
+
+/**
+ * BFA port attribute returned in queries
+ */
+struct bfa_lport_attr_s {
+       enum bfa_lport_state state;     /*  port state */
+       u32      pid;   /*  port ID */
+       struct bfa_lport_cfg_s   port_cfg;      /*  port configuration */
+       enum bfa_port_type port_type;   /*  current topology */
+       u32      loopback;      /*  cable is externally looped back */
+       wwn_t   fabric_name; /*  attached switch's nwwn */
+       u8      fabric_ip_addr[BFA_FCS_FABRIC_IPADDR_SZ]; /*  attached
+       * fabric's ip addr */
+       mac_t      fpma_mac;    /*  Lport's FPMA Mac address */
+       u16     authfail;       /*  auth failed state */
+};
+
+
+/**
+ * VPORT states
+ */
+enum bfa_vport_state {
+       BFA_FCS_VPORT_UNINIT            = 0,
+       BFA_FCS_VPORT_CREATED           = 1,
+       BFA_FCS_VPORT_OFFLINE           = 1,
+       BFA_FCS_VPORT_FDISC_SEND        = 2,
+       BFA_FCS_VPORT_FDISC             = 3,
+       BFA_FCS_VPORT_FDISC_RETRY       = 4,
+       BFA_FCS_VPORT_ONLINE            = 5,
+       BFA_FCS_VPORT_DELETING          = 6,
+       BFA_FCS_VPORT_CLEANUP           = 6,
+       BFA_FCS_VPORT_LOGO_SEND         = 7,
+       BFA_FCS_VPORT_LOGO              = 8,
+       BFA_FCS_VPORT_ERROR             = 9,
+       BFA_FCS_VPORT_MAX_STATE,
+};
+
+/**
+ * vport statistics
+ */
+struct bfa_vport_stats_s {
+       struct bfa_lport_stats_s port_stats;    /*  base class (port) stats */
+       /*
+        * TODO - remove
+        */
+
+       u32        fdisc_sent;  /*  num fdisc sent */
+       u32        fdisc_accepts;       /*  fdisc accepts */
+       u32        fdisc_retries;       /*  fdisc retries */
+       u32        fdisc_timeouts;      /*  fdisc timeouts */
+       u32        fdisc_rsp_err;       /*  fdisc response error */
+       u32        fdisc_acc_bad;       /*  bad fdisc accepts */
+       u32        fdisc_rejects;       /*  fdisc rejects */
+       u32        fdisc_unknown_rsp;
+       /*
+        *!< fdisc rsp unknown error
+        */
+       u32        fdisc_alloc_wait;/*  fdisc req (fcxp)alloc wait */
+
+       u32        logo_alloc_wait;/*  logo req (fcxp) alloc wait */
+       u32        logo_sent;   /*  logo sent */
+       u32        logo_accepts;        /*  logo accepts */
+       u32        logo_rejects;        /*  logo rejects */
+       u32        logo_rsp_err;        /*  logo rsp errors */
+       u32        logo_unknown_rsp;
+                       /*  logo rsp unknown errors */
+
+       u32        fab_no_npiv; /*  fabric does not support npiv */
+
+       u32        fab_offline; /*  offline events from fab SM */
+       u32        fab_online;  /*  online events from fab SM */
+       u32        fab_cleanup; /*  cleanup request from fab SM */
+       u32        rsvd;
+};
+
+/**
+ * BFA vport attribute returned in queries
+ */
+struct bfa_vport_attr_s {
+       struct bfa_lport_attr_s   port_attr; /*  base class (port) attributes */
+       enum bfa_vport_state vport_state; /*  vport state */
+       u32          rsvd;
+};
+
+/**
+ * FCS remote port states
+ */
+enum bfa_rport_state {
+       BFA_RPORT_UNINIT        = 0,    /*  PORT is not yet initialized */
+       BFA_RPORT_OFFLINE       = 1,    /*  rport is offline */
+       BFA_RPORT_PLOGI         = 2,    /*  PLOGI to rport is in progress */
+       BFA_RPORT_ONLINE        = 3,    /*  login to rport is complete */
+       BFA_RPORT_PLOGI_RETRY   = 4,    /*  retrying login to rport */
+       BFA_RPORT_NSQUERY       = 5,    /*  nameserver query */
+       BFA_RPORT_ADISC         = 6,    /*  ADISC authentication */
+       BFA_RPORT_LOGO          = 7,    /*  logging out with rport */
+       BFA_RPORT_LOGORCV       = 8,    /*  handling LOGO from rport */
+       BFA_RPORT_NSDISC        = 9,    /*  re-discover rport */
+};
+
+/**
+ *  Rport Scsi Function : Initiator/Target.
+ */
+enum bfa_rport_function {
+       BFA_RPORT_INITIATOR     = 0x01, /*  SCSI Initiator      */
+       BFA_RPORT_TARGET        = 0x02, /*  SCSI Target */
+};
+
+/**
+ * port/node symbolic names for rport
+ */
+#define BFA_RPORT_SYMNAME_MAXLEN       255
+struct bfa_rport_symname_s {
+       char            symname[BFA_RPORT_SYMNAME_MAXLEN];
+};
+
+/**
+ * FCS remote port statistics
+ */
+struct bfa_rport_stats_s {
+       u32        offlines;           /*  remote port offline count  */
+       u32        onlines;            /*  remote port online count   */
+       u32        rscns;              /*  RSCN affecting rport       */
+       u32        plogis;                  /*  plogis sent                */
+       u32        plogi_accs;      /*  plogi accepts              */
+       u32        plogi_timeouts;          /*  plogi timeouts             */
+       u32        plogi_rejects;           /*  rcvd plogi rejects         */
+       u32        plogi_failed;            /*  local failure              */
+       u32        plogi_rcvd;      /*  plogis rcvd                */
+       u32        prli_rcvd;          /*  inbound PRLIs              */
+       u32        adisc_rcvd;         /*  ADISCs received            */
+       u32        adisc_rejects;      /*  recvd  ADISC rejects       */
+       u32        adisc_sent;         /*  ADISC requests sent        */
+       u32        adisc_accs;         /*  ADISC accepted by rport    */
+       u32        adisc_failed;       /*  ADISC failed (no response) */
+       u32        adisc_rejected;     /*  ADISC rejected by us    */
+       u32        logos;              /*  logos sent                 */
+       u32        logo_accs;          /*  LOGO accepts from rport    */
+       u32        logo_failed;        /*  LOGO failures              */
+       u32        logo_rejected;      /*  LOGO rejects from rport    */
+       u32        logo_rcvd;          /*  LOGO from remote port      */
+
+       u32        rpsc_rcvd;         /*  RPSC received            */
+       u32        rpsc_rejects;      /*  recvd  RPSC rejects       */
+       u32        rpsc_sent;         /*  RPSC requests sent        */
+       u32        rpsc_accs;         /*  RPSC accepted by rport    */
+       u32        rpsc_failed;       /*  RPSC failed (no response) */
+       u32        rpsc_rejected;     /*  RPSC rejected by us    */
+
+       u32     rjt_insuff_res; /*  LS RJT with insuff resources */
+       struct bfa_rport_hal_stats_s    hal_stats;  /*  BFA rport stats    */
+};
+
+/**
+ * FCS remote port attributes returned in queries
+ */
+struct bfa_rport_attr_s {
+       wwn_t           nwwn;   /*  node wwn */
+       wwn_t           pwwn;   /*  port wwn */
+       enum fc_cos cos_supported;      /*  supported class of services */
+       u32             pid;    /*  port ID */
+       u32             df_sz;  /*  Max payload size */
+       enum bfa_rport_state    state;  /*  Rport State machine state */
+       enum fc_cos     fc_cos; /*  FC classes of services */
+       bfa_boolean_t   cisc;   /*  CISC capable device */
+       struct bfa_rport_symname_s symname; /*  Symbolic Name */
+       enum bfa_rport_function scsi_function; /*  Initiator/Target */
+       struct bfa_rport_qos_attr_s qos_attr; /*  qos attributes  */
+       enum bfa_port_speed curr_speed;   /*  operating speed got from
+                                           * RPSC ELS. UNKNOWN, if RPSC
+                                           * is not supported */
+       bfa_boolean_t   trl_enforced;   /*  TRL enforced ? TRUE/FALSE */
+       enum bfa_port_speed     assigned_speed; /* Speed assigned by the user.
+                                                * will be used if RPSC is not
+                                                * supported by the rport */
+};
+
+struct bfa_rport_remote_link_stats_s {
+       u32 lfc; /*  Link Failure Count */
+       u32 lsyc; /*  Loss of Synchronization Count */
+       u32 lsic; /*  Loss of Signal Count */
+       u32 pspec; /*  Primitive Sequence Protocol Error Count */
+       u32 itwc; /*  Invalid Transmission Word Count */
+       u32 icc; /*  Invalid CRC Count */
+};
+
+
+#define BFA_MAX_IO_INDEX 7
+#define BFA_NO_IO_INDEX 9
+
+/**
+ * FCS itnim states
+ */
+enum bfa_itnim_state {
+       BFA_ITNIM_OFFLINE       = 0,    /*  offline */
+       BFA_ITNIM_PRLI_SEND     = 1,    /*  prli send */
+       BFA_ITNIM_PRLI_SENT     = 2,    /*  prli sent */
+       BFA_ITNIM_PRLI_RETRY    = 3,    /*  prli retry */
+       BFA_ITNIM_HCB_ONLINE    = 4,    /*  online callback */
+       BFA_ITNIM_ONLINE        = 5,    /*  online */
+       BFA_ITNIM_HCB_OFFLINE   = 6,    /*  offline callback */
+       BFA_ITNIM_INITIATIOR    = 7,    /*  initiator */
+};
+
+/**
+ * FCS remote port statistics
+ */
+struct bfa_itnim_stats_s {
+       u32        onlines;     /*  num rport online */
+       u32        offlines;    /*  num rport offline */
+       u32        prli_sent;   /*  num prli sent out */
+       u32        fcxp_alloc_wait;/*  num fcxp alloc waits */
+       u32        prli_rsp_err;        /*  num prli rsp errors */
+       u32        prli_rsp_acc;        /*  num prli rsp accepts */
+       u32        initiator;   /*  rport is an initiator */
+       u32        prli_rsp_parse_err;  /*  prli rsp parsing errors */
+       u32        prli_rsp_rjt;        /*  num prli rsp rejects */
+       u32        timeout;     /*  num timeouts detected */
+       u32        sler;                /*  num sler notification from BFA */
+       u32     rsvd;           /* padding for 64 bit alignment */
+};
+
+/**
+ * FCS itnim attributes returned in queries
+ */
+struct bfa_itnim_attr_s {
+       enum bfa_itnim_state state; /*  FCS itnim state        */
+       u8 retry;               /*  data retransmision support */
+       u8      task_retry_id;  /*  task retry ident support   */
+       u8 rec_support;    /*  REC supported              */
+       u8 conf_comp;      /*  confirmed completion supp  */
+};
+
+#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 (file)
index 0000000..56226fc
--- /dev/null
@@ -0,0 +1,1081 @@
+/*
+ * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * All rights reserved
+ * www.brocade.com
+ *
+ * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License (GPL) Version 2 as
+ * published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef __BFA_DEFS_SVC_H__
+#define __BFA_DEFS_SVC_H__
+
+#include "bfa_defs.h"
+#include "bfa_fc.h"
+#include "bfi.h"
+
+#define BFA_IOCFC_INTR_DELAY   1125
+#define BFA_IOCFC_INTR_LATENCY 225
+#define BFA_IOCFCOE_INTR_DELAY 25
+#define BFA_IOCFCOE_INTR_LATENCY 5
+
+/**
+ * Interrupt coalescing configuration.
+ */
+#pragma pack(1)
+struct bfa_iocfc_intr_attr_s {
+       u8              coalesce;       /*  enable/disable coalescing */
+       u8              rsvd[3];
+       u16     latency;        /*  latency in microseconds   */
+       u16     delay;          /*  delay in microseconds     */
+};
+
+/**
+ * IOC firmware configuraton
+ */
+struct bfa_iocfc_fwcfg_s {
+       u16        num_fabrics; /*  number of fabrics           */
+       u16        num_lports;  /*  number of local lports      */
+       u16        num_rports;  /*  number of remote ports      */
+       u16        num_ioim_reqs;       /*  number of IO reqs           */
+       u16        num_tskim_reqs;      /*  task management requests    */
+       u16        num_iotm_reqs;       /*  number of TM IO reqs        */
+       u16        num_tsktm_reqs;      /*  TM task management requests*/
+       u16        num_fcxp_reqs;       /*  unassisted FC exchanges     */
+       u16        num_uf_bufs; /*  unsolicited recv buffers    */
+       u8              num_cqs;
+       u8              fw_tick_res;    /*  FW clock resolution in ms */
+       u8              rsvd[4];
+};
+#pragma pack()
+
+struct bfa_iocfc_drvcfg_s {
+       u16        num_reqq_elems;      /*  number of req queue elements */
+       u16        num_rspq_elems;      /*  number of rsp queue elements */
+       u16        num_sgpgs;   /*  number of total SG pages      */
+       u16        num_sboot_tgts;      /*  number of SAN boot targets    */
+       u16        num_sboot_luns;      /*  number of SAN boot luns       */
+       u16         ioc_recover;        /*  IOC recovery mode             */
+       u16         min_cfg;    /*  minimum configuration         */
+       u16        path_tov;    /*  device path timeout   */
+       bfa_boolean_t   delay_comp; /*  delay completion of
+                                                       failed inflight IOs */
+       u32             rsvd;
+};
+
+/**
+ * IOC configuration
+ */
+struct bfa_iocfc_cfg_s {
+       struct bfa_iocfc_fwcfg_s        fwcfg;  /*  firmware side config */
+       struct bfa_iocfc_drvcfg_s       drvcfg; /*  driver side config    */
+};
+
+/**
+ * IOC firmware IO stats
+ */
+struct bfa_fw_io_stats_s {
+       u32     host_abort;             /*  IO aborted by host driver*/
+       u32     host_cleanup;           /*  IO clean up by host driver */
+
+       u32     fw_io_timeout;          /*  IOs timedout */
+       u32     fw_frm_parse;           /*  frame parsed by f/w */
+       u32     fw_frm_data;            /*  fcp_data frame parsed by f/w */
+       u32     fw_frm_rsp;             /*  fcp_rsp frame parsed by f/w */
+       u32     fw_frm_xfer_rdy;        /*  xfer_rdy frame parsed by f/w */
+       u32     fw_frm_bls_acc;         /*  BLS ACC  frame parsed by f/w */
+       u32     fw_frm_tgt_abort;       /*  target ABTS parsed by f/w */
+       u32     fw_frm_unknown;         /*  unknown parsed by f/w */
+       u32     fw_data_dma;            /*  f/w DMA'ed the data frame */
+       u32     fw_frm_drop;            /*  f/w drop the frame */
+
+       u32     rec_timeout;            /*  FW rec timed out */
+       u32     error_rec;                      /*  FW sending rec on
+                                                       * an error condition*/
+       u32     wait_for_si;            /*  FW wait for SI */
+       u32     rec_rsp_inval;          /*  REC rsp invalid */
+       u32     seqr_io_abort;          /*  target does not know cmd so abort */
+       u32     seqr_io_retry;          /*  SEQR failed so retry IO */
+
+       u32     itn_cisc_upd_rsp;       /*  ITN cisc updated on fcp_rsp */
+       u32     itn_cisc_upd_data;      /*  ITN cisc updated on fcp_data */
+       u32     itn_cisc_upd_xfer_rdy;  /*  ITN cisc updated on fcp_data */
+
+       u32     fcp_data_lost;          /*  fcp data lost */
+
+       u32     ro_set_in_xfer_rdy;     /*  Target set RO in Xfer_rdy frame */
+       u32     xfer_rdy_ooo_err;       /*  Out of order Xfer_rdy received */
+       u32     xfer_rdy_unknown_err;   /*  unknown error in xfer_rdy frame */
+
+       u32     io_abort_timeout;       /*  ABTS timedout  */
+       u32     sler_initiated;         /*  SLER initiated */
+
+       u32     unexp_fcp_rsp;          /*  fcp response in wrong state */
+
+       u32     fcp_rsp_under_run;      /*  fcp rsp IO underrun */
+       u32        fcp_rsp_under_run_wr;   /*  fcp rsp IO underrun for write */
+       u32     fcp_rsp_under_run_err;  /*  fcp rsp IO underrun error */
+       u32        fcp_rsp_resid_inval;    /*  invalid residue */
+       u32     fcp_rsp_over_run;       /*  fcp rsp IO overrun */
+       u32     fcp_rsp_over_run_err;   /*  fcp rsp IO overrun error */
+       u32     fcp_rsp_proto_err;      /*  protocol error in fcp rsp */
+       u32     fcp_rsp_sense_err;      /*  error in sense info in fcp rsp */
+       u32     fcp_conf_req;           /*  FCP conf requested */
+
+       u32     tgt_aborted_io;         /*  target initiated abort */
+
+       u32     ioh_edtov_timeout_event;/*  IOH edtov timer popped */
+       u32     ioh_fcp_rsp_excp_event; /*  IOH FCP_RSP exception */
+       u32     ioh_fcp_conf_event;     /*  IOH FCP_CONF */
+       u32     ioh_mult_frm_rsp_event; /*  IOH multi_frame FCP_RSP */
+       u32     ioh_hit_class2_event;   /*  IOH hit class2 */
+       u32     ioh_miss_other_event;   /*  IOH miss other */
+       u32     ioh_seq_cnt_err_event;  /*  IOH seq cnt error */
+       u32     ioh_len_err_event;              /*  IOH len error - fcp_dl !=
+                                                       * bytes xfered */
+       u32     ioh_seq_len_err_event;  /*  IOH seq len error */
+       u32     ioh_data_oor_event;     /*  Data out of range */
+       u32     ioh_ro_ooo_event;       /*  Relative offset out of range */
+       u32     ioh_cpu_owned_event;    /*  IOH hit -iost owned by f/w */
+       u32     ioh_unexp_frame_event;  /*  unexpected frame recieved
+                                                *   count */
+       u32     ioh_err_int;            /*  IOH error int during data-phase
+                                                *   for scsi write
+                                                */
+};
+
+/**
+ * IOC port firmware stats
+ */
+
+struct bfa_fw_port_fpg_stats_s {
+    u32    intr_evt;
+    u32    intr;
+    u32    intr_excess;
+    u32    intr_cause0;
+    u32    intr_other;
+    u32    intr_other_ign;
+    u32    sig_lost;
+    u32    sig_regained;
+    u32    sync_lost;
+    u32    sync_to;
+    u32    sync_regained;
+    u32    div2_overflow;
+    u32    div2_underflow;
+    u32    efifo_overflow;
+    u32    efifo_underflow;
+    u32    idle_rx;
+    u32    lrr_rx;
+    u32    lr_rx;
+    u32    ols_rx;
+    u32    nos_rx;
+    u32    lip_rx;
+    u32    arbf0_rx;
+    u32    arb_rx;
+    u32    mrk_rx;
+    u32    const_mrk_rx;
+    u32    prim_unknown;
+};
+
+
+struct bfa_fw_port_lksm_stats_s {
+    u32    hwsm_success;       /*  hwsm state machine success          */
+    u32    hwsm_fails;         /*  hwsm fails                          */
+    u32    hwsm_wdtov;         /*  hwsm timed out                      */
+    u32    swsm_success;       /*  swsm success                        */
+    u32    swsm_fails;         /*  swsm fails                          */
+    u32    swsm_wdtov;         /*  swsm timed out                      */
+    u32    busybufs;           /*  link init failed due to busybuf     */
+    u32    buf_waits;          /*  bufwait state entries               */
+    u32    link_fails;         /*  link failures                       */
+    u32    psp_errors;         /*  primitive sequence protocol errors  */
+    u32    lr_unexp;           /*  No. of times LR rx-ed unexpectedly  */
+    u32    lrr_unexp;          /*  No. of times LRR rx-ed unexpectedly */
+    u32    lr_tx;              /*  No. of times LR tx started          */
+    u32    lrr_tx;             /*  No. of times LRR tx started         */
+    u32    ols_tx;             /*  No. of times OLS tx started         */
+    u32    nos_tx;             /*  No. of times NOS tx started         */
+    u32    hwsm_lrr_rx;        /*  No. of times LRR rx-ed by HWSM      */
+    u32    hwsm_lr_rx;         /*  No. of times LR rx-ed by HWSM      */
+};
+
+struct bfa_fw_port_snsm_stats_s {
+    u32    hwsm_success;       /*  Successful hwsm terminations        */
+    u32    hwsm_fails;         /*  hwsm fail count                     */
+    u32    hwsm_wdtov;         /*  hwsm timed out                      */
+    u32    swsm_success;       /*  swsm success                        */
+    u32    swsm_wdtov;         /*  swsm timed out                      */
+    u32    error_resets;       /*  error resets initiated by upsm      */
+    u32    sync_lost;          /*  Sync loss count                     */
+    u32    sig_lost;           /*  Signal loss count                   */
+};
+
+struct bfa_fw_port_physm_stats_s {
+    u32    module_inserts;     /*  Module insert count                 */
+    u32    module_xtracts;     /*  Module extracts count               */
+    u32    module_invalids;    /*  Invalid module inserted count       */
+    u32    module_read_ign;    /*  Module validation status ignored    */
+    u32    laser_faults;       /*  Laser fault count                   */
+    u32    rsvd;
+};
+
+struct bfa_fw_fip_stats_s {
+    u32    vlan_req;           /*  vlan discovery requests             */
+    u32    vlan_notify;        /*  vlan notifications                  */
+    u32    vlan_err;           /*  vlan response error                 */
+    u32    vlan_timeouts;      /*  vlan disvoery timeouts              */
+    u32    vlan_invalids;      /*  invalid vlan in discovery advert.   */
+    u32    disc_req;           /*  Discovery solicit requests          */
+    u32    disc_rsp;           /*  Discovery solicit response          */
+    u32    disc_err;           /*  Discovery advt. parse errors        */
+    u32    disc_unsol;         /*  Discovery unsolicited               */
+    u32    disc_timeouts;      /*  Discovery timeouts                  */
+    u32    disc_fcf_unavail;   /*  Discovery FCF Not Avail.            */
+    u32    linksvc_unsupp;     /*  Unsupported link service req        */
+    u32    linksvc_err;        /*  Parse error in link service req     */
+    u32    logo_req;           /*  FIP logos received                  */
+    u32    clrvlink_req;       /*  Clear virtual link req              */
+    u32    op_unsupp;          /*  Unsupported FIP operation           */
+    u32    untagged;           /*  Untagged frames (ignored)           */
+    u32    invalid_version;    /*  Invalid FIP version                 */
+};
+
+struct bfa_fw_lps_stats_s {
+    u32    mac_invalids;       /*  Invalid mac assigned                */
+    u32    rsvd;
+};
+
+struct bfa_fw_fcoe_stats_s {
+    u32    cee_linkups;        /*  CEE link up count                   */
+    u32    cee_linkdns;        /*  CEE link down count                 */
+    u32    fip_linkups;        /*  FIP link up count                   */
+    u32    fip_linkdns;        /*  FIP link up count                   */
+    u32    fip_fails;          /*  FIP fail count                      */
+    u32    mac_invalids;       /*  Invalid mac assigned                */
+};
+
+/**
+ * IOC firmware FCoE port stats
+ */
+struct bfa_fw_fcoe_port_stats_s {
+    struct bfa_fw_fcoe_stats_s  fcoe_stats;
+    struct bfa_fw_fip_stats_s   fip_stats;
+};
+
+/**
+ * IOC firmware FC uport stats
+ */
+struct bfa_fw_fc_uport_stats_s {
+       struct bfa_fw_port_snsm_stats_s         snsm_stats;
+       struct bfa_fw_port_lksm_stats_s         lksm_stats;
+};
+
+/**
+ * IOC firmware FC port stats
+ */
+union bfa_fw_fc_port_stats_s {
+       struct bfa_fw_fc_uport_stats_s  fc_stats;
+       struct bfa_fw_fcoe_port_stats_s fcoe_stats;
+};
+
+/**
+ * IOC firmware port stats
+ */
+struct bfa_fw_port_stats_s {
+       struct bfa_fw_port_fpg_stats_s          fpg_stats;
+       struct bfa_fw_port_physm_stats_s        physm_stats;
+       union  bfa_fw_fc_port_stats_s           fc_port;
+};
+
+/**
+ * fcxchg module statistics
+ */
+struct bfa_fw_fcxchg_stats_s {
+       u32     ua_tag_inv;
+       u32     ua_state_inv;
+};
+
+struct bfa_fw_lpsm_stats_s {
+       u32     cls_rx;
+       u32     cls_tx;
+};
+
+/**
+ *  Trunk statistics
+ */
+struct bfa_fw_trunk_stats_s {
+       u32 emt_recvd;          /*  Trunk EMT received          */
+       u32 emt_accepted;               /*  Trunk EMT Accepted          */
+       u32 emt_rejected;               /*  Trunk EMT rejected          */
+       u32 etp_recvd;          /*  Trunk ETP received          */
+       u32 etp_accepted;               /*  Trunk ETP Accepted          */
+       u32 etp_rejected;               /*  Trunk ETP rejected          */
+       u32 lr_recvd;           /*  Trunk LR received           */
+       u32 rsvd;                       /*  padding for 64 bit alignment */
+};
+
+struct bfa_fw_advsm_stats_s {
+       u32 flogi_sent;         /*  Flogi sent                  */
+       u32 flogi_acc_recvd;    /*  Flogi Acc received          */
+       u32 flogi_rjt_recvd;    /*  Flogi rejects received      */
+       u32 flogi_retries;              /*  Flogi retries               */
+
+       u32 elp_recvd;          /*  ELP received                */
+       u32 elp_accepted;               /*  ELP Accepted                */
+       u32 elp_rejected;               /*  ELP rejected                */
+       u32 elp_dropped;                /*  ELP dropped         */
+};
+
+/**
+ * IOCFC firmware stats
+ */
+struct bfa_fw_iocfc_stats_s {
+       u32     cfg_reqs;       /*  cfg request */
+       u32     updq_reqs;      /*  update queue request */
+       u32     ic_reqs;        /*  interrupt coalesce reqs */
+       u32     unknown_reqs;
+       u32     set_intr_reqs;  /*  set interrupt reqs */
+};
+
+/**
+ * IOC attributes returned in queries
+ */
+struct bfa_iocfc_attr_s {
+       struct bfa_iocfc_cfg_s          config;         /*  IOCFC config   */
+       struct bfa_iocfc_intr_attr_s    intr_attr;      /*  interrupt attr */
+};
+
+/**
+ * Eth_sndrcv mod stats
+ */
+struct bfa_fw_eth_sndrcv_stats_s {
+       u32     crc_err;
+       u32     rsvd;           /*  64bit align    */
+};
+
+/**
+ * CT MAC mod stats
+ */
+struct bfa_fw_mac_mod_stats_s {
+       u32     mac_on;         /*  MAC got turned-on */
+       u32     link_up;        /*  link-up */
+       u32     signal_off;     /*  lost signal */
+       u32     dfe_on;         /*  DFE on */
+       u32     mac_reset;      /*  # of MAC reset to bring lnk up */
+       u32     pcs_reset;      /*  # of PCS reset to bring lnk up */
+       u32     loopback;       /*  MAC got into serdes loopback */
+       u32     lb_mac_reset;
+                       /*  # of MAC reset to bring link up in loopback */
+       u32     lb_pcs_reset;
+                       /*  # of PCS reset to bring link up in loopback */
+       u32     rsvd;           /*  64bit align    */
+};
+
+/**
+ * CT MOD stats
+ */
+struct bfa_fw_ct_mod_stats_s {
+       u32     rxa_rds_undrun; /*  RxA RDS underrun */
+       u32     rad_bpc_ovfl;   /*  RAD BPC overflow */
+       u32     rad_rlb_bpc_ovfl; /*  RAD RLB BPC overflow */
+       u32     bpc_fcs_err;    /*  BPC FCS_ERR */
+       u32     txa_tso_hdr;    /*  TxA TSO header too long */
+       u32     rsvd;           /*  64bit align    */
+};
+
+/**
+ * IOC firmware stats
+ */
+struct bfa_fw_stats_s {
+       struct bfa_fw_ioc_stats_s       ioc_stats;
+       struct bfa_fw_iocfc_stats_s     iocfc_stats;
+       struct bfa_fw_io_stats_s        io_stats;
+       struct bfa_fw_port_stats_s      port_stats;
+       struct bfa_fw_fcxchg_stats_s    fcxchg_stats;
+       struct bfa_fw_lpsm_stats_s      lpsm_stats;
+       struct bfa_fw_lps_stats_s       lps_stats;
+       struct bfa_fw_trunk_stats_s     trunk_stats;
+       struct bfa_fw_advsm_stats_s     advsm_stats;
+       struct bfa_fw_mac_mod_stats_s   macmod_stats;
+       struct bfa_fw_ct_mod_stats_s    ctmod_stats;
+       struct bfa_fw_eth_sndrcv_stats_s        ethsndrcv_stats;
+};
+
+#define BFA_IOCFC_PATHTOV_MAX  60
+#define BFA_IOCFC_QDEPTH_MAX   2000
+
+/**
+ * QoS states
+ */
+enum bfa_qos_state {
+       BFA_QOS_ONLINE = 1,             /*  QoS is online */
+       BFA_QOS_OFFLINE = 2,            /*  QoS is offline */
+};
+
+/**
+ * QoS  Priority levels.
+ */
+enum bfa_qos_priority {
+       BFA_QOS_UNKNOWN = 0,
+       BFA_QOS_HIGH  = 1,      /*  QoS Priority Level High */
+       BFA_QOS_MED  =  2,      /*  QoS Priority Level Medium */
+       BFA_QOS_LOW  =  3,      /*  QoS Priority Level Low */
+};
+
+/**
+ * QoS  bandwidth allocation for each priority level
+ */
+enum bfa_qos_bw_alloc {
+       BFA_QOS_BW_HIGH  = 60,  /*  bandwidth allocation for High */
+       BFA_QOS_BW_MED  =  30,  /*  bandwidth allocation for Medium */
+       BFA_QOS_BW_LOW  =  10,  /*  bandwidth allocation for Low */
+};
+#pragma pack(1)
+/**
+ * QoS attribute returned in QoS Query
+ */
+struct bfa_qos_attr_s {
+       u8              state;          /*  QoS current state */
+       u8              rsvd[3];
+       u32  total_bb_cr;               /*  Total BB Credits */
+};
+
+/**
+ * These fields should be displayed only from the CLI.
+ * There will be a separate BFAL API (get_qos_vc_attr ?)
+ * to retrieve this.
+ *
+ */
+#define  BFA_QOS_MAX_VC  16
+
+struct bfa_qos_vc_info_s {
+       u8 vc_credit;
+       u8 borrow_credit;
+       u8 priority;
+       u8 resvd;
+};
+
+struct bfa_qos_vc_attr_s {
+       u16  total_vc_count;                    /*  Total VC Count */
+       u16  shared_credit;
+       u32  elp_opmode_flags;
+       struct bfa_qos_vc_info_s vc_info[BFA_QOS_MAX_VC];  /*   as many as
+                                                           * total_vc_count */
+};
+
+/**
+ * QoS statistics
+ */
+struct bfa_qos_stats_s {
+       u32     flogi_sent;             /*  QoS Flogi sent */
+       u32     flogi_acc_recvd;        /*  QoS Flogi Acc received */
+       u32     flogi_rjt_recvd; /*  QoS Flogi rejects received */
+       u32     flogi_retries;          /*  QoS Flogi retries */
+
+       u32     elp_recvd;              /*  QoS ELP received */
+       u32     elp_accepted;           /*  QoS ELP Accepted */
+       u32     elp_rejected;       /*  QoS ELP rejected */
+       u32     elp_dropped;        /*  QoS ELP dropped  */
+
+       u32     qos_rscn_recvd;     /*  QoS RSCN received */
+       u32     rsvd;               /* padding for 64 bit alignment */
+};
+
+/**
+ * FCoE statistics
+ */
+struct bfa_fcoe_stats_s {
+       u64     secs_reset;     /*  Seconds since stats reset        */
+       u64     cee_linkups;    /*  CEE link up              */
+       u64     cee_linkdns;    /*  CEE link down                    */
+       u64     fip_linkups;    /*  FIP link up              */
+       u64     fip_linkdns;    /*  FIP link down                    */
+       u64     fip_fails;      /*  FIP failures                     */
+       u64     mac_invalids;   /*  Invalid mac assignments          */
+       u64     vlan_req;       /*  Vlan requests                    */
+       u64     vlan_notify;    /*  Vlan notifications               */
+       u64     vlan_err;       /*  Vlan notification errors         */
+       u64     vlan_timeouts;  /*  Vlan request timeouts            */
+       u64     vlan_invalids;  /*  Vlan invalids                    */
+       u64     disc_req;       /*  Discovery requests               */
+       u64     disc_rsp;       /*  Discovery responses      */
+       u64     disc_err;       /*  Discovery error frames           */
+       u64     disc_unsol;     /*  Discovery unsolicited            */
+       u64     disc_timeouts;  /*  Discovery timeouts               */
+       u64     disc_fcf_unavail; /*  Discovery FCF not avail        */
+       u64     linksvc_unsupp; /*  FIP link service req unsupp.    */
+       u64     linksvc_err;    /*  FIP link service req errors     */
+       u64     logo_req;       /*  FIP logos received               */
+       u64     clrvlink_req;   /*  Clear virtual link requests     */
+       u64     op_unsupp;      /*  FIP operation unsupp.            */
+       u64     untagged;       /*  FIP untagged frames      */
+       u64     txf_ucast;      /*  Tx FCoE unicast frames           */
+       u64     txf_ucast_vlan; /*  Tx FCoE unicast vlan frames     */
+       u64     txf_ucast_octets; /*  Tx FCoE unicast octets         */
+       u64     txf_mcast;      /*  Tx FCoE multicast frames         */
+       u64     txf_mcast_vlan; /*  Tx FCoE multicast vlan frames   */
+       u64     txf_mcast_octets; /*  Tx FCoE multicast octets       */
+       u64     txf_bcast;      /*  Tx FCoE broadcast frames         */
+       u64     txf_bcast_vlan; /*  Tx FCoE broadcast vlan frames   */
+       u64     txf_bcast_octets; /*  Tx FCoE broadcast octets       */
+       u64     txf_timeout;    /*  Tx timeouts              */
+       u64     txf_parity_errors; /*  Transmit parity err           */
+       u64     txf_fid_parity_errors; /*  Transmit FID parity err  */
+       u64     rxf_ucast_octets; /*  Rx FCoE unicast octets         */
+       u64     rxf_ucast;      /*  Rx FCoE unicast frames           */
+       u64     rxf_ucast_vlan; /*  Rx FCoE unicast vlan frames     */
+       u64     rxf_mcast_octets; /*  Rx FCoE multicast octets       */
+       u64     rxf_mcast;      /*  Rx FCoE multicast frames         */
+       u64     rxf_mcast_vlan; /*  Rx FCoE multicast vlan frames   */
+       u64     rxf_bcast_octets; /*  Rx FCoE broadcast octets       */
+       u64     rxf_bcast;      /*  Rx FCoE broadcast frames         */
+       u64     rxf_bcast_vlan; /*  Rx FCoE broadcast vlan frames   */
+};
+
+/**
+ * QoS or FCoE stats (fcport stats excluding physical FC port stats)
+ */
+union bfa_fcport_stats_u {
+       struct bfa_qos_stats_s  fcqos;
+       struct bfa_fcoe_stats_s fcoe;
+};
+#pragma pack()
+
+struct bfa_fcpim_del_itn_stats_s {
+       u32     del_itn_iocomp_aborted;    /* Aborted IO requests             */
+       u32     del_itn_iocomp_timedout;   /* IO timeouts                     */
+       u32     del_itn_iocom_sqer_needed; /* IO retry for SQ error recovery  */
+       u32     del_itn_iocom_res_free;    /* Delayed freeing of IO resources */
+       u32     del_itn_iocom_hostabrts;   /* Host IO abort requests          */
+       u32     del_itn_total_ios;         /* Total IO count                  */
+       u32     del_io_iocdowns;           /* IO cleaned-up due to IOC down   */
+       u32     del_tm_iocdowns;           /* TM cleaned-up due to IOC down   */
+};
+
+struct bfa_itnim_iostats_s {
+
+       u32     total_ios;              /*  Total IO Requests           */
+       u32     input_reqs;             /*  Data in-bound requests      */
+       u32     output_reqs;            /*  Data out-bound requests     */
+       u32     io_comps;               /*  Total IO Completions        */
+       u32     wr_throughput;          /*  Write data transfered in bytes */
+       u32     rd_throughput;          /*  Read data transfered in bytes  */
+
+       u32     iocomp_ok;              /*  Slowpath IO completions     */
+       u32     iocomp_underrun;        /*  IO underrun         */
+       u32     iocomp_overrun;         /*  IO overrun                  */
+       u32     qwait;                  /*  IO Request-Q wait           */
+       u32     qresumes;               /*  IO Request-Q wait done      */
+       u32     no_iotags;              /*  No free IO tag              */
+       u32     iocomp_timedout;        /*  IO timeouts         */
+       u32     iocom_nexus_abort;      /*  IO failure due to target offline */
+       u32     iocom_proto_err;        /*  IO protocol errors          */
+       u32     iocom_dif_err;          /*  IO SBC-3 protection errors  */
+
+       u32     iocom_sqer_needed;      /*  fcp-2 error recovery failed */
+       u32     iocom_res_free;         /*  Delayed freeing of IO tag   */
+
+
+       u32     io_aborts;              /*  Host IO abort requests      */
+       u32     iocom_hostabrts;        /*  Host IO abort completions   */
+       u32     io_cleanups;            /*  IO clean-up requests        */
+       u32     path_tov_expired;       /*  IO path tov expired */
+       u32     iocomp_aborted;         /*  IO abort completions        */
+       u32     io_iocdowns;            /*  IO cleaned-up due to IOC down */
+       u32     iocom_utags;            /*  IO comp with unknown tags   */
+
+       u32     io_tmaborts;            /*  Abort request due to TM command */
+       u32     tm_io_comps;            /* Abort completion due to TM command */
+
+       u32     creates;                /*  IT Nexus create requests    */
+       u32     fw_create;              /*  IT Nexus FW create requests */
+       u32     create_comps;           /*  IT Nexus FW create completions */
+       u32     onlines;                /*  IT Nexus onlines            */
+       u32     offlines;               /*  IT Nexus offlines           */
+       u32     fw_delete;              /*  IT Nexus FW delete requests */
+       u32     delete_comps;           /*  IT Nexus FW delete completions */
+       u32     deletes;                /*  IT Nexus delete requests       */
+       u32     sler_events;            /*  SLER events         */
+       u32     ioc_disabled;           /*  Num IOC disables            */
+       u32     cleanup_comps;          /*  IT Nexus cleanup completions    */
+
+       u32     tm_cmnds;               /*  TM Requests         */
+       u32     tm_fw_rsps;             /*  TM Completions              */
+       u32     tm_success;             /*  TM initiated IO cleanup success */
+       u32     tm_failures;            /*  TM initiated IO cleanup failure */
+       u32     no_tskims;              /*  No free TM tag              */
+       u32     tm_qwait;               /*  TM Request-Q wait           */
+       u32     tm_qresumes;            /*  TM Request-Q wait done      */
+
+       u32     tm_iocdowns;            /*  TM cleaned-up due to IOC down   */
+       u32     tm_cleanups;            /*  TM cleanup requests */
+       u32     tm_cleanup_comps;       /*  TM cleanup completions      */
+};
+
+/* Modify char* port_stt[] in bfal_port.c if a new state was added */
+enum bfa_port_states {
+       BFA_PORT_ST_UNINIT              = 1,
+       BFA_PORT_ST_ENABLING_QWAIT      = 2,
+       BFA_PORT_ST_ENABLING            = 3,
+       BFA_PORT_ST_LINKDOWN            = 4,
+       BFA_PORT_ST_LINKUP              = 5,
+       BFA_PORT_ST_DISABLING_QWAIT     = 6,
+       BFA_PORT_ST_DISABLING           = 7,
+       BFA_PORT_ST_DISABLED            = 8,
+       BFA_PORT_ST_STOPPED             = 9,
+       BFA_PORT_ST_IOCDOWN             = 10,
+       BFA_PORT_ST_IOCDIS              = 11,
+       BFA_PORT_ST_FWMISMATCH          = 12,
+       BFA_PORT_ST_PREBOOT_DISABLED    = 13,
+       BFA_PORT_ST_TOGGLING_QWAIT      = 14,
+       BFA_PORT_ST_MAX_STATE,
+};
+
+/**
+ *     Port operational type (in sync with SNIA port type).
+ */
+enum bfa_port_type {
+       BFA_PORT_TYPE_UNKNOWN   = 1,    /*  port type is unknown */
+       BFA_PORT_TYPE_NPORT     = 5,    /*  P2P with switched fabric */
+       BFA_PORT_TYPE_NLPORT    = 6,    /*  public loop */
+       BFA_PORT_TYPE_LPORT     = 20,   /*  private loop */
+       BFA_PORT_TYPE_P2P       = 21,   /*  P2P with no switched fabric */
+       BFA_PORT_TYPE_VPORT     = 22,   /*  NPIV - virtual port */
+};
+
+/**
+ *     Port topology setting. A port's topology and fabric login status
+ *     determine its operational type.
+ */
+enum bfa_port_topology {
+       BFA_PORT_TOPOLOGY_NONE = 0,     /*  No valid topology */
+       BFA_PORT_TOPOLOGY_P2P  = 1,     /*  P2P only */
+       BFA_PORT_TOPOLOGY_LOOP = 2,     /*  LOOP topology */
+       BFA_PORT_TOPOLOGY_AUTO = 3,     /*  auto topology selection */
+};
+
+/**
+ *     Physical port loopback types.
+ */
+enum bfa_port_opmode {
+       BFA_PORT_OPMODE_NORMAL   = 0x00, /*  normal non-loopback mode */
+       BFA_PORT_OPMODE_LB_INT   = 0x01, /*  internal loop back */
+       BFA_PORT_OPMODE_LB_SLW   = 0x02, /*  serial link wrapback (serdes) */
+       BFA_PORT_OPMODE_LB_EXT   = 0x04, /*  external loop back (serdes) */
+       BFA_PORT_OPMODE_LB_CBL   = 0x08, /*  cabled loop back */
+       BFA_PORT_OPMODE_LB_NLINT = 0x20, /*  NL_Port internal loopback */
+};
+
+#define BFA_PORT_OPMODE_LB_HARD(_mode)                 \
+       ((_mode == BFA_PORT_OPMODE_LB_INT) ||           \
+       (_mode == BFA_PORT_OPMODE_LB_SLW) ||            \
+       (_mode == BFA_PORT_OPMODE_LB_EXT))
+
+/**
+ *     Port link state
+ */
+enum bfa_port_linkstate {
+       BFA_PORT_LINKUP         = 1,    /*  Physical port/Trunk link up */
+       BFA_PORT_LINKDOWN       = 2,    /*  Physical port/Trunk link down */
+};
+
+/**
+ *     Port link state reason code
+ */
+enum bfa_port_linkstate_rsn {
+       BFA_PORT_LINKSTATE_RSN_NONE             = 0,
+       BFA_PORT_LINKSTATE_RSN_DISABLED         = 1,
+       BFA_PORT_LINKSTATE_RSN_RX_NOS           = 2,
+       BFA_PORT_LINKSTATE_RSN_RX_OLS           = 3,
+       BFA_PORT_LINKSTATE_RSN_RX_LIP           = 4,
+       BFA_PORT_LINKSTATE_RSN_RX_LIPF7         = 5,
+       BFA_PORT_LINKSTATE_RSN_SFP_REMOVED      = 6,
+       BFA_PORT_LINKSTATE_RSN_PORT_FAULT       = 7,
+       BFA_PORT_LINKSTATE_RSN_RX_LOS           = 8,
+       BFA_PORT_LINKSTATE_RSN_LOCAL_FAULT      = 9,
+       BFA_PORT_LINKSTATE_RSN_REMOTE_FAULT     = 10,
+       BFA_PORT_LINKSTATE_RSN_TIMEOUT          = 11,
+
+
+
+       /* CEE related reason codes/errors */
+       CEE_LLDP_INFO_AGED_OUT                  = 20,
+       CEE_LLDP_SHUTDOWN_TLV_RCVD              = 21,
+       CEE_PEER_NOT_ADVERTISE_DCBX             = 22,
+       CEE_PEER_NOT_ADVERTISE_PG               = 23,
+       CEE_PEER_NOT_ADVERTISE_PFC              = 24,
+       CEE_PEER_NOT_ADVERTISE_FCOE             = 25,
+       CEE_PG_NOT_COMPATIBLE                   = 26,
+       CEE_PFC_NOT_COMPATIBLE                  = 27,
+       CEE_FCOE_NOT_COMPATIBLE                 = 28,
+       CEE_BAD_PG_RCVD                         = 29,
+       CEE_BAD_BW_RCVD                         = 30,
+       CEE_BAD_PFC_RCVD                        = 31,
+       CEE_BAD_APP_PRI_RCVD                    = 32,
+       CEE_FCOE_PRI_PFC_OFF                    = 33,
+       CEE_DUP_CONTROL_TLV_RCVD                = 34,
+       CEE_DUP_FEAT_TLV_RCVD                   = 35,
+       CEE_APPLY_NEW_CFG                       = 36, /* reason, not error */
+       CEE_PROTOCOL_INIT                       = 37, /* reason, not error */
+       CEE_PHY_LINK_DOWN                       = 38,
+       CEE_LLS_FCOE_ABSENT                     = 39,
+       CEE_LLS_FCOE_DOWN                       = 40,
+       CEE_ISCSI_NOT_COMPATIBLE                = 41,
+       CEE_ISCSI_PRI_PFC_OFF                   = 42,
+       CEE_ISCSI_PRI_OVERLAP_FCOE_PRI          = 43
+};
+#pragma pack(1)
+/**
+ *      Physical port configuration
+ */
+struct bfa_port_cfg_s {
+       u8       topology;      /*  bfa_port_topology           */
+       u8       speed;         /*  enum bfa_port_speed */
+       u8       trunked;       /*  trunked or not              */
+       u8       qos_enabled;   /*  qos enabled or not          */
+       u8       cfg_hardalpa;  /*  is hard alpa configured     */
+       u8       hardalpa;      /*  configured hard alpa        */
+       u16 maxfrsize;  /*  maximum frame size          */
+       u8       rx_bbcredit;   /*  receive buffer credits      */
+       u8       tx_bbcredit;   /*  transmit buffer credits     */
+       u8       ratelimit;     /*  ratelimit enabled or not    */
+       u8       trl_def_speed; /*  ratelimit default speed     */
+       u16 path_tov;   /*  device path timeout */
+       u16 q_depth;    /*  SCSI Queue depth            */
+};
+#pragma pack()
+
+/**
+ *     Port attribute values.
+ */
+struct bfa_port_attr_s {
+       /*
+        * Static fields
+        */
+       wwn_t      nwwn;                /*  node wwn */
+       wwn_t      pwwn;                /*  port wwn */
+       wwn_t      factorynwwn; /*  factory node wwn */
+       wwn_t      factorypwwn; /*  factory port wwn */
+       enum fc_cos     cos_supported;  /*  supported class of services */
+       u32     rsvd;
+       struct fc_symname_s     port_symname;   /*  port symbolic name */
+       enum bfa_port_speed speed_supported; /*  supported speeds */
+       bfa_boolean_t   pbind_enabled;
+
+       /*
+        * Configured values
+        */
+       struct bfa_port_cfg_s pport_cfg;        /*  pport cfg */
+
+       /*
+        * Dynamic field - info from BFA
+        */
+       enum bfa_port_states    port_state;     /*  current port state */
+       enum bfa_port_speed     speed;          /*  current speed */
+       enum bfa_port_topology  topology;       /*  current topology */
+       bfa_boolean_t           beacon;         /*  current beacon status */
+       bfa_boolean_t           link_e2e_beacon; /*  link beacon is on */
+       bfa_boolean_t           plog_enabled;   /*  portlog is enabled */
+
+       /*
+        * Dynamic field - info from FCS
+        */
+       u32             pid;            /*  port ID */
+       enum bfa_port_type      port_type;      /*  current topology */
+       u32             loopback;       /*  external loopback */
+       u32             authfail;       /*  auth fail state */
+       bfa_boolean_t           io_profile;     /*  get it from fcpim mod */
+       u8                      pad[4];         /*  for 64-bit alignement */
+
+       /* FCoE specific  */
+       u16             fcoe_vlan;
+       u8                      rsvd1[6];
+};
+
+/**
+ *           Port FCP mappings.
+ */
+struct bfa_port_fcpmap_s {
+       char            osdevname[256];
+       u32     bus;
+       u32     target;
+       u32     oslun;
+       u32     fcid;
+       wwn_t      nwwn;
+       wwn_t      pwwn;
+       u64     fcplun;
+       char            luid[256];
+};
+
+/**
+ *           Port RNID info.
+ */
+struct bfa_port_rnid_s {
+       wwn_t        wwn;
+       u32       unittype;
+       u32       portid;
+       u32       attached_nodes_num;
+       u16       ip_version;
+       u16       udp_port;
+       u8         ipaddr[16];
+       u16       rsvd;
+       u16       topologydiscoveryflags;
+};
+
+#pragma pack(1)
+struct bfa_fcport_fcf_s {
+       wwn_t      name;           /*  FCF name          */
+       wwn_t      fabric_name;    /*  Fabric Name            */
+       u8              fipenabled;     /*  FIP enabled or not */
+       u8              fipfailed;      /*  FIP failed or not   */
+       u8              resv[2];
+       u8       pri;       /*  FCF priority         */
+       u8       version;       /*  FIP version used     */
+       u8       available;      /*  Available  for  login    */
+       u8       fka_disabled;   /*  FKA is disabled      */
+       u8       maxsz_verified; /*  FCoE max size verified   */
+       u8       fc_map[3];      /*  FC map                */
+       u16     vlan;      /*  FCoE vlan tag/priority   */
+       u32     fka_adv_per;    /*  FIP  ka advert. period   */
+       mac_t      mac;     /*  FCF mac           */
+};
+
+/**
+ *     Trunk states for BCU/BFAL
+ */
+enum bfa_trunk_state {
+       BFA_TRUNK_DISABLED      = 0,    /*  Trunk is not configured     */
+       BFA_TRUNK_ONLINE        = 1,    /*  Trunk is online             */
+       BFA_TRUNK_OFFLINE       = 2,    /*  Trunk is offline            */
+};
+
+/**
+ *     VC attributes for trunked link
+ */
+struct bfa_trunk_vc_attr_s {
+       u32 bb_credit;
+       u32 elp_opmode_flags;
+       u32 req_credit;
+       u16 vc_credits[8];
+};
+
+/**
+ *     Link state information
+ */
+struct bfa_port_link_s {
+       u8       linkstate;     /*  Link state bfa_port_linkstate */
+       u8       linkstate_rsn; /*  bfa_port_linkstate_rsn_t */
+       u8       topology;      /*  P2P/LOOP bfa_port_topology */
+       u8       speed;         /*  Link speed (1/2/4/8 G) */
+       u32     linkstate_opt;  /*  Linkstate optional data (debug) */
+       u8       trunked;       /*  Trunked or not (1 or 0) */
+       u8       resvd[3];
+       struct bfa_qos_attr_s  qos_attr;   /* QoS Attributes */
+       union {
+               struct bfa_qos_vc_attr_s qos_vc_attr;  /*  VC info from ELP */
+               struct bfa_trunk_vc_attr_s trunk_vc_attr;
+               struct bfa_fcport_fcf_s fcf; /*  FCF information (for FCoE) */
+       } vc_fcf;
+};
+#pragma pack()
+
+enum bfa_trunk_link_fctl {
+       BFA_TRUNK_LINK_FCTL_NORMAL,
+       BFA_TRUNK_LINK_FCTL_VC,
+       BFA_TRUNK_LINK_FCTL_VC_QOS,
+};
+
+enum bfa_trunk_link_state {
+       BFA_TRUNK_LINK_STATE_UP = 1,            /* link part of trunk */
+       BFA_TRUNK_LINK_STATE_DN_LINKDN = 2,     /* physical link down */
+       BFA_TRUNK_LINK_STATE_DN_GRP_MIS = 3,    /* trunk group different */
+       BFA_TRUNK_LINK_STATE_DN_SPD_MIS = 4,    /* speed mismatch */
+       BFA_TRUNK_LINK_STATE_DN_MODE_MIS = 5,   /* remote port not trunked */
+};
+
+#define BFA_TRUNK_MAX_PORTS    2
+struct bfa_trunk_link_attr_s {
+       wwn_t    trunk_wwn;
+       enum bfa_trunk_link_fctl fctl;
+       enum bfa_trunk_link_state link_state;
+       enum bfa_port_speed     speed;
+       u32 deskew;
+};
+
+struct bfa_trunk_attr_s {
+       enum bfa_trunk_state    state;
+       enum bfa_port_speed     speed;
+       u32             port_id;
+       u32             rsvd;
+       struct bfa_trunk_link_attr_s link_attr[BFA_TRUNK_MAX_PORTS];
+};
+
+struct bfa_rport_hal_stats_s {
+       u32        sm_un_cr;        /*  uninit: create events      */
+       u32        sm_un_unexp;     /*  uninit: exception events   */
+       u32        sm_cr_on;        /*  created: online events     */
+       u32        sm_cr_del;       /*  created: delete events     */
+       u32        sm_cr_hwf;       /*  created: IOC down          */
+       u32        sm_cr_unexp;     /*  created: exception events  */
+       u32        sm_fwc_rsp;      /*  fw create: f/w responses   */
+       u32        sm_fwc_del;      /*  fw create: delete events   */
+       u32        sm_fwc_off;      /*  fw create: offline events  */
+       u32        sm_fwc_hwf;      /*  fw create: IOC down        */
+       u32        sm_fwc_unexp;            /*  fw create: exception events*/
+       u32        sm_on_off;       /*  online: offline events     */
+       u32        sm_on_del;       /*  online: delete events      */
+       u32        sm_on_hwf;       /*  online: IOC down events    */
+       u32        sm_on_unexp;     /*  online: exception events   */
+       u32        sm_fwd_rsp;      /*  fw delete: fw responses    */
+       u32        sm_fwd_del;      /*  fw delete: delete events   */
+       u32        sm_fwd_hwf;      /*  fw delete: IOC down events */
+       u32        sm_fwd_unexp;            /*  fw delete: exception events*/
+       u32        sm_off_del;      /*  offline: delete events     */
+       u32        sm_off_on;       /*  offline: online events     */
+       u32        sm_off_hwf;      /*  offline: IOC down events   */
+       u32        sm_off_unexp;            /*  offline: exception events  */
+       u32        sm_del_fwrsp;            /*  delete: fw responses       */
+       u32        sm_del_hwf;      /*  delete: IOC down events    */
+       u32        sm_del_unexp;            /*  delete: exception events   */
+       u32        sm_delp_fwrsp;           /*  delete pend: fw responses  */
+       u32        sm_delp_hwf;     /*  delete pend: IOC downs     */
+       u32        sm_delp_unexp;           /*  delete pend: exceptions    */
+       u32        sm_offp_fwrsp;           /*  off-pending: fw responses  */
+       u32        sm_offp_del;     /*  off-pending: deletes       */
+       u32        sm_offp_hwf;     /*  off-pending: IOC downs     */
+       u32        sm_offp_unexp;           /*  off-pending: exceptions    */
+       u32        sm_iocd_off;     /*  IOC down: offline events   */
+       u32        sm_iocd_del;     /*  IOC down: delete events    */
+       u32        sm_iocd_on;      /*  IOC down: online events    */
+       u32        sm_iocd_unexp;           /*  IOC down: exceptions       */
+       u32        rsvd;
+};
+#pragma pack(1)
+/**
+ *  Rport's QoS attributes
+ */
+struct bfa_rport_qos_attr_s {
+       u8                      qos_priority;  /*  rport's QoS priority   */
+       u8                      rsvd[3];
+       u32            qos_flow_id;       /*  QoS flow Id        */
+};
+#pragma pack()
+
+#define BFA_IOBUCKET_MAX 14
+
+struct bfa_itnim_latency_s {
+       u32 min[BFA_IOBUCKET_MAX];
+       u32 max[BFA_IOBUCKET_MAX];
+       u32 count[BFA_IOBUCKET_MAX];
+       u32 avg[BFA_IOBUCKET_MAX];
+};
+
+struct bfa_itnim_ioprofile_s {
+       u32 clock_res_mul;
+       u32 clock_res_div;
+       u32 index;
+       u32 io_profile_start_time;      /*  IO profile start time       */
+       u32 iocomps[BFA_IOBUCKET_MAX];  /*  IO completed        */
+       struct bfa_itnim_latency_s io_latency;
+};
+
+/**
+ * FC physical port statistics.
+ */
+struct bfa_port_fc_stats_s {
+       u64     secs_reset;     /*  Seconds since stats is reset */
+       u64     tx_frames;      /*  Tx frames                   */
+       u64     tx_words;       /*  Tx words                    */
+       u64     tx_lip;         /*  Tx LIP                      */
+       u64     tx_nos;         /*  Tx NOS                      */
+       u64     tx_ols;         /*  Tx OLS                      */
+       u64     tx_lr;          /*  Tx LR                       */
+       u64     tx_lrr;         /*  Tx LRR                      */
+       u64     rx_frames;      /*  Rx frames                   */
+       u64     rx_words;       /*  Rx words                    */
+       u64     lip_count;      /*  Rx LIP                      */
+       u64     nos_count;      /*  Rx NOS                      */
+       u64     ols_count;      /*  Rx OLS                      */
+       u64     lr_count;       /*  Rx LR                       */
+       u64     lrr_count;      /*  Rx LRR                      */
+       u64     invalid_crcs;   /*  Rx CRC err frames           */
+       u64     invalid_crc_gd_eof; /*  Rx CRC err good EOF frames */
+       u64     undersized_frm; /*  Rx undersized frames        */
+       u64     oversized_frm;  /*  Rx oversized frames */
+       u64     bad_eof_frm;    /*  Rx frames with bad EOF      */
+       u64     error_frames;   /*  Errored frames              */
+       u64     dropped_frames; /*  Dropped frames              */
+       u64     link_failures;  /*  Link Failure (LF) count     */
+       u64     loss_of_syncs;  /*  Loss of sync count          */
+       u64     loss_of_signals; /*  Loss of signal count       */
+       u64     primseq_errs;   /*  Primitive sequence protocol err. */
+       u64     bad_os_count;   /*  Invalid ordered sets        */
+       u64     err_enc_out;    /*  Encoding err nonframe_8b10b */
+       u64     err_enc;        /*  Encoding err frame_8b10b    */
+};
+
+/**
+ * Eth Physical Port statistics.
+ */
+struct bfa_port_eth_stats_s {
+       u64     secs_reset;     /*  Seconds since stats is reset */
+       u64     frame_64;       /*  Frames 64 bytes             */
+       u64     frame_65_127;   /*  Frames 65-127 bytes */
+       u64     frame_128_255;  /*  Frames 128-255 bytes        */
+       u64     frame_256_511;  /*  Frames 256-511 bytes        */
+       u64     frame_512_1023; /*  Frames 512-1023 bytes       */
+       u64     frame_1024_1518; /*  Frames 1024-1518 bytes     */
+       u64     frame_1519_1522; /*  Frames 1519-1522 bytes     */
+       u64     tx_bytes;       /*  Tx bytes                    */
+       u64     tx_packets;      /*  Tx packets         */
+       u64     tx_mcast_packets; /*  Tx multicast packets      */
+       u64     tx_bcast_packets; /*  Tx broadcast packets      */
+       u64     tx_control_frame; /*  Tx control frame          */
+       u64     tx_drop;        /*  Tx drops                    */
+       u64     tx_jabber;      /*  Tx jabber                   */
+       u64     tx_fcs_error;   /*  Tx FCS errors               */
+       u64     tx_fragments;   /*  Tx fragments                */
+       u64     rx_bytes;       /*  Rx bytes                    */
+       u64     rx_packets;     /*  Rx packets                  */
+       u64     rx_mcast_packets; /*  Rx multicast packets      */
+       u64     rx_bcast_packets; /*  Rx broadcast packets      */
+       u64     rx_control_frames; /*  Rx control frames        */
+       u64     rx_unknown_opcode; /*  Rx unknown opcode        */
+       u64     rx_drop;        /*  Rx drops                    */
+       u64     rx_jabber;      /*  Rx jabber                   */
+       u64     rx_fcs_error;   /*  Rx FCS errors               */
+       u64     rx_alignment_error; /*  Rx alignment errors     */
+       u64     rx_frame_length_error; /*  Rx frame len errors  */
+       u64     rx_code_error;  /*  Rx code errors              */
+       u64     rx_fragments;   /*  Rx fragments                */
+       u64     rx_pause;       /*  Rx pause                    */
+       u64     rx_zero_pause;  /*  Rx zero pause               */
+       u64     tx_pause;       /*  Tx pause                    */
+       u64     tx_zero_pause;  /*  Tx zero pause               */
+       u64     rx_fcoe_pause;  /*  Rx FCoE pause               */
+       u64     rx_fcoe_zero_pause; /*  Rx FCoE zero pause      */
+       u64     tx_fcoe_pause;  /*  Tx FCoE pause               */
+       u64     tx_fcoe_zero_pause; /*  Tx FCoE zero pause      */
+       u64     rx_iscsi_pause; /*  Rx iSCSI pause              */
+       u64     rx_iscsi_zero_pause; /*  Rx iSCSI zero pause    */
+       u64     tx_iscsi_pause; /*  Tx iSCSI pause              */
+       u64     tx_iscsi_zero_pause; /*  Tx iSCSI zero pause    */
+};
+
+/**
+ *              Port statistics.
+ */
+union bfa_port_stats_u {
+       struct bfa_port_fc_stats_s      fc;
+       struct bfa_port_eth_stats_s     eth;
+};
+
+#endif /* __BFA_DEFS_SVC_H__ */
similarity index 76%
rename from drivers/scsi/bfa/bfa_module.c
rename to drivers/scsi/bfa/bfa_drv.c
index a7fcc80..1412764 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
+ * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
  * All rights reserved
  * www.brocade.com
  *
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
  */
-#include <bfa.h>
-#include <defs/bfa_defs_pci.h>
-#include <cs/bfa_debug.h>
-#include <bfa_iocfc.h>
+
+#include "bfa_modules.h"
 
 /**
  * BFA module list terminated by NULL
@@ -30,9 +28,6 @@ struct bfa_module_s *hal_mods[] = {
        &hal_mod_uf,
        &hal_mod_rport,
        &hal_mod_fcpim,
-#ifdef BFA_CFG_PBIND
-       &hal_mod_pbind,
-#endif
        NULL
 };
 
@@ -74,17 +69,39 @@ bfa_isr_func_t  bfa_isrs[BFI_MC_MAX] = {
        bfa_isr_unhandled,      /* --------- */
 };
 
+
 /**
  * Message handlers for mailbox command classes
  */
 bfa_ioc_mbox_mcfunc_t  bfa_mbox_isrs[BFI_MC_MAX] = {
        NULL,
-       NULL,                   /* BFI_MC_IOC   */
-       NULL,                   /* BFI_MC_DIAG  */
+       NULL,                   /* BFI_MC_IOC   */
+       NULL,                   /* BFI_MC_DIAG  */
        NULL,           /* BFI_MC_FLASH */
-       NULL,                   /* BFI_MC_CEE   */
-       NULL,                   /* BFI_MC_PORT  */
+       NULL,                   /* BFI_MC_CEE   */
+       NULL,                   /* BFI_MC_PORT  */
        bfa_iocfc_isr,          /* BFI_MC_IOCFC */
        NULL,
 };
 
+
+
+void
+bfa_com_port_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi)
+{
+       struct bfa_port_s       *port = &bfa->modules.port;
+       u32             dm_len;
+       u8                      *dm_kva;
+       u64             dm_pa;
+
+       dm_len = bfa_port_meminfo();
+       dm_kva = bfa_meminfo_dma_virt(mi);
+       dm_pa  = bfa_meminfo_dma_phys(mi);
+
+       memset(port, 0, sizeof(struct bfa_port_s));
+       bfa_port_attach(port, &bfa->ioc, bfa, bfa->trcmod);
+       bfa_port_mem_claim(port, dm_kva, dm_pa);
+
+       bfa_meminfo_dma_virt(mi) = dm_kva + dm_len;
+       bfa_meminfo_dma_phys(mi) = dm_pa + dm_len;
+}
diff --git a/drivers/scsi/bfa/bfa_fc.h b/drivers/scsi/bfa/bfa_fc.h
new file mode 100644 (file)
index 0000000..6eff705
--- /dev/null
@@ -0,0 +1,1916 @@
+/*
+ * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
+ * All rights reserved
+ * www.brocade.com
+ *
+ * Linux driver for Brocade Fibre Channel Host Bus Adapter.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License (GPL) Version 2 as
+ * published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef __BFA_FC_H__
+#define __BFA_FC_H__
+
+#include "bfa_os_inc.h"
+
+typedef u64 wwn_t;
+typedef u64 lun_t;
+
+#define WWN_NULL       (0)
+#define FC_SYMNAME_MAX 256     /*  max name server symbolic name size */
+#define FC_ALPA_MAX    128
+
+#pragma pack(1)
+
+#define MAC_ADDRLEN    (6)
+struct mac_s { u8 mac[MAC_ADDRLEN]; };
+#define mac_t struct mac_s
+
+/*
+ * generic SCSI cdb definition
+ */
+#define SCSI_MAX_CDBLEN     16
+struct scsi_cdb_s {
+       u8         scsi_cdb[SCSI_MAX_CDBLEN];
+};
+#define scsi_cdb_t struct scsi_cdb_s
+
+/* ------------------------------------------------------------
+ * SCSI status byte values
+ * ------------------------------------------------------------
+ */
+#define SCSI_STATUS_GOOD                   0x00
+#define SCSI_STATUS_CHECK_CONDITION        0x02
+#define SCSI_STATUS_CONDITION_MET          0x04
+#define SCSI_STATUS_BUSY                   0x08
+#define SCSI_STATUS_INTERMEDIATE           0x10
+#define SCSI_STATUS_ICM                    0x14 /* intermediate condition met */
+#define SCSI_STATUS_RESERVATION_CONFLICT   0x18
+#define SCSI_STATUS_COMMAND_TERMINATED     0x22
+#define SCSI_STATUS_QUEUE_FULL             0x28
+#define SCSI_STATUS_ACA_ACTIVE             0x30
+
+#define SCSI_MAX_ALLOC_LEN      0xFF    /* maximum allocarion length */
+
+/*
+ * Fibre Channel Header Structure (FCHS) definition
+ */
+struct fchs_s {
+#ifdef __BIGENDIAN
+       u32        routing:4;   /* routing bits */
+       u32        cat_info:4;  /* category info */
+#else
+       u32        cat_info:4;  /* category info */
+       u32        routing:4;   /* routing bits */
+#endif
+       u32        d_id:24;     /* destination identifier */
+
+       u32        cs_ctl:8;    /* class specific control */
+       u32        s_id:24;     /* source identifier */
+
+       u32        type:8;              /* data structure type */
+       u32        f_ctl:24;    /* initial frame control */
+
+       u8         seq_id;              /* sequence identifier */
+       u8         df_ctl;              /* data field control */
+       u16        seq_cnt;     /* sequence count */
+
+       u16        ox_id;               /* originator exchange ID */
+       u16        rx_id;               /* responder exchange ID */
+
+       u32        ro;          /* relative offset */
+};
+
+#define FC_SOF_LEN             4
+#define FC_EOF_LEN             4
+#define FC_CRC_LEN             4
+
+/*
+ * Fibre Channel BB_E Header Structure
+ */
+struct fcbbehs_s {
+       u16     ver_rsvd;
+       u32     rsvd[2];
+       u32     rsvd__sof;
+};
+
+#define FC_SEQ_ID_MAX          256
+
+/*
+ * routing bit definitions
+ */
+enum {
+       FC_RTG_FC4_DEV_DATA     = 0x0,  /* FC-4 Device Data */
+       FC_RTG_EXT_LINK         = 0x2,  /* Extended Link Data */
+       FC_RTG_FC4_LINK_DATA    = 0x3,  /* FC-4 Link Data */
+       FC_RTG_VIDEO_DATA       = 0x4,  /* Video Data */
+       FC_RTG_EXT_HDR          = 0x5,  /* VFT, IFR or Encapsuled */
+       FC_RTG_BASIC_LINK       = 0x8,  /* Basic Link data */
+       FC_RTG_LINK_CTRL        = 0xC,  /* Link Control */
+};
+
+/*
+ * information category for extended link data and FC-4 Link Data
+ */
+enum {
+       FC_CAT_LD_REQUEST       = 0x2,  /* Request */
+       FC_CAT_LD_REPLY         = 0x3,  /* Reply */
+       FC_CAT_LD_DIAG          = 0xF,  /* for DIAG use only */
+};
+
+/*
+ * information category for extended headers (VFT, IFR or encapsulation)
+ */
+enum {
+       FC_CAT_VFT_HDR = 0x0,   /* Virtual fabric tagging header */
+       FC_CAT_IFR_HDR = 0x1,   /* Inter-Fabric routing header */
+       FC_CAT_ENC_HDR = 0x2,   /* Encapsulation header */
+};
+
+/*
+ * information category for FC-4 device data
+ */
+enum {
+       FC_CAT_UNCATEG_INFO     = 0x0,  /* Uncategorized information */
+       FC_CAT_SOLICIT_DATA     = 0x1,  /* Solicited Data */
+       FC_CAT_UNSOLICIT_CTRL   = 0x2,  /* Unsolicited Control */
+       FC_CAT_SOLICIT_CTRL     = 0x3,  /* Solicited Control */
+       FC_CAT_UNSOLICIT_DATA   = 0x4,  /* Unsolicited Data */
+       FC_CAT_DATA_DESC        = 0x5,  /* Data Descriptor */
+       FC_CAT_UNSOLICIT_CMD    = 0x6,  /* Unsolicited Command */
+       FC_CAT_CMD_STATUS       = 0x7,  /* Command Status */
+};
+
+/*
+ * information category for Link Control
+ */
+enum {
+       FC_CAT_ACK_1            = 0x00,
+       FC_CAT_ACK_0_N          = 0x01,
+       FC_CAT_P_RJT            = 0x02,
+       FC_CAT_F_RJT            = 0x03,
+       FC_CAT_P_BSY            = 0x04,
+       FC_CAT_F_BSY_DATA       = 0x05,
+       FC_CAT_F_BSY_LINK_CTL   = 0x06,
+       FC_CAT_F_LCR            = 0x07,
+       FC_CAT_NTY              = 0x08,
+       FC_CAT_END              = 0x09,
+};
+
+/*
+ * Type Field Definitions. FC-PH Section 18.5 pg. 165
+ */
+enum {
+       FC_TYPE_BLS             = 0x0,  /* Basic Link Service */
+       FC_TYPE_ELS             = 0x1,  /* Extended Link Service */
+       FC_TYPE_IP              = 0x5,  /* IP */
+       FC_TYPE_FCP             = 0x8,  /* SCSI-FCP */
+       FC_TYPE_GPP             = 0x9,  /* SCSI_GPP */
+       FC_TYPE_SERVICES        = 0x20, /* Fibre Channel Services */
+       FC_TYPE_FC_FSS          = 0x22, /* Fabric Switch Services */
+       FC_TYPE_FC_AL           = 0x23, /* FC-AL */
+       FC_TYPE_FC_SNMP         = 0x24, /* FC-SNMP */
+       FC_TYPE_FC_SPINFAB      = 0xEE, /* SPINFAB */
+       FC_TYPE_FC_DIAG         = 0xEF, /* DIAG */
+       FC_TYPE_MAX             = 256,  /* 256 FC-4 types */
+};
+
+struct fc_fc4types_s {
+       u8         bits[FC_TYPE_MAX / 8];
+};
+
+/*
+ * Frame Control Definitions. FC-PH Table-45. pg. 168
+ */
+enum {
+       FCTL_EC_ORIG = 0x000000,        /* exchange originator */
+       FCTL_EC_RESP = 0x800000,        /* exchange responder */
+       FCTL_SEQ_INI = 0x000000,        /* sequence initiator */
+       FCTL_SEQ_REC = 0x400000,        /* sequence recipient */
+       FCTL_FS_EXCH = 0x200000,        /* first sequence of xchg */
+       FCTL_LS_EXCH = 0x100000,        /* last sequence of xchg */
+       FCTL_END_SEQ = 0x080000,        /* last frame of sequence */
+       FCTL_SI_XFER = 0x010000,        /* seq initiative transfer */
+       FCTL_RO_PRESENT = 0x000008,     /* relative offset present */
+       FCTL_FILLBYTE_MASK = 0x000003   /* , fill byte mask */
+};
+
+/*
+ * Fabric Well Known Addresses
+ */
+enum {
+       FC_MIN_WELL_KNOWN_ADDR          = 0xFFFFF0,
+       FC_DOMAIN_CONTROLLER_MASK       = 0xFFFC00,
+       FC_ALIAS_SERVER                 = 0xFFFFF8,
+       FC_MGMT_SERVER                  = 0xFFFFFA,
+       FC_TIME_SERVER                  = 0xFFFFFB,
+       FC_NAME_SERVER                  = 0xFFFFFC,
+       FC_FABRIC_CONTROLLER            = 0xFFFFFD,
+       FC_FABRIC_PORT                  = 0xFFFFFE,
+       FC_BROADCAST_SERVER             = 0xFFFFFF
+};
+
+/*
+ * domain/area/port defines
+ */
+#define FC_DOMAIN_MASK  0xFF0000
+#define FC_DOMAIN_SHIFT 16
+#define FC_AREA_MASK    0x00FF00
+#define FC_AREA_SHIFT   8
+#define FC_PORT_MASK    0x0000FF
+#define FC_PORT_SHIFT   0
+
+#define FC_GET_DOMAIN(p)       (((p) & FC_DOMAIN_MASK) >> FC_DOMAIN_SHIFT)
+#define FC_GET_AREA(p)         (((p) & FC_AREA_MASK) >> FC_AREA_SHIFT)
+#define FC_GET_PORT(p)         (((p) & FC_PORT_MASK) >> FC_PORT_SHIFT)
+
+#define FC_DOMAIN_CTRLR(p)     (FC_DOMAIN_CONTROLLER_MASK | (FC_GET_DOMAIN(p)))
+
+enum {
+       FC_RXID_ANY = 0xFFFFU,
+};
+
+/*
+ * generic ELS command
+ */
+struct fc_els_cmd_s {
+       u32        els_code:8;  /* ELS Command Code */
+       u32        reserved:24;
+};
+
+/*
+ * ELS Command Codes. FC-PH Table-75. pg. 223
+ */
+enum {
+       FC_ELS_LS_RJT = 0x1,    /* Link Service Reject. */
+       FC_ELS_ACC = 0x02,      /* Accept */
+       FC_ELS_PLOGI = 0x03,    /* N_Port Login. */
+       FC_ELS_FLOGI = 0x04,    /* F_Port Login. */
+       FC_ELS_LOGO = 0x05,     /* Logout. */
+       FC_ELS_ABTX = 0x06,     /* Abort Exchange */
+       FC_ELS_RES = 0x08,      /* Read Exchange status */
+       FC_ELS_RSS = 0x09,      /* Read sequence status block */
+       FC_ELS_RSI = 0x0A,      /* Request Sequence Initiative */
+       FC_ELS_ESTC = 0x0C,     /* Estimate Credit. */
+       FC_ELS_RTV = 0x0E,      /* Read Timeout Value. */
+       FC_ELS_RLS = 0x0F,      /* Read Link Status. */
+       FC_ELS_ECHO = 0x10,     /* Echo */
+       FC_ELS_TEST = 0x11,     /* Test */
+       FC_ELS_RRQ = 0x12,      /* Reinstate Recovery Qualifier. */
+       FC_ELS_REC = 0x13,      /* Add this for TAPE support in FCR */
+       FC_ELS_PRLI = 0x20,     /* Process Login */
+       FC_ELS_PRLO = 0x21,     /* Process Logout. */
+       FC_ELS_SCN = 0x22,      /* State Change Notification. */
+       FC_ELS_TPRLO = 0x24,    /* Third Party Process Logout. */
+       FC_ELS_PDISC = 0x50,    /* Discover N_Port Parameters. */
+       FC_ELS_FDISC = 0x51,    /* Discover F_Port Parameters. */
+       FC_ELS_ADISC = 0x52,    /* Discover Address. */
+       FC_ELS_FARP_REQ = 0x54, /* FARP Request. */
+       FC_ELS_FARP_REP = 0x55, /* FARP Reply. */
+       FC_ELS_FAN = 0x60,      /* Fabric Address Notification */
+       FC_ELS_RSCN = 0x61,     /* Reg State Change Notification */
+       FC_ELS_SCR = 0x62,      /* State Change Registration. */
+       FC_ELS_RTIN = 0x77,     /* Mangement server request */
+       FC_ELS_RNID = 0x78,     /* Mangement server request */
+       FC_ELS_RLIR = 0x79,     /* Registered Link Incident Record */
+
+       FC_ELS_RPSC = 0x7D,     /* Report Port Speed Capabilities */
+       FC_ELS_QSA = 0x7E,      /* Query Security Attributes. Ref FC-SP */
+       FC_ELS_E2E_LBEACON = 0x81,
+                               /* End-to-End Link Beacon */
+       FC_ELS_AUTH = 0x90,     /* Authentication. Ref FC-SP */
+       FC_ELS_RFCN = 0x97,     /* Request Fabric Change Notification. Ref
+                                *FC-SP */
+
+};
+
+/*
+ *  Version numbers for FC-PH standards,
+ *  used in login to indicate what port
+ *  supports. See FC-PH-X table 158.
+ */
+enum {
+       FC_PH_VER_4_3 = 0x09,
+       FC_PH_VER_PH_3 = 0x20,
+};
+
+/*
+ * PDU size defines
+ */
+enum {
+       FC_MIN_PDUSZ = 512,
+       FC_MAX_PDUSZ = 2112,
+};
+
+/*
+ * N_Port PLOGI Common Service Parameters.
+ * FC-PH-x. Figure-76. pg. 308.
+ */
+struct fc_plogi_csp_s {
+       u8         verhi;       /* FC-PH high version */
+       u8         verlo;       /* FC-PH low version */
+       u16        bbcred;      /* BB_Credit */
+
+#ifdef __BIGENDIAN
+       u8         ciro:1,              /* continuously increasing RO */
+                       rro:1,          /* random relative offset */
+                       npiv_supp:1,    /* NPIV supported */
+                       port_type:1,    /* N_Port/F_port */
+                       altbbcred:1,    /* alternate BB_Credit */
+                       resolution:1,   /* ms/ns ED_TOV resolution */
+                       vvl_info:1,     /* VVL Info included */
+                       reserved1:1;
+
+       u8         hg_supp:1,
+                       query_dbc:1,
+                       security:1,
+                       sync_cap:1,
+                       r_t_tov:1,
+                       dh_dup_supp:1,
+                       cisc:1,         /* continuously increasing seq count */
+                       payload:1;
+#else
+       u8         reserved2:2,
+                       resolution:1,   /* ms/ns ED_TOV resolution */
+                       altbbcred:1,    /* alternate BB_Credit */
+                       port_type:1,    /* N_Port/F_port */
+                       npiv_supp:1,    /* NPIV supported */
+                       rro:1,          /* random relative offset */
+                       ciro:1;         /* continuously increasing RO */
+
+       u8         payload:1,
+                       cisc:1,         /* continuously increasing seq count */
+                       dh_dup_supp:1,
+                       r_t_tov:1,
+                       sync_cap:1,
+                       security:1,
+                       query_dbc:1,
+                       hg_supp:1;
+#endif
+
+       u16        rxsz;                /* recieve data_field size */
+
+       u16        conseq;
+       u16        ro_bitmap;
+
+       u32        e_d_tov;
+};
+
+/*
+ * N_Port PLOGI Class Specific Parameters.
+ * FC-PH-x. Figure 78. pg. 318.
+ */
+struct fc_plogi_clp_s {
+#ifdef __BIGENDIAN
+       u32        class_valid:1;
+       u32        intermix:1;  /* class intermix supported if set =1.
+                                        * valid only for class1. Reserved for
+                                        * class2 & class3
+                                        */
+       u32        reserved1:2;
+       u32        sequential:1;
+       u32        reserved2:3;
+#else
+       u32        reserved2:3;
+       u32        sequential:1;
+       u32        reserved1:2;
+       u32        intermix:1;  /* class intermix supported if set =1.
+                                        * valid only for class1. Reserved for
+                                        * class2 & class3
+                                        */
+       u32        class_valid:1;
+#endif
+
+       u32        reserved3:24;
+
+       u32        reserved4:16;
+       u32        rxsz:16;     /* Receive data_field size */
+
+       u32        reserved5:8;
+       u32        conseq:8;
+       u32        e2e_credit:16;       /* end to end credit */
+
+       u32        reserved7:8;
+       u32        ospx:8;
+       u32        reserved8:16;
+};
+
+/* ASCII value for each character in string "BRCD" */
+#define FLOGI_VVL_BRCD    0x42524344
+
+/*
+ * PLOGI els command and reply payload
+ */
+struct fc_logi_s {
+       struct fc_els_cmd_s els_cmd;    /* ELS command code */
+       struct fc_plogi_csp_s csp;              /* common service params */
+       wwn_t           port_name;
+       wwn_t           node_name;
+       struct fc_plogi_clp_s class1;           /* class 1 service parameters */
+       struct fc_plogi_clp_s class2;           /* class 2 service parameters */
+       struct fc_plogi_clp_s class3;           /* class 3 service parameters */
+       struct fc_plogi_clp_s class4;           /* class 4 service parameters */
+       u8         vvl[16];     /* vendor version level */
+};
+
+/*
+ * LOGO els command payload
+ */
+struct fc_logo_s {
+       struct fc_els_cmd_s els_cmd;    /* ELS command code */
+       u32        res1:8;
+       u32        nport_id:24; /* N_Port identifier of source */
+       wwn_t           orig_port_name; /* Port name of the LOGO originator */
+};
+
+/*
+ * ADISC els command payload
+ */
+struct fc_adisc_s {
+       struct fc_els_cmd_s els_cmd;    /* ELS command code */
+       u32        res1:8;
+       u32        orig_HA:24;  /* originator hard address */
+       wwn_t           orig_port_name; /* originator port name */
+       wwn_t           orig_node_name; /* originator node name */
+       u32        res2:8;
+       u32        nport_id:24; /* originator NPortID */
+};
+
+/*
+ * Exchange status block
+ */
+struct fc_exch_status_blk_s {
+       u32        oxid:16;
+       u32        rxid:16;
+       u32        res1:8;
+       u32        orig_np:24;  /* originator NPortID */
+       u32        res2:8;
+       u32        resp_np:24;  /* responder NPortID */
+       u32        es_bits;
+       u32        res3;
+       /*
+        * un modified section of the fields
+        */
+};
+
+/*
+ * RES els command payload
+ */
+struct fc_res_s {
+       struct fc_els_cmd_s els_cmd;    /* ELS command code */
+       u32        res1:8;
+       u32        nport_id:24; /* N_Port identifier of source */
+       u32        oxid:16;
+       u32        rxid:16;
+       u8         assoc_hdr[32];
+};
+
+/*
+ * RES els accept payload
+ */
+struct fc_res_acc_s {
+       struct fc_els_cmd_s             els_cmd;        /* ELS command code */
+       struct fc_exch_status_blk_s     fc_exch_blk; /* Exchange status block */
+};
+
+/*
+ * REC els command payload
+ */
+struct fc_rec_s {
+       struct fc_els_cmd_s els_cmd;    /* ELS command code */
+       u32        res1:8;
+       u32        nport_id:24; /* N_Port identifier of source */
+       u32        oxid:16;
+       u32        rxid:16;
+};
+
+#define FC_REC_ESB_OWN_RSP     0x80000000      /* responder owns */
+#define FC_REC_ESB_SI          0x40000000      /* SI is owned  */
+#define FC_REC_ESB_COMP                0x20000000      /* exchange is complete */
+#define FC_REC_ESB_ENDCOND_ABN 0x10000000      /* abnormal ending      */
+#define FC_REC_ESB_RQACT       0x04000000      /* recovery qual active */
+#define FC_REC_ESB_ERRP_MSK    0x03000000
+#define FC_REC_ESB_OXID_INV    0x00800000      /* invalid OXID         */
+#define FC_REC_ESB_RXID_INV    0x00400000      /* invalid RXID         */
+#define FC_REC_ESB_PRIO_INUSE  0x00200000
+
+/*
+ * REC els accept payload
+ */
+struct fc_rec_acc_s {
+       struct fc_els_cmd_s els_cmd;    /* ELS command code */
+       u32        oxid:16;
+       u32        rxid:16;
+       u32        res1:8;
+       u32        orig_id:24;  /* N_Port id of exchange originator */
+       u32        res2:8;
+       u32        resp_id:24;  /* N_Port id of exchange responder */
+       u32        count;               /* data transfer count */
+       u32        e_stat;              /* exchange status */
+};
+
+/*
+ * RSI els payload
+ */
+struct fc_rsi_s {
+       struct fc_els_cmd_s els_cmd;
+       u32        res1:8;
+       u32        orig_sid:24;
+       u32        oxid:16;
+       u32        rxid:16;
+};
+
+/*
+ * structure for PRLI paramater pages, both request & response
+ * see FC-PH-X table 113 & 115 for explanation also FCP table 8
+ */
+struct fc_prli_params_s {
+       u32        reserved:16;
+#ifdef __BIGENDIAN
+       u32        reserved1:5;
+       u32        rec_support:1;
+       u32        task_retry_id:1;
+       u32        retry:1;
+
+       u32        confirm:1;
+       u32        doverlay:1;
+       u32        initiator:1;
+       u32        target:1;
+       u32        cdmix:1;
+       u32        drmix:1;
+       u32        rxrdisab:1;
+       u32        wxrdisab:1;
+#else
+       u32        retry:1;
+       u32        task_retry_id:1;
+       u32        rec_support:1;
+       u32        reserved1:5;
+
+       u32        wxrdisab:1;
+       u32        rxrdisab:1;
+       u32        drmix:1;
+       u32        cdmix:1;
+       u32        target:1;
+       u32        initiator:1;
+       u32        doverlay:1;
+       u32        confirm:1;
+#endif
+};
+
+/*
+ * valid values for rspcode in PRLI ACC payload
+ */
+enum {
+       FC_PRLI_ACC_XQTD = 0x1,         /* request executed */
+       FC_PRLI_ACC_PREDEF_IMG = 0x5,   /* predefined image - no prli needed */
+};
+
+struct fc_prli_params_page_s {
+       u32        type:8;
+       u32        codext:8;
+#ifdef __BIGENDIAN
+       u32        origprocasv:1;
+       u32        rsppav:1;
+       u32        imagepair:1;
+       u32        reserved1:1;
+       u32        rspcode:4;
+#else
+       u32        rspcode:4;
+       u32        reserved1:1;
+       u32        imagepair:1;
+       u32        rsppav:1;
+       u32        origprocasv:1;
+#endif
+       u32        reserved2:8;
+
+       u32        origprocas;
+       u32        rspprocas;
+       struct fc_prli_params_s servparams;
+};
+
+/*
+ * PRLI request and accept payload, FC-PH-X tables 112 & 114
+ */
+struct fc_prli_s {
+       u32        command:8;
+       u32        pglen:8;
+       u32        pagebytes:16;
+       struct fc_prli_params_page_s parampage;
+};
+
+/*
+ * PRLO logout params page
+ */
+struct fc_prlo_params_page_s {
+       u32        type:8;
+       u32        type_ext:8;
+#ifdef __BIGENDIAN
+       u32        opa_valid:1; /* originator process associator
+                                        * valid
+                                        */
+       u32        rpa_valid:1; /* responder process associator valid */
+       u32        res1:14;
+#else
+       u32        res1:14;
+       u32        rpa_valid:1; /* responder process associator valid */
+       u32        opa_valid:1; /* originator process associator
+                                        * valid
+                                        */
+#endif
+       u32        orig_process_assc;
+       u32        resp_process_assc;
+
+       u32        res2;
+};
+
+/*
+ * PRLO els command payload
+ */
+struct fc_prlo_s {
+       u32     command:8;
+       u32     page_len:8;
+       u32     payload_len:16;
+       struct fc_prlo_params_page_s    prlo_params[1];
+};
+
+/*
+ * PRLO Logout response parameter page
+ */
+struct fc_prlo_acc_params_page_s {
+       u32        type:8;
+       u32        type_ext:8;
+
+#ifdef __BIGENDIAN
+       u32        opa_valid:1; /* originator process associator
+                                        * valid
+                                        */
+       u32        rpa_valid:1; /* responder process associator valid */
+       u32        res1:14;
+#else
+       u32        res1:14;
+       u32        rpa_valid:1; /* responder process associator valid */
+       u32        opa_valid:1; /* originator process associator
+                                        * valid
+                                        */
+#endif
+       u32        orig_process_assc;
+       u32        resp_process_assc;
+
+       u32        fc4type_csp;
+};
+
+/*
+ * PRLO els command ACC payload
+ */
+struct fc_prlo_acc_s {
+       u32        command:8;
+       u32        page_len:8;
+       u32        payload_len:16;
+       struct fc_prlo_acc_params_page_s prlo_acc_params[1];
+};
+
+/*
+ * SCR els command payload
+ */
+enum {
+       FC_SCR_REG_FUNC_FABRIC_DETECTED = 0x01,
+       FC_SCR_REG_FUNC_N_PORT_DETECTED = 0x02,
+       FC_SCR_REG_FUNC_FULL = 0x03,
+       FC_SCR_REG_FUNC_CLEAR_REG = 0xFF,
+};
+
+/* SCR VU registrations */
+enum {
+       FC_VU_SCR_REG_FUNC_FABRIC_NAME_CHANGE = 0x01
+};
+
+struct fc_scr_s {
+       u32 command:8;
+       u32 res:24;
+       u32 vu_reg_func:8; /* Vendor Unique Registrations */
+       u32 res1:16;
+       u32 reg_func:8;
+};
+
+/*
+ * Information category for Basic link data
+ */
+enum {
+       FC_CAT_NOP      = 0x0,
+       FC_CAT_ABTS     = 0x1,
+       FC_CAT_RMC      = 0x2,
+       FC_CAT_BA_ACC   = 0x4,
+       FC_CAT_BA_RJT   = 0x5,
+       FC_CAT_PRMT     = 0x6,
+};
+
+/*
+ * LS_RJT els reply payload
+ */
+struct fc_ls_rjt_s {
+       struct fc_els_cmd_s els_cmd;            /* ELS command code */
+       u32        res1:8;
+       u32        reason_code:8;               /* Reason code for reject */
+       u32        reason_code_expl:8;  /* Reason code explanation */
+       u32        vendor_unique:8;     /* Vendor specific */
+};
+
+/*
+ * LS_RJT reason codes
+ */
+enum {
+       FC_LS_RJT_RSN_INV_CMD_CODE      = 0x01,
+       FC_LS_RJT_RSN_LOGICAL_ERROR     = 0x03,
+       FC_LS_RJT_RSN_LOGICAL_BUSY      = 0x05,
+       FC_LS_RJT_RSN_PROTOCOL_ERROR    = 0x07,
+       FC_LS_RJT_RSN_UNABLE_TO_PERF_CMD = 0x09,
+       FC_LS_RJT_RSN_CMD_NOT_SUPP      = 0x0B,
+};
+
+/*
+ * LS_RJT reason code explanation
+ */
+enum {
+       FC_LS_RJT_EXP_NO_ADDL_INFO              = 0x00,
+       FC_LS_RJT_EXP_SPARMS_ERR_OPTIONS        = 0x01,
+       FC_LS_RJT_EXP_SPARMS_ERR_INI_CTL        = 0x03,
+       FC_LS_RJT_EXP_SPARMS_ERR_REC_CTL        = 0x05,
+       FC_LS_RJT_EXP_SPARMS_ERR_RXSZ           = 0x07,
+       FC_LS_RJT_EXP_SPARMS_ERR_CONSEQ         = 0x09,
+       FC_LS_RJT_EXP_SPARMS_ERR_CREDIT         = 0x0B,
+       FC_LS_RJT_EXP_INV_PORT_NAME             = 0x0D,
+       FC_LS_RJT_EXP_INV_NODE_FABRIC_NAME      = 0x0E,
+       FC_LS_RJT_EXP_INV_CSP                   = 0x0F,
+       FC_LS_RJT_EXP_INV_ASSOC_HDR             = 0x11,
+       FC_LS_RJT_EXP_ASSOC_HDR_REQD            = 0x13,
+       FC_LS_RJT_EXP_INV_ORIG_S_ID             = 0x15,
+       FC_LS_RJT_EXP_INV_OXID_RXID_COMB        = 0x17,
+       FC_LS_RJT_EXP_CMD_ALREADY_IN_PROG       = 0x19,
+       FC_LS_RJT_EXP_LOGIN_REQUIRED            = 0x1E,
+       FC_LS_RJT_EXP_INVALID_NPORT_ID          = 0x1F,
+       FC_LS_RJT_EXP_INSUFF_RES                = 0x29,
+       FC_LS_RJT_EXP_CMD_NOT_SUPP              = 0x2C,
+       FC_LS_RJT_EXP_INV_PAYLOAD_LEN           = 0x2D,
+};
+
+/*
+ * RRQ els command payload
+ */
+struct fc_rrq_s {
+       struct fc_els_cmd_s els_cmd;    /* ELS command code */
+       u32        res1:8;
+       u32        s_id:24;     /* exchange originator S_ID */
+
+       u32        ox_id:16;    /* originator exchange ID */
+       u32        rx_id:16;    /* responder exchange ID */
+
+       u32        res2[8];     /* optional association header */
+};
+
+/*
+ * ABTS BA_ACC reply payload
+ */
+struct fc_ba_acc_s {
+       u32        seq_id_valid:8;      /* set to 0x00 for Abort Exchange */
+       u32        seq_id:8;    /* invalid for Abort Exchange */
+       u32        res2:16;
+       u32        ox_id:16;    /* OX_ID from ABTS frame */
+       u32        rx_id:16;    /* RX_ID from ABTS frame */
+       u32        low_seq_cnt:16;      /* set to 0x0000 for Abort Exchange */
+       u32        high_seq_cnt:16;/* set to 0xFFFF for Abort Exchange */
+};
+
+/*
+ * ABTS BA_RJT reject payload
+ */
+struct fc_ba_rjt_s {
+       u32        res1:8;              /* Reserved */
+       u32        reason_code:8;       /* reason code for reject */
+       u32        reason_expl:8;       /* reason code explanation */
+       u32        vendor_unique:8;/* vendor unique reason code,set to 0 */
+};
+
+/*
+ * TPRLO logout parameter page
+ */
+struct fc_tprlo_params_page_s {
+u32        type:8;
+u32        type_ext:8;
+
+#ifdef __BIGENDIAN
+       u32        opa_valid:1;
+       u32        rpa_valid:1;
+       u32        tpo_nport_valid:1;
+       u32        global_process_logout:1;
+       u32        res1:12;
+#else
+       u32        res1:12;
+       u32        global_process_logout:1;
+       u32        tpo_nport_valid:1;
+       u32        rpa_valid:1;
+       u32        opa_valid:1;
+#endif
+
+       u32        orig_process_assc;
+       u32        resp_process_assc;
+
+       u32        res2:8;
+       u32        tpo_nport_id;
+};
+
+/*
+ * TPRLO ELS command payload
+ */
+struct fc_tprlo_s {
+       u32        command:8;
+       u32        page_len:8;
+       u32        payload_len:16;
+
+       struct fc_tprlo_params_page_s tprlo_params[1];
+};
+
+enum fc_tprlo_type {
+       FC_GLOBAL_LOGO = 1,
+       FC_TPR_LOGO
+};
+
+/*
+ * TPRLO els command ACC payload
+ */
+struct fc_tprlo_acc_s {
+       u32     command:8;
+       u32     page_len:8;
+       u32     payload_len:16;
+       struct fc_prlo_acc_params_page_s tprlo_acc_params[1];
+};
+
+/*
+ * RSCN els command req payload
+ */
+#define FC_RSCN_PGLEN  0x4
+
+enum fc_rscn_format {
+       FC_RSCN_FORMAT_PORTID   = 0x0,
+       FC_RSCN_FORMAT_AREA     = 0x1,
+       FC_RSCN_FORMAT_DOMAIN   = 0x2,
+       FC_RSCN_FORMAT_FABRIC   = 0x3,
+};
+
+struct fc_rscn_event_s {
+       u32        format:2;
+       u32        qualifier:4;
+       u32        resvd:2;
+       u32        portid:24;
+};
+
+struct fc_rscn_pl_s {
+       u8         command;
+       u8         pagelen;
+       u16        payldlen;
+       struct fc_rscn_event_s event[1];
+};
+
+/*
+ * ECHO els command req payload
+ */
+struct fc_echo_s {
+       struct fc_els_cmd_s els_cmd;
+};
+
+/*
+ * RNID els command
+ */
+
+#define RNID_NODEID_DATA_FORMAT_COMMON                 0x00
+#define RNID_NODEID_DATA_FORMAT_FCP3                   0x08
+#define RNID_NODEID_DATA_FORMAT_DISCOVERY              0xDF
+
+#define RNID_ASSOCIATED_TYPE_UNKNOWN                   0x00000001
+#define RNID_ASSOCIATED_TYPE_OTHER                      0x00000002
+#define RNID_ASSOCIATED_TYPE_HUB                        0x00000003
+#define RNID_ASSOCIATED_TYPE_SWITCH                     0x00000004
+#define RNID_ASSOCIATED_TYPE_GATEWAY                    0x00000005
+#define RNID_ASSOCIATED_TYPE_STORAGE_DEVICE             0x00000009
+#define RNID_ASSOCIATED_TYPE_HOST                       0x0000000A
+#define RNID_ASSOCIATED_TYPE_STORAGE_SUBSYSTEM          0x0000000B
+#define RNID_ASSOCIATED_TYPE_STORAGE_ACCESS_DEVICE      0x0000000E
+#define RNID_ASSOCIATED_TYPE_NAS_SERVER                 0x00000011
+#define RNID_ASSOCIATED_TYPE_BRIDGE                     0x00000002
+#define RNID_ASSOCIATED_TYPE_VIRTUALIZATION_DEVICE      0x00000003
+#define RNID_ASSOCIATED_TYPE_MULTI_FUNCTION_DEVICE      0x000000FF
+
+/*
+ * RNID els command payload
+ */
+struct fc_rnid_cmd_s {
+       struct fc_els_cmd_s els_cmd;
+       u32        node_id_data_format:8;
+       u32        reserved:24;
+};
+
+/*
+ * RNID els response payload
+ */
+
+struct fc_rnid_common_id_data_s {
+       wwn_t           port_name;
+       wwn_t           node_name;
+};
+
+struct fc_rnid_general_topology_data_s {
+       u32        vendor_unique[4];
+       u32        asso_type;
+       u32        phy_port_num;
+       u32        num_attached_nodes;
+       u32        node_mgmt:8;
+       u32        ip_version:8;
+       u32        udp_tcp_port_num:16;
+       u32        ip_address[4];
+       u32        reserved:16;
+       u32        vendor_specific:16;
+};
+
+struct fc_rnid_acc_s {
+       struct fc_els_cmd_s els_cmd;
+       u32        node_id_data_format:8;
+       u32        common_id_data_length:8;
+       u32        reserved:8;
+       u32        specific_id_data_length:8;
+       struct fc_rnid_common_id_data_s common_id_data;
+       struct fc_rnid_general_topology_data_s gen_topology_data;
+};
+
+#define RNID_ASSOCIATED_TYPE_UNKNOWN                    0x00000001
+#define RNID_ASSOCIATED_TYPE_OTHER                      0x00000002
+#define RNID_ASSOCIATED_TYPE_HUB                        0x00000003
+#define RNID_ASSOCIATED_TYPE_SWITCH                     0x00000004
+#define RNID_ASSOCIATED_TYPE_GATEWAY                    0x00000005
+#define RNID_ASSOCIATED_TYPE_STORAGE_DEVICE             0x00000009
+#define RNID_ASSOCIATED_TYPE_HOST                       0x0000000A
+#define RNID_ASSOCIATED_TYPE_STORAGE_SUBSYSTEM          0x0000000B
+#define RNID_ASSOCIATED_TYPE_STORAGE_ACCESS_DEVICE      0x0000000E
+#define RNID_ASSOCIATED_TYPE_NAS_SERVER                 0x00000011
+#define RNID_ASSOCIATED_TYPE_BRIDGE                     0x00000002
+#define RNID_ASSOCIATED_TYPE_VIRTUALIZATION_DEVICE      0x00000003
+#define RNID_ASSOCIATED_TYPE_MULTI_FUNCTION_DEVICE      0x000000FF
+
+enum fc_rpsc_speed_cap {
+       RPSC_SPEED_CAP_1G = 0x8000,
+       RPSC_SPEED_CAP_2G = 0x4000,
+       RPSC_SPEED_CAP_4G = 0x2000,
+       RPSC_SPEED_CAP_10G = 0x1000,
+       RPSC_SPEED_CAP_8G = 0x0800,
+       RPSC_SPEED_CAP_16G = 0x0400,
+
+       RPSC_SPEED_CAP_UNKNOWN = 0x0001,
+};
+
+enum fc_rpsc_op_speed {
+       RPSC_OP_SPEED_1G = 0x8000,
+       RPSC_OP_SPEED_2G = 0x4000,
+       RPSC_OP_SPEED_4G = 0x2000,
+       RPSC_OP_SPEED_10G = 0x1000,
+       RPSC_OP_SPEED_8G = 0x0800,
+       RPSC_OP_SPEED_16G = 0x0400,
+
+       RPSC_OP_SPEED_NOT_EST = 0x0001, /*! speed not established */
+};
+
+struct fc_rpsc_speed_info_s {
+       u16        port_speed_cap;      /*! see enum fc_rpsc_speed_cap */
+       u16        port_op_speed;       /*! see enum fc_rpsc_op_speed */
+};
+
+enum link_e2e_beacon_subcmd {
+       LINK_E2E_BEACON_ON = 1,
+       LINK_E2E_BEACON_OFF = 2
+};
+
+enum beacon_type {
+       BEACON_TYPE_NORMAL      = 1,    /*! Normal Beaconing. Green */
+       BEACON_TYPE_WARN        = 2,    /*! Warning Beaconing. Yellow/Amber */
+       BEACON_TYPE_CRITICAL    = 3     /*! Critical Beaconing. Red */
+};
+
+struct link_e2e_beacon_param_s {
+       u8         beacon_type; /* Beacon Type. See enum beacon_type */
+       u8         beacon_frequency;
+                                       /* Beacon frequency. Number of blinks
+                                        * per 10 seconds
+                                        */
+       u16        beacon_duration;/* Beacon duration (in Seconds). The
+                                        * command operation should be
+                                        * terminated at the end of this
+                                        * timeout value.
+                                        *
+                                        * Ignored if diag_sub_cmd is
+                                        * LINK_E2E_BEACON_OFF.
+                                        *
+                                        * If 0, beaconing will continue till a
+                                        * BEACON OFF request is received
+                                        */
+};
+
+/*
+ * Link E2E beacon request/good response format.
+ * For LS_RJTs use struct fc_ls_rjt_s
+ */
+struct link_e2e_beacon_req_s {
+       u32        ls_code;     /*! FC_ELS_E2E_LBEACON in requests *
+                                        *or FC_ELS_ACC in good replies */
+       u32        ls_sub_cmd;  /*! See enum link_e2e_beacon_subcmd */
+       struct link_e2e_beacon_param_s beacon_parm;
+};
+
+/**
+ * If RPSC request is sent to the Domain Controller, the request is for
+ * all the ports within that domain (TODO - I don't think FOS implements
+ * this...).
+ */
+struct fc_rpsc_cmd_s {
+       struct fc_els_cmd_s els_cmd;
+};
+
+/*
+ * RPSC Acc
+ */
+struct fc_rpsc_acc_s {
+       u32        command:8;
+       u32        rsvd:8;
+       u32        num_entries:16;
+
+       struct fc_rpsc_speed_info_s speed_info[1];
+};
+
+/**
+ * If RPSC2 request is sent to the Domain Controller,
+ */
+#define FC_BRCD_TOKEN    0x42524344
+
+struct fc_rpsc2_cmd_s {
+       struct fc_els_cmd_s els_cmd;
+       u32     token;
+       u16     resvd;
+       u16     num_pids;       /* Number of pids in the request */
+       struct  {
+               u32     rsvd1:8;
+               u32     pid:24;         /* port identifier */
+       } pid_list[1];
+};
+
+enum fc_rpsc2_port_type {
+       RPSC2_PORT_TYPE_UNKNOWN = 0,
+       RPSC2_PORT_TYPE_NPORT   = 1,
+       RPSC2_PORT_TYPE_NLPORT  = 2,
+       RPSC2_PORT_TYPE_NPIV_PORT  = 0x5f,
+       RPSC2_PORT_TYPE_NPORT_TRUNK  = 0x6f,
+};
+/*
+ * RPSC2 portInfo entry structure
+ */
+struct fc_rpsc2_port_info_s {
+    u32    pid;        /* PID */
+    u16    resvd1;
+    u16    index;      /* port number / index */
+    u8     resvd2;
+    u8    type;        /* port type N/NL/... */
+    u16    speed;      /* port Operating Speed */
+};
+
+/*
+ * RPSC2 Accept payload
+ */
+struct fc_rpsc2_acc_s {
+       u8        els_cmd;
+       u8        resvd;
+    u16       num_pids;  /* Number of pids in the request */
+    struct fc_rpsc2_port_info_s port_info[1];    /* port information */
+};
+
+/**
+ * bit fields so that multiple classes can be specified
+ */
+enum fc_cos {
+       FC_CLASS_2      = 0x04,
+       FC_CLASS_3      = 0x08,
+       FC_CLASS_2_3    = 0x0C,
+};
+
+/*
+ * symbolic name
+ */
+struct fc_symname_s {
+       u8         symname[FC_SYMNAME_MAX];
+};
+
+struct fc_alpabm_s {
+       u8         alpa_bm[FC_ALPA_MAX / 8];
+};
+
+/*
+ * protocol default timeout values
+ */
+#define FC_ED_TOV              2
+#define FC_REC_TOV             (FC_ED_TOV + 1)
+#define FC_RA_TOV              10
+#define FC_ELS_TOV             (2 * FC_RA_TOV)
+#define FC_FCCT_TOV            (3 * FC_RA_TOV)
+
+/*
+ * virtual fabric related defines
+ */
+#define FC_VF_ID_NULL    0     /*  must not be used as VF_ID */
+#define FC_VF_ID_MIN     1
+#define FC_VF_ID_MAX     0xEFF
+#define FC_VF_ID_CTL     0xFEF /*  control VF_ID */
+
+/**
+ * Virtual Fabric Tagging header format
+ * @caution This is defined only in BIG ENDIAN format.
+ */
+struct fc_vft_s {
+       u32        r_ctl:8;
+       u32        ver:2;
+       u32        type:4;
+       u32        res_a:2;
+       u32        priority:3;
+       u32        vf_id:12;
+       u32        res_b:1;
+       u32        hopct:8;
+       u32        res_c:24;
+};
+
+/*
+ * FCP
+ */
+enum {
+       FCP_RJT         = 0x01000000,   /* SRR reject */
+       FCP_SRR_ACCEPT  = 0x02000000,   /* SRR accept */
+       FCP_SRR         = 0x14000000,   /* Sequence Retransmission Request */
+};
+
+/*
+ * SRR FC-4 LS payload
+ */
+struct fc_srr_s {
+       u32     ls_cmd;
+       u32        ox_id:16;    /* ox-id */
+       u32        rx_id:16;    /* rx-id */
+       u32        ro;          /* relative offset */
+       u32        r_ctl:8;             /* R_CTL for I.U. */
+       u32        res:24;
+};
+
+
+/*
+ * FCP_CMND definitions
+ */
+#define FCP_CMND_CDB_LEN    16
+#define FCP_CMND_LUN_LEN    8
+
+struct fcp_cmnd_s {
+       lun_t           lun;            /* 64-bit LU number */
+       u8         crn;         /* command reference number */
+#ifdef __BIGENDIAN
+       u8         resvd:1,
+                       priority:4,     /* FCP-3: SAM-3 priority */
+                       taskattr:3;     /* scsi task attribute */
+#else
+       u8         taskattr:3,  /* scsi task attribute */
+                       priority:4,     /* FCP-3: SAM-3 priority */
+                       resvd:1;
+#endif
+       u8         tm_flags;    /* task management flags */
+#ifdef __BIGENDIAN
+       u8         addl_cdb_len:6,      /* additional CDB length words */
+                       iodir:2;        /* read/write FCP_DATA IUs */
+#else
+       u8         iodir:2,     /* read/write FCP_DATA IUs */
+                       addl_cdb_len:6; /* additional CDB length */
+#endif
+       scsi_cdb_t      cdb;
+
+       /*
+        * !!! additional cdb bytes follows here!!!
+        */
+       u32        fcp_dl;      /* bytes to be transferred */
+};
+
+#define fcp_cmnd_cdb_len(_cmnd) ((_cmnd)->addl_cdb_len * 4 + FCP_CMND_CDB_LEN)
+#define fcp_cmnd_fcpdl(_cmnd)  ((&(_cmnd)->fcp_dl)[(_cmnd)->addl_cdb_len])
+
+/*
+ * struct fcp_cmnd_s .iodir field values
+ */
+enum fcp_iodir {
+       FCP_IODIR_NONE  = 0,
+       FCP_IODIR_WRITE = 1,
+       FCP_IODIR_READ  = 2,
+       FCP_IODIR_RW    = 3,
+};
+
+/*
+ * Task attribute field
+ */
+enum {
+       FCP_TASK_ATTR_SIMPLE    = 0,
+       FCP_TASK_ATTR_HOQ       = 1,
+       FCP_TASK_ATTR_ORDERED   = 2,
+       FCP_TASK_ATTR_ACA       = 4,
+       FCP_TASK_ATTR_UNTAGGED  = 5,    /* obsolete in FCP-3 */
+};
+
+/*
+ * Task management flags field - only one bit shall be set
+ */
+enum fcp_tm_cmnd {
+       FCP_TM_ABORT_TASK_SET   = BIT(1),
+       FCP_TM_CLEAR_TASK_SET   = BIT(2),
+       FCP_TM_LUN_RESET        = BIT(4),
+       FCP_TM_TARGET_RESET     = BIT(5),       /* obsolete in FCP-3 */
+       FCP_TM_CLEAR_ACA        = BIT(6),
+};
+
+/*
+ * FCP_XFER_RDY IU defines
+ */
+struct fcp_xfer_rdy_s {
+       u32        data_ro;
+       u32        burst_len;
+       u32        reserved;
+};
+
+/*
+ * FCP_RSP residue flags
+ */
+enum fcp_residue {
+       FCP_NO_RESIDUE = 0,     /* no residue */
+       FCP_RESID_OVER = 1,     /* more data left that was not sent */
+       FCP_RESID_UNDER = 2,    /* less data than requested */
+};
+
+enum {
+       FCP_RSPINFO_GOOD = 0,
+       FCP_RSPINFO_DATALEN_MISMATCH = 1,
+       FCP_RSPINFO_CMND_INVALID = 2,
+       FCP_RSPINFO_ROLEN_MISMATCH = 3,
+       FCP_RSPINFO_TM_NOT_SUPP = 4,
+       FCP_RSPINFO_TM_FAILED = 5,
+};
+
+struct fcp_rspinfo_s {
+       u32        res0:24;
+       u32        rsp_code:8;  /* response code (as above) */
+       u32        res1;
+};
+
+struct fcp_resp_s {
+       u32        reserved[2]; /* 2 words reserved */
+       u16        reserved2;
+#ifdef __BIGENDIAN
+       u8         reserved3:3;
+       u8         fcp_conf_req:1;      /* FCP_CONF is requested */
+       u8         resid_flags:2;       /* underflow/overflow */
+       u8         sns_len_valid:1;/* sense len is valid */
+       u8         rsp_len_valid:1;/* response len is valid */
+#else
+       u8         rsp_len_valid:1;/* response len is valid */
+       u8         sns_len_valid:1;/* sense len is valid */
+       u8         resid_flags:2;       /* underflow/overflow */
+       u8         fcp_conf_req:1;      /* FCP_CONF is requested */
+       u8         reserved3:3;
+#endif
+       u8         scsi_status; /* one byte SCSI status */
+       u32        residue;     /* residual data bytes */
+       u32        sns_len;     /* length od sense info */
+       u32        rsp_len;     /* length of response info */
+};
+
+#define fcp_snslen(__fcprsp)   ((__fcprsp)->sns_len_valid ?            \
+                                       (__fcprsp)->sns_len : 0)
+#define fcp_rsplen(__fcprsp)   ((__fcprsp)->rsp_len_valid ?            \
+                                       (__fcprsp)->rsp_len : 0)
+#define fcp_rspinfo(__fcprsp)  ((struct fcp_rspinfo_s *)((__fcprsp) + 1))
+#define fcp_snsinfo(__fcprsp)  (((u8 *)fcp_rspinfo(__fcprsp)) +        \
+                                               fcp_rsplen(__fcprsp))
+
+struct fcp_cmnd_fr_s {
+       struct fchs_s fchs;
+       struct fcp_cmnd_s fcp;
+};
+
+/*
+ * CT
+ */
+struct ct_hdr_s {
+       u32     rev_id:8;       /* Revision of the CT */
+       u32     in_id:24;       /* Initiator Id */
+       u32     gs_type:8;      /* Generic service Type */
+       u32     gs_sub_type:8;  /* Generic service sub type */
+       u32     options:8;      /* options */
+       u32     rsvrd:8;        /* reserved */
+       u32     cmd_rsp_code:16;/* ct command/response code */
+       u32     max_res_size:16;/* maximum/residual size */
+       u32     frag_id:8;      /* fragment ID */
+       u32     reason_code:8;  /* reason code */
+       u32     exp_code:8;     /* explanation code */
+       u32     vendor_unq:8;   /* vendor unique */
+};
+
+/*
+ * defines for the Revision
+ */
+enum {
+       CT_GS3_REVISION = 0x01,
+};
+
+/*
+ * defines for gs_type
+ */
+enum {
+       CT_GSTYPE_KEYSERVICE    = 0xF7,
+       CT_GSTYPE_ALIASSERVICE  = 0xF8,
+       CT_GSTYPE_MGMTSERVICE   = 0xFA,
+       CT_GSTYPE_TIMESERVICE   = 0xFB,
+       CT_GSTYPE_DIRSERVICE    = 0xFC,
+};
+
+/*
+ * defines for gs_sub_type for gs type directory service
+ */
+enum {
+       CT_GSSUBTYPE_NAMESERVER = 0x02,
+};
+
+/*
+ * defines for gs_sub_type for gs type management service
+ */
+enum {
+       CT_GSSUBTYPE_CFGSERVER  = 0x01,
+       CT_GSSUBTYPE_UNZONED_NS = 0x02,
+       CT_GSSUBTYPE_ZONESERVER = 0x03,
+       CT_GSSUBTYPE_LOCKSERVER = 0x04,
+       CT_GSSUBTYPE_HBA_MGMTSERVER = 0x10,     /* for FDMI */
+};
+
+/*
+ * defines for CT response code field
+ */
+enum {
+       CT_RSP_REJECT = 0x8001,
+       CT_RSP_ACCEPT = 0x8002,
+};
+
+/*
+ * defintions for CT reason code
+ */
+enum {
+       CT_RSN_INV_CMD          = 0x01,
+       CT_RSN_INV_VER          = 0x02,
+       CT_RSN_LOGIC_ERR        = 0x03,
+       CT_RSN_INV_SIZE         = 0x04,
+       CT_RSN_LOGICAL_BUSY     = 0x05,
+       CT_RSN_PROTO_ERR        = 0x07,
+       CT_RSN_UNABLE_TO_PERF   = 0x09,
+       CT_RSN_NOT_SUPP                 = 0x0B,
+       CT_RSN_SERVER_NOT_AVBL  = 0x0D,
+       CT_RSN_SESSION_COULD_NOT_BE_ESTBD = 0x0E,
+       CT_RSN_VENDOR_SPECIFIC  = 0xFF,
+
+};
+
+/*
+ * definitions for explanations code for Name server
+ */
+enum {
+       CT_NS_EXP_NOADDITIONAL  = 0x00,
+       CT_NS_EXP_ID_NOT_REG    = 0x01,
+       CT_NS_EXP_PN_NOT_REG    = 0x02,
+       CT_NS_EXP_NN_NOT_REG    = 0x03,
+       CT_NS_EXP_CS_NOT_REG    = 0x04,
+       CT_NS_EXP_IPN_NOT_REG   = 0x05,
+       CT_NS_EXP_IPA_NOT_REG   = 0x06,
+       CT_NS_EXP_FT_NOT_REG    = 0x07,
+       CT_NS_EXP_SPN_NOT_REG   = 0x08,
+       CT_NS_EXP_SNN_NOT_REG   = 0x09,
+       CT_NS_EXP_PT_NOT_REG    = 0x0A,
+       CT_NS_EXP_IPP_NOT_REG   = 0x0B,
+       CT_NS_EXP_FPN_NOT_REG   = 0x0C,
+       CT_NS_EXP_HA_NOT_REG    = 0x0D,
+       CT_NS_EXP_FD_NOT_REG    = 0x0E,
+       CT_NS_EXP_FF_NOT_REG    = 0x0F,
+       CT_NS_EXP_ACCESSDENIED  = 0x10,
+       CT_NS_EXP_UNACCEPTABLE_ID = 0x11,
+       CT_NS_EXP_DATABASEEMPTY         = 0x12,
+       CT_NS_EXP_NOT_REG_IN_SCOPE      = 0x13,
+       CT_NS_EXP_DOM_ID_NOT_PRESENT    = 0x14,
+       CT_NS_EXP_PORT_NUM_NOT_PRESENT  = 0x15,
+       CT_NS_EXP_NO_DEVICE_ATTACHED    = 0x16
+};
+
+/*
+ * defintions for the explanation code for all servers
+ */
+enum {
+       CT_EXP_AUTH_EXCEPTION                   = 0xF1,
+       CT_EXP_DB_FULL                                  = 0xF2,
+       CT_EXP_DB_EMPTY                                 = 0xF3,
+       CT_EXP_PROCESSING_REQ                   = 0xF4,
+       CT_EXP_UNABLE_TO_VERIFY_CONN    = 0xF5,
+       CT_EXP_DEVICES_NOT_IN_CMN_ZONE  = 0xF6
+};
+
+/*
+ * Command codes for Name server
+ */
+enum {
+       GS_GID_PN       = 0x0121,       /* Get Id on port name */
+       GS_GPN_ID       = 0x0112,       /* Get port name on ID */
+       GS_GNN_ID       = 0x0113,       /* Get node name on ID */
+       GS_GID_FT       = 0x0171,       /* Get Id on FC4 type */
+       GS_GSPN_ID      = 0x0118,       /* Get symbolic PN on ID */
+       GS_RFT_ID       = 0x0217,       /* Register fc4type on ID */
+       GS_RSPN_ID      = 0x0218,       /* Register symbolic PN on ID */
+       GS_RPN_ID       = 0x0212,       /* Register port name */
+       GS_RNN_ID       = 0x0213,       /* Register node name */
+       GS_RCS_ID       = 0x0214,       /* Register class of service */
+       GS_RPT_ID       = 0x021A,       /* Register port type */
+       GS_GA_NXT       = 0x0100,       /* Get all next */
+       GS_RFF_ID       = 0x021F,       /* Register FC4 Feature         */
+};
+
+struct fcgs_id_req_s{
+       u32 rsvd:8;
+       u32 dap:24; /* port identifier */
+};
+#define fcgs_gpnid_req_t struct fcgs_id_req_s
+#define fcgs_gnnid_req_t struct fcgs_id_req_s
+#define fcgs_gspnid_req_t struct fcgs_id_req_s
+
+struct fcgs_gidpn_req_s {
+       wwn_t   port_name;      /* port wwn */
+};
+
+struct fcgs_gidpn_resp_s {
+       u32     rsvd:8;
+       u32     dap:24; /* port identifier */
+};
+
+/**
+ * RFT_ID
+ */
+struct fcgs_rftid_req_s {
+       u32     rsvd:8;
+       u32     dap:24;         /* port identifier */
+       u32     fc4_type[8];    /* fc4 types */
+};
+
+/**
+ * RFF_ID : Register FC4 features.
+ */
+
+#define FC_GS_FCP_FC4_FEATURE_INITIATOR  0x02
+#define FC_GS_FCP_FC4_FEATURE_TARGET    0x01
+
+struct fcgs_rffid_req_s {
+    u32    rsvd:8;
+    u32    dap:24;             /* port identifier      */
+    u32    rsvd1:16;
+    u32    fc4ftr_bits:8;              /* fc4 feature bits     */
+    u32    fc4_type:8;         /* corresponding FC4 Type */
+};
+
+/**
+ * GID_FT Request
+ */
+struct fcgs_gidft_req_s {
+       u8      reserved;
+       u8      domain_id;      /* domain, 0 - all fabric */
+       u8      area_id;        /* area, 0 - whole domain */
+       u8      fc4_type;       /* FC_TYPE_FCP for SCSI devices */
+};             /* GID_FT Request */
+
+/**
+ * GID_FT Response
+ */
+struct fcgs_gidft_resp_s {
+       u8              last:1; /* last port identifier flag */
+       u8              reserved:7;
+       u32     pid:24; /* port identifier */
+};             /* GID_FT Response */
+
+/**
+ * RSPN_ID
+ */
+struct fcgs_rspnid_req_s {
+       u32     rsvd:8;
+       u32     dap:24;         /* port identifier */
+       u8              spn_len;        /* symbolic port name length */
+       u8              spn[256];       /* symbolic port name */
+};
+
+/**
+ * RPN_ID
+ */
+struct fcgs_rpnid_req_s {
+       u32     rsvd:8;
+       u32     port_id:24;
+       wwn_t           port_name;
+};
+
+/**
+ * RNN_ID
+ */
+struct fcgs_rnnid_req_s {
+       u32     rsvd:8;
+       u32     port_id:24;
+       wwn_t           node_name;
+};
+
+/**
+ * RCS_ID
+ */
+struct fcgs_rcsid_req_s {
+       u32     rsvd:8;
+       u32     port_id:24;
+       u32     cos;
+};
+
+/**
+ * RPT_ID
+ */
+struct fcgs_rptid_req_s {
+       u32     rsvd:8;
+       u32     port_id:24;
+       u32     port_type:8;
+       u32     rsvd1:24;
+};
+
+/**
+ * GA_NXT Request
+ */
+struct fcgs_ganxt_req_s {
+       u32     rsvd:8;
+       u32     port_id:24;
+};
+
+/**
+ * GA_NXT Response
+ */
+struct fcgs_ganxt_rsp_s {
+       u32     port_type:8;    /* Port Type */
+       u32     port_id:24;     /* Port Identifier */
+       wwn_t           port_name;      /* Port Name */
+       u8              spn_len;        /* Length of Symbolic Port Name */
+       char            spn[255];       /* Symbolic Port Name */
+       wwn_t           node_name;      /* Node Name */
+       u8              snn_len;        /* Length of Symbolic Node Name */
+       char            snn[255];       /* Symbolic Node Name */
+       u8              ipa[8];         /* Initial Process Associator */
+       u8              ip[16];         /* IP Address */
+       u32     cos;            /* Class of Service */
+       u32     fc4types[8];    /* FC-4 TYPEs */
+       wwn_t           fabric_port_name;
+                                       /* Fabric Port Name */
+       u32     rsvd:8;         /* Reserved */
+       u32     hard_addr:24;   /* Hard Address */
+};
+
+/*
+ * Fabric Config Server
+ */
+
+/*
+ * Command codes for Fabric Configuration Server
+ */
+enum {
+       GS_FC_GFN_CMD   = 0x0114,       /* GS FC Get Fabric Name  */
+       GS_FC_GMAL_CMD  = 0x0116,       /* GS FC GMAL  */
+       GS_FC_TRACE_CMD = 0x0400,       /* GS FC Trace Route */
+       GS_FC_PING_CMD  = 0x0401,       /* GS FC Ping */
+};
+
+/*
+ * Source or Destination Port Tags.
+ */
+enum {
+       GS_FTRACE_TAG_NPORT_ID          = 1,
+       GS_FTRACE_TAG_NPORT_NAME        = 2,
+};
+
+/*
+* Port Value : Could be a Port id or wwn
+ */
+union fcgs_port_val_u {
+       u32     nport_id;
+       wwn_t           nport_wwn;
+};
+
+#define GS_FTRACE_MAX_HOP_COUNT        20
+#define GS_FTRACE_REVISION     1
+
+/*
+ * Ftrace Related Structures.
+ */
+
+/*
+ * STR (Switch Trace) Reject Reason Codes. From FC-SW.
+ */
+enum {
+       GS_FTRACE_STR_CMD_COMPLETED_SUCC        = 0,
+       GS_FTRACE_STR_CMD_NOT_SUPP_IN_NEXT_SWITCH,
+       GS_FTRACE_STR_NO_RESP_FROM_NEXT_SWITCH,
+       GS_FTRACE_STR_MAX_HOP_CNT_REACHED,
+       GS_FTRACE_STR_SRC_PORT_NOT_FOUND,
+       GS_FTRACE_STR_DST_PORT_NOT_FOUND,
+       GS_FTRACE_STR_DEVICES_NOT_IN_COMMON_ZONE,
+       GS_FTRACE_STR_NO_ROUTE_BW_PORTS,
+       GS_FTRACE_STR_NO_ADDL_EXPLN,
+       GS_FTRACE_STR_FABRIC_BUSY,
+       GS_FTRACE_STR_FABRIC_BUILD_IN_PROGRESS,
+       GS_FTRACE_STR_VENDOR_SPECIFIC_ERR_START = 0xf0,
+       GS_FTRACE_STR_VENDOR_SPECIFIC_ERR_END = 0xff,
+};
+
+/*
+ * Ftrace Request
+ */
+struct fcgs_ftrace_req_s {
+       u32     revision;
+       u16     src_port_tag;   /* Source Port tag */
+       u16     src_port_len;   /* Source Port len */
+       union fcgs_port_val_u src_port_val;     /* Source Port value */
+       u16     dst_port_tag;   /* Destination Port tag */
+       u16     dst_port_len;   /* Destination Port len */
+       union fcgs_port_val_u dst_port_val;     /* Destination Port value */
+       u32     token;
+       u8              vendor_id[8];   /* T10 Vendor Identifier */
+       u8              vendor_info[8]; /* Vendor specific Info */
+       u32     max_hop_cnt;    /* Max Hop Count */
+};
+
+/*
+ * Path info structure
+ */
+struct fcgs_ftrace_path_info_s {
+       wwn_t           switch_name;            /* Switch WWN */
+       u32     domain_id;
+       wwn_t           ingress_port_name;      /* Ingress ports wwn */
+       u32     ingress_phys_port_num;  /* Ingress ports physical port
+                                                * number
+                                                */
+       wwn_t           egress_port_name;       /* Ingress ports wwn */
+       u32     egress_phys_port_num;   /* Ingress ports physical port
+                                                * number
+                                                */
+};
+
+/*
+ * Ftrace Acc Response
+ */
+struct fcgs_ftrace_resp_s {
+       u32     revision;
+       u32     token;
+       u8              vendor_id[8];           /* T10 Vendor Identifier */
+       u8              vendor_info[8];         /* Vendor specific Info */
+       u32     str_rej_reason_code;    /* STR Reject Reason Code */
+       u32     num_path_info_entries;  /* No. of path info entries */
+       /*
+        * path info entry/entries.
+        */
+       struct fcgs_ftrace_path_info_s path_info[1];
+
+};
+
+/*
+* Fabric Config Server : FCPing
+ */
+
+/*
+ * FC Ping Request
+ */
+struct fcgs_fcping_req_s {
+       u32     revision;
+       u16     port_tag;
+       u16     port_len;       /* Port len */
+       union fcgs_port_val_u port_val; /* Port value */
+       u32     token;
+};
+
+/*
+ * FC Ping Response
+ */
+struct fcgs_fcping_resp_s {
+       u32     token;
+};
+
+/*
+ * Command codes for zone server query.
+ */
+enum {
+       ZS_GZME = 0x0124,       /* Get zone member extended */
+};
+
+/*
+ * ZS GZME request
+ */
+#define ZS_GZME_ZNAMELEN       32
+struct zs_gzme_req_s {
+       u8      znamelen;
+       u8      rsvd[3];
+       u8      zname[ZS_GZME_ZNAMELEN];
+};
+
+enum zs_mbr_type {
+       ZS_MBR_TYPE_PWWN        = 1,
+       ZS_MBR_TYPE_DOMPORT     = 2,
+       ZS_MBR_TYPE_PORTID      = 3,
+       ZS_MBR_TYPE_NWWN        = 4,
+};
+
+struct zs_mbr_wwn_s {
+       u8      mbr_type;
+       u8      rsvd[3];
+       wwn_t   wwn;
+};
+
+struct zs_query_resp_s {
+       u32     nmbrs;  /*  number of zone members */
+       struct zs_mbr_wwn_s     mbr[1];
+};
+
+/*
+ * GMAL Command ( Get ( interconnect Element) Management Address List)
+ * To retrieve the IP Address of a Switch.
+ */
+
+#define CT_GMAL_RESP_PREFIX_TELNET      "telnet://"
+#define CT_GMAL_RESP_PREFIX_HTTP        "http://"
+
+/*  GMAL/GFN request */
+struct fcgs_req_s {
+       wwn_t    wwn;   /* PWWN/NWWN */
+};
+
+#define fcgs_gmal_req_t struct fcgs_req_s
+#define fcgs_gfn_req_t struct fcgs_req_s
+
+/* Accept Response to GMAL */
+struct fcgs_gmal_resp_s {
+       u32     ms_len;   /* Num of entries */
+       u8      ms_ma[256];
+};
+
+struct fcgs_gmal_entry_s {
+       u8  len;
+       u8  prefix[7]; /* like "http://" */
+       u8  ip_addr[248];
+};
+
+/*
+ * FDMI
+ */
+/*
+ * FDMI Command Codes
+ */
+#define        FDMI_GRHL               0x0100
+#define        FDMI_GHAT               0x0101
+#define        FDMI_GRPL               0x0102
+#define        FDMI_GPAT               0x0110
+#define        FDMI_RHBA               0x0200
+#define        FDMI_RHAT               0x0201
+#define        FDMI_RPRT               0x0210
+#define        FDMI_RPA                0x0211
+#define        FDMI_DHBA               0x0300
+#define        FDMI_DPRT               0x0310
+
+/*
+ * FDMI reason codes
+ */
+#define        FDMI_NO_ADDITIONAL_EXP          0x00
+#define        FDMI_HBA_ALREADY_REG            0x10
+#define        FDMI_HBA_ATTRIB_NOT_REG         0x11
+#define        FDMI_HBA_ATTRIB_MULTIPLE        0x12
+#define        FDMI_HBA_ATTRIB_LENGTH_INVALID  0x13
+#define        FDMI_HBA_ATTRIB_NOT_PRESENT     0x14
+#define        FDMI_PORT_ORIG_NOT_IN_LIST      0x15
+#define        FDMI_PORT_HBA_NOT_IN_LIST       0x16
+#define        FDMI_PORT_ATTRIB_NOT_REG        0x20
+#define        FDMI_PORT_NOT_REG               0x21
+#define        FDMI_PORT_ATTRIB_MULTIPLE       0x22
+#define        FDMI_PORT_ATTRIB_LENGTH_INVALID 0x23
+#define        FDMI_PORT_ALREADY_REGISTEREED   0x24
+
+/*
+ * FDMI Transmission Speed Mask values
+ */
+#define        FDMI_TRANS_SPEED_1G             0x00000001
+#define        FDMI_TRANS_SPEED_2G             0x00000002
+#define        FDMI_TRANS_SPEED_10G            0x00000004
+#define        FDMI_TRANS_SPEED_4G             0x00000008
+#define        FDMI_TRANS_SPEED_8G             0x00000010
+#define        FDMI_TRANS_SPEED_16G            0x00000020
+#define        FDMI_TRANS_SPEED_UNKNOWN        0x00008000
+
+/*
+ * FDMI HBA attribute types
+ */
+enum fdmi_hba_attribute_type {
+       FDMI_HBA_ATTRIB_NODENAME = 1,   /* 0x0001 */
+       FDMI_HBA_ATTRIB_MANUFACTURER,   /* 0x0002 */
+       FDMI_HBA_ATTRIB_SERIALNUM,      /* 0x0003 */
+       FDMI_HBA_ATTRIB_MODEL,          /* 0x0004 */
+       FDMI_HBA_ATTRIB_MODEL_DESC,     /* 0x0005 */
+       FDMI_HBA_ATTRIB_HW_VERSION,     /* 0x0006 */
+       FDMI_HBA_ATTRIB_DRIVER_VERSION, /* 0x0007 */
+       FDMI_HBA_ATTRIB_ROM_VERSION,    /* 0x0008 */
+       FDMI_HBA_ATTRIB_FW_VERSION,     /* 0x0009 */
+       FDMI_HBA_ATTRIB_OS_NAME,        /* 0x000A */
+       FDMI_HBA_ATTRIB_MAX_CT,         /* 0x000B */
+
+       FDMI_HBA_ATTRIB_MAX_TYPE
+};
+
+/*
+ * FDMI Port attribute types
+ */
+enum fdmi_port_attribute_type {
+       FDMI_PORT_ATTRIB_FC4_TYPES = 1, /* 0x0001 */
+       FDMI_PORT_ATTRIB_SUPP_SPEED,    /* 0x0002 */
+       FDMI_PORT_ATTRIB_PORT_SPEED,    /* 0x0003 */
+       FDMI_PORT_ATTRIB_FRAME_SIZE,    /* 0x0004 */
+       FDMI_PORT_ATTRIB_DEV_NAME,      /* 0x0005 */
+       FDMI_PORT_ATTRIB_HOST_NAME,     /* 0x0006 */
+
+       FDMI_PORT_ATTR_MAX_TYPE
+};
+
+/*
+ * FDMI attribute
+ */
+struct fdmi_attr_s {
+       u16        type;
+       u16        len;
+       u8         value[1];
+};
+
+/*
+ * HBA Attribute Block
+ */
+struct fdmi_hba_attr_s {
+       u32        attr_count;  /* # of attributes */
+       struct fdmi_attr_s hba_attr;    /* n attributes */
+};
+
+/*
+ * Registered Port List
+ */
+struct fdmi_port_list_s {
+       u32        num_ports;   /* number Of Port Entries */
+       wwn_t           port_entry;     /* one or more */
+};
+
+/*
+ * Port Attribute Block
+ */
+struct fdmi_port_attr_s {
+       u32        attr_count;  /* # of attributes */
+       struct fdmi_attr_s port_attr;   /* n attributes */
+};
+
+/*
+ * FDMI Register HBA Attributes
+ */
+struct fdmi_rhba_s {
+       wwn_t           hba_id;         /* HBA Identifier */
+       struct fdmi_port_list_s port_list;      /* Registered Port List */
+       struct fdmi_hba_attr_s hba_attr_blk;    /* HBA attribute block */
+};
+
+/*
+ * FDMI Register Port
+ */
+struct fdmi_rprt_s {
+       wwn_t           hba_id;         /* HBA Identifier */
+       wwn_t           port_name;      /* Port wwn */
+       struct fdmi_port_attr_s port_attr_blk;  /* Port Attr Block */
+};
+
+/*
+ * FDMI Register Port Attributes
+ */
+struct fdmi_rpa_s {
+       wwn_t           port_name;      /* port wwn */
+       struct fdmi_port_attr_s port_attr_blk;  /* Port Attr Block */
+};
+
+#pragma pack()
+
+#endif /* __BFA_FC_H__ */
similarity index 82%
rename from drivers/scsi/bfa/fcbuild.c
rename to drivers/scsi/bfa/bfa_fcbuild.c
index fee5456..b7d2657 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
+ * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
  * All rights reserved
  * www.brocade.com
  *
  * fcbuild.c - FC link service frame building and parsing routines
  */
 
-#include <bfa_os_inc.h>
-#include "fcbuild.h"
+#include "bfa_os_inc.h"
+#include "bfa_fcbuild.h"
 
 /*
  * static build functions
  */
-static void fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
-                       u16 ox_id);
-static void fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
-                       u16 ox_id);
-static struct fchs_s   fc_els_req_tmpl;
-static struct fchs_s   fc_els_rsp_tmpl;
-static struct fchs_s   fc_bls_req_tmpl;
-static struct fchs_s   fc_bls_rsp_tmpl;
+static void     fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
+                                u16 ox_id);
+static void     fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
+                                u16 ox_id);
+static struct fchs_s fc_els_req_tmpl;
+static struct fchs_s fc_els_rsp_tmpl;
+static struct fchs_s fc_bls_req_tmpl;
+static struct fchs_s fc_bls_rsp_tmpl;
 static struct fc_ba_acc_s ba_acc_tmpl;
 static struct fc_logi_s plogi_tmpl;
 static struct fc_prli_s prli_tmpl;
 static struct fc_rrq_s rrq_tmpl;
-static struct fchs_s   fcp_fchs_tmpl;
+static struct fchs_s fcp_fchs_tmpl;
 
 void
 fcbuild_init(void)
@@ -123,7 +123,7 @@ fcbuild_init(void)
        rrq_tmpl.els_cmd.els_code = FC_ELS_RRQ;
 
        /*
-        * fcp_fchs_tmpl
+        * fcp_struct fchs_s mpl
         */
        fcp_fchs_tmpl.routing = FC_RTG_FC4_DEV_DATA;
        fcp_fchs_tmpl.cat_info = FC_CAT_UNSOLICIT_CMD;
@@ -135,8 +135,7 @@ fcbuild_init(void)
 }
 
 static void
-fc_gs_fchdr_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
-                       u32 ox_id)
+fc_gs_fchdr_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u32 ox_id)
 {
        bfa_os_memset(fchs, 0, sizeof(struct fchs_s));
 
@@ -158,8 +157,7 @@ fc_gs_fchdr_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
 }
 
 void
-fc_els_req_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
-                       u16 ox_id)
+fc_els_req_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id)
 {
        bfa_os_memcpy(fchs, &fc_els_req_tmpl, sizeof(struct fchs_s));
        fchs->d_id = (d_id);
@@ -168,8 +166,7 @@ fc_els_req_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
 }
 
 static void
-fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
-                       u16 ox_id)
+fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id)
 {
        bfa_os_memcpy(fchs, &fc_els_rsp_tmpl, sizeof(struct fchs_s));
        fchs->d_id = d_id;
@@ -180,8 +177,8 @@ fc_els_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
 enum fc_parse_status
 fc_els_rsp_parse(struct fchs_s *fchs, int len)
 {
-       struct fc_els_cmd_s   *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
-       struct fc_ls_rjt_s    *ls_rjt = (struct fc_ls_rjt_s *) els_cmd;
+       struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
+       struct fc_ls_rjt_s *ls_rjt = (struct fc_ls_rjt_s *) els_cmd;
 
        len = len;
 
@@ -199,8 +196,7 @@ fc_els_rsp_parse(struct fchs_s *fchs, int len)
 }
 
 static void
-fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
-                       u16 ox_id)
+fc_bls_rsp_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id)
 {
        bfa_os_memcpy(fchs, &fc_bls_rsp_tmpl, sizeof(struct fchs_s));
        fchs->d_id = d_id;
@@ -213,7 +209,7 @@ fc_plogi_x_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
                 u16 ox_id, wwn_t port_name, wwn_t node_name,
                 u16 pdu_size, u8 els_code)
 {
-       struct fc_logi_s     *plogi = (struct fc_logi_s *) (pld);
+       struct fc_logi_s *plogi = (struct fc_logi_s *) (pld);
 
        bfa_os_memcpy(plogi, &plogi_tmpl, sizeof(struct fc_logi_s));
 
@@ -233,12 +229,11 @@ fc_plogi_x_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
 
 u16
 fc_flogi_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
-               u16 ox_id, wwn_t port_name, wwn_t node_name,
-               u16 pdu_size, u8 set_npiv, u8 set_auth,
-               u16 local_bb_credits)
+               u16 ox_id, wwn_t port_name, wwn_t node_name, u16 pdu_size,
+              u8 set_npiv, u8 set_auth, u16 local_bb_credits)
 {
        u32        d_id = bfa_os_hton3b(FC_FABRIC_PORT);
-       u32     *vvl_info;
+       u32     *vvl_info;
 
        bfa_os_memcpy(flogi, &plogi_tmpl, sizeof(struct fc_logi_s));
 
@@ -292,8 +287,7 @@ fc_flogi_acc_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
 
 u16
 fc_fdisc_build(struct fchs_s *fchs, struct fc_logi_s *flogi, u32 s_id,
-               u16 ox_id, wwn_t port_name, wwn_t node_name,
-               u16 pdu_size)
+               u16 ox_id, wwn_t port_name, wwn_t node_name, u16 pdu_size)
 {
        u32        d_id = bfa_os_hton3b(FC_FABRIC_PORT);
 
@@ -330,9 +324,9 @@ fc_plogi_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
 enum fc_parse_status
 fc_plogi_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
 {
-       struct fc_els_cmd_s   *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
-       struct fc_logi_s     *plogi;
-       struct fc_ls_rjt_s    *ls_rjt;
+       struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
+       struct fc_logi_s *plogi;
+       struct fc_ls_rjt_s *ls_rjt;
 
        switch (els_cmd->els_code) {
        case FC_ELS_LS_RJT:
@@ -364,7 +358,7 @@ fc_plogi_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
 enum fc_parse_status
 fc_plogi_parse(struct fchs_s *fchs)
 {
-       struct fc_logi_s     *plogi = (struct fc_logi_s *) (fchs + 1);
+       struct fc_logi_s *plogi = (struct fc_logi_s *) (fchs + 1);
 
        if (plogi->class3.class_valid != 1)
                return FC_PARSE_FAILURE;
@@ -381,7 +375,7 @@ u16
 fc_prli_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
              u16 ox_id)
 {
-       struct fc_prli_s      *prli = (struct fc_prli_s *) (pld);
+       struct fc_prli_s *prli = (struct fc_prli_s *) (pld);
 
        fc_els_req_build(fchs, d_id, s_id, ox_id);
        bfa_os_memcpy(prli, &prli_tmpl, sizeof(struct fc_prli_s));
@@ -398,19 +392,16 @@ fc_prli_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
 
 u16
 fc_prli_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
-                 u16 ox_id, enum bfa_port_role role)
+                 u16 ox_id, enum bfa_lport_role role)
 {
-       struct fc_prli_s      *prli = (struct fc_prli_s *) (pld);
+       struct fc_prli_s *prli = (struct fc_prli_s *) (pld);
 
        fc_els_rsp_build(fchs, d_id, s_id, ox_id);
        bfa_os_memcpy(prli, &prli_tmpl, sizeof(struct fc_prli_s));
 
        prli->command = FC_ELS_ACC;
 
-       if ((role & BFA_PORT_ROLE_FCP_TM) == BFA_PORT_ROLE_FCP_TM)
-               prli->parampage.servparams.target = 1;
-       else
-               prli->parampage.servparams.initiator = 1;
+       prli->parampage.servparams.initiator = 1;
 
        prli->parampage.rspcode = FC_PRLI_ACC_XQTD;
 
@@ -452,12 +443,12 @@ fc_prli_parse(struct fc_prli_s *prli)
 }
 
 u16
-fc_logo_build(struct fchs_s *fchs, struct fc_logo_s *logo, u32 d_id,
-                       u32 s_id, u16 ox_id, wwn_t port_name)
+fc_logo_build(struct fchs_s *fchs, struct fc_logo_s *logo, u32 d_id, u32 s_id,
+             u16 ox_id, wwn_t port_name)
 {
        fc_els_req_build(fchs, d_id, s_id, ox_id);
 
-       memset(logo, '\0', sizeof(struct fc_logo_s));
+       bfa_os_memset(logo, '\0', sizeof(struct fc_logo_s));
        logo->els_cmd.els_code = FC_ELS_LOGO;
        logo->nport_id = (s_id);
        logo->orig_port_name = port_name;
@@ -470,7 +461,7 @@ fc_adisc_x_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
                 u32 s_id, u16 ox_id, wwn_t port_name,
                 wwn_t node_name, u8 els_code)
 {
-       memset(adisc, '\0', sizeof(struct fc_adisc_s));
+       bfa_os_memset(adisc, '\0', sizeof(struct fc_adisc_s));
 
        adisc->els_cmd.els_code = els_code;
 
@@ -489,8 +480,7 @@ fc_adisc_x_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
 
 u16
 fc_adisc_build(struct fchs_s *fchs, struct fc_adisc_s *adisc, u32 d_id,
-               u32 s_id, u16 ox_id, wwn_t port_name,
-               wwn_t node_name)
+               u32 s_id, u16 ox_id, wwn_t port_name, wwn_t node_name)
 {
        return fc_adisc_x_build(fchs, adisc, d_id, s_id, ox_id, port_name,
                                node_name, FC_ELS_ADISC);
@@ -523,10 +513,10 @@ fc_adisc_rsp_parse(struct fc_adisc_s *adisc, int len, wwn_t port_name,
 }
 
 enum fc_parse_status
-fc_adisc_parse(struct fchs_s *fchs, void *pld, u32 host_dap,
-                wwn_t node_name, wwn_t port_name)
+fc_adisc_parse(struct fchs_s *fchs, void *pld, u32 host_dap, wwn_t node_name,
+              wwn_t port_name)
 {
-       struct fc_adisc_s     *adisc = (struct fc_adisc_s *) pld;
+       struct fc_adisc_s *adisc = (struct fc_adisc_s *) pld;
 
        if (adisc->els_cmd.els_code != FC_ELS_ACC)
                return FC_PARSE_FAILURE;
@@ -542,13 +532,13 @@ fc_adisc_parse(struct fchs_s *fchs, void *pld, u32 host_dap,
 enum fc_parse_status
 fc_pdisc_parse(struct fchs_s *fchs, wwn_t node_name, wwn_t port_name)
 {
-       struct fc_logi_s     *pdisc = (struct fc_logi_s *) (fchs + 1);
+       struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
 
        if (pdisc->class3.class_valid != 1)
                return FC_PARSE_FAILURE;
 
        if ((bfa_os_ntohs(pdisc->class3.rxsz) <
-                (FC_MIN_PDUSZ - sizeof(struct fchs_s)))
+               (FC_MIN_PDUSZ - sizeof(struct fchs_s)))
            || (pdisc->class3.rxsz == 0))
                return FC_PARSE_FAILURE;
 
@@ -584,8 +574,8 @@ fc_abts_rsp_parse(struct fchs_s *fchs, int len)
 }
 
 u16
-fc_rrq_build(struct fchs_s *fchs, struct fc_rrq_s *rrq, u32 d_id,
-                        u32 s_id, u16 ox_id, u16 rrq_oxid)
+fc_rrq_build(struct fchs_s *fchs, struct fc_rrq_s *rrq, u32 d_id, u32 s_id,
+            u16 ox_id, u16 rrq_oxid)
 {
        fc_els_req_build(fchs, d_id, s_id, ox_id);
 
@@ -604,11 +594,11 @@ u16
 fc_logo_acc_build(struct fchs_s *fchs, void *pld, u32 d_id, u32 s_id,
                  u16 ox_id)
 {
-       struct fc_els_cmd_s   *acc = pld;
+       struct fc_els_cmd_s *acc = pld;
 
        fc_els_rsp_build(fchs, d_id, s_id, ox_id);
 
-       memset(acc, 0, sizeof(struct fc_els_cmd_s));
+       bfa_os_memset(acc, 0, sizeof(struct fc_els_cmd_s));
        acc->els_code = FC_ELS_ACC;
 
        return sizeof(struct fc_els_cmd_s);
@@ -620,7 +610,7 @@ fc_ls_rjt_build(struct fchs_s *fchs, struct fc_ls_rjt_s *ls_rjt, u32 d_id,
                u8 reason_code_expl)
 {
        fc_els_rsp_build(fchs, d_id, s_id, ox_id);
-       memset(ls_rjt, 0, sizeof(struct fc_ls_rjt_s));
+       bfa_os_memset(ls_rjt, 0, sizeof(struct fc_ls_rjt_s));
 
        ls_rjt->els_cmd.els_code = FC_ELS_LS_RJT;
        ls_rjt->reason_code = reason_code;
@@ -647,11 +637,11 @@ fc_ba_acc_build(struct fchs_s *fchs, struct fc_ba_acc_s *ba_acc, u32 d_id,
 }
 
 u16
-fc_ls_acc_build(struct fchs_s *fchs, struct fc_els_cmd_s *els_cmd,
-                       u32 d_id, u32 s_id, u16 ox_id)
+fc_ls_acc_build(struct fchs_s *fchs, struct fc_els_cmd_s *els_cmd, u32 d_id,
+               u32 s_id, u16 ox_id)
 {
        fc_els_rsp_build(fchs, d_id, s_id, ox_id);
-       memset(els_cmd, 0, sizeof(struct fc_els_cmd_s));
+       bfa_os_memset(els_cmd, 0, sizeof(struct fc_els_cmd_s));
        els_cmd->els_code = FC_ELS_ACC;
 
        return sizeof(struct fc_els_cmd_s);
@@ -661,8 +651,8 @@ int
 fc_logout_params_pages(struct fchs_s *fc_frame, u8 els_code)
 {
        int             num_pages = 0;
-       struct fc_prlo_s      *prlo;
-       struct fc_tprlo_s     *tprlo;
+       struct fc_prlo_s *prlo;
+       struct fc_tprlo_s *tprlo;
 
        if (els_code == FC_ELS_PRLO) {
                prlo = (struct fc_prlo_s *) (fc_frame + 1);
@@ -676,14 +666,13 @@ fc_logout_params_pages(struct fchs_s *fc_frame, u8 els_code)
 
 u16
 fc_tprlo_acc_build(struct fchs_s *fchs, struct fc_tprlo_acc_s *tprlo_acc,
-                       u32 d_id, u32 s_id, u16 ox_id,
-                       int num_pages)
+               u32 d_id, u32 s_id, u16 ox_id, int num_pages)
 {
        int             page;
 
        fc_els_rsp_build(fchs, d_id, s_id, ox_id);
 
-       memset(tprlo_acc, 0, (num_pages * 16) + 4);
+       bfa_os_memset(tprlo_acc, 0, (num_pages * 16) + 4);
        tprlo_acc->command = FC_ELS_ACC;
 
        tprlo_acc->page_len = 0x10;
@@ -700,15 +689,14 @@ fc_tprlo_acc_build(struct fchs_s *fchs, struct fc_tprlo_acc_s *tprlo_acc,
 }
 
 u16
-fc_prlo_acc_build(struct fchs_s *fchs, struct fc_prlo_acc_s *prlo_acc,
-                       u32 d_id, u32 s_id, u16 ox_id,
-                       int num_pages)
+fc_prlo_acc_build(struct fchs_s *fchs, struct fc_prlo_acc_s *prlo_acc, u32 d_id,
+                 u32 s_id, u16 ox_id, int num_pages)
 {
        int             page;
 
        fc_els_rsp_build(fchs, d_id, s_id, ox_id);
 
-       memset(prlo_acc, 0, (num_pages * 16) + 4);
+       bfa_os_memset(prlo_acc, 0, (num_pages * 16) + 4);
        prlo_acc->command = FC_ELS_ACC;
        prlo_acc->page_len = 0x10;
        prlo_acc->payload_len = bfa_os_htons((num_pages * 16) + 4);
@@ -726,11 +714,11 @@ fc_prlo_acc_build(struct fchs_s *fchs, struct fc_prlo_acc_s *prlo_acc,
 
 u16
 fc_rnid_build(struct fchs_s *fchs, struct fc_rnid_cmd_s *rnid, u32 d_id,
-                       u32 s_id, u16 ox_id, u32 data_format)
+               u32 s_id, u16 ox_id, u32 data_format)
 {
        fc_els_req_build(fchs, d_id, s_id, ox_id);
 
-       memset(rnid, 0, sizeof(struct fc_rnid_cmd_s));
+       bfa_os_memset(rnid, 0, sizeof(struct fc_rnid_cmd_s));
 
        rnid->els_cmd.els_code = FC_ELS_RNID;
        rnid->node_id_data_format = data_format;
@@ -739,13 +727,12 @@ fc_rnid_build(struct fchs_s *fchs, struct fc_rnid_cmd_s *rnid, u32 d_id,
 }
 
 u16
-fc_rnid_acc_build(struct fchs_s *fchs, struct fc_rnid_acc_s *rnid_acc,
-                       u32 d_id, u32 s_id, u16 ox_id,
-                       u32 data_format,
-                       struct fc_rnid_common_id_data_s *common_id_data,
-                       struct fc_rnid_general_topology_data_s *gen_topo_data)
+fc_rnid_acc_build(struct fchs_s *fchs, struct fc_rnid_acc_s *rnid_acc, u32 d_id,
+                 u32 s_id, u16 ox_id, u32 data_format,
+                 struct fc_rnid_common_id_data_s *common_id_data,
+                 struct fc_rnid_general_topology_data_s *gen_topo_data)
 {
-       memset(rnid_acc, 0, sizeof(struct fc_rnid_acc_s));
+       bfa_os_memset(rnid_acc, 0, sizeof(struct fc_rnid_acc_s));
 
        fc_els_rsp_build(fchs, d_id, s_id, ox_id);
 
@@ -769,27 +756,26 @@ fc_rnid_acc_build(struct fchs_s *fchs, struct fc_rnid_acc_s *rnid_acc,
 
 u16
 fc_rpsc_build(struct fchs_s *fchs, struct fc_rpsc_cmd_s *rpsc, u32 d_id,
-                       u32 s_id, u16 ox_id)
+               u32 s_id, u16 ox_id)
 {
        fc_els_req_build(fchs, d_id, s_id, ox_id);
 
-       memset(rpsc, 0, sizeof(struct fc_rpsc_cmd_s));
+       bfa_os_memset(rpsc, 0, sizeof(struct fc_rpsc_cmd_s));
 
        rpsc->els_cmd.els_code = FC_ELS_RPSC;
        return sizeof(struct fc_rpsc_cmd_s);
 }
 
 u16
-fc_rpsc2_build(struct fchs_s *fchs, struct fc_rpsc2_cmd_s *rpsc2,
-                       u32 d_id, u32 s_id, u32 *pid_list,
-                       u16 npids)
+fc_rpsc2_build(struct fchs_s *fchs, struct fc_rpsc2_cmd_s *rpsc2, u32 d_id,
+               u32 s_id, u32 *pid_list, u16 npids)
 {
        u32 dctlr_id = FC_DOMAIN_CTRLR(bfa_os_hton3b(d_id));
        int i = 0;
 
        fc_els_req_build(fchs, bfa_os_hton3b(dctlr_id), s_id, 0);
 
-       memset(rpsc2, 0, sizeof(struct fc_rpsc2_cmd_s));
+       bfa_os_memset(rpsc2, 0, sizeof(struct fc_rpsc2_cmd_s));
 
        rpsc2->els_cmd.els_code = FC_ELS_RPSC;
        rpsc2->token = bfa_os_htonl(FC_BRCD_TOKEN);
@@ -797,16 +783,15 @@ fc_rpsc2_build(struct fchs_s *fchs, struct fc_rpsc2_cmd_s *rpsc2,
        for (i = 0; i < npids; i++)
                rpsc2->pid_list[i].pid = pid_list[i];
 
-       return sizeof(struct fc_rpsc2_cmd_s) + ((npids - 1) *
-                       (sizeof(u32)));
+       return sizeof(struct fc_rpsc2_cmd_s) + ((npids - 1) * (sizeof(u32)));
 }
 
 u16
 fc_rpsc_acc_build(struct fchs_s *fchs, struct fc_rpsc_acc_s *rpsc_acc,
-                       u32 d_id, u32 s_id, u16 ox_id,
-                       struct fc_rpsc_speed_info_s *oper_speed)
+               u32 d_id, u32 s_id, u16 ox_id,
+                 struct fc_rpsc_speed_info_s *oper_speed)
 {
-       memset(rpsc_acc, 0, sizeof(struct fc_rpsc_acc_s));
+       bfa_os_memset(rpsc_acc, 0, sizeof(struct fc_rpsc_acc_s));
 
        fc_els_rsp_build(fchs, d_id, s_id, ox_id);
 
@@ -820,7 +805,6 @@ fc_rpsc_acc_build(struct fchs_s *fchs, struct fc_rpsc_acc_s *rpsc_acc,
                bfa_os_htons(oper_speed->port_op_speed);
 
        return sizeof(struct fc_rpsc_acc_s);
-
 }
 
 /*
@@ -831,7 +815,7 @@ fc_rpsc_acc_build(struct fchs_s *fchs, struct fc_rpsc_acc_s *rpsc_acc,
 u16
 fc_logo_rsp_parse(struct fchs_s *fchs, int len)
 {
-       struct fc_els_cmd_s   *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
+       struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
 
        len = len;
        if (els_cmd->els_code != FC_ELS_ACC)
@@ -841,11 +825,10 @@ fc_logo_rsp_parse(struct fchs_s *fchs, int len)
 }
 
 u16
-fc_pdisc_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
-                       u16 ox_id, wwn_t port_name, wwn_t node_name,
-                       u16 pdu_size)
+fc_pdisc_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
+              wwn_t port_name, wwn_t node_name, u16 pdu_size)
 {
-       struct fc_logi_s     *pdisc = (struct fc_logi_s *) (fchs + 1);
+       struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
 
        bfa_os_memcpy(pdisc, &plogi_tmpl, sizeof(struct fc_logi_s));
 
@@ -862,7 +845,7 @@ fc_pdisc_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
 u16
 fc_pdisc_rsp_parse(struct fchs_s *fchs, int len, wwn_t port_name)
 {
-       struct fc_logi_s     *pdisc = (struct fc_logi_s *) (fchs + 1);
+       struct fc_logi_s *pdisc = (struct fc_logi_s *) (fchs + 1);
 
        if (len < sizeof(struct fc_logi_s))
                return FC_PARSE_LEN_INVAL;
@@ -886,11 +869,11 @@ u16
 fc_prlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
              int num_pages)
 {
-       struct fc_prlo_s      *prlo = (struct fc_prlo_s *) (fchs + 1);
+       struct fc_prlo_s *prlo = (struct fc_prlo_s *) (fchs + 1);
        int             page;
 
        fc_els_req_build(fchs, d_id, s_id, ox_id);
-       memset(prlo, 0, (num_pages * 16) + 4);
+       bfa_os_memset(prlo, 0, (num_pages * 16) + 4);
        prlo->command = FC_ELS_PRLO;
        prlo->page_len = 0x10;
        prlo->payload_len = bfa_os_htons((num_pages * 16) + 4);
@@ -909,7 +892,7 @@ fc_prlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
 u16
 fc_prlo_rsp_parse(struct fchs_s *fchs, int len)
 {
-       struct fc_prlo_acc_s  *prlo = (struct fc_prlo_acc_s *) (fchs + 1);
+       struct fc_prlo_acc_s *prlo = (struct fc_prlo_acc_s *) (fchs + 1);
        int             num_pages = 0;
        int             page = 0;
 
@@ -941,15 +924,14 @@ fc_prlo_rsp_parse(struct fchs_s *fchs, int len)
 }
 
 u16
-fc_tprlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
-                       u16 ox_id, int num_pages,
-                       enum fc_tprlo_type tprlo_type, u32 tpr_id)
+fc_tprlo_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
+              int num_pages, enum fc_tprlo_type tprlo_type, u32 tpr_id)
 {
-       struct fc_tprlo_s     *tprlo = (struct fc_tprlo_s *) (fchs + 1);
+       struct fc_tprlo_s *tprlo = (struct fc_tprlo_s *) (fchs + 1);
        int             page;
 
        fc_els_req_build(fchs, d_id, s_id, ox_id);
-       memset(tprlo, 0, (num_pages * 16) + 4);
+       bfa_os_memset(tprlo, 0, (num_pages * 16) + 4);
        tprlo->command = FC_ELS_TPRLO;
        tprlo->page_len = 0x10;
        tprlo->payload_len = bfa_os_htons((num_pages * 16) + 4);
@@ -1003,7 +985,7 @@ fc_tprlo_rsp_parse(struct fchs_s *fchs, int len)
 enum fc_parse_status
 fc_rrq_rsp_parse(struct fchs_s *fchs, int len)
 {
-       struct fc_els_cmd_s   *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
+       struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
 
        len = len;
        if (els_cmd->els_code != FC_ELS_ACC)
@@ -1013,11 +995,10 @@ fc_rrq_rsp_parse(struct fchs_s *fchs, int len)
 }
 
 u16
-fc_ba_rjt_build(struct fchs_s *fchs, u32 d_id, u32 s_id,
-                       u16 ox_id, u32 reason_code,
-                       u32 reason_expl)
+fc_ba_rjt_build(struct fchs_s *fchs, u32 d_id, u32 s_id, u16 ox_id,
+               u32 reason_code, u32 reason_expl)
 {
-       struct fc_ba_rjt_s    *ba_rjt = (struct fc_ba_rjt_s *) (fchs + 1);
+       struct fc_ba_rjt_s *ba_rjt = (struct fc_ba_rjt_s *) (fchs + 1);
 
        fc_bls_rsp_build(fchs, d_id, s_id, ox_id);
 
@@ -1062,10 +1043,8 @@ u16
 fc_gidpn_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
               wwn_t port_name)
 {
-
-       struct ct_hdr_s       *cthdr = (struct ct_hdr_s *) pyld;
-       struct fcgs_gidpn_req_s *gidpn =
-                       (struct fcgs_gidpn_req_s *) (cthdr + 1);
+       struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
+       struct fcgs_gidpn_req_s *gidpn = (struct fcgs_gidpn_req_s *)(cthdr + 1);
        u32        d_id = bfa_os_hton3b(FC_NAME_SERVER);
 
        fc_gs_fchdr_build(fchs, d_id, s_id, ox_id);
@@ -1080,8 +1059,7 @@ u16
 fc_gpnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
               u32 port_id)
 {
-
-       struct ct_hdr_s       *cthdr = (struct ct_hdr_s *) pyld;
+       struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
        fcgs_gpnid_req_t *gpnid = (fcgs_gpnid_req_t *) (cthdr + 1);
        u32        d_id = bfa_os_hton3b(FC_NAME_SERVER);
 
@@ -1097,8 +1075,7 @@ u16
 fc_gnnid_build(struct fchs_s *fchs, void *pyld, u32 s_id, u16 ox_id,
               u32 port_id)
 {
-
-       struct ct_hdr_s       *cthdr = (struct ct_hdr_s *) pyld;
+       struct ct_hdr_s *cthdr = (struct ct_hdr_s *) pyld;
        fcgs_gnnid_req_t *gnnid = (fcgs_gnnid_req_t *) (cthdr + 1);
        u32        d_id = bfa_os_hton3b(FC_NAME_SERVER);
 
@@ -1124,8 +1101,8 @@ fc_ct_rsp_parse(struct ct_hdr_s *cthdr)
 }
 
 u16
-fc_scr_build(struct fchs_s *fchs, struct fc_scr_s *scr, u8 set_br_reg,
-                       u32 s_id, u16 ox_id)
+fc_scr_build(struct fchs_s *fchs, struct fc_scr_s *scr,
+               u8 set_br_reg, u32 s_id, u16 ox_id)
 {
        u32        d_id = bfa_os_hton3b(FC_FABRIC_CONTROLLER);
 
@@ -1141,8 +1118,8 @@ fc_scr_build(struct fchs_s *fchs