Browse Source

qcacld-3.0: Refactor fisa packet history for BE

Refactor fisa history to not directly access "struct rx_pkt_tlvs". This
is needed since rx_pkt_tlv size may be different for Li and Be
architectures.

CRs-Fixed: 2891099
Change-Id: If7359680538128c7b093aef9f2991756a2f753f7
Rakesh Pillai 3 năm trước cách đây
mục cha
commit
7fdb9e21a7
2 tập tin đã thay đổi với 75 bổ sung65 xóa
  1. 30 26
      core/dp/txrx3.0/dp_fisa_rx.c
  2. 45 39
      core/dp/txrx3.0/dp_rx_fst.c

+ 30 - 26
core/dp/txrx3.0/dp_fisa_rx.c

@@ -112,24 +112,24 @@ static void dump_tlvs(hal_soc_handle_t hal_soc_hdl, uint8_t *buf,
 #ifdef WLAN_SUPPORT_RX_FISA_HIST
 static
 void dp_fisa_record_pkt(struct dp_fisa_rx_sw_ft *fisa_flow, qdf_nbuf_t nbuf,
-			uint8_t *rx_tlv_hdr)
+			uint8_t *rx_tlv_hdr, uint16_t tlv_size)
 {
 	uint32_t index;
-	struct fisa_pkt_hist_elem *hist_elem;
+	uint8_t *tlv_hist_ptr;
 
-	if (!rx_tlv_hdr || !fisa_flow || !fisa_flow->pkt_hist)
+	if (!rx_tlv_hdr || !fisa_flow || !fisa_flow->pkt_hist.tlv_hist)
 		return;
 
-	index = fisa_flow->pkt_hist->idx++ % FISA_FLOW_MAX_AGGR_COUNT;
-	hist_elem = &fisa_flow->pkt_hist->hist_elem[index];
+	index = fisa_flow->pkt_hist.idx++ % FISA_FLOW_MAX_AGGR_COUNT;
 
-	hist_elem->ts = qdf_get_log_timestamp();
-	qdf_mem_copy(&hist_elem->tlvs, rx_tlv_hdr, sizeof(hist_elem->tlvs));
+	fisa_flow->pkt_hist.ts_hist[index] = qdf_get_log_timestamp();
+	tlv_hist_ptr = fisa_flow->pkt_hist.tlv_hist + (index * tlv_size);
+	qdf_mem_copy(tlv_hist_ptr, rx_tlv_hdr, tlv_size);
 }
 #else
 static
 void dp_fisa_record_pkt(struct dp_fisa_rx_sw_ft *fisa_flow, qdf_nbuf_t nbuf,
-			uint8_t *rx_tlv_hdr)
+			uint8_t *rx_tlv_hdr, uint16_t tlv_size)
 {
 }
 
