qcacmn: Add more fields to SAMP message

Add new fields such as agc_total_gain, sscan_gainchange
to the Spectral SAMP message.

CRs-Fixed: 2291499
Change-Id: Ia6a9fd742c2ee98fd9d7102f0d8c66dcd22a1614
diff --git a/spectral/dispatcher/inc/wlan_spectral_public_structs.h b/spectral/dispatcher/inc/wlan_spectral_public_structs.h
index 3d39a66..afa06f1 100644
--- a/spectral/dispatcher/inc/wlan_spectral_public_structs.h
+++ b/spectral/dispatcher/inc/wlan_spectral_public_structs.h
@@ -440,6 +440,10 @@
 	int16_t noise_floor;
 	int16_t noise_floor_sec80;
 	uint32_t ch_width;
+	uint8_t spectral_agc_total_gain;
+	uint8_t spectral_agc_total_gain_sec80;
+	uint8_t spectral_gainchange;
+	uint8_t spectral_gainchange_sec80;
 } __ATTRIB_PACKED;
 
 /**
diff --git a/target_if/spectral/target_if_spectral.h b/target_if/spectral/target_if_spectral.h
index f3a8aa3..0cee776 100644
--- a/target_if/spectral/target_if_spectral.h
+++ b/target_if/spectral/target_if_spectral.h
@@ -289,6 +289,20 @@
 } __ATTRIB_PACK;
 
 /**
+ * struct sscan_report_fields_gen3 - Fields of spectral report
+ * @sscan_agc_total_gain:  The AGC total gain in DB.
+ * @inband_pwr_db: The in-band power of the signal in 1/2 DB steps
+ * @sscan_gainchange: This bit is set to 1 if a gainchange occurred during
+ *                 the spectral scan FFT.  Software may choose to
+ *                 disregard the results.
+ */
+struct sscan_report_fields_gen3 {
+	uint8_t sscan_agc_total_gain;
+	int16_t inband_pwr_db;
+	uint8_t sscan_gainchange;
+};
+
+/**
  * struct spectral_sscan_report_gen3 - spectral report in phyerr event
  * @sscan_timestamp:  Timestamp at which fft report was generated
  * @sscan_hdr_sig:    signature
@@ -888,6 +902,10 @@
 	struct interf_src_rsp interf_list;
 	struct spectral_classifier_params classifier_params;
 	struct ath_softc *sc;
+	uint8_t agc_total_gain;
+	uint8_t agc_total_gain_sec80;
+	uint8_t gainchange;
+	uint8_t gainchange_sec80;
 };
 
 #ifdef WLAN_CONV_SPECTRAL_ENABLE
diff --git a/target_if/spectral/target_if_spectral_netlink.c b/target_if/spectral/target_if_spectral_netlink.c
index e8bed94..2aae510 100644
--- a/target_if/spectral/target_if_spectral_netlink.c
+++ b/target_if/spectral/target_if_spectral_netlink.c
@@ -154,6 +154,9 @@
 	spec_samp_msg->freq_loading = params->freq_loading;
 	spec_samp_msg->samp_data.spectral_data_len = params->datalen;
 	spec_samp_msg->samp_data.spectral_rssi = params->rssi;
+	spec_samp_msg->samp_data.spectral_agc_total_gain =
+			params->agc_total_gain;
+	spec_samp_msg->samp_data.spectral_gainchange = params->gainchange;
 	spec_samp_msg->samp_data.ch_width = spectral->ch_width;
 
 	spec_samp_msg->samp_data.spectral_combined_rssi =
@@ -226,6 +229,10 @@
 		    params->rssi_sec80;
 		spec_samp_msg->samp_data.noise_floor_sec80 =
 		    params->noise_floor_sec80;
+		spec_samp_msg->samp_data.spectral_agc_total_gain_sec80 =
+			params->agc_total_gain_sec80;
+		spec_samp_msg->samp_data.spectral_gainchange_sec80 =
+			params->gainchange_sec80;
 
 		spec_samp_msg->samp_data.spectral_data_len_sec80 =
 		    params->datalen_sec80;
diff --git a/target_if/spectral/target_if_spectral_phyerr.c b/target_if/spectral/target_if_spectral_phyerr.c
index 69b4990..caf0a02 100644
--- a/target_if/spectral/target_if_spectral_phyerr.c
+++ b/target_if/spectral/target_if_spectral_phyerr.c
@@ -1251,19 +1251,18 @@
  *
  * Consume spectral summary report for gen3
  *
- * Return: rssi
+ * Return: void
  */
-static int
+static void
 target_if_consume_sscan_report_gen3(struct target_if_spectral *spectral,
-				    uint8_t *data) {
-	int rssi;
+				    uint8_t *data,
+				    struct sscan_report_fields_gen3 *fields) {
 	struct spectral_sscan_report_gen3 *psscan_report;
 
 	psscan_report = (struct spectral_sscan_report_gen3 *)data;
-	/* RSSI is in 1/2 dBm steps, Covert it to dBm scale */
-	rssi = (get_bitfield(psscan_report->hdr_a, 10, 18)) >> 1;
-
-	return rssi;
+	fields->sscan_agc_total_gain = get_bitfield(psscan_report->hdr_a, 8, 0);
+	fields->inband_pwr_db = get_bitfield(psscan_report->hdr_a, 10, 18);
+	fields->sscan_gainchange = get_bitfield(psscan_report->hdr_b, 1, 30);
 }
 
 /**
@@ -1375,6 +1374,7 @@
 	uint8_t *data = report->data;
 	struct wlan_objmgr_vdev *vdev;
 	uint8_t vdev_rxchainmask;
+	struct sscan_report_fields_gen3 sscan_report_fields;
 
 	OS_MEMZERO(&params, sizeof(params));
 
@@ -1382,7 +1382,12 @@
 			spectral, data,
 			TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3) != 0)
 		goto fail;
-	rssi = target_if_consume_sscan_report_gen3(spectral, data);
+	target_if_consume_sscan_report_gen3(spectral, data,
+					    &sscan_report_fields);
+	/* RSSI is in 1/2 dBm steps, Covert it to dBm scale */
+	rssi = (sscan_report_fields.inband_pwr_db) >> 1;
+	params.agc_total_gain = sscan_report_fields.sscan_agc_total_gain;
+	params.gainchange = sscan_report_fields.sscan_gainchange;
 	/* Advance buf pointer to the search fft report */
 	data += sizeof(struct spectral_sscan_report_gen3);
 
@@ -1502,7 +1507,13 @@
 				spectral, data,
 				TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3) != 0)
 			goto fail;
-		rssi = target_if_consume_sscan_report_gen3(spectral, data);
+		 target_if_consume_sscan_report_gen3(spectral, data,
+						     &sscan_report_fields);
+		/* RSSI is in 1/2 dBm steps, Covert it to dBm scale */
+		rssi = (sscan_report_fields.inband_pwr_db) >> 1;
+		params.agc_total_gain_sec80 =
+			sscan_report_fields.sscan_agc_total_gain;
+		params.gainchange_sec80 = sscan_report_fields.sscan_gainchange;
 		/* Advance buf pointer to the search fft report */
 		data += sizeof(struct spectral_sscan_report_gen3);