18b230ed8SRasesh Mody /* 28b230ed8SRasesh Mody * Linux network driver for Brocade Converged Network Adapter. 38b230ed8SRasesh Mody * 48b230ed8SRasesh Mody * This program is free software; you can redistribute it and/or modify it 58b230ed8SRasesh Mody * under the terms of the GNU General Public License (GPL) Version 2 as 68b230ed8SRasesh Mody * published by the Free Software Foundation 78b230ed8SRasesh Mody * 88b230ed8SRasesh Mody * This program is distributed in the hope that it will be useful, but 98b230ed8SRasesh Mody * WITHOUT ANY WARRANTY; without even the implied warranty of 108b230ed8SRasesh Mody * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 118b230ed8SRasesh Mody * General Public License for more details. 128b230ed8SRasesh Mody */ 138b230ed8SRasesh Mody /* 148b230ed8SRasesh Mody * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. 158b230ed8SRasesh Mody * All rights reserved 168b230ed8SRasesh Mody * www.brocade.com 178b230ed8SRasesh Mody */ 188b230ed8SRasesh Mody 198b230ed8SRasesh Mody #ifndef __BFA_IOC_H__ 208b230ed8SRasesh Mody #define __BFA_IOC_H__ 218b230ed8SRasesh Mody 22758ccc34SRasesh Mody #include "bfa_cs.h" 238b230ed8SRasesh Mody #include "bfi.h" 248b230ed8SRasesh Mody #include "cna.h" 258b230ed8SRasesh Mody 268b230ed8SRasesh Mody #define BFA_IOC_TOV 3000 /* msecs */ 278b230ed8SRasesh Mody #define BFA_IOC_HWSEM_TOV 500 /* msecs */ 288b230ed8SRasesh Mody #define BFA_IOC_HB_TOV 500 /* msecs */ 29078086f3SRasesh Mody #define BFA_IOC_POLL_TOV 200 /* msecs */ 307afc5dbdSKrishna Gudipati #define BNA_DBG_FWTRC_LEN (BFI_IOC_TRC_ENTS * BFI_IOC_TRC_ENT_SZ + \ 317afc5dbdSKrishna Gudipati BFI_IOC_TRC_HDR_SZ) 328b230ed8SRasesh Mody 331aa8b471SBen Hutchings /* PCI device information required by IOC */ 348b230ed8SRasesh Mody struct bfa_pcidev { 358b230ed8SRasesh Mody int pci_slot; 368b230ed8SRasesh Mody u8 pci_func; 378b230ed8SRasesh Mody u16 device_id; 38586b2816SRasesh Mody u16 ssid; 398b230ed8SRasesh Mody void __iomem *pci_bar_kva; 408b230ed8SRasesh Mody }; 418b230ed8SRasesh Mody 421aa8b471SBen Hutchings /* Structure used to remember the DMA-able memory block's KVA and Physical 438b230ed8SRasesh Mody * Address 448b230ed8SRasesh Mody */ 458b230ed8SRasesh Mody struct bfa_dma { 468b230ed8SRasesh Mody void *kva; /* ! Kernel virtual address */ 478b230ed8SRasesh Mody u64 pa; /* ! Physical address */ 488b230ed8SRasesh Mody }; 498b230ed8SRasesh Mody 508b230ed8SRasesh Mody #define BFA_DMA_ALIGN_SZ 256 518b230ed8SRasesh Mody 521aa8b471SBen Hutchings /* smem size for Crossbow and Catapult */ 538b230ed8SRasesh Mody #define BFI_SMEM_CB_SIZE 0x200000U /* ! 2MB for crossbow */ 548b230ed8SRasesh Mody #define BFI_SMEM_CT_SIZE 0x280000U /* ! 2.5MB for catapult */ 558b230ed8SRasesh Mody 561aa8b471SBen Hutchings /* BFA dma address assignment macro. (big endian format) */ 578b230ed8SRasesh Mody #define bfa_dma_be_addr_set(dma_addr, pa) \ 588b230ed8SRasesh Mody __bfa_dma_be_addr_set(&dma_addr, (u64)pa) 598b230ed8SRasesh Mody static inline void 608b230ed8SRasesh Mody __bfa_dma_be_addr_set(union bfi_addr_u *dma_addr, u64 pa) 618b230ed8SRasesh Mody { 628b230ed8SRasesh Mody dma_addr->a32.addr_lo = (u32) htonl(pa); 638b230ed8SRasesh Mody dma_addr->a32.addr_hi = (u32) htonl(upper_32_bits(pa)); 648b230ed8SRasesh Mody } 658b230ed8SRasesh Mody 6672a9730bSKrishna Gudipati #define bfa_alen_set(__alen, __len, __pa) \ 6772a9730bSKrishna Gudipati __bfa_alen_set(__alen, __len, (u64)__pa) 6872a9730bSKrishna Gudipati 6972a9730bSKrishna Gudipati static inline void 7072a9730bSKrishna Gudipati __bfa_alen_set(struct bfi_alen *alen, u32 len, u64 pa) 7172a9730bSKrishna Gudipati { 7272a9730bSKrishna Gudipati alen->al_len = cpu_to_be32(len); 7372a9730bSKrishna Gudipati bfa_dma_be_addr_set(alen->al_addr, pa); 7472a9730bSKrishna Gudipati } 7572a9730bSKrishna Gudipati 768b230ed8SRasesh Mody struct bfa_ioc_regs { 778b230ed8SRasesh Mody void __iomem *hfn_mbox_cmd; 788b230ed8SRasesh Mody void __iomem *hfn_mbox; 798b230ed8SRasesh Mody void __iomem *lpu_mbox_cmd; 808b230ed8SRasesh Mody void __iomem *lpu_mbox; 81be3a84d1SRasesh Mody void __iomem *lpu_read_stat; 828b230ed8SRasesh Mody void __iomem *pss_ctl_reg; 838b230ed8SRasesh Mody void __iomem *pss_err_status_reg; 848b230ed8SRasesh Mody void __iomem *app_pll_fast_ctl_reg; 858b230ed8SRasesh Mody void __iomem *app_pll_slow_ctl_reg; 868b230ed8SRasesh Mody void __iomem *ioc_sem_reg; 878b230ed8SRasesh Mody void __iomem *ioc_usage_sem_reg; 888b230ed8SRasesh Mody void __iomem *ioc_init_sem_reg; 898b230ed8SRasesh Mody void __iomem *ioc_usage_reg; 908b230ed8SRasesh Mody void __iomem *host_page_num_fn; 918b230ed8SRasesh Mody void __iomem *heartbeat; 928b230ed8SRasesh Mody void __iomem *ioc_fwstate; 931d32f769SRasesh Mody void __iomem *alt_ioc_fwstate; 948b230ed8SRasesh Mody void __iomem *ll_halt; 951d32f769SRasesh Mody void __iomem *alt_ll_halt; 968b230ed8SRasesh Mody void __iomem *err_set; 971d32f769SRasesh Mody void __iomem *ioc_fail_sync; 988b230ed8SRasesh Mody void __iomem *shirq_isr_next; 998b230ed8SRasesh Mody void __iomem *shirq_msk_next; 1008b230ed8SRasesh Mody void __iomem *smem_page_start; 1018b230ed8SRasesh Mody u32 smem_pg0; 1028b230ed8SRasesh Mody }; 1038b230ed8SRasesh Mody 1041aa8b471SBen Hutchings /* IOC Mailbox structures */ 105bd5a92e9SRasesh Mody typedef void (*bfa_mbox_cmd_cbfn_t)(void *cbarg); 1068b230ed8SRasesh Mody struct bfa_mbox_cmd { 1078b230ed8SRasesh Mody struct list_head qe; 108bd5a92e9SRasesh Mody bfa_mbox_cmd_cbfn_t cbfn; 109bd5a92e9SRasesh Mody void *cbarg; 1108b230ed8SRasesh Mody u32 msg[BFI_IOC_MSGSZ]; 1118b230ed8SRasesh Mody }; 1128b230ed8SRasesh Mody 1131aa8b471SBen Hutchings /* IOC mailbox module */ 1148b230ed8SRasesh Mody typedef void (*bfa_ioc_mbox_mcfunc_t)(void *cbarg, struct bfi_mbmsg *m); 1158b230ed8SRasesh Mody struct bfa_ioc_mbox_mod { 1168b230ed8SRasesh Mody struct list_head cmd_q; /*!< pending mbox queue */ 1178b230ed8SRasesh Mody int nmclass; /*!< number of handlers */ 1188b230ed8SRasesh Mody struct { 1198b230ed8SRasesh Mody bfa_ioc_mbox_mcfunc_t cbfn; /*!< message handlers */ 1208b230ed8SRasesh Mody void *cbarg; 1218b230ed8SRasesh Mody } mbhdlr[BFI_MC_MAX]; 1228b230ed8SRasesh Mody }; 1238b230ed8SRasesh Mody 1241aa8b471SBen Hutchings /* IOC callback function interfaces */ 1258b230ed8SRasesh Mody typedef void (*bfa_ioc_enable_cbfn_t)(void *bfa, enum bfa_status status); 1268b230ed8SRasesh Mody typedef void (*bfa_ioc_disable_cbfn_t)(void *bfa); 1278b230ed8SRasesh Mody typedef void (*bfa_ioc_hbfail_cbfn_t)(void *bfa); 1288b230ed8SRasesh Mody typedef void (*bfa_ioc_reset_cbfn_t)(void *bfa); 1298b230ed8SRasesh Mody struct bfa_ioc_cbfn { 1308b230ed8SRasesh Mody bfa_ioc_enable_cbfn_t enable_cbfn; 1318b230ed8SRasesh Mody bfa_ioc_disable_cbfn_t disable_cbfn; 1328b230ed8SRasesh Mody bfa_ioc_hbfail_cbfn_t hbfail_cbfn; 1338b230ed8SRasesh Mody bfa_ioc_reset_cbfn_t reset_cbfn; 1348b230ed8SRasesh Mody }; 1358b230ed8SRasesh Mody 1361aa8b471SBen Hutchings /* IOC event notification mechanism. */ 137bd5a92e9SRasesh Mody enum bfa_ioc_event { 138bd5a92e9SRasesh Mody BFA_IOC_E_ENABLED = 1, 139bd5a92e9SRasesh Mody BFA_IOC_E_DISABLED = 2, 140bd5a92e9SRasesh Mody BFA_IOC_E_FAILED = 3, 141bd5a92e9SRasesh Mody }; 142bd5a92e9SRasesh Mody 143bd5a92e9SRasesh Mody typedef void (*bfa_ioc_notify_cbfn_t)(void *, enum bfa_ioc_event); 144bd5a92e9SRasesh Mody 145bd5a92e9SRasesh Mody struct bfa_ioc_notify { 146bd5a92e9SRasesh Mody struct list_head qe; 147bd5a92e9SRasesh Mody bfa_ioc_notify_cbfn_t cbfn; 148bd5a92e9SRasesh Mody void *cbarg; 149bd5a92e9SRasesh Mody }; 150bd5a92e9SRasesh Mody 1511aa8b471SBen Hutchings /* Initialize a IOC event notification structure */ 152bd5a92e9SRasesh Mody #define bfa_ioc_notify_init(__notify, __cbfn, __cbarg) do { \ 1538b230ed8SRasesh Mody (__notify)->cbfn = (__cbfn); \ 1548b230ed8SRasesh Mody (__notify)->cbarg = (__cbarg); \ 1558b230ed8SRasesh Mody } while (0) 1568b230ed8SRasesh Mody 1571d32f769SRasesh Mody struct bfa_iocpf { 1581d32f769SRasesh Mody bfa_fsm_t fsm; 1591d32f769SRasesh Mody struct bfa_ioc *ioc; 160078086f3SRasesh Mody bool fw_mismatch_notified; 1611d32f769SRasesh Mody bool auto_recover; 162078086f3SRasesh Mody u32 poll_time; 1631d32f769SRasesh Mody }; 1641d32f769SRasesh Mody 1658b230ed8SRasesh Mody struct bfa_ioc { 1668b230ed8SRasesh Mody bfa_fsm_t fsm; 1678b230ed8SRasesh Mody struct bfa *bfa; 1688b230ed8SRasesh Mody struct bfa_pcidev pcidev; 1698b230ed8SRasesh Mody struct timer_list ioc_timer; 1701d32f769SRasesh Mody struct timer_list iocpf_timer; 1718b230ed8SRasesh Mody struct timer_list sem_timer; 1728b230ed8SRasesh Mody struct timer_list hb_timer; 1738b230ed8SRasesh Mody u32 hb_count; 174bd5a92e9SRasesh Mody struct list_head notify_q; 1758b230ed8SRasesh Mody void *dbg_fwsave; 1768b230ed8SRasesh Mody int dbg_fwsave_len; 1778b230ed8SRasesh Mody bool dbg_fwsave_once; 178078086f3SRasesh Mody enum bfi_pcifn_class clscode; 1798b230ed8SRasesh Mody struct bfa_ioc_regs ioc_regs; 1808b230ed8SRasesh Mody struct bfa_ioc_drv_stats stats; 1818b230ed8SRasesh Mody bool fcmode; 1828b230ed8SRasesh Mody bool pllinit; 1838b230ed8SRasesh Mody bool stats_busy; /*!< outstanding stats */ 1848b230ed8SRasesh Mody u8 port_id; 1858b230ed8SRasesh Mody 1868b230ed8SRasesh Mody struct bfa_dma attr_dma; 1878b230ed8SRasesh Mody struct bfi_ioc_attr *attr; 1888b230ed8SRasesh Mody struct bfa_ioc_cbfn *cbfn; 1898b230ed8SRasesh Mody struct bfa_ioc_mbox_mod mbox_mod; 190d91d25d5Sstephen hemminger const struct bfa_ioc_hwif *ioc_hwif; 1911d32f769SRasesh Mody struct bfa_iocpf iocpf; 192078086f3SRasesh Mody enum bfi_asic_gen asic_gen; 193078086f3SRasesh Mody enum bfi_asic_mode asic_mode; 194078086f3SRasesh Mody enum bfi_port_mode port0_mode; 195078086f3SRasesh Mody enum bfi_port_mode port1_mode; 196078086f3SRasesh Mody enum bfa_mode port_mode; 197078086f3SRasesh Mody u8 ad_cap_bm; /*!< adapter cap bit mask */ 198078086f3SRasesh Mody u8 port_mode_cfg; /*!< config port mode */ 1998b230ed8SRasesh Mody }; 2008b230ed8SRasesh Mody 2018b230ed8SRasesh Mody struct bfa_ioc_hwif { 202078086f3SRasesh Mody enum bfa_status (*ioc_pll_init) (void __iomem *rb, 203078086f3SRasesh Mody enum bfi_asic_mode m); 2048b230ed8SRasesh Mody bool (*ioc_firmware_lock) (struct bfa_ioc *ioc); 2058b230ed8SRasesh Mody void (*ioc_firmware_unlock) (struct bfa_ioc *ioc); 2068b230ed8SRasesh Mody void (*ioc_reg_init) (struct bfa_ioc *ioc); 2078b230ed8SRasesh Mody void (*ioc_map_port) (struct bfa_ioc *ioc); 2088b230ed8SRasesh Mody void (*ioc_isr_mode_set) (struct bfa_ioc *ioc, 2098b230ed8SRasesh Mody bool msix); 2101d32f769SRasesh Mody void (*ioc_notify_fail) (struct bfa_ioc *ioc); 2118b230ed8SRasesh Mody void (*ioc_ownership_reset) (struct bfa_ioc *ioc); 21279ea6c89SRasesh Mody bool (*ioc_sync_start) (struct bfa_ioc *ioc); 2131d32f769SRasesh Mody void (*ioc_sync_join) (struct bfa_ioc *ioc); 2141d32f769SRasesh Mody void (*ioc_sync_leave) (struct bfa_ioc *ioc); 2151d32f769SRasesh Mody void (*ioc_sync_ack) (struct bfa_ioc *ioc); 2161d32f769SRasesh Mody bool (*ioc_sync_complete) (struct bfa_ioc *ioc); 217078086f3SRasesh Mody bool (*ioc_lpu_read_stat) (struct bfa_ioc *ioc); 218*41ed903aSRasesh Mody void (*ioc_set_fwstate) (struct bfa_ioc *ioc, 219*41ed903aSRasesh Mody enum bfi_ioc_state fwstate); 220*41ed903aSRasesh Mody enum bfi_ioc_state (*ioc_get_fwstate) (struct bfa_ioc *ioc); 221*41ed903aSRasesh Mody void (*ioc_set_alt_fwstate) (struct bfa_ioc *ioc, 222*41ed903aSRasesh Mody enum bfi_ioc_state fwstate); 223*41ed903aSRasesh Mody enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc *ioc); 224*41ed903aSRasesh Mody 2258b230ed8SRasesh Mody }; 2268b230ed8SRasesh Mody 2278b230ed8SRasesh Mody #define bfa_ioc_pcifn(__ioc) ((__ioc)->pcidev.pci_func) 2288b230ed8SRasesh Mody #define bfa_ioc_devid(__ioc) ((__ioc)->pcidev.device_id) 2298b230ed8SRasesh Mody #define bfa_ioc_bar0(__ioc) ((__ioc)->pcidev.pci_bar_kva) 2308b230ed8SRasesh Mody #define bfa_ioc_portid(__ioc) ((__ioc)->port_id) 231078086f3SRasesh Mody #define bfa_ioc_asic_gen(__ioc) ((__ioc)->asic_gen) 23243c07adaSRasesh Mody #define bfa_ioc_is_default(__ioc) \ 23343c07adaSRasesh Mody (bfa_ioc_pcifn(__ioc) == bfa_ioc_portid(__ioc)) 2348b230ed8SRasesh Mody #define bfa_ioc_fetch_stats(__ioc, __stats) \ 2358b230ed8SRasesh Mody (((__stats)->drv_stats) = (__ioc)->stats) 2368b230ed8SRasesh Mody #define bfa_ioc_clr_stats(__ioc) \ 2378b230ed8SRasesh Mody memset(&(__ioc)->stats, 0, sizeof((__ioc)->stats)) 2388b230ed8SRasesh Mody #define bfa_ioc_maxfrsize(__ioc) ((__ioc)->attr->maxfrsize) 2398b230ed8SRasesh Mody #define bfa_ioc_rx_bbcredit(__ioc) ((__ioc)->attr->rx_bbcredit) 2408b230ed8SRasesh Mody #define bfa_ioc_speed_sup(__ioc) \ 2418b230ed8SRasesh Mody BFI_ADAPTER_GETP(SPEED, (__ioc)->attr->adapter_prop) 2428b230ed8SRasesh Mody #define bfa_ioc_get_nports(__ioc) \ 2438b230ed8SRasesh Mody BFI_ADAPTER_GETP(NPORTS, (__ioc)->attr->adapter_prop) 2448b230ed8SRasesh Mody 2458b230ed8SRasesh Mody #define bfa_ioc_stats(_ioc, _stats) ((_ioc)->stats._stats++) 2469b08a4fcSRasesh Mody #define bfa_ioc_stats_hb_count(_ioc, _hb_count) \ 2479b08a4fcSRasesh Mody ((_ioc)->stats.hb_count = (_hb_count)) 2488b230ed8SRasesh Mody #define BFA_IOC_FWIMG_MINSZ (16 * 1024) 2498b230ed8SRasesh Mody #define BFA_IOC_FW_SMEM_SIZE(__ioc) \ 250078086f3SRasesh Mody ((bfa_ioc_asic_gen(__ioc) == BFI_ASIC_GEN_CB) \ 251078086f3SRasesh Mody ? BFI_SMEM_CB_SIZE : BFI_SMEM_CT_SIZE) 2528b230ed8SRasesh Mody #define BFA_IOC_FLASH_CHUNK_NO(off) (off / BFI_FLASH_CHUNK_SZ_WORDS) 2538b230ed8SRasesh Mody #define BFA_IOC_FLASH_OFFSET_IN_CHUNK(off) (off % BFI_FLASH_CHUNK_SZ_WORDS) 2548b230ed8SRasesh Mody #define BFA_IOC_FLASH_CHUNK_ADDR(chunkno) (chunkno * BFI_FLASH_CHUNK_SZ_WORDS) 2558b230ed8SRasesh Mody 2561aa8b471SBen Hutchings /* IOC mailbox interface */ 257af027a34SRasesh Mody bool bfa_nw_ioc_mbox_queue(struct bfa_ioc *ioc, 258af027a34SRasesh Mody struct bfa_mbox_cmd *cmd, 259af027a34SRasesh Mody bfa_mbox_cmd_cbfn_t cbfn, void *cbarg); 2608a891429SRasesh Mody void bfa_nw_ioc_mbox_isr(struct bfa_ioc *ioc); 2618a891429SRasesh Mody void bfa_nw_ioc_mbox_regisr(struct bfa_ioc *ioc, enum bfi_mclass mc, 2628b230ed8SRasesh Mody bfa_ioc_mbox_mcfunc_t cbfn, void *cbarg); 2638b230ed8SRasesh Mody 2641aa8b471SBen Hutchings /* IOC interfaces */ 2658b230ed8SRasesh Mody 2668b230ed8SRasesh Mody #define bfa_ioc_pll_init_asic(__ioc) \ 2678b230ed8SRasesh Mody ((__ioc)->ioc_hwif->ioc_pll_init((__ioc)->pcidev.pci_bar_kva, \ 268078086f3SRasesh Mody (__ioc)->asic_mode)) 2698b230ed8SRasesh Mody 270772b5235SRasesh Mody #define bfa_ioc_isr_mode_set(__ioc, __msix) do { \ 271772b5235SRasesh Mody if ((__ioc)->ioc_hwif->ioc_isr_mode_set) \ 272772b5235SRasesh Mody ((__ioc)->ioc_hwif->ioc_isr_mode_set(__ioc, __msix)); \ 273772b5235SRasesh Mody } while (0) 2748b230ed8SRasesh Mody #define bfa_ioc_ownership_reset(__ioc) \ 2758b230ed8SRasesh Mody ((__ioc)->ioc_hwif->ioc_ownership_reset(__ioc)) 2768b230ed8SRasesh Mody 277078086f3SRasesh Mody #define bfa_ioc_lpu_read_stat(__ioc) do { \ 278078086f3SRasesh Mody if ((__ioc)->ioc_hwif->ioc_lpu_read_stat) \ 279078086f3SRasesh Mody ((__ioc)->ioc_hwif->ioc_lpu_read_stat(__ioc)); \ 280078086f3SRasesh Mody } while (0) 281078086f3SRasesh Mody 2828a891429SRasesh Mody void bfa_nw_ioc_set_ct_hwif(struct bfa_ioc *ioc); 283be3a84d1SRasesh Mody void bfa_nw_ioc_set_ct2_hwif(struct bfa_ioc *ioc); 28470f14381SRasesh Mody void bfa_nw_ioc_ct2_poweron(struct bfa_ioc *ioc); 2858b230ed8SRasesh Mody 2868a891429SRasesh Mody void bfa_nw_ioc_attach(struct bfa_ioc *ioc, void *bfa, 2878b230ed8SRasesh Mody struct bfa_ioc_cbfn *cbfn); 2888a891429SRasesh Mody void bfa_nw_ioc_auto_recover(bool auto_recover); 2898a891429SRasesh Mody void bfa_nw_ioc_detach(struct bfa_ioc *ioc); 2908a891429SRasesh Mody void bfa_nw_ioc_pci_init(struct bfa_ioc *ioc, struct bfa_pcidev *pcidev, 291078086f3SRasesh Mody enum bfi_pcifn_class clscode); 2928a891429SRasesh Mody u32 bfa_nw_ioc_meminfo(void); 2938a891429SRasesh Mody void bfa_nw_ioc_mem_claim(struct bfa_ioc *ioc, u8 *dm_kva, u64 dm_pa); 2948a891429SRasesh Mody void bfa_nw_ioc_enable(struct bfa_ioc *ioc); 2958a891429SRasesh Mody void bfa_nw_ioc_disable(struct bfa_ioc *ioc); 2968b230ed8SRasesh Mody 2978a891429SRasesh Mody void bfa_nw_ioc_error_isr(struct bfa_ioc *ioc); 298bd5a92e9SRasesh Mody bool bfa_nw_ioc_is_disabled(struct bfa_ioc *ioc); 2997afc5dbdSKrishna Gudipati bool bfa_nw_ioc_is_operational(struct bfa_ioc *ioc); 3008a891429SRasesh Mody void bfa_nw_ioc_get_attr(struct bfa_ioc *ioc, struct bfa_ioc_attr *ioc_attr); 301bd5a92e9SRasesh Mody void bfa_nw_ioc_notify_register(struct bfa_ioc *ioc, 302bd5a92e9SRasesh Mody struct bfa_ioc_notify *notify); 3038a891429SRasesh Mody bool bfa_nw_ioc_sem_get(void __iomem *sem_reg); 3048a891429SRasesh Mody void bfa_nw_ioc_sem_release(void __iomem *sem_reg); 3058a891429SRasesh Mody void bfa_nw_ioc_hw_sem_release(struct bfa_ioc *ioc); 3068a891429SRasesh Mody void bfa_nw_ioc_fwver_get(struct bfa_ioc *ioc, 3078b230ed8SRasesh Mody struct bfi_ioc_image_hdr *fwhdr); 3088a891429SRasesh Mody bool bfa_nw_ioc_fwver_cmp(struct bfa_ioc *ioc, 3098b230ed8SRasesh Mody struct bfi_ioc_image_hdr *fwhdr); 3108a891429SRasesh Mody mac_t bfa_nw_ioc_get_mac(struct bfa_ioc *ioc); 3117afc5dbdSKrishna Gudipati void bfa_nw_ioc_debug_memclaim(struct bfa_ioc *ioc, void *dbg_fwsave); 3127afc5dbdSKrishna Gudipati int bfa_nw_ioc_debug_fwtrc(struct bfa_ioc *ioc, void *trcdata, int *trclen); 3137afc5dbdSKrishna Gudipati int bfa_nw_ioc_debug_fwsave(struct bfa_ioc *ioc, void *trcdata, int *trclen); 3148b230ed8SRasesh Mody 3158b230ed8SRasesh Mody /* 3168b230ed8SRasesh Mody * Timeout APIs 3178b230ed8SRasesh Mody */ 3188a891429SRasesh Mody void bfa_nw_ioc_timeout(void *ioc); 3198a891429SRasesh Mody void bfa_nw_ioc_hb_check(void *ioc); 3201d32f769SRasesh Mody void bfa_nw_iocpf_timeout(void *ioc); 3211d32f769SRasesh Mody void bfa_nw_iocpf_sem_timeout(void *ioc); 3228b230ed8SRasesh Mody 3238b230ed8SRasesh Mody /* 3248b230ed8SRasesh Mody * F/W Image Size & Chunk 3258b230ed8SRasesh Mody */ 326078086f3SRasesh Mody u32 *bfa_cb_image_get_chunk(enum bfi_asic_gen asic_gen, u32 off); 327078086f3SRasesh Mody u32 bfa_cb_image_get_size(enum bfi_asic_gen asic_gen); 3288b230ed8SRasesh Mody 32972a9730bSKrishna Gudipati /* 33072a9730bSKrishna Gudipati * Flash module specific 33172a9730bSKrishna Gudipati */ 33272a9730bSKrishna Gudipati typedef void (*bfa_cb_flash) (void *cbarg, enum bfa_status status); 33372a9730bSKrishna Gudipati 33472a9730bSKrishna Gudipati struct bfa_flash { 33572a9730bSKrishna Gudipati struct bfa_ioc *ioc; /* back pointer to ioc */ 33672a9730bSKrishna Gudipati u32 type; /* partition type */ 33772a9730bSKrishna Gudipati u8 instance; /* partition instance */ 33872a9730bSKrishna Gudipati u8 rsv[3]; 33972a9730bSKrishna Gudipati u32 op_busy; /* operation busy flag */ 34072a9730bSKrishna Gudipati u32 residue; /* residual length */ 34172a9730bSKrishna Gudipati u32 offset; /* offset */ 34272a9730bSKrishna Gudipati enum bfa_status status; /* status */ 34372a9730bSKrishna Gudipati u8 *dbuf_kva; /* dma buf virtual address */ 34472a9730bSKrishna Gudipati u64 dbuf_pa; /* dma buf physical address */ 34572a9730bSKrishna Gudipati bfa_cb_flash cbfn; /* user callback function */ 34672a9730bSKrishna Gudipati void *cbarg; /* user callback arg */ 34772a9730bSKrishna Gudipati u8 *ubuf; /* user supplied buffer */ 34872a9730bSKrishna Gudipati u32 addr_off; /* partition address offset */ 34972a9730bSKrishna Gudipati struct bfa_mbox_cmd mb; /* mailbox */ 35072a9730bSKrishna Gudipati struct bfa_ioc_notify ioc_notify; /* ioc event notify */ 35172a9730bSKrishna Gudipati }; 35272a9730bSKrishna Gudipati 35372a9730bSKrishna Gudipati enum bfa_status bfa_nw_flash_get_attr(struct bfa_flash *flash, 35472a9730bSKrishna Gudipati struct bfa_flash_attr *attr, 35572a9730bSKrishna Gudipati bfa_cb_flash cbfn, void *cbarg); 35672a9730bSKrishna Gudipati enum bfa_status bfa_nw_flash_update_part(struct bfa_flash *flash, 35772a9730bSKrishna Gudipati u32 type, u8 instance, void *buf, u32 len, u32 offset, 35872a9730bSKrishna Gudipati bfa_cb_flash cbfn, void *cbarg); 35972a9730bSKrishna Gudipati enum bfa_status bfa_nw_flash_read_part(struct bfa_flash *flash, 36072a9730bSKrishna Gudipati u32 type, u8 instance, void *buf, u32 len, u32 offset, 36172a9730bSKrishna Gudipati bfa_cb_flash cbfn, void *cbarg); 36272a9730bSKrishna Gudipati u32 bfa_nw_flash_meminfo(void); 36372a9730bSKrishna Gudipati void bfa_nw_flash_attach(struct bfa_flash *flash, 36472a9730bSKrishna Gudipati struct bfa_ioc *ioc, void *dev); 36572a9730bSKrishna Gudipati void bfa_nw_flash_memclaim(struct bfa_flash *flash, u8 *dm_kva, u64 dm_pa); 36672a9730bSKrishna Gudipati 3678b230ed8SRasesh Mody #endif /* __BFA_IOC_H__ */ 368