From 3efaabd70475270fea7fcc46621defb016797d6e Mon Sep 17 00:00:00 2001 From: Himanshu Batra Date: Mon, 3 Jul 2023 18:31:29 +0530 Subject: [PATCH] qcacmn: Update UIO info for DP data rings Update UIO info for DP data rings. Change-Id: I0c6e8c8e59aefb373dc024d91eb1379ed7564f31 CRs-Fixed: 3623839 --- dp/inc/cdp_txrx_cmn.h | 24 ++++++ dp/inc/cdp_txrx_ops.h | 4 + dp/wifi3.0/dp_main.c | 167 ++++++++++++++++++++++++++++++++++++ dp/wifi3.0/dp_rings.h | 13 +++ dp/wifi3.0/dp_rings_main.c | 119 +++++++++++++++++++++++++ qdf/inc/qdf_platform.h | 19 ++++ qdf/linux/src/i_qdf_types.h | 7 ++ qdf/src/qdf_platform.c | 16 ++++ wlan_cfg/wlan_cfg.c | 12 +++ wlan_cfg/wlan_cfg.h | 8 ++ 10 files changed, 389 insertions(+) diff --git a/dp/inc/cdp_txrx_cmn.h b/dp/inc/cdp_txrx_cmn.h index 40ad6857e9..c140aa5607 100644 --- a/dp/inc/cdp_txrx_cmn.h +++ b/dp/inc/cdp_txrx_cmn.h @@ -3376,4 +3376,28 @@ QDF_STATUS cdp_mlo_dev_ctxt_detach(ol_txrx_soc_handle soc, return QDF_STATUS_SUCCESS; } #endif /* WLAN_FEATURE_11BE_MLO */ + +#ifdef WLAN_SUPPORT_DPDK +/* + * cdp_dpdk_get_ring_info - get dp ring info for dpdk + * @soc: soc handle + * @uio_info: pointer to fill dp ring info + * + * Return: none + */ +static inline void cdp_dpdk_get_ring_info(ol_txrx_soc_handle soc, + qdf_uio_info_t *uio_info) +{ + if (!soc) { + dp_cdp_debug("Invalid Instance"); + return; + } + + if (!soc->ops->cmn_drv_ops || + !soc->ops->cmn_drv_ops->dpdk_get_ring_info) + return; + + soc->ops->cmn_drv_ops->dpdk_get_ring_info(soc, uio_info); +} +#endif #endif /* _CDP_TXRX_CMN_H_ */ diff --git a/dp/inc/cdp_txrx_ops.h b/dp/inc/cdp_txrx_ops.h index b374450717..b826260ecd 100644 --- a/dp/inc/cdp_txrx_ops.h +++ b/dp/inc/cdp_txrx_ops.h @@ -745,6 +745,10 @@ struct cdp_cmn_ops { uint64_t *value); void (*txrx_get_tqm_offset)(struct cdp_soc_t *soc_hdl, uint64_t *value); uint64_t (*get_fst_cmem_base)(struct cdp_soc_t *soc_hdl, uint64_t size); +#ifdef WLAN_SUPPORT_DPDK + void (*dpdk_get_ring_info)(struct cdp_soc_t *soc_hdl, + qdf_uio_info_t *uio_info); +#endif }; struct cdp_ctrl_ops { diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c index fbc23e734b..796223ce06 100644 --- a/dp/wifi3.0/dp_main.c +++ b/dp/wifi3.0/dp_main.c @@ -12185,6 +12185,166 @@ update_tx_ilp: } #endif +#ifdef WLAN_SUPPORT_DPDK +static char *tcl_ring_name[] = { + "tcl_data_ring1", + "tcl_data_ring2", + "tcl_data_ring3", + "tcl_data_ring4", + "tcl_data_ring5", +}; + +static char *tcl_comp_ring_name[] = { + "tcl_comp_ring1", + "tcl_comp_ring2", + "tcl_comp_ring3", + "tcl_comp_ring4", + "tcl_comp_ring5", +}; + +static char *reo_dest_ring_name[] = { + "reo_dest_ring1", + "reo_dest_ring2", + "reo_dest_ring3", + "reo_dest_ring4", + "reo_dest_ring5", + "reo_dest_ring6", + "reo_dest_ring7", + "reo_dest_ring8", +}; + +static void dp_dpdk_get_ring_info(struct cdp_soc_t *soc_hdl, + qdf_uio_info_t *uio_info) +{ + struct dp_soc *soc = (struct dp_soc *)soc_hdl; + struct hal_soc *hal_soc = (struct hal_soc *)soc->hal_soc; + struct hal_srng *hal_srng; + uint8_t idx = 1, i; + + /* WBM Desc Release Ring */ + hal_srng = (struct hal_srng *) + soc->tcl_data_ring[0].hal_srng; + + hal_srng = (struct hal_srng *) + soc->wbm_desc_rel_ring.hal_srng; + uio_info->mem[idx].name = "wbm_desc_rel_ring"; + uio_info->mem[idx].addr = (unsigned long)hal_srng->ring_base_paddr; + uio_info->mem[idx].size = + (hal_srng->num_entries * hal_srng->entry_size) << 2; + uio_info->mem[idx].memtype = UIO_MEM_PHYS; + idx++; + + /* WBM Idle Link Ring */ + hal_srng = (struct hal_srng *) + soc->wbm_idle_link_ring.hal_srng; + uio_info->mem[idx].name = "wbm_idle_link_ring"; + uio_info->mem[idx].addr = (unsigned long)hal_srng->ring_base_paddr; + uio_info->mem[idx].size = + (hal_srng->num_entries * hal_srng->entry_size) << 2; + uio_info->mem[idx].memtype = UIO_MEM_PHYS; + idx++; + + /* TCL Data Rings */ + for (i = 0; i < soc->num_tcl_data_rings; i++) { + hal_srng = (struct hal_srng *) + soc->tcl_data_ring[i].hal_srng; + uio_info->mem[idx].name = tcl_ring_name[i]; + uio_info->mem[idx].addr = + (unsigned long)hal_srng->ring_base_paddr; + uio_info->mem[idx].size = + (hal_srng->num_entries * hal_srng->entry_size) << 2; + uio_info->mem[idx].memtype = UIO_MEM_PHYS; + idx++; + } + + /* TCL Completion Rings */ + for (i = 0; i < soc->num_tcl_data_rings; i++) { + hal_srng = (struct hal_srng *) + soc->tx_comp_ring[i].hal_srng; + uio_info->mem[idx].name = tcl_comp_ring_name[i]; + uio_info->mem[idx].addr = + (unsigned long)hal_srng->ring_base_paddr; + uio_info->mem[idx].size = + (hal_srng->num_entries * hal_srng->entry_size) << 2; + uio_info->mem[idx].memtype = UIO_MEM_PHYS; + idx++; + } + + /* Reo Dest Rings */ + for (i = 0; i < soc->num_reo_dest_rings; i++) { + hal_srng = (struct hal_srng *) + soc->reo_dest_ring[i].hal_srng; + uio_info->mem[idx].name = reo_dest_ring_name[i]; + uio_info->mem[idx].addr = + (unsigned long)hal_srng->ring_base_paddr; + uio_info->mem[idx].size = + (hal_srng->num_entries * hal_srng->entry_size) << 2; + uio_info->mem[idx].memtype = UIO_MEM_PHYS; + idx++; + } + + /* RXDMA Refill Ring */ + hal_srng = (struct hal_srng *) + soc->rx_refill_buf_ring[0].hal_srng; + uio_info->mem[idx].name = "rxdma_buf_ring"; + uio_info->mem[idx].addr = (unsigned long)hal_srng->ring_base_paddr; + uio_info->mem[idx].size = + (hal_srng->num_entries * hal_srng->entry_size) << 2; + uio_info->mem[idx].memtype = UIO_MEM_PHYS; + idx++; + + /* REO Exception Ring */ + hal_srng = (struct hal_srng *) + soc->reo_exception_ring.hal_srng; + uio_info->mem[idx].name = "reo_exception_ring"; + uio_info->mem[idx].addr = + (unsigned long)hal_srng->ring_base_paddr; + uio_info->mem[idx].size = + (hal_srng->num_entries * hal_srng->entry_size) << 2; + uio_info->mem[idx].memtype = UIO_MEM_PHYS; + idx++; + + /* RX Release Ring */ + hal_srng = (struct hal_srng *) + soc->rx_rel_ring.hal_srng; + uio_info->mem[idx].name = "rx_release_ring"; + uio_info->mem[idx].addr = (unsigned long)hal_srng->ring_base_paddr; + uio_info->mem[idx].size = + (hal_srng->num_entries * hal_srng->entry_size) << 2; + uio_info->mem[idx].memtype = UIO_MEM_PHYS; + idx++; + + /* Reo Reinject Ring */ + hal_srng = (struct hal_srng *) + soc->reo_reinject_ring.hal_srng; + uio_info->mem[idx].name = "reo_reinject_ring"; + uio_info->mem[idx].addr = + (unsigned long)hal_srng->ring_base_paddr; + uio_info->mem[idx].size = + (hal_srng->num_entries * hal_srng->entry_size) << 2; + uio_info->mem[idx].memtype = UIO_MEM_PHYS; + idx++; + + /* Shadow Write Pointer for LMAC Ring */ + uio_info->mem[idx].name = "lmac_shadow_wrptr"; + uio_info->mem[idx].addr = + (unsigned long)hal_soc->shadow_wrptr_mem_paddr; + uio_info->mem[idx].size = + sizeof(*(hal_soc->shadow_wrptr_mem_vaddr)) * HAL_MAX_LMAC_RINGS; + uio_info->mem[idx].memtype = UIO_MEM_PHYS; + idx++; + + /* Shadow Write Pointer for LMAC Ring */ + uio_info->mem[idx].name = "lmac_shadow_rdptr"; + uio_info->mem[idx].addr = + (unsigned long)hal_soc->shadow_rdptr_mem_paddr; + uio_info->mem[idx].size = + sizeof(*(hal_soc->shadow_rdptr_mem_vaddr)) * HAL_SRNG_ID_MAX; + uio_info->mem[idx].memtype = UIO_MEM_PHYS; + +} +#endif + static struct cdp_cmn_ops dp_ops_cmn = { .txrx_soc_attach_target = dp_soc_attach_target_wifi3, .txrx_vdev_attach = dp_vdev_attach_wifi3, @@ -12321,6 +12481,9 @@ static struct cdp_cmn_ops dp_ops_cmn = { #ifdef WLAN_SUPPORT_RX_FISA .get_fst_cmem_base = dp_rx_fisa_get_cmem_base, #endif +#ifdef WLAN_SUPPORT_DPDK + .dpdk_get_ring_info = dp_dpdk_get_ring_info, +#endif }; static struct cdp_ctrl_ops dp_ops_ctrl = { @@ -14375,6 +14538,10 @@ static QDF_STATUS dp_pdev_init(struct cdp_soc_t *txrx_soc, dp_soc_reset_intr_mask(soc); } + /* Reset the ring interrupt mask if DPDK is enabled */ + if (wlan_cfg_get_dp_soc_dpdk_cfg(soc->ctrl_psoc)) { + dp_soc_reset_dpdk_intr_mask(soc); + } /* Reset the cpu ring map if radio is NSS offloaded */ dp_soc_reset_ipa_vlan_intr_mask(soc); diff --git a/dp/wifi3.0/dp_rings.h b/dp/wifi3.0/dp_rings.h index 5c9430ad1a..63cbfaf99b 100644 --- a/dp/wifi3.0/dp_rings.h +++ b/dp/wifi3.0/dp_rings.h @@ -863,4 +863,17 @@ dp_srng_configure_nf_interrupt_thresholds(struct dp_soc *soc, { } #endif + +#ifdef WLAN_SUPPORT_DPDK +/* + * dp_soc_reset_dpdk_intr_mask() - reset interrupt mask + * @dp_soc - DP Soc handle + * + * Return: Return void + */ +void dp_soc_reset_dpdk_intr_mask(struct dp_soc *soc); +#else +static inline void dp_soc_reset_dpdk_intr_mask(struct dp_soc *soc) +{ } +#endif #endif /* _DP_RINGS_H_ */ diff --git a/dp/wifi3.0/dp_rings_main.c b/dp/wifi3.0/dp_rings_main.c index 973faa51f5..522ac0601d 100644 --- a/dp/wifi3.0/dp_rings_main.c +++ b/dp/wifi3.0/dp_rings_main.c @@ -4258,3 +4258,122 @@ void dp_pdev_set_default_reo(struct dp_pdev *pdev) } } +#ifdef WLAN_SUPPORT_DPDK +void dp_soc_reset_dpdk_intr_mask(struct dp_soc *soc) +{ + uint8_t j; + uint8_t *grp_mask = NULL; + int group_number, mask, num_ring; + + /* number of tx ring */ + num_ring = soc->num_tcl_data_rings; + + /* + * group mask for tx completion ring. + */ + grp_mask = &soc->wlan_cfg_ctx->int_tx_ring_mask[0]; + + for (j = 0; j < WLAN_CFG_NUM_TCL_DATA_RINGS; j++) { + /* + * Group number corresponding to tx offloaded ring. + */ + group_number = dp_srng_find_ring_in_mask(j, grp_mask); + if (group_number < 0) { + dp_init_debug("%pK: ring not part of any group; ring_type: %d, ring_num %d", + soc, WBM2SW_RELEASE, j); + continue; + } + + mask = wlan_cfg_get_tx_ring_mask(soc->wlan_cfg_ctx, + group_number); + + /* reset the tx mask for offloaded ring */ + mask &= (~(1 << j)); + + /* + * reset the interrupt mask for offloaded ring. + */ + wlan_cfg_set_tx_ring_mask(soc->wlan_cfg_ctx, + group_number, mask); + } + + /* number of rx rings */ + num_ring = soc->num_reo_dest_rings; + + /* + * group mask for reo destination ring. + */ + grp_mask = &soc->wlan_cfg_ctx->int_rx_ring_mask[0]; + + for (j = 0; j < WLAN_CFG_NUM_REO_DEST_RING; j++) { + /* + * Group number corresponding to rx offloaded ring. + */ + group_number = dp_srng_find_ring_in_mask(j, grp_mask); + if (group_number < 0) { + dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d", + soc, REO_DST, j); + continue; + } + + mask = wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, + group_number); + + /* reset the interrupt mask for offloaded ring */ + mask &= (~(1 << j)); + + /* + * set the interrupt mask to zero for rx offloaded radio. + */ + wlan_cfg_set_rx_ring_mask(soc->wlan_cfg_ctx, + group_number, mask); + } + + /* + * group mask for Rx buffer refill ring + */ + grp_mask = &soc->wlan_cfg_ctx->int_host2rxdma_ring_mask[0]; + + for (j = 0; j < MAX_PDEV_CNT; j++) { + int lmac_id = wlan_cfg_get_hw_mac_idx(soc->wlan_cfg_ctx, j); + + /* + * Group number corresponding to rx offloaded ring. + */ + group_number = dp_srng_find_ring_in_mask(lmac_id, grp_mask); + if (group_number < 0) { + dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d", + soc, REO_DST, lmac_id); + continue; + } + + /* set the interrupt mask for offloaded ring */ + mask = wlan_cfg_get_host2rxdma_ring_mask(soc->wlan_cfg_ctx, + group_number); + mask &= (~(1 << lmac_id)); + + /* + * set the interrupt mask to zero for rx offloaded radio. + */ + wlan_cfg_set_host2rxdma_ring_mask(soc->wlan_cfg_ctx, + group_number, mask); + } + + grp_mask = &soc->wlan_cfg_ctx->int_rx_err_ring_mask[0]; + + for (j = 0; j < num_ring; j++) { + /* + * Group number corresponding to rx err ring. + */ + group_number = dp_srng_find_ring_in_mask(j, grp_mask); + if (group_number < 0) { + dp_init_debug("%pK: ring not part of any group; ring_type: %d,ring_num %d", + soc, REO_EXCEPTION, j); + continue; + } + + wlan_cfg_set_rx_err_ring_mask(soc->wlan_cfg_ctx, + group_number, 0); + } +} +#endif diff --git a/qdf/inc/qdf_platform.h b/qdf/inc/qdf_platform.h index b5e2ff47c7..327030f583 100644 --- a/qdf/inc/qdf_platform.h +++ b/qdf/inc/qdf_platform.h @@ -368,4 +368,23 @@ void qdf_register_get_bus_reg_dump(qdf_bus_reg_dump callback); * Return: none */ void qdf_get_bus_reg_dump(struct device *dev, uint8_t *buf, uint32_t len); + +#ifdef WLAN_SUPPORT_DPDK +/** + * qdf_uio_register_device() - register dev to UIO dev + * @parent: parent device to be registered with UIO dev + * @info: UIO device capabilities + * + * Return: zero on success or a negative error code + */ +int qdf_uio_register_device(struct device *parent, qdf_uio_info_t *info); + +/** + * qdf_uio_unregister_device - unregister a UIO device + * @info: UIO device capabilities + * + * Return: none + */ +void qdf_uio_unregister_device(qdf_uio_info_t *info); +#endif #endif /*_QDF_PLATFORM_H*/ diff --git a/qdf/linux/src/i_qdf_types.h b/qdf/linux/src/i_qdf_types.h index 6b958c01a2..4d9215e5e0 100644 --- a/qdf/linux/src/i_qdf_types.h +++ b/qdf/linux/src/i_qdf_types.h @@ -65,6 +65,9 @@ #ifdef IPA_OFFLOAD #include #endif +#ifdef WLAN_SUPPORT_DPDK +#include +#endif #define __qdf_must_check __must_check @@ -365,6 +368,10 @@ enum __qdf_net_wireless_evcode { #endif #define __qdf_inline inline +#if defined(WLAN_SUPPORT_DPDK) && defined(__KERNEL__) +typedef struct uio_info qdf_uio_info_t; +#endif + /* * 1. GNU C/C++ Compiler * diff --git a/qdf/src/qdf_platform.c b/qdf/src/qdf_platform.c index c2258eb8e3..a6a077cc45 100644 --- a/qdf/src/qdf_platform.c +++ b/qdf/src/qdf_platform.c @@ -253,3 +253,19 @@ void qdf_get_bus_reg_dump(struct device *dev, uint8_t *buf, uint32_t len) } qdf_export_symbol(qdf_get_bus_reg_dump); + +#ifdef WLAN_SUPPORT_DPDK +int qdf_uio_register_device(struct device *parent, qdf_uio_info_t *info) +{ + return uio_register_device(parent, (struct uio_info *)info); +} + +qdf_export_symbol(qdf_uio_register_device); + +void qdf_uio_unregister_device(qdf_uio_info_t *info) +{ + uio_unregister_device(info); +} + +qdf_export_symbol(qdf_uio_unregister_device); +#endif diff --git a/wlan_cfg/wlan_cfg.c b/wlan_cfg/wlan_cfg.c index 9a17aecad5..6c3a54b9f2 100644 --- a/wlan_cfg/wlan_cfg.c +++ b/wlan_cfg/wlan_cfg.c @@ -5916,3 +5916,15 @@ bool wlan_cfg_get_ast_indication_disable(struct wlan_cfg_dp_soc_ctxt *cfg) { return cfg->fw_ast_indication_disable; } + +#ifdef WLAN_SUPPORT_DPDK +int wlan_cfg_get_dp_soc_dpdk_cfg(struct cdp_ctrl_objmgr_psoc *psoc) +{ + return cfg_get(psoc, CFG_DPDK_WIFI); +} +#else +int wlan_cfg_get_dp_soc_dpdk_cfg(struct cdp_ctrl_objmgr_psoc *psoc) +{ + return 0; +} +#endif diff --git a/wlan_cfg/wlan_cfg.h b/wlan_cfg/wlan_cfg.h index f5050b7799..31fb5a3e2a 100644 --- a/wlan_cfg/wlan_cfg.h +++ b/wlan_cfg/wlan_cfg.h @@ -2737,4 +2737,12 @@ void wlan_cfg_set_ast_indication_disable(struct wlan_cfg_dp_soc_ctxt *cfg, * Return: true or false */ bool wlan_cfg_get_ast_indication_disable(struct wlan_cfg_dp_soc_ctxt *cfg); + +/** + * wlan_cfg_get_dp_soc_dpdk_cfg - Return soc dpdk config + * @psoc: psoc object + * + * Return: dpdk_cfg + */ +int wlan_cfg_get_dp_soc_dpdk_cfg(struct cdp_ctrl_objmgr_psoc *psoc); #endif /*__WLAN_CFG_H*/