Skip to content

Commit

Permalink
ethdev: support L2TPv2 and PPP procotol
Browse files Browse the repository at this point in the history
Added flow pattern items and header formats of L2TPv2 and PPP.

Signed-off-by: Wenjun Wu <wenjun1.wu@intel.com>
Signed-off-by: Jie Wang <jie1x.wang@intel.com>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
jiewang-code authored and Ferruh Yigit committed Oct 21, 2021
1 parent 77140af commit 3a929df
Show file tree
Hide file tree
Showing 9 changed files with 373 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/api/doxy-api-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ The public API headers are grouped by topics:
[MPLS] (@ref rte_mpls.h),
[VXLAN] (@ref rte_vxlan.h),
[Geneve] (@ref rte_geneve.h),
[eCPRI] (@ref rte_ecpri.h)
[eCPRI] (@ref rte_ecpri.h),
[L2TPv2] (@ref rte_l2tpv2.h),
[PPP] (@ref rte_ppp.h)

- **QoS**:
[metering] (@ref rte_meter.h),
Expand Down
2 changes: 2 additions & 0 deletions doc/guides/nics/features/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ ipv4 =
ipv6 =
ipv6_ext =
ipv6_frag_ext =
l2tpv2 =
l2tpv3oip =
mark =
meta =
Expand All @@ -121,6 +122,7 @@ pfcp =
phy_port =
port_id =
port_representor =
ppp =
pppoed =
pppoes =
pppoe_proto_id =
Expand Down
25 changes: 25 additions & 0 deletions doc/guides/prog_guide/rte_flow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,31 @@ rte_flow_flex_item_create() routine.
as padded with trailing zeroes up to full configured length, both for
value and mask.

Item: ``L2TPV2``
^^^^^^^^^^^^^^^^^^^

Matches a L2TPv2 header.

- ``flags_version``: flags(12b), version(4b).
- ``length``: total length of the message.
- ``tunnel_id``: identifier for the control connection.
- ``session_id``: identifier for a session within a tunnel.
- ``ns``: sequence number for this date or control message.
- ``nr``: sequence number expected in the next control message to be received.
- ``offset_size``: offset of payload data.
- ``offset_padding``: offset padding, variable length.
- Default ``mask`` matches flags_version only.

Item: ``PPP``
^^^^^^^^^^^^^^^^^^^

Matches a PPP header.

- ``addr``: PPP address.
- ``ctrl``: PPP control.
- ``proto_id``: PPP protocol identifier.
- Default ``mask`` matches addr, ctrl, proto_id.

Actions
~~~~~~~

Expand Down
4 changes: 4 additions & 0 deletions doc/guides/rel_notes/release_21_11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ New Features
Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and
TCP/UDP/SCTP header checksum field can be used as input set for RSS.

* **Added L2TPv2 and PPP protocol support in flow API.**

Added flow pattern items and header formats of L2TPv2 and PPP protocol.

* **Added flow flex item.**

The configurable flow flex item provides the capability to introduce
Expand Down
2 changes: 2 additions & 0 deletions lib/ethdev/rte_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
MK_FLOW_ITEM(REPRESENTED_PORT, sizeof(struct rte_flow_item_ethdev)),
MK_FLOW_ITEM_FN(FLEX, sizeof(struct rte_flow_item_flex),
rte_flow_item_flex_conv),
MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
};

/** Generate flow_action[] entry. */
Expand Down
67 changes: 67 additions & 0 deletions lib/ethdev/rte_flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <rte_mbuf_dyn.h>
#include <rte_meter.h>
#include <rte_gtp.h>
#include <rte_l2tpv2.h>
#include <rte_ppp.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -644,6 +646,20 @@ enum rte_flow_item_type {
* @see struct rte_flow_item_flex.
*/
RTE_FLOW_ITEM_TYPE_FLEX,

/**
* Matches L2TPv2 Header.
*
* See struct rte_flow_item_l2tpv2.
*/
RTE_FLOW_ITEM_TYPE_L2TPV2,

/**
* Matches PPP Header.
*
* See struct rte_flow_item_ppp.
*/
RTE_FLOW_ITEM_TYPE_PPP,
};

/**
Expand Down Expand Up @@ -1900,6 +1916,57 @@ static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
};
#endif

/**
* @warning
* @b EXPERIMENTAL: this structure may change without prior notice
*
* RTE_FLOW_ITEM_TYPE_L2TPV2
*
* Matches L2TPv2 Header
*/
struct rte_flow_item_l2tpv2 {
struct rte_l2tpv2_combined_msg_hdr hdr;
};

/** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV2. */
#ifndef __cplusplus
static const struct rte_flow_item_l2tpv2 rte_flow_item_l2tpv2_mask = {
/*
* flags and version bit mask
* 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
* T L x x S x O P x x x x V V V V
*/
.hdr = {
.common = {
.flags_version = RTE_BE16(0xcb0f),
},
},
};
#endif

/**
* @warning
* @b EXPERIMENTAL: this structure may change without prior notice
*
* RTE_FLOW_ITEM_TYPE_PPP
*
* Matches PPP Header
*/
struct rte_flow_item_ppp {
struct rte_ppp_hdr hdr;
};

/** Default mask for RTE_FLOW_ITEM_TYPE_PPP. */
#ifndef __cplusplus
static const struct rte_flow_item_ppp rte_flow_item_ppp_mask = {
.hdr = {
.addr = 0xff,
.ctrl = 0xff,
.proto_id = RTE_BE16(0xffff),
}
};
#endif

/**
* Matching pattern item definition.
*
Expand Down
2 changes: 2 additions & 0 deletions lib/net/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ headers = files(
'rte_higig.h',
'rte_ecpri.h',
'rte_geneve.h',
'rte_l2tpv2.h',
'rte_ppp.h',
)

sources = files(
Expand Down
Loading

0 comments on commit 3a929df

Please sign in to comment.