[dpdk-dev] kni: fix stack frame size compile error

Message ID 20160922144854.1318-1-ferruh.yigit@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Commit Message

Ferruh Yigit Sept. 22, 2016, 2:48 p.m. UTC
  Compile error:
.../lib/librte_eal/linuxapp/kni/kni_net.c:
In function ‘kni_net_rx_lo_fifo’:
.../lib/librte_eal/linuxapp/kni/kni_net.c:331:1:
error: the frame size of 1056 bytes is larger than 1024 bytes
[-Werror=frame-larger-than=]

This compile error seen with some compiler / kernel combinations.

Moved some local variables to the kni_dev struct.

Fixes: 8451269e6d7b ("kni: remove continuous memory restriction")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h |  8 ++++++-
 lib/librte_eal/linuxapp/kni/kni_net.c | 45 +++++++++++++----------------------
 2 files changed, 23 insertions(+), 30 deletions(-)
  

Comments

Thomas Monjalon Sept. 22, 2016, 3:44 p.m. UTC | #1
2016-09-22 15:48, Ferruh Yigit:
> Compile error:
> .../lib/librte_eal/linuxapp/kni/kni_net.c:
> In function ‘kni_net_rx_lo_fifo’:
> .../lib/librte_eal/linuxapp/kni/kni_net.c:331:1:
> error: the frame size of 1056 bytes is larger than 1024 bytes
> [-Werror=frame-larger-than=]
> 
> This compile error seen with some compiler / kernel combinations.
> 
> Moved some local variables to the kni_dev struct.
> 
> Fixes: 8451269e6d7b ("kni: remove continuous memory restriction")
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index a0e5cb6..4a4a8e1 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -39,10 +39,11 @@ 
 #include <exec-env/rte_kni_common.h>
 #define KNI_KTHREAD_RESCHEDULE_INTERVAL 5 /* us */
 
+#define MBUF_BURST_SZ 32
+
 /**
  * A structure describing the private information for a kni device.
  */
-
 struct kni_dev {
 	/* kni list */
 	struct list_head list;
@@ -104,6 +105,11 @@  struct kni_dev {
 		BE_FINISH = 0x4,
 	}vq_status;
 #endif
+	/* buffers */
+	void *pa[MBUF_BURST_SZ];
+	void *va[MBUF_BURST_SZ];
+	void *alloc_pa[MBUF_BURST_SZ];
+	void *alloc_va[MBUF_BURST_SZ];
 };
 
 #define KNI_ERR(args...) printk(KERN_DEBUG "KNI: Error: " args)
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 3d2abe9..5d8711c 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -44,8 +44,6 @@ 
 
 #define WD_TIMEOUT 5 /*jiffies */
 
-#define MBUF_BURST_SZ 32
-
 #define KNI_WAIT_RESPONSE_TIMEOUT 300 /* 3 seconds */
 
 /* typedef for rx function */
@@ -163,10 +161,7 @@  kni_net_rx_normal(struct kni_dev *kni)
 	uint32_t len;
 	unsigned i, num_rx, num_fq;
 	struct rte_kni_mbuf *kva;
-	void *pa[MBUF_BURST_SZ];
-	void *va[MBUF_BURST_SZ];
 	void *data_kva;
-
 	struct sk_buff *skb;
 	struct net_device *dev = kni->net_dev;
 
@@ -181,16 +176,16 @@  kni_net_rx_normal(struct kni_dev *kni)
 	num_rx = min(num_fq, (unsigned)MBUF_BURST_SZ);
 
 	/* Burst dequeue from rx_q */
