WiFi-Hal: Support new header of size 16-bytes for fate stats

Host driver sends the stats with 15th-bit set in flags field of
wh_pktlog_hdr_t header if the structure size is 16-bytes.
Offset for the fates stats from header by size of new
structure (16-bytes) if the flag is set. Otherwise offset by the
size of existing structure (12 bytes).

Change-Id: I5941c3ac5f525f36291ebee8eff01309dee11cc8
diff --git a/qcwcn/wifi_hal/pkt_stats.h b/qcwcn/wifi_hal/pkt_stats.h
index 9f6b0c5..d1cc71a 100644
--- a/qcwcn/wifi_hal/pkt_stats.h
+++ b/qcwcn/wifi_hal/pkt_stats.h
@@ -61,6 +61,7 @@
 #define PKT_INFO_FLG_RX_REORDER_DROP_S   0x100
 #define PKT_INFO_FLG_RX_PEER_INFO_S      0x200
 #define PKT_INFO_FLG_UNKNOWN_S           0x400
+#define PKT_INFO_FLG_PKT_DUMP_V2         0x8000
 
 /* MASK value of flags based on RX_STAT content.
  * These are the events that carry Rx decriptor
@@ -81,6 +82,16 @@
     u32 timestamp;
 } __attribute__((packed)) wh_pktlog_hdr_t;
 
+/* Format of the v2 packet stats event*/
+typedef struct {
+    u16 flags;
+    u16 missed_cnt;
+    u16 log_type;
+    u16 size;
+    u32 timestamp;
+    u32 reserved;
+} __attribute__((packed)) wh_pktlog_hdr_v2_t;
+
 /*Rx stats specific structures. */
 struct rx_attention {
     u32 first_mpdu                      :  1; //[0]
diff --git a/qcwcn/wifi_hal/wifilogger_diag.cpp b/qcwcn/wifi_hal/wifilogger_diag.cpp
index 9684ec0..5e9227b 100644
--- a/qcwcn/wifi_hal/wifilogger_diag.cpp
+++ b/qcwcn/wifi_hal/wifilogger_diag.cpp
@@ -2018,11 +2018,16 @@
     } else if (pkt_stats_header->log_type == PKTLOG_TYPE_PKT_DUMP ||
                pkt_stats_header->log_type == PKTLOG_TYPE_PKT_DUMP_V2) {
         pthread_mutex_lock(&info->pkt_fate_stats_lock);
-        if (info->fate_monitoring_enabled)
-            status = parse_pkt_fate_stats(info,
-                                          (u8 *)(pkt_stats_header + 1),
-                                          pkt_stats_header->size);
-        else
+        if (info->fate_monitoring_enabled) {
+            if (pkt_stats_header->flags & PKT_INFO_FLG_PKT_DUMP_V2)
+                status = parse_pkt_fate_stats(info,
+                                              (u8 *)pkt_stats_header + sizeof(wh_pktlog_hdr_v2_t),
+                                              pkt_stats_header->size);
+            else
+                status = parse_pkt_fate_stats(info,
+                                              (u8 *)pkt_stats_header + sizeof(wh_pktlog_hdr_t),
+                                              pkt_stats_header->size);
+        } else
             status = WIFI_SUCCESS;
         pthread_mutex_unlock(&info->pkt_fate_stats_lock);
     } else {
@@ -2057,8 +2062,13 @@
                   pkt_stats_header->log_type);
             return status;
         }
-        data += (sizeof(wh_pktlog_hdr_t) + pkt_stats_header->size);
-        buflen -= (sizeof(wh_pktlog_hdr_t) + pkt_stats_header->size);
+        if (pkt_stats_header->flags & PKT_INFO_FLG_PKT_DUMP_V2){
+            data += (sizeof(wh_pktlog_hdr_v2_t) + pkt_stats_header->size);
+            buflen -= (sizeof(wh_pktlog_hdr_v2_t) + pkt_stats_header->size);
+        } else {
+            data += (sizeof(wh_pktlog_hdr_t) + pkt_stats_header->size);
+            buflen -= (sizeof(wh_pktlog_hdr_t) + pkt_stats_header->size);
+        }
     } while (buflen > 0);
 
     return status;