Browse Source

qcacld-3.0: Add ol soc context

Add the soc context for ol_txrx.
This soc layer is used to hold ol pdev context.

CRs-Fixed: 2539731
Change-Id: I27a3f34a533034a4748674ce8b9212163b231b24
Rakesh Pillai 5 years ago
parent
commit
ca99b83616
3 changed files with 84 additions and 13 deletions
  1. 25 13
      core/dp/txrx/ol_txrx.c
  2. 34 0
      core/dp/txrx/ol_txrx.h
  3. 25 0
      core/dp/txrx/ol_txrx_types.h

+ 25 - 13
core/dp/txrx/ol_txrx.c

@@ -701,9 +701,11 @@ static inline void ol_txrx_debugfs_exit(ol_txrx_pdev_handle pdev)
 
 /**
  * ol_txrx_pdev_attach() - allocate txrx pdev
+ * @soc: soc handle
  * @ctrl_pdev: cfg pdev
  * @htc_pdev: HTC pdev
  * @osdev: os dev
+ * @pdev_id: pdev identifier for pdev attach
  *
  * Return: txrx pdev handle
  *		  NULL for failure
@@ -713,10 +715,14 @@ ol_txrx_pdev_attach(ol_txrx_soc_handle soc,
 		    struct cdp_ctrl_objmgr_pdev *ctrl_pdev,
 		    HTC_HANDLE htc_pdev, qdf_device_t osdev, uint8_t pdev_id)
 {
+	struct ol_txrx_soc_t *ol_soc = cdp_soc_t_to_ol_txrx_soc_t(soc);
 	struct ol_txrx_pdev_t *pdev;
 	struct cdp_cfg *cfg_pdev = (struct cdp_cfg *)ctrl_pdev;
 	int i, tid;
 
+	if (pdev_id == OL_TXRX_INVALID_PDEV_ID)
+		return NULL;
+
 	pdev = qdf_mem_malloc(sizeof(*pdev));
 	if (!pdev)
 		goto fail0;
@@ -739,6 +745,9 @@ ol_txrx_pdev_attach(ol_txrx_soc_handle soc,
 	/* store provided params */
 	pdev->ctrl_pdev = cfg_pdev;
 	pdev->osdev = osdev;
+	pdev->id = pdev_id;
+	pdev->soc = ol_soc;
+	ol_soc->pdev_list[pdev_id] = pdev;
 
 	for (i = 0; i < htt_num_sec_types; i++)
 		pdev->sec_types[i] = (enum ol_sec_type)i;
