Browse Source

qcacmn: Enable Packetlog

Enable Packetlog for Lithium Based chipsets by:
Replacing ol_txrx calls with equivalent cdp calls

Change-Id: Ibf4431daca23c23c9e1c1a5e1ebb2579079e4969
CRs-Fixed: 2117063
Venkata Sharath Chandra Manchala 7 years ago
parent
commit
09adf5336c

+ 47 - 0
dp/inc/cdp_txrx_ctrl.h

@@ -715,4 +715,51 @@ static inline int cdp_set_mgmt_tx_power(ol_txrx_soc_handle soc,
 							subtype, tx_power);
 	return 0;
 }
+/**
+ * @brief WDI event handler
+ * @details
+ *  This function handles in the events posted by the packet logger.
+ *  This function shall only be called if there was a successful prior call
+ *  to event_sub() on the same wdi_event_subscribe object.
+ *
+ * @param soc - pointer to the soc
+ * @param pdev - the data physical device object
+ * @param event - which event is being handled
+ * @param event - data for the event
+ * @return - int
+ */
+static inline A_STATUS
+cdp_wdi_event_handler(ol_txrx_soc_handle soc,
+		struct cdp_pdev *pdev, uint32_t event, void *evt_data)
+{
+	if (!soc || !soc->ops || !soc->ops->ctrl_ops) {
+		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
+			"%s invalid instance", __func__);
+		return A_ERROR;
+	}
+
+	if (soc->ops->ctrl_ops->txrx_wdi_event_handler)
+		return soc->ops->ctrl_ops->txrx_wdi_event_handler
+			(pdev, event, evt_data);
+
+	return A_OK;
+}
+
+static inline void *
+cdp_get_pldev(ol_txrx_soc_handle soc,
+		struct cdp_pdev *pdev)
+{
+	if (!soc || !soc->ops) {
+		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
+			"%s invalid instance", __func__);
+		QDF_BUG(0);
+		return NULL;
+	}
+
+	if (!soc->ops->ctrl_ops || !soc->ops->ctrl_ops->txrx_get_pldev)
+		return NULL;
+
+	return soc->ops->ctrl_ops->txrx_get_pldev(pdev);
+}
+
 #endif

+ 3 - 0
dp/inc/cdp_txrx_ops.h

