Message ID | 1413181389-14887-2-git-send-email-yongwang@vmware.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 360B368B5; Mon, 13 Oct 2014 08:15:50 +0200 (CEST) Received: from smtp-outbound-1.vmware.com (smtp-outbound-1.vmware.com [208.91.2.12]) by dpdk.org (Postfix) with ESMTP id 02CE67E33 for <dev@dpdk.org>; Mon, 13 Oct 2014 08:15:47 +0200 (CEST) Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 2C935986A1 for <dev@dpdk.org>; Sun, 12 Oct 2014 23:23:14 -0700 (PDT) Received: from ubuntu.localdomain (unknown [10.113.230.81]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id AEEFA41420 for <dev@dpdk.org>; Sun, 12 Oct 2014 23:23:13 -0700 (PDT) From: Yong Wang <yongwang@vmware.com> To: dev@dpdk.org Date: Sun, 12 Oct 2014 23:23:05 -0700 Message-Id: <1413181389-14887-2-git-send-email-yongwang@vmware.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1413181389-14887-1-git-send-email-yongwang@vmware.com> References: <1413181389-14887-1-git-send-email-yongwang@vmware.com> Subject: [dpdk-dev] [PATCH 1/5] vmxnet3: Fix VLAN Rx stripping X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Yong Wang
Oct. 13, 2014, 6:23 a.m. UTC
Shouldn't reset vlan_tci to 0 if a valid VLAN tag is stripped.
Signed-off-by: Yong Wang <yongwang@vmware.com>
---
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
Comments
On Sun, 12 Oct 2014 23:23:05 -0700 Yong Wang <yongwang@vmware.com> wrote: > Shouldn't reset vlan_tci to 0 if a valid VLAN tag is stripped. > > Signed-off-by: Yong Wang <yongwang@vmware.com> Since vlan_tci is initialized to zero by rte_pktmbuf layer, the driver shouldn't be messing with it.
Are you referring to the patch as a whole or your comment is about the reset of vlan_tci on the "else" (no vlan tags stripped) path? I am not sure I get your comments here. This patch simply fixes a bug on the rx vlan stripping path (where valid vlan_tci stripped is overwritten unconditionally later on the rx path in the original vmxnet3 pmd driver). All the other pmd drivers are doing the same thing in terms of translating descriptor status to rte_mbuf flags for vlan stripping.
On Mon, 13 Oct 2014 18:42:18 +0000
Yong Wang <yongwang@vmware.com> wrote:
> Are you referring to the patch as a whole or your comment is about the reset of vlan_tci on the "else" (no vlan tags stripped) path? I am not sure I get your comments here. This patch simply fixes a bug on the rx vlan stripping path (where valid vlan_tci stripped is overwritten unconditionally later on the rx path in the original vmxnet3 pmd driver). All the other pmd drivers are doing the same thing in terms of translating descriptor status to rte_mbuf flags for vlan stripping.
I was thinking that there are many fields in a pktmbuf and rather than individually
setting them (like tci). The code should call the common rte_pktmbuf_reset before setting
the fields. That way when someone adds a field to mbuf they don't have to chasing
through every driver that does it's own initialization.
On 10/22/14, 6:39 AM, "Stephen Hemminger" <stephen@networkplumber.org> wrote: >On Mon, 13 Oct 2014 18:42:18 +0000 >Yong Wang <yongwang@vmware.com> wrote: > >> Are you referring to the patch as a whole or your comment is about the >>reset of vlan_tci on the "else" (no vlan tags stripped) path? I am not >>sure I get your comments here. This patch simply fixes a bug on the rx >>vlan stripping path (where valid vlan_tci stripped is overwritten >>unconditionally later on the rx path in the original vmxnet3 pmd >>driver). All the other pmd drivers are doing the same thing in terms of >>translating descriptor status to rte_mbuf flags for vlan stripping. > >I was thinking that there are many fields in a pktmbuf and rather than >individually >setting them (like tci). The code should call the common >rte_pktmbuf_reset before setting >the fields. That way when someone adds a field to mbuf they don't have >to chasing >through every driver that does it's own initialization. Currently rte_pktmbuf_reset() is used in rte_pktmbuf_alloc() but looks like most pmd drivers use rte_rxmbuf_alloc() to replenish rx buffers, which directly calls __rte_mbuf_raw_alloc () without calling rte_pktmbuf_reset(). How about we change that in a separate patch to all pmd drivers so that we can keep their behavior consistent?
On Tue, Oct 28, 2014 at 09:57:14PM +0000, Yong Wang wrote: > On 10/22/14, 6:39 AM, "Stephen Hemminger" <stephen@networkplumber.org> > wrote: > > > >On Mon, 13 Oct 2014 18:42:18 +0000 > >Yong Wang <yongwang@vmware.com> wrote: > > > >> Are you referring to the patch as a whole or your comment is about the > >>reset of vlan_tci on the "else" (no vlan tags stripped) path? I am not > >>sure I get your comments here. This patch simply fixes a bug on the rx > >>vlan stripping path (where valid vlan_tci stripped is overwritten > >>unconditionally later on the rx path in the original vmxnet3 pmd > >>driver). All the other pmd drivers are doing the same thing in terms of > >>translating descriptor status to rte_mbuf flags for vlan stripping. > > > >I was thinking that there are many fields in a pktmbuf and rather than > >individually > >setting them (like tci). The code should call the common > >rte_pktmbuf_reset before setting > >the fields. That way when someone adds a field to mbuf they don't have > >to chasing > >through every driver that does it's own initialization. > > Currently rte_pktmbuf_reset() is used in rte_pktmbuf_alloc() but looks > like most pmd drivers use rte_rxmbuf_alloc() to replenish rx buffers, > which directly calls __rte_mbuf_raw_alloc > () without calling rte_pktmbuf_reset(). How about we change that in a > separate patch to all pmd drivers so that we can keep their behavior > consistent? > We can look to do that, but we need to beware of performance regressions if we do so. Certainly the vector implementation of the ixgbe would be severely impacted performance-wise if such a change were made. However, code paths which are not as highly tuned, or which do not need to be as highly tuned could perhaps use the standard function. The main reason for this regression is that reset will clear all fields of the mbuf, which would be wasted cycles for a number of the PMDs as they will later set some of the fields based on values in the receive descriptor. Basically, on descriptor rearm in a PMD, the only fields that need to be reset would be those not set by the copy of data from the descriptor. /Bruce
2014-10-29 09:04, Bruce Richardson: > On Tue, Oct 28, 2014 at 09:57:14PM +0000, Yong Wang wrote: > > On 10/22/14, 6:39 AM, "Stephen Hemminger" <stephen@networkplumber.org> > > wrote: > > > > > > >On Mon, 13 Oct 2014 18:42:18 +0000 > > >Yong Wang <yongwang@vmware.com> wrote: > > > > > >> Are you referring to the patch as a whole or your comment is about the > > >>reset of vlan_tci on the "else" (no vlan tags stripped) path? I am not > > >>sure I get your comments here. This patch simply fixes a bug on the rx > > >>vlan stripping path (where valid vlan_tci stripped is overwritten > > >>unconditionally later on the rx path in the original vmxnet3 pmd > > >>driver). All the other pmd drivers are doing the same thing in terms of > > >>translating descriptor status to rte_mbuf flags for vlan stripping. > > > > > >I was thinking that there are many fields in a pktmbuf and rather than > > >individually > > >setting them (like tci). The code should call the common > > >rte_pktmbuf_reset before setting > > >the fields. That way when someone adds a field to mbuf they don't have > > >to chasing > > >through every driver that does it's own initialization. > > > > Currently rte_pktmbuf_reset() is used in rte_pktmbuf_alloc() but looks > > like most pmd drivers use rte_rxmbuf_alloc() to replenish rx buffers, > > which directly calls __rte_mbuf_raw_alloc > > () without calling rte_pktmbuf_reset(). How about we change that in a > > separate patch to all pmd drivers so that we can keep their behavior > > consistent? > > > > We can look to do that, but we need to beware of performance regressions if > we do so. Certainly the vector implementation of the ixgbe would be severely > impacted performance-wise if such a change were made. However, code paths > which are not as highly tuned, or which do not need to be as highly tuned > could perhaps use the standard function. > > The main reason for this regression is that reset will clear all fields of > the mbuf, which would be wasted cycles for a number of the PMDs as they will > later set some of the fields based on values in the receive descriptor. > Basically, on descriptor rearm in a PMD, the only fields that need to be > reset would be those not set by the copy of data from the descriptor. This is typically a trade-off situation. I think that we should prefer the performance.
Sounds good to me but it does look like the rte_rxmbuf_alloc() could use some comments to make it explicit that rte_pktmbuf_reset() is avoided by design for the reasons that Bruce described. Furthermore, rte_rxmbuf_alloc() is duplicated in almost all the pmd drivers. Will it make sense to promote it to a public API? Just a thought. Yong On 10/29/14, 2:41 AM, "Thomas Monjalon" <thomas.monjalon@6wind.com> wrote: >2014-10-29 09:04, Bruce Richardson: >> On Tue, Oct 28, 2014 at 09:57:14PM +0000, Yong Wang wrote: >> > On 10/22/14, 6:39 AM, "Stephen Hemminger" <stephen@networkplumber.org> >> > wrote: >> > >> > >> > >On Mon, 13 Oct 2014 18:42:18 +0000 >> > >Yong Wang <yongwang@vmware.com> wrote: >> > > >> > >> Are you referring to the patch as a whole or your comment is about >>the >> > >>reset of vlan_tci on the "else" (no vlan tags stripped) path? I am >>not >> > >>sure I get your comments here. This patch simply fixes a bug on >>the rx >> > >>vlan stripping path (where valid vlan_tci stripped is overwritten >> > >>unconditionally later on the rx path in the original vmxnet3 pmd >> > >>driver). All the other pmd drivers are doing the same thing in >>terms of >> > >>translating descriptor status to rte_mbuf flags for vlan stripping. >> > > >> > >I was thinking that there are many fields in a pktmbuf and rather >>than >> > >individually >> > >setting them (like tci). The code should call the common >> > >rte_pktmbuf_reset before setting >> > >the fields. That way when someone adds a field to mbuf they don't >>have >> > >to chasing >> > >through every driver that does it's own initialization. >> > >> > Currently rte_pktmbuf_reset() is used in rte_pktmbuf_alloc() but looks >> > like most pmd drivers use rte_rxmbuf_alloc() to replenish rx buffers, >> > which directly calls __rte_mbuf_raw_alloc >> > () without calling rte_pktmbuf_reset(). How about we change that in a >> > separate patch to all pmd drivers so that we can keep their behavior >> > consistent? >> > >> >> We can look to do that, but we need to beware of performance >>regressions if >> we do so. Certainly the vector implementation of the ixgbe would be >>severely >> impacted performance-wise if such a change were made. However, code >>paths >> which are not as highly tuned, or which do not need to be as highly >>tuned >> could perhaps use the standard function. >> >> The main reason for this regression is that reset will clear all fields >>of >> the mbuf, which would be wasted cycles for a number of the PMDs as they >>will >> later set some of the fields based on values in the receive descriptor. >> >> Basically, on descriptor rearm in a PMD, the only fields that need to >>be >> reset would be those not set by the copy of data from the descriptor. > >This is typically a trade-off situation. >I think that we should prefer the performance. > >-- >Thomas
2014-10-29 17:57, Yong Wang: > Sounds good to me but it does look like the rte_rxmbuf_alloc() could use > some comments to make it explicit that rte_pktmbuf_reset() is avoided by > design for the reasons that Bruce described. Furthermore, > rte_rxmbuf_alloc() is duplicated in almost all the pmd drivers. Will it > make sense to promote it to a public API? Just a thought. Yes, it makes sense. > On 10/29/14, 2:41 AM, "Thomas Monjalon" <thomas.monjalon@6wind.com> wrote: > > >2014-10-29 09:04, Bruce Richardson: > >> On Tue, Oct 28, 2014 at 09:57:14PM +0000, Yong Wang wrote: > >> > On 10/22/14, 6:39 AM, "Stephen Hemminger" <stephen@networkplumber.org> > >> > wrote: > >> > > >> > > >> > >On Mon, 13 Oct 2014 18:42:18 +0000 > >> > >Yong Wang <yongwang@vmware.com> wrote: > >> > > > >> > >> Are you referring to the patch as a whole or your comment is about > >>the > >> > >>reset of vlan_tci on the "else" (no vlan tags stripped) path? I am > >>not > >> > >>sure I get your comments here. This patch simply fixes a bug on > >>the rx > >> > >>vlan stripping path (where valid vlan_tci stripped is overwritten > >> > >>unconditionally later on the rx path in the original vmxnet3 pmd > >> > >>driver). All the other pmd drivers are doing the same thing in > >>terms of > >> > >>translating descriptor status to rte_mbuf flags for vlan stripping. > >> > > > >> > >I was thinking that there are many fields in a pktmbuf and rather > >>than > >> > >individually > >> > >setting them (like tci). The code should call the common > >> > >rte_pktmbuf_reset before setting > >> > >the fields. That way when someone adds a field to mbuf they don't > >>have > >> > >to chasing > >> > >through every driver that does it's own initialization. > >> > > >> > Currently rte_pktmbuf_reset() is used in rte_pktmbuf_alloc() but looks > >> > like most pmd drivers use rte_rxmbuf_alloc() to replenish rx buffers, > >> > which directly calls __rte_mbuf_raw_alloc > >> > () without calling rte_pktmbuf_reset(). How about we change that in a > >> > separate patch to all pmd drivers so that we can keep their behavior > >> > consistent? > >> > > >> > >> We can look to do that, but we need to beware of performance > >>regressions if > >> we do so. Certainly the vector implementation of the ixgbe would be > >>severely > >> impacted performance-wise if such a change were made. However, code > >>paths > >> which are not as highly tuned, or which do not need to be as highly > >>tuned > >> could perhaps use the standard function. > >> > >> The main reason for this regression is that reset will clear all fields > >>of > >> the mbuf, which would be wasted cycles for a number of the PMDs as they > >>will > >> later set some of the fields based on values in the receive descriptor. > >> > >> Basically, on descriptor rearm in a PMD, the only fields that need to > >>be > >> reset would be those not set by the copy of data from the descriptor. > > > >This is typically a trade-off situation. > >I think that we should prefer the performance.
diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c index 263f9ce..986e5e5 100644 --- a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +++ b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c @@ -540,21 +540,19 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) /* Check for hardware stripped VLAN tag */ if (rcd->ts) { - PMD_RX_LOG(ERR, "Received packet with vlan ID: %d.", rcd->tci); rxm->ol_flags = PKT_RX_VLAN_PKT; - #ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER VMXNET3_ASSERT(rxm && rte_pktmbuf_mtod(rxm, void *)); #endif /* Copy vlan tag in packet buffer */ - rxm->vlan_tci = rte_le_to_cpu_16( - (uint16_t)rcd->tci); - - } else + rxm->vlan_tci = rte_le_to_cpu_16((uint16_t)rcd->tci); + } else { rxm->ol_flags = 0; + rxm->vlan_tci = 0; + } /* Initialize newly received packet buffer */ rxm->port = rxq->port_id; @@ -563,11 +561,9 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxm->pkt_len = (uint16_t)rcd->len; rxm->data_len = (uint16_t)rcd->len; rxm->port = rxq->port_id; - rxm->vlan_tci = 0; rxm->data_off = RTE_PKTMBUF_HEADROOM; 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);