mbuf: fix to update documentation of QinQ stripped bit interpretation
diff mbox series

Message ID 20200106083423.26600-1-somnath.kotur@broadcom.com
State New
Delegated to: Thomas Monjalon
Headers show
Series
  • mbuf: fix to update documentation of QinQ stripped bit interpretation
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance fail Performance Testing issues
ci/travis-robot success Travis build: passed
ci/checkpatch success coding style OK

Commit Message

Somnath Kotur Jan. 6, 2020, 8:34 a.m. UTC
Certain hardware may be able to strip and/or save only the outermost
VLAN instead of both the VLANs in the mbuf in a QinQ scenario.
To handle such cases, we could re-interpret setting of just
PKT_RX_QINQ_STRIPPED to indicate that only the outermost VLAN has
been stripped and saved in mbuf->vlan_tci_outer.
Only When both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2
VLANs have been stripped by the hardware and their TCI are saved in
mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).

Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 lib/librte_mbuf/rte_mbuf_core.h | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Somnath Kotur Feb. 6, 2020, 4:27 p.m. UTC | #1
On Mon, Jan 6, 2020 at 2:05 PM Somnath Kotur <somnath.kotur@broadcom.com> wrote:
>
> Certain hardware may be able to strip and/or save only the outermost
> VLAN instead of both the VLANs in the mbuf in a QinQ scenario.
> To handle such cases, we could re-interpret setting of just
> PKT_RX_QINQ_STRIPPED to indicate that only the outermost VLAN has
> been stripped and saved in mbuf->vlan_tci_outer.
> Only When both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2
> VLANs have been stripped by the hardware and their TCI are saved in
> mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
>
> Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> ---
>  lib/librte_mbuf/rte_mbuf_core.h | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h
> index 9a8557d..db1070b 100644
> --- a/lib/librte_mbuf/rte_mbuf_core.h
> +++ b/lib/librte_mbuf/rte_mbuf_core.h
> @@ -124,12 +124,19 @@
>  #define PKT_RX_FDIR_FLX      (1ULL << 14)
>
>  /**
> - * The 2 vlans have been stripped by the hardware and their tci are
> - * saved in mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
> + * The outer vlan has been stripped by the hardware and their tci are
> + * saved in mbuf->vlan_tci_outer (outer).
>   * This can only happen if vlan stripping is enabled in the RX
>   * configuration of the PMD.
> - * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |
> - * PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ) must also be set.
> + * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |  PKT_RX_QINQ)
> + * must also be set.
> + * When both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2 vlans
> + * have been stripped by the hardware and their tci are saved in
> + * mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
> + * This can only happen if vlan stripping is enabled in the RX configuration
> + * of the PMD.
> + * When PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set,
> + * (PKT_RX_VLAN | PKT_RX_QINQ) must also be set.
>   */
>  #define PKT_RX_QINQ_STRIPPED (1ULL << 15)
>
> --
> 1.8.3.1

Seeing as its been a month since it was submitted and no comments on
it yet , are we ok to go ahead and merge this in please?

Thanks
Som
Olivier Matz Feb. 6, 2020, 5:25 p.m. UTC | #2
Hi Somnath,

Sorry for the delay, please find some comments below.

I suggest the following title instead:

  mbuf: extend meaning of QinQ stripped bit

On Mon, Jan 06, 2020 at 02:04:23PM +0530, Somnath Kotur wrote:
> Certain hardware may be able to strip and/or save only the outermost
> VLAN instead of both the VLANs in the mbuf in a QinQ scenario.
> To handle such cases, we could re-interpret setting of just
> PKT_RX_QINQ_STRIPPED to indicate that only the outermost VLAN has
> been stripped and saved in mbuf->vlan_tci_outer.

To be sure we're on the same page: we are talking about case 7 of this
link: http://inbox.dpdk.org/dev/20191227145041.GQ22738@platinum/

So, even if the inner vlan_tci is not stripped from packet data, it has
to be saved in m->vlan_tci, because it is implied by PKT_RX_VLAN.

From the same link, the case where the driver only strips+saves the
outer vlan without saving or stripping the inner one is case 3.

