xref: /openbmc/linux/drivers/net/ethernet/brocade/bna/bfa_ioc.h (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
152fa7bf9SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2f844a0eaSJeff Kirsher /*
32732ba56SRasesh Mody  * Linux network driver for QLogic BR-series Converged Network Adapter.
4f844a0eaSJeff Kirsher  */
5f844a0eaSJeff Kirsher /*
62732ba56SRasesh Mody  * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
72732ba56SRasesh Mody  * Copyright (c) 2014-2015 QLogic Corporation
8f844a0eaSJeff Kirsher  * All rights reserved
92732ba56SRasesh Mody  * www.qlogic.com
10f844a0eaSJeff Kirsher  */
11f844a0eaSJeff Kirsher 
12f844a0eaSJeff Kirsher #ifndef __BFA_IOC_H__
13f844a0eaSJeff Kirsher #define __BFA_IOC_H__
14f844a0eaSJeff Kirsher 
15f844a0eaSJeff Kirsher #include "bfa_cs.h"
16f844a0eaSJeff Kirsher #include "bfi.h"
17f844a0eaSJeff Kirsher #include "cna.h"
18f844a0eaSJeff Kirsher 
19f844a0eaSJeff Kirsher #define BFA_IOC_TOV		3000	/* msecs */
20f844a0eaSJeff Kirsher #define BFA_IOC_HWSEM_TOV	500	/* msecs */
21f844a0eaSJeff Kirsher #define BFA_IOC_HB_TOV		500	/* msecs */
22078086f3SRasesh Mody #define BFA_IOC_POLL_TOV	200	/* msecs */
237afc5dbdSKrishna Gudipati #define BNA_DBG_FWTRC_LEN      (BFI_IOC_TRC_ENTS * BFI_IOC_TRC_ENT_SZ + \
247afc5dbdSKrishna Gudipati 				BFI_IOC_TRC_HDR_SZ)
25f844a0eaSJeff Kirsher 
261aa8b471SBen Hutchings /* PCI device information required by IOC */
27f844a0eaSJeff Kirsher struct bfa_pcidev {
28f844a0eaSJeff Kirsher 	int	pci_slot;
29f844a0eaSJeff Kirsher 	u8	pci_func;
30f844a0eaSJeff Kirsher 	u16	device_id;
31586b2816SRasesh Mody 	u16	ssid;
32f844a0eaSJeff Kirsher 	void	__iomem *pci_bar_kva;
33f844a0eaSJeff Kirsher };
34f844a0eaSJeff Kirsher 
351aa8b471SBen Hutchings /* Structure used to remember the DMA-able memory block's KVA and Physical
36f844a0eaSJeff Kirsher  * Address
37f844a0eaSJeff Kirsher  */
38f844a0eaSJeff Kirsher struct bfa_dma {
39f844a0eaSJeff Kirsher 	void	*kva;	/* ! Kernel virtual address	*/
40f844a0eaSJeff Kirsher 	u64	pa;	/* ! Physical address		*/
41f844a0eaSJeff Kirsher };
42f844a0eaSJeff Kirsher 
43f844a0eaSJeff Kirsher #define BFA_DMA_ALIGN_SZ	256
44f844a0eaSJeff Kirsher 
451aa8b471SBen Hutchings /* smem size for Crossbow and Catapult */
46f844a0eaSJeff Kirsher #define BFI_SMEM_CB_SIZE	0x200000U	/* ! 2MB for crossbow	*/
47f844a0eaSJeff Kirsher #define BFI_SMEM_CT_SIZE	0x280000U	/* ! 2.5MB for catapult	*/
48f844a0eaSJeff Kirsher 
491aa8b471SBen Hutchings /* BFA dma address assignment macro. (big endian format) */
50f844a0eaSJeff Kirsher #define bfa_dma_be_addr_set(dma_addr, pa)	\
51f844a0eaSJeff Kirsher 		__bfa_dma_be_addr_set(&dma_addr, (u64)pa)
52f844a0eaSJeff Kirsher static inline void
__bfa_dma_be_addr_set(union bfi_addr_u * dma_addr,u64 pa)53f844a0eaSJeff Kirsher __bfa_dma_be_addr_set(union bfi_addr_u *dma_addr, u64 pa)
54f844a0eaSJeff Kirsher {
55f844a0eaSJeff Kirsher 	dma_addr->a32.addr_lo = (u32) htonl(pa);
56f844a0eaSJeff Kirsher 	dma_addr->a32.addr_hi = (u32) htonl(upper_32_bits(pa));
57f844a0eaSJeff Kirsher }
58f844a0eaSJeff Kirsher 
5972a9730bSKrishna Gudipati #define bfa_alen_set(__alen, __len, __pa)	\
6072a9730bSKrishna Gudipati 	__bfa_alen_set(__alen, __len, (u64)__pa)
6172a9730bSKrishna Gudipati 
6272a9730bSKrishna Gudipati static inline void
__bfa_alen_set(struct bfi_alen * alen,u32 len,u64 pa)6372a9730bSKrishna Gudipati __bfa_alen_set(struct bfi_alen *alen, u32 len, u64 pa)
6472a9730bSKrishna Gudipati {
6572a9730bSKrishna Gudipati 	alen->al_len = cpu_to_be32(len);
6672a9730bSKrishna Gudipati 	bfa_dma_be_addr_set(alen->al_addr, pa);
6772a9730bSKrishna Gudipati }
6872a9730bSKrishna Gudipati 
69f844a0eaSJeff Kirsher struct bfa_ioc_regs {
70f844a0eaSJeff Kirsher 	void __iomem *hfn_mbox_cmd;
71f844a0eaSJeff Kirsher 	void __iomem *hfn_mbox;
72f844a0eaSJeff Kirsher 	void __iomem *lpu_mbox_cmd;
73f844a0eaSJeff Kirsher 	void __iomem *lpu_mbox;
74be3a84d1SRasesh Mody 	void __iomem *lpu_read_stat;
75f844a0eaSJeff Kirsher 	void __iomem *pss_ctl_reg;
76f844a0eaSJeff Kirsher 	void __iomem *pss_err_status_reg;
77f844a0eaSJeff Kirsher 	void __iomem *app_pll_fast_ctl_reg;
78f844a0eaSJeff Kirsher 	void __iomem *app_pll_slow_ctl_reg;
79f844a0eaSJeff Kirsher 	void __iomem *ioc_sem_reg;
80f844a0eaSJeff Kirsher 	void __iomem *ioc_usage_sem_reg;
81f844a0eaSJeff Kirsher 	void __iomem *ioc_init_sem_reg;
82f844a0eaSJeff Kirsher 	void __iomem *ioc_usage_reg;
83f844a0eaSJeff Kirsher 	void __iomem *host_page_num_fn;
84f844a0eaSJeff Kirsher 	void __iomem *heartbeat;
85f844a0eaSJeff Kirsher 	void __iomem *ioc_fwstate;
86f844a0eaSJeff Kirsher 	void __iomem *alt_ioc_fwstate;
87f844a0eaSJeff Kirsher 	void __iomem *ll_halt;
88f844a0eaSJeff Kirsher 	void __iomem *alt_ll_halt;
89f844a0eaSJeff Kirsher 	void __iomem *err_set;
90f844a0eaSJeff Kirsher 	void __iomem *ioc_fail_sync;
91f844a0eaSJeff Kirsher 	void __iomem *shirq_isr_next;
92f844a0eaSJeff Kirsher 	void __iomem *shirq_msk_next;
93f844a0eaSJeff Kirsher 	void __iomem *smem_page_start;
94f844a0eaSJeff Kirsher 	u32	smem_pg0;
95f844a0eaSJeff Kirsher };
96f844a0eaSJeff Kirsher 
971aa8b471SBen Hutchings /* IOC Mailbox structures */
98f844a0eaSJeff Kirsher typedef void (*bfa_mbox_cmd_cbfn_t)(void *cbarg);
99f844a0eaSJeff Kirsher struct bfa_mbox_cmd {
100f844a0eaSJeff Kirsher 	struct list_head	qe;
101f844a0eaSJeff Kirsher 	bfa_mbox_cmd_cbfn_t     cbfn;
102f844a0eaSJeff Kirsher 	void		    *cbarg;
103f844a0eaSJeff Kirsher 	u32     msg[BFI_IOC_MSGSZ];
104f844a0eaSJeff Kirsher };
105f844a0eaSJeff Kirsher 
1061aa8b471SBen Hutchings /* IOC mailbox module */
107f844a0eaSJeff Kirsher typedef void (*bfa_ioc_mbox_mcfunc_t)(void *cbarg, struct bfi_mbmsg *m);
108f844a0eaSJeff Kirsher struct bfa_ioc_mbox_mod {
109f844a0eaSJeff Kirsher 	struct list_head	cmd_q;		/*!< pending mbox queue	*/
110f844a0eaSJeff Kirsher 	int			nmclass;	/*!< number of handlers */
111f844a0eaSJeff Kirsher 	struct {
112f844a0eaSJeff Kirsher 		bfa_ioc_mbox_mcfunc_t	cbfn;	/*!< message handlers	*/
113f844a0eaSJeff Kirsher 		void			*cbarg;
114f844a0eaSJeff Kirsher 	} mbhdlr[BFI_MC_MAX];
115f844a0eaSJeff Kirsher };
116f844a0eaSJeff Kirsher 
1171aa8b471SBen Hutchings /* IOC callback function interfaces */
118f844a0eaSJeff Kirsher typedef void (*bfa_ioc_enable_cbfn_t)(void *bfa, enum bfa_status status);
119f844a0eaSJeff Kirsher typedef void (*bfa_ioc_disable_cbfn_t)(void *bfa);
120f844a0eaSJeff Kirsher typedef void (*bfa_ioc_hbfail_cbfn_t)(void *bfa);
121f844a0eaSJeff Kirsher typedef void (*bfa_ioc_reset_cbfn_t)(void *bfa);
122f844a0eaSJeff Kirsher struct bfa_ioc_cbfn {
123f844a0eaSJeff Kirsher 	bfa_ioc_enable_cbfn_t	enable_cbfn;
124f844a0eaSJeff Kirsher 	bfa_ioc_disable_cbfn_t	disable_cbfn;
125f844a0eaSJeff Kirsher 	bfa_ioc_hbfail_cbfn_t	hbfail_cbfn;
126f844a0eaSJeff Kirsher 	bfa_ioc_reset_cbfn_t	reset_cbfn;
127f844a0eaSJeff Kirsher };
128f844a0eaSJeff Kirsher 
1291aa8b471SBen Hutchings /* IOC event notification mechanism. */
130f844a0eaSJeff Kirsher enum bfa_ioc_event {
131f844a0eaSJeff Kirsher 	BFA_IOC_E_ENABLED	= 1,
132f844a0eaSJeff Kirsher 	BFA_IOC_E_DISABLED	= 2,
133f844a0eaSJeff Kirsher 	BFA_IOC_E_FAILED	= 3,
134f844a0eaSJeff Kirsher };
135f844a0eaSJeff Kirsher 
136f844a0eaSJeff Kirsher typedef void (*bfa_ioc_notify_cbfn_t)(void *, enum bfa_ioc_event);
137f844a0eaSJeff Kirsher 
138f844a0eaSJeff Kirsher struct bfa_ioc_notify {
139f844a0eaSJeff Kirsher 	struct list_head	qe;
140f844a0eaSJeff Kirsher 	bfa_ioc_notify_cbfn_t	cbfn;
141f844a0eaSJeff Kirsher 	void			*cbarg;
142f844a0eaSJeff Kirsher };
143f844a0eaSJeff Kirsher 
1441aa8b471SBen Hutchings /* Initialize a IOC event notification structure */
145f844a0eaSJeff Kirsher #define bfa_ioc_notify_init(__notify, __cbfn, __cbarg) do {	\
146f844a0eaSJeff Kirsher 	(__notify)->cbfn = (__cbfn);				\
147f844a0eaSJeff Kirsher 	(__notify)->cbarg = (__cbarg);				\
148f844a0eaSJeff Kirsher } while (0)
149f844a0eaSJeff Kirsher 
150*8719a1c3SGustavo A. R. Silva enum iocpf_event;
151*8719a1c3SGustavo A. R. Silva 
152f844a0eaSJeff Kirsher struct bfa_iocpf {
153*8719a1c3SGustavo A. R. Silva 	void (*fsm)(struct bfa_iocpf *s, enum iocpf_event e);
154f844a0eaSJeff Kirsher 	struct bfa_ioc		*ioc;
155078086f3SRasesh Mody 	bool			fw_mismatch_notified;
156f844a0eaSJeff Kirsher 	bool			auto_recover;
157078086f3SRasesh Mody 	u32			poll_time;
158f844a0eaSJeff Kirsher };
159f844a0eaSJeff Kirsher 
160*8719a1c3SGustavo A. R. Silva enum ioc_event;
161*8719a1c3SGustavo A. R. Silva 
162f844a0eaSJeff Kirsher struct bfa_ioc {
163*8719a1c3SGustavo A. R. Silva 	void (*fsm)(struct bfa_ioc *s, enum ioc_event e);
164f844a0eaSJeff Kirsher 	struct bfa		*bfa;
165f844a0eaSJeff Kirsher 	struct bfa_pcidev	pcidev;
166f844a0eaSJeff Kirsher 	struct timer_list	ioc_timer;
167f844a0eaSJeff Kirsher 	struct timer_list	iocpf_timer;
168f844a0eaSJeff Kirsher 	struct timer_list	sem_timer;
169f844a0eaSJeff Kirsher 	struct timer_list	hb_timer;
170f844a0eaSJeff Kirsher 	u32			hb_count;
171f844a0eaSJeff Kirsher 	struct list_head	notify_q;
172f844a0eaSJeff Kirsher 	void			*dbg_fwsave;
173f844a0eaSJeff Kirsher 	int			dbg_fwsave_len;
174f844a0eaSJeff Kirsher 	bool			dbg_fwsave_once;
175078086f3SRasesh Mody 	enum bfi_pcifn_class	clscode;
176f844a0eaSJeff Kirsher 	struct bfa_ioc_regs	ioc_regs;
177f844a0eaSJeff Kirsher 	struct bfa_ioc_drv_stats stats;
178f844a0eaSJeff Kirsher 	bool			fcmode;
179f844a0eaSJeff Kirsher 	bool			pllinit;
180f844a0eaSJeff Kirsher 	bool			stats_busy;	/*!< outstanding stats */
181f844a0eaSJeff Kirsher 	u8			port_id;
182f844a0eaSJeff Kirsher 
183f844a0eaSJeff Kirsher 	struct bfa_dma		attr_dma;
184f844a0eaSJeff Kirsher 	struct bfi_ioc_attr	*attr;
185f844a0eaSJeff Kirsher 	struct bfa_ioc_cbfn	*cbfn;
186f844a0eaSJeff Kirsher 	struct bfa_ioc_mbox_mod	mbox_mod;
187d91d25d5Sstephen hemminger 	const struct bfa_ioc_hwif *ioc_hwif;
188f844a0eaSJeff Kirsher 	struct bfa_iocpf	iocpf;
189078086f3SRasesh Mody 	enum bfi_asic_gen	asic_gen;
190078086f3SRasesh Mody 	enum bfi_asic_mode	asic_mode;
191078086f3SRasesh Mody 	enum bfi_port_mode	port0_mode;
192078086f3SRasesh Mody 	enum bfi_port_mode	port1_mode;
193078086f3SRasesh Mody 	enum bfa_mode		port_mode;
194078086f3SRasesh Mody 	u8			ad_cap_bm;	/*!< adapter cap bit mask */
195078086f3SRasesh Mody 	u8			port_mode_cfg;	/*!< config port mode */
196f844a0eaSJeff Kirsher };
197f844a0eaSJeff Kirsher 
198f844a0eaSJeff Kirsher struct bfa_ioc_hwif {
199078086f3SRasesh Mody 	enum bfa_status (*ioc_pll_init) (void __iomem *rb,
200078086f3SRasesh Mody 						enum bfi_asic_mode m);
201f844a0eaSJeff Kirsher 	bool		(*ioc_firmware_lock)	(struct bfa_ioc *ioc);
202f844a0eaSJeff Kirsher 	void		(*ioc_firmware_unlock)	(struct bfa_ioc *ioc);
203f844a0eaSJeff Kirsher 	void		(*ioc_reg_init)	(struct bfa_ioc *ioc);
204f844a0eaSJeff Kirsher 	void		(*ioc_map_port)	(struct bfa_ioc *ioc);
205f844a0eaSJeff Kirsher 	void		(*ioc_isr_mode_set)	(struct bfa_ioc *ioc,
206f844a0eaSJeff Kirsher 					bool msix);
207f844a0eaSJeff Kirsher 	void		(*ioc_notify_fail)	(struct bfa_ioc *ioc);
208f844a0eaSJeff Kirsher 	void		(*ioc_ownership_reset)	(struct bfa_ioc *ioc);
209f844a0eaSJeff Kirsher 	bool		(*ioc_sync_start)       (struct bfa_ioc *ioc);
210f844a0eaSJeff Kirsher 	void		(*ioc_sync_join)	(struct bfa_ioc *ioc);
211f844a0eaSJeff Kirsher 	void		(*ioc_sync_leave)	(struct bfa_ioc *ioc);
212f844a0eaSJeff Kirsher 	void		(*ioc_sync_ack)		(struct bfa_ioc *ioc);
213f844a0eaSJeff Kirsher 	bool		(*ioc_sync_complete)	(struct bfa_ioc *ioc);
214078086f3SRasesh Mody 	bool		(*ioc_lpu_read_stat)	(struct bfa_ioc *ioc);
21541ed903aSRasesh Mody 	void		(*ioc_set_fwstate)	(struct bfa_ioc *ioc,
21641ed903aSRasesh Mody 					enum bfi_ioc_state fwstate);
21741ed903aSRasesh Mody 	enum bfi_ioc_state (*ioc_get_fwstate) (struct bfa_ioc *ioc);
21841ed903aSRasesh Mody 	void		(*ioc_set_alt_fwstate)	(struct bfa_ioc *ioc,
21941ed903aSRasesh Mody 					enum bfi_ioc_state fwstate);
22041ed903aSRasesh Mody 	enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc *ioc);
22141ed903aSRasesh Mody 
222f844a0eaSJeff Kirsher };
223f844a0eaSJeff Kirsher 
224f844a0eaSJeff Kirsher #define bfa_ioc_pcifn(__ioc)		((__ioc)->pcidev.pci_func)
225f844a0eaSJeff Kirsher #define bfa_ioc_devid(__ioc)		((__ioc)->pcidev.device_id)
226f844a0eaSJeff Kirsher #define bfa_ioc_bar0(__ioc)		((__ioc)->pcidev.pci_bar_kva)
227f844a0eaSJeff Kirsher #define bfa_ioc_portid(__ioc)		((__ioc)->port_id)
228078086f3SRasesh Mody #define bfa_ioc_asic_gen(__ioc)		((__ioc)->asic_gen)
22943c07adaSRasesh Mody #define bfa_ioc_is_default(__ioc)	\
23043c07adaSRasesh Mody 	(bfa_ioc_pcifn(__ioc) == bfa_ioc_portid(__ioc))
231f844a0eaSJeff Kirsher #define bfa_ioc_speed_sup(__ioc)	\
232f844a0eaSJeff Kirsher 	BFI_ADAPTER_GETP(SPEED, (__ioc)->attr->adapter_prop)
233f844a0eaSJeff Kirsher #define bfa_ioc_get_nports(__ioc)	\
234f844a0eaSJeff Kirsher 	BFI_ADAPTER_GETP(NPORTS, (__ioc)->attr->adapter_prop)
235f844a0eaSJeff Kirsher 
236f844a0eaSJeff Kirsher #define bfa_ioc_stats(_ioc, _stats)	((_ioc)->stats._stats++)
237f844a0eaSJeff Kirsher #define bfa_ioc_stats_hb_count(_ioc, _hb_count)	\
238f844a0eaSJeff Kirsher 	((_ioc)->stats.hb_count = (_hb_count))
239f844a0eaSJeff Kirsher #define BFA_IOC_FWIMG_MINSZ	(16 * 1024)
240f844a0eaSJeff Kirsher #define BFA_IOC_FW_SMEM_SIZE(__ioc)					\
241078086f3SRasesh Mody 	((bfa_ioc_asic_gen(__ioc) == BFI_ASIC_GEN_CB)			\
242078086f3SRasesh Mody 	? BFI_SMEM_CB_SIZE : BFI_SMEM_CT_SIZE)
243f844a0eaSJeff Kirsher #define BFA_IOC_FLASH_CHUNK_NO(off)		(off / BFI_FLASH_CHUNK_SZ_WORDS)
244f844a0eaSJeff Kirsher #define BFA_IOC_FLASH_OFFSET_IN_CHUNK(off)	(off % BFI_FLASH_CHUNK_SZ_WORDS)
245f844a0eaSJeff Kirsher #define BFA_IOC_FLASH_CHUNK_ADDR(chunkno)  (chunkno * BFI_FLASH_CHUNK_SZ_WORDS)
246f844a0eaSJeff Kirsher 
2471aa8b471SBen Hutchings /* IOC mailbox interface */
248af027a34SRasesh Mody bool bfa_nw_ioc_mbox_queue(struct bfa_ioc *ioc,
249af027a34SRasesh Mody 			struct bfa_mbox_cmd *cmd,
250af027a34SRasesh Mody 			bfa_mbox_cmd_cbfn_t cbfn, void *cbarg);
251f844a0eaSJeff Kirsher void bfa_nw_ioc_mbox_isr(struct bfa_ioc *ioc);
252f844a0eaSJeff Kirsher void bfa_nw_ioc_mbox_regisr(struct bfa_ioc *ioc, enum bfi_mclass mc,
253f844a0eaSJeff Kirsher 		bfa_ioc_mbox_mcfunc_t cbfn, void *cbarg);
254f844a0eaSJeff Kirsher 
2551aa8b471SBen Hutchings /* IOC interfaces */
256f844a0eaSJeff Kirsher 
257f844a0eaSJeff Kirsher #define bfa_ioc_pll_init_asic(__ioc) \
258f844a0eaSJeff Kirsher 	((__ioc)->ioc_hwif->ioc_pll_init((__ioc)->pcidev.pci_bar_kva, \
259078086f3SRasesh Mody 			   (__ioc)->asic_mode))
260f844a0eaSJeff Kirsher 
261078086f3SRasesh Mody #define bfa_ioc_lpu_read_stat(__ioc) do {				\
262078086f3SRasesh Mody 		if ((__ioc)->ioc_hwif->ioc_lpu_read_stat)		\
263078086f3SRasesh Mody 			((__ioc)->ioc_hwif->ioc_lpu_read_stat(__ioc));	\
264078086f3SRasesh Mody } while (0)
265078086f3SRasesh Mody 
266f844a0eaSJeff Kirsher void bfa_nw_ioc_set_ct_hwif(struct bfa_ioc *ioc);
267be3a84d1SRasesh Mody void bfa_nw_ioc_set_ct2_hwif(struct bfa_ioc *ioc);
26870f14381SRasesh Mody void bfa_nw_ioc_ct2_poweron(struct bfa_ioc *ioc);
269f844a0eaSJeff Kirsher 
270f844a0eaSJeff Kirsher void bfa_nw_ioc_attach(struct bfa_ioc *ioc, void *bfa,
271f844a0eaSJeff Kirsher 		struct bfa_ioc_cbfn *cbfn);
272f844a0eaSJeff Kirsher void bfa_nw_ioc_auto_recover(bool auto_recover);
273f844a0eaSJeff Kirsher void bfa_nw_ioc_detach(struct bfa_ioc *ioc);
274f844a0eaSJeff Kirsher void bfa_nw_ioc_pci_init(struct bfa_ioc *ioc, struct bfa_pcidev *pcidev,
275078086f3SRasesh Mody 		enum bfi_pcifn_class clscode);
276f844a0eaSJeff Kirsher u32 bfa_nw_ioc_meminfo(void);
277f844a0eaSJeff Kirsher void bfa_nw_ioc_mem_claim(struct bfa_ioc *ioc,  u8 *dm_kva, u64 dm_pa);
278f844a0eaSJeff Kirsher void bfa_nw_ioc_enable(struct bfa_ioc *ioc);
279f844a0eaSJeff Kirsher void bfa_nw_ioc_disable(struct bfa_ioc *ioc);
280f844a0eaSJeff Kirsher 
281f844a0eaSJeff Kirsher void bfa_nw_ioc_error_isr(struct bfa_ioc *ioc);
282f844a0eaSJeff Kirsher bool bfa_nw_ioc_is_disabled(struct bfa_ioc *ioc);
2837afc5dbdSKrishna Gudipati bool bfa_nw_ioc_is_operational(struct bfa_ioc *ioc);
284f844a0eaSJeff Kirsher void bfa_nw_ioc_get_attr(struct bfa_ioc *ioc, struct bfa_ioc_attr *ioc_attr);
285c107ba17SRasesh Mody enum bfa_status bfa_nw_ioc_fwsig_invalidate(struct bfa_ioc *ioc);
286f844a0eaSJeff Kirsher void bfa_nw_ioc_notify_register(struct bfa_ioc *ioc,
287f844a0eaSJeff Kirsher 	struct bfa_ioc_notify *notify);
288f844a0eaSJeff Kirsher bool bfa_nw_ioc_sem_get(void __iomem *sem_reg);
289f844a0eaSJeff Kirsher void bfa_nw_ioc_sem_release(void __iomem *sem_reg);
290f844a0eaSJeff Kirsher void bfa_nw_ioc_hw_sem_release(struct bfa_ioc *ioc);
291f844a0eaSJeff Kirsher void bfa_nw_ioc_fwver_get(struct bfa_ioc *ioc,
292f844a0eaSJeff Kirsher 			struct bfi_ioc_image_hdr *fwhdr);
293f844a0eaSJeff Kirsher bool bfa_nw_ioc_fwver_cmp(struct bfa_ioc *ioc,
294f844a0eaSJeff Kirsher 			struct bfi_ioc_image_hdr *fwhdr);
295d6b30598SIvan Vecera void bfa_nw_ioc_get_mac(struct bfa_ioc *ioc, u8 *mac);
2967afc5dbdSKrishna Gudipati void bfa_nw_ioc_debug_memclaim(struct bfa_ioc *ioc, void *dbg_fwsave);
2977afc5dbdSKrishna Gudipati int bfa_nw_ioc_debug_fwtrc(struct bfa_ioc *ioc, void *trcdata, int *trclen);
2987afc5dbdSKrishna Gudipati int bfa_nw_ioc_debug_fwsave(struct bfa_ioc *ioc, void *trcdata, int *trclen);
299f844a0eaSJeff Kirsher 
300f844a0eaSJeff Kirsher /*
301f844a0eaSJeff Kirsher  * Timeout APIs
302f844a0eaSJeff Kirsher  */
303ad24d6f0SIvan Vecera void bfa_nw_ioc_timeout(struct bfa_ioc *ioc);
304ad24d6f0SIvan Vecera void bfa_nw_ioc_hb_check(struct bfa_ioc *ioc);
305ad24d6f0SIvan Vecera void bfa_nw_iocpf_timeout(struct bfa_ioc *ioc);
306ad24d6f0SIvan Vecera void bfa_nw_iocpf_sem_timeout(struct bfa_ioc *ioc);
307f844a0eaSJeff Kirsher 
308f844a0eaSJeff Kirsher /*
309f844a0eaSJeff Kirsher  * F/W Image Size & Chunk
310f844a0eaSJeff Kirsher  */
311078086f3SRasesh Mody u32 *bfa_cb_image_get_chunk(enum bfi_asic_gen asic_gen, u32 off);
312078086f3SRasesh Mody u32 bfa_cb_image_get_size(enum bfi_asic_gen asic_gen);
313f844a0eaSJeff Kirsher 
31472a9730bSKrishna Gudipati /*
31572a9730bSKrishna Gudipati  *	Flash module specific
31672a9730bSKrishna Gudipati  */
31772a9730bSKrishna Gudipati typedef void	(*bfa_cb_flash) (void *cbarg, enum bfa_status status);
31872a9730bSKrishna Gudipati 
31972a9730bSKrishna Gudipati struct bfa_flash {
32072a9730bSKrishna Gudipati 	struct bfa_ioc *ioc;		/* back pointer to ioc */
32172a9730bSKrishna Gudipati 	u32		type;		/* partition type */
32272a9730bSKrishna Gudipati 	u8		instance;	/* partition instance */
32372a9730bSKrishna Gudipati 	u8		rsv[3];
32472a9730bSKrishna Gudipati 	u32		op_busy;	/*  operation busy flag */
32572a9730bSKrishna Gudipati 	u32		residue;	/*  residual length */
32672a9730bSKrishna Gudipati 	u32		offset;		/*  offset */
32772a9730bSKrishna Gudipati 	enum bfa_status	status;		/*  status */
32872a9730bSKrishna Gudipati 	u8		*dbuf_kva;	/*  dma buf virtual address */
32972a9730bSKrishna Gudipati 	u64		dbuf_pa;	/*  dma buf physical address */
33072a9730bSKrishna Gudipati 	bfa_cb_flash	cbfn;		/*  user callback function */
33172a9730bSKrishna Gudipati 	void		*cbarg;		/*  user callback arg */
33272a9730bSKrishna Gudipati 	u8		*ubuf;		/*  user supplied buffer */
33372a9730bSKrishna Gudipati 	u32		addr_off;	/*  partition address offset */
33472a9730bSKrishna Gudipati 	struct bfa_mbox_cmd mb;		/*  mailbox */
33572a9730bSKrishna Gudipati 	struct bfa_ioc_notify ioc_notify; /*  ioc event notify */
33672a9730bSKrishna Gudipati };
33772a9730bSKrishna Gudipati 
33872a9730bSKrishna Gudipati enum bfa_status bfa_nw_flash_get_attr(struct bfa_flash *flash,
33972a9730bSKrishna Gudipati 			struct bfa_flash_attr *attr,
34072a9730bSKrishna Gudipati 			bfa_cb_flash cbfn, void *cbarg);
34172a9730bSKrishna Gudipati enum bfa_status bfa_nw_flash_update_part(struct bfa_flash *flash,
34272a9730bSKrishna Gudipati 			u32 type, u8 instance, void *buf, u32 len, u32 offset,
34372a9730bSKrishna Gudipati 			bfa_cb_flash cbfn, void *cbarg);
34472a9730bSKrishna Gudipati enum bfa_status bfa_nw_flash_read_part(struct bfa_flash *flash,
34572a9730bSKrishna Gudipati 			u32 type, u8 instance, void *buf, u32 len, u32 offset,
34672a9730bSKrishna Gudipati 			bfa_cb_flash cbfn, void *cbarg);
34772a9730bSKrishna Gudipati u32	bfa_nw_flash_meminfo(void);
34872a9730bSKrishna Gudipati void	bfa_nw_flash_attach(struct bfa_flash *flash,
34972a9730bSKrishna Gudipati 			    struct bfa_ioc *ioc, void *dev);
35072a9730bSKrishna Gudipati void	bfa_nw_flash_memclaim(struct bfa_flash *flash, u8 *dm_kva, u64 dm_pa);
35172a9730bSKrishna Gudipati 
352f844a0eaSJeff Kirsher #endif /* __BFA_IOC_H__ */
353