ethdev: add VLAN and MPLS actions to flow API

Add support for the following OpenFlow-defined actions:

- RTE_FLOW_ACTION_OF_POP_VLAN: pop the outer VLAN tag.

- RTE_FLOW_ACTION_OF_PUSH_VLAN: push a new VLAN tag.

- RTE_FLOW_ACTION_OF_SET_VLAN_VID: set the 802.1q VLAN id.

- RTE_FLOW_ACTION_OF_SET_VLAN_PCP: set the 802.1q priority.

- RTE_FLOW_ACTION_OF_POP_MPLS: pop the outer MPLS tag.

- RTE_FLOW_ACTION_OF_PUSH_MPLS: push a new MPLS tag.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
This commit is contained in:
Qi Zhang 2018-04-24 17:59:02 +02:00 committed by Ferruh Yigit
parent 1c54c93809
commit 7e3389b172
6 changed files with 381 additions and 0 deletions

View File

@ -222,6 +222,17 @@ enum index {
ACTION_OF_DEC_NW_TTL,
ACTION_OF_COPY_TTL_OUT,
ACTION_OF_COPY_TTL_IN,
ACTION_OF_POP_VLAN,
ACTION_OF_PUSH_VLAN,
ACTION_OF_PUSH_VLAN_ETHERTYPE,
ACTION_OF_SET_VLAN_VID,
ACTION_OF_SET_VLAN_VID_VLAN_VID,
ACTION_OF_SET_VLAN_PCP,
ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
ACTION_OF_POP_MPLS,
ACTION_OF_POP_MPLS_ETHERTYPE,
ACTION_OF_PUSH_MPLS,
ACTION_OF_PUSH_MPLS_ETHERTYPE,
};
/** Maximum size for pattern in struct rte_flow_item_raw. */
@ -744,6 +755,12 @@ static const enum index next_action[] = {
ACTION_OF_DEC_NW_TTL,
ACTION_OF_COPY_TTL_OUT,
ACTION_OF_COPY_TTL_IN,
ACTION_OF_POP_VLAN,
ACTION_OF_PUSH_VLAN,
ACTION_OF_SET_VLAN_VID,
ACTION_OF_SET_VLAN_PCP,
ACTION_OF_POP_MPLS,
ACTION_OF_PUSH_MPLS,
ZERO,
};
@ -809,6 +826,36 @@ static const enum index action_of_set_nw_ttl[] = {
ZERO,
};
static const enum index action_of_push_vlan[] = {
ACTION_OF_PUSH_VLAN_ETHERTYPE,
ACTION_NEXT,
ZERO,
};
static const enum index action_of_set_vlan_vid[] = {
ACTION_OF_SET_VLAN_VID_VLAN_VID,
ACTION_NEXT,
ZERO,
};
static const enum index action_of_set_vlan_pcp[] = {
ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
ACTION_NEXT,
ZERO,
};
static const enum index action_of_pop_mpls[] = {
ACTION_OF_POP_MPLS_ETHERTYPE,
ACTION_NEXT,
ZERO,
};
static const enum index action_of_push_mpls[] = {
ACTION_OF_PUSH_MPLS_ETHERTYPE,
ACTION_NEXT,
ZERO,
};
static int parse_init(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
@ -2174,6 +2221,102 @@ static const struct token token_list[] = {
.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
.call = parse_vc,
},
[ACTION_OF_POP_VLAN] = {
.name = "of_pop_vlan",
.help = "OpenFlow's OFPAT_POP_VLAN",
.priv = PRIV_ACTION(OF_POP_VLAN, 0),
.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
.call = parse_vc,
},
[ACTION_OF_PUSH_VLAN] = {
.name = "of_push_vlan",
.help = "OpenFlow's OFPAT_PUSH_VLAN",
.priv = PRIV_ACTION
(OF_PUSH_VLAN,
sizeof(struct rte_flow_action_of_push_vlan)),
.next = NEXT(action_of_push_vlan),
.call = parse_vc,
},
[ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
.name = "ethertype",
.help = "EtherType",
.next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
.args = ARGS(ARGS_ENTRY_HTON
(struct rte_flow_action_of_push_vlan,
ethertype)),
.call = parse_vc_conf,
},
[ACTION_OF_SET_VLAN_VID] = {
.name = "of_set_vlan_vid",
.help = "OpenFlow's OFPAT_SET_VLAN_VID",
.priv = PRIV_ACTION
(OF_SET_VLAN_VID,
sizeof(struct rte_flow_action_of_set_vlan_vid)),
.next = NEXT(action_of_set_vlan_vid),
.call = parse_vc,
},
[ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
.name = "vlan_vid",
.help = "VLAN id",
.next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
.args = ARGS(ARGS_ENTRY_HTON
(struct rte_flow_action_of_set_vlan_vid,
vlan_vid)),
.call = parse_vc_conf,
},
[ACTION_OF_SET_VLAN_PCP] = {
.name = "of_set_vlan_pcp",
.help = "OpenFlow's OFPAT_SET_VLAN_PCP",
.priv = PRIV_ACTION
(OF_SET_VLAN_PCP,
sizeof(struct rte_flow_action_of_set_vlan_pcp)),
.next = NEXT(action_of_set_vlan_pcp),
.call = parse_vc,
},
[ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
.name = "vlan_pcp",
.help = "VLAN priority",
.next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
.args = ARGS(ARGS_ENTRY_HTON
(struct rte_flow_action_of_set_vlan_pcp,
vlan_pcp)),
.call = parse_vc_conf,
},
[ACTION_OF_POP_MPLS] = {
.name = "of_pop_mpls",
.help = "OpenFlow's OFPAT_POP_MPLS",
.priv = PRIV_ACTION(OF_POP_MPLS,
sizeof(struct rte_flow_action_of_pop_mpls)),
.next = NEXT(action_of_pop_mpls),
.call = parse_vc,
},
[ACTION_OF_POP_MPLS_ETHERTYPE] = {
.name = "ethertype",
.help = "EtherType",
.next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
.args = ARGS(ARGS_ENTRY_HTON
(struct rte_flow_action_of_pop_mpls,
ethertype)),
.call = parse_vc_conf,
},
[ACTION_OF_PUSH_MPLS] = {
.name = "of_push_mpls",
.help = "OpenFlow's OFPAT_PUSH_MPLS",
.priv = PRIV_ACTION
(OF_PUSH_MPLS,
sizeof(struct rte_flow_action_of_push_mpls)),
.next = NEXT(action_of_push_mpls),
.call = parse_vc,
},
[ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
.name = "ethertype",
.help = "EtherType",
.next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
.args = ARGS(ARGS_ENTRY_HTON
(struct rte_flow_action_of_push_mpls,
ethertype)),
.call = parse_vc_conf,
},
};
/** Remove and return last entry from argument stack. */