@@ -430,6 +430,9 @@ struct cdp_ctrl_ops {
 
 	void (*txrx_set_pdev_param)(struct cdp_pdev *pdev,
 			enum cdp_pdev_param_type type, uint8_t val);
+	int (*txrx_wdi_event_handler)(struct cdp_pdev *pdev,
+					uint32_t event, void *evt_data);
+	void * (*txrx_get_pldev)(struct cdp_pdev *pdev);
 };
 
 struct cdp_me_ops {

+ 4 - 0
hif/src/hif_main.h

@@ -171,6 +171,10 @@ struct hif_softc {
 	int wake_irq;
 	void (*initial_wakeup_cb)(void *);
 	void *initial_wakeup_priv;
+#ifdef REMOVE_PKT_LOG
+	/* Handle to pktlog device */
+	void *pktlog_dev;
+#endif
 };
 
 static inline void *hif_get_hal_handle(void *hif_hdl)

+ 16 - 10
utils/pktlog/include/pktlog_ac.h

@@ -27,17 +27,17 @@
 
 #ifndef _PKTLOG_AC_H_
 #define _PKTLOG_AC_H_
-#ifndef REMOVE_PKT_LOG
 
+#ifndef REMOVE_PKT_LOG
 #include "ol_if_athvar.h"
-#include <pktlog_ac_api.h>
-#include <pktlog_ac_fmt.h>
 #include "osdep.h"
 #include <wmi_unified.h>
 #include <wmi_unified_api.h>
 #include <wdi_event_api.h>
 #include "hif.h"
 #include <ol_defines.h>
+#include <pktlog_ac_api.h>
+#include <pktlog_ac_fmt.h>
 
 #define NO_REG_FUNCS    4
 
@@ -57,18 +57,20 @@
  */
 #define PKTLOG_READ_OFFSET    8
 
+/* forward declaration for cdp_pdev */
+struct cdp_pdev;
+
 /* Opaque softc */
 struct ol_ath_generic_softc_t;
 typedef struct ol_ath_generic_softc_t *ol_ath_generic_softc_handle;
 extern void pktlog_disable_adapter_logging(struct hif_opaque_softc *scn);
 extern int pktlog_alloc_buf(struct hif_opaque_softc *scn);
-extern void pktlog_release_buf(ol_txrx_pdev_handle pdev_txrx_handle);
+extern void pktlog_release_buf(struct hif_opaque_softc *scn);
 
 ssize_t pktlog_read_proc_entry(char *buf, size_t nbytes, loff_t *ppos,
 		struct ath_pktlog_info *pl_info, bool *read_complete);
 int pktlog_send_per_pkt_stats_to_user(void);
-A_STATUS
-wdi_pktlog_unsubscribe(struct ol_txrx_pdev_t *txrx_pdev, uint32_t log_state);
+A_STATUS wdi_pktlog_unsubscribe(struct cdp_pdev *txrx_pdev, uint32_t log_state);
 
 struct ol_pl_arch_dep_funcs {
 	void (*pktlog_init)(struct hif_opaque_softc *scn);
@@ -81,7 +83,7 @@ struct ol_pl_arch_dep_funcs {
 
 struct ol_pl_os_dep_funcs {
 	int (*pktlog_attach)(struct hif_opaque_softc *scn);
-	void (*pktlog_detach)(struct ol_txrx_pdev_t *handle);
+	void (*pktlog_detach)(struct hif_opaque_softc *scn);
 
 };
 
@@ -96,7 +98,7 @@ extern struct ol_pl_arch_dep_funcs ol_pl_funcs;
 extern struct ol_pl_os_dep_funcs *g_ol_pl_os_dep_funcs;
 
 /* Pktlog handler to save the state of the pktlogs */
-struct ol_pktlog_dev_t {
+struct pktlog_dev_t {
 	struct ol_pl_arch_dep_funcs *pl_funcs;
 	struct ath_pktlog_info *pl_info;
 	ol_ath_generic_softc_handle scn;
@@ -108,6 +110,7 @@ struct ol_pktlog_dev_t {
 	uint8_t htc_endpoint;
 	void *htc_pdev;
 	bool vendor_cmd_send;
+	uint8_t callback_type;
 };
 
 #define PKTLOG_SYSCTL_SIZE      14
@@ -131,7 +134,8 @@ extern struct ol_pktlog_dev_t ol_pl_dev;
  * WDI related data and functions
  * Callback function to the WDI events
  */
-void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data);
+void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data,
+			u_int16_t peer_id, uint32_t status);
 
 void pktlog_init(struct hif_opaque_softc *scn);
 int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
@@ -140,9 +144,11 @@ int pktlog_setsize(struct hif_opaque_softc *scn, int32_t log_state);
 int pktlog_clearbuff(struct hif_opaque_softc *scn, bool clear_buff);
 int pktlog_disable(struct hif_opaque_softc *scn);
 int pktlogmod_init(void *context);
-void pktlogmod_exit(struct ol_txrx_pdev_t *handle);
+void pktlogmod_exit(void *context);
 int pktlog_htc_attach(void);
 void pktlog_process_fw_msg(uint32_t *msg_word);
+void lit_pktlog_callback(void *context, enum WDI_EVENT event, void *log_data,
+	u_int16_t peer_id, uint32_t status);
 
 #define ol_pktlog_attach(_scn)			\
 	do {					\

+ 15 - 3
utils/pktlog/include/pktlog_ac_api.h

@@ -48,6 +48,11 @@ typedef struct ol_pktlog_dev_t *ol_pktlog_dev_handle;
 struct hif_opaque_softc;
 typedef struct hif_opaque_softc *hif_opaque_softc_handle;
 
+enum pktlog_callback_regtype {
+	PKTLOG_DEFAULT_CALLBACK_REGISTRATION,
+	PKTLOG_LITE_CALLBACK_REGISTRATION
+};
+
 /**
  * @typedef net_device_handle
  * @brief opaque handle linux phy device object
@@ -55,9 +60,16 @@ typedef struct hif_opaque_softc *hif_opaque_softc_handle;
 struct net_device;
 typedef struct net_device *net_device_handle;
 
-void ol_pl_sethandle(ol_pktlog_dev_handle *pl_handle,
+struct pktlog_dev_t;
+
+void pktlog_sethandle(struct pktlog_dev_t **pl_handle,
 		     hif_opaque_softc_handle scn);
 
+void *get_txrx_context(void);
+
+struct pktlog_dev_t *get_pktlog_handle(void);
+void pktlog_set_callback_regtype(enum pktlog_callback_regtype callback_type);
+
 /* Packet log state information */
 #ifndef _PKTLOG_INFO
 #define _PKTLOG_INFO
@@ -126,8 +138,8 @@ struct ath_pktlog_info {
 };
 #endif /* _PKTLOG_INFO */
 #else                           /* REMOVE_PKT_LOG */
-typedef void *ol_pktlog_dev_handle;
-#define ol_pl_sethandle(pl_handle, scn)	\
+typedef void *pktlog_dev_handle;
+#define pktlog_sethandle(pl_handle, scn)	\
 	do {				\
 		(void)pl_handle;	\
 		(void)scn;		\

+ 7 - 8
utils/pktlog/include/pktlog_ac_i.h

@@ -27,22 +27,21 @@
 
 #ifndef _PKTLOG_AC_I_
 #define _PKTLOG_AC_I_
+
 #ifndef REMOVE_PKT_LOG
 
 #include <ol_txrx_internal.h>
 #include <pktlog_ac.h>
 
-#ifdef FEATURE_PKTLOG
-#define PKTLOG_DEFAULT_BUFSIZE          (10 * 1024 * 1024) /* 10MB */
-#else
+
 #define PKTLOG_DEFAULT_BUFSIZE          (1 * 1024 * 1024) /* 1MB */
-#endif
 #define PKTLOG_DEFAULT_SACK_THR         3
 #define PKTLOG_DEFAULT_TAIL_LENGTH      100
 #define PKTLOG_DEFAULT_THRUPUT_THRESH   (64 * 1024)
 #define PKTLOG_DEFAULT_PER_THRESH       30
 #define PKTLOG_DEFAULT_PHYERR_THRESH    300
 #define PKTLOG_DEFAULT_TRIGGER_INTERVAL 500
+
 struct ath_pktlog_arg {
 	struct ath_pktlog_info *pl_info;
 	uint32_t flags;
@@ -62,17 +61,17 @@ struct ath_pktlog_arg {
 };
 
 void pktlog_getbuf_intsafe(struct ath_pktlog_arg *plarg);
-char *pktlog_getbuf(struct ol_pktlog_dev_t *pl_dev,
+char *pktlog_getbuf(struct pktlog_dev_t *pl_dev,
 		    struct ath_pktlog_info *pl_info,
 		    size_t log_size, struct ath_pktlog_hdr *pl_hdr);
 
-A_STATUS process_tx_info(struct ol_txrx_pdev_t *pdev, void *data);
+A_STATUS process_tx_info(struct cdp_pdev *pdev, void *data);
 A_STATUS process_rx_info(void *pdev, void *data);
 A_STATUS process_rx_info_remote(void *pdev, void *data);
 A_STATUS process_rate_find(void *pdev, void *data);
 A_STATUS process_rate_update(void *pdev, void *data);
 A_STATUS process_sw_event(void *pdev, void *data);
-
-
+int process_pktlog_lite(void *context, void *log_data, uint16_t log_type);
+int process_rx_desc_remote(void *pdev, void *data);
 #endif /* REMOVE_PKT_LOG */
 #endif

+ 70 - 83
utils/pktlog/linux_ac.c

@@ -42,7 +42,6 @@
 #include <linux/proc_fs.h>
 #include <pktlog_ac_i.h>
 #include <pktlog_ac_fmt.h>
-#include <pktlog_ac.h>
 #include "i_host_diag_core_log.h"
 #include "host_diag_core_log.h"
 #include "ani_global.h"
@@ -78,8 +77,8 @@ static struct ath_pktlog_info *g_pktlog_info;
 
 static struct proc_dir_entry *g_pktlog_pde;
 
-static int pktlog_attach(struct hif_opaque_softc *sc);
-static void pktlog_detach(struct ol_txrx_pdev_t *handle);
+static int pktlog_attach(struct hif_opaque_softc *scn);
+static void pktlog_detach(struct hif_opaque_softc *scn);
 static int pktlog_open(struct inode *i, struct file *f);
 static int pktlog_release(struct inode *i, struct file *f);
 static ssize_t pktlog_read(struct file *file, char *buf, size_t nbytes,
@@ -91,31 +90,9 @@ static struct file_operations pktlog_fops = {
 	read : pktlog_read,
 };
 
-/*
- * Linux implementation of helper functions
- */
-static struct ol_pktlog_dev_t *cds_get_pl_handle(void)
-{
-	ol_txrx_pdev_handle pdev_txrx_handle;
-	pdev_txrx_handle = cds_get_context(QDF_MODULE_ID_TXRX);
-	if (!pdev_txrx_handle) {
-		QDF_ASSERT(0);
-		return NULL;
-	}
-	return pdev_txrx_handle->pl_dev;
-}
-
-static struct ol_pktlog_dev_t *ol_get_pl_handle(
-		ol_txrx_pdev_handle pdev_txrx_handle)
-{
-	if (!pdev_txrx_handle)
-		return NULL;
-	return pdev_txrx_handle->pl_dev;
-}
-
 void pktlog_disable_adapter_logging(struct hif_opaque_softc *scn)
 {
-	struct ol_pktlog_dev_t *pl_dev = cds_get_pl_handle();
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 	if (pl_dev)
 		pl_dev->pl_info->log_state = 0;
 }
@@ -125,12 +102,13 @@ int pktlog_alloc_buf(struct hif_opaque_softc *scn)
 	uint32_t page_cnt;
 	unsigned long vaddr;
 	struct page *vpg;
+	struct pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info *pl_info;
 	struct ath_pktlog_buf *buffer;
-	ol_txrx_pdev_handle pdev_txrx_handle;
-	pdev_txrx_handle = cds_get_context(QDF_MODULE_ID_TXRX);
 
-	if (!pdev_txrx_handle || !pdev_txrx_handle->pl_dev) {
+	pl_dev = get_pktlog_handle();
+
+	if (!pl_dev) {
 		printk(PKTLOG_TAG
 		       "%s: Unable to allocate buffer "
 		       "scn or scn->pdev_txrx_handle->pl_dev is null\n",
@@ -138,7 +116,7 @@ int pktlog_alloc_buf(struct hif_opaque_softc *scn)
 		return -EINVAL;
 	}
 
-	pl_info = pdev_txrx_handle->pl_dev->pl_info;
+	pl_info = pl_dev->pl_info;
 
 	page_cnt = (sizeof(*(pl_info->buf)) + pl_info->buf_size) / PAGE_SIZE;
 
@@ -171,29 +149,33 @@ int pktlog_alloc_buf(struct hif_opaque_softc *scn)
 
 	spin_lock_bh(&pl_info->log_lock);
 	if (pl_info->buf != NULL)
-		pktlog_release_buf(pdev_txrx_handle);
+		pktlog_release_buf(scn);
 
 	pl_info->buf =  buffer;
 	spin_unlock_bh(&pl_info->log_lock);
 	return 0;
 }
 
-void pktlog_release_buf(ol_txrx_pdev_handle pdev_txrx_handle)
+void pktlog_release_buf(struct hif_opaque_softc *scn)
 {
 	unsigned long page_cnt;
 	unsigned long vaddr;
 	struct page *vpg;
+	struct pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info *pl_info;
 
-	if (!pdev_txrx_handle || !pdev_txrx_handle->pl_dev) {
-		printk(PKTLOG_TAG
-		       "%s: Unable to allocate buffer"
-		       "scn or scn->pdev_txrx_handle->pl_dev is null\n",
-		       __func__);
+	pl_dev = get_pktlog_handle();
+	pl_info = pl_dev->pl_info;
+
+	if (!pl_dev) {
+		qdf_print("%s: invalid pl_dev handle", __func__);
 		return;
 	}
 
-	pl_info = pdev_txrx_handle->pl_dev->pl_info;
+	if (!pl_dev->pl_info) {
+		qdf_print("%s: invalid pl_dev handle", __func__);
+		return;
+	}
 
 	page_cnt = ((sizeof(*(pl_info->buf)) + pl_info->buf_size) /
 		    PAGE_SIZE) + 1;
@@ -222,7 +204,7 @@ qdf_sysctl_decl(ath_sysctl_pktlog_enable, ctl, write, filp, buffer, lenp, ppos)
 {
 	int ret, enable;
 	ol_ath_generic_softc_handle scn;
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev;
 
 	scn = (ol_ath_generic_softc_handle) ctl->extra1;
 
@@ -232,7 +214,7 @@ qdf_sysctl_decl(ath_sysctl_pktlog_enable, ctl, write, filp, buffer, lenp, ppos)
 		return -EINVAL;
 	}
 
-	pl_dev = cds_get_pl_handle();
+	pl_dev = get_pktlog_handle();
 
 	if (!pl_dev) {
 		printk("%s: Invalid pktlog context\n", __func__);
@@ -269,7 +251,7 @@ qdf_sysctl_decl(ath_sysctl_pktlog_enable, ctl, write, filp, buffer, lenp, ppos)
 	return ret;
 }
 
-static int get_pktlog_bufsize(struct ol_pktlog_dev_t *pl_dev)
+static int get_pktlog_bufsize(struct pktlog_dev_t *pl_dev)
 {
 	return pl_dev->pl_info->buf_size;
 }
@@ -280,7 +262,7 @@ qdf_sysctl_decl(ath_sysctl_pktlog_size, ctl, write, filp, buffer, lenp, ppos)
 {
 	int ret, size;
 	ol_ath_generic_softc_handle scn;
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev;
 
 	scn = (ol_ath_generic_softc_handle) ctl->extra1;
 
@@ -290,7 +272,7 @@ qdf_sysctl_decl(ath_sysctl_pktlog_size, ctl, write, filp, buffer, lenp, ppos)
 		return -EINVAL;
 	}
 
-	pl_dev = cds_get_pl_handle();
+	pl_dev = get_pktlog_handle();
 
 	if (!pl_dev) {
 		printk("%s: Invalid pktlog handle\n", __func__);
@@ -322,7 +304,7 @@ qdf_sysctl_decl(ath_sysctl_pktlog_size, ctl, write, filp, buffer, lenp, ppos)
 /* Register sysctl table */
 static int pktlog_sysctl_register(struct hif_opaque_softc *scn)
 {
-	struct ol_pktlog_dev_t *pl_dev = cds_get_pl_handle();
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 	struct ath_pktlog_info_lnx *pl_info_lnx;
 	char *proc_name;
 
@@ -426,23 +408,27 @@ static int pktlog_sysctl_register(struct hif_opaque_softc *scn)
  */
 static int pktlog_attach(struct hif_opaque_softc *scn)
 {
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info_lnx *pl_info_lnx;
 	char *proc_name;
 	struct proc_dir_entry *proc_entry;
 
-	pl_dev = cds_get_pl_handle();
+	/* Allocate pktlog dev for later use */
+	pl_dev = get_pktlog_handle();
 
 	if (pl_dev != NULL) {
 		pl_info_lnx = kmalloc(sizeof(*pl_info_lnx), GFP_KERNEL);
 		if (pl_info_lnx == NULL) {
-			printk(PKTLOG_TAG "%s:allocation failed for pl_info\n",
-			       __func__);
-			return -ENOMEM;
+			QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
+				 "%s: Allocation failed for pl_info\n",
+				 __func__);
+			goto attach_fail1;
 		}
+
 		pl_dev->pl_info = &pl_info_lnx->info;
 		pl_dev->name = WLANDEV_BASENAME;
 		proc_name = pl_dev->name;
+
 		if (!pl_dev->pl_funcs)
 			pl_dev->pl_funcs = &ol_pl_funcs;
 
@@ -459,17 +445,16 @@ static int pktlog_attach(struct hif_opaque_softc *scn)
 	 * might be good to move to pktlog_init
 	 */
 	/* pl_dev->tgt_pktlog_alloced = false; */
-	pl_dev->vendor_cmd_send = false;
 	pl_info_lnx->proc_entry = NULL;
 	pl_info_lnx->sysctl_header = NULL;
 
 	proc_entry = proc_create_data(proc_name, PKTLOG_PROC_PERM,
-				      g_pktlog_pde, &pktlog_fops,
-				      &pl_info_lnx->info);
+			g_pktlog_pde, &pktlog_fops,
+			&pl_info_lnx->info);
 
 	if (proc_entry == NULL) {
 		printk(PKTLOG_TAG "%s: create_proc_entry failed for %s\n",
-		       __func__, proc_name);
+				__func__, proc_name);
 		goto attach_fail1;
 	}
 
@@ -477,9 +462,10 @@ static int pktlog_attach(struct hif_opaque_softc *scn)
 
 	if (pktlog_sysctl_register(scn)) {
 		printk(PKTLOG_TAG "%s: sysctl register failed for %s\n",
-		       __func__, proc_name);
+				__func__, proc_name);
 		goto attach_fail2;
 	}
+
 	return 0;
 
 attach_fail2:
@@ -488,10 +474,11 @@ attach_fail2:
 attach_fail1:
 	if (pl_dev)
 		kfree(pl_dev->pl_info);
+
 	return -EINVAL;
 }
 
-static void pktlog_sysctl_unregister(struct ol_pktlog_dev_t *pl_dev)
+static void pktlog_sysctl_unregister(struct pktlog_dev_t *pl_dev)
 {
 	struct ath_pktlog_info_lnx *pl_info_lnx;
 
@@ -510,20 +497,11 @@ static void pktlog_sysctl_unregister(struct ol_pktlog_dev_t *pl_dev)
 	}
 }
 
-static void pktlog_detach(struct ol_txrx_pdev_t *handle)
+static void pktlog_detach(struct hif_opaque_softc *scn)
 {
-	struct ol_txrx_pdev_t *txrx_pdev;
-	struct ol_pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info *pl_info;
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 
-	txrx_pdev = handle;
-	if (!txrx_pdev) {
-		printk("%s: Invalid txrx_pdev context\n", __func__);
-		ASSERT(0);
-		return;
-	}
-
-	pl_dev = txrx_pdev->pl_dev;
 	if (!pl_dev) {
 		printk("%s: Invalid pktlog context\n", __func__);
 		ASSERT(0);
@@ -537,7 +515,7 @@ static void pktlog_detach(struct ol_txrx_pdev_t *handle)
 	spin_lock_bh(&pl_info->log_lock);
 
 	if (pl_info->buf) {
-		pktlog_release_buf(txrx_pdev);
+		pktlog_release_buf(scn);
 		pl_dev->tgt_pktlog_alloced = false;
 	}
 	spin_unlock_bh(&pl_info->log_lock);
@@ -552,7 +530,7 @@ static void pktlog_detach(struct ol_txrx_pdev_t *handle)
 static int __pktlog_open(struct inode *i, struct file *f)
 {
 	struct hif_opaque_softc *scn;
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info *pl_info;
 	int ret = 0;
 
@@ -585,7 +563,7 @@ static int __pktlog_open(struct inode *i, struct file *f)
 		return -EINVAL;
 	}
 
-	pl_dev = cds_get_pl_handle();
+	pl_dev = get_pktlog_handle();
 
 	if (!pl_dev) {
 		pl_info->curr_pkt_state = PKTLOG_OPR_NOT_IN_PROGRESS;
@@ -625,7 +603,7 @@ static int pktlog_open(struct inode *i, struct file *f)
 static int __pktlog_release(struct inode *i, struct file *f)
 {
 	struct hif_opaque_softc *scn;
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info *pl_info;
 	int ret = 0;
 
@@ -650,7 +628,7 @@ static int __pktlog_release(struct inode *i, struct file *f)
 		return -EINVAL;
 	}
 
-	pl_dev = cds_get_pl_handle();
+	pl_dev = get_pktlog_handle();
 
 	if (!pl_dev) {
 		pl_info->curr_pkt_state = PKTLOG_OPR_NOT_IN_PROGRESS;
@@ -669,6 +647,7 @@ static int __pktlog_release(struct inode *i, struct file *f)
 	ret = pl_dev->pl_funcs->pktlog_enable(
 			(struct hif_opaque_softc *)scn, pl_info->log_state,
 			cds_is_packet_log_enabled(), 0, 1);
+
 	if (ret != 0)
 		pr_warn("%s: pktlog cannot be enabled. ret value %d\n",
 			__func__, ret);
@@ -893,6 +872,7 @@ __pktlog_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
 	bufhdr_size = sizeof(log_buf->bufhdr);
 
 	/* copy valid log entries from circular buffer into user space */
+
 	rem_len = nbytes;
 	count = 0;
 
@@ -900,8 +880,9 @@ __pktlog_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
 		count = QDF_MIN((bufhdr_size - *ppos), rem_len);
 		spin_unlock_bh(&pl_info->log_lock);
 		if (copy_to_user(buf, ((char *)&log_buf->bufhdr) + *ppos,
-				 count))
+				 count)) {
 			return -EFAULT;
+		}
 		rem_len -= count;
 		ret_val += count;
 		spin_lock_bh(&pl_info->log_lock);
@@ -947,9 +928,12 @@ __pktlog_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
 
 		count = QDF_MIN(rem_len, (end_offset - ppos_data + 1));
 		spin_unlock_bh(&pl_info->log_lock);
+
 		if (copy_to_user(buf + ret_val,
-				 log_buf->log_data + ppos_data, count))
+				 log_buf->log_data + ppos_data, count)) {
 			return -EFAULT;
+		}
+
 		ret_val += count;
 		rem_len -= count;
 		spin_lock_bh(&pl_info->log_lock);
@@ -958,8 +942,10 @@ __pktlog_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
 			count = QDF_MIN(rem_len, (fold_offset - ppos_data + 1));
 			spin_unlock_bh(&pl_info->log_lock);
 			if (copy_to_user(buf + ret_val,
-					 log_buf->log_data + ppos_data, count))
+					 log_buf->log_data + ppos_data,
+					 count)) {
 				return -EFAULT;
+			}
 			ret_val += count;
 			rem_len -= count;
 			spin_lock_bh(&pl_info->log_lock);
@@ -976,8 +962,10 @@ __pktlog_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
 			count = QDF_MIN(rem_len, (end_offset - ppos_data + 1));
 			spin_unlock_bh(&pl_info->log_lock);
 			if (copy_to_user(buf + ret_val,
-					 log_buf->log_data + ppos_data, count))
+					 log_buf->log_data + ppos_data,
+					 count)) {
 				return -EFAULT;
+			}
 			ret_val += count;
 			rem_len -= count;
 			spin_lock_bh(&pl_info->log_lock);
@@ -1002,7 +990,7 @@ pktlog_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
 	struct ath_pktlog_info *pl_info;
 
 	pl_info = (struct ath_pktlog_info *)
-					PDE_DATA(file->f_path.dentry->d_inode);
+			PDE_DATA(file->f_path.dentry->d_inode);
 	if (!pl_info)
 		return 0;
 
@@ -1029,6 +1017,7 @@ int pktlogmod_init(void *context)
 	/* Attach packet log */
 	ret = pktlog_attach((struct hif_opaque_softc *)context);
 
+	/* If packet log init failed */
 	if (ret)
 		goto attach_fail;
 
@@ -1037,19 +1026,17 @@ int pktlogmod_init(void *context)
 attach_fail:
 	remove_proc_entry(PKTLOG_PROC_DIR, NULL);
 	g_pktlog_pde = NULL;
+
 	return ret;
 }
 
-void pktlogmod_exit(struct ol_txrx_pdev_t *handle)
+void pktlogmod_exit(void *context)
 {
-	struct ol_pktlog_dev_t *pl_dev;
-
-	pl_dev = ol_get_pl_handle(handle);
-
-	if (!pl_dev || g_pktlog_pde == NULL)
+	if (g_pktlog_pde == NULL)
 		return;
 
-	pktlog_detach(handle);
+	pktlog_detach((struct hif_opaque_softc *)context);
+
 	/*
 	 *  pdev kill needs to be implemented
 	 */

+ 298 - 159
utils/pktlog/pktlog_ac.c

@@ -41,12 +41,15 @@
  */
 
 #ifndef REMOVE_PKT_LOG
+
 #include "qdf_mem.h"
 #include "athdefs.h"
 #include "pktlog_ac_i.h"
 #include "cds_api.h"
 #include "wma_types.h"
 #include "htc.h"
+#include <cdp_txrx_cmn_struct.h>
+#include <cdp_txrx_ctrl.h>
 
 wdi_event_subscribe PKTLOG_TX_SUBSCRIBER;
 wdi_event_subscribe PKTLOG_RX_SUBSCRIBER;
@@ -54,6 +57,8 @@ wdi_event_subscribe PKTLOG_RX_REMOTE_SUBSCRIBER;
 wdi_event_subscribe PKTLOG_RCFIND_SUBSCRIBER;
 wdi_event_subscribe PKTLOG_RCUPDATE_SUBSCRIBER;
 wdi_event_subscribe PKTLOG_SW_EVENT_SUBSCRIBER;
+wdi_event_subscribe PKTLOG_LITE_T2H_SUBSCRIBER;
+wdi_event_subscribe PKTLOG_LITE_RX_SUBSCRIBER;
 
 struct ol_pl_arch_dep_funcs ol_pl_funcs = {
 	.pktlog_init = pktlog_init,
@@ -62,17 +67,51 @@ struct ol_pl_arch_dep_funcs ol_pl_funcs = {
 	.pktlog_disable = pktlog_disable,       /* valid for f/w disable */
 };
 
-struct ol_pktlog_dev_t ol_pl_dev = {
+struct pktlog_dev_t pl_dev = {
 	.pl_funcs = &ol_pl_funcs,
 };
 
-void ol_pl_sethandle(ol_pktlog_dev_handle *pl_handle,
+void pktlog_sethandle(struct pktlog_dev_t **pl_handle,
 		     struct hif_opaque_softc *scn)
 {
-	ol_pl_dev.scn = (ol_ath_generic_softc_handle) scn;
-	*pl_handle = &ol_pl_dev;
+	pl_dev.scn = (ol_ath_generic_softc_handle) scn;
+	*pl_handle = &pl_dev;
+}
+
+void pktlog_set_callback_regtype(
+		enum pktlog_callback_regtype callback_type)
+{
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
+	pl_dev->callback_type = callback_type;
+}
+
+#ifdef CONFIG_MCL
+struct pktlog_dev_t *get_pktlog_handle(void)
+{
+	struct cdp_pdev *pdev_txrx_handle =
+				cds_get_context(QDF_MODULE_ID_TXRX);
+	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
+
+	return cdp_get_pldev(soc, pdev_txrx_handle);
+}
+
+/*
+ * Get current txrx context
+ */
+void *get_txrx_context(void)
+{
+	return cds_get_context(QDF_MODULE_ID_TXRX);
 }
 
+#else
+/* TODO: Need to use WIN implementation to return pktlog_dev handle */
+static inline struct pktlog_dev_t *get_pktlog_handle(void)
+{
+	return NULL;
+}
+static struct pktlog_dev_t *get_txrx_context(void) { }
+#endif
+
 static A_STATUS pktlog_wma_post_msg(WMI_PKTLOG_EVENT event_types,
 				    WMI_CMD_ID cmd_id, bool ini_triggered,
 				    uint8_t user_triggered)
@@ -131,55 +170,77 @@ pktlog_enable_tgt(struct hif_opaque_softc *_scn, uint32_t log_state,
 }
 
 static inline A_STATUS
-wdi_pktlog_subscribe(struct ol_txrx_pdev_t *txrx_pdev, int32_t log_state)
+wdi_pktlog_subscribe(struct cdp_pdev *cdp_pdev, int32_t log_state)
 {
-	if (!txrx_pdev) {
-		printk("Invalid pdev in %s\n", __func__);
+#ifdef CONFIG_MCL
+	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
+#else
+	/*TODO: WIN implementation to get soc */
+#endif
+
+	if (!cdp_pdev) {
+		qdf_print("Invalid pdev in %s\n", __func__);
 		return A_ERROR;
 	}
+
 	if (log_state & ATH_PKTLOG_TX) {
-		if (wdi_event_sub(txrx_pdev,
-				  &PKTLOG_TX_SUBSCRIBER, WDI_EVENT_TX_STATUS)) {
+		if (cdp_wdi_event_sub(soc, cdp_pdev, &PKTLOG_TX_SUBSCRIBER,
+				WDI_EVENT_TX_STATUS)) {
 			return A_ERROR;
 		}
 	}
 	if (log_state & ATH_PKTLOG_RX) {
-		if (wdi_event_sub(txrx_pdev,
-				  &PKTLOG_RX_SUBSCRIBER, WDI_EVENT_RX_DESC)) {
+		if (cdp_wdi_event_sub(soc, cdp_pdev, &PKTLOG_RX_SUBSCRIBER,
+				WDI_EVENT_RX_DESC)) {
 			return A_ERROR;
 		}
-		if (wdi_event_sub(txrx_pdev,
-				  &PKTLOG_RX_REMOTE_SUBSCRIBER,
-				  WDI_EVENT_RX_DESC_REMOTE)) {
+		if (cdp_wdi_event_sub(soc, cdp_pdev,
+				&PKTLOG_RX_REMOTE_SUBSCRIBER,
+				WDI_EVENT_RX_DESC_REMOTE)) {
 			return A_ERROR;
 		}
 	}
 	if (log_state & ATH_PKTLOG_RCFIND) {
-		if (wdi_event_sub(txrx_pdev,
+		if (cdp_wdi_event_sub(soc, cdp_pdev,
 				  &PKTLOG_RCFIND_SUBSCRIBER,
 				  WDI_EVENT_RATE_FIND)) {
 			return A_ERROR;
 		}
 	}
 	if (log_state & ATH_PKTLOG_RCUPDATE) {
-		if (wdi_event_sub(txrx_pdev,
+		if (cdp_wdi_event_sub(soc, cdp_pdev,
 				  &PKTLOG_RCUPDATE_SUBSCRIBER,
 				  WDI_EVENT_RATE_UPDATE)) {
 			return A_ERROR;
 		}
 	}
 	if (log_state & ATH_PKTLOG_SW_EVENT) {
-		if (wdi_event_sub(txrx_pdev,
+		if (cdp_wdi_event_sub(soc, cdp_pdev,
 				  &PKTLOG_SW_EVENT_SUBSCRIBER,
 				  WDI_EVENT_SW_EVENT)) {
 			return A_ERROR;
 		}
 	}
+	if (log_state & ATH_PKTLOG_LITE_T2H) {
+		if (cdp_wdi_event_sub(soc, cdp_pdev,
+				  &PKTLOG_LITE_T2H_SUBSCRIBER,
+				  WDI_EVENT_LITE_T2H)) {
+			return A_ERROR;
+		}
+	}
+	if (log_state & ATH_PKTLOG_LITE_RX) {
+		if (cdp_wdi_event_sub(soc, cdp_pdev,
+				&PKTLOG_LITE_RX_SUBSCRIBER,
+				WDI_EVENT_LITE_RX)) {
+			return A_ERROR;
+		}
+	}
 
 	return A_OK;
 }
 
-void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data)
+void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data,
+		u_int16_t peer_id, uint32_t status)
 {
 	switch (event) {
 	case WDI_EVENT_TX_STATUS:
@@ -188,7 +249,7 @@ void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data)
 		 * process TX message
 		 */
 		if (process_tx_info(pdev, log_data)) {
-			printk("Unable to process TX info\n");
+			qdf_print("Unable to process TX info\n");
 			return;
 		}
 		break;
@@ -199,7 +260,7 @@ void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data)
 		 * process RX message for local frames
 		 */
 		if (process_rx_info(pdev, log_data)) {
-			printk("Unable to process RX info\n");
+			qdf_print("Unable to process RX info\n");
 			return;
 		}
 		break;
@@ -210,7 +271,7 @@ void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data)
 		 * process RX message for remote frames
 		 */
 		if (process_rx_info_remote(pdev, log_data)) {
-			printk("Unable to process RX info\n");
+			qdf_print("Unable to process RX info\n");
 			return;
 		}
 		break;
@@ -221,7 +282,7 @@ void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data)
 		 * process RATE_FIND message
 		 */
 		if (process_rate_find(pdev, log_data)) {
-			printk("Unable to process RC_FIND info\n");
+			qdf_print("Unable to process RC_FIND info\n");
 			return;
 		}
 		break;
@@ -232,7 +293,7 @@ void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data)
 		 * process RATE_UPDATE message
 		 */
 		if (process_rate_update(pdev, log_data)) {
-			printk("Unable to process RC_UPDATE\n");
+			qdf_print("Unable to process RC_UPDATE\n");
 			return;
 		}
 		break;
@@ -243,7 +304,43 @@ void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data)
 		 * process SW EVENT message
 		 */
 		if (process_sw_event(pdev, log_data)) {
-			printk("Unable to process SW_EVENT\n");
+			qdf_print("Unable to process SW_EVENT\n");
+			return;
+		}
+		break;
+	}
+	default:
+		break;
+	}
+}
+
+void
+lit_pktlog_callback(void *context, enum WDI_EVENT event, void *log_data,
+			u_int16_t peer_id, uint32_t status)
+{
+	switch (event) {
+	case WDI_EVENT_RX_DESC:
+	{
+		if (process_rx_desc_remote(context, log_data)) {
+			qdf_print("Unable to process RX info\n");
+			return;
+		}
+		break;
+	}
+	case WDI_EVENT_LITE_T2H:
+	{
+		if (process_pktlog_lite(context, log_data,
+					PKTLOG_TYPE_LITE_T2H)) {
+			qdf_print("Unable to process lite_t2h\n");
+			return;
+		}
+		break;
+	}
+	case WDI_EVENT_LITE_RX:
+	{
+		if (process_pktlog_lite(context, log_data,
+					PKTLOG_TYPE_LITE_RX)) {
+			qdf_print("Unable to process lite_rx\n");
 			return;
 		}
 		break;
@@ -254,66 +351,96 @@ void pktlog_callback(void *pdev, enum WDI_EVENT event, void *log_data)
 }
 
 A_STATUS
-wdi_pktlog_unsubscribe(struct ol_txrx_pdev_t *txrx_pdev, uint32_t log_state)
+wdi_pktlog_unsubscribe(struct cdp_pdev *pdev, uint32_t log_state)
 {
+#ifdef CONFIG_MCL
+	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
+#else
+	/* TODO: WIN implementation to get soc */
+#endif
+
 	if (log_state & ATH_PKTLOG_TX) {
-		if (wdi_event_unsub(txrx_pdev,
+		if (cdp_wdi_event_unsub(soc, pdev,
 				    &PKTLOG_TX_SUBSCRIBER,
 				    WDI_EVENT_TX_STATUS)) {
 			return A_ERROR;
 		}
 	}
 	if (log_state & ATH_PKTLOG_RX) {
-		if (wdi_event_unsub(txrx_pdev,
+		if (cdp_wdi_event_unsub(soc, pdev,
 				    &PKTLOG_RX_SUBSCRIBER, WDI_EVENT_RX_DESC)) {
 			return A_ERROR;
 		}
-		if (wdi_event_unsub(txrx_pdev,
+		if (cdp_wdi_event_unsub(soc, pdev,
 				    &PKTLOG_RX_REMOTE_SUBSCRIBER,
 				    WDI_EVENT_RX_DESC_REMOTE)) {
 			return A_ERROR;
 		}
 	}
 	if (log_state & ATH_PKTLOG_RCFIND) {
-		if (wdi_event_unsub(txrx_pdev,
+		if (cdp_wdi_event_unsub(soc, pdev,
 				    &PKTLOG_RCFIND_SUBSCRIBER,
 				    WDI_EVENT_RATE_FIND)) {
 			return A_ERROR;
 		}
 	}
 	if (log_state & ATH_PKTLOG_RCUPDATE) {
-		if (wdi_event_unsub(txrx_pdev,
+		if (cdp_wdi_event_unsub(soc, pdev,
 				    &PKTLOG_RCUPDATE_SUBSCRIBER,
 				    WDI_EVENT_RATE_UPDATE)) {
 			return A_ERROR;
 		}
 	}
 	if (log_state & ATH_PKTLOG_RCUPDATE) {
-		if (wdi_event_unsub(txrx_pdev,
+		if (cdp_wdi_event_unsub(soc, pdev,
 				    &PKTLOG_SW_EVENT_SUBSCRIBER,
 				    WDI_EVENT_SW_EVENT)) {
 			return A_ERROR;
 		}
 	}
+	if (log_state & ATH_PKTLOG_LITE_T2H) {
+		if (cdp_wdi_event_unsub(soc, pdev,
+				  &PKTLOG_LITE_T2H_SUBSCRIBER,
+				  WDI_EVENT_LITE_T2H)) {
+			return A_ERROR;
+		}
+	}
+	if (log_state & ATH_PKTLOG_LITE_RX) {
+		if (cdp_wdi_event_unsub(soc, pdev,
+				&PKTLOG_LITE_RX_SUBSCRIBER,
+				WDI_EVENT_LITE_RX)) {
+			return A_ERROR;
+		}
+	}
+
 	return A_OK;
 }
 
 int pktlog_disable(struct hif_opaque_softc *scn)
 {
-	struct ol_txrx_pdev_t *txrx_pdev =
-		cds_get_context(QDF_MODULE_ID_TXRX);
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info *pl_info;
 	uint8_t save_pktlog_state;
+	struct cdp_pdev *txrx_pdev = get_txrx_context();
 
-	if (txrx_pdev == NULL ||
-			txrx_pdev->pl_dev == NULL ||
-			txrx_pdev->pl_dev->pl_info == NULL)
-		return -EFAULT;
-
-	pl_dev = txrx_pdev->pl_dev;
+	pl_dev = get_pktlog_handle();
 	pl_info = pl_dev->pl_info;
 
+	if (!pl_dev) {
+		qdf_print("Invalid pl_dev");
+		return -EINVAL;
+	}
+
+	if (!pl_dev->pl_info) {
+		qdf_print("Invalid pl_info");
+		return -EINVAL;
+	}
+
+	if (!txrx_pdev) {
+		qdf_print("Invalid cdp_pdev");
+		return -EINVAL;
+	}
+
 	if (pl_info->curr_pkt_state == PKTLOG_OPR_IN_PROGRESS ||
 	    pl_info->curr_pkt_state ==
 			PKTLOG_OPR_IN_PROGRESS_READ_START_PKTLOG_DISABLED ||
@@ -327,18 +454,17 @@ int pktlog_disable(struct hif_opaque_softc *scn)
 
 	if (pktlog_wma_post_msg(0, WMI_PDEV_PKTLOG_DISABLE_CMDID, 0, 0)) {
 		pl_info->curr_pkt_state = PKTLOG_OPR_NOT_IN_PROGRESS;
-		printk("Failed to disable pktlog in target\n");
+		qdf_print("Failed to disable pktlog in target\n");
 		return -EINVAL;
 	}
 
 	if (pl_dev->is_pktlog_cb_subscribed &&
 		wdi_pktlog_unsubscribe(txrx_pdev, pl_info->log_state)) {
 		pl_info->curr_pkt_state = PKTLOG_OPR_NOT_IN_PROGRESS;
-		printk("Cannot unsubscribe pktlog from the WDI\n");
+		qdf_print("Cannot unsubscribe pktlog from the WDI\n");
 		return -EINVAL;
 	}
 	pl_dev->is_pktlog_cb_subscribed = false;
-	pl_dev->is_pktlog_cb_subscribed = false;
 	if (save_pktlog_state == PKTLOG_OPR_IN_PROGRESS_READ_START)
 		pl_info->curr_pkt_state =
 			PKTLOG_OPR_IN_PROGRESS_READ_START_PKTLOG_DISABLED;
@@ -349,16 +475,15 @@ int pktlog_disable(struct hif_opaque_softc *scn)
 
 void pktlog_init(struct hif_opaque_softc *scn)
 {
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 	struct ath_pktlog_info *pl_info;
-	ol_txrx_pdev_handle pdev_txrx_handle;
-	pdev_txrx_handle = cds_get_context(QDF_MODULE_ID_TXRX);
 
-	if (pdev_txrx_handle == NULL ||
-			pdev_txrx_handle->pl_dev == NULL ||
-			pdev_txrx_handle->pl_dev->pl_info == NULL)
+	if (pl_dev == NULL || pl_dev->pl_info == NULL) {
+		qdf_print("pl_dev or pl_info is invalid\n");
 		return;
+	}
 
-	pl_info = pdev_txrx_handle->pl_dev->pl_info;
+	pl_info = pl_dev->pl_info;
 
 	OS_MEMZERO(pl_info, sizeof(*pl_info));
 	PKTLOG_LOCK_INIT(pl_info);
@@ -378,49 +503,56 @@ void pktlog_init(struct hif_opaque_softc *scn)
 	pl_info->pktlen = 0;
 	pl_info->start_time_thruput = 0;
 	pl_info->start_time_per = 0;
-	pdev_txrx_handle->pl_dev->vendor_cmd_send = false;
-
-	PKTLOG_TX_SUBSCRIBER.callback = pktlog_callback;
-	PKTLOG_RX_SUBSCRIBER.callback = pktlog_callback;
-	PKTLOG_RX_REMOTE_SUBSCRIBER.callback = pktlog_callback;
-	PKTLOG_RCFIND_SUBSCRIBER.callback = pktlog_callback;
-	PKTLOG_RCUPDATE_SUBSCRIBER.callback = pktlog_callback;
-	PKTLOG_SW_EVENT_SUBSCRIBER.callback = pktlog_callback;
+	pl_dev->vendor_cmd_send = false;
+
+	if (pl_dev->callback_type == PKTLOG_DEFAULT_CALLBACK_REGISTRATION) {
+		PKTLOG_TX_SUBSCRIBER.callback = pktlog_callback;
+		PKTLOG_RX_SUBSCRIBER.callback = pktlog_callback;
+		PKTLOG_RX_REMOTE_SUBSCRIBER.callback = pktlog_callback;
+		PKTLOG_RCFIND_SUBSCRIBER.callback = pktlog_callback;
+		PKTLOG_RCUPDATE_SUBSCRIBER.callback = pktlog_callback;
+		PKTLOG_SW_EVENT_SUBSCRIBER.callback = pktlog_callback;
+	} else if (pl_dev->callback_type == PKTLOG_LITE_CALLBACK_REGISTRATION) {
+		PKTLOG_LITE_T2H_SUBSCRIBER.callback = lit_pktlog_callback;
+		PKTLOG_LITE_RX_SUBSCRIBER.callback = lit_pktlog_callback;
+	}
 }
 
 static int __pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
 		 bool ini_triggered, uint8_t user_triggered,
 		 uint32_t is_iwpriv_command)
 {
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info *pl_info;
-	struct ol_txrx_pdev_t *txrx_pdev;
+	struct cdp_pdev *cdp_pdev;
 	int error;
 
 	if (!scn) {
-		printk("%s: Invalid scn context\n", __func__);
+		qdf_print("%s: Invalid scn context\n", __func__);
 		ASSERT(0);
 		return -EINVAL;
 	}
 
-	txrx_pdev = cds_get_context(QDF_MODULE_ID_TXRX);
-	if (!txrx_pdev) {
-		printk("%s: Invalid txrx_pdev context\n", __func__);
+	pl_dev = get_pktlog_handle();
+	if (!pl_dev) {
+		qdf_print("%s: Invalid pktlog context\n", __func__);
 		ASSERT(0);
 		return -EINVAL;
 	}
 
-	pl_dev = txrx_pdev->pl_dev;
-	if (!pl_dev) {
-		printk("%s: Invalid pktlog context\n", __func__);
+	cdp_pdev = get_txrx_context();
+	if (!cdp_pdev) {
+		qdf_print("%s: Invalid txrx context\n", __func__);
 		ASSERT(0);
 		return -EINVAL;
 	}
 
 	pl_info = pl_dev->pl_info;
-
-	if (!pl_info)
-		return 0;
+	if (!pl_info) {
+		qdf_print("%s: Invalid pl_info context\n", __func__);
+		ASSERT(0);
+		return -EINVAL;
+	}
 
 	if (pl_info->curr_pkt_state < PKTLOG_OPR_IN_PROGRESS_CLEARBUFF_COMPLETE)
 		return -EBUSY;
@@ -434,6 +566,7 @@ static int __pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
 	if (is_iwpriv_command == 0 && log_state == 0 &&
 	    pl_dev->vendor_cmd_send == false) {
 		pl_info->curr_pkt_state = PKTLOG_OPR_NOT_IN_PROGRESS;
+		qdf_print("%s: pktlog operation not in progress\n", __func__);
 		return 0;
 	}
 
@@ -444,13 +577,15 @@ static int __pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
 			if (error != 0) {
 				pl_info->curr_pkt_state =
 					PKTLOG_OPR_NOT_IN_PROGRESS;
-				return error;
+				qdf_print("%s: pktlog buff alloc failed\n",
+					__func__);
+				return -ENOMEM;
 			}
 
 			if (!pl_info->buf) {
 				pl_info->curr_pkt_state =
 					PKTLOG_OPR_NOT_IN_PROGRESS;
-				printk("%s: pktlog buf alloc failed\n",
+				qdf_print("%s: pktlog buf alloc failed\n",
 				       __func__);
 				ASSERT(0);
 				return -ENOMEM;
@@ -477,18 +612,22 @@ static int __pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
 
 	if (log_state != 0) {
 		/* WDI subscribe */
-		if ((!pl_dev->is_pktlog_cb_subscribed) &&
-			wdi_pktlog_subscribe(txrx_pdev, log_state)) {
-			pl_info->curr_pkt_state = PKTLOG_OPR_NOT_IN_PROGRESS;
-			printk("Unable to subscribe to the WDI %s\n", __func__);
-			return -EINVAL;
+		if (!pl_dev->is_pktlog_cb_subscribed) {
+			error = wdi_pktlog_subscribe(cdp_pdev, log_state);
+			if (error) {
+				pl_info->curr_pkt_state =
+						PKTLOG_OPR_NOT_IN_PROGRESS;
+				qdf_print("Unable to subscribe to the WDI %s\n",
+					__func__);
+				return -EINVAL;
+			}
 		}
 		pl_dev->is_pktlog_cb_subscribed = true;
 		/* WMI command to enable pktlog on the firmware */
 		if (pktlog_enable_tgt(scn, log_state, ini_triggered,
 				user_triggered)) {
 			pl_info->curr_pkt_state = PKTLOG_OPR_NOT_IN_PROGRESS;
-			printk("Device cannot be enabled, %s\n", __func__);
+			qdf_print("Device cannot be enabled, %s\n", __func__);
 			return -EINVAL;
 		}
 
@@ -510,42 +649,27 @@ int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
 		 bool ini_triggered, uint8_t user_triggered,
 		 uint32_t is_iwpriv_command)
 {
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info *pl_info;
-	struct ol_txrx_pdev_t *txrx_pdev;
-	int error;
-
-	if (!scn) {
-		printk("%s: Invalid scn context\n", __func__);
-		ASSERT(0);
-		return -EINVAL;
-	}
+	int err;
 
-	txrx_pdev = cds_get_context(QDF_MODULE_ID_TXRX);
-	if (!txrx_pdev) {
-		printk("%s: Invalid txrx_pdev context\n", __func__);
-		ASSERT(0);
-		return -EINVAL;
-	}
+	pl_dev = get_pktlog_handle();
+	pl_info = pl_dev->pl_info;
 
-	pl_dev = txrx_pdev->pl_dev;
 	if (!pl_dev) {
-		printk("%s: Invalid pktlog context\n", __func__);
-		ASSERT(0);
+		qdf_print("%s: invalid pl_dev handle", __func__);
 		return -EINVAL;
 	}
 
-	pl_info = pl_dev->pl_info;
-
 	if (!pl_info)
 		return 0;
 
 
 	mutex_lock(&pl_info->pktlog_mutex);
-	error = __pktlog_enable(scn, log_state, ini_triggered,
+	err = __pktlog_enable(scn, log_state, ini_triggered,
 				user_triggered, is_iwpriv_command);
 	mutex_unlock(&pl_info->pktlog_mutex);
-	return error;
+	return err;
 }
 
 #define ONE_MEGABYTE (1024 * 1024)
@@ -553,21 +677,33 @@ int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
 
 static int __pktlog_setsize(struct hif_opaque_softc *scn, int32_t size)
 {
-	ol_txrx_pdev_handle pdev_txrx_handle =
-		cds_get_context(QDF_MODULE_ID_TXRX);
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info *pl_info;
+	struct cdp_pdev *pdev;
 
-	if (pdev_txrx_handle == NULL ||
-			pdev_txrx_handle->pl_dev == NULL ||
-			pdev_txrx_handle->pl_dev->pl_info == NULL)
-		return -EFAULT;
-
-	pl_dev = pdev_txrx_handle->pl_dev;
+	pl_dev = get_pktlog_handle();
 	pl_info = pl_dev->pl_info;
+	pdev = get_txrx_context();
+
+	if (!pl_dev) {
+		qdf_print("%s: invalid pl_dev handle", __func__);
+		return -EINVAL;
+	}
+
+	if (!pl_dev->pl_info) {
+		qdf_print("%s: invalid pl_dev handle", __func__);
+		return -EINVAL;
+	}
+
+	if (!pdev) {
+		qdf_print("%s: invalid pdev handle", __func__);
+		return -EINVAL;
+	}
 
-	if (pl_info->curr_pkt_state < PKTLOG_OPR_NOT_IN_PROGRESS)
+	if (pl_info->curr_pkt_state < PKTLOG_OPR_NOT_IN_PROGRESS) {
+		qdf_print("%s: pktlog is not configured", __func__);
 		return -EBUSY;
+	}
 
 	pl_info->curr_pkt_state = PKTLOG_OPR_IN_PROGRESS;
 
@@ -577,6 +713,7 @@ static int __pktlog_setsize(struct hif_opaque_softc *scn, int32_t size)
 			__func__, size, (ONE_MEGABYTE/ONE_MEGABYTE),
 			(MAX_ALLOWED_PKTLOG_SIZE/ONE_MEGABYTE));
 		pl_info->curr_pkt_state = PKTLOG_OPR_NOT_IN_PROGRESS;
+		qdf_print("%s: Invalid requested buff size", __func__);
 		return -EINVAL;
 	}
 
@@ -597,14 +734,14 @@ static int __pktlog_setsize(struct hif_opaque_softc *scn, int32_t size)
 	spin_lock_bh(&pl_info->log_lock);
 	if (pl_info->buf != NULL) {
 		if (pl_dev->is_pktlog_cb_subscribed &&
-			wdi_pktlog_unsubscribe(pdev_txrx_handle,
-					 pl_info->log_state)) {
-			pl_info->curr_pkt_state = PKTLOG_OPR_NOT_IN_PROGRESS;
-			printk("Cannot unsubscribe pktlog from the WDI\n");
+			wdi_pktlog_unsubscribe(pdev, pl_info->log_state)) {
+			pl_info->curr_pkt_state =
+				PKTLOG_OPR_NOT_IN_PROGRESS;
+			qdf_print("Cannot unsubscribe pktlog from the WDI\n");
 			spin_unlock_bh(&pl_info->log_lock);
 			return -EFAULT;
 		}
-		pktlog_release_buf(pdev_txrx_handle);
+		pktlog_release_buf(scn);
 		pl_dev->is_pktlog_cb_subscribed = false;
 		pl_dev->tgt_pktlog_alloced = false;
 	}
@@ -620,18 +757,11 @@ static int __pktlog_setsize(struct hif_opaque_softc *scn, int32_t size)
 
 int pktlog_setsize(struct hif_opaque_softc *scn, int32_t size)
 {
-	int status;
-	ol_txrx_pdev_handle pdev_txrx_handle =
-		cds_get_context(QDF_MODULE_ID_TXRX);
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info *pl_info;
+	int status;
 
-	if (pdev_txrx_handle == NULL ||
-			pdev_txrx_handle->pl_dev == NULL ||
-			pdev_txrx_handle->pl_dev->pl_info == NULL)
-		return -EFAULT;
-
-	pl_dev = pdev_txrx_handle->pl_dev;
+	pl_dev = get_pktlog_handle();
 	pl_info = pl_dev->pl_info;
 
 	mutex_lock(&pl_info->pktlog_mutex);
@@ -643,20 +773,23 @@ int pktlog_setsize(struct hif_opaque_softc *scn, int32_t size)
 
 int pktlog_clearbuff(struct hif_opaque_softc *scn, bool clear_buff)
 {
-	ol_txrx_pdev_handle pdev_txrx_handle =
-		cds_get_context(QDF_MODULE_ID_TXRX);
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev;
 	struct ath_pktlog_info *pl_info;
 	uint8_t save_pktlog_state;
 
-	if (pdev_txrx_handle == NULL ||
-			pdev_txrx_handle->pl_dev == NULL ||
-			pdev_txrx_handle->pl_dev->pl_info == NULL)
-		return -EFAULT;
-
-	pl_dev = pdev_txrx_handle->pl_dev;
+	pl_dev = get_pktlog_handle();
 	pl_info = pl_dev->pl_info;
 
+	if (!pl_dev) {
+		qdf_print("%s: invalid pl_dev handle", __func__);
+		return -EINVAL;
+	}
+
+	if (!pl_dev->pl_info) {
+		qdf_print("%s: invalid pl_dev handle", __func__);
+		return -EINVAL;
+	}
+
 	if (!clear_buff)
 		return -EINVAL;
 
@@ -714,9 +847,14 @@ void pktlog_process_fw_msg(uint32_t *buff)
 {
 	uint32_t *pl_hdr;
 	uint32_t log_type;
-	struct ol_txrx_pdev_t *txrx_pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct cdp_pdev *pdev = get_txrx_context();
+#ifdef CONFIG_MCL
+	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
+#else
+	/*TODO: WIN implementation to get soc */
+#endif
 
-	if (!txrx_pdev) {
+	if (!pdev) {
 		qdf_print("%s: txrx_pdev is NULL", __func__);
 		return;
 	}
@@ -725,26 +863,26 @@ void pktlog_process_fw_msg(uint32_t *buff)
 	log_type =
 		(*(pl_hdr + 1) & ATH_PKTLOG_HDR_LOG_TYPE_MASK) >>
 		ATH_PKTLOG_HDR_LOG_TYPE_SHIFT;
+
 	if ((log_type == PKTLOG_TYPE_TX_CTRL)
 		|| (log_type == PKTLOG_TYPE_TX_STAT)
 		|| (log_type == PKTLOG_TYPE_TX_MSDU_ID)
 		|| (log_type == PKTLOG_TYPE_TX_FRM_HDR)
 		|| (log_type == PKTLOG_TYPE_TX_VIRT_ADDR))
-		wdi_event_handler(WDI_EVENT_TX_STATUS,
-				  txrx_pdev, pl_hdr);
+		cdp_wdi_event_handler(soc, pdev,
+				WDI_EVENT_TX_STATUS, pl_hdr);
 	else if (log_type == PKTLOG_TYPE_RC_FIND)
-		wdi_event_handler(WDI_EVENT_RATE_FIND,
-				  txrx_pdev, pl_hdr);
+		cdp_wdi_event_handler(soc, pdev,
+				WDI_EVENT_RATE_FIND, pl_hdr);
 	else if (log_type == PKTLOG_TYPE_RC_UPDATE)
-		wdi_event_handler(WDI_EVENT_RATE_UPDATE,
-				  txrx_pdev, pl_hdr);
+		cdp_wdi_event_handler(soc, pdev,
+				WDI_EVENT_RATE_UPDATE, pl_hdr);
 	else if (log_type == PKTLOG_TYPE_RX_STAT)
-		wdi_event_handler(WDI_EVENT_RX_DESC,
-				  txrx_pdev, pl_hdr);
+		cdp_wdi_event_handler(soc, pdev,
+				WDI_EVENT_RX_DESC, pl_hdr);
 	else if (log_type == PKTLOG_TYPE_SW_EVENT)
-		wdi_event_handler(WDI_EVENT_SW_EVENT,
-				  txrx_pdev, pl_hdr);
-
+		cdp_wdi_event_handler(soc, pdev,
+				WDI_EVENT_SW_EVENT, pl_hdr);
 }
 
 #if defined(QCA_WIFI_3_0_ADRASTEA)
@@ -768,7 +906,7 @@ static inline int pktlog_nbuf_check_sanity(qdf_nbuf_t nbuf)
  */
 static void pktlog_t2h_msg_handler(void *context, HTC_PACKET *pkt)
 {
-	struct ol_pktlog_dev_t *pdev = (struct ol_pktlog_dev_t *)context;
+	struct pktlog_dev_t *pdev = (struct pktlog_dev_t *)context;
 	qdf_nbuf_t pktlog_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
 	uint32_t *msg_word;
 
@@ -841,7 +979,7 @@ static enum htc_send_full_action pktlog_h2t_full(void *context, HTC_PACKET *pkt)
  *
  * Return: 0 for success/failure
  */
-static int pktlog_htc_connect_service(struct ol_pktlog_dev_t *pdev)
+static int pktlog_htc_connect_service(struct pktlog_dev_t *pdev)
 {
 	struct htc_service_connect_req connect;
 	struct htc_service_connect_resp response;
@@ -896,27 +1034,28 @@ static int pktlog_htc_connect_service(struct ol_pktlog_dev_t *pdev)
  */
 int pktlog_htc_attach(void)
 {
-	struct ol_txrx_pdev_t *txrx_pdev = cds_get_context(QDF_MODULE_ID_TXRX);
-	struct ol_pktlog_dev_t *pdev = NULL;
+	struct pktlog_dev_t *pl_pdev = get_pktlog_handle();
 	void *htc_pdev = cds_get_context(QDF_MODULE_ID_HTC);
 
-	if ((!txrx_pdev) || (!txrx_pdev->pl_dev) || (!htc_pdev))
+	if ((!pl_pdev) || (!htc_pdev)) {
+		qdf_print("Invalid pl_dev or htc_pdev handle");
 		return -EINVAL;
+	}
 
-	pdev = txrx_pdev->pl_dev;
-	pdev->htc_pdev = htc_pdev;
-	return pktlog_htc_connect_service(pdev);
+	pl_pdev->htc_pdev = htc_pdev;
+	return pktlog_htc_connect_service(pl_pdev);
 }
 #else
 int pktlog_htc_attach(void)
 {
-	struct ol_txrx_pdev_t *txrx_pdev = cds_get_context(QDF_MODULE_ID_TXRX);
-	struct ol_pktlog_dev_t *pdev = NULL;
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 
-	if (!txrx_pdev)
+	if (!pl_dev) {
+		qdf_print("Invalid pl_dev handle");
 		return -EINVAL;
-	pdev = txrx_pdev->pl_dev;
-	pdev->mt_pktlog_enabled = false;
+	}
+
+	pl_dev->mt_pktlog_enabled = false;
 	return 0;
 }
 #endif

+ 118 - 38
utils/pktlog/pktlog_internal.c

@@ -91,6 +91,8 @@ void pktlog_getbuf_intsafe(struct ath_pktlog_arg *plarg)
 		printk("Invalid log_buf in %s\n", __func__);
 		return;
 	}
+
+
 	buf_size = pl_info->buf_size;
 	cur_wr_offset = log_buf->wr_offset;
 	/* Move read offset to the next entry if there is a buffer overlap */
@@ -146,7 +148,7 @@ void pktlog_getbuf_intsafe(struct ath_pktlog_arg *plarg)
 	plarg->buf = log_ptr;
 }
 
-char *pktlog_getbuf(struct ol_pktlog_dev_t *pl_dev,
+char *pktlog_getbuf(struct pktlog_dev_t *pl_dev,
 		    struct ath_pktlog_info *pl_info,
 		    size_t log_size, struct ath_pktlog_hdr *pl_hdr)
 {
@@ -253,8 +255,9 @@ static void process_ieee_hdr(void *data)
  *
  * Return: none
  */
+/* TODO: Platform specific function */
 static void
-fill_ieee80211_hdr_data(struct ol_txrx_pdev_t *txrx_pdev,
+fill_ieee80211_hdr_data(struct cdp_pdev *pdev,
 	struct ath_pktlog_msdu_info *pl_msdu_info, void *data)
 {
 	uint32_t i;
@@ -270,6 +273,7 @@ fill_ieee80211_hdr_data(struct ol_txrx_pdev_t *txrx_pdev,
 	uint8_t vdev_id;
 	qdf_nbuf_t netbuf;
 	uint32_t len;
+	struct ol_txrx_pdev_t *txrx_pdev = (struct ol_txrx_pdev_t *)pdev;
 
 
 	pl_msdu_info->num_msdu = *msdu_id_info;
@@ -341,13 +345,13 @@ fill_ieee80211_hdr_data(struct ol_txrx_pdev_t *txrx_pdev,
 #endif
 
 #ifdef HELIUMPLUS
-A_STATUS process_tx_info(struct ol_txrx_pdev_t *txrx_pdev, void *data)
+A_STATUS process_tx_info(struct cdp_pdev *txrx_pdev, void *data)
 {
 	/*
 	 * Must include to process different types
 	 * TX_CTL, TX_STATUS, TX_MSDU_ID, TX_FRM_HDR
 	 */
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 	struct ath_pktlog_hdr pl_hdr;
 	struct ath_pktlog_info *pl_info;
 	uint32_t *pl_tgt_hdr;
@@ -356,9 +360,9 @@ A_STATUS process_tx_info(struct ol_txrx_pdev_t *txrx_pdev, void *data)
 		printk("Invalid pdev in %s\n", __func__);
 		return A_ERROR;
 	}
-	qdf_assert(txrx_pdev->pl_dev);
+
+	qdf_assert(pl_dev);
 	qdf_assert(data);
-	pl_dev = txrx_pdev->pl_dev;
 
 	pl_tgt_hdr = (uint32_t *) data;
 	/*
@@ -413,6 +417,7 @@ A_STATUS process_tx_info(struct ol_txrx_pdev_t *txrx_pdev, void *data)
 		qdf_mem_copy(txstat_log.ds_status,
 			     ((void *)data + sizeof(struct ath_pktlog_hdr)),
 			     pl_hdr.size);
+		/* TODO: MCL specific API */
 		cds_pkt_stats_to_logger_thread(&pl_hdr, NULL,
 						txstat_log.ds_status);
 	}
@@ -420,13 +425,13 @@ A_STATUS process_tx_info(struct ol_txrx_pdev_t *txrx_pdev, void *data)
 }
 
 #else
-A_STATUS process_tx_info(struct ol_txrx_pdev_t *txrx_pdev, void *data)
+A_STATUS process_tx_info(struct cdp_pdev *txrx_pdev, void *data)
 {
 	/*
 	 * Must include to process different types
 	 * TX_CTL, TX_STATUS, TX_MSDU_ID, TX_FRM_HDR
 	 */
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 	struct ath_pktlog_hdr pl_hdr;
 	struct ath_pktlog_info *pl_info;
 	uint32_t *pl_tgt_hdr;
@@ -435,9 +440,9 @@ A_STATUS process_tx_info(struct ol_txrx_pdev_t *txrx_pdev, void *data)
 		qdf_print("Invalid pdev in %s\n", __func__);
 		return A_ERROR;
 	}
-	qdf_assert(txrx_pdev->pl_dev);
+
+	qdf_assert(pl_dev);
 	qdf_assert(data);
-	pl_dev = txrx_pdev->pl_dev;
 
 	pl_tgt_hdr = (uint32_t *) data;
 	/*
@@ -479,9 +484,11 @@ A_STATUS process_tx_info(struct ol_txrx_pdev_t *txrx_pdev, void *data)
 			A_UINT32 buf_size;
 
 			vdev_id &= 0x00FFFFFF;
+			/* TODO: MCL specific API */
 			data = wma_get_beacon_buffer_by_vdev_id(vdev_id,
 								&buf_size);
 			if (data) {
+				/* TODO: platform specific API */
 				process_ieee_hdr(data);
 				qdf_mem_free(data);
 			}
@@ -540,6 +547,7 @@ A_STATUS process_tx_info(struct ol_txrx_pdev_t *txrx_pdev, void *data)
 		qdf_mem_copy(txstat_log.ds_status,
 			     ((void *)data + sizeof(struct ath_pktlog_hdr)),
 			     pl_hdr.size);
+
 		cds_pkt_stats_to_logger_thread(&pl_hdr, NULL,
 						txstat_log.ds_status);
 	}
@@ -564,13 +572,15 @@ A_STATUS process_tx_info(struct ol_txrx_pdev_t *txrx_pdev, void *data)
 		cds_pkt_stats_to_logger_thread(&pl_hdr, NULL,
 						pl_msdu_info.ath_msdu_info);
 	}
+
 	return A_OK;
 }
 #endif
 
+/* TODO: hardware dependent function */
 A_STATUS process_rx_info_remote(void *pdev, void *data)
 {
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 	struct ath_pktlog_info *pl_info;
 	struct htt_host_rx_desc_base *rx_desc;
 	struct ath_pktlog_hdr pl_hdr;
@@ -579,15 +589,11 @@ A_STATUS process_rx_info_remote(void *pdev, void *data)
 	struct ol_rx_remote_data *r_data = (struct ol_rx_remote_data *)data;
 	qdf_nbuf_t msdu;
 
-	if (!pdev) {
-		printk("Invalid pdev in %s\n", __func__);
+	if (!pdev || !r_data || !pl_dev) {
+		qdf_print("%s: Invalid handle", __func__);
 		return A_ERROR;
 	}
-	if (!r_data) {
-		printk("Invalid data in %s\n", __func__);
-		return A_ERROR;
-	}
-	pl_dev = ((struct ol_txrx_pdev_t *)pdev)->pl_dev;
+
 	pl_info = pl_dev->pl_info;
 	msdu = r_data->msdu;
 
@@ -632,7 +638,7 @@ A_STATUS process_rx_info_remote(void *pdev, void *data)
 
 A_STATUS process_rx_info(void *pdev, void *data)
 {
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 	struct ath_pktlog_info *pl_info;
 	struct ath_pktlog_rx_info rxstat_log;
 	struct ath_pktlog_hdr pl_hdr;
@@ -643,7 +649,12 @@ A_STATUS process_rx_info(void *pdev, void *data)
 		printk("Invalid pdev in %s", __func__);
 		return A_ERROR;
 	}
-	pl_dev = ((struct ol_txrx_pdev_t *)pdev)->pl_dev;
+
+	if (!pl_dev) {
+		printk("Invalid pl_dev in %s", __func__);
+		return A_ERROR;
+	}
+
 	pl_info = pl_dev->pl_info;
 	pl_tgt_hdr = (uint32_t *) data;
 	pl_hdr.flags = (*(pl_tgt_hdr + ATH_PKTLOG_HDR_FLAGS_OFFSET) &
@@ -682,7 +693,7 @@ A_STATUS process_rx_info(void *pdev, void *data)
 
 A_STATUS process_rate_find(void *pdev, void *data)
 {
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 	struct ath_pktlog_hdr pl_hdr;
 	struct ath_pktlog_info *pl_info;
 	size_t log_size;
@@ -695,12 +706,8 @@ A_STATUS process_rate_find(void *pdev, void *data)
 	struct ath_pktlog_rc_find rcf_log;
 	uint32_t *pl_tgt_hdr;
 
-	if (!pdev) {
-		qdf_print("Invalid pdev in %s\n", __func__);
-		return A_ERROR;
-	}
-	if (!data) {
-		qdf_print("Invalid data in %s\n", __func__);
+	if (!pdev || !data || !pl_dev) {
+		qdf_print("%s: Invalid handle", __func__);
 		return A_ERROR;
 	}
 
@@ -732,7 +739,6 @@ A_STATUS process_rate_find(void *pdev, void *data)
 	pl_hdr.size = (*(pl_tgt_hdr + ATH_PKTLOG_HDR_SIZE_OFFSET) &
 		       ATH_PKTLOG_HDR_SIZE_MASK) >> ATH_PKTLOG_HDR_SIZE_SHIFT;
 	pl_hdr.timestamp = *(pl_tgt_hdr + ATH_PKTLOG_HDR_TIMESTAMP_OFFSET);
-	pl_dev = ((struct ol_txrx_pdev_t *)pdev)->pl_dev;
 	pl_info = pl_dev->pl_info;
 	log_size = pl_hdr.size;
 	rcf_log.rcFind = (void *)pktlog_getbuf(pl_dev, pl_info,
@@ -748,7 +754,7 @@ A_STATUS process_rate_find(void *pdev, void *data)
 
 A_STATUS process_sw_event(void *pdev, void *data)
 {
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 	struct ath_pktlog_hdr pl_hdr;
 	struct ath_pktlog_info *pl_info;
 	size_t log_size;
@@ -769,6 +775,11 @@ A_STATUS process_sw_event(void *pdev, void *data)
 		qdf_print("Invalid data in %s\n", __func__);
 		return A_ERROR;
 	}
+	if (!pl_dev) {
+		qdf_print("Invalid pl_dev in %s", __func__);
+		return A_ERROR;
+	}
+
 
 	pl_tgt_hdr = (uint32_t *) data;
 	/*
@@ -803,7 +814,6 @@ A_STATUS process_sw_event(void *pdev, void *data)
 		*(pl_tgt_hdr + ATH_PKTLOG_HDR_TYPE_SPECIFIC_DATA_OFFSET);
 #endif
 
-	pl_dev = ((struct ol_txrx_pdev_t *)pdev)->pl_dev;
 	pl_info = pl_dev->pl_info;
 	log_size = pl_hdr.size;
 	sw_event.sw_event = (void *)pktlog_getbuf(pl_dev, pl_info,
@@ -818,21 +828,18 @@ A_STATUS process_sw_event(void *pdev, void *data)
 
 A_STATUS process_rate_update(void *pdev, void *data)
 {
-	struct ol_pktlog_dev_t *pl_dev;
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
 	struct ath_pktlog_hdr pl_hdr;
 	size_t log_size;
 	struct ath_pktlog_info *pl_info;
 	struct ath_pktlog_rc_update rcu_log;
 	uint32_t *pl_tgt_hdr;
 
-	if (!pdev) {
-		printk("Invalid pdev in %s\n", __func__);
-		return A_ERROR;
-	}
-	if (!data) {
-		printk("Invalid data in %s\n", __func__);
+	if (!pdev || !data || !pl_dev) {
+		qdf_print("%s: Invalid handle", __func__);
 		return A_ERROR;
 	}
+
 	pl_tgt_hdr = (uint32_t *) data;
 	/*
 	 * Makes the short words (16 bits) portable b/w little endian
@@ -861,7 +868,6 @@ A_STATUS process_rate_update(void *pdev, void *data)
 	pl_hdr.size = (*(pl_tgt_hdr + ATH_PKTLOG_HDR_SIZE_OFFSET) &
 		       ATH_PKTLOG_HDR_SIZE_MASK) >> ATH_PKTLOG_HDR_SIZE_SHIFT;
 	pl_hdr.timestamp = *(pl_tgt_hdr + ATH_PKTLOG_HDR_TIMESTAMP_OFFSET);
-	pl_dev = ((struct ol_txrx_pdev_t *)pdev)->pl_dev;
 	log_size = pl_hdr.size;
 	pl_info = pl_dev->pl_info;
 
@@ -878,4 +884,78 @@ A_STATUS process_rate_update(void *pdev, void *data)
 	cds_pkt_stats_to_logger_thread(&pl_hdr, NULL, rcu_log.txRateCtrl);
 	return A_OK;
 }
+#ifdef QCA_WIFI_QCA6290
+int process_rx_desc_remote(void *pdev, void *data)
+{
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
+	struct ath_pktlog_hdr pl_hdr;
+	struct ath_pktlog_rx_info rxstat_log;
+	size_t log_size;
+	struct ath_pktlog_info *pl_info;
+	qdf_nbuf_t log_nbuf = (qdf_nbuf_t)data;
+
+	pl_info = pl_dev->pl_info;
+	pl_hdr.flags = (1 << PKTLOG_FLG_FRM_TYPE_REMOTE_S);
+	pl_hdr.missed_cnt = 0;
+	pl_hdr.log_type = 22; /*PKTLOG_TYPE_RX_STATBUF*/
+	pl_hdr.size = qdf_nbuf_len(log_nbuf);
+	pl_hdr.timestamp = 0;
+	log_size = pl_hdr.size;
+	rxstat_log.rx_desc = (void *)pktlog_getbuf(pl_dev, pl_info,
+						  log_size, &pl_hdr);
+
+	if (rxstat_log.rx_desc == NULL) {
+		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
+				"%s: Rx descriptor is NULL", __func__);
+		return -EFAULT;
+	}
+
+	qdf_mem_copy(rxstat_log.rx_desc, qdf_nbuf_data(log_nbuf), pl_hdr.size);
+	cds_pkt_stats_to_logger_thread(&pl_hdr, NULL,
+						rxstat_log.rx_desc);
+	return 0;
+}
+
+int
+process_pktlog_lite(void *context, void *log_data, uint16_t log_type)
+{
+	struct pktlog_dev_t *pl_dev = get_pktlog_handle();
+	struct ath_pktlog_info *pl_info;
+	struct ath_pktlog_hdr pl_hdr;
+	struct ath_pktlog_rx_info rxstat_log;
+	size_t log_size;
+	qdf_nbuf_t log_nbuf = (qdf_nbuf_t)log_data;
+
+	pl_info = pl_dev->pl_info;
+	pl_hdr.flags = (1 << PKTLOG_FLG_FRM_TYPE_REMOTE_S);
+	pl_hdr.missed_cnt = 0;
+	pl_hdr.log_type = log_type;
+	pl_hdr.size = qdf_nbuf_len(log_nbuf);
+	pl_hdr.timestamp = 0;
+	log_size = pl_hdr.size;
+	rxstat_log.rx_desc = (void *)pktlog_getbuf(pl_dev, pl_info,
+						  log_size, &pl_hdr);
+
+	if (rxstat_log.rx_desc == NULL) {
+		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
+			"%s: Rx descriptor is NULL", __func__);
+		return -EFAULT;
+	}
+
+	qdf_mem_copy(rxstat_log.rx_desc, qdf_nbuf_data(log_nbuf), pl_hdr.size);
+
+	cds_pkt_stats_to_logger_thread(&pl_hdr, NULL, rxstat_log.rx_desc);
+	return 0;
+}
+#else
+int process_rx_desc_remote(void *pdev, void *data)
+{
+	return 0;
+}
+int
+process_pktlog_lite(void *context, void *log_data, uint16_t log_type)
+{
+	return 0;
+}
+#endif
 #endif /*REMOVE_PKT_LOG */

+ 0 - 1
wlan_cfg/wlan_cfg.c

@@ -57,7 +57,6 @@
 #define WLAN_CFG_INT_TIMER_THRESHOLD_TX 8
 #define WLAN_CFG_INT_TIMER_THRESHOLD_RX 8
 #define WLAN_CFG_INT_TIMER_THRESHOLD_OTHER 8
-
 #endif
 
 #ifdef CONFIG_WIN