qcacmn: Change the maximum serialization pending commands

The host driver serialization module currently supports upto 4
commands in non scan pending queue. This is calculated at the
wlan_serialization_vdev_create_handler() as:
    max_pending_cmds = (WLAN_SER_MAX_PENDING_CMDS /
                        WLAN_SER_MAX_VDEVS)

But in SAP case, if multiple STA sends deauth at the same time,
4 pending commands in non scan pending queue is not sufficient
and will result in only disassoc from the first 4 STA getting
honored.

The current host wlan driver supports 3 SAP mode and
2 STA vdevs amounting to a total of 5 vdevs supported.
So calculate the total non scan pending commands for
serialization based on the total peers supported for each
mode to fix this issue.

In SAP case, maximum 32 peer are supported and for STA case,
maximum 4 pending commands for serialization. So change the
max pending commands calculation as:
 max_pending_cmds = (No. of sap modes supported * 32) +
                    (No .of STA modes supported *4 )

For MCL case the definition of WLAN_SER_MAX_PENDING_CMDS
will be moved to Kbuild.
For WIN case, the existing maximum count will be retained.

Change-Id: Iff1d9430b45e26812b600560b08e85e6040eafef
CRs-Fixed: 2483520
diff --git a/umac/cmn_services/serialization/src/wlan_serialization_main.c b/umac/cmn_services/serialization/src/wlan_serialization_main.c
index f663a8d..2f865fc 100644
--- a/umac/cmn_services/serialization/src/wlan_serialization_main.c
+++ b/umac/cmn_services/serialization/src/wlan_serialization_main.c
@@ -252,6 +252,8 @@
 			max_active_cmds = WLAN_SER_MAX_ACTIVE_CMDS;
 			max_pending_cmds = WLAN_SER_MAX_PENDING_CMDS;
 			cmd_pool_size = max_active_cmds + max_pending_cmds;
+			ser_debug("max_active_cmds %d max_pending_cmds %d",
+				  max_active_cmds, max_pending_cmds);
 			break;
 		}
 		qdf_list_create(&pdev_queue->active_list,
@@ -406,8 +408,16 @@
 		case SER_VDEV_QUEUE_COMP_NON_SCAN:
 			max_active_cmds = WLAN_SER_MAX_ACTIVE_CMDS /
 				WLAN_SER_MAX_VDEVS;
-			max_pending_cmds = WLAN_SER_MAX_PENDING_CMDS /
-				WLAN_SER_MAX_VDEVS;
+			if (wlan_vdev_mlme_get_opmode(vdev) == QDF_SAP_MODE ||
+			    wlan_vdev_mlme_get_opmode(vdev) == QDF_P2P_GO_MODE)
+				max_pending_cmds = WLAN_SER_MAX_PENDING_CMDS_AP;
+			else
+				max_pending_cmds =
+						WLAN_SER_MAX_PENDING_CMDS_STA;
+
+			ser_debug("Vdev type %d max_pending_cmds %d",
+				  wlan_vdev_mlme_get_opmode(vdev),
+				  max_pending_cmds);
 			break;
 		}
 
diff --git a/umac/cmn_services/serialization/src/wlan_serialization_main_i.h b/umac/cmn_services/serialization/src/wlan_serialization_main_i.h
index 3d63430..d2c95ad 100644
--- a/umac/cmn_services/serialization/src/wlan_serialization_main_i.h
+++ b/umac/cmn_services/serialization/src/wlan_serialization_main_i.h
@@ -28,10 +28,22 @@
 #include <wlan_objmgr_pdev_obj.h>
 #include <qdf_mc_timer.h>
 
-#define WLAN_SER_MAX_VDEVS 17
+#define WLAN_SER_MAX_VDEVS WLAN_UMAC_PDEV_MAX_VDEVS
 
 #define WLAN_SER_MAX_ACTIVE_CMDS WLAN_SER_MAX_VDEVS
+
+#ifndef WLAN_SER_MAX_PENDING_CMDS
 #define WLAN_SER_MAX_PENDING_CMDS (WLAN_SER_MAX_VDEVS * 4)
+#endif
+
+#ifndef WLAN_SER_MAX_PENDING_CMDS_AP
+#define WLAN_SER_MAX_PENDING_CMDS_AP \
+	(WLAN_SER_MAX_PENDING_CMDS / WLAN_SER_MAX_VDEVS)
+#endif
+#ifndef WLAN_SER_MAX_PENDING_CMDS_STA
+#define WLAN_SER_MAX_PENDING_CMDS_STA \
+	(WLAN_SER_MAX_PENDING_CMDS / WLAN_SER_MAX_VDEVS)
+#endif
 
 #define WLAN_SER_MAX_ACTIVE_SCAN_CMDS 8
 #define WLAN_SER_MAX_PENDING_SCAN_CMDS 24
@@ -59,6 +71,13 @@
 
 #define ser_err_no_fl(params...) \
 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_SERIALIZATION, params)
+
+/*
+ * Rate limited serialization logging api
+ */
+#define ser_err_rl(params...) \
+	QDF_TRACE_ERROR_RL(QDF_MODULE_ID_SERIALIZATION, params)
+
 /**
  * struct serialization_legacy_callback - to handle legacy serialization cb
  * @serialization_purge_cmd_list: function ptr to be filled by serialization
diff --git a/umac/cmn_services/serialization/src/wlan_serialization_non_scan.c b/umac/cmn_services/serialization/src/wlan_serialization_non_scan.c
index e451eda..30001aa 100644
--- a/umac/cmn_services/serialization/src/wlan_serialization_non_scan.c
+++ b/umac/cmn_services/serialization/src/wlan_serialization_non_scan.c
@@ -142,6 +142,8 @@
 			ser_pdev_obj, cmd_list, is_cmd_for_active_queue);
 
 	if (vdev_status == WLAN_SER_CMD_DENIED_LIST_FULL) {
+		ser_err_rl("List is full cannot add CMD %d cmd id %d",
+			   cmd_list->cmd.cmd_type, cmd_list->cmd.cmd_id);
 		status = vdev_status;
 		goto vdev_error;
 	}
diff --git a/umac/cmn_services/serialization/src/wlan_serialization_utils.c b/umac/cmn_services/serialization/src/wlan_serialization_utils.c
index 8395ec5..003baa5 100644
--- a/umac/cmn_services/serialization/src/wlan_serialization_utils.c
+++ b/umac/cmn_services/serialization/src/wlan_serialization_utils.c
@@ -550,6 +550,8 @@
 
 	if (qdf_list_size(queue) == qdf_list_max_size(queue)) {
 		status = WLAN_SER_CMD_DENIED_LIST_FULL;
+		ser_err("qdf_list_size: %d is already max %d",
+			qdf_list_size(queue), qdf_list_max_size(queue));
 		goto error;
 	}