View File

@ -1114,6 +1114,17 @@ static const struct {
MK_FLOW_ACTION(OF_DEC_NW_TTL, 0),
MK_FLOW_ACTION(OF_COPY_TTL_OUT, 0),
MK_FLOW_ACTION(OF_COPY_TTL_IN, 0),
MK_FLOW_ACTION(OF_POP_VLAN, 0),
MK_FLOW_ACTION(OF_PUSH_VLAN,
sizeof(struct rte_flow_action_of_push_vlan)),
MK_FLOW_ACTION(OF_SET_VLAN_VID,
sizeof(struct rte_flow_action_of_set_vlan_vid)),
MK_FLOW_ACTION(OF_SET_VLAN_PCP,
sizeof(struct rte_flow_action_of_set_vlan_pcp)),
MK_FLOW_ACTION(OF_POP_MPLS,
sizeof(struct rte_flow_action_of_pop_mpls)),
MK_FLOW_ACTION(OF_PUSH_MPLS,
sizeof(struct rte_flow_action_of_push_mpls)),
};
/** Compute storage space needed by action configuration and copy it. */

View File

@ -1813,6 +1813,102 @@ next-to-outermost") as defined by the `OpenFlow Switch Specification`_.
| no properties |
+---------------+
Action: ``OF_POP_VLAN``
^^^^^^^^^^^^^^^^^^^^^^^
Implements ``OFPAT_POP_VLAN`` ("pop the outer VLAN tag") as defined
by the `OpenFlow Switch Specification`_.
.. _table_rte_flow_action_of_pop_vlan:
.. table:: OF_POP_VLAN
+---------------+
| Field |
+===============+
| no properties |
+---------------+
Action: ``OF_PUSH_VLAN``
^^^^^^^^^^^^^^^^^^^^^^^^
Implements ``OFPAT_PUSH_VLAN`` ("push a new VLAN tag") as defined by the
`OpenFlow Switch Specification`_.
.. _table_rte_flow_action_of_push_vlan:
.. table:: OF_PUSH_VLAN
+---------------+-----------+
| Field | Value |
+===============+===========+
| ``ethertype`` | EtherType |
+---------------+-----------+
Action: ``OF_SET_VLAN_VID``
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Implements ``OFPAT_SET_VLAN_VID`` ("set the 802.1q VLAN id") as defined by
the `OpenFlow Switch Specification`_.
.. _table_rte_flow_action_of_set_vlan_vid:
.. table:: OF_SET_VLAN_VID
+--------------+---------+
| Field | Value |
+==============+=========+
| ``vlan_vid`` | VLAN id |
+--------------+---------+
Action: ``OF_SET_VLAN_PCP``
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Implements ``OFPAT_SET_LAN_PCP`` ("set the 802.1q priority") as defined by
the `OpenFlow Switch Specification`_.
.. _table_rte_flow_action_of_set_vlan_pcp:
.. table:: OF_SET_VLAN_PCP
+--------------+---------------+
| Field | Value |
+==============+===============+
| ``vlan_pcp`` | VLAN priority |
+--------------+---------------+
Action: ``OF_POP_MPLS``
^^^^^^^^^^^^^^^^^^^^^^^
Implements ``OFPAT_POP_MPLS`` ("pop the outer MPLS tag") as defined by the
`OpenFlow Switch Specification`_.
.. _table_rte_flow_action_of_pop_mpls:
.. table:: OF_POP_MPLS
+---------------+-----------+
| Field | Value |
+===============+===========+
| ``ethertype`` | EtherType |
+---------------+-----------+
Action: ``OF_PUSH_MPLS``
^^^^^^^^^^^^^^^^^^^^^^^^
Implements ``OFPAT_PUSH_MPLS`` ("push a new MPLS tag") as defined by the
`OpenFlow Switch Specification`_.
.. _table_rte_flow_action_of_push_mpls:
.. table:: OF_PUSH_MPLS
+---------------+-----------+
| Field | Value |
+===============+===========+
| ``ethertype`` | EtherType |
+---------------+-----------+
Negative types
~~~~~~~~~~~~~~

