blob: a08309fb981d13a94dde6574d8862a745b4862d3 [file] [log] [blame]
Jing Huang7725ccf2009-09-23 17:46:15 -07001/*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef __BFA_IOCFC_H__
19#define __BFA_IOCFC_H__
20
21#include <bfa_ioc.h>
22#include <bfa.h>
23#include <bfi/bfi_iocfc.h>
Jing Huangd9883542010-07-08 19:46:26 -070024#include <bfi/bfi_pbc.h>
Jing Huang7725ccf2009-09-23 17:46:15 -070025#include <bfa_callback_priv.h>
26
27#define BFA_REQQ_NELEMS_MIN (4)
28#define BFA_RSPQ_NELEMS_MIN (4)
29
30struct bfa_iocfc_regs_s {
31 bfa_os_addr_t intr_status;
32 bfa_os_addr_t intr_mask;
33 bfa_os_addr_t cpe_q_pi[BFI_IOC_MAX_CQS];
34 bfa_os_addr_t cpe_q_ci[BFI_IOC_MAX_CQS];
35 bfa_os_addr_t cpe_q_depth[BFI_IOC_MAX_CQS];
36 bfa_os_addr_t cpe_q_ctrl[BFI_IOC_MAX_CQS];
37 bfa_os_addr_t rme_q_ci[BFI_IOC_MAX_CQS];
38 bfa_os_addr_t rme_q_pi[BFI_IOC_MAX_CQS];
39 bfa_os_addr_t rme_q_depth[BFI_IOC_MAX_CQS];
40 bfa_os_addr_t rme_q_ctrl[BFI_IOC_MAX_CQS];
41};
42
43/**
44 * MSIX vector handlers
45 */
46#define BFA_MSIX_MAX_VECTORS 22
47typedef void (*bfa_msix_handler_t)(struct bfa_s *bfa, int vec);
48struct bfa_msix_s {
49 int nvecs;
50 bfa_msix_handler_t handler[BFA_MSIX_MAX_VECTORS];
51};
52
53/**
54 * Chip specific interfaces
55 */
56struct bfa_hwif_s {
57 void (*hw_reginit)(struct bfa_s *bfa);
Krishna Gudipatif5713c52010-03-05 19:37:09 -080058 void (*hw_reqq_ack)(struct bfa_s *bfa, int reqq);
Jing Huang7725ccf2009-09-23 17:46:15 -070059 void (*hw_rspq_ack)(struct bfa_s *bfa, int rspq);
60 void (*hw_msix_init)(struct bfa_s *bfa, int nvecs);
61 void (*hw_msix_install)(struct bfa_s *bfa);
62 void (*hw_msix_uninstall)(struct bfa_s *bfa);
63 void (*hw_isr_mode_set)(struct bfa_s *bfa, bfa_boolean_t msix);
64 void (*hw_msix_getvecs)(struct bfa_s *bfa, u32 *vecmap,
65 u32 *nvecs, u32 *maxvec);
66};
67typedef void (*bfa_cb_iocfc_t) (void *cbarg, enum bfa_status status);
68
69struct bfa_iocfc_s {
70 struct bfa_s *bfa;
71 struct bfa_iocfc_cfg_s cfg;
72 int action;
73
74 u32 req_cq_pi[BFI_IOC_MAX_CQS];
75 u32 rsp_cq_ci[BFI_IOC_MAX_CQS];
76
77 struct bfa_cb_qe_s init_hcb_qe;
78 struct bfa_cb_qe_s stop_hcb_qe;
79 struct bfa_cb_qe_s dis_hcb_qe;
80 struct bfa_cb_qe_s stats_hcb_qe;
81 bfa_boolean_t cfgdone;
82
83 struct bfa_dma_s cfg_info;
84 struct bfi_iocfc_cfg_s *cfginfo;
85 struct bfa_dma_s cfgrsp_dma;
86 struct bfi_iocfc_cfgrsp_s *cfgrsp;
87 struct bfi_iocfc_cfg_reply_s *cfg_reply;
88
89 u8 *stats_kva;
90 u64 stats_pa;
91 struct bfa_fw_stats_s *fw_stats;
92 struct bfa_timer_s stats_timer; /* timer */
93 struct bfa_iocfc_stats_s *stats_ret; /* driver stats location */
94 bfa_status_t stats_status; /* stats/statsclr status */
95 bfa_boolean_t stats_busy; /* outstanding stats */
96 bfa_cb_ioc_t stats_cbfn; /* driver callback function */
97 void *stats_cbarg; /* user callback arg */
98
99 struct bfa_dma_s req_cq_ba[BFI_IOC_MAX_CQS];
100 struct bfa_dma_s req_cq_shadow_ci[BFI_IOC_MAX_CQS];
101 struct bfa_dma_s rsp_cq_ba[BFI_IOC_MAX_CQS];
102 struct bfa_dma_s rsp_cq_shadow_pi[BFI_IOC_MAX_CQS];
103 struct bfa_iocfc_regs_s bfa_regs; /* BFA device registers */
104 struct bfa_hwif_s hwif;
105
106 bfa_cb_iocfc_t updateq_cbfn; /* bios callback function */
107 void *updateq_cbarg; /* bios callback arg */
108};
109
110#define bfa_lpuid(__bfa) bfa_ioc_portid(&(__bfa)->ioc)
111#define bfa_msix_init(__bfa, __nvecs) \
Jing Huangf8ceafd2009-09-25 12:29:54 -0700112 ((__bfa)->iocfc.hwif.hw_msix_init(__bfa, __nvecs))
Jing Huang7725ccf2009-09-23 17:46:15 -0700113#define bfa_msix_install(__bfa) \
Jing Huangf8ceafd2009-09-25 12:29:54 -0700114 ((__bfa)->iocfc.hwif.hw_msix_install(__bfa))
Jing Huang7725ccf2009-09-23 17:46:15 -0700115#define bfa_msix_uninstall(__bfa) \
Jing Huangf8ceafd2009-09-25 12:29:54 -0700116 ((__bfa)->iocfc.hwif.hw_msix_uninstall(__bfa))
Jing Huang7725ccf2009-09-23 17:46:15 -0700117#define bfa_isr_mode_set(__bfa, __msix) \
Jing Huangf8ceafd2009-09-25 12:29:54 -0700118 ((__bfa)->iocfc.hwif.hw_isr_mode_set(__bfa, __msix))
Jing Huang7725ccf2009-09-23 17:46:15 -0700119#define bfa_msix_getvecs(__bfa, __vecmap, __nvecs, __maxvec) \
Jing Huanged969322010-07-08 19:45:56 -0700120 ((__bfa)->iocfc.hwif.hw_msix_getvecs(__bfa, __vecmap, \
121 __nvecs, __maxvec))
Jing Huang7725ccf2009-09-23 17:46:15 -0700122
123/*
124 * FC specific IOC functions.
125 */
126void bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
127 u32 *dm_len);
128void bfa_iocfc_attach(struct bfa_s *bfa, void *bfad,
129 struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo,
130 struct bfa_pcidev_s *pcidev);
131void bfa_iocfc_detach(struct bfa_s *bfa);
132void bfa_iocfc_init(struct bfa_s *bfa);
133void bfa_iocfc_start(struct bfa_s *bfa);
134void bfa_iocfc_stop(struct bfa_s *bfa);
135void bfa_iocfc_isr(void *bfa, struct bfi_mbmsg_s *msg);
136void bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa);
137bfa_boolean_t bfa_iocfc_is_operational(struct bfa_s *bfa);
138void bfa_iocfc_reset_queues(struct bfa_s *bfa);
139void bfa_iocfc_updateq(struct bfa_s *bfa, u32 reqq_ba, u32 rspq_ba,
140 u32 reqq_sci, u32 rspq_spi,
141 bfa_cb_iocfc_t cbfn, void *cbarg);
142
143void bfa_msix_all(struct bfa_s *bfa, int vec);
144void bfa_msix_reqq(struct bfa_s *bfa, int vec);
145void bfa_msix_rspq(struct bfa_s *bfa, int vec);
146void bfa_msix_lpu_err(struct bfa_s *bfa, int vec);
147
148void bfa_hwcb_reginit(struct bfa_s *bfa);
Krishna Gudipatif5713c52010-03-05 19:37:09 -0800149void bfa_hwcb_reqq_ack(struct bfa_s *bfa, int rspq);
Jing Huang7725ccf2009-09-23 17:46:15 -0700150void bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq);
151void bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs);
152void bfa_hwcb_msix_install(struct bfa_s *bfa);
153void bfa_hwcb_msix_uninstall(struct bfa_s *bfa);
154void bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
155void bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *vecmap,
156 u32 *nvecs, u32 *maxvec);
157void bfa_hwct_reginit(struct bfa_s *bfa);
Krishna Gudipatif5713c52010-03-05 19:37:09 -0800158void bfa_hwct_reqq_ack(struct bfa_s *bfa, int rspq);
Jing Huang7725ccf2009-09-23 17:46:15 -0700159void bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq);
160void bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs);
161void bfa_hwct_msix_install(struct bfa_s *bfa);
162void bfa_hwct_msix_uninstall(struct bfa_s *bfa);
163void bfa_hwct_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
164void bfa_hwct_msix_getvecs(struct bfa_s *bfa, u32 *vecmap,
165 u32 *nvecs, u32 *maxvec);
166
167void bfa_com_meminfo(bfa_boolean_t mincfg, u32 *dm_len);
168void bfa_com_attach(struct bfa_s *bfa, struct bfa_meminfo_s *mi,
169 bfa_boolean_t mincfg);
170void bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t **wwns);
Jing Huanged969322010-07-08 19:45:56 -0700171void bfa_iocfc_get_pbc_boot_cfg(struct bfa_s *bfa,
172 struct bfa_boot_pbc_s *pbcfg);
Jing Huangd9883542010-07-08 19:46:26 -0700173int bfa_iocfc_get_pbc_vports(struct bfa_s *bfa,
174 struct bfi_pbc_vport_s *pbc_vport);
Jing Huang7725ccf2009-09-23 17:46:15 -0700175
176#endif /* __BFA_IOCFC_H__ */
177