-	num_rx = kni_fifo_get(kni->rx_q, pa, num_rx);
+	num_rx = kni_fifo_get(kni->rx_q, kni->pa, num_rx);
 	if (num_rx == 0)
 		return;
 
 	/* Transfer received packets to netif */
 	for (i = 0; i < num_rx; i++) {
-		kva = pa2kva(pa[i]);
+		kva = pa2kva(kni->pa[i]);
 		len = kva->pkt_len;
 		data_kva = kva2data_kva(kva);
-		va[i] = pa2va(pa[i], kva);
+		kni->va[i] = pa2va(kni->pa[i], kva);
 
 		skb = dev_alloc_skb(len + 2);
 		if (!skb) {
@@ -234,7 +229,7 @@  kni_net_rx_normal(struct kni_dev *kni)
 	}
 
 	/* Burst enqueue mbufs into free_q */
-	ret = kni_fifo_put(kni->free_q, va, num_rx);
+	ret = kni_fifo_put(kni->free_q, kni->va, num_rx);
 	if (ret != num_rx)
 		/* Failing should not happen */
 		KNI_ERR("Fail to enqueue entries into free_q\n");
@@ -250,13 +245,8 @@  kni_net_rx_lo_fifo(struct kni_dev *kni)
 	uint32_t len;
 	unsigned i, num, num_rq, num_tq, num_aq, num_fq;
 	struct rte_kni_mbuf *kva;
-	void *pa[MBUF_BURST_SZ];
-	void *va[MBUF_BURST_SZ];
 	void * data_kva;
-
 	struct rte_kni_mbuf *alloc_kva;
-	void *alloc_pa[MBUF_BURST_SZ];
-	void *alloc_va[MBUF_BURST_SZ];
 	void *alloc_data_kva;
 
 	/* Get the number of entries in rx_q */
@@ -282,24 +272,24 @@  kni_net_rx_lo_fifo(struct kni_dev *kni)
 		return;
 
 	/* Burst dequeue from rx_q */
-	ret = kni_fifo_get(kni->rx_q, pa, num);
+	ret = kni_fifo_get(kni->rx_q, kni->pa, num);
 	if (ret == 0)
 		return; /* Failing should not happen */
 
 	/* Dequeue entries from alloc_q */
-	ret = kni_fifo_get(kni->alloc_q, alloc_pa, num);
+	ret = kni_fifo_get(kni->alloc_q, kni->alloc_pa, num);
 	if (ret) {
 		num = ret;
 		/* Copy mbufs */
 		for (i = 0; i < num; i++) {
-			kva = pa2kva(pa[i]);
+			kva = pa2kva(kni->pa[i]);
 			len = kva->pkt_len;
 			data_kva = kva2data_kva(kva);
-			va[i] = pa2va(pa[i], kva);
+			kni->va[i] = pa2va(kni->pa[i], kva);
 
-			alloc_kva = pa2kva(alloc_pa[i]);
+			alloc_kva = pa2kva(kni->alloc_pa[i]);
 			alloc_data_kva = kva2data_kva(alloc_kva);
-			alloc_va[i] = pa2va(alloc_pa[i], alloc_kva);
+			kni->alloc_va[i] = pa2va(kni->alloc_pa[i], alloc_kva);
 
 			memcpy(alloc_data_kva, data_kva, len);
 			alloc_kva->pkt_len = len;
@@ -310,14 +300,14 @@  kni_net_rx_lo_fifo(struct kni_dev *kni)
 		}
 
 		/* Burst enqueue mbufs into tx_q */
-		ret = kni_fifo_put(kni->tx_q, alloc_va, num);
+		ret = kni_fifo_put(kni->tx_q, kni->alloc_va, num);
 		if (ret != num)
 			/* Failing should not happen */
 			KNI_ERR("Fail to enqueue mbufs into tx_q\n");
 	}
 
 	/* Burst enqueue mbufs into free_q */
-	ret = kni_fifo_put(kni->free_q, va, num);
+	ret = kni_fifo_put(kni->free_q, kni->va, num);
 	if (ret != num)
 		/* Failing should not happen */
 		KNI_ERR("Fail to enqueue mbufs into free_q\n");
@@ -340,10 +330,7 @@  kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 	uint32_t len;
 	unsigned i, num_rq, num_fq, num;
 	struct rte_kni_mbuf *kva;
-	void *pa[MBUF_BURST_SZ];
-	void *va[MBUF_BURST_SZ];
 	void *data_kva;
-
 	struct sk_buff *skb;
 	struct net_device *dev = kni->net_dev;
 
@@ -362,16 +349,16 @@  kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 		return;
 
 	/* Burst dequeue mbufs from rx_q */
-	ret = kni_fifo_get(kni->rx_q, pa, num);
+	ret = kni_fifo_get(kni->rx_q, kni->pa, num);
 	if (ret == 0)
 		return;
 
 	/* Copy mbufs to sk buffer and then call tx interface */
 	for (i = 0; i < num; i++) {
-		kva = pa2kva(pa[i]);
+		kva = pa2kva(kni->pa[i]);
 		len = kva->pkt_len;
 		data_kva = kva2data_kva(kva);
-		va[i] = pa2va(pa[i], kva);
+		kni->va[i] = pa2va(kni->pa[i], kva);
 
 		skb = dev_alloc_skb(len + 2);
 		if (skb == NULL)
@@ -425,7 +412,7 @@  kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 	}
 
 	/* enqueue all the mbufs from rx_q into free_q */
-	ret = kni_fifo_put(kni->free_q, va, num);
+	ret = kni_fifo_put(kni->free_q, kni->va, num);
 	if (ret != num)
 		/* Failing should not happen */
 		KNI_ERR("Fail to enqueue mbufs into free_q\n");