From: Hiroshi Shimamoto <h-shimam...@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 at ct.jp.nec.com> Reviewed-by: Hayato Momma <h-momma at 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