/** * 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); }
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; } }
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); bfa_ioc_mem_claim(&bfa->ioc, dm_kva, dm_pa); dm_kva += bfa_ioc_meminfo(); dm_pa += bfa_ioc_meminfo(); 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; } 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); 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->iocfc.stats_kva = dm_kva; bfa->iocfc.stats_pa = dm_pa; bfa->iocfc.fw_stats = (struct bfa_fw_stats_s *) dm_kva; dm_kva += BFA_ROUNDUP(sizeof(struct bfa_fw_stats_s), BFA_CACHELINE_SZ); dm_pa += BFA_ROUNDUP(sizeof(struct bfa_fw_stats_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; } }