> Only When both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2
> VLANs have been stripped by the hardware and their TCI are saved in
> mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
> 
> Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> ---
>  lib/librte_mbuf/rte_mbuf_core.h | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h
> index 9a8557d..db1070b 100644
> --- a/lib/librte_mbuf/rte_mbuf_core.h
> +++ b/lib/librte_mbuf/rte_mbuf_core.h
> @@ -124,12 +124,19 @@
>  #define PKT_RX_FDIR_FLX      (1ULL << 14)
>  
>  /**
> - * The 2 vlans have been stripped by the hardware and their tci are
> - * saved in mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
> + * The outer vlan has been stripped by the hardware and their tci are
> + * saved in mbuf->vlan_tci_outer (outer).

their tci are -> its tci is

>   * This can only happen if vlan stripping is enabled in the RX
>   * configuration of the PMD.
> - * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |
> - * PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ) must also be set.
> + * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |  PKT_RX_QINQ)
> + * must also be set.

ok

> + * When both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2 vlans
> + * have been stripped by the hardware and their tci are saved in
> + * mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).

This is correct, but I'd use a bullet list to add another sentence:

 * - If both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2 vlans
 *   have been stripped by the hardware and their tci are saved in
 *   mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
 * - If PKT_RX_QINQ_STRIPPED is set and PKT_RX_VLAN_STRIPPED is unset, only the
 *   outer vlan is removed from packet data, but both tci are saved in
 *   mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).

> + * This can only happen if vlan stripping is enabled in the RX configuration
> + * of the PMD.

The same exact sentence is above, this one can be removed.

> + * When PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set,
> + * (PKT_RX_VLAN | PKT_RX_QINQ) must also be set.

This can be removed too as it is redundant with above sentence:

 * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |  PKT_RX_QINQ)
 * must also be set.


Thanks,
Olivier
Somnath Kotur Feb. 7, 2020, 1:43 p.m. UTC | #3
Olivier,

On Thu, Feb 6, 2020 at 10:55 PM Olivier Matz <olivier.matz@6wind.com> wrote:
>
> Hi Somnath,
>
> Sorry for the delay, please find some comments below.
>
> I suggest the following title instead:
>
>   mbuf: extend meaning of QinQ stripped bit
>
> On Mon, Jan 06, 2020 at 02:04:23PM +0530, Somnath Kotur wrote:
> > Certain hardware may be able to strip and/or save only the outermost
> > VLAN instead of both the VLANs in the mbuf in a QinQ scenario.
> > To handle such cases, we could re-interpret setting of just
> > PKT_RX_QINQ_STRIPPED to indicate that only the outermost VLAN has
> > been stripped and saved in mbuf->vlan_tci_outer.
>
> To be sure we're on the same page: we are talking about case 7 of this
> link: http://inbox.dpdk.org/dev/20191227145041.GQ22738@platinum/

I'm not sure we are on the same page then, please see my response inline below
>
> So, even if the inner vlan_tci is not stripped from packet data, it has
> to be saved in m->vlan_tci, because it is implied by PKT_RX_VLAN.
>
> From the same link, the case where the driver only strips+saves the
> outer vlan without saving or stripping the inner one is case 3.
>
While this is how it works currently, I'm wondering how will the
application know if this was
a double VLAN pkt, correct?
Also when i look at options 5 and 7 I don't really see the difference
in semantics between them ?
Both seem to store the outer-vlan and inner-vlan in m->vlan_tci_outer
and m->vlan_tci_inner respectively

7/ PKT_RX_VLAN | PKT_RX_QINQ | PKT_RX_QINQ_STRIPPED
   outer-vlan is removed from packet data
   m->vlan_tci_outer=outer-vlan
   m->vlan_tci=inner-vlan

I was hoping that with the new interpretation of PKT_RX_QINQ_STRIPPED,
it only meant that outer-vlan is removed from packet data
and m->vlan_tci_outer = outer_vlan, while PKT_RX_QINQ implies it is a
double-vlan pkt and PKT_RX_VLAN implies that pkt has VLAN
associated with it?   Not m->vlan_tci = inner-vlan

Thanks
Som


> > Only When both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2
> > VLANs have been stripped by the hardware and their TCI are saved in
> > mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
> >
> > Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> > ---
> >  lib/librte_mbuf/rte_mbuf_core.h | 15 +++++++++++----
> >  1 file changed, 11 insertions(+), 4 deletions(-)
> >
> > diff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h
> > index 9a8557d..db1070b 100644
> > --- a/lib/librte_mbuf/rte_mbuf_core.h
> > +++ b/lib/librte_mbuf/rte_mbuf_core.h
> > @@ -124,12 +124,19 @@
> >  #define PKT_RX_FDIR_FLX      (1ULL << 14)
> >
> >  /**
> > - * The 2 vlans have been stripped by the hardware and their tci are
> > - * saved in mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
> > + * The outer vlan has been stripped by the hardware and their tci are
> > + * saved in mbuf->vlan_tci_outer (outer).
>
> their tci are -> its tci is
>
> >   * This can only happen if vlan stripping is enabled in the RX
> >   * configuration of the PMD.
> > - * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |
> > - * PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ) must also be set.
> > + * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |  PKT_RX_QINQ)
> > + * must also be set.
>
> ok
>
> > + * When both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2 vlans
> > + * have been stripped by the hardware and their tci are saved in
> > + * mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
>
> This is correct, but I'd use a bullet list to add another sentence:
>
>  * - If both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2 vlans
>  *   have been stripped by the hardware and their tci are saved in
>  *   mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
>  * - If PKT_RX_QINQ_STRIPPED is set and PKT_RX_VLAN_STRIPPED is unset, only the
>  *   outer vlan is removed from packet data, but both tci are saved in
>  *   mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
>
> > + * This can only happen if vlan stripping is enabled in the RX configuration
> > + * of the PMD.
>
> The same exact sentence is above, this one can be removed.
>
> > + * When PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set,
> > + * (PKT_RX_VLAN | PKT_RX_QINQ) must also be set.
>
> This can be removed too as it is redundant with above sentence:
>
>  * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |  PKT_RX_QINQ)
>  * must also be set.
>
>
> Thanks,
> Olivier
Olivier Matz Feb. 7, 2020, 2:29 p.m. UTC | #4
Hi Somnath,

On Fri, Feb 07, 2020 at 07:13:04PM +0530, Somnath Kotur wrote:
> Olivier,
> 
> On Thu, Feb 6, 2020 at 10:55 PM Olivier Matz <olivier.matz@6wind.com> wrote:
> >
> > Hi Somnath,
> >
> > Sorry for the delay, please find some comments below.
> >
> > I suggest the following title instead:
> >
> >   mbuf: extend meaning of QinQ stripped bit
> >
> > On Mon, Jan 06, 2020 at 02:04:23PM +0530, Somnath Kotur wrote:
> > > Certain hardware may be able to strip and/or save only the outermost
> > > VLAN instead of both the VLANs in the mbuf in a QinQ scenario.
> > > To handle such cases, we could re-interpret setting of just
> > > PKT_RX_QINQ_STRIPPED to indicate that only the outermost VLAN has
> > > been stripped and saved in mbuf->vlan_tci_outer.
> >
> > To be sure we're on the same page: we are talking about case 7 of this
> > link: http://inbox.dpdk.org/dev/20191227145041.GQ22738@platinum/
> 
> I'm not sure we are on the same page then, please see my response inline below
> >
> > So, even if the inner vlan_tci is not stripped from packet data, it has
> > to be saved in m->vlan_tci, because it is implied by PKT_RX_VLAN.
> >
> > From the same link, the case where the driver only strips+saves the
> > outer vlan without saving or stripping the inner one is case 3.
> >
> While this is how it works currently, I'm wondering how will the
> application know if this was
> a double VLAN pkt, correct?

If the hardware supports it and configured for it, the flag PKT_RX_QINQ
is set when there are 2 vlans.

FYI, the m->packet_type field can also be useful. It describes what is
really present in the packet data, as described in rte_mbuf_core.h:

	/*
	 * The packet type, which is the combination of outer/inner L2, L3, L4
	 * and tunnel types. The packet_type is about data really present in the
	 * mbuf. Example: if vlan stripping is enabled, a received vlan packet
	 * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
	 * vlan is stripped from the data.
	 */

