qcacld-3.0: Correct the logic to decrement the beacon count in CSA IE

Beacon template may get updated from many use cases like change in
protection mode, update in CSA count and etc. Make sure that the driver
maintains the beacon count which is same as in beacon template, otherwise
there may be duplicate/missing beacon count due to inconsistency.

Decrement the beacon count value before updating the beacon template.

Change-Id: I0c4552445071dd6ab5322191c04d4f7d32c9a987
CRs-Fixed: 2170097
diff --git a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c
index 13f72e6..93757ca 100644
--- a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c
+++ b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c
@@ -2591,6 +2591,14 @@
 
 	if (LIM_IS_AP_ROLE(psessionEntry) &&
 	    true == psessionEntry->dfsIncludeChanSwIe) {
+
+		if (psessionEntry->gLimChannelSwitch.switchCount) {
+			/* Decrement the beacon switch count */
+			psessionEntry->gLimChannelSwitch.switchCount--;
+			pe_debug("current beacon count %d",
+				psessionEntry->gLimChannelSwitch.switchCount);
+		}
+
 		/* Send only 5 beacons with CSA IE Set in when a radar is detected */
 		if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
 			/*
@@ -2605,8 +2613,6 @@
 				lim_send_chan_switch_action_frame(pMac,
 					ch, ch_width, psessionEntry);
 
-			/* Decrement the IE count */
-			psessionEntry->gLimChannelSwitch.switchCount--;
 		} else {
 			/* Done with CSA IE update, send response back to SME */
 			psessionEntry->gLimChannelSwitch.switchCount = 0;