blob: d52b32f5695cc40d68f716a28789d56a4753f07d [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#ifndef __BFA_H__
18#define __BFA_H__
19
20#include <bfa_os_inc.h>
21#include <cs/bfa_debug.h>
22#include <cs/bfa_q.h>
23#include <cs/bfa_trc.h>
24#include <cs/bfa_log.h>
25#include <cs/bfa_plog.h>
26#include <defs/bfa_defs_status.h>
27#include <defs/bfa_defs_ioc.h>
28#include <defs/bfa_defs_iocfc.h>
29#include <aen/bfa_aen.h>
30#include <bfi/bfi.h>
31
32struct bfa_s;
33#include <bfa_intr_priv.h>
34
35struct bfa_pcidev_s;
36
37/**
38 * PCI devices supported by the current BFA
39 */
40struct bfa_pciid_s {
41 u16 device_id;
42 u16 vendor_id;
43};
44
45extern char bfa_version[];
46
47/**
48 * BFA Power Mgmt Commands
49 */
50enum bfa_pm_cmd {
51 BFA_PM_CTL_D0 = 0,
52 BFA_PM_CTL_D1 = 1,
53 BFA_PM_CTL_D2 = 2,
54 BFA_PM_CTL_D3 = 3,
55};
56
57/**
58 * BFA memory resources
59 */
60enum bfa_mem_type {
61 BFA_MEM_TYPE_KVA = 1, /*! Kernel Virtual Memory *(non-dma-able) */
62 BFA_MEM_TYPE_DMA = 2, /*! DMA-able memory */
63 BFA_MEM_TYPE_MAX = BFA_MEM_TYPE_DMA,
64};
65
66struct bfa_mem_elem_s {
67 enum bfa_mem_type mem_type; /* see enum bfa_mem_type */
68 u32 mem_len; /* Total Length in Bytes */
69 u8 *kva; /* kernel virtual address */
70 u64 dma; /* dma address if DMA memory */
71 u8 *kva_curp; /* kva allocation cursor */
72 u64 dma_curp; /* dma allocation cursor */
73};
74
75struct bfa_meminfo_s {
76 struct bfa_mem_elem_s meminfo[BFA_MEM_TYPE_MAX];
77};
78#define bfa_meminfo_kva(_m) \
Jing Huangf8ceafd2009-09-25 12:29:54 -070079 ((_m)->meminfo[BFA_MEM_TYPE_KVA - 1].kva_curp)
Jing Huang7725ccf2009-09-23 17:46:15 -070080#define bfa_meminfo_dma_virt(_m) \
Jing Huangf8ceafd2009-09-25 12:29:54 -070081 ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].kva_curp)
Jing Huang7725ccf2009-09-23 17:46:15 -070082#define bfa_meminfo_dma_phys(_m) \
Jing Huangf8ceafd2009-09-25 12:29:54 -070083 ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].dma_curp)
Jing Huang7725ccf2009-09-23 17:46:15 -070084
85/**
86 * Generic Scatter Gather Element used by driver
87 */
88struct bfa_sge_s {
89 u32 sg_len;
90 void *sg_addr;
91};
92
93#define bfa_sge_to_be(__sge) do { \
94 ((u32 *)(__sge))[0] = bfa_os_htonl(((u32 *)(__sge))[0]); \
95 ((u32 *)(__sge))[1] = bfa_os_htonl(((u32 *)(__sge))[1]); \
96 ((u32 *)(__sge))[2] = bfa_os_htonl(((u32 *)(__sge))[2]); \
97} while (0)
98
99
100/*
101 * bfa stats interfaces
102 */
Jing Huangf8ceafd2009-09-25 12:29:54 -0700103#define bfa_stats(_mod, _stats) ((_mod)->stats._stats++)
Jing Huang7725ccf2009-09-23 17:46:15 -0700104
105#define bfa_ioc_get_stats(__bfa, __ioc_stats) \
106 bfa_ioc_fetch_stats(&(__bfa)->ioc, __ioc_stats)
107#define bfa_ioc_clear_stats(__bfa) \
108 bfa_ioc_clr_stats(&(__bfa)->ioc)
Krishna Gudipati0a4b1fc2010-03-05 19:37:57 -0800109#define bfa_get_nports(__bfa) \
110 bfa_ioc_get_nports(&(__bfa)->ioc)
111#define bfa_get_adapter_manufacturer(__bfa, __manufacturer) \
112 bfa_ioc_get_adapter_manufacturer(&(__bfa)->ioc, __manufacturer)
113#define bfa_get_adapter_model(__bfa, __model) \
114 bfa_ioc_get_adapter_model(&(__bfa)->ioc, __model)
115#define bfa_get_adapter_serial_num(__bfa, __serial_num) \
116 bfa_ioc_get_adapter_serial_num(&(__bfa)->ioc, __serial_num)
117#define bfa_get_adapter_fw_ver(__bfa, __fw_ver) \
118 bfa_ioc_get_adapter_fw_ver(&(__bfa)->ioc, __fw_ver)
119#define bfa_get_adapter_optrom_ver(__bfa, __optrom_ver) \
120 bfa_ioc_get_adapter_optrom_ver(&(__bfa)->ioc, __optrom_ver)
121#define bfa_get_pci_chip_rev(__bfa, __chip_rev) \
122 bfa_ioc_get_pci_chip_rev(&(__bfa)->ioc, __chip_rev)
123#define bfa_get_ioc_state(__bfa) \
124 bfa_ioc_get_state(&(__bfa)->ioc)
125#define bfa_get_type(__bfa) \
126 bfa_ioc_get_type(&(__bfa)->ioc)
127#define bfa_get_mac(__bfa) \
128 bfa_ioc_get_mac(&(__bfa)->ioc)
Jing Huang07b28382010-07-08 19:59:24 -0700129#define bfa_get_mfg_mac(__bfa) \
130 bfa_ioc_get_mfg_mac(&(__bfa)->ioc)
Jing Huangb85d0452010-07-08 19:48:49 -0700131#define bfa_get_fw_clock_res(__bfa) \
132 ((__bfa)->iocfc.cfgrsp->fwcfg.fw_tick_res)
Jing Huang7725ccf2009-09-23 17:46:15 -0700133
134/*
135 * bfa API functions
136 */
137void bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids);
138void bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg);
139void bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg);
140void bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg,
141 struct bfa_meminfo_s *meminfo);
142void bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
143 struct bfa_meminfo_s *meminfo,
144 struct bfa_pcidev_s *pcidev);
145void bfa_init_trc(struct bfa_s *bfa, struct bfa_trc_mod_s *trcmod);
146void bfa_init_log(struct bfa_s *bfa, struct bfa_log_mod_s *logmod);
147void bfa_init_aen(struct bfa_s *bfa, struct bfa_aen_s *aen);
148void bfa_init_plog(struct bfa_s *bfa, struct bfa_plog_s *plog);
149void bfa_detach(struct bfa_s *bfa);
150void bfa_init(struct bfa_s *bfa);
151void bfa_start(struct bfa_s *bfa);
152void bfa_stop(struct bfa_s *bfa);
153void bfa_attach_fcs(struct bfa_s *bfa);
154void bfa_cb_init(void *bfad, bfa_status_t status);
155void bfa_cb_stop(void *bfad, bfa_status_t status);
156void bfa_cb_updateq(void *bfad, bfa_status_t status);
157
158bfa_boolean_t bfa_intx(struct bfa_s *bfa);
159void bfa_isr_enable(struct bfa_s *bfa);
160void bfa_isr_disable(struct bfa_s *bfa);
161void bfa_msix_getvecs(struct bfa_s *bfa, u32 *msix_vecs_bmap,
162 u32 *num_vecs, u32 *max_vec_bit);
Jing Huangf8ceafd2009-09-25 12:29:54 -0700163#define bfa_msix(__bfa, __vec) ((__bfa)->msix.handler[__vec](__bfa, __vec))
Jing Huang7725ccf2009-09-23 17:46:15 -0700164
165void bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q);
166void bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q);
167void bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q);
168
169typedef void (*bfa_cb_ioc_t) (void *cbarg, enum bfa_status status);
170void bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr);
171bfa_status_t bfa_iocfc_get_stats(struct bfa_s *bfa,
172 struct bfa_iocfc_stats_s *stats,
173 bfa_cb_ioc_t cbfn, void *cbarg);
174bfa_status_t bfa_iocfc_clear_stats(struct bfa_s *bfa,
175 bfa_cb_ioc_t cbfn, void *cbarg);
176void bfa_get_attr(struct bfa_s *bfa, struct bfa_ioc_attr_s *ioc_attr);
177
178void bfa_adapter_get_attr(struct bfa_s *bfa,
179 struct bfa_adapter_attr_s *ad_attr);
180u64 bfa_adapter_get_id(struct bfa_s *bfa);
181
182bfa_status_t bfa_iocfc_israttr_set(struct bfa_s *bfa,
183 struct bfa_iocfc_intr_attr_s *attr);
184
185void bfa_iocfc_enable(struct bfa_s *bfa);
186void bfa_iocfc_disable(struct bfa_s *bfa);
187void bfa_ioc_auto_recover(bfa_boolean_t auto_recover);
Krishna Gudipati0a20de42010-03-05 19:34:20 -0800188void bfa_chip_reset(struct bfa_s *bfa);
Jing Huang7725ccf2009-09-23 17:46:15 -0700189void bfa_cb_ioc_disable(void *bfad);
190void bfa_timer_tick(struct bfa_s *bfa);
191#define bfa_timer_start(_bfa, _timer, _timercb, _arg, _timeout) \
192 bfa_timer_begin(&(_bfa)->timer_mod, _timer, _timercb, _arg, _timeout)
193
194/*
195 * BFA debug API functions
196 */
197bfa_status_t bfa_debug_fwtrc(struct bfa_s *bfa, void *trcdata, int *trclen);
198bfa_status_t bfa_debug_fwsave(struct bfa_s *bfa, void *trcdata, int *trclen);
Krishna Gudipati738c9e62010-03-05 19:36:19 -0800199void bfa_debug_fwsave_clear(struct bfa_s *bfa);
Jing Huang7725ccf2009-09-23 17:46:15 -0700200
201#include "bfa_priv.h"
202
203#endif /* __BFA_H__ */