> Also when i look at options 5 and 7 I don't really see the difference
> in semantics between them ?
> Both seem to store the outer-vlan and inner-vlan in m->vlan_tci_outer
> and m->vlan_tci_inner respectively
> 
> 7/ PKT_RX_VLAN | PKT_RX_QINQ | PKT_RX_QINQ_STRIPPED
>    outer-vlan is removed from packet data
>    m->vlan_tci_outer=outer-vlan
>    m->vlan_tci=inner-vlan

The difference is about what was stripped or not from mbuf data.

> I was hoping that with the new interpretation of PKT_RX_QINQ_STRIPPED,
> it only meant that outer-vlan is removed from packet data
> and m->vlan_tci_outer = outer_vlan, while PKT_RX_QINQ implies it is a
> double-vlan pkt and PKT_RX_VLAN implies that pkt has VLAN
> associated with it?   Not m->vlan_tci = inner-vlan

The meaning of each flag should be as simple as possible, I think we can
summarize them like this:

- PKT_RX_VLAN: the vlan is saved in vlan tci.
- PKT_RX_VLAN_STRIPPED: the vlan hdr is removed from packet data.
- PKT_RX_QINQ: the outer vlan is saved in vlan tci.
- PKT_RX_QINQ_STRIPPED: the inner vlan is stripped from packet data.
- When PKT_RX_QINQ is set, PKT_RX_VLAN* refer to the inner vlan
  of initial packet, else it refers to the first vlan of the packet.

