DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [memnic PATCH 2/5] pmd: prepare to support variable frame size
@ 2014-06-06 11:06 Hiroshi Shimamoto
  0 siblings, 0 replies; only message in thread
From: Hiroshi Shimamoto @ 2014-06-06 11:06 UTC (permalink / raw)
  To: dev; +Cc: Hayato Momma

From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>

Add framesz field in adapter structure, and initialized with the current
frame size.
Replace length check on TX/RX with the above frame size.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Reviewed-by: Hayato Momma <h-momma@ce.jp.nec.com>
---
 pmd/pmd_memnic.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pmd/pmd_memnic.c b/pmd/pmd_memnic.c
index 4abdf26..6b6bcb3 100644
--- a/pmd/pmd_memnic.c
+++ b/pmd/pmd_memnic.c
@@ -49,6 +49,7 @@
 struct memnic_adapter {
 	struct memnic_area *nic;
 	int up_idx, down_idx;
+	uint32_t framesz;
 	struct rte_mempool *mp;
 	struct ether_addr mac_addr;
 	/*
@@ -107,6 +108,7 @@ static int memnic_dev_start(struct rte_eth_dev *dev)
 	adapter->nic->hdr.reset = 1;
 	/* no need to wait here */
 	adapter->up_idx = adapter->down_idx = 0;
+	adapter->framesz = MEMNIC_MAX_FRAME_LEN;
 
 	return 0;
 }
@@ -256,6 +258,7 @@ static uint16_t memnic_recv_pkts(void *rx_queue,
 	struct rte_mbuf *mb;
 	uint16_t nr;
 	uint64_t pkts, bytes, errs;
+	uint32_t framesz = adapter->framesz;
 	int idx;
 	struct rte_eth_stats *st = &adapter->stats[rte_lcore_id()];
 
@@ -268,7 +271,7 @@ static uint16_t memnic_recv_pkts(void *rx_queue,
 		p = &data->packets[idx];
 		if (p->status != MEMNIC_PKT_ST_FILLED)
 			break;
-		if (p->len > MEMNIC_MAX_FRAME_LEN) {
+		if (p->len > framesz) {
 			errs++;
 			goto drop;
 		}
@@ -317,6 +320,7 @@ static uint16_t memnic_xmit_pkts(void *tx_queue,
 	int idx;
 	struct rte_eth_stats *st = &adapter->stats[rte_lcore_id()];
 	uint64_t pkts, bytes, errs;
+	uint32_t framesz = adapter->framesz;
 
 	if (!adapter->nic->hdr.valid)
 		return 0;
@@ -324,11 +328,11 @@ static uint16_t memnic_xmit_pkts(void *tx_queue,
 	pkts = bytes = errs = 0;
 
 	for (nr = 0; nr < nb_pkts; nr++) {
-		int pkt_len = rte_pktmbuf_pkt_len(tx_pkts[nr]);
+		uint32_t pkt_len = rte_pktmbuf_pkt_len(tx_pkts[nr]);
 		struct rte_mbuf *sg;
 		void *ptr;
 
-		if (pkt_len > MEMNIC_MAX_FRAME_LEN) {
+		if (pkt_len > framesz) {
 			errs++;
 			break;
 		}
-- 
1.8.4

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-06-06 11:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-06 11:06 [dpdk-dev] [memnic PATCH 2/5] pmd: prepare to support variable frame size Hiroshi Shimamoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).