View File

@ -3519,6 +3519,28 @@ This section lists supported actions and their attributes, if any.
- ``of_copy_ttl_in``: OpenFlow's ``OFPAT_COPY_TTL_IN``.
- ``of_pop_vlan``: OpenFlow's ``OFPAT_POP_VLAN``.
- ``of_push_vlan``: OpenFlow's ``OFPAT_PUSH_VLAN``.
- ``ethertype``: Ethertype.
- ``of_set_vlan_vid``: OpenFlow's ``OFPAT_SET_VLAN_VID``.
- ``vlan_vid``: VLAN id.
- ``of_set_vlan_pcp``: OpenFlow's ``OFPAT_SET_VLAN_PCP``.
- ``vlan_pcp``: VLAN priority.
- ``of_pop_mpls``: OpenFlow's ``OFPAT_POP_MPLS``.
- ``ethertype``: Ethertype.
- ``of_push_mpls``: OpenFlow's ``OFPAT_PUSH_MPLS``.
- ``ethertype``: Ethertype.
Destroying flow rules
~~~~~~~~~~~~~~~~~~~~~

View File

@ -98,6 +98,17 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
MK_FLOW_ACTION(OF_DEC_NW_TTL, 0),
MK_FLOW_ACTION(OF_COPY_TTL_OUT, 0),
MK_FLOW_ACTION(OF_COPY_TTL_IN, 0),
MK_FLOW_ACTION(OF_POP_VLAN, 0),
MK_FLOW_ACTION(OF_PUSH_VLAN,
sizeof(struct rte_flow_action_of_push_vlan)),
MK_FLOW_ACTION(OF_SET_VLAN_VID,
sizeof(struct rte_flow_action_of_set_vlan_vid)),
MK_FLOW_ACTION(OF_SET_VLAN_PCP,
sizeof(struct rte_flow_action_of_set_vlan_pcp)),
MK_FLOW_ACTION(OF_POP_MPLS,
sizeof(struct rte_flow_action_of_pop_mpls)),
MK_FLOW_ACTION(OF_PUSH_MPLS,
sizeof(struct rte_flow_action_of_push_mpls)),
};
static int

View File

@ -1383,6 +1383,54 @@ enum rte_flow_action_type {
* No associated configuration structure.
*/
RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
/**
* Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
* by the OpenFlow Switch Specification.
*
* No associated configuration structure.
*/
RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
/**
* Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
* the OpenFlow Switch Specification.
*
* See struct rte_flow_action_of_push_vlan.
*/
RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
/**
* Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
* defined by the OpenFlow Switch Specification.
*
* See struct rte_flow_action_of_set_vlan_vid.
*/
RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
/**
* Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
* defined by the OpenFlow Switch Specification.
*
* See struct rte_flow_action_of_set_vlan_pcp.
*/
RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
/**
* Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
* by the OpenFlow Switch Specification.
*
* See struct rte_flow_action_of_pop_mpls.
*/
RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
/**
* Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
* the OpenFlow Switch Specification.
*
* See struct rte_flow_action_of_push_mpls.
*/
RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
};
/**
@ -1579,6 +1627,56 @@ struct rte_flow_action_of_set_nw_ttl {
uint8_t nw_ttl; /**< IP TTL. */
};
/**
* RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
*
* Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
* OpenFlow Switch Specification.
*/
struct rte_flow_action_of_push_vlan {
rte_be16_t ethertype; /**< EtherType. */
};
/**
* RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
*
* Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
* the OpenFlow Switch Specification.
*/
struct rte_flow_action_of_set_vlan_vid {
rte_be16_t vlan_vid; /**< VLAN id. */
};
/**
* RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
*
* Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
* the OpenFlow Switch Specification.
*/
struct rte_flow_action_of_set_vlan_pcp {
uint8_t vlan_pcp; /**< VLAN priority. */
};
/**
* RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
*
* Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
* OpenFlow Switch Specification.
*/
struct rte_flow_action_of_pop_mpls {
rte_be16_t ethertype; /**< EtherType. */
};
/**
* RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
*
* Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
* OpenFlow Switch Specification.
*/
struct rte_flow_action_of_push_mpls {
rte_be16_t ethertype; /**< EtherType. */
};
/**
* Definition of a single action.
*