Merge "[qca-nss-drv]: Add a new wifi_vdev Host to NSS message"
diff --git a/exports/nss_wifi_vdev.h b/exports/nss_wifi_vdev.h
index 32b437b..5cf0f80 100644
--- a/exports/nss_wifi_vdev.h
+++ b/exports/nss_wifi_vdev.h
@@ -68,6 +68,7 @@
 	NSS_WIFI_VDEV_QWRAP_PSTA_DELETE_ENTRY,
 	NSS_WIFI_VDEV_QWRAP_PSTA_ADD_ENTRY,
 	NSS_WIFI_VDEV_QWRAP_ISOLATION_ENABLE,
+	NSS_WIFI_VDEV_SET_PEER_NEXT_HOP,
 	NSS_WIFI_VDEV_MAX_MSG
 };
 
@@ -115,6 +116,8 @@
 	NSS_WIFI_VDEV_QWRAP_PSTA_DEL_FAIL,
 	NSS_WIFI_VDEV_QWRAP_ISOLATION_EN_FAIL,
 	NSS_WIFI_VDEV_QWRAP_ALLOC_FAIL,
+	NSS_WIFI_VDEV_PEER_NOT_FOUND_BY_MAC,
+	NSS_WIFI_VDEV_PEER_NEXT_HOP_NOT_FOUND,
 	NSS_WIFI_VDEV_EINV_MAX_CFG
 };
 
@@ -425,6 +428,16 @@
 };
 
 /**
+ * nss_wifi_vdev_set_peer_next_hop
+ *	Set per peer next hop.
+ */
+struct nss_wifi_vdev_set_peer_next_hop_msg {
+	uint8_t peer_mac_addr[ETH_ALEN];   /**< MAC peer address. */
+	uint16_t reserved;		   /**< Reserved. */
+	uint32_t if_num;                   /**< Next hop interface number. */
+};
+
+/**
  * nss_wifi_vdev_qwrap_psta_msg
  *	PSTA VAP entry map in QWRAP mode.
  */
@@ -875,6 +888,8 @@
 				/**< Message to get PSTA VAP details in QWRAP mode. */
 		struct nss_wifi_vdev_qwrap_isolation_en_msg vdev_qwrap_isolation_en;
 				/**< Message to enable QWRAP isolation mode. */
+		struct nss_wifi_vdev_set_peer_next_hop_msg vdev_set_peer_next_hp;
+				/**< Message to set next hop per peer. */
 	} msg;		/**< Virtual device message payload. */
 };
 
@@ -974,7 +989,7 @@
  * @return
  * None.
  */
-void nss_wifi_vdev_msg_init(struct nss_wifi_vdev_msg *nim, uint16_t if_num, uint32_t type, uint32_t len,
+void nss_wifi_vdev_msg_init(struct nss_wifi_vdev_msg *nim, uint32_t if_num, uint32_t type, uint32_t len,
 				nss_wifi_vdev_msg_callback_t *cb, void *app_data);
 
 /**
@@ -1047,6 +1062,23 @@
  */
 nss_tx_status_t nss_wifi_vdev_set_next_hop(struct nss_ctx_instance *nss_ctx, int if_num, int next_hop);
 
+/**
+ * nss_wifi_vdev_set_peer_next_hop
+ *	Send peer next hop message to Wi-Fi virtual device.
+ *
+ * @datatypes
+ * nss_ctx_instance
+ *
+ * @param[in]    nss_ctx      Pointer to the NSS core context.
+ * @param[in]    nss_if       NSS interface number.
+ * @param[in]    addr         Peer MAC address.
+ * @param[in]    next_hop_if  Next hop interface number.
+ *
+ * @return
+ * Status of the Tx operation.
+ */
+nss_tx_status_t nss_wifi_vdev_set_peer_next_hop(struct nss_ctx_instance *nss_ctx, uint32_t nss_if, uint8_t *addr, uint32_t next_hop_if);
+
 /*
  * nss_wifi_vdev_set_dp_type
  *	Set datapath type for virtual device.
diff --git a/nss_wifi_vdev.c b/nss_wifi_vdev.c
index a04fd6d..e182b2c 100644
--- a/nss_wifi_vdev.c
+++ b/nss_wifi_vdev.c
@@ -75,7 +75,7 @@
  * nss_wifi_vdev_msg_init()
  *	Initialize wifi message.
  */
-void nss_wifi_vdev_msg_init(struct nss_wifi_vdev_msg *nim, uint16_t if_num, uint32_t type, uint32_t len,
+void nss_wifi_vdev_msg_init(struct nss_wifi_vdev_msg *nim, uint32_t if_num, uint32_t type, uint32_t len,
 			nss_wifi_vdev_msg_callback_t *cb, void *app_data)
 {
 	nss_cmn_msg_init(&nim->cm, if_num, type, len, (void *)cb, app_data);
@@ -189,7 +189,7 @@
 	}
 
 	next_hop_msg->ifnumber = next_hop;
-	nss_wifi_vdev_msg_init(wifivdevmsg, if_num, NSS_WIFI_VDEV_SET_NEXT_HOP, 0, NULL, NULL);
+	nss_wifi_vdev_msg_init(wifivdevmsg, if_num, NSS_WIFI_VDEV_SET_NEXT_HOP, sizeof(struct nss_wifi_vdev_set_next_hop_msg), NULL, NULL);
 
 	status = nss_wifi_vdev_tx_msg(ctx, wifivdevmsg);
 	if (status != NSS_TX_SUCCESS) {
@@ -202,6 +202,36 @@
 EXPORT_SYMBOL(nss_wifi_vdev_set_next_hop);
 
 /*
+ * nss_wifi_vdev_set_next_hop()
+ */
+nss_tx_status_t nss_wifi_vdev_set_peer_next_hop(struct nss_ctx_instance *ctx, uint32_t nss_if, uint8_t *addr, uint32_t next_hop_if)
+{
+	nss_tx_status_t status;
+	struct nss_wifi_vdev_msg *wifivdevmsg = kzalloc(sizeof(struct nss_wifi_vdev_msg), GFP_KERNEL);
+	struct nss_wifi_vdev_set_peer_next_hop_msg *peer_next_hop_msg = &wifivdevmsg->msg.vdev_set_peer_next_hp;
+
+	if (!wifivdevmsg) {
+		nss_warning("%p: Unable to allocate next hop message", ctx);
+		return NSS_TX_FAILURE;
+	}
+
+	memcpy(peer_next_hop_msg->peer_mac_addr, addr, ETH_ALEN);
+
+	peer_next_hop_msg->if_num = next_hop_if;
+	nss_wifi_vdev_msg_init(wifivdevmsg, nss_if, NSS_WIFI_VDEV_SET_PEER_NEXT_HOP,
+			sizeof(struct nss_wifi_vdev_set_peer_next_hop_msg), NULL, NULL);
+
+	status = nss_wifi_vdev_tx_msg(ctx, wifivdevmsg);
+	if (status != NSS_TX_SUCCESS) {
+		nss_warning("%p: Unable to send peer next hop message", ctx);
+	}
+
+	kfree(wifivdevmsg);
+	return status;
+}
+EXPORT_SYMBOL(nss_wifi_vdev_set_peer_next_hop);
+
+/*
  * nss_wifi_vdev_set_dp_type()
  *	Set the vap datapath type of the packet.
  */