There is a link between vlan flag and vlan_tci field, and qinq flag and
vlan_tci_outer field.

I'm still not sure to understand what you expect. Can you give an
example with flags (which are set), and the expected content of m->vlan_tci
and m->vlan_tci_outer?

By the way, the case 5/ is not very well described too, maybe we should
add something about it.

Thanks,
Olivier


> 
> Thanks
> Som
> 
> 
> > > Only When both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2
> > > VLANs have been stripped by the hardware and their TCI are saved in
> > > mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
> > >
> > > Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
> > > ---
> > >  lib/librte_mbuf/rte_mbuf_core.h | 15 +++++++++++----
> > >  1 file changed, 11 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h
> > > index 9a8557d..db1070b 100644
> > > --- a/lib/librte_mbuf/rte_mbuf_core.h
> > > +++ b/lib/librte_mbuf/rte_mbuf_core.h
> > > @@ -124,12 +124,19 @@
> > >  #define PKT_RX_FDIR_FLX      (1ULL << 14)
> > >
> > >  /**
> > > - * The 2 vlans have been stripped by the hardware and their tci are
> > > - * saved in mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
> > > + * The outer vlan has been stripped by the hardware and their tci are
> > > + * saved in mbuf->vlan_tci_outer (outer).
> >
> > their tci are -> its tci is
> >
> > >   * This can only happen if vlan stripping is enabled in the RX
> > >   * configuration of the PMD.
> > > - * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |
> > > - * PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ) must also be set.
> > > + * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |  PKT_RX_QINQ)
> > > + * must also be set.
> >
> > ok
> >
> > > + * When both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2 vlans
> > > + * have been stripped by the hardware and their tci are saved in
> > > + * mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
> >
> > This is correct, but I'd use a bullet list to add another sentence:
> >
> >  * - If both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2 vlans
> >  *   have been stripped by the hardware and their tci are saved in
> >  *   mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
> >  * - If PKT_RX_QINQ_STRIPPED is set and PKT_RX_VLAN_STRIPPED is unset, only the
> >  *   outer vlan is removed from packet data, but both tci are saved in
> >  *   mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
> >
> > > + * This can only happen if vlan stripping is enabled in the RX configuration
> > > + * of the PMD.
> >
> > The same exact sentence is above, this one can be removed.
> >
> > > + * When PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set,
> > > + * (PKT_RX_VLAN | PKT_RX_QINQ) must also be set.
> >
> > This can be removed too as it is redundant with above sentence:
> >
> >  * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |  PKT_RX_QINQ)
> >  * must also be set.
> >
> >
> > Thanks,
> > Olivier

Patch
diff mbox series

diff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h
index 9a8557d..db1070b 100644
--- a/lib/librte_mbuf/rte_mbuf_core.h
+++ b/lib/librte_mbuf/rte_mbuf_core.h
@@ -124,12 +124,19 @@ 
 #define PKT_RX_FDIR_FLX      (1ULL << 14)
 
 /**
- * The 2 vlans have been stripped by the hardware and their tci are
- * saved in mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
+ * The outer vlan has been stripped by the hardware and their tci are
+ * saved in mbuf->vlan_tci_outer (outer).
  * This can only happen if vlan stripping is enabled in the RX
  * configuration of the PMD.
- * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |
- * PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ) must also be set.
+ * When PKT_RX_QINQ_STRIPPED is set, the flags (PKT_RX_VLAN |  PKT_RX_QINQ)
+ * must also be set.
+ * When both PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set, the 2 vlans
+ * have been stripped by the hardware and their tci are saved in
+ * mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
+ * This can only happen if vlan stripping is enabled in the RX configuration
+ * of the PMD.
+ * When PKT_RX_QINQ_STRIPPED and PKT_RX_VLAN_STRIPPED are set,
+ * (PKT_RX_VLAN | PKT_RX_QINQ) must also be set.
  */
 #define PKT_RX_QINQ_STRIPPED (1ULL << 15)