From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by dpdk.org (Postfix) with ESMTP id 88B7A5FEB for ; Fri, 6 Mar 2015 01:10:50 +0100 (CET) Received: by pdbfp1 with SMTP id fp1so19411453pdb.2 for ; Thu, 05 Mar 2015 16:10:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/XeRZKG/H/+IEm6OhsapA82pjpdgAzHIbZucrIW0EEo=; b=eSPZrJh9wpsUxSG0JLiazLXkA17IV4nzERhJH4egyEAP1bFc6rWiK/9jZXOM7zoQ7a bqwkgt2GalcyExkp802lSOLiq5lA8j5hAwMPI2nf/77eiUPm/bAJLs9ajYiknPwrEM70 c8A5VZl/jwHDKTrCciLnve/9RB0/axcq62IdlgJLeq1gaL/Z83iGdzQ52EnpQlVtCk9q 7muX3WM0xnquCy58HOr/X0S2NnXd2lFMLyA0F8A4bG3gfZZnBAmOepEg0a7MciB0X15H J8CtMNcWIC3RJ7XjhgmVf1+ZM4oWPhFIR8IzY0TKuLYFtB7Xi9IKfxo5Lo6xF5iYmYKH R/vQ== X-Gm-Message-State: ALoCoQnXNthsAvP+beCpX0eGM0FJtgIuiZcu7YooCBF2d6G7CVsNovOnZyGPpVMKwckT+zrrlkep X-Received: by 10.70.135.165 with SMTP id pt5mr20068512pdb.101.1425600649916; Thu, 05 Mar 2015 16:10:49 -0800 (PST) Received: from urahara.brocade.com (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by mx.google.com with ESMTPSA id ms5sm7940550pbb.59.2015.03.05.16.10.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Mar 2015 16:10:49 -0800 (PST) From: Stephen Hemminger To: Yong Wang Date: Thu, 5 Mar 2015 16:10:32 -0800 Message-Id: <1425600635-20628-8-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1425600635-20628-1-git-send-email-stephen@networkplumber.org> References: <1425600635-20628-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org, Stephen Hemminger Subject: [dpdk-dev] [PATCH v3 07/10] vmxnet3: support jumbo frames X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Mar 2015 00:10:51 -0000 From: Stephen Hemminger Add support for linking multi-segment buffers together to handle Jumbo packets. Signed-off-by: Stephen Hemminger --- lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c | 3 +- lib/librte_pmd_vmxnet3/vmxnet3_ring.h | 2 + lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 76 ++++++++++++++++++++------------- 3 files changed, 50 insertions(+), 31 deletions(-) diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c index 35bb561..4f1bc4f 100644 --- a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +++ b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c @@ -401,6 +401,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) { struct rte_eth_conf port_conf = dev->data->dev_conf; struct vmxnet3_hw *hw = dev->data->dev_private; + uint32_t mtu = dev->data->mtu; Vmxnet3_DriverShared *shared = hw->shared; Vmxnet3_DSDevRead *devRead = &shared->devRead; uint32_t *mac_ptr; @@ -418,7 +419,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) devRead->misc.driverInfo.vmxnet3RevSpt = 1; devRead->misc.driverInfo.uptVerSpt = 1; - devRead->misc.mtu = rte_le_to_cpu_32(dev->data->mtu); + devRead->misc.mtu = rte_le_to_cpu_32(mtu); devRead->misc.queueDescPA = hw->queueDescPA; devRead->misc.queueDescLen = hw->queue_desc_len; devRead->misc.numTxQueues = hw->num_tx_queues; diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_ring.h b/lib/librte_pmd_vmxnet3/vmxnet3_ring.h index 612487e..55ceadf 100644 --- a/lib/librte_pmd_vmxnet3/vmxnet3_ring.h +++ b/lib/librte_pmd_vmxnet3/vmxnet3_ring.h @@ -171,6 +171,8 @@ typedef struct vmxnet3_rx_queue { uint32_t qid1; uint32_t qid2; Vmxnet3_RxQueueDesc *shared; + struct rte_mbuf *start_seg; + struct rte_mbuf *last_seg; struct vmxnet3_rxq_stats stats; bool stopped; uint16_t queue_id; /**< Device RX queue index. */ diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c index ba48a12..5cf187a 100644 --- a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +++ b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c @@ -571,7 +571,6 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) vmxnet3_rx_queue_t *rxq; Vmxnet3_RxCompDesc *rcd; vmxnet3_buf_info_t *rbi; - Vmxnet3_RxDesc *rxd; struct rte_mbuf *rxm = NULL; struct vmxnet3_hw *hw; @@ -596,42 +595,18 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) idx = rcd->rxdIdx; ring_idx = (uint8_t)((rcd->rqID == rxq->qid1) ? 0 : 1); - rxd = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx; rbi = rxq->cmd_ring[ring_idx].buf_info + idx; - if (unlikely(rcd->sop != 1 || rcd->eop != 1)) { - rte_pktmbuf_free_seg(rbi->m); - PMD_RX_LOG(DEBUG, "Packet spread across multiple buffers\n)"); - goto rcd_done; - } PMD_RX_LOG(DEBUG, "rxd idx: %d ring idx: %d.", idx, ring_idx); #ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER + Vmxnet3_RxDesc *rxd + = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx; VMXNET3_ASSERT(rcd->len <= rxd->len); VMXNET3_ASSERT(rbi->m); #endif - if (unlikely(rcd->len == 0)) { - PMD_RX_LOG(DEBUG, "Rx buf was skipped. rxring[%d][%d]\n)", - ring_idx, idx); -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER - VMXNET3_ASSERT(rcd->sop && rcd->eop); -#endif - rte_pktmbuf_free_seg(rbi->m); - goto rcd_done; - } - /* Assuming a packet is coming in a single packet buffer */ - if (unlikely(rxd->btype != VMXNET3_RXD_BTYPE_HEAD)) { - PMD_RX_LOG(DEBUG, - "Alert : Misbehaving device, incorrect " - " buffer type used. iPacket dropped."); - rte_pktmbuf_free_seg(rbi->m); - goto rcd_done; - } -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER - VMXNET3_ASSERT(rxd->btype == VMXNET3_RXD_BTYPE_HEAD); -#endif /* Get the packet buffer pointer from buf_info */ rxm = rbi->m; @@ -643,7 +618,7 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxq->cmd_ring[ring_idx].next2comp = idx; /* For RCD with EOP set, check if there is frame error */ - if (unlikely(rcd->err)) { + if (unlikely(rcd->eop && rcd->err)) { rxq->stats.drop_total++; rxq->stats.drop_err++; @@ -669,9 +644,49 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxm->ol_flags = 0; rxm->vlan_tci = 0; - vmxnet3_rx_offload(rcd, rxm); + /* + * If this is the first buffer of the received packet, + * set the pointer to the first mbuf of the packet + * Otherwise, update the total length and the number of segments + * of the current scattered packet, and update the pointer to + * the last mbuf of the current packet. + */ + if (rcd->sop) { +#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER + VMXNET3_ASSERT(!rxq->start_seg); + VMXNET3_ASSERT(rxd->btype == VMXNET3_RXD_BTYPE_HEAD); +#endif + + if (unlikely(rcd->len == 0)) { + PMD_RX_LOG(DEBUG, + "Rx buf was skipped. rxring[%d][%d])", + ring_idx, idx); + rte_pktmbuf_free_seg(rbi->m); + goto rcd_done; + } + + rxq->start_seg = rxm; + vmxnet3_rx_offload(rcd, rxm); + } else { + struct rte_mbuf *start = rxq->start_seg; + +#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER + VMXNET3_ASSERT(rxd->btype == VMXNET3_RXD_BTYPE_BODY); + VMXNET3_ASSERT(start != NULL); +#endif + + start->pkt_len += rxm->data_len; + start->nb_segs++; + + rxq->last_seg->next = rxm; + } + rxq->last_seg = rxm; + + if (rcd->eop) { + rx_pkts[nb_rx++] = rxq->start_seg; + rxq->start_seg = NULL; + } - rx_pkts[nb_rx++] = rxm; rcd_done: rxq->cmd_ring[ring_idx].next2comp = idx; VMXNET3_INC_RING_IDX_ONLY(rxq->cmd_ring[ring_idx].next2comp, rxq->cmd_ring[ring_idx].size); @@ -975,6 +990,7 @@ vmxnet3_dev_rxtx_init(struct rte_eth_dev *dev) } } rxq->stopped = FALSE; + rxq->start_seg = NULL; } for (i = 0; i < dev->data->nb_tx_queues; i++) { -- 2.1.4