From 209d8138a305d81977481ebf1c7479d35c3495ef Mon Sep 17 00:00:00 2001 From: Ramanathan Choodamani Date: Tue, 7 Mar 2023 01:40:23 -0800 Subject: [PATCH 5/6] ath12k: Optimize Tx direct path variable init Group all the pointers used in the tx path in arvif and try to use all value from arvif. This could help avoid multiple locations being referred Signed-off-by: Balamurugan Mahalingam Signed-off-by: Ramanathan Choodamani --- drivers/net/wireless/ath/ath12k/core.h | 9 ++++++--- drivers/net/wireless/ath/ath12k/dp_tx.c | 33 +++++++++++++++++++-------------- drivers/net/wireless/ath/ath12k/mac.c | 4 ++++ 3 files changed, 29 insertions(+), 17 deletions(-) --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -326,7 +326,13 @@ struct ath12k_vif_tcl_desc_template { }; struct ath12k_link_vif { + struct ath12k_base *ab; + struct ath12k_dp *dp; struct ath12k_vif_tcl_desc_template desc; + struct ieee80211_vif *vif; + struct device *dev; + struct ath12k *ar; + u8 pdev_idx; u32 vdev_id; u32 beacon_interval; u32 dtim_period; @@ -336,9 +342,6 @@ struct ath12k_link_vif { u16 tcl_metadata; u8 hal_addr_search_flags; u8 search_type; - - struct ath12k *ar; - int bank_id; u8 vdev_id_check_en; --- a/drivers/net/wireless/ath/ath12k/dp_tx.c +++ b/drivers/net/wireless/ath/ath12k/dp_tx.c @@ -155,15 +155,18 @@ static int ath12k_dp_prepare_htt_metadat int ath12k_dp_tx_direct(struct ath12k_link_vif *arvif, struct sk_buff *skb) { struct ath12k *ar = arvif->ar; - struct ath12k_base *ab = ar->ab; - struct ath12k_dp *dp = &ab->dp; + struct ath12k_base *ab = arvif->ab; + struct ath12k_dp *dp = arvif->dp; struct ath12k_tx_desc_info *tx_desc = NULL; struct ath12k_skb_cb *skb_cb = ATH12K_SKB_CB(skb); struct hal_srng *tcl_ring; struct dp_tx_ring *tx_ring; + struct device *dev = arvif->dev; void *hal_tcl_desc; + void *mem = ab->mem; struct hal_tcl_data_cmd tcl_desc; u8 hal_ring_id, ring_id; + dma_addr_t paddr; int ret; ring_id = smp_processor_id(); @@ -175,9 +178,9 @@ int ath12k_dp_tx_direct(struct ath12k_li ab->soc_stats.tx_err.txbuf_na[ring_id]++; return -ENOSPC; } - skb_cb->paddr = dma_map_single(ab->dev, skb->data, 256, - DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(ab->dev, skb_cb->paddr))) { + paddr = dma_map_single(dev, skb->data, 256, + DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(dev, paddr))) { atomic_inc(&ab->soc_stats.tx_err.misc_fail); ath12k_warn(ab, "failed to DMA map data Tx buffer\n"); ret = -ENOMEM; @@ -185,11 +188,12 @@ int ath12k_dp_tx_direct(struct ath12k_li } tx_desc->skb = skb; - tx_desc->mac_id = ar->pdev_idx; + tx_desc->mac_id = arvif->pdev_idx; + skb_cb->vif = arvif->ahvif->vif; - skb_cb->ar = ar; + skb_cb->paddr = paddr; - hal_ring_id = tx_ring->tcl_data_ring.ring_id; + hal_ring_id = ring_id + HAL_SRNG_RING_ID_SW2TCL1; tcl_ring = &ab->hal.srng_list[hal_ring_id]; ath12k_hal_srng_access_src_ring_begin_nolock(ab, tcl_ring); @@ -199,7 +203,7 @@ int ath12k_dp_tx_direct(struct ath12k_li /* NOTE: It is highly unlikely we'll be running out of tcl_ring * desc because the desc is directly enqueued onto hw queue. */ - ath12k_hal_srng_access_umac_src_ring_end_nolock(ab->mem, tcl_ring); + ath12k_hal_srng_access_umac_src_ring_end_nolock(mem, tcl_ring); ab->soc_stats.tx_err.desc_na[ring_id]++; ret = -ENOMEM; goto fail_unmap_dma; @@ -207,7 +211,7 @@ int ath12k_dp_tx_direct(struct ath12k_li ab->soc_stats.tx_enqueued[ring_id]++; - tcl_desc.buf_addr_info.info0 = (u32)skb_cb->paddr; + tcl_desc.buf_addr_info.info0 = (u32)paddr; tcl_desc.buf_addr_info.info1 = (tx_desc->desc_id << 12); tcl_desc.info0 = arvif->desc.info0; tcl_desc.info1 = arvif->desc.info1; @@ -220,7 +224,7 @@ int ath12k_dp_tx_direct(struct ath12k_li tcl_desc.info5 = 0; memcpy(hal_tcl_desc, &tcl_desc, sizeof(tcl_desc)); dsb(st); - ath12k_hal_srng_access_umac_src_ring_end_nolock(ab->mem, tcl_ring); + ath12k_hal_srng_access_umac_src_ring_end_nolock(mem, tcl_ring); atomic_inc(&ar->dp.num_tx_pending); @@ -547,7 +551,7 @@ ath12k_dp_tx_htt_tx_complete_buf(struct struct sk_buff *msdu, struct dp_tx_ring *tx_ring, struct ath12k_dp_htt_wbm_tx_status *ts, - struct sk_buff *skb_ext_desc) + struct sk_buff *skb_ext_desc, u8 mac_id) { struct ieee80211_tx_info *info; struct ath12k_skb_cb *skb_cb; @@ -559,7 +563,7 @@ ath12k_dp_tx_htt_tx_complete_buf(struct skb_cb = ATH12K_SKB_CB(msdu); info = IEEE80211_SKB_CB(msdu); - ar = skb_cb->ar; + ar = ab->pdevs[mac_id].ar; ab->soc_stats.tx_completed[tx_ring->tcl_data_ring_id]++; if (atomic_dec_and_test(&ar->dp.num_tx_pending)) @@ -642,7 +646,8 @@ ath12k_dp_tx_process_htt_tx_complete(str ts.acked = (htt_status == HAL_WBM_REL_HTT_TX_COMP_STATUS_OK); ts.ack_rssi = u32_get_bits(status_desc->info2, HTT_TX_WBM_COMP_INFO2_ACK_RSSI); - ath12k_dp_tx_htt_tx_complete_buf(ab, msdu, tx_ring, &ts, skb_ext_desc); + ath12k_dp_tx_htt_tx_complete_buf(ab, msdu, tx_ring, &ts, skb_ext_desc, mac_id); + break; case HAL_WBM_REL_HTT_TX_COMP_STATUS_REINJ: case HAL_WBM_REL_HTT_TX_COMP_STATUS_INSPECT: --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -9442,6 +9442,10 @@ static int ath12k_mac_vdev_create(struct arvif->tx_vdev_id = vdev_id; ahvif->vdev_subtype = WMI_VDEV_SUBTYPE_NONE; arvif->ar = ar; + arvif->ab = ab; + arvif->dp = &ab->dp; + arvif->dev = ab->dev; + arvif->pdev_idx = ar->pdev_idx; switch (vif->type) { case NL80211_IFTYPE_UNSPECIFIED: