qcacmn: Add sequence number to peer mlme object

The new P2P component cannot use legacy API's to get/set
the sequence number, thus we need new obj manager API's to handle
MLME sequence numbers.

Change-Id: I848f6c33f82cab6b90710f1411e0be55647e4476
CRs-Fixed: 2014032
diff --git a/umac/cmn_services/inc/wlan_cmn.h b/umac/cmn_services/inc/wlan_cmn.h
index a066b1d..5bcef18 100644
--- a/umac/cmn_services/inc/wlan_cmn.h
+++ b/umac/cmn_services/inc/wlan_cmn.h
@@ -38,6 +38,9 @@
 /* Max length of a SSID */
 #define WLAN_SSID_MAX_LEN 32
 
+/* Max sequence number */
+#define WLAN_MAX_SEQ_NUM    4096
+
 /* Max no. of Stations can be associated to VDEV*/
 #define WLAN_UMAC_MAX_AP_PEERS WLAN_UMAC_PSOC_MAX_PEERS
 /* Max no. of peers for STA vap */
diff --git a/umac/cmn_services/obj_mgr/inc/wlan_objmgr_peer_obj.h b/umac/cmn_services/obj_mgr/inc/wlan_objmgr_peer_obj.h
index 22fafb0..6b9a276 100644
--- a/umac/cmn_services/obj_mgr/inc/wlan_objmgr_peer_obj.h
+++ b/umac/cmn_services/obj_mgr/inc/wlan_objmgr_peer_obj.h
@@ -121,6 +121,7 @@
  * @phymode:         phy mode of station
  * @rssi:            Last received RSSI value
  * @max_rate:        Max Rate supported
+ * @seq_num:         Sequence number
  * @state:           State of the peer
  */
 struct wlan_objmgr_peer_mlme {
@@ -130,6 +131,7 @@
 	enum wlan_phymode phymode;
 	int8_t rssi;
 	uint32_t max_rate;
+	uint16_t seq_num;
 	enum wlan_peer_state state;
 };
 
@@ -746,4 +748,61 @@
 	/* This API is invoked with lock acquired, do not add log prints */
 	return peer->peer_mlme.state;
 }
+
+/**
+ * wlan_peer_mlme_get_next_seq_num() - get peer mlme next sequence number
+ * @peer: PEER object
+ *
+ * API to get mlme peer next sequence number
+ *
+ * Caller need to acquire lock with wlan_peer_obj_lock()
+ *
+ * Return: peer mlme next sequence number
+ */
+static inline uint32_t wlan_peer_mlme_get_next_seq_num(
+				struct wlan_objmgr_peer *peer)
+{
+	/* This API is invoked with lock acquired, do not add log prints */
+	if (peer->peer_mlme.seq_num < WLAN_MAX_SEQ_NUM)
+		peer->peer_mlme.seq_num++;
+	else
+		peer->peer_mlme.seq_num = 0;
+
+	return peer->peer_mlme.seq_num;
+}
+
+/**
+ * wlan_peer_mlme_get_seq_num() - get peer mlme sequence number
+ * @peer: PEER object
+ *
+ * API to get mlme peer sequence number
+ *
+ * Caller need to acquire lock with wlan_peer_obj_lock()
+ *
+ * Return: peer mlme sequence number
+ */
+static inline uint32_t wlan_peer_mlme_get_seq_num(
+				struct wlan_objmgr_peer *peer)
+{
+	/* This API is invoked with lock acquired, do not add log prints */
+	return peer->peer_mlme.seq_num;
+}
+
+/**
+ * wlan_peer_mlme_reset_seq_num() - reset peer mlme sequence number
+ * @peer: PEER object
+ *
+ * API to reset peer sequence number
+ *
+ * Caller need to acquire lock with wlan_peer_obj_lock()
+ *
+ * Return: void
+ */
+static inline void wlan_peer_mlme_reset_seq_num(
+				struct wlan_objmgr_peer *peer)
+{
+	/* This API is invoked with lock acquired, do not add log prints */
+	peer->peer_mlme.seq_num = 0;
+}
+
 #endif /* _WLAN_OBJMGR_PEER_OBJ_H_*/
diff --git a/umac/cmn_services/obj_mgr/src/wlan_objmgr_peer_obj.c b/umac/cmn_services/obj_mgr/src/wlan_objmgr_peer_obj.c
index 593a5e7..bc130c0 100644
--- a/umac/cmn_services/obj_mgr/src/wlan_objmgr_peer_obj.c
+++ b/umac/cmn_services/obj_mgr/src/wlan_objmgr_peer_obj.c
@@ -143,6 +143,7 @@
 	wlan_peer_set_macaddr(peer, macaddr);
 	/* initialize peer state */
 	wlan_peer_mlme_set_state(peer, WLAN_INIT_STATE);
+	wlan_peer_mlme_reset_seq_num(peer);
 	qdf_atomic_init(&peer->peer_objmgr.ref_cnt);
 	/* Attach peer to psoc, psoc maintains the node table for the device */
 	if (wlan_objmgr_psoc_peer_attach(psoc, peer) !=