[qca-nss-drv] Add new message type to request conn stats from FW
A new message type is added to request connection stats from FW.
The message may be larger then the ipv4/ipv6_msg so the caller
need to specify the actual size of the msg so ipv4/ipv6_tx can
allocate buffer that is large enough to carry this msg
Change-Id: Ia99ff4e3e42c669bf49aba630eb6f9dadb68d0c3
Signed-off-by: Stephen Wang <wstephen@codeaurora.org>
diff --git a/nss_ipv6.c b/nss_ipv6.c
index 16067a4..ffd2032 100644
--- a/nss_ipv6.c
+++ b/nss_ipv6.c
@@ -53,6 +53,27 @@
}
/*
+ * nss_ipv6_driver_conn_sync_many_update()
+ * Update driver specific information from the conn_sync_many messsage.
+ */
+static void nss_ipv6_driver_conn_sync_many_update(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_conn_sync_many_msg *nicsm)
+{
+ uint32_t i;
+
+ /*
+ * Sanity check for the stats count
+ */
+ if (nicsm->count * sizeof(struct nss_ipv6_conn_sync) >= nicsm->size) {
+ nss_warning("%p: stats sync count %u exceeds the size of this msg %u", nss_ctx, nicsm->count, nicsm->size);
+ return;
+ }
+
+ for (i = 0; i < nicsm->count; i++) {
+ nss_ipv6_driver_conn_sync_update(nss_ctx, &nicsm->conn_sync[i]);
+ }
+}
+
+/*
* nss_ipv6_driver_node_sync_update)
* Update driver specific information from the messsage.
*/
@@ -141,6 +162,13 @@
*/
nss_ipv6_driver_conn_sync_update(nss_ctx, &nim->msg.conn_stats);
break;
+
+ case NSS_IPV6_TX_CONN_STATS_SYNC_MANY_MSG:
+ /*
+ * Update driver statistics on connection sync many.
+ */
+ nss_ipv6_driver_conn_sync_many_update(nss_ctx, &nim->msg.conn_stats_many);
+ break;
}
/*
@@ -167,10 +195,10 @@
}
/*
- * nss_ipv6_tx()
- * Transmit an ipv6 message to the FW.
+ * nss_ipv6_tx_with_size()
+ * Transmit an ipv6 message to the FW with a specified size.
*/
-nss_tx_status_t nss_ipv6_tx(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *nim)
+nss_tx_status_t nss_ipv6_tx_with_size(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *nim, uint32_t size)
{
struct nss_ipv6_msg *nim2;
struct nss_cmn_msg *ncm = &nim->cm;
@@ -201,7 +229,12 @@
return NSS_TX_FAILURE;
}
- nbuf = dev_alloc_skb(NSS_NBUF_PAYLOAD_SIZE);
+ if(size > PAGE_SIZE) {
+ nss_warning("%p: tx request size too large: %u", nss_ctx, size);
+ return NSS_TX_FAILURE;
+ }
+
+ nbuf = dev_alloc_skb(size);
if (unlikely(!nbuf)) {
NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NBUF_ALLOC_FAILS]);
nss_warning("%p: msg dropped as command allocation failed", nss_ctx);
@@ -229,6 +262,15 @@
}
/*
+ * nss_ipv6_tx()
+ * Transmit an ipv4 message to the FW.
+ */
+nss_tx_status_t nss_ipv6_tx(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *nim)
+{
+ return nss_ipv6_tx_with_size(nss_ctx, nim, NSS_NBUF_PAYLOAD_SIZE);
+}
+
+/*
**********************************
Register/Unregister/Miscellaneous APIs
**********************************
@@ -487,6 +529,7 @@
}
EXPORT_SYMBOL(nss_ipv6_tx);
+EXPORT_SYMBOL(nss_ipv6_tx_with_size);
EXPORT_SYMBOL(nss_ipv6_notify_register);
EXPORT_SYMBOL(nss_ipv6_notify_unregister);
EXPORT_SYMBOL(nss_ipv6_get_mgr);