@@ -1578,10 +1587,16 @@ static void ol_txrx_pdev_pre_detach(struct cdp_pdev *ppdev, int force)
  */
 static void ol_txrx_pdev_detach(struct cdp_pdev *ppdev, int force)
 {
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
 	struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev;
 	struct ol_txrx_stats_req_internal *req, *temp_req;
 	int i = 0;
 
+	if (!soc)
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
 	/*checking to ensure txrx pdev structure is not NULL */
 	if (!pdev) {
 		ol_txrx_err("pdev is NULL");
@@ -1632,6 +1647,7 @@ static void ol_txrx_pdev_detach(struct cdp_pdev *ppdev, int force)
 
 	ol_txrx_debugfs_exit(pdev);
 
+	soc->pdev_list[pdev->id] = NULL;
 	qdf_mem_free(pdev);
 }
 
@@ -5891,24 +5907,20 @@ static struct cdp_ops ol_txrx_ops = {
 	.pmf_ops = &ol_ops_pmf
 };
 
-/*
- * Local prototype added to temporarily address warning caused by
- * -Wmissing-prototypes. A more correct solution, namely to expose
- * a prototype in an appropriate header file, will come later.
- */
-struct cdp_soc_t *ol_txrx_soc_attach(void *scn_handle,
-				     struct ol_if_ops *dp_ol_if_ops);
-struct cdp_soc_t *ol_txrx_soc_attach(void *scn_handle,
-				     struct ol_if_ops *dp_ol_if_ops)
+ol_txrx_soc_handle ol_txrx_soc_attach(void *scn_handle,
+				      struct ol_if_ops *dp_ol_if_ops)
 {
-	struct cdp_soc_t *soc = qdf_mem_malloc(sizeof(struct cdp_soc_t));
+	struct ol_txrx_soc_t *soc;
 
+	soc = qdf_mem_malloc(sizeof(*soc));
 	if (!soc)
 		return NULL;
 
-	soc->ops = &ol_txrx_ops;
-	soc->ol_ops = dp_ol_if_ops;
-	return soc;
+	soc->psoc = scn_handle;
+	soc->cdp_soc.ops = &ol_txrx_ops;
+	soc->cdp_soc.ol_ops = dp_ol_if_ops;
+
+	return ol_txrx_soc_t_to_cdp_soc_t(soc);
 }
 
 bool ol_txrx_get_new_htt_msg_format(struct ol_txrx_pdev_t *pdev)

+ 34 - 0
core/dp/txrx/ol_txrx.h

@@ -74,6 +74,16 @@ ol_txrx_peer_handle ol_txrx_peer_get_ref_by_addr(ol_txrx_pdev_handle pdev,
 int  ol_txrx_peer_release_ref(ol_txrx_peer_handle peer,
 			      enum peer_debug_id_type dbg_id);
 
+/**
+ * ol_txrx_soc_attach() - initialize the soc
+ * @scn_handle: Opaque SOC handle from control plane
+ * @dp_ol_if_ops: Offload Operations
+ *
+ * Return: SOC handle on success, NULL on failure
+ */
+ol_txrx_soc_handle ol_txrx_soc_attach(void *scn_handle,
+				      struct ol_if_ops *dp_ol_if_ops);
+
 /**
  * ol_tx_desc_pool_size_hl() - allocate tx descriptor pool size for HL systems
  * @ctrl_pdev: the control pdev handle
@@ -308,6 +318,30 @@ uint32_t ol_tx_get_desc_global_pool_size(struct ol_txrx_pdev_t *pdev)
 #endif
 #endif
 
+/**
+ * cdp_soc_t_to_ol_txrx_soc_t() - typecast cdp_soc_t to ol_txrx_soc_t
+ * @soc: OL soc handle
+ *
+ * Return: struct ol_txrx_soc_t pointer
+ */
+static inline
+struct ol_txrx_soc_t *cdp_soc_t_to_ol_txrx_soc_t(ol_txrx_soc_handle soc)
+{
+	return (struct ol_txrx_soc_t *)soc;
+}
+
+/**
+ * ol_txrx_soc_t_to_cdp_soc_t() - typecast ol_txrx_soc_t to cdp_soc
+ * @soc: Opaque soc handle
+ *
+ * Return: struct cdp_soc_t pointer
+ */
+static inline
+ol_txrx_soc_handle ol_txrx_soc_t_to_cdp_soc_t(struct ol_txrx_soc_t *soc)
+{
+	return (struct cdp_soc_t *)soc;
+}
+
 #ifdef QCA_LL_TX_FLOW_CONTROL_V2
 void ol_tx_set_desc_global_pool_size(uint32_t num_msdu_desc);
 uint32_t ol_tx_get_total_free_desc(struct ol_txrx_pdev_t *pdev);

+ 25 - 0
core/dp/txrx/ol_txrx_types.h

@@ -81,6 +81,8 @@
 #define ETHERTYPE_OCB_TX   0x8151
 #define ETHERTYPE_OCB_RX   0x8152
 
+#define OL_TXRX_MAX_PDEV_CNT	1
+
 struct ol_txrx_pdev_t;
 struct ol_txrx_vdev_t;
 struct ol_txrx_peer_t;
@@ -569,6 +571,23 @@ struct ol_txrx_fw_stats_desc_elem_t {
 	struct ol_txrx_fw_stats_desc_t desc;
 };
 
+/**
+ * struct ol_txrx_soc_t - soc reference structure
+ * @cdp_soc: common base structure
+ * @cdp_ctrl_objmgr_psoc: opaque handle for UMAC psoc object
+ * @pdev_list: list of all the pdev on a soc
+ *
+ * This is the reference to the soc and all the data
+ * which is soc specific.
+ */
+struct ol_txrx_soc_t {
+	/* Common base structure - Should be the first member */
+	struct cdp_soc_t cdp_soc;
+
+	struct cdp_ctrl_objmgr_psoc *psoc;
+	struct ol_txrx_pdev_t *pdev_list[OL_TXRX_MAX_PDEV_CNT];
+};
+
 /*
  * As depicted in the diagram below, the pdev contains an array of
  * NUM_EXT_TID ol_tx_active_queues_in_tid_t elements.
@@ -623,6 +642,9 @@ struct ol_txrx_fw_stats_desc_elem_t {
  *                        `------'
  */
 struct ol_txrx_pdev_t {
+	/* soc - reference to soc structure */
+	struct ol_txrx_soc_t *soc;
+
 	/* ctrl_pdev - handle for querying config info */
 	struct cdp_cfg *ctrl_pdev;
 
@@ -792,6 +814,9 @@ struct ol_txrx_pdev_t {
 #endif
 	} tx_desc;
 
+	/* The pdev_id for this pdev */
+	uint8_t id;
+
 	uint8_t is_mgmt_over_wmi_enabled;
 #if defined(QCA_LL_TX_FLOW_CONTROL_V2)
 	struct ol_txrx_pool_stats pool_stats;