[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_ipv4.c b/nss_ipv4.c
index de99ece..6c73c7c 100644
--- a/nss_ipv4.c
+++ b/nss_ipv4.c
@@ -54,6 +54,27 @@
}
/*
+ * nss_ipv4_driver_conn_sync_many_update()
+ * Update driver specific information from the conn_sync_many messsage.
+ */
+static void nss_ipv4_driver_conn_sync_many_update(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_conn_sync_many_msg *nicsm)
+{
+ int i;
+
+ /*
+ * Sanity check for the stats count
+ */
+ if (nicsm->count * sizeof(struct nss_ipv4_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_ipv4_driver_conn_sync_update(nss_ctx, &nicsm->conn_sync[i]);
+ }
+}
+
+/*
* nss_ipv4_driver_node_sync_update)
* Update driver specific information from the messsage.
*/
@@ -138,6 +159,13 @@
*/
nss_ipv4_driver_conn_sync_update(nss_ctx, &nim->msg.conn_stats);
break;
+
+ case NSS_IPV4_TX_CONN_STATS_SYNC_MANY_MSG:
+ /*
+ * Update driver statistics on connection sync many.
+ */
+ nss_ipv4_driver_conn_sync_many_update(nss_ctx, &nim->msg.conn_stats_many);
+ break;
}
/*
@@ -164,10 +192,10 @@
}
/*
- * nss_ipv4_tx()
- * Transmit an ipv4 message to the FW.
+ * nss_ipv4_tx_with_size()
+ * Transmit an ipv4 message to the FW with a specified size.
*/
-nss_tx_status_t nss_ipv4_tx(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_msg *nim)
+nss_tx_status_t nss_ipv4_tx_with_size(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_msg *nim, uint32_t size)
{
struct nss_ipv4_msg *nim2;
struct nss_cmn_msg *ncm = &nim->cm;
@@ -198,7 +226,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);
@@ -226,6 +259,15 @@
}
/*
+ * nss_ipv4_tx()
+ * Transmit an ipv4 message to the FW.
+ */
+nss_tx_status_t nss_ipv4_tx(struct nss_ctx_instance *nss_ctx, struct nss_ipv4_msg *nim)
+{
+ return nss_ipv4_tx_with_size(nss_ctx, nim, NSS_NBUF_PAYLOAD_SIZE);
+}
+
+/*
**********************************
Register/Unregister/Miscellaneous APIs
**********************************
@@ -487,6 +529,7 @@
}
EXPORT_SYMBOL(nss_ipv4_tx);
+EXPORT_SYMBOL(nss_ipv4_tx_with_size);
EXPORT_SYMBOL(nss_ipv4_notify_register);
EXPORT_SYMBOL(nss_ipv4_notify_unregister);
EXPORT_SYMBOL(nss_ipv4_get_mgr);