Browse Source

qcacmn: Use converged packetdump API to avoid corrupting dp_pdev

Packetdump invokes legacy data path API directly without
considering underlying HW:
1. ol_register_packetdump_callback
2. ol_deregister_packetdump_callback
Global pointer pdev_txrx_ctx will be casted to struct ol_txrx_pdev_t
always even Lithium (use struct dp_pdev) underlying, that leads to
struct dp_pdev be overwritten unexpectly.

Wrap with cdp API to avoid.

About packet-dump feature:
It is one debug feature/requirement for Android N, to track/dump
TX/RX data/mgmt. packets during connection. This enhancement can help
in debugging connection related issues.
This change only touches its data packet callback register API.

Change-Id: Ie63fd2dfa909f89741ccf0c5131f6d3305093a3e
CRs-Fixed: 2366334
Lin Bai 6 years ago
parent
commit
324f49155b
3 changed files with 59 additions and 1 deletions
  1. 7 1
      dp/inc/cdp_txrx_cmn_struct.h
  2. 47 0
      dp/inc/cdp_txrx_misc.h
  3. 5 0
      dp/inc/cdp_txrx_ops.h

+ 7 - 1
dp/inc/cdp_txrx_cmn_struct.h

@@ -491,7 +491,7 @@ enum connectivity_stats_pkt_status {
 };
 
 /**
- * cdp_mgmt_tx_cb - tx management delivery notification
+ * ol_txrx_mgmt_tx_cb - tx management delivery notification
  * callback function
  */
 typedef void
@@ -632,6 +632,12 @@ typedef void (*ol_txrx_stats_callback)(void *ctxt,
 				       enum htt_cmn_dbg_stats_type type,
 				       uint8_t *buf, int bytes);
 
+/**
+ * ol_txrx_pktdump_cb - callback for packet dump feature
+ */
+typedef void (*ol_txrx_pktdump_cb)(qdf_nbuf_t netbuf, uint8_t status,
+				   uint8_t vdev_id, uint8_t type);
+
 /**
  * ol_txrx_ops - (pointers to) the functions used for tx and rx
  * data xfer

+ 47 - 0
dp/inc/cdp_txrx_misc.h

@@ -570,4 +570,51 @@ static inline int cdp_get_num_rx_contexts(ol_txrx_soc_handle soc)
 
 	return 0;
 }
+
+/**
+ * cdp_register_packetdump_cb() - API to register packetdump callback
+ *
+ * Register TX/RX callback for data packets, during connection. And per packet
+ * stats will be passed to user-space by @tx_cb/@rx_cb.
+ *
+ * @soc: soc handle
+ * @tx_cb: tx packet callback
+ * @rx_cb: rx packet callback
+ *
+ * Return: void
+ */
+static inline void cdp_register_packetdump_cb(ol_txrx_soc_handle soc,
+					      ol_txrx_pktdump_cb tx_cb,
+					      ol_txrx_pktdump_cb rx_cb)
+{
+	if (!soc || !soc->ops || !soc->ops->misc_ops) {
+		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
+			  "%s invalid instance", __func__);
+		return;
+	}
+
+	if (soc->ops->misc_ops->register_pktdump_cb)
+		return soc->ops->misc_ops->register_pktdump_cb(tx_cb, rx_cb);
+}
+
+/**
+ * cdp_deregister_packetdump_cb() - API to unregister packetdump callback
+ *
+ * Deregister callback for TX/RX data packets.
+ *
+ * @soc: soc handle
+ *
+ * Return: void
+ */
+static inline void cdp_deregister_packetdump_cb(ol_txrx_soc_handle soc)
+{
+	if (!soc || !soc->ops || !soc->ops->misc_ops) {
+		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
+			  "%s invalid instance", __func__);
+		return;
+	}
+
+	if (soc->ops->misc_ops->unregister_pktdump_cb)
+		return soc->ops->misc_ops->unregister_pktdump_cb();
+}
 #endif /* _CDP_TXRX_MISC_H_ */

+ 5 - 0
dp/inc/cdp_txrx_ops.h

@@ -956,6 +956,8 @@ struct ol_if_ops {
  * @txrx_post_data_stall_event
  * @runtime_suspend:
  * @runtime_resume:
+ * @register_packetdump_cb:
+ * @unregister_packetdump_cb:
  */
 struct cdp_misc_ops {
 	uint16_t (*set_ibss_vdev_heart_beat_timer)(struct cdp_vdev *vdev,
@@ -990,6 +992,9 @@ struct cdp_misc_ops {
 	void (*pkt_log_init)(struct cdp_pdev *handle, void *scn);
 	void (*pkt_log_con_service)(struct cdp_pdev *pdev, void *scn);
 	int (*get_num_rx_contexts)(struct cdp_soc_t *soc);
+	void (*register_pktdump_cb)(ol_txrx_pktdump_cb tx_cb,
+				    ol_txrx_pktdump_cb rx_cb);
+	void (*unregister_pktdump_cb)(void);
 };
 
 /**