Browse Source

qcacmn: Add iwpriv pktlog command to clear pktlog buffer

Implement iwpriv pktlog command to clear pktlog buffer.
This command is effective only if pktlog disable is issued previously.
This command needs one argument.
Command to use this feature : iwpriv wlan0 pktlog 4

Change-Id: I431169a10828b6cfcd21c7d8065f325c5eb8cbba
CRs-Fixed: 2031212
Poddar, Siddarth 8 years ago
parent
commit
5503c76aca
2 changed files with 50 additions and 0 deletions
  1. 5 0
      utils/pktlog/include/pktlog_ac.h
  2. 45 0
      utils/pktlog/pktlog_ac.c

+ 5 - 0
utils/pktlog/include/pktlog_ac.h

@@ -136,6 +136,7 @@ void pktlog_init(struct hif_opaque_softc *scn);
 int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
 		 bool, uint8_t, uint32_t);
 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);
@@ -172,6 +173,10 @@ static int pktlog_setsize(struct hif_opaque_softc *scn, int32_t log_state)
 {
 	return 0;
 }
+static int pktlog_clearbuff(struct hif_opaque_softc *scn, bool clear_buff)
+{
+	return 0;
+}
 static int pktlog_disable(struct hif_opaque_softc *scn)
 {
 	return 0;

+ 45 - 0
utils/pktlog/pktlog_ac.c

@@ -516,6 +516,51 @@ int pktlog_setsize(struct hif_opaque_softc *scn, int32_t size)
 	return 0;
 }
 
+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 ath_pktlog_info *pl_info;
+
+	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_info = pl_dev->pl_info;
+
+	if (!clear_buff)
+		return -EINVAL;
+
+	if (pl_info->log_state) {
+		qdf_print("%s: Logging should be disabled before clearing "
+			  "pktlog buffer.", __func__);
+		return -EINVAL;
+	}
+
+	if (pl_info->buf != NULL) {
+		if (pl_info->buf_size > 0) {
+			qdf_print("%s: pktlog buffer is cleared.", __func__);
+			memset(pl_info->buf, 0, pl_info->buf_size);
+			pl_dev->is_pktlog_cb_subscribed = false;
+			pl_dev->tgt_pktlog_alloced = false;
+			pl_info->buf->rd_offset = -1;
+		} else {
+			qdf_print("%s: pktlog buffer size is not proper. "
+				  "Existing Buf size %d", __func__,
+				  pl_info->buf_size);
+			return -EFAULT;
+		}
+	} else {
+		qdf_print("%s: pktlog buff is NULL", __func__);
+		return -EFAULT;
+	}
+
+	return 0;
+}
+
 /**
  * pktlog_process_fw_msg() - process packetlog message
  * @buff: buffer