@@ -556,7 +556,7 @@ dp_rx_fisa_add_ft_entry(struct dp_vdev *vdev,
 			sw_ft_entry->napi_id = reo_id;
 			sw_ft_entry->reo_dest_indication = reo_dest_indication;
 			sw_ft_entry->flow_id_toeplitz =
-				hal_rx_msdu_start_toeplitz_get(rx_tlv_hdr);
+						QDF_NBUF_CB_RX_FLOW_ID(nbuf);
 			sw_ft_entry->flow_init_ts = qdf_get_log_timestamp();
 
 			qdf_mem_copy(&sw_ft_entry->rx_flow_tuple_info,
@@ -655,12 +655,14 @@ static bool is_flow_idx_valid(bool flow_invalid, bool flow_timeout)
  * dp_rx_fisa_get_pkt_hist() - Get ptr to pkt history from rx sw ft entry
  * @ft_entry: sw ft entry
  *
- * Return: ptr to pkt history
+ * Return: None
  */
-static inline struct fisa_pkt_hist *
-dp_rx_fisa_get_pkt_hist(struct dp_fisa_rx_sw_ft *ft_entry)
+static inline void
+dp_rx_fisa_save_pkt_hist(struct dp_fisa_rx_sw_ft *ft_entry,
+			 struct fisa_pkt_hist *pkt_hist)
 {
-	return ft_entry->pkt_hist;
+	/* Structure copy by assignment */
+	*pkt_hist = ft_entry->pkt_hist;
 }
 
 /**
@@ -671,21 +673,22 @@ dp_rx_fisa_get_pkt_hist(struct dp_fisa_rx_sw_ft *ft_entry)
  * Return: None
  */
 static inline void
-dp_rx_fisa_set_pkt_hist(struct dp_fisa_rx_sw_ft *ft_entry,
-			struct fisa_pkt_hist *pkt_hist)
+dp_rx_fisa_restore_pkt_hist(struct dp_fisa_rx_sw_ft *ft_entry,
+			    struct fisa_pkt_hist *pkt_hist)
 {
-	ft_entry->pkt_hist = pkt_hist;
+	/* Structure copy by assignment */
+	ft_entry->pkt_hist = *pkt_hist;
 }
 #else
-static inline struct fisa_pkt_hist *
-dp_rx_fisa_get_pkt_hist(struct dp_fisa_rx_sw_ft *ft_entry)
+static inline void
+dp_rx_fisa_save_pkt_hist(struct dp_fisa_rx_sw_ft *ft_entry,
+			 struct fisa_pkt_hist *pkt_hist)
 {
-	return NULL;
 }
 
 static inline void
-dp_rx_fisa_set_pkt_hist(struct dp_fisa_rx_sw_ft *ft_entry,
-			struct fisa_pkt_hist *pkt_hist)
+dp_rx_fisa_restore_pkt_hist(struct dp_fisa_rx_sw_ft *ft_entry,
+			    struct fisa_pkt_hist *pkt_hist)
 {
 }
 #endif
@@ -705,8 +708,8 @@ dp_fisa_rx_delete_flow(struct dp_rx_fst *fisa_hdl,
 		       uint32_t hashed_flow_idx)
 {
 	struct dp_fisa_rx_sw_ft *sw_ft_entry;
+	struct fisa_pkt_hist pkt_hist;
 	u8 reo_id;
-	struct fisa_pkt_hist *pkt_hist;
 
 	sw_ft_entry = &(((struct dp_fisa_rx_sw_ft *)
 				fisa_hdl->base)[hashed_flow_idx]);
@@ -717,11 +720,11 @@ dp_fisa_rx_delete_flow(struct dp_rx_fst *fisa_hdl,
 	/* Flush the flow before deletion */
 	dp_rx_fisa_flush_flow_wrap(sw_ft_entry);
 
-	pkt_hist = dp_rx_fisa_get_pkt_hist(sw_ft_entry);
-
+	dp_rx_fisa_save_pkt_hist(sw_ft_entry, &pkt_hist);
+	/* Clear the sw_ft_entry */
 	memset(sw_ft_entry, 0, sizeof(*sw_ft_entry));
+	dp_rx_fisa_restore_pkt_hist(sw_ft_entry, &pkt_hist);
 
-	dp_rx_fisa_set_pkt_hist(sw_ft_entry, pkt_hist);
 	dp_rx_fisa_update_sw_ft_entry(sw_ft_entry, elem->flow_idx, elem->vdev,
 				      fisa_hdl->soc_hdl, hashed_flow_idx);
 
@@ -1777,7 +1780,8 @@ static int dp_add_nbuf_to_fisa_flow(struct dp_rx_fst *fisa_hdl,
 		qdf_assert(0);
 	}
 
-	dp_fisa_record_pkt(fisa_flow, nbuf, rx_tlv_hdr);
+	dp_fisa_record_pkt(fisa_flow, nbuf, rx_tlv_hdr,
+			   fisa_hdl->soc_hdl->rx_pkt_tlv_size);
 
 	if (fisa_flow->is_flow_udp) {
 		dp_rx_fisa_aggr_udp(fisa_hdl, fisa_flow, nbuf);

+ 45 - 39
core/dp/txrx3.0/dp_rx_fst.c

@@ -199,50 +199,50 @@ static QDF_STATUS dp_rx_fst_cmem_init(struct dp_rx_fst *fst)
 }
 
 #ifdef WLAN_SUPPORT_RX_FISA_HIST
-/**
- * dp_rx_sw_fst_hist_attach() - Initialize the pkt history per
- *  sw ft entry
- * @fst: pointer to rx fst info
- *
- * Return: None
- */
-static void
-dp_rx_sw_fst_hist_attach(struct dp_rx_fst *fst)
+static
+QDF_STATUS dp_rx_sw_ft_hist_init(struct dp_fisa_rx_sw_ft *sw_ft,
+				 uint32_t max_entries,
+				 uint32_t rx_pkt_tlv_size)
 {
-	struct dp_fisa_rx_sw_ft *ft_entry;
 	int i;
-
-	ft_entry = (struct dp_fisa_rx_sw_ft *)fst->base;
-	for (i = 0; i < fst->max_entries; i++)
-		ft_entry[i].pkt_hist = qdf_mem_malloc(
-						 sizeof(*ft_entry[i].pkt_hist));
+	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
+
+	for (i = 0; i < max_entries; i++) {
+		sw_ft[i].pkt_hist.tlv_hist =
+			(uint8_t *)qdf_mem_malloc(rx_pkt_tlv_size *
+						  FISA_FLOW_MAX_AGGR_COUNT);
+		if (!sw_ft[i].pkt_hist.tlv_hist) {
+			dp_err("unable to allocate tlv history");
+			qdf_status = QDF_STATUS_E_NOMEM;
+			break;
+		}
+	}
+	return qdf_status;
 }
 
-/**
- * dp_rx_sw_fst_hist_detach() - De-initialize the pkt history per
- *  sw ft entry
- * @fst: pointer to rx fst info
- *
- * Return: None
- */
-static void
-dp_rx_sw_fst_hist_detach(struct dp_rx_fst *fst)
+static void dp_rx_sw_ft_hist_deinit(struct dp_fisa_rx_sw_ft *sw_ft,
+				    uint32_t max_entries)
 {
-	struct dp_fisa_rx_sw_ft *ft_entry;
 	int i;
 
-	ft_entry = (struct dp_fisa_rx_sw_ft *)fst->base;
-	for (i = 0; i < fst->max_entries; i++)
-		qdf_mem_free(ft_entry[i].pkt_hist);
+	for (i = 0; i < max_entries; i++) {
+		if (sw_ft[i].pkt_hist.tlv_hist)
+			qdf_mem_free(sw_ft[i].pkt_hist.tlv_hist);
+	}
 }
+
 #else
-static inline void
-dp_rx_sw_fst_hist_attach(struct dp_rx_fst *fst)
+
+static
+QDF_STATUS dp_rx_sw_ft_hist_init(struct dp_fisa_rx_sw_ft *sw_ft,
+				 uint32_t max_entries,
+				 uint32_t rx_pkt_tlv_size)
 {
+	return QDF_STATUS_SUCCESS;
 }
 
-static inline void
-dp_rx_sw_fst_hist_detach(struct dp_rx_fst *fst)
+static void dp_rx_sw_ft_hist_deinit(struct dp_fisa_rx_sw_ft *sw_ft,
+				    uint32_t max_entries)
 {
 }
 #endif
@@ -302,13 +302,17 @@ QDF_STATUS dp_rx_fst_attach(struct dp_soc *soc, struct dp_pdev *pdev)
 				DP_RX_GET_SW_FT_ENTRY_SIZE * fst->max_entries);
 
 	if (!fst->base)
-		goto out2;
+		goto free_rx_fst;
 
 	ft_entry = (struct dp_fisa_rx_sw_ft *)fst->base;
+
 	for (i = 0; i < fst->max_entries; i++)
 		ft_entry[i].napi_id = INVALID_NAPI;
 
-	dp_rx_sw_fst_hist_attach(fst);
+	status = dp_rx_sw_ft_hist_init(ft_entry, fst->max_entries,
+				       soc->rx_pkt_tlv_size);
+	if (QDF_IS_STATUS_ERROR(status))
+		goto free_hist;
 
 	fst->hal_rx_fst = hal_rx_fst_attach(soc->osdev,
 					    &fst->hal_rx_fst_base_paddr,
@@ -319,7 +323,7 @@ QDF_STATUS dp_rx_fst_attach(struct dp_soc *soc, struct dp_pdev *pdev)
 		QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_ERROR,
 			  "Rx Hal fst allocation failed, #entries:%d\n",
 			  fst->max_entries);
-		goto out1;
+		goto free_hist;
 	}
 
 	qdf_spinlock_create(&fst->dp_rx_fst_lock);
@@ -350,10 +354,11 @@ QDF_STATUS dp_rx_fst_attach(struct dp_soc *soc, struct dp_pdev *pdev)
 timer_init_fail:
 	qdf_spinlock_destroy(&fst->dp_rx_fst_lock);
 	hal_rx_fst_detach(fst->hal_rx_fst, soc->osdev);
-out1:
-	dp_rx_sw_fst_hist_detach(fst);
+free_hist:
+	dp_rx_sw_ft_hist_deinit((struct dp_fisa_rx_sw_ft *)fst->base,
+				fst->max_entries);
 	dp_context_free_mem(soc, DP_FISA_RX_FT_TYPE, fst->base);
-out2:
+free_rx_fst:
 	qdf_mem_free(fst);
 	return QDF_STATUS_E_NOMEM;
 }
@@ -447,7 +452,8 @@ void dp_rx_fst_detach(struct dp_soc *soc, struct dp_pdev *pdev)
 		else
 			hal_rx_fst_detach(dp_fst->hal_rx_fst, soc->osdev);
 
-		dp_rx_sw_fst_hist_detach(dp_fst);
+		dp_rx_sw_ft_hist_deinit((struct dp_fisa_rx_sw_ft *)dp_fst->base,
+					dp_fst->max_entries);
 		dp_context_free_mem(soc, DP_FISA_RX_FT_TYPE, dp_fst->base);
 		qdf_spinlock_destroy(&dp_fst->dp_rx_fst_lock);
 		qdf_mem_free(dp_fst);