Skip to contentSkip to conversation

additions to support tunnel encap/decap

PATCH Superseded Declan Doherty 5 participants 23 messages Apr 26, 2018 – Apr 27, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v6 cover additions to support tunnel encap/decap

his patchset contains the revised proposal to manage tunnel endpoints hardware accleration based on community feedback on RFC
(http://dpdk.org/ml/archives/dev/2017-December/084676.html). This proposal is purely enabled through rte_flow APIs with the additions of some new features which were previously implemented by the proposed rte_tep APIs which were proposed in the original RFC. This patchset ultimately aims to enable the configuration of inline data path encapsulation and decapsulation of tunnel endpoint network overlays on accelerated IO devices.

V2:
- Split new functions into separate patches, and add additional documentaiton.

V3:

- Extended the description of group counter in documentation.
- Renamed VTEP to TUNNEL.
- Fixed C99 syntax.

V4:

- Modify encap/decap actions to be protocol specific
- rename group action type to jump
- add mark flow item type in place of metadata flow/action types
- add count action data structure
- modify query API to accept rte_flow_action structure in place of rte_flow_actio_type enumeration to support specification and querying of multiple actions of the same type

V5:
- Documentation and comment updates
- Mark new API structures as experimental
- squash new function testpmd enablement into relevant patches.

V6:
- rebased to head of next-net
- fixed whitespace issues add in previous revision

The summary of the additions to the rte_flow are as follows:

- Add new flow actions RTE_RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_ENCAP and RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_DECAP to rte_flow to support specfication of encapsulation and decapsulation of VXLAN and NVGRE tunnels in hardware.
- Introduces support for the use of pipeline metadata in
the flow pattern definition and the population of metadata fields from flow actions using the MARK flow and action items.
- Add shared flag to counters to enable statistics to be kept on groups offlows such as all ingress/egress flows of a tunnel
- Adds jump_action to allow a flows to be redirected to a group within the device.

A high level summary of the proposed usage model is as follows:

1. Decapsulation

1.1. Decapsulation of tunnel outer headers and forward all traffic
to the same queue/s or port, would have the follow flows paramteters, sudo code used here.

struct rte_flow_attr attr = { .ingress = 1 };

struct rte_flow_item pattern[] = {
	{ .type = RTE_FLOW_ITEM_TYPE_ETH,  .spec = &eth_item },
	{ .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item },
	{ .type = RTE_FLOW_ITEM_TYPE_UDP, .spec = &udp_item },
	{ .type = RTE_FLOW_ITEM_TYPE_VxLAN, .spec = &vxlan_item },
	{ .type = RTE_FLOW_ITEM_TYPE_END }
};

struct rte_flow_action actions[] = {
{ .type = RTE_FLOW_ACTION_TYPE_VXLAN_DECAP },
{ .type = RTE_FLOW_ACTION_TYPE_VF, .conf = &vf_action }, { .type = RTE_FLOW_ACTION_TYPE_END }
}

1.2.

Decapsulation of tunnel outer headers and matching on inner headers, and forwarding to the same queue/s or port.

1.2.1.

The same scenario as above but either the application or hardware requires configuration as 2 logically independent operations (viewing it as 2 logical tables). The first stage being the flow rule to define the pattern to match the tunnel and the action to decapsulate the packet, and the second stage stage table matches the inner header and defines the actions, forward to port etc.

flow rule for outer header on table 0

struct rte_flow_attr attr = { .ingress = 1, .table = 0 };

struct rte_flow_item pattern[] = {
	{ .type = RTE_FLOW_ITEM_TYPE_ETH,  .spec = &eth_item },
	{ .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item },
	{ .type = RTE_FLOW_ITEM_TYPE_UDP, .spec = &udp_item },
	{ .type = RTE_FLOW_ITEM_TYPE_VxLAN, .spec = &vxlan_item },
	{ .type = RTE_FLOW_ITEM_TYPE_END }
};
struct rte_flow_item_count shared_couter = {
	.shared = 1,
	.id = {counter_id}
}
struct rte_flow_action actions[] = {
	{ .type = RTE_FLOW_ACTION_TYPE_COUNT, .conf = &shared_counter },
	{ .type = RTE_FLOW_ACTION_TYPE_MARK, .conf = &mark_action },
	{ .type = RTE_FLOW_ACTION_TYPE_VXLAN_DECAP },
	{
	  .type = RTE_FLOW_ACTION_TYPE_JUMP,
	  .conf = { .group = 1 }
	},
	{ .type = RTE_FLOW_ACTION_TYPE_END }
}

flow rule for inner header on table 1

struct rte_flow_attr attr = { .ingress = 1, .group = 1 };

struct rte_flow_item_mark mark_item = { id = {mark_id} };

struct rte_flow_item pattern[] = {
	{ .type = RTE_FLOW_ITEM_TYPE_MARK,  .spec = &mark_item },
	{ .type = RTE_FLOW_ITEM_TYPE_ETH,  .spec = &eth_item },
	{ .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item },
	{ .type = RTE_FLOW_ITEM_TYPE_TCP, .spec = &tcp_item },
	{ .type = RTE_FLOW_ITEM_TYPE_END }
};
struct rte_flow_action actions[] = {
	{
	  .type = RTE_FLOW_ACTION_TYPE_PORT_ID,
	  .conf = &port_id_action = { port_id }
	},
	{ .type = RTE_FLOW_ACTION_TYPE_END }
}

Note that the mark action in the flow rule in group 0 is generating the value in the pipeline which is then used in as part as the flow pattern in group 1 to specify the exact flow to match against. In the case where exact match rules are being provided by the application explicitly then the MARK item value can be provided by the application in the flow pattern for the flow rule in group 1 also.

2. Encapsulation

Encapsulation of all traffic matching a specific flow pattern to a specified tunnel and egressing to a particular port.

struct rte_flow_attr attr = { .egress = 1 };

struct rte_flow_item pattern[] = {
	{ .type = RTE_FLOW_ITEM_TYPE_ETH, .spec = &eth_item },
	{ .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item },
	{ .type = RTE_FLOW_ITEM_TYPE_TCP, .spec = &tcp_item },
	{ .type = RTE_FLOW_ITEM_TYPE_END }
};
struct rte_flow_action_tunnel_encap vxlan_encap_action = {
	.definition = {
		{ .type=eth, .spec={}, .mask={} },
		{ .type=ipv4, .spec={}, .mask={} },
		{ .type=udp, .spec={}, .mask={} },
		{ .type=vxlan, .spec={}, .mask={} }
		{ .type=end }
	}
};
struct rte_flow_action actions[] = {
	{ .type = RTE_FLOW_ACTION_TYPE_COUNT, .conf = &count } },
	{ .type = RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP, .conf = &vxlan_encap_action } },
	{
	  .type = RTE_FLOW_ACTION_TYPE_PORT_ID,
	  .conf = &port_id_action = { port_id }
	},
	{ .type = RTE_FLOW_ACTION_TYPE_END }
};

Declan Doherty (4):
ethdev: Add tunnel encap/decap actions
ethdev: Add group JUMP action
ethdev: add mark flow item to rte_flow_item_types
ethdev: add shared counter support to rte_flow

 app/test-pmd/cmdline_flow.c                 |  51 +++++-
 app/test-pmd/config.c                       |  15 +-
 app/test-pmd/testpmd.h                      |   2 +-
 doc/guides/prog_guide/rte_flow.rst          | 257 ++++++++++++++++++++++++----
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 +
 drivers/net/bonding/rte_eth_bond_flow.c     |   9 +-
 drivers/net/failsafe/failsafe_flow.c        |   4 +-
 lib/librte_ether/rte_flow.c                 |   2 +-
 lib/librte_ether/rte_flow.h                 | 211 +++++++++++++++++++++--
 lib/librte_ether/rte_flow_driver.h          |   2 +-
 10 files changed, 500 insertions(+), 61 deletions(-)
Signature · 1 line
2.14.3
#1 lore raw

PATCH v6 1/4 ethdev: Add tunnel encap/decap actions

Add new flow action types and associated action data structures to support the encapsulation and decapsulation of VXLAN and NVGRE tunnel endpoints.

The RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_ENCAP action will cause the matching flow to be encapsulated in the tunnel endpoint overlay defined in the [vxlan/nvgre]_encap action data.

The RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_DECAP action will cause all headers associated with the outer most tunnel endpoint of the specified type for the matching flows.

---
 doc/guides/prog_guide/rte_flow.rst | 107 +++++++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_flow.h        | 103 +++++++++++++++++++++++++++++++++++
 2 files changed, 210 insertions(+)
doc/guides/prog_guide/rte_flow.rst +107 -0
index 629cc90a9..a7197cb7e 100644
@@ -1909,6 +1909,113 @@ Implements ``OFPAT_PUSH_MPLS`` ("push a new MPLS tag") as defined by the
    | ``ethertype`` | EtherType |
    +---------------+-----------+
 
+Action: ``VXLAN_ENCAP``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Performs a VXLAN encapsulation action by encapsulating the matched flow in the
+VXLAN tunnel as defined in the``rte_flow_action_vxlan_encap`` flow items
+definition.
+
+This action modifies the payload of matched flows. The flow definition specified
+in the ``rte_flow_action_tunnel_encap`` action structure must define a valid
+VLXAN network overlay which conforms with RFC 7348 (Virtual eXtensible Local
+Area Network (VXLAN): A Framework for Overlaying Virtualized Layer 2 Networks
+over Layer 3 Networks). The pattern must be terminated with the
+RTE_FLOW_ITEM_TYPE_END item type.
+
+.. _table_rte_flow_action_vxlan_encap:
+
+.. table:: VXLAN_ENCAP
+
+   +----------------+-------------------------------------+
+   | Field          | Value                               |
+   +================+=====================================+
+   | ``definition`` | Tunnel end-point overlay definition |
+   +----------------+-------------------------------------+
+
+.. _table_rte_flow_action_vxlan_encap_example:
+
+.. table:: IPv4 VxLAN flow pattern example.
+
+   +-------+----------+
+   | Index | Item     |
+   +=======+==========+
+   | 0     | Ethernet |
+   +-------+----------+
+   | 1     | IPv4     |
+   +-------+----------+
+   | 2     | UDP      |
+   +-------+----------+
+   | 3     | VXLAN    |
+   +-------+----------+
+   | 4     | END      |
+   +-------+----------+
+
+Action: ``VXLAN_DECAP``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Performs a decapsulation action by stripping all headers of the VXLAN tunnel
+network overlay from the matched flow.
+
+The flow items pattern defined for the flow rule with which a ``VXLAN_DECAP``
+action is specified, must define a valid VXLAN tunnel as per RFC7348. If the
+flow pattern does not specify a valid VXLAN tunnel then a
+RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
+
+This action modifies the payload of matched flows.
+
+Action: ``NVGRE_ENCAP``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Performs a NVGRE encapsulation action by encapsulating the matched flow in the
+NVGRE tunnel as defined in the``rte_flow_action_tunnel_encap`` flow item
+definition.
+
+This action modifies the payload of matched flows. The flow definition specified
+in the ``rte_flow_action_tunnel_encap`` action structure must defined a valid
+NVGRE network overlay which conforms with RFC 7637 (NVGRE: Network
+Virtualization Using Generic Routing Encapsulation). The pattern must be
+terminated with the RTE_FLOW_ITEM_TYPE_END item type.
+
+.. _table_rte_flow_action_nvgre_encap:
+
+.. table:: NVGRE_ENCAP
+
+   +----------------+-------------------------------------+
+   | Field          | Value                               |
+   +================+=====================================+
+   | ``definition`` | NVGRE end-point overlay definition |
+   +----------------+-------------------------------------+
+
+.. _table_rte_flow_action_nvgre_encap_example:
+
+.. table:: IPv4 NVGRE flow pattern example.
+
+   +-------+----------+
+   | Index | Item     |
+   +=======+==========+
+   | 0     | Ethernet |
+   +-------+----------+
+   | 1     | IPv4     |
+   +-------+----------+
+   | 2     | NVGRE    |
+   +-------+----------+
+   | 3     | END      |
+   +-------+----------+
+
+Action: ``NVGRE_DECAP``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Performs a decapsulation action by stripping all headers of the NVGRE tunnel
+network overlay from the matched flow.
+
+The flow items pattern defined for the flow rule with which a ``NVGRE_DECAP``
+action is specified, must define a valid NVGRE tunnel as per RFC7637. If the
+flow pattern does not specify a valid NVGRE tunnel then a
+RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
+
+This action modifies the payload of matched flows.
+
 Negative types
 ~~~~~~~~~~~~~~
 
lib/librte_ether/rte_flow.h +103 -0

115 lines not on this page · raw message

Signature · 1 line
2.14.3
#2 lore raw

PATCH v6 2/4 ethdev: Add group JUMP action

In reply to Declan Doherty

Add jump action type which defines an action which allows a matched flow to be redirect to the specified group. This allows physical and logical flow table/group hierarchies to be defined through rte_flow.

This breaks ABI compatibility for the following public functions (as it modifes the ordering of the rte_flow_action_type enumeration):

- rte_flow_copy()
- rte_flow_create()
- rte_flow_query()
- rte_flow_validate()

Add support for specification of new JUMP action to testpmd's flow cli, and update the testpmd documentation to describe this new action.

---
 app/test-pmd/cmdline_flow.c                 | 23 +++++++++++
 doc/guides/prog_guide/rte_flow.rst          | 61 ++++++++++++++++++++++++-----
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 ++
 lib/librte_ether/rte_flow.h                 | 41 +++++++++++++++----
 4 files changed, 112 insertions(+), 17 deletions(-)
app/test-pmd/cmdline_flow.c +23 -0
index 4239602b6..6e9fa5d7c 100644
@@ -183,6 +183,8 @@ enum index {
 	ACTION_END,
 	ACTION_VOID,
 	ACTION_PASSTHRU,
+	ACTION_JUMP,
+	ACTION_JUMP_GROUP,
 	ACTION_MARK,
 	ACTION_MARK_ID,
 	ACTION_FLAG,
@@ -738,6 +740,7 @@ static const enum index next_action[] = {
 	ACTION_END,
 	ACTION_VOID,
 	ACTION_PASSTHRU,
+	ACTION_JUMP,
 	ACTION_MARK,
 	ACTION_FLAG,
 	ACTION_QUEUE,
@@ -856,6 +859,12 @@ static const enum index action_of_push_mpls[] = {
 	ZERO,
 };
 
+static const enum index action_jump[] = {
+	ACTION_JUMP_GROUP,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -1931,6 +1940,20 @@ static const struct token token_list[] = {
 		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
 		.call = parse_vc,
 	},
+	[ACTION_JUMP] = {
+		.name = "jump",
+		.help = "redirect traffic to a given group",
+		.priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
+		.next = NEXT(action_jump),
+		.call = parse_vc,
+	},
+	[ACTION_JUMP_GROUP] = {
+		.name = "group",
+		.help = "group to redirect traffic to",
+		.next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
+		.call = parse_vc_conf,
+	},
 	[ACTION_MARK] = {
 		.name = "mark",
 		.help = "attach 32 bit value to packets",
doc/guides/prog_guide/rte_flow.rst +51 -10

94 lines not on this page · raw message

doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -0
index 2edf96dd6..260d044d5 100644
@@ -3453,6 +3453,10 @@ This section lists supported actions and their attributes, if any.
 
 - ``passthru``: let subsequent rule process matched packets.
 
+- ``jump``: redirect traffic to group on device.
+
+  - ``group {unsigned}``: group to redirect to.
+
 - ``mark``: attach 32 bit value to packets.
 
   - ``id {unsigned}``: 32 bit value to return with packets.
lib/librte_ether/rte_flow.h +34 -7

71 lines not on this page · raw message

Signature · 1 line
2.14.3
#3 lore raw

PATCH v6 3/4 ethdev: add mark flow item to rte_flow_item_types

In reply to Declan Doherty

Introduces a new action type RTE_FLOW_ITEM_TYPE_MARK which enables flow patterns to specify arbitrary integer values to match aginst set by the RTE_FLOW_ACTION_TYPE_MARK action in previously matched flows.

Add support for specification of new MARK flow item in testpmd's cli. Update testpmd documentation to describe new MARK flow item support.

---
 app/test-pmd/cmdline_flow.c                 | 22 +++++++++++++++++++++
 doc/guides/prog_guide/rte_flow.rst          | 30 +++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 ++++
 lib/librte_ether/rte_flow.h                 | 29 ++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+)
app/test-pmd/cmdline_flow.c +22 -0
index 6e9fa5d7c..1ac04a0ab 100644
@@ -91,6 +91,8 @@ enum index {
 	ITEM_PHY_PORT_INDEX,
 	ITEM_PORT_ID,
 	ITEM_PORT_ID_ID,
+	ITEM_MARK,
+	ITEM_MARK_ID,
 	ITEM_RAW,
 	ITEM_RAW_RELATIVE,
 	ITEM_RAW_SEARCH,
@@ -494,6 +496,7 @@ static const enum index next_item[] = {
 	ITEM_VF,
 	ITEM_PHY_PORT,
 	ITEM_PORT_ID,
+	ITEM_MARK,
 	ITEM_RAW,
 	ITEM_ETH,
 	ITEM_VLAN,
@@ -555,6 +558,12 @@ static const enum index item_port_id[] = {
 	ZERO,
 };
 
+static const enum index item_mark[] = {
+	ITEM_MARK_ID,
+	ITEM_NEXT,
+	ZERO,
+};
+
 static const enum index item_raw[] = {
 	ITEM_RAW_RELATIVE,
 	ITEM_RAW_SEARCH,
@@ -1289,6 +1298,19 @@ static const struct token token_list[] = {
 		.next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
 		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
 	},
+	[ITEM_MARK] = {
+		.name = "mark",
+		.help = "match traffic against value set in previously matched rule",
+		.priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
+		.next = NEXT(item_mark),
+		.call = parse_vc,
+	},
+	[ITEM_MARK_ID] = {
+		.name = "id",
+		.help = "Integer value to match against",
+		.next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
+	},
 	[ITEM_RAW] = {
 		.name = "raw",
 		.help = "match an arbitrary byte string",
doc/guides/prog_guide/rte_flow.rst +30 -0
index 1102fae09..301f8762e 100644
@@ -656,6 +656,36 @@ representor" depending on the kind of underlying device).
    | ``mask`` | ``id``   | zeroed to match any port ID |
    +----------+----------+-----------------------------+
 
+Item: ``MARK``
+^^^^^^^^^^^^^^
+
+Matches an arbitrary integer value which was set using the ``MARK`` action in
+a previously matched rule.
+
+This item can only specified once as a match criteria as the ``MARK`` action can
+only be specified once in a flow action.
+
+Note the value of MARK field is arbitrary and application defined.
+
+Depending on the underlying implementation the MARK item may be supported on
+the physical device, with virtual groups in the PMD or not at all.
+
+- Default ``mask`` matches any integer value.
+
+.. _table_rte_flow_item_mark:
+
+.. table:: MARK
+
+   +----------+----------+---------------------------+
+   | Field    | Subfield | Value                     |
+   +==========+==========+===========================+
+   | ``spec`` | ``id``   | integer value             |
+   +----------+--------------------------------------+
+   | ``last`` | ``id``   | upper range value         |
+   +----------+----------+---------------------------+
+   | ``mask`` | ``id``   | zeroed to match any value |
+   +----------+------- --+---------------------------+
+
 Data matching item types
 ~~~~~~~~~~~~~~~~~~~~~~~~
 
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -0
index 260d044d5..013a40549 100644
@@ -3240,6 +3240,10 @@ This section lists supported pattern items and their attributes, if any.
 
   - ``id {unsigned}``: DPDK port ID.
 
+- ``mark``: match value set in previously matched flow rule using the mark action.
+
+  - ``id {unsigned}``: arbitrary integer value.
+
 - ``raw``: match an arbitrary byte string.
 
   - ``relative {boolean}``: look for pattern after the previous item.
lib/librte_ether/rte_flow.h +29 -0
index 17c1c4a89..d390bbf5a 100644
@@ -406,6 +406,13 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
 	 */
 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
+
+	/**
+	 * Matches specified mark field.
+	 *
+	 * See struct rte_flow_item_mark.
+	 */
+	RTE_FLOW_ITEM_TYPE_MARK,
 };
 
 /**
@@ -1148,6 +1155,28 @@ rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
 };
 #endif
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_MARK
+ *
+ * Matches an arbitrary integer value which was set using the ``MARK`` action
+ * in a previously matched rule.
+ *
+ * This item can only be specified once as a match criteria as the ``MARK``
+ * action can only be specified once in a flow action.
+ *
+ * This value is arbitrary and application-defined. Maximum allowed value
+ * depends on the underlying implementation.
+ *
+ * Depending on the underlying implementation the MARK item may be supported on
+ * the physical device, with virtual groups in the PMD or not at all.
+ */
+struct rte_flow_item_mark {
+	uint32_t id; /**< Integer value to match against. */
+};
+
 /**
  * Matching pattern item definition.
  *
Signature · 1 line
2.14.3
#4 lore raw

PATCH v6 4/4 ethdev: add shared counter support to rte_flow

In reply to Declan Doherty

Add rte_flow_action_count action data structure to enable shared counters across multiple flows on a single port or across multiple flows on multiple ports within the same switch domain. Also this enables multiple count actions to be specified in a single flow action.

This patch also modifies the existing rte_flow_query API to take the rte_flow_action structure as an input parameter instead of the rte_flow_action_type enumeration to allow querying a specific action from a flow rule when multiple actions of the same type are specified.

This patch also contains updates for the bonding and failsafe PMDs and testpmd application which are affected by this API change.

---
 app/test-pmd/cmdline_flow.c             |  6 ++--
 app/test-pmd/config.c                   | 15 +++++----
 app/test-pmd/testpmd.h                  |  2 +-
 doc/guides/prog_guide/rte_flow.rst      | 59 +++++++++++++++++++++------------
 drivers/net/bonding/rte_eth_bond_flow.c |  9 ++---
 drivers/net/failsafe/failsafe_flow.c    |  4 +--
 lib/librte_ether/rte_flow.c             |  2 +-
 lib/librte_ether/rte_flow.h             | 38 +++++++++++++++++++--
 lib/librte_ether/rte_flow_driver.h      |  2 +-
 9 files changed, 93 insertions(+), 44 deletions(-)
app/test-pmd/cmdline_flow.c +3 -3
index 1ac04a0ab..5754e7858 100644
@@ -420,7 +420,7 @@ struct buffer {
 		} destroy; /**< Destroy arguments. */
 		struct {
 			uint32_t rule;
-			enum rte_flow_action_type action;
+			struct rte_flow_action action;
 		} query; /**< Query arguments. */
 		struct {
 			uint32_t *group;
@@ -1101,7 +1101,7 @@ static const struct token token_list[] = {
 		.next = NEXT(NEXT_ENTRY(QUERY_ACTION),
 			     NEXT_ENTRY(RULE_ID),
 			     NEXT_ENTRY(PORT_ID)),
-		.args = ARGS(ARGS_ENTRY(struct buffer, args.query.action),
+		.args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
 			     ARGS_ENTRY(struct buffer, args.query.rule),
 			     ARGS_ENTRY(struct buffer, port)),
 		.call = parse_query,
@@ -3842,7 +3842,7 @@ cmd_flow_parsed(const struct buffer *in)
 		break;
 	case QUERY:
 		port_flow_query(in->port, in->args.query.rule,
-				in->args.query.action);
+				&in->args.query.action);
 		break;
 	case LIST:
 		port_flow_list(in->port, in->args.list.group_n,
app/test-pmd/config.c +8 -7
index 0f2425229..cd6102dfc 100644
@@ -1452,7 +1452,7 @@ port_flow_flush(portid_t port_id)
 /** Query a flow rule. */
 int
 port_flow_query(portid_t port_id, uint32_t rule,
-		enum rte_flow_action_type action)
+		const struct rte_flow_action *action)
 {
 	struct rte_flow_error error;
 	struct rte_port *port;
@@ -1474,15 +1474,16 @@ port_flow_query(portid_t port_id, uint32_t rule,
 		return -ENOENT;
 	}
 	if ((unsigned int)action >= RTE_DIM(flow_action) ||
-	    !flow_action[action].name)
+	    !flow_action[action->type].name)
 		name = "unknown";
 	else
-		name = flow_action[action].name;
-	switch (action) {
+		name = flow_action[action->type].name;
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		break;
 	default:
-		printf("Cannot query action type %d (%s)\n", action, name);
+		printf("Cannot query action type %d (%s)\n",
+			action->type, name);
 		return -ENOTSUP;
 	}
 	/* Poisoning to make sure PMDs update it in case of error. */
@@ -1490,7 +1491,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
 	memset(&query, 0, sizeof(query));
 	if (rte_flow_query(port_id, pf->flow, action, &query, &error))
 		return port_flow_complain(&error);
-	switch (action) {
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		printf("%s:\n"
 		       " hits_set: %u\n"
@@ -1505,7 +1506,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
 		break;
 	default:
 		printf("Cannot display result for action type %d (%s)\n",
-		       action, name);
+		       action->type, name);
 		break;
 	}
 	return 0;
app/test-pmd/testpmd.h +1 -1
index a33b525e2..1af87b8f4 100644
@@ -620,7 +620,7 @@ int port_flow_create(portid_t port_id,
 int port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule);
 int port_flow_flush(portid_t port_id);
 int port_flow_query(portid_t port_id, uint32_t rule,
-		    enum rte_flow_action_type action);
+		    const struct rte_flow_action *action);
 void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group);
 int port_flow_isolate(portid_t port_id, int set);
 
doc/guides/prog_guide/rte_flow.rst +37 -22

91 lines not on this page · raw message

drivers/net/bonding/rte_eth_bond_flow.c +5 -4
index 8093c04f5..31e4bcaeb 100644
@@ -152,6 +152,7 @@ bond_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *err)
 
 static int
 bond_flow_query_count(struct rte_eth_dev *dev, struct rte_flow *flow,
+		      const struct rte_flow_action *action,
 		      struct rte_flow_query_count *count,
 		      struct rte_flow_error *err)
 {
@@ -165,7 +166,7 @@ bond_flow_query_count(struct rte_eth_dev *dev, struct rte_flow *flow,
 	rte_memcpy(&slave_count, count, sizeof(slave_count));
 	for (i = 0; i < internals->slave_count; i++) {
 		ret = rte_flow_query(internals->slaves[i].port_id,
-				     flow->flows[i], RTE_FLOW_ACTION_TYPE_COUNT,
+				     flow->flows[i], action,
 				     &slave_count, err);
 		if (unlikely(ret != 0)) {
 			RTE_BOND_LOG(ERR, "Failed to query flow on"
@@ -182,12 +183,12 @@ bond_flow_query_count(struct rte_eth_dev *dev, struct rte_flow *flow,
 
 static int
 bond_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
-		enum rte_flow_action_type type, void *arg,
+		const struct rte_flow_action *action, void *arg,
 		struct rte_flow_error *err)
 {
-	switch (type) {
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
-		return bond_flow_query_count(dev, flow, arg, err);
+		return bond_flow_query_count(dev, flow, action, arg, err);
 	default:
 		return rte_flow_error_set(err, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ACTION, arg,
drivers/net/failsafe/failsafe_flow.c +2 -2
index a97f4075d..bfe42fcee 100644
@@ -174,7 +174,7 @@ fs_flow_flush(struct rte_eth_dev *dev,
 static int
 fs_flow_query(struct rte_eth_dev *dev,
 	      struct rte_flow *flow,
-	      enum rte_flow_action_type type,
+	      const struct rte_flow_action *action,
 	      void *arg,
 	      struct rte_flow_error *error)
 {
@@ -185,7 +185,7 @@ fs_flow_query(struct rte_eth_dev *dev,
 	if (sdev != NULL) {
 		int ret = rte_flow_query(PORT_ID(sdev),
 					 flow->flows[SUB_ID(sdev)],
-					 type, arg, error);
+					 action, arg, error);
 
 		if ((ret = fs_err(sdev, ret))) {
 			fs_unlock(dev, 0);
lib/librte_ether/rte_flow.c +1 -1
index 4f94ac9b5..7947529da 100644
@@ -233,7 +233,7 @@ rte_flow_flush(uint16_t port_id,
 int
 rte_flow_query(uint16_t port_id,
 	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
 	       void *data,
 	       struct rte_flow_error *error)
 {
lib/librte_ether/rte_flow.h +35 -3
index d390bbf5a..f8ba71cdb 100644
@@ -1314,7 +1314,7 @@ enum rte_flow_action_type {
 	 * These counters can be retrieved and reset through rte_flow_query(),
 	 * see struct rte_flow_query_count.
 	 *
-	 * No associated configuration structure.
+	 * See struct rte_flow_action_count.
 	 */
 	RTE_FLOW_ACTION_TYPE_COUNT,
 
@@ -1546,6 +1546,38 @@ struct rte_flow_action_queue {
 	uint16_t index; /**< Queue index to use. */
 };
 
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_COUNT
+ *
+ * Adds a counter action to a matched flow.
+ *
+ * If more than one count action is specified in a single flow rule, then each
+ * action must specify a unique id.
+ *
+ * Counters can be retrieved and reset through ``rte_flow_query()``, see
+ * ``struct rte_flow_query_count``.
+ *
+ * The shared flag indicates whether the counter is unique to the flow rule the
+ * action is specified with, or whether it is a shared counter.
+ *
+ * For a count action with the shared flag set, then then a global device
+ * namespace is assumed for the counter id, so that any matched flow rules using
+ * a count action with the same counter id on the same port will contribute to
+ * that counter.
+ *
+ * For ports within the same switch domain then the counter id namespace extends
+ * to all ports within that switch domain.
+ */
+struct rte_flow_action_count {
+	uint32_t shared:1; /**< Share counter ID with other flow rules. */
+	uint32_t reserved:31; /**< Reserved, must be zero. */
+	uint32_t id; /**< Counter ID. */
+};
+
 /**
  * RTE_FLOW_ACTION_TYPE_COUNT (query)
  *
@@ -2044,7 +2076,7 @@ rte_flow_flush(uint16_t port_id,
  * @param flow
  *   Flow rule handle to query.
  * @param action
- *   Action type to query.
+ *   Action definition as defined in original flow rule.
  * @param[in, out] data
  *   Pointer to storage for the associated query data type.
  * @param[out] error
@@ -2057,7 +2089,7 @@ rte_flow_flush(uint16_t port_id,
 int
 rte_flow_query(uint16_t port_id,
 	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
 	       void *data,
 	       struct rte_flow_error *error);
 
lib/librte_ether/rte_flow_driver.h +1 -1
index 3800310ba..1c90c600d 100644
@@ -88,7 +88,7 @@ struct rte_flow_ops {
 	int (*query)
 		(struct rte_eth_dev *,
 		 struct rte_flow *,
-		 enum rte_flow_action_type,
+		 const struct rte_flow_action *,
 		 void *,
 		 struct rte_flow_error *);
 	/** See rte_flow_isolate(). */
Signature · 1 line
2.14.3
#5 lore raw

Re: [PATCH v6 4/4] ethdev: add shared counter support to rte_flow

Hi Declan,

You are changing API (port_flow_query) which is in use in both MLX5 and MLX4 this results in breaking the build.

Best,
Ori

Quoted 405 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Thursday, April 26, 2018 3:08 PM
To: [email protected]
Cc: Ferruh Yigit <[email protected]>; Declan Doherty <[email protected]>
Subject: [dpdk-dev] [PATCH v6 4/4] ethdev: add shared counter support to rte_flow

Add rte_flow_action_count action data structure to enable shared counters across multiple flows on a single port or across multiple flows on multiple ports within the same switch domain. Also this enables multiple count actions to be specified in a single flow action.

This patch also modifies the existing rte_flow_query API to take the rte_flow_action structure as an input parameter instead of the rte_flow_action_type enumeration to allow querying a specific action from a flow rule when multiple actions of the same type are specified.

This patch also contains updates for the bonding and failsafe PMDs and testpmd application which are affected by this API change.

---
 app/test-pmd/cmdline_flow.c             |  6 ++--
 app/test-pmd/config.c                   | 15 +++++----
 app/test-pmd/testpmd.h                  |  2 +-
 doc/guides/prog_guide/rte_flow.rst      | 59 +++++++++++++++++++++------
------
 drivers/net/bonding/rte_eth_bond_flow.c |  9 ++---
 drivers/net/failsafe/failsafe_flow.c    |  4 +--
 lib/librte_ether/rte_flow.c             |  2 +-
 lib/librte_ether/rte_flow.h             | 38 +++++++++++++++++++--
 lib/librte_ether/rte_flow_driver.h      |  2 +-
 9 files changed, 93 insertions(+), 44 deletions(-)
app/test-pmd/cmdline_flow.c +2 -2
index 1ac04a0ab..5754e7858 100644
@@ -420,7 +420,7 @@ struct buffer {
 		} destroy; /**< Destroy arguments. */
 		struct {
 			uint32_t rule;
-			enum rte_flow_action_type action;
+			struct rte_flow_action action;
 		} query; /**< Query arguments. */
 		struct {
 			uint32_t *group;
@@ -1101,7 +1101,7 @@ static const struct token token_list[] = {
 		.next = NEXT(NEXT_ENTRY(QUERY_ACTION),
 			     NEXT_ENTRY(RULE_ID),
 			     NEXT_ENTRY(PORT_ID)),
-		.args = ARGS(ARGS_ENTRY(struct buffer, args.query.action),
+		.args = ARGS(ARGS_ENTRY(struct buffer,
 args.query.action.type),
 			     ARGS_ENTRY(struct buffer, args.query.rule),
 			     ARGS_ENTRY(struct buffer, port)),
app/test-pmd/cmdline_flow.c +1 -1
 		.call = parse_query,
@@ -3842,7 +3842,7 @@ cmd_flow_parsed(const struct buffer *in)
 		break;
 	case QUERY:
 		port_flow_query(in->port, in->args.query.rule,
-				in->args.query.action);
+				&in->args.query.action);
 		break;
 	case LIST:
 		port_flow_list(in->port, in->args.list.group_n,
app/test-pmd/config.c +8 -7
index 0f2425229..cd6102dfc 100644
@@ -1452,7 +1452,7 @@ port_flow_flush(portid_t port_id)
 /** Query a flow rule. */
 int
 port_flow_query(portid_t port_id, uint32_t rule,
-		enum rte_flow_action_type action)
+		const struct rte_flow_action *action)
 {
 	struct rte_flow_error error;
 	struct rte_port *port;
@@ -1474,15 +1474,16 @@ port_flow_query(portid_t port_id, uint32_t rule,
 		return -ENOENT;
 	}
 	if ((unsigned int)action >= RTE_DIM(flow_action) ||
-	    !flow_action[action].name)
+	    !flow_action[action->type].name)
 		name = "unknown";
 	else
-		name = flow_action[action].name;
-	switch (action) {
+		name = flow_action[action->type].name;
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		break;
 	default:
-		printf("Cannot query action type %d (%s)\n", action, name);
+		printf("Cannot query action type %d (%s)\n",
+			action->type, name);
 		return -ENOTSUP;
 	}
 	/* Poisoning to make sure PMDs update it in case of error. */
@@ -1490,7 +1491,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
 	memset(&query, 0, sizeof(query));
 	if (rte_flow_query(port_id, pf->flow, action, &query, &error))
 		return port_flow_complain(&error);
-	switch (action) {
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		printf("%s:\n"
 		       " hits_set: %u\n"
@@ -1505,7 +1506,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
 		break;
 	default:
 		printf("Cannot display result for action type %d (%s)\n",
-		       action, name);
+		       action->type, name);
 		break;
 	}
 	return 0;
app/test-pmd/testpmd.h +1 -1
index a33b525e2..1af87b8f4 100644
@@ -620,7 +620,7 @@ int port_flow_create(portid_t port_id,
 int port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule);
 int port_flow_flush(portid_t port_id);
 int port_flow_query(portid_t port_id, uint32_t rule,
-		    enum rte_flow_action_type action);
+		    const struct rte_flow_action *action);
 void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group);
 int port_flow_isolate(portid_t port_id, int set);
 
doc/guides/prog_guide/rte_flow.rst +23 -15
index 301f8762e..88bfc87eb 100644
@@ -1277,17 +1277,19 @@ Actions are performed in list order:
 
 .. table:: Mark, count then redirect
 
-   +-------+--------+-----------+-------+
-   | Index | Action | Field     | Value |
-   +=======+========+===========+=======+
-   | 0     | MARK   | ``mark``  | 0x2a  |
-   +-------+--------+-----------+-------+
-   | 1     | COUNT                      |
-   +-------+--------+-----------+-------+
-   | 2     | QUEUE  | ``queue`` | 10    |
-   +-------+--------+-----------+-------+
-   | 3     | END                        |
-   +-------+----------------------------+
+   +-------+--------+------------+-------+
+   | Index | Action | Field      | Value |
+   +=======+========+============+=======+
+   | 0     | MARK   | ``mark``   | 0x2a  |
+   +-------+--------+------------+-------+
+   | 1     | COUNT  | ``shared`` | 0     |
+   |       |        +------------+-------+
+   |       |        | ``id``     | 0     |
+   +-------+--------+------------+-------+
+   | 2     | QUEUE  | ``queue``  | 10    |
+   +-------+--------+------------+-------+
+   | 3     | END                         |
+   +-------+-----------------------------+
 
 |
 
@@ -1516,23 +1518,36 @@ Drop packets.
 Action: ``COUNT``
 ^^^^^^^^^^^^^^^^^
 
-Enables counters for this rule.
+Adds a counter action to a matched flow.
+
+If more than one count action is specified in a single flow rule, then each
+action must specify a unique id.
 
-These counters can be retrieved and reset through ``rte_flow_query()``, see
+Counters can be retrieved and reset through ``rte_flow_query()``, see
 ``struct rte_flow_query_count``.
 
-- Counters can be retrieved with ``rte_flow_query()``.
-- No configurable properties.
+The shared flag indicates whether the counter is unique to the flow rule the
+action is specified with, or whether it is a shared counter.
+
+For a count action with the shared flag set, then then a global device
+namespace is assumed for the counter id, so that any matched flow rules

using

doc/guides/prog_guide/rte_flow.rst +4 -0
+a count action with the same counter id on the same port will contribute to
+that counter.
+
+For ports within the same switch domain then the counter id namespace

extends

doc/guides/prog_guide/rte_flow.rst +10 -7
+to all ports within that switch domain.
 
 .. _table_rte_flow_action_count:
 
 .. table:: COUNT
 
-   +---------------+
-   | Field         |
-   +===============+
-   | no properties |
-   +---------------+
+   +------------+---------------------+
+   | Field      | Value               |
+   +============+=====================+
+   | ``shared`` | shared counter flag |
+   +------------+---------------------+
+   | ``id``     | counter id          |
+   +------------+---------------------+
 
 Query structure to retrieve and reset flow rule counters:
@@ -2282,7 +2297,7 @@ definition.
    int
    rte_flow_query(uint16_t port_id,
                   struct rte_flow *flow,
-                  enum rte_flow_action_type action,
+                  const struct rte_flow_action *action,
                   void *data,
                   struct rte_flow_error *error);
 
@@ -2290,7 +2305,7 @@ Arguments:
 
 - ``port_id``: port identifier of Ethernet device.
 - ``flow``: flow rule handle to query.
-- ``action``: action type to query.
+- ``action``: action to query, this must match prototype from flow rule.
 - ``data``: pointer to storage for the associated query data type.
 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
   this structure in case of error only.
drivers/net/bonding/rte_eth_bond_flow.c +1 -0
index 8093c04f5..31e4bcaeb 100644
@@ -152,6 +152,7 @@ bond_flow_flush(struct rte_eth_dev *dev, struct
 rte_flow_error *err)
 
 static int
 bond_flow_query_count(struct rte_eth_dev *dev, struct rte_flow *flow,
+		      const struct rte_flow_action *action,
 		      struct rte_flow_query_count *count,
 		      struct rte_flow_error *err)

{

drivers/net/bonding/rte_eth_bond_flow.c +1 -1
@@ -165,7 +166,7 @@ bond_flow_query_count(struct rte_eth_dev *dev,
 struct rte_flow *flow,
 	rte_memcpy(&slave_count, count, sizeof(slave_count));
 	for (i = 0; i < internals->slave_count; i++) {
 		ret = rte_flow_query(internals->slaves[i].port_id,
-				     flow->flows[i],
 RTE_FLOW_ACTION_TYPE_COUNT,
+				     flow->flows[i], action,
 				     &slave_count, err);
drivers/net/bonding/rte_eth_bond_flow.c +3 -3
 		if (unlikely(ret != 0)) {
 			RTE_BOND_LOG(ERR, "Failed to query flow on"
@@ -182,12 +183,12 @@ bond_flow_query_count(struct rte_eth_dev *dev,
 struct rte_flow *flow,
 
 static int
 bond_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
-		enum rte_flow_action_type type, void *arg,
+		const struct rte_flow_action *action, void *arg,
 		struct rte_flow_error *err)
 {
-	switch (type) {
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
-		return bond_flow_query_count(dev, flow, arg, err);
+		return bond_flow_query_count(dev, flow, action, arg, err);
 	default:
 		return rte_flow_error_set(err, ENOTSUP,

RTE_FLOW_ERROR_TYPE_ACTION,
arg,

drivers/net/failsafe/failsafe_flow.c +2 -2
index a97f4075d..bfe42fcee 100644
@@ -174,7 +174,7 @@ fs_flow_flush(struct rte_eth_dev *dev,
 static int
 fs_flow_query(struct rte_eth_dev *dev,
 	      struct rte_flow *flow,
-	      enum rte_flow_action_type type,
+	      const struct rte_flow_action *action,
 	      void *arg,
 	      struct rte_flow_error *error)
 {
@@ -185,7 +185,7 @@ fs_flow_query(struct rte_eth_dev *dev,
 	if (sdev != NULL) {
 		int ret = rte_flow_query(PORT_ID(sdev),
 					 flow->flows[SUB_ID(sdev)],
-					 type, arg, error);
+					 action, arg, error);
 
 		if ((ret = fs_err(sdev, ret))) {
 			fs_unlock(dev, 0);
lib/librte_ether/rte_flow.c +1 -1
index 4f94ac9b5..7947529da 100644
@@ -233,7 +233,7 @@ rte_flow_flush(uint16_t port_id,
 int
 rte_flow_query(uint16_t port_id,
 	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
 	       void *data,
 	       struct rte_flow_error *error)
 {
lib/librte_ether/rte_flow.h +17 -1
index d390bbf5a..f8ba71cdb 100644
@@ -1314,7 +1314,7 @@ enum rte_flow_action_type {
 	 * These counters can be retrieved and reset through
 rte_flow_query(),
 	 * see struct rte_flow_query_count.
 	 *
-	 * No associated configuration structure.
+	 * See struct rte_flow_action_count.
 	 */
 	RTE_FLOW_ACTION_TYPE_COUNT,
@@ -1546,6 +1546,38 @@ struct rte_flow_action_queue {
 	uint16_t index; /**< Queue index to use. */
 };
 
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_COUNT
+ *
+ * Adds a counter action to a matched flow.
+ *
+ * If more than one count action is specified in a single flow rule, then each
+ * action must specify a unique id.
+ *
+ * Counters can be retrieved and reset through ``rte_flow_query()``, see
+ * ``struct rte_flow_query_count``.
+ *
+ * The shared flag indicates whether the counter is unique to the flow rule

the
+ * action is specified with, or whether it is a shared counter.
+ *
+ * For a count action with the shared flag set, then then a global device
+ * namespace is assumed for the counter id, so that any matched flow rules using
+ * a count action with the same counter id on the same port will contribute to
+ * that counter.
+ *
+ * For ports within the same switch domain then the counter id namespace extends
+ * to all ports within that switch domain.
+ */

lib/librte_ether/rte_flow.h +8 -2
+struct rte_flow_action_count {
+	uint32_t shared:1; /**< Share counter ID with other flow rules. */
+	uint32_t reserved:31; /**< Reserved, must be zero. */
+	uint32_t id; /**< Counter ID. */
+};
+
 /**
  * RTE_FLOW_ACTION_TYPE_COUNT (query)
  *
@@ -2044,7 +2076,7 @@ rte_flow_flush(uint16_t port_id,
  * @param flow
  *   Flow rule handle to query.
  * @param action
- *   Action type to query.
+ *   Action definition as defined in original flow rule.
  * @param[in, out] data
  *   Pointer to storage for the associated query data type.
  * @param[out] error
@@ -2057,7 +2089,7 @@ rte_flow_flush(uint16_t port_id,
 int
 rte_flow_query(uint16_t port_id,
 	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
 	       void *data,
 	       struct rte_flow_error *error);
 
lib/librte_ether/rte_flow_driver.h +1 -2
index 3800310ba..1c90c600d 100644
@@ -88,7 +88,7 @@ struct rte_flow_ops {
 	int (*query)
 		(struct rte_eth_dev *,
 		 struct rte_flow *,
-		 enum rte_flow_action_type,
+		 const struct rte_flow_action *,
 		 void *,
 		 struct rte_flow_error *);
 	/** See rte_flow_isolate(). */
--

2.14.3

#6 lore raw

Re: [PATCH v6 4/4] ethdev: add shared counter support to rte_flow

Quoted 4 lines · Ori Kam

Hi Declan,

You are changing API (port_flow_query) which is in use in both MLX5 and MLX4 this results in breaking the build.

Hi Ori,

Do you mean "rte_flow_query"? port_flow_query() is a function in testpmd, how mlx is using it?

Quoted 410 lines

Best,
Ori

Quoted 405 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Thursday, April 26, 2018 3:08 PM
To: [email protected]
Cc: Ferruh Yigit <[email protected]>; Declan Doherty <[email protected]>
Subject: [dpdk-dev] [PATCH v6 4/4] ethdev: add shared counter support to rte_flow

Add rte_flow_action_count action data structure to enable shared counters across multiple flows on a single port or across multiple flows on multiple ports within the same switch domain. Also this enables multiple count actions to be specified in a single flow action.

This patch also modifies the existing rte_flow_query API to take the rte_flow_action structure as an input parameter instead of the rte_flow_action_type enumeration to allow querying a specific action from a flow rule when multiple actions of the same type are specified.

This patch also contains updates for the bonding and failsafe PMDs and testpmd application which are affected by this API change.

---
 app/test-pmd/cmdline_flow.c             |  6 ++--
 app/test-pmd/config.c                   | 15 +++++----
 app/test-pmd/testpmd.h                  |  2 +-
 doc/guides/prog_guide/rte_flow.rst      | 59 +++++++++++++++++++++------
------
 drivers/net/bonding/rte_eth_bond_flow.c |  9 ++---
 drivers/net/failsafe/failsafe_flow.c    |  4 +--
 lib/librte_ether/rte_flow.c             |  2 +-
 lib/librte_ether/rte_flow.h             | 38 +++++++++++++++++++--
 lib/librte_ether/rte_flow_driver.h      |  2 +-
 9 files changed, 93 insertions(+), 44 deletions(-)
app/test-pmd/cmdline_flow.c +2 -2
index 1ac04a0ab..5754e7858 100644
@@ -420,7 +420,7 @@ struct buffer {
 		} destroy; /**< Destroy arguments. */
 		struct {
 			uint32_t rule;
-			enum rte_flow_action_type action;
+			struct rte_flow_action action;
 		} query; /**< Query arguments. */
 		struct {
 			uint32_t *group;
@@ -1101,7 +1101,7 @@ static const struct token token_list[] = {
 		.next = NEXT(NEXT_ENTRY(QUERY_ACTION),
 			     NEXT_ENTRY(RULE_ID),
 			     NEXT_ENTRY(PORT_ID)),
-		.args = ARGS(ARGS_ENTRY(struct buffer, args.query.action),
+		.args = ARGS(ARGS_ENTRY(struct buffer,
 args.query.action.type),
 			     ARGS_ENTRY(struct buffer, args.query.rule),
 			     ARGS_ENTRY(struct buffer, port)),
app/test-pmd/cmdline_flow.c +1 -1
 		.call = parse_query,
@@ -3842,7 +3842,7 @@ cmd_flow_parsed(const struct buffer *in)
 		break;
 	case QUERY:
 		port_flow_query(in->port, in->args.query.rule,
-				in->args.query.action);
+				&in->args.query.action);
 		break;
 	case LIST:
 		port_flow_list(in->port, in->args.list.group_n,
app/test-pmd/config.c +8 -7
index 0f2425229..cd6102dfc 100644
@@ -1452,7 +1452,7 @@ port_flow_flush(portid_t port_id)
 /** Query a flow rule. */
 int
 port_flow_query(portid_t port_id, uint32_t rule,
-		enum rte_flow_action_type action)
+		const struct rte_flow_action *action)
 {
 	struct rte_flow_error error;
 	struct rte_port *port;
@@ -1474,15 +1474,16 @@ port_flow_query(portid_t port_id, uint32_t rule,
 		return -ENOENT;
 	}
 	if ((unsigned int)action >= RTE_DIM(flow_action) ||
-	    !flow_action[action].name)
+	    !flow_action[action->type].name)
 		name = "unknown";
 	else
-		name = flow_action[action].name;
-	switch (action) {
+		name = flow_action[action->type].name;
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		break;
 	default:
-		printf("Cannot query action type %d (%s)\n", action, name);
+		printf("Cannot query action type %d (%s)\n",
+			action->type, name);
 		return -ENOTSUP;
 	}
 	/* Poisoning to make sure PMDs update it in case of error. */
@@ -1490,7 +1491,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
 	memset(&query, 0, sizeof(query));
 	if (rte_flow_query(port_id, pf->flow, action, &query, &error))
 		return port_flow_complain(&error);
-	switch (action) {
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		printf("%s:\n"
 		       " hits_set: %u\n"
@@ -1505,7 +1506,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
 		break;
 	default:
 		printf("Cannot display result for action type %d (%s)\n",
-		       action, name);
+		       action->type, name);
 		break;
 	}
 	return 0;
app/test-pmd/testpmd.h +1 -1
index a33b525e2..1af87b8f4 100644
@@ -620,7 +620,7 @@ int port_flow_create(portid_t port_id,
 int port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule);
 int port_flow_flush(portid_t port_id);
 int port_flow_query(portid_t port_id, uint32_t rule,
-		    enum rte_flow_action_type action);
+		    const struct rte_flow_action *action);
 void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group);
 int port_flow_isolate(portid_t port_id, int set);
 
doc/guides/prog_guide/rte_flow.rst +23 -15
index 301f8762e..88bfc87eb 100644
@@ -1277,17 +1277,19 @@ Actions are performed in list order:
 
 .. table:: Mark, count then redirect
 
-   +-------+--------+-----------+-------+
-   | Index | Action | Field     | Value |
-   +=======+========+===========+=======+
-   | 0     | MARK   | ``mark``  | 0x2a  |
-   +-------+--------+-----------+-------+
-   | 1     | COUNT                      |
-   +-------+--------+-----------+-------+
-   | 2     | QUEUE  | ``queue`` | 10    |
-   +-------+--------+-----------+-------+
-   | 3     | END                        |
-   +-------+----------------------------+
+   +-------+--------+------------+-------+
+   | Index | Action | Field      | Value |
+   +=======+========+============+=======+
+   | 0     | MARK   | ``mark``   | 0x2a  |
+   +-------+--------+------------+-------+
+   | 1     | COUNT  | ``shared`` | 0     |
+   |       |        +------------+-------+
+   |       |        | ``id``     | 0     |
+   +-------+--------+------------+-------+
+   | 2     | QUEUE  | ``queue``  | 10    |
+   +-------+--------+------------+-------+
+   | 3     | END                         |
+   +-------+-----------------------------+
 
 |
 
@@ -1516,23 +1518,36 @@ Drop packets.
 Action: ``COUNT``
 ^^^^^^^^^^^^^^^^^
 
-Enables counters for this rule.
+Adds a counter action to a matched flow.
+
+If more than one count action is specified in a single flow rule, then each
+action must specify a unique id.
 
-These counters can be retrieved and reset through ``rte_flow_query()``, see
+Counters can be retrieved and reset through ``rte_flow_query()``, see
 ``struct rte_flow_query_count``.
 
-- Counters can be retrieved with ``rte_flow_query()``.
-- No configurable properties.
+The shared flag indicates whether the counter is unique to the flow rule the
+action is specified with, or whether it is a shared counter.
+
+For a count action with the shared flag set, then then a global device
+namespace is assumed for the counter id, so that any matched flow rules

using

doc/guides/prog_guide/rte_flow.rst +4 -0
+a count action with the same counter id on the same port will contribute to
+that counter.
+
+For ports within the same switch domain then the counter id namespace

extends

doc/guides/prog_guide/rte_flow.rst +10 -7
+to all ports within that switch domain.
 
 .. _table_rte_flow_action_count:
 
 .. table:: COUNT
 
-   +---------------+
-   | Field         |
-   +===============+
-   | no properties |
-   +---------------+
+   +------------+---------------------+
+   | Field      | Value               |
+   +============+=====================+
+   | ``shared`` | shared counter flag |
+   +------------+---------------------+
+   | ``id``     | counter id          |
+   +------------+---------------------+
 
 Query structure to retrieve and reset flow rule counters:
@@ -2282,7 +2297,7 @@ definition.
    int
    rte_flow_query(uint16_t port_id,
                   struct rte_flow *flow,
-                  enum rte_flow_action_type action,
+                  const struct rte_flow_action *action,
                   void *data,
                   struct rte_flow_error *error);
 
@@ -2290,7 +2305,7 @@ Arguments:
 
 - ``port_id``: port identifier of Ethernet device.
 - ``flow``: flow rule handle to query.
-- ``action``: action type to query.
+- ``action``: action to query, this must match prototype from flow rule.
 - ``data``: pointer to storage for the associated query data type.
 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
   this structure in case of error only.
drivers/net/bonding/rte_eth_bond_flow.c +1 -0
index 8093c04f5..31e4bcaeb 100644
@@ -152,6 +152,7 @@ bond_flow_flush(struct rte_eth_dev *dev, struct
 rte_flow_error *err)
 
 static int
 bond_flow_query_count(struct rte_eth_dev *dev, struct rte_flow *flow,
+		      const struct rte_flow_action *action,
 		      struct rte_flow_query_count *count,
 		      struct rte_flow_error *err)

{

drivers/net/bonding/rte_eth_bond_flow.c +1 -1
@@ -165,7 +166,7 @@ bond_flow_query_count(struct rte_eth_dev *dev,
 struct rte_flow *flow,
 	rte_memcpy(&slave_count, count, sizeof(slave_count));
 	for (i = 0; i < internals->slave_count; i++) {
 		ret = rte_flow_query(internals->slaves[i].port_id,
-				     flow->flows[i],
 RTE_FLOW_ACTION_TYPE_COUNT,
+				     flow->flows[i], action,
 				     &slave_count, err);
drivers/net/bonding/rte_eth_bond_flow.c +3 -3
 		if (unlikely(ret != 0)) {
 			RTE_BOND_LOG(ERR, "Failed to query flow on"
@@ -182,12 +183,12 @@ bond_flow_query_count(struct rte_eth_dev *dev,
 struct rte_flow *flow,
 
 static int
 bond_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
-		enum rte_flow_action_type type, void *arg,
+		const struct rte_flow_action *action, void *arg,
 		struct rte_flow_error *err)
 {
-	switch (type) {
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
-		return bond_flow_query_count(dev, flow, arg, err);
+		return bond_flow_query_count(dev, flow, action, arg, err);
 	default:
 		return rte_flow_error_set(err, ENOTSUP,

RTE_FLOW_ERROR_TYPE_ACTION,
arg,

drivers/net/failsafe/failsafe_flow.c +2 -2
index a97f4075d..bfe42fcee 100644
@@ -174,7 +174,7 @@ fs_flow_flush(struct rte_eth_dev *dev,
 static int
 fs_flow_query(struct rte_eth_dev *dev,
 	      struct rte_flow *flow,
-	      enum rte_flow_action_type type,
+	      const struct rte_flow_action *action,
 	      void *arg,
 	      struct rte_flow_error *error)
 {
@@ -185,7 +185,7 @@ fs_flow_query(struct rte_eth_dev *dev,
 	if (sdev != NULL) {
 		int ret = rte_flow_query(PORT_ID(sdev),
 					 flow->flows[SUB_ID(sdev)],
-					 type, arg, error);
+					 action, arg, error);
 
 		if ((ret = fs_err(sdev, ret))) {
 			fs_unlock(dev, 0);
lib/librte_ether/rte_flow.c +1 -1
index 4f94ac9b5..7947529da 100644
@@ -233,7 +233,7 @@ rte_flow_flush(uint16_t port_id,
 int
 rte_flow_query(uint16_t port_id,
 	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
 	       void *data,
 	       struct rte_flow_error *error)
 {
lib/librte_ether/rte_flow.h +17 -1
index d390bbf5a..f8ba71cdb 100644
@@ -1314,7 +1314,7 @@ enum rte_flow_action_type {
 	 * These counters can be retrieved and reset through
 rte_flow_query(),
 	 * see struct rte_flow_query_count.
 	 *
-	 * No associated configuration structure.
+	 * See struct rte_flow_action_count.
 	 */
 	RTE_FLOW_ACTION_TYPE_COUNT,
@@ -1546,6 +1546,38 @@ struct rte_flow_action_queue {
 	uint16_t index; /**< Queue index to use. */
 };
 
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_COUNT
+ *
+ * Adds a counter action to a matched flow.
+ *
+ * If more than one count action is specified in a single flow rule, then each
+ * action must specify a unique id.
+ *
+ * Counters can be retrieved and reset through ``rte_flow_query()``, see
+ * ``struct rte_flow_query_count``.
+ *
+ * The shared flag indicates whether the counter is unique to the flow rule

the
+ * action is specified with, or whether it is a shared counter.
+ *
+ * For a count action with the shared flag set, then then a global device
+ * namespace is assumed for the counter id, so that any matched flow rules using
+ * a count action with the same counter id on the same port will contribute to
+ * that counter.
+ *
+ * For ports within the same switch domain then the counter id namespace extends
+ * to all ports within that switch domain.
+ */

lib/librte_ether/rte_flow.h +8 -2
+struct rte_flow_action_count {
+	uint32_t shared:1; /**< Share counter ID with other flow rules. */
+	uint32_t reserved:31; /**< Reserved, must be zero. */
+	uint32_t id; /**< Counter ID. */
+};
+
 /**
  * RTE_FLOW_ACTION_TYPE_COUNT (query)
  *
@@ -2044,7 +2076,7 @@ rte_flow_flush(uint16_t port_id,
  * @param flow
  *   Flow rule handle to query.
  * @param action
- *   Action type to query.
+ *   Action definition as defined in original flow rule.
  * @param[in, out] data
  *   Pointer to storage for the associated query data type.
  * @param[out] error
@@ -2057,7 +2089,7 @@ rte_flow_flush(uint16_t port_id,
 int
 rte_flow_query(uint16_t port_id,
 	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
 	       void *data,
 	       struct rte_flow_error *error);
 
lib/librte_ether/rte_flow_driver.h +1 -2
index 3800310ba..1c90c600d 100644
@@ -88,7 +88,7 @@ struct rte_flow_ops {
 	int (*query)
 		(struct rte_eth_dev *,
 		 struct rte_flow *,
-		 enum rte_flow_action_type,
+		 const struct rte_flow_action *,
 		 void *,
 		 struct rte_flow_error *);
 	/** See rte_flow_isolate(). */
--

2.14.3

#7 lore raw

Re: [PATCH v6 4/4] ethdev: add shared counter support to rte_flow

Hi,

PSB

Ori

Quoted 12 lines

-----Original Message-----
From: Ferruh Yigit [mailto:[email protected]]
Sent: Thursday, April 26, 2018 5:28 PM
To: Ori Kam <[email protected]>; Declan Doherty <[email protected]>; [email protected]; Matan Azrad <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 4/4] ethdev: add shared counter support to rte_flow

Quoted 2 lines · Ori Kam

Hi Declan,

Quoted 8 lines
Quoted 2 lines

You are changing API (port_flow_query) which is in use in both MLX5 and MLX4 this results in breaking the build.

Hi Ori,

Do you mean "rte_flow_query"? port_flow_query() is a function in testpmd, how mlx is using it?

My bad let me be clearer.
MLX5 and MLX4 are implementing the rte_flow_ops query function.
This patch changes the prototype for the query function which results in compilation error and should also result in some change in the MLX5 and MLX4 implementation.

Quoted 421 lines
Quoted 32 lines

Best,
Ori

Quoted 28 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Thursday, April 26, 2018 3:08 PM
To: [email protected]
Cc: Ferruh Yigit <[email protected]>; Declan Doherty <[email protected]>
Subject: [dpdk-dev] [PATCH v6 4/4] ethdev: add shared counter support to rte_flow

Add rte_flow_action_count action data structure to enable shared counters across multiple flows on a single port or across multiple flows on multiple ports within the same switch domain. Also this enables multiple count actions to be specified in a single flow action.

This patch also modifies the existing rte_flow_query API to take the rte_flow_action structure as an input parameter instead of the rte_flow_action_type enumeration to allow querying a specific action from a flow rule when multiple actions of the same type are specified.

This patch also contains updates for the bonding and failsafe PMDs and testpmd application which are affected by this API change.

---
 app/test-pmd/cmdline_flow.c             |  6 ++--
 app/test-pmd/config.c                   | 15 +++++----
 app/test-pmd/testpmd.h                  |  2 +-
 doc/guides/prog_guide/rte_flow.rst      | 59 +++++++++++++++++++++--

----

Quoted 46 lines
Quoted 46 lines

------

 drivers/net/bonding/rte_eth_bond_flow.c |  9 ++---
 drivers/net/failsafe/failsafe_flow.c    |  4 +--
 lib/librte_ether/rte_flow.c             |  2 +-
 lib/librte_ether/rte_flow.h             | 38 +++++++++++++++++++--
 lib/librte_ether/rte_flow_driver.h      |  2 +-
 9 files changed, 93 insertions(+), 44 deletions(-)
(quoted diff) +0 -0

b/app/test-pmd/cmdline_flow.c index 1ac04a0ab..5754e7858 100644

app/test-pmd/cmdline_flow.c +2 -2
@@ -420,7 +420,7 @@ struct buffer {
 		} destroy; /**< Destroy arguments. */
 		struct {
 			uint32_t rule;
-			enum rte_flow_action_type action;
+			struct rte_flow_action action;
 		} query; /**< Query arguments. */
 		struct {
 			uint32_t *group;
@@ -1101,7 +1101,7 @@ static const struct token token_list[] = {
 		.next = NEXT(NEXT_ENTRY(QUERY_ACTION),
 			     NEXT_ENTRY(RULE_ID),
 			     NEXT_ENTRY(PORT_ID)),
-		.args = ARGS(ARGS_ENTRY(struct buffer, args.query.action),
+		.args = ARGS(ARGS_ENTRY(struct buffer,
 args.query.action.type),
 			     ARGS_ENTRY(struct buffer, args.query.rule),
 			     ARGS_ENTRY(struct buffer, port)),
app/test-pmd/cmdline_flow.c +1 -1
 		.call = parse_query,
@@ -3842,7 +3842,7 @@ cmd_flow_parsed(const struct buffer *in)
 		break;
 	case QUERY:
 		port_flow_query(in->port, in->args.query.rule,
-				in->args.query.action);
+				&in->args.query.action);
 		break;
 	case LIST:
 		port_flow_list(in->port, in->args.list.group_n, diff --git

a/app/test-pmd/config.c b/app/test-pmd/config.c index 0f2425229..cd6102dfc 100644

app/test-pmd/config.c +0 -0
@@ -1452,7 +1452,7 @@ port_flow_flush(portid_t port_id)
 /** Query a flow rule. */
Quoted 8 lines

app/test-pmd/config.c port_flow_query(portid_t port_id, uint32_t

Quoted 8 lines
app/test-pmd/config.c +1 -1
 int
 port_flow_query(portid_t port_id, uint32_t rule,
-		enum rte_flow_action_type action)
+		const struct rte_flow_action *action)
 {
 	struct rte_flow_error error;
 	struct rte_port *port;
@@ -1474,15 +1474,16 @@ port_flow_query(portid_t port_id, uint32_t

rule,

Quoted 22 lines
Quoted 22 lines
app/test-pmd/config.c +5 -5
 		return -ENOENT;
 	}
 	if ((unsigned int)action >= RTE_DIM(flow_action) ||
-	    !flow_action[action].name)
+	    !flow_action[action->type].name)
 		name = "unknown";
 	else
-		name = flow_action[action].name;
-	switch (action) {
+		name = flow_action[action->type].name;
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		break;
 	default:
-		printf("Cannot query action type %d (%s)\n", action, name);
+		printf("Cannot query action type %d (%s)\n",
+			action->type, name);
 		return -ENOTSUP;
 	}
 	/* Poisoning to make sure PMDs update it in case of error. */ @@
-1490,7 +1491,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
 	memset(&query, 0, sizeof(query));
Quoted 8 lines

app/test-pmd/config.c port_flow_query(portid_t port_id, uint32_t

Quoted 8 lines
app/test-pmd/config.c +1 -1
 	if (rte_flow_query(port_id, pf->flow, action, &query, &error))
 		return port_flow_complain(&error);
-	switch (action) {
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		printf("%s:\n"
 		       " hits_set: %u\n"
@@ -1505,7 +1506,7 @@ port_flow_query(portid_t port_id, uint32_t

rule,

Quoted 135 lines
Quoted 135 lines
app/test-pmd/config.c +1 -1
 		break;
 	default:
 		printf("Cannot display result for action type %d (%s)\n",
-		       action, name);
+		       action->type, name);
 		break;
 	}
 	return 0;
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

a33b525e2..1af87b8f4 100644

app/test-pmd/testpmd.h +0 -0
@@ -620,7 +620,7 @@ int port_flow_create(portid_t port_id,  int

port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule); int port_flow_flush(portid_t port_id); int port_flow_query(portid_t port_id, uint32_t rule,

app/test-pmd/testpmd.h +1 -1
-		    enum rte_flow_action_type action);
+		    const struct rte_flow_action *action);
 void port_flow_list(portid_t port_id, uint32_t n, const uint32_t

*group); int port_flow_isolate(portid_t port_id, int set);

doc/guides/prog_guide/rte_flow.rst +17 -13
index 301f8762e..88bfc87eb 100644
@@ -1277,17 +1277,19 @@ Actions are performed in list order:
 
 .. table:: Mark, count then redirect
 
-   +-------+--------+-----------+-------+
-   | Index | Action | Field     | Value |
-   +=======+========+===========+=======+
-   | 0     | MARK   | ``mark``  | 0x2a  |
-   +-------+--------+-----------+-------+
-   | 1     | COUNT                      |
-   +-------+--------+-----------+-------+
-   | 2     | QUEUE  | ``queue`` | 10    |
-   +-------+--------+-----------+-------+
-   | 3     | END                        |
-   +-------+----------------------------+
+   +-------+--------+------------+-------+
+   | Index | Action | Field      | Value |
+   +=======+========+============+=======+
+   | 0     | MARK   | ``mark``   | 0x2a  |
+   +-------+--------+------------+-------+
+   | 1     | COUNT  | ``shared`` | 0     |
+   |       |        +------------+-------+
+   |       |        | ``id``     | 0     |
+   +-------+--------+------------+-------+
+   | 2     | QUEUE  | ``queue``  | 10    |
+   +-------+--------+------------+-------+
+   | 3     | END                         |
+   +-------+-----------------------------+
 
 |
 
@@ -1516,23 +1518,36 @@ Drop packets.
 Action: ``COUNT``
 ^^^^^^^^^^^^^^^^^
 
-Enables counters for this rule.
+Adds a counter action to a matched flow.
+
+If more than one count action is specified in a single flow rule,
+then each action must specify a unique id.
 
-These counters can be retrieved and reset through

``rte_flow_query()``, see

doc/guides/prog_guide/rte_flow.rst +8 -2
+Counters can be retrieved and reset through ``rte_flow_query()``,
+see
 ``struct rte_flow_query_count``.
 
-- Counters can be retrieved with ``rte_flow_query()``.
-- No configurable properties.
+The shared flag indicates whether the counter is unique to the flow
+rule the action is specified with, or whether it is a shared counter.
+
+For a count action with the shared flag set, then then a global
+device namespace is assumed for the counter id, so that any matched
+flow rules

using

doc/guides/prog_guide/rte_flow.rst +5 -0
+a count action with the same counter id on the same port will
+contribute to that counter.
+
+For ports within the same switch domain then the counter id
+namespace

extends

doc/guides/prog_guide/rte_flow.rst +10 -7
+to all ports within that switch domain.
 
 .. _table_rte_flow_action_count:
 
 .. table:: COUNT
 
-   +---------------+
-   | Field         |
-   +===============+
-   | no properties |
-   +---------------+
+   +------------+---------------------+
+   | Field      | Value               |
+   +============+=====================+
+   | ``shared`` | shared counter flag |
+   +------------+---------------------+
+   | ``id``     | counter id          |
+   +------------+---------------------+
 
 Query structure to retrieve and reset flow rule counters:
@@ -2282,7 +2297,7 @@ definition.
    int
    rte_flow_query(uint16_t port_id,
                   struct rte_flow *flow,
-                  enum rte_flow_action_type action,
+                  const struct rte_flow_action *action,
                   void *data,
                   struct rte_flow_error *error);
 
@@ -2290,7 +2305,7 @@ Arguments:
 
 - ``port_id``: port identifier of Ethernet device.
 - ``flow``: flow rule handle to query.
-- ``action``: action type to query.
+- ``action``: action to query, this must match prototype from flow rule.
 - ``data``: pointer to storage for the associated query data type.
 - ``error``: perform verbose error reporting if not NULL. PMDs initialize
   this structure in case of error only.
drivers/net/bonding/rte_eth_bond_flow.c +0 -0
index 8093c04f5..31e4bcaeb 100644
@@ -152,6 +152,7 @@ bond_flow_flush(struct rte_eth_dev *dev, struct
 rte_flow_error *err)
 
Quoted 8 lines

drivers/net/bonding/rte_eth_bond_flow.c bond_flow_query_count(struct rte_eth_dev

Quoted 8 lines
drivers/net/bonding/rte_eth_bond_flow.c +1 -0
 static int
 bond_flow_query_count(struct rte_eth_dev *dev, struct rte_flow
 *flow,
+		      const struct rte_flow_action *action,
 		      struct rte_flow_query_count *count,
drivers/net/bonding/rte_eth_bond_flow.c +0 -0
 		      struct rte_flow_error *err)
 {
@@ -165,7 +166,7 @@ bond_flow_query_count(struct rte_eth_dev

*dev,

Quoted 11 lines

drivers/net/bonding/rte_eth_bond_flow.c bond_flow_query_count(struct rte_eth_dev

Quoted 11 lines
drivers/net/bonding/rte_eth_bond_flow.c +1 -1
 struct rte_flow *flow,
 	rte_memcpy(&slave_count, count, sizeof(slave_count));
 	for (i = 0; i < internals->slave_count; i++) {
 		ret = rte_flow_query(internals->slaves[i].port_id,
-				     flow->flows[i],
 RTE_FLOW_ACTION_TYPE_COUNT,
+				     flow->flows[i], action,
 				     &slave_count, err);
drivers/net/bonding/rte_eth_bond_flow.c +0 -0
 		if (unlikely(ret != 0)) {
 			RTE_BOND_LOG(ERR, "Failed to query flow on"
@@ -182,12 +183,12 @@ bond_flow_query_count(struct rte_eth_dev

*dev,

Quoted 146 lines
Quoted 145 lines
drivers/net/bonding/rte_eth_bond_flow.c +3 -3
 struct rte_flow *flow,
 
 static int
 bond_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
-		enum rte_flow_action_type type, void *arg,
+		const struct rte_flow_action *action, void *arg,
 		struct rte_flow_error *err)
 {
-	switch (type) {
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
-		return bond_flow_query_count(dev, flow, arg, err);
+		return bond_flow_query_count(dev, flow, action, arg, err);
 	default:
 		return rte_flow_error_set(err, ENOTSUP,

RTE_FLOW_ERROR_TYPE_ACTION,
arg,

drivers/net/failsafe/failsafe_flow.c +1 -1
index a97f4075d..bfe42fcee 100644
@@ -174,7 +174,7 @@ fs_flow_flush(struct rte_eth_dev *dev,  static
 int  fs_flow_query(struct rte_eth_dev *dev,
 	      struct rte_flow *flow,
-	      enum rte_flow_action_type type,
+	      const struct rte_flow_action *action,
 	      void *arg,
 	      struct rte_flow_error *error)  { @@ -185,7 +185,7 @@
 fs_flow_query(struct rte_eth_dev *dev,
 	if (sdev != NULL) {
drivers/net/failsafe/failsafe_flow.c +1 -1
 		int ret = rte_flow_query(PORT_ID(sdev),
 					 flow->flows[SUB_ID(sdev)],
-					 type, arg, error);
+					 action, arg, error);
 
 		if ((ret = fs_err(sdev, ret))) {
 			fs_unlock(dev, 0);
(quoted diff) +0 -0

b/lib/librte_ether/rte_flow.c index 4f94ac9b5..7947529da 100644

lib/librte_ether/rte_flow.c +1 -1
@@ -233,7 +233,7 @@ rte_flow_flush(uint16_t port_id,  int
 rte_flow_query(uint16_t port_id,
 	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
 	       void *data,
 	       struct rte_flow_error *error)  { diff --git

a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index d390bbf5a..f8ba71cdb 100644

lib/librte_ether/rte_flow.h +20 -1
@@ -1314,7 +1314,7 @@ enum rte_flow_action_type {
 	 * These counters can be retrieved and reset through
 rte_flow_query(),
 	 * see struct rte_flow_query_count.
 	 *
-	 * No associated configuration structure.
+	 * See struct rte_flow_action_count.
 	 */
 	RTE_FLOW_ACTION_TYPE_COUNT,
@@ -1546,6 +1546,38 @@ struct rte_flow_action_queue {
 	uint16_t index; /**< Queue index to use. */  };
 
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_COUNT
+ *
+ * Adds a counter action to a matched flow.
+ *
+ * If more than one count action is specified in a single flow rule,
+then each
+ * action must specify a unique id.
+ *
+ * Counters can be retrieved and reset through ``rte_flow_query()``,
+see
+ * ``struct rte_flow_query_count``.
+ *
+ * The shared flag indicates whether the counter is unique to the
+flow rule

the
+ * action is specified with, or whether it is a shared counter.
+ *
+ * For a count action with the shared flag set, then then a global
+ device
+ * namespace is assumed for the counter id, so that any matched flow
+ rules
using
+ * a count action with the same counter id on the same port will
+ contribute
to
+ * that counter.
+ *
+ * For ports within the same switch domain then the counter id
+ namespace
extends
+ * to all ports within that switch domain.
+ */

lib/librte_ether/rte_flow.h +8 -2
+struct rte_flow_action_count {
+	uint32_t shared:1; /**< Share counter ID with other flow rules. */
+	uint32_t reserved:31; /**< Reserved, must be zero. */
+	uint32_t id; /**< Counter ID. */
+};
+
 /**
  * RTE_FLOW_ACTION_TYPE_COUNT (query)
  *
@@ -2044,7 +2076,7 @@ rte_flow_flush(uint16_t port_id,
  * @param flow
  *   Flow rule handle to query.
  * @param action
- *   Action type to query.
+ *   Action definition as defined in original flow rule.
  * @param[in, out] data
  *   Pointer to storage for the associated query data type.
  * @param[out] error
@@ -2057,7 +2089,7 @@ rte_flow_flush(uint16_t port_id,  int
 rte_flow_query(uint16_t port_id,
 	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
 	       void *data,
 	       struct rte_flow_error *error);
 
lib/librte_ether/rte_flow_driver.h +1 -2
index 3800310ba..1c90c600d 100644
@@ -88,7 +88,7 @@ struct rte_flow_ops {
 	int (*query)
 		(struct rte_eth_dev *,
 		 struct rte_flow *,
-		 enum rte_flow_action_type,
+		 const struct rte_flow_action *,
 		 void *,
 		 struct rte_flow_error *);
 	/** See rte_flow_isolate(). */
--

2.14.3

#8 lore raw

Re: [PATCH v6 4/4] ethdev: add shared counter support to rte_flow

Quoted 22 lines · Ori Kam

Hi,

PSB

Ori

Quoted 17 lines

-----Original Message-----
From: Ferruh Yigit [mailto:[email protected]]
Sent: Thursday, April 26, 2018 5:28 PM
To: Ori Kam <[email protected]>; Declan Doherty <[email protected]>; [email protected]; Matan Azrad <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 4/4] ethdev: add shared counter support to rte_flow

Quoted 4 lines · Ori Kam

Hi Declan,

You are changing API (port_flow_query) which is in use in both MLX5 and MLX4 this results in breaking the build.

Hi Ori,

Quoted 10 lines
Quoted 3 lines

Do you mean "rte_flow_query"? port_flow_query() is a function in testpmd, how mlx is using it?

My bad let me be clearer.
MLX5 and MLX4 are implementing the rte_flow_ops query function.
This patch changes the prototype for the query function which results in compilation error and should also result in some change in the MLX5 and MLX4 implementation.

Hey Ori, I don't see any references to the query in MLX4 code.

static const struct rte_flow_ops mlx4_flow_ops = {
.validate = mlx4_flow_validate, .create = mlx4_flow_create, .destroy = mlx4_flow_destroy, .flush = mlx4_flow_flush,
.isolate = mlx4_flow_isolate,
};

I just looking at fixing the MLX5 code compilation, I missed that due to the function being ifdefined out with HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT the flag and I missed the reference.

Quoted 422 lines
Quoted 421 lines
Quoted 32 lines

Best,
Ori

Quoted 28 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Thursday, April 26, 2018 3:08 PM
To: [email protected]
Cc: Ferruh Yigit <[email protected]>; Declan Doherty <[email protected]>
Subject: [dpdk-dev] [PATCH v6 4/4] ethdev: add shared counter support to rte_flow

Add rte_flow_action_count action data structure to enable shared counters across multiple flows on a single port or across multiple flows on multiple ports within the same switch domain. Also this enables multiple count actions to be specified in a single flow action.

This patch also modifies the existing rte_flow_query API to take the rte_flow_action structure as an input parameter instead of the rte_flow_action_type enumeration to allow querying a specific action from a flow rule when multiple actions of the same type are specified.

This patch also contains updates for the bonding and failsafe PMDs and testpmd application which are affected by this API change.

---
  app/test-pmd/cmdline_flow.c             |  6 ++--
  app/test-pmd/config.c                   | 15 +++++----
  app/test-pmd/testpmd.h                  |  2 +-
  doc/guides/prog_guide/rte_flow.rst      | 59 +++++++++++++++++++++--

----

Quoted 46 lines
Quoted 46 lines

------

  drivers/net/bonding/rte_eth_bond_flow.c |  9 ++---
  drivers/net/failsafe/failsafe_flow.c    |  4 +--
  lib/librte_ether/rte_flow.c             |  2 +-
  lib/librte_ether/rte_flow.h             | 38 +++++++++++++++++++--
  lib/librte_ether/rte_flow_driver.h      |  2 +-
  9 files changed, 93 insertions(+), 44 deletions(-)
(quoted diff) +0 -0

b/app/test-pmd/cmdline_flow.c index 1ac04a0ab..5754e7858 100644

app/test-pmd/cmdline_flow.c +2 -2
@@ -420,7 +420,7 @@ struct buffer {
  		} destroy; /**< Destroy arguments. */
  		struct {
  			uint32_t rule;
-			enum rte_flow_action_type action;
+			struct rte_flow_action action;
  		} query; /**< Query arguments. */
  		struct {
  			uint32_t *group;
@@ -1101,7 +1101,7 @@ static const struct token token_list[] = {
  		.next = NEXT(NEXT_ENTRY(QUERY_ACTION),
  			     NEXT_ENTRY(RULE_ID),
  			     NEXT_ENTRY(PORT_ID)),
-		.args = ARGS(ARGS_ENTRY(struct buffer, args.query.action),
+		.args = ARGS(ARGS_ENTRY(struct buffer,
 args.query.action.type),
  			     ARGS_ENTRY(struct buffer, args.query.rule),
  			     ARGS_ENTRY(struct buffer, port)),

.call = parse_query,

app/test-pmd/cmdline_flow.c +1 -1
@@ -3842,7 +3842,7 @@ cmd_flow_parsed(const struct buffer *in)
  		break;
  	case QUERY:
  		port_flow_query(in->port, in->args.query.rule,
-				in->args.query.action);
+				&in->args.query.action);
  		break;
  	case LIST:
  		port_flow_list(in->port, in->args.list.group_n, diff --git

a/app/test-pmd/config.c b/app/test-pmd/config.c index 0f2425229..cd6102dfc 100644

app/test-pmd/config.c +0 -0
@@ -1452,7 +1452,7 @@ port_flow_flush(portid_t port_id)
  /** Query a flow rule. */
Quoted 8 lines

app/test-pmd/config.c port_flow_query(portid_t port_id, uint32_t

Quoted 8 lines
app/test-pmd/config.c +1 -1
  int
  port_flow_query(portid_t port_id, uint32_t rule,
-		enum rte_flow_action_type action)
+		const struct rte_flow_action *action)
  {
  	struct rte_flow_error error;
  	struct rte_port *port;
@@ -1474,15 +1474,16 @@ port_flow_query(portid_t port_id, uint32_t

rule,

Quoted 22 lines
Quoted 22 lines
app/test-pmd/config.c +5 -5
  		return -ENOENT;
  	}
  	if ((unsigned int)action >= RTE_DIM(flow_action) ||
-	    !flow_action[action].name)
+	    !flow_action[action->type].name)
  		name = "unknown";
  	else
-		name = flow_action[action].name;
-	switch (action) {
+		name = flow_action[action->type].name;
+	switch (action->type) {
  	case RTE_FLOW_ACTION_TYPE_COUNT:
  		break;
  	default:
-		printf("Cannot query action type %d (%s)\n", action, name);
+		printf("Cannot query action type %d (%s)\n",
+			action->type, name);
  		return -ENOTSUP;
  	}
  	/* Poisoning to make sure PMDs update it in case of error. */ @@
-1490,7 +1491,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
  	memset(&query, 0, sizeof(query));
Quoted 8 lines

app/test-pmd/config.c port_flow_query(portid_t port_id, uint32_t

Quoted 8 lines
  	if (rte_flow_query(port_id, pf->flow, action, &query, &error))
  		return port_flow_complain(&error);
app/test-pmd/config.c +1 -1
-	switch (action) {
+	switch (action->type) {
  	case RTE_FLOW_ACTION_TYPE_COUNT:
  		printf("%s:\n"
  		       " hits_set: %u\n"
@@ -1505,7 +1506,7 @@ port_flow_query(portid_t port_id, uint32_t

rule,

Quoted 135 lines
Quoted 135 lines
app/test-pmd/config.c +1 -1
  		break;
  	default:
  		printf("Cannot display result for action type %d (%s)\n",
-		       action, name);
+		       action->type, name);
  		break;
  	}
  	return 0;
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

a33b525e2..1af87b8f4 100644

app/test-pmd/testpmd.h +0 -0
@@ -620,7 +620,7 @@ int port_flow_create(portid_t port_id,  int

port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule); int port_flow_flush(portid_t port_id); int port_flow_query(portid_t port_id, uint32_t rule,

app/test-pmd/testpmd.h +1 -1
-		    enum rte_flow_action_type action);
+		    const struct rte_flow_action *action);
  void port_flow_list(portid_t port_id, uint32_t n, const uint32_t

*group); int port_flow_isolate(portid_t port_id, int set);

doc/guides/prog_guide/rte_flow.rst +17 -13
index 301f8762e..88bfc87eb 100644
@@ -1277,17 +1277,19 @@ Actions are performed in list order:
 
  .. table:: Mark, count then redirect
 
-   +-------+--------+-----------+-------+
-   | Index | Action | Field     | Value |
-   +=======+========+===========+=======+
-   | 0     | MARK   | ``mark``  | 0x2a  |
-   +-------+--------+-----------+-------+
-   | 1     | COUNT                      |
-   +-------+--------+-----------+-------+
-   | 2     | QUEUE  | ``queue`` | 10    |
-   +-------+--------+-----------+-------+
-   | 3     | END                        |
-   +-------+----------------------------+
+   +-------+--------+------------+-------+
+   | Index | Action | Field      | Value |
+   +=======+========+============+=======+
+   | 0     | MARK   | ``mark``   | 0x2a  |
+   +-------+--------+------------+-------+
+   | 1     | COUNT  | ``shared`` | 0     |
+   |       |        +------------+-------+
+   |       |        | ``id``     | 0     |
+   +-------+--------+------------+-------+
+   | 2     | QUEUE  | ``queue``  | 10    |
+   +-------+--------+------------+-------+
+   | 3     | END                         |
+   +-------+-----------------------------+
 
  |
 
@@ -1516,23 +1518,36 @@ Drop packets.
  Action: ``COUNT``
  ^^^^^^^^^^^^^^^^^
 
-Enables counters for this rule.
+Adds a counter action to a matched flow.
+
+If more than one count action is specified in a single flow rule,
+then each action must specify a unique id.
 
-These counters can be retrieved and reset through

``rte_flow_query()``, see

doc/guides/prog_guide/rte_flow.rst +8 -2
+Counters can be retrieved and reset through ``rte_flow_query()``,
+see
  ``struct rte_flow_query_count``.
 
-- Counters can be retrieved with ``rte_flow_query()``.
-- No configurable properties.
+The shared flag indicates whether the counter is unique to the flow
+rule the action is specified with, or whether it is a shared counter.
+
+For a count action with the shared flag set, then then a global
+device namespace is assumed for the counter id, so that any matched
+flow rules

using

doc/guides/prog_guide/rte_flow.rst +5 -0
+a count action with the same counter id on the same port will
+contribute to that counter.
+
+For ports within the same switch domain then the counter id
+namespace

extends

doc/guides/prog_guide/rte_flow.rst +10 -7
+to all ports within that switch domain.
 
  .. _table_rte_flow_action_count:
 
  .. table:: COUNT
 
-   +---------------+
-   | Field         |
-   +===============+
-   | no properties |
-   +---------------+
+   +------------+---------------------+
+   | Field      | Value               |
+   +============+=====================+
+   | ``shared`` | shared counter flag |
+   +------------+---------------------+
+   | ``id``     | counter id          |
+   +------------+---------------------+
 
  Query structure to retrieve and reset flow rule counters:
@@ -2282,7 +2297,7 @@ definition.
     int
     rte_flow_query(uint16_t port_id,
                    struct rte_flow *flow,
-                  enum rte_flow_action_type action,
+                  const struct rte_flow_action *action,
                    void *data,
                    struct rte_flow_error *error);
 
@@ -2290,7 +2305,7 @@ Arguments:
 
  - ``port_id``: port identifier of Ethernet device.
  - ``flow``: flow rule handle to query.
-- ``action``: action type to query.
+- ``action``: action to query, this must match prototype from flow rule.
  - ``data``: pointer to storage for the associated query data type.
  - ``error``: perform verbose error reporting if not NULL. PMDs initialize
    this structure in case of error only.
drivers/net/bonding/rte_eth_bond_flow.c +0 -0
index 8093c04f5..31e4bcaeb 100644
@@ -152,6 +152,7 @@ bond_flow_flush(struct rte_eth_dev *dev, struct
 rte_flow_error *err)
 
Quoted 8 lines

drivers/net/bonding/rte_eth_bond_flow.c bond_flow_query_count(struct rte_eth_dev

Quoted 8 lines
drivers/net/bonding/rte_eth_bond_flow.c +1 -0
  static int
  bond_flow_query_count(struct rte_eth_dev *dev, struct rte_flow
 *flow,
+		      const struct rte_flow_action *action,
  		      struct rte_flow_query_count *count,
  		      struct rte_flow_error *err)
  {
drivers/net/bonding/rte_eth_bond_flow.c +0 -0
@@ -165,7 +166,7 @@ bond_flow_query_count(struct rte_eth_dev

*dev,

Quoted 11 lines

drivers/net/bonding/rte_eth_bond_flow.c bond_flow_query_count(struct rte_eth_dev

Quoted 11 lines
drivers/net/bonding/rte_eth_bond_flow.c +1 -1
 struct rte_flow *flow,
  	rte_memcpy(&slave_count, count, sizeof(slave_count));
  	for (i = 0; i < internals->slave_count; i++) {
  		ret = rte_flow_query(internals->slaves[i].port_id,
-				     flow->flows[i],
 RTE_FLOW_ACTION_TYPE_COUNT,
+				     flow->flows[i], action,
  				     &slave_count, err);

if (unlikely(ret != 0)) {
RTE_BOND_LOG(ERR, "Failed to query flow on"

drivers/net/bonding/rte_eth_bond_flow.c +0 -0
@@ -182,12 +183,12 @@ bond_flow_query_count(struct rte_eth_dev

*dev,

Quoted 146 lines
Quoted 145 lines
drivers/net/bonding/rte_eth_bond_flow.c +3 -3
 struct rte_flow *flow,
 
  static int
  bond_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
-		enum rte_flow_action_type type, void *arg,
+		const struct rte_flow_action *action, void *arg,
  		struct rte_flow_error *err)
  {
-	switch (type) {
+	switch (action->type) {
  	case RTE_FLOW_ACTION_TYPE_COUNT:
-		return bond_flow_query_count(dev, flow, arg, err);
+		return bond_flow_query_count(dev, flow, action, arg, err);
  	default:
  		return rte_flow_error_set(err, ENOTSUP,

RTE_FLOW_ERROR_TYPE_ACTION,
arg,

drivers/net/failsafe/failsafe_flow.c +1 -1
index a97f4075d..bfe42fcee 100644
@@ -174,7 +174,7 @@ fs_flow_flush(struct rte_eth_dev *dev,  static
 int  fs_flow_query(struct rte_eth_dev *dev,
  	      struct rte_flow *flow,
-	      enum rte_flow_action_type type,
+	      const struct rte_flow_action *action,
  	      void *arg,
  	      struct rte_flow_error *error)  { @@ -185,7 +185,7 @@
 fs_flow_query(struct rte_eth_dev *dev,
  	if (sdev != NULL) {

int ret = rte_flow_query(PORT_ID(sdev),
flow->flows[SUB_ID(sdev)],

drivers/net/failsafe/failsafe_flow.c +1 -1
-					 type, arg, error);
+					 action, arg, error);
 
  		if ((ret = fs_err(sdev, ret))) {
  			fs_unlock(dev, 0);
(quoted diff) +0 -0

b/lib/librte_ether/rte_flow.c index 4f94ac9b5..7947529da 100644

lib/librte_ether/rte_flow.c +1 -1
@@ -233,7 +233,7 @@ rte_flow_flush(uint16_t port_id,  int
 rte_flow_query(uint16_t port_id,
  	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
  	       void *data,
  	       struct rte_flow_error *error)  { diff --git

a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index d390bbf5a..f8ba71cdb 100644

lib/librte_ether/rte_flow.h +20 -1
@@ -1314,7 +1314,7 @@ enum rte_flow_action_type {
  	 * These counters can be retrieved and reset through
 rte_flow_query(),
  	 * see struct rte_flow_query_count.
  	 *
-	 * No associated configuration structure.
+	 * See struct rte_flow_action_count.
  	 */
  	RTE_FLOW_ACTION_TYPE_COUNT,
@@ -1546,6 +1546,38 @@ struct rte_flow_action_queue {
  	uint16_t index; /**< Queue index to use. */  };
 
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_COUNT
+ *
+ * Adds a counter action to a matched flow.
+ *
+ * If more than one count action is specified in a single flow rule,
+then each
+ * action must specify a unique id.
+ *
+ * Counters can be retrieved and reset through ``rte_flow_query()``,
+see
+ * ``struct rte_flow_query_count``.
+ *
+ * The shared flag indicates whether the counter is unique to the
+flow rule

the
+ * action is specified with, or whether it is a shared counter.
+ *
+ * For a count action with the shared flag set, then then a global
+ device
+ * namespace is assumed for the counter id, so that any matched flow
+ rules
using
+ * a count action with the same counter id on the same port will
+ contribute
to
+ * that counter.
+ *
+ * For ports within the same switch domain then the counter id
+ namespace
extends
+ * to all ports within that switch domain.
+ */

lib/librte_ether/rte_flow.h +8 -2
+struct rte_flow_action_count {
+	uint32_t shared:1; /**< Share counter ID with other flow rules. */
+	uint32_t reserved:31; /**< Reserved, must be zero. */
+	uint32_t id; /**< Counter ID. */
+};
+
  /**
   * RTE_FLOW_ACTION_TYPE_COUNT (query)
   *
@@ -2044,7 +2076,7 @@ rte_flow_flush(uint16_t port_id,
   * @param flow
   *   Flow rule handle to query.
   * @param action
- *   Action type to query.
+ *   Action definition as defined in original flow rule.
   * @param[in, out] data
   *   Pointer to storage for the associated query data type.
   * @param[out] error
@@ -2057,7 +2089,7 @@ rte_flow_flush(uint16_t port_id,  int
 rte_flow_query(uint16_t port_id,
  	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
  	       void *data,
  	       struct rte_flow_error *error);
 
lib/librte_ether/rte_flow_driver.h +1 -2
index 3800310ba..1c90c600d 100644
@@ -88,7 +88,7 @@ struct rte_flow_ops {
  	int (*query)
  		(struct rte_eth_dev *,
  		 struct rte_flow *,
-		 enum rte_flow_action_type,
+		 const struct rte_flow_action *,
  		 void *,
  		 struct rte_flow_error *);
  	/** See rte_flow_isolate(). */
--

2.14.3

#9 lore raw

v7 cover ethdev: add shared counter support to rte_flow

In reply to Declan Doherty

This patchset contains the revised proposal to manage tunnel endpoints hardware accleration based on community feedback on RFC
(http://dpdk.org/ml/archives/dev/2017-December/084676.html). This proposal is purely enabled through rte_flow APIs with the additions of some new features which were previously implemented by the proposed rte_tep APIs which were proposed in the original RFC. This patchset ultimately aims to enable the configuration of inline data path encapsulation and decapsulation of tunnel endpoint network overlays on accelerated IO devices.

V2:
- Split new functions into separate patches, and add additional documentaiton.

V3:
- Extended the descriptio:wn of group counter in documentation.
- Renamed VTEP to TUNNEL.
- Fixed C99 syntax.

V4:
- Modify encap/decap actions to be protocol specific
- rename group action type to jump
- add mark flow item type in place of metadata flow/action types
- add count action data structure
- modify query API to accept rte_flow_action structure in place of rte_flow_actio_type enumeration to support specification and querying of multiple actions of the same type

V5:
- Documentation and comment updates
- Mark new API structures as experimental
- squash new function testpmd enablement into relevant patches.

V6:
- rebased to head of next-net
- fixed whitespace issues add in previous revision

V7:
- fix mlx5 compliation issue due to change in flow query API

The summary of the additions to the rte_flow are as follows:

- Add new flow actions RTE_RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_ENCAP and RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_DECAP to rte_flow to support specfication of encapsulation and decapsulation of VXLAN and NVGRE tunnels in hardware.
- Introduces support for the use of pipeline metadata in
the flow pattern definition and the population of metadata fields from flow actions using the MARK flow and action items.
- Add shared flag to counters to enable statistics to be kept on groups offlows such as all ingress/egress flows of a tunnel
- Adds jump_action to allow a flows to be redirected to a group within the device.

A high level summary of the proposed usage model is as follows:

1. Decapsulation

1.1. Decapsulation of tunnel outer headers and forward all traffic
to the same queue/s or port, would have the follow flows paramteters, sudo code used here.

struct rte_flow_attr attr = { .ingress = 1 };

struct rte_flow_item pattern[] = {
{ .type = RTE_FLOW_ITEM_TYPE_ETH, .spec = &eth_item }, { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item }, { .type = RTE_FLOW_ITEM_TYPE_UDP, .spec = &udp_item }, { .type = RTE_FLOW_ITEM_TYPE_VxLAN, .spec = &vxlan_item }, { .type = RTE_FLOW_ITEM_TYPE_END }
};

struct rte_flow_action actions[] = {
{ .type = RTE_FLOW_ACTION_TYPE_VXLAN_DECAP },
{ .type = RTE_FLOW_ACTION_TYPE_VF, .conf = &vf_action }, { .type = RTE_FLOW_ACTION_TYPE_END }
}

1.2.

Decapsulation of tunnel outer headers and matching on inner headers, and forwarding to the same queue/s or port.

1.2.1.

The same scenario as above but either the application or hardware requires configuration as 2 logically independent operations (viewing it as 2 logical tables). The first stage being the flow rule to define the pattern to match the tunnel and the action to decapsulate the packet, and the second stage stage table matches the inner header and defines the actions, forward to port etc.

flow rule for outer header on table 0

struct rte_flow_attr attr = { .ingress = 1, .table = 0 };

struct rte_flow_item pattern[] = {
{ .type = RTE_FLOW_ITEM_TYPE_ETH, .spec = &eth_item }, { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item }, { .type = RTE_FLOW_ITEM_TYPE_UDP, .spec = &udp_item }, { .type = RTE_FLOW_ITEM_TYPE_VxLAN, .spec = &vxlan_item }, { .type = RTE_FLOW_ITEM_TYPE_END }
};

struct rte_flow_item_count shared_couter = {
.shared = 1,
.id = {counter_id}
}

struct rte_flow_action actions[] = {
{ .type = RTE_FLOW_ACTION_TYPE_COUNT, .conf = &shared_counter }, { .type = RTE_FLOW_ACTION_TYPE_MARK, .conf = &mark_action }, { .type = RTE_FLOW_ACTION_TYPE_VXLAN_DECAP },
{
.type = RTE_FLOW_ACTION_TYPE_JUMP,
.conf = { .group = 1 }
},
{ .type = RTE_FLOW_ACTION_TYPE_END }
}

flow rule for inner header on table 1

struct rte_flow_attr attr = { .ingress = 1, .group = 1 };

struct rte_flow_item_mark mark_item = { id = {mark_id} };

struct rte_flow_item pattern[] = {
{ .type = RTE_FLOW_ITEM_TYPE_MARK, .spec = &mark_item }, { .type = RTE_FLOW_ITEM_TYPE_ETH, .spec = &eth_item }, { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item }, { .type = RTE_FLOW_ITEM_TYPE_TCP, .spec = &tcp_item }, { .type = RTE_FLOW_ITEM_TYPE_END }
};

struct rte_flow_action actions[] = {
{
.type = RTE_FLOW_ACTION_TYPE_PORT_ID,
.conf = &port_id_action = { port_id }
},
{ .type = RTE_FLOW_ACTION_TYPE_END }
}

Note that the mark action in the flow rule in group 0 is generating the value in the pipeline which is then used in as part as the flow pattern in group 1 to specify the exact flow to match against. In the case where exact match rules are being provided by the application explicitly then the MARK item value can be provided by the application in the flow pattern for the flow rule in group 1 also.

2. Encapsulation

Encapsulation of all traffic matching a specific flow pattern to a specified tunnel and egressing to a particular port.

struct rte_flow_attr attr = { .egress = 1 };

struct rte_flow_item pattern[] = {
{ .type = RTE_FLOW_ITEM_TYPE_ETH, .spec = &eth_item }, { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item }, { .type = RTE_FLOW_ITEM_TYPE_TCP, .spec = &tcp_item }, { .type = RTE_FLOW_ITEM_TYPE_END }
};

struct rte_flow_action_tunnel_encap vxlan_encap_action = { .definition = {
{ .type=eth, .spec={}, .mask={} },
{ .type=ipv4, .spec={}, .mask={} },
{ .type=udp, .spec={}, .mask={} },
{ .type=vxlan, .spec={}, .mask={} }
{ .type=end }
}
};

struct rte_flow_action actions[] = {
{ .type = RTE_FLOW_ACTION_TYPE_COUNT, .conf = &count } },
{ .type = RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP, .conf = &vxlan_encap_action } },
{
.type = RTE_FLOW_ACTION_TYPE_PORT_ID,
.conf = &port_id_action = { port_id }
},
{ .type = RTE_FLOW_ACTION_TYPE_END }
;

Declan Doherty (4):
ethdev: Add tunnel encap/decap actions
ethdev: Add group JUMP action
ethdev: add mark flow item to rte_flow_item_types
ethdev: add shared counter support to rte_flow

 app/test-pmd/cmdline_flow.c                 |  51 +++++-
 app/test-pmd/config.c                       |  19 +-
 app/test-pmd/testpmd.h                      |   2 +-
 doc/guides/prog_guide/rte_flow.rst          | 257 ++++++++++++++++++++++++----
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 +
 drivers/net/bonding/rte_eth_bond_flow.c     |   9 +-
 drivers/net/failsafe/failsafe_flow.c        |   4 +-
 drivers/net/mlx5/mlx5.h                     |   2 +-
 drivers/net/mlx5/mlx5_flow.c                |   2 +-
 lib/librte_ether/rte_flow.c                 |   2 +-
 lib/librte_ether/rte_flow.h                 | 211 +++++++++++++++++++++--
 lib/librte_ether/rte_flow_driver.h          |   2 +-
 12 files changed, 504 insertions(+), 65 deletions(-)
Signature · 1 line
2.14.3
#10 lore raw

PATCH v7 1/4 ethdev: Add tunnel encap/decap actions

Add new flow action types and associated action data structures to support the encapsulation and decapsulation of VXLAN and NVGRE tunnel endpoints.

The RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_ENCAP action will cause the matching flow to be encapsulated in the tunnel endpoint overlay defined in the [vxlan/nvgre]_encap action data.

The RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_DECAP action will cause all headers associated with the outer most tunnel endpoint of the specified type for the matching flows.

---
 doc/guides/prog_guide/rte_flow.rst | 107 +++++++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_flow.h        | 103 +++++++++++++++++++++++++++++++++++
 2 files changed, 210 insertions(+)
doc/guides/prog_guide/rte_flow.rst +107 -0
index 629cc90a9..e92969757 100644
@@ -1909,6 +1909,113 @@ Implements ``OFPAT_PUSH_MPLS`` ("push a new MPLS tag") as defined by the
    | ``ethertype`` | EtherType |
    +---------------+-----------+
 
+Action: ``VXLAN_ENCAP``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Performs a VXLAN encapsulation action by encapsulating the matched flow in the
+VXLAN tunnel as defined in the``rte_flow_action_vxlan_encap`` flow items
+definition.
+
+This action modifies the payload of matched flows. The flow definition specified
+in the ``rte_flow_action_tunnel_encap`` action structure must define a valid
+VLXAN network overlay which conforms with RFC 7348 (Virtual eXtensible Local
+Area Network (VXLAN): A Framework for Overlaying Virtualized Layer 2 Networks
+over Layer 3 Networks). The pattern must be terminated with the
+RTE_FLOW_ITEM_TYPE_END item type.
+
+.. _table_rte_flow_action_vxlan_encap:
+
+.. table:: VXLAN_ENCAP
+
+   +----------------+-------------------------------------+
+   | Field          | Value                               |
+   +================+=====================================+
+   | ``definition`` | Tunnel end-point overlay definition |
+   +----------------+-------------------------------------+
+
+.. _table_rte_flow_action_vxlan_encap_example:
+
+.. table:: IPv4 VxLAN flow pattern example.
+
+   +-------+----------+
+   | Index | Item     |
+   +=======+==========+
+   | 0     | Ethernet |
+   +-------+----------+
+   | 1     | IPv4     |
+   +-------+----------+
+   | 2     | UDP      |
+   +-------+----------+
+   | 3     | VXLAN    |
+   +-------+----------+
+   | 4     | END      |
+   +-------+----------+
+
+Action: ``VXLAN_DECAP``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Performs a decapsulation action by stripping all headers of the VXLAN tunnel
+network overlay from the matched flow.
+
+The flow items pattern defined for the flow rule with which a ``VXLAN_DECAP``
+action is specified, must define a valid VXLAN tunnel as per RFC7348. If the
+flow pattern does not specify a valid VXLAN tunnel then a
+RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
+
+This action modifies the payload of matched flows.
+
+Action: ``NVGRE_ENCAP``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Performs a NVGRE encapsulation action by encapsulating the matched flow in the
+NVGRE tunnel as defined in the``rte_flow_action_tunnel_encap`` flow item
+definition.
+
+This action modifies the payload of matched flows. The flow definition specified
+in the ``rte_flow_action_tunnel_encap`` action structure must defined a valid
+NVGRE network overlay which conforms with RFC 7637 (NVGRE: Network
+Virtualization Using Generic Routing Encapsulation). The pattern must be
+terminated with the RTE_FLOW_ITEM_TYPE_END item type.
+
+.. _table_rte_flow_action_nvgre_encap:
+
+.. table:: NVGRE_ENCAP
+
+   +----------------+-------------------------------------+
+   | Field          | Value                               |
+   +================+=====================================+
+   | ``definition`` | NVGRE end-point overlay definition  |
+   +----------------+-------------------------------------+
+
+.. _table_rte_flow_action_nvgre_encap_example:
+
+.. table:: IPv4 NVGRE flow pattern example.
+
+   +-------+----------+
+   | Index | Item     |
+   +=======+==========+
+   | 0     | Ethernet |
+   +-------+----------+
+   | 1     | IPv4     |
+   +-------+----------+
+   | 2     | NVGRE    |
+   +-------+----------+
+   | 3     | END      |
+   +-------+----------+
+
+Action: ``NVGRE_DECAP``
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Performs a decapsulation action by stripping all headers of the NVGRE tunnel
+network overlay from the matched flow.
+
+The flow items pattern defined for the flow rule with which a ``NVGRE_DECAP``
+action is specified, must define a valid NVGRE tunnel as per RFC7637. If the
+flow pattern does not specify a valid NVGRE tunnel then a
+RTE_FLOW_ERROR_TYPE_ACTION error should be returned.
+
+This action modifies the payload of matched flows.
+
 Negative types
 ~~~~~~~~~~~~~~
 
lib/librte_ether/rte_flow.h +103 -0

115 lines not on this page · raw message

Signature · 1 line
2.14.3
#11 lore raw

PATCH v7 2/4 ethdev: Add group JUMP action

In reply to Declan Doherty

Add jump action type which defines an action which allows a matched flow to be redirect to the specified group. This allows physical and logical flow table/group hierarchies to be defined through rte_flow.

This breaks ABI compatibility for the following public functions (as it modifes the ordering of the rte_flow_action_type enumeration):

- rte_flow_copy()
- rte_flow_create()
- rte_flow_query()
- rte_flow_validate()

Add support for specification of new JUMP action to testpmd's flow cli, and update the testpmd documentation to describe this new action.

---
 app/test-pmd/cmdline_flow.c                 | 23 +++++++++++
 doc/guides/prog_guide/rte_flow.rst          | 61 ++++++++++++++++++++++++-----
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 ++
 lib/librte_ether/rte_flow.h                 | 41 +++++++++++++++----
 4 files changed, 112 insertions(+), 17 deletions(-)
app/test-pmd/cmdline_flow.c +23 -0
index 4239602b6..6e9fa5d7c 100644
@@ -183,6 +183,8 @@ enum index {
 	ACTION_END,
 	ACTION_VOID,
 	ACTION_PASSTHRU,
+	ACTION_JUMP,
+	ACTION_JUMP_GROUP,
 	ACTION_MARK,
 	ACTION_MARK_ID,
 	ACTION_FLAG,
@@ -738,6 +740,7 @@ static const enum index next_action[] = {
 	ACTION_END,
 	ACTION_VOID,
 	ACTION_PASSTHRU,
+	ACTION_JUMP,
 	ACTION_MARK,
 	ACTION_FLAG,
 	ACTION_QUEUE,
@@ -856,6 +859,12 @@ static const enum index action_of_push_mpls[] = {
 	ZERO,
 };
 
+static const enum index action_jump[] = {
+	ACTION_JUMP_GROUP,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -1931,6 +1940,20 @@ static const struct token token_list[] = {
 		.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
 		.call = parse_vc,
 	},
+	[ACTION_JUMP] = {
+		.name = "jump",
+		.help = "redirect traffic to a given group",
+		.priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
+		.next = NEXT(action_jump),
+		.call = parse_vc,
+	},
+	[ACTION_JUMP_GROUP] = {
+		.name = "group",
+		.help = "group to redirect traffic to",
+		.next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
+		.call = parse_vc_conf,
+	},
 	[ACTION_MARK] = {
 		.name = "mark",
 		.help = "attach 32 bit value to packets",
doc/guides/prog_guide/rte_flow.rst +51 -10

94 lines not on this page · raw message

doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -0
index 2edf96dd6..260d044d5 100644
@@ -3453,6 +3453,10 @@ This section lists supported actions and their attributes, if any.
 
 - ``passthru``: let subsequent rule process matched packets.
 
+- ``jump``: redirect traffic to group on device.
+
+  - ``group {unsigned}``: group to redirect to.
+
 - ``mark``: attach 32 bit value to packets.
 
   - ``id {unsigned}``: 32 bit value to return with packets.
lib/librte_ether/rte_flow.h +34 -7

71 lines not on this page · raw message

Signature · 1 line
2.14.3
#12 lore raw

Re: [PATCH v7 2/4] ethdev: Add group JUMP action

About title, we use uppercase only for acronyms.
So it should be:
ethdev: add group jump action

#13 lore raw

Re: [PATCH v7 2/4] ethdev: Add group JUMP action

Quoted 3 lines · Thomas Monjalon

About title, we use uppercase only for acronyms.
So it should be:
ethdev: add group jump action

Updated on next-net.

#14 lore raw

PATCH v7 3/4 ethdev: add mark flow item to rte_flow_item_types

In reply to Declan Doherty

Introduces a new action type RTE_FLOW_ITEM_TYPE_MARK which enables flow patterns to specify arbitrary integer values to match aginst set by the RTE_FLOW_ACTION_TYPE_MARK action in previously matched flows.

Add support for specification of new MARK flow item in testpmd's cli. Update testpmd documentation to describe new MARK flow item support.

---
 app/test-pmd/cmdline_flow.c                 | 22 +++++++++++++++++++++
 doc/guides/prog_guide/rte_flow.rst          | 30 +++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 ++++
 lib/librte_ether/rte_flow.h                 | 29 ++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+)
app/test-pmd/cmdline_flow.c +22 -0
index 6e9fa5d7c..1ac04a0ab 100644
@@ -91,6 +91,8 @@ enum index {
 	ITEM_PHY_PORT_INDEX,
 	ITEM_PORT_ID,
 	ITEM_PORT_ID_ID,
+	ITEM_MARK,
+	ITEM_MARK_ID,
 	ITEM_RAW,
 	ITEM_RAW_RELATIVE,
 	ITEM_RAW_SEARCH,
@@ -494,6 +496,7 @@ static const enum index next_item[] = {
 	ITEM_VF,
 	ITEM_PHY_PORT,
 	ITEM_PORT_ID,
+	ITEM_MARK,
 	ITEM_RAW,
 	ITEM_ETH,
 	ITEM_VLAN,
@@ -555,6 +558,12 @@ static const enum index item_port_id[] = {
 	ZERO,
 };
 
+static const enum index item_mark[] = {
+	ITEM_MARK_ID,
+	ITEM_NEXT,
+	ZERO,
+};
+
 static const enum index item_raw[] = {
 	ITEM_RAW_RELATIVE,
 	ITEM_RAW_SEARCH,
@@ -1289,6 +1298,19 @@ static const struct token token_list[] = {
 		.next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
 		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
 	},
+	[ITEM_MARK] = {
+		.name = "mark",
+		.help = "match traffic against value set in previously matched rule",
+		.priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
+		.next = NEXT(item_mark),
+		.call = parse_vc,
+	},
+	[ITEM_MARK_ID] = {
+		.name = "id",
+		.help = "Integer value to match against",
+		.next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
+	},
 	[ITEM_RAW] = {
 		.name = "raw",
 		.help = "match an arbitrary byte string",
doc/guides/prog_guide/rte_flow.rst +30 -0
index 92e0f89ad..5b23778c7 100644
@@ -656,6 +656,36 @@ representor" depending on the kind of underlying device).
    | ``mask`` | ``id``   | zeroed to match any port ID |
    +----------+----------+-----------------------------+
 
+Item: ``MARK``
+^^^^^^^^^^^^^^
+
+Matches an arbitrary integer value which was set using the ``MARK`` action in
+a previously matched rule.
+
+This item can only specified once as a match criteria as the ``MARK`` action can
+only be specified once in a flow action.
+
+Note the value of MARK field is arbitrary and application defined.
+
+Depending on the underlying implementation the MARK item may be supported on
+the physical device, with virtual groups in the PMD or not at all.
+
+- Default ``mask`` matches any integer value.
+
+.. _table_rte_flow_item_mark:
+
+.. table:: MARK
+
+   +----------+----------+---------------------------+
+   | Field    | Subfield | Value                     |
+   +==========+==========+===========================+
+   | ``spec`` | ``id``   | integer value             |
+   +----------+--------------------------------------+
+   | ``last`` | ``id``   | upper range value         |
+   +----------+----------+---------------------------+
+   | ``mask`` | ``id``   | zeroed to match any value |
+   +----------+----------+---------------------------+
+
 Data matching item types
 ~~~~~~~~~~~~~~~~~~~~~~~~
 
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -0
index 260d044d5..013a40549 100644
@@ -3240,6 +3240,10 @@ This section lists supported pattern items and their attributes, if any.
 
   - ``id {unsigned}``: DPDK port ID.
 
+- ``mark``: match value set in previously matched flow rule using the mark action.
+
+  - ``id {unsigned}``: arbitrary integer value.
+
 - ``raw``: match an arbitrary byte string.
 
   - ``relative {boolean}``: look for pattern after the previous item.
lib/librte_ether/rte_flow.h +29 -0
index 17c1c4a89..d390bbf5a 100644
@@ -406,6 +406,13 @@ enum rte_flow_item_type {
 	 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
 	 */
 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
+
+	/**
+	 * Matches specified mark field.
+	 *
+	 * See struct rte_flow_item_mark.
+	 */
+	RTE_FLOW_ITEM_TYPE_MARK,
 };
 
 /**
@@ -1148,6 +1155,28 @@ rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
 };
 #endif
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_MARK
+ *
+ * Matches an arbitrary integer value which was set using the ``MARK`` action
+ * in a previously matched rule.
+ *
+ * This item can only be specified once as a match criteria as the ``MARK``
+ * action can only be specified once in a flow action.
+ *
+ * This value is arbitrary and application-defined. Maximum allowed value
+ * depends on the underlying implementation.
+ *
+ * Depending on the underlying implementation the MARK item may be supported on
+ * the physical device, with virtual groups in the PMD or not at all.
+ */
+struct rte_flow_item_mark {
+	uint32_t id; /**< Integer value to match against. */
+};
+
 /**
  * Matching pattern item definition.
  *
Signature · 1 line
2.14.3
#15 lore raw

Re: [PATCH v7 3/4] ethdev: add mark flow item to rte_flow_item_types

26/04/2018 19:29, Declan Doherty:

Quoted 4 lines

Introduces a new action type RTE_FLOW_ITEM_TYPE_MARK which enables flow patterns to specify arbitrary integer values to match aginst set by the RTE_FLOW_ACTION_TYPE_MARK action in previously matched flows.

In the title, I don't think you need specify rte_flow_item_types (which doesn't exist BTW).
I suggest:
ethdev: add mark flow item

#16 lore raw

Re: [PATCH v7 3/4] ethdev: add mark flow item to rte_flow_item_types

Quoted 10 lines · Thomas Monjalon

26/04/2018 19:29, Declan Doherty:

Quoted 4 lines

Introduces a new action type RTE_FLOW_ITEM_TYPE_MARK which enables flow patterns to specify arbitrary integer values to match aginst set by the RTE_FLOW_ACTION_TYPE_MARK action in previously matched flows.

In the title, I don't think you need specify rte_flow_item_types (which doesn't exist BTW).
I suggest:
ethdev: add mark flow item

Updated on next-net.

#17 lore raw

PATCH v7 4/4 ethdev: add shared counter support to rte_flow

In reply to Declan Doherty

Add rte_flow_action_count action data structure to enable shared counters across multiple flows on a single port or across multiple flows on multiple ports within the same switch domain. Also this enables multiple count actions to be specified in a single flow action.

This patch also modifies the existing rte_flow_query API to take the rte_flow_action structure as an input parameter instead of the rte_flow_action_type enumeration to allow querying a specific action from a flow rule when multiple actions of the same type are specified.

This patch also contains updates for the bonding, failsafe and mlx5 PMDs and testpmd application which are affected by this API change.

---
 app/test-pmd/cmdline_flow.c             |  6 ++--
 app/test-pmd/config.c                   | 19 ++++++-----
 app/test-pmd/testpmd.h                  |  2 +-
 doc/guides/prog_guide/rte_flow.rst      | 59 +++++++++++++++++++++------------
 drivers/net/bonding/rte_eth_bond_flow.c |  9 ++---
 drivers/net/failsafe/failsafe_flow.c    |  4 +--
 drivers/net/mlx5/mlx5.h                 |  2 +-
 drivers/net/mlx5/mlx5_flow.c            |  2 +-
 lib/librte_ether/rte_flow.c             |  2 +-
 lib/librte_ether/rte_flow.h             | 38 +++++++++++++++++++--
 lib/librte_ether/rte_flow_driver.h      |  2 +-
 11 files changed, 97 insertions(+), 48 deletions(-)
app/test-pmd/cmdline_flow.c +3 -3
index 1ac04a0ab..5754e7858 100644
@@ -420,7 +420,7 @@ struct buffer {
 		} destroy; /**< Destroy arguments. */
 		struct {
 			uint32_t rule;
-			enum rte_flow_action_type action;
+			struct rte_flow_action action;
 		} query; /**< Query arguments. */
 		struct {
 			uint32_t *group;
@@ -1101,7 +1101,7 @@ static const struct token token_list[] = {
 		.next = NEXT(NEXT_ENTRY(QUERY_ACTION),
 			     NEXT_ENTRY(RULE_ID),
 			     NEXT_ENTRY(PORT_ID)),
-		.args = ARGS(ARGS_ENTRY(struct buffer, args.query.action),
+		.args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
 			     ARGS_ENTRY(struct buffer, args.query.rule),
 			     ARGS_ENTRY(struct buffer, port)),
 		.call = parse_query,
@@ -3842,7 +3842,7 @@ cmd_flow_parsed(const struct buffer *in)
 		break;
 	case QUERY:
 		port_flow_query(in->port, in->args.query.rule,
-				in->args.query.action);
+				&in->args.query.action);
 		break;
 	case LIST:
 		port_flow_list(in->port, in->args.list.group_n,
app/test-pmd/config.c +10 -9
index 0f2425229..c7dc1bfd0 100644
@@ -1099,7 +1099,7 @@ static const struct {
 	MK_FLOW_ACTION(FLAG, 0),
 	MK_FLOW_ACTION(QUEUE, sizeof(struct rte_flow_action_queue)),
 	MK_FLOW_ACTION(DROP, 0),
-	MK_FLOW_ACTION(COUNT, 0),
+	MK_FLOW_ACTION(COUNT, sizeof(struct rte_flow_action_count)),
 	MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)),
 	MK_FLOW_ACTION(PF, 0),
 	MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)),
@@ -1452,7 +1452,7 @@ port_flow_flush(portid_t port_id)
 /** Query a flow rule. */
 int
 port_flow_query(portid_t port_id, uint32_t rule,
-		enum rte_flow_action_type action)
+		const struct rte_flow_action *action)
 {
 	struct rte_flow_error error;
 	struct rte_port *port;
@@ -1473,16 +1473,17 @@ port_flow_query(portid_t port_id, uint32_t rule,
 		printf("Flow rule #%u not found\n", rule);
 		return -ENOENT;
 	}
-	if ((unsigned int)action >= RTE_DIM(flow_action) ||
-	    !flow_action[action].name)
+	if ((unsigned int)action->type >= RTE_DIM(flow_action) ||
+	    !flow_action[action->type].name)
 		name = "unknown";
 	else
-		name = flow_action[action].name;
-	switch (action) {
+		name = flow_action[action->type].name;
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		break;
 	default:
-		printf("Cannot query action type %d (%s)\n", action, name);
+		printf("Cannot query action type %d (%s)\n",
+			action->type, name);
 		return -ENOTSUP;
 	}
 	/* Poisoning to make sure PMDs update it in case of error. */
@@ -1490,7 +1491,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
 	memset(&query, 0, sizeof(query));
 	if (rte_flow_query(port_id, pf->flow, action, &query, &error))
 		return port_flow_complain(&error);
-	switch (action) {
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
 		printf("%s:\n"
 		       " hits_set: %u\n"
@@ -1505,7 +1506,7 @@ port_flow_query(portid_t port_id, uint32_t rule,
 		break;
 	default:
 		printf("Cannot display result for action type %d (%s)\n",
-		       action, name);
+		       action->type, name);
 		break;
 	}
 	return 0;
app/test-pmd/testpmd.h +1 -1
index a33b525e2..1af87b8f4 100644
@@ -620,7 +620,7 @@ int port_flow_create(portid_t port_id,
 int port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule);
 int port_flow_flush(portid_t port_id);
 int port_flow_query(portid_t port_id, uint32_t rule,
-		    enum rte_flow_action_type action);
+		    const struct rte_flow_action *action);
 void port_flow_list(portid_t port_id, uint32_t n, const uint32_t *group);
 int port_flow_isolate(portid_t port_id, int set);
 
doc/guides/prog_guide/rte_flow.rst +37 -22

91 lines not on this page · raw message

drivers/net/bonding/rte_eth_bond_flow.c +5 -4
index 8093c04f5..31e4bcaeb 100644
@@ -152,6 +152,7 @@ bond_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *err)
 
 static int
 bond_flow_query_count(struct rte_eth_dev *dev, struct rte_flow *flow,
+		      const struct rte_flow_action *action,
 		      struct rte_flow_query_count *count,
 		      struct rte_flow_error *err)
 {
@@ -165,7 +166,7 @@ bond_flow_query_count(struct rte_eth_dev *dev, struct rte_flow *flow,
 	rte_memcpy(&slave_count, count, sizeof(slave_count));
 	for (i = 0; i < internals->slave_count; i++) {
 		ret = rte_flow_query(internals->slaves[i].port_id,
-				     flow->flows[i], RTE_FLOW_ACTION_TYPE_COUNT,
+				     flow->flows[i], action,
 				     &slave_count, err);
 		if (unlikely(ret != 0)) {
 			RTE_BOND_LOG(ERR, "Failed to query flow on"
@@ -182,12 +183,12 @@ bond_flow_query_count(struct rte_eth_dev *dev, struct rte_flow *flow,
 
 static int
 bond_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
-		enum rte_flow_action_type type, void *arg,
+		const struct rte_flow_action *action, void *arg,
 		struct rte_flow_error *err)
 {
-	switch (type) {
+	switch (action->type) {
 	case RTE_FLOW_ACTION_TYPE_COUNT:
-		return bond_flow_query_count(dev, flow, arg, err);
+		return bond_flow_query_count(dev, flow, action, arg, err);
 	default:
 		return rte_flow_error_set(err, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ACTION, arg,
drivers/net/failsafe/failsafe_flow.c +2 -2
index a97f4075d..bfe42fcee 100644
@@ -174,7 +174,7 @@ fs_flow_flush(struct rte_eth_dev *dev,
 static int
 fs_flow_query(struct rte_eth_dev *dev,
 	      struct rte_flow *flow,
-	      enum rte_flow_action_type type,
+	      const struct rte_flow_action *action,
 	      void *arg,
 	      struct rte_flow_error *error)
 {
@@ -185,7 +185,7 @@ fs_flow_query(struct rte_eth_dev *dev,
 	if (sdev != NULL) {
 		int ret = rte_flow_query(PORT_ID(sdev),
 					 flow->flows[SUB_ID(sdev)],
-					 type, arg, error);
+					 action, arg, error);
 
 		if ((ret = fs_err(sdev, ret))) {
 			fs_unlock(dev, 0);
drivers/net/mlx5/mlx5.h +1 -1
index 874978baa..c4d1d456b 100644
@@ -277,7 +277,7 @@ int mlx5_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
 void mlx5_flow_list_flush(struct rte_eth_dev *dev, struct mlx5_flows *list);
 int mlx5_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error);
 int mlx5_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
-		    enum rte_flow_action_type action, void *data,
+		    const struct rte_flow_action *action, void *data,
 		    struct rte_flow_error *error);
 int mlx5_flow_isolate(struct rte_eth_dev *dev, int enable,
 		      struct rte_flow_error *error);
drivers/net/mlx5/mlx5_flow.c +1 -1
index 8f5fcf4d6..c385f6ced 100644
@@ -3079,7 +3079,7 @@ mlx5_flow_query_count(struct ibv_counter_set *cs,
 int
 mlx5_flow_query(struct rte_eth_dev *dev __rte_unused,
 		struct rte_flow *flow,
-		enum rte_flow_action_type action __rte_unused,
+		const struct rte_flow_action *action __rte_unused,
 		void *data,
 		struct rte_flow_error *error)
 {
lib/librte_ether/rte_flow.c +1 -1
index 4f94ac9b5..7947529da 100644
@@ -233,7 +233,7 @@ rte_flow_flush(uint16_t port_id,
 int
 rte_flow_query(uint16_t port_id,
 	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
 	       void *data,
 	       struct rte_flow_error *error)
 {
lib/librte_ether/rte_flow.h +35 -3
index d390bbf5a..f8ba71cdb 100644
@@ -1314,7 +1314,7 @@ enum rte_flow_action_type {
 	 * These counters can be retrieved and reset through rte_flow_query(),
 	 * see struct rte_flow_query_count.
 	 *
-	 * No associated configuration structure.
+	 * See struct rte_flow_action_count.
 	 */
 	RTE_FLOW_ACTION_TYPE_COUNT,
 
@@ -1546,6 +1546,38 @@ struct rte_flow_action_queue {
 	uint16_t index; /**< Queue index to use. */
 };
 
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_COUNT
+ *
+ * Adds a counter action to a matched flow.
+ *
+ * If more than one count action is specified in a single flow rule, then each
+ * action must specify a unique id.
+ *
+ * Counters can be retrieved and reset through ``rte_flow_query()``, see
+ * ``struct rte_flow_query_count``.
+ *
+ * The shared flag indicates whether the counter is unique to the flow rule the
+ * action is specified with, or whether it is a shared counter.
+ *
+ * For a count action with the shared flag set, then then a global device
+ * namespace is assumed for the counter id, so that any matched flow rules using
+ * a count action with the same counter id on the same port will contribute to
+ * that counter.
+ *
+ * For ports within the same switch domain then the counter id namespace extends
+ * to all ports within that switch domain.
+ */
+struct rte_flow_action_count {
+	uint32_t shared:1; /**< Share counter ID with other flow rules. */
+	uint32_t reserved:31; /**< Reserved, must be zero. */
+	uint32_t id; /**< Counter ID. */
+};
+
 /**
  * RTE_FLOW_ACTION_TYPE_COUNT (query)
  *
@@ -2044,7 +2076,7 @@ rte_flow_flush(uint16_t port_id,
  * @param flow
  *   Flow rule handle to query.
  * @param action
- *   Action type to query.
+ *   Action definition as defined in original flow rule.
  * @param[in, out] data
  *   Pointer to storage for the associated query data type.
  * @param[out] error
@@ -2057,7 +2089,7 @@ rte_flow_flush(uint16_t port_id,
 int
 rte_flow_query(uint16_t port_id,
 	       struct rte_flow *flow,
-	       enum rte_flow_action_type action,
+	       const struct rte_flow_action *action,
 	       void *data,
 	       struct rte_flow_error *error);
 
lib/librte_ether/rte_flow_driver.h +1 -1
index 3800310ba..1c90c600d 100644
@@ -88,7 +88,7 @@ struct rte_flow_ops {
 	int (*query)
 		(struct rte_eth_dev *,
 		 struct rte_flow *,
-		 enum rte_flow_action_type,
+		 const struct rte_flow_action *,
 		 void *,
 		 struct rte_flow_error *);
 	/** See rte_flow_isolate(). */
Signature · 1 line
2.14.3
#18 lore raw

Re: [PATCH v7 4/4] ethdev: add shared counter support to rte_flow

26/04/2018 19:29, Declan Doherty:

Quoted 5 lines

Add rte_flow_action_count action data structure to enable shared counters across multiple flows on a single port or across multiple flows on multiple ports within the same switch domain. Also this enables multiple count actions to be specified in a single flow action.

Quoted 7 lines

This patch also modifies the existing rte_flow_query API to take the rte_flow_action structure as an input parameter instead of the rte_flow_action_type enumeration to allow querying a specific action from a flow rule when multiple actions of the same type are specified.

This patch also contains updates for the bonding, failsafe and mlx5 PMDs and testpmd application which are affected by this API change.

The API changes must be notified in the release notes (there is a section for API changes).

#19 lore raw

Re: [PATCH v7 4/4] ethdev: add shared counter support to rte_flow

Quoted 11 lines · Thomas Monjalon

26/04/2018 19:29, Declan Doherty:

Quoted 10 lines

Add rte_flow_action_count action data structure to enable shared counters across multiple flows on a single port or across multiple flows on multiple ports within the same switch domain. Also this enables multiple count actions to be specified in a single flow action.

This patch also modifies the existing rte_flow_query API to take the rte_flow_action structure as an input parameter instead of the rte_flow_action_type enumeration to allow querying a specific action from a flow rule when multiple actions of the same type are specified.

Quoted 5 lines
Quoted 2 lines

This patch also contains updates for the bonding, failsafe and mlx5 PMDs and testpmd application which are affected by this API change.

The API changes must be notified in the release notes (there is a section for API changes).

Hi Declan,

If you can send the update as a separate patch, I can squash it in next-net.

#20 lore raw

Re: [PATCH v7 4/4] ethdev: add shared counter support to rte_flow

Quoted 15 lines · Ferruh Yigit
Quoted 14 lines · Thomas Monjalon

26/04/2018 19:29, Declan Doherty:

Quoted 12 lines

Add rte_flow_action_count action data structure to enable shared counters across multiple flows on a single port or across multiple flows on multiple ports within the same switch domain. Also this enables multiple count actions to be specified in a single flow action.

This patch also modifies the existing rte_flow_query API to take the rte_flow_action structure as an input parameter instead of the rte_flow_action_type enumeration to allow querying a specific action from a flow rule when multiple actions of the same type are specified.

This patch also contains updates for the bonding, failsafe and mlx5 PMDs and testpmd application which are affected by this API change.

Quoted 6 lines
Quoted 2 lines

The API changes must be notified in the release notes (there is a section for API changes).

Hi Declan,

If you can send the update as a separate patch, I can squash it in next-net.

Thanks Declan, following addition squashed into related commit:

* ethdev: change flow APIs regarding count action:
* ``rte_flow_create()`` API count action now requires the ``struct
rte_flow_action_count``.
* ``rte_flow_query()`` API parameter changed from action type to action structure.

#21 lore raw

Re: [PATCH v7 0/4] ethdev: add shared counter support to rte_flow

In reply to Declan Doherty
Quoted 188 lines · Declan Doherty

This patchset contains the revised proposal to manage tunnel endpoints hardware accleration based on community feedback on RFC
(http://dpdk.org/ml/archives/dev/2017-December/084676.html). This proposal is purely enabled through rte_flow APIs with the additions of some new features which were previously implemented by the proposed rte_tep APIs which were proposed in the original RFC. This patchset ultimately aims to enable the configuration of inline data path encapsulation and decapsulation of tunnel endpoint network overlays on accelerated IO devices.

V2:
- Split new functions into separate patches, and add additional documentaiton.

V3:
- Extended the descriptio:wn of group counter in documentation.
- Renamed VTEP to TUNNEL.
- Fixed C99 syntax.

V4:
- Modify encap/decap actions to be protocol specific
- rename group action type to jump
- add mark flow item type in place of metadata flow/action types
- add count action data structure
- modify query API to accept rte_flow_action structure in place of rte_flow_actio_type enumeration to support specification and querying of multiple actions of the same type

V5:
- Documentation and comment updates
- Mark new API structures as experimental
- squash new function testpmd enablement into relevant patches.

V6:
- rebased to head of next-net
- fixed whitespace issues add in previous revision

V7:
- fix mlx5 compliation issue due to change in flow query API

The summary of the additions to the rte_flow are as follows:

- Add new flow actions RTE_RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_ENCAP and RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_DECAP to rte_flow to support specfication of encapsulation and decapsulation of VXLAN and NVGRE tunnels in hardware.
- Introduces support for the use of pipeline metadata in
the flow pattern definition and the population of metadata fields from flow actions using the MARK flow and action items.
- Add shared flag to counters to enable statistics to be kept on groups offlows such as all ingress/egress flows of a tunnel
- Adds jump_action to allow a flows to be redirected to a group within the device.

A high level summary of the proposed usage model is as follows:

1. Decapsulation

1.1. Decapsulation of tunnel outer headers and forward all traffic
to the same queue/s or port, would have the follow flows paramteters, sudo code used here.

struct rte_flow_attr attr = { .ingress = 1 };

struct rte_flow_item pattern[] = {
{ .type = RTE_FLOW_ITEM_TYPE_ETH, .spec = &eth_item }, { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item }, { .type = RTE_FLOW_ITEM_TYPE_UDP, .spec = &udp_item }, { .type = RTE_FLOW_ITEM_TYPE_VxLAN, .spec = &vxlan_item }, { .type = RTE_FLOW_ITEM_TYPE_END }
};

struct rte_flow_action actions[] = {
{ .type = RTE_FLOW_ACTION_TYPE_VXLAN_DECAP },
{ .type = RTE_FLOW_ACTION_TYPE_VF, .conf = &vf_action }, { .type = RTE_FLOW_ACTION_TYPE_END }
}

1.2.

Decapsulation of tunnel outer headers and matching on inner headers, and forwarding to the same queue/s or port.

1.2.1.

The same scenario as above but either the application or hardware requires configuration as 2 logically independent operations (viewing it as 2 logical tables). The first stage being the flow rule to define the pattern to match the tunnel and the action to decapsulate the packet, and the second stage stage table matches the inner header and defines the actions, forward to port etc.

flow rule for outer header on table 0

struct rte_flow_attr attr = { .ingress = 1, .table = 0 };

struct rte_flow_item pattern[] = {
{ .type = RTE_FLOW_ITEM_TYPE_ETH, .spec = &eth_item }, { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item }, { .type = RTE_FLOW_ITEM_TYPE_UDP, .spec = &udp_item }, { .type = RTE_FLOW_ITEM_TYPE_VxLAN, .spec = &vxlan_item }, { .type = RTE_FLOW_ITEM_TYPE_END }
};

struct rte_flow_item_count shared_couter = {
.shared = 1,
.id = {counter_id}
}

struct rte_flow_action actions[] = {
{ .type = RTE_FLOW_ACTION_TYPE_COUNT, .conf = &shared_counter }, { .type = RTE_FLOW_ACTION_TYPE_MARK, .conf = &mark_action }, { .type = RTE_FLOW_ACTION_TYPE_VXLAN_DECAP },
{
.type = RTE_FLOW_ACTION_TYPE_JUMP,
.conf = { .group = 1 }
},
{ .type = RTE_FLOW_ACTION_TYPE_END }
}

flow rule for inner header on table 1

struct rte_flow_attr attr = { .ingress = 1, .group = 1 };

struct rte_flow_item_mark mark_item = { id = {mark_id} };

struct rte_flow_item pattern[] = {
{ .type = RTE_FLOW_ITEM_TYPE_MARK, .spec = &mark_item }, { .type = RTE_FLOW_ITEM_TYPE_ETH, .spec = &eth_item }, { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item }, { .type = RTE_FLOW_ITEM_TYPE_TCP, .spec = &tcp_item }, { .type = RTE_FLOW_ITEM_TYPE_END }
};

struct rte_flow_action actions[] = {
{
.type = RTE_FLOW_ACTION_TYPE_PORT_ID,
.conf = &port_id_action = { port_id }
},
{ .type = RTE_FLOW_ACTION_TYPE_END }
}

Note that the mark action in the flow rule in group 0 is generating the value in the pipeline which is then used in as part as the flow pattern in group 1 to specify the exact flow to match against. In the case where exact match rules are being provided by the application explicitly then the MARK item value can be provided by the application in the flow pattern for the flow rule in group 1 also.

2. Encapsulation

Encapsulation of all traffic matching a specific flow pattern to a specified tunnel and egressing to a particular port.

struct rte_flow_attr attr = { .egress = 1 };

struct rte_flow_item pattern[] = {
{ .type = RTE_FLOW_ITEM_TYPE_ETH, .spec = &eth_item }, { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item }, { .type = RTE_FLOW_ITEM_TYPE_TCP, .spec = &tcp_item }, { .type = RTE_FLOW_ITEM_TYPE_END }
};

struct rte_flow_action_tunnel_encap vxlan_encap_action = { .definition = {
{ .type=eth, .spec={}, .mask={} },
{ .type=ipv4, .spec={}, .mask={} },
{ .type=udp, .spec={}, .mask={} },
{ .type=vxlan, .spec={}, .mask={} }
{ .type=end }
}
};

struct rte_flow_action actions[] = {
{ .type = RTE_FLOW_ACTION_TYPE_COUNT, .conf = &count } },
{ .type = RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP, .conf = &vxlan_encap_action } },
{
.type = RTE_FLOW_ACTION_TYPE_PORT_ID,
.conf = &port_id_action = { port_id }
},
{ .type = RTE_FLOW_ACTION_TYPE_END }
;

Quoted 5 lines

Declan Doherty (4):
ethdev: Add tunnel encap/decap actions
ethdev: Add group JUMP action
ethdev: add mark flow item to rte_flow_item_types
ethdev: add shared counter support to rte_flow

Series applied to dpdk-next-net/master, thanks.

#22 lore raw
In reply to Declan Doherty

Hi Declan,

Thank you (and DPDK) for driving this proposal, much appreciated. Upon quick review of the proposal one thing stood out.

In rte_flow.h the new tunnel action, RLTE_FLOW_ACTION_VXLAN_ENCAP/DECAP, similar with NVGRE_ENCAP/DECAP, is defined as:

/**
* Decapsulate outer most VXLAN tunnel from matched flow.
*
* If flow pattern does not define a valid VXLAN tunnel (as specified by
* RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
* error.
*/
RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,

and

* RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
*
* VXLAN tunnel end-point encapsulation data definition
*
* The tunnel definition is provided through the flow item pattern, the
* provided pattern must conform to RFC7348 for the tunnel specified. The flow
* definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
* definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END. *
* The mask field allows user to specify which fields in the flow item
* definitions can be ignored and which have valid data and can be used
* verbatim.
*
* Note: the last field is not used in the definition of a tunnel and can be
* ignored.
*
* Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
*
* - ETH / IPV4 / UDP / VXLAN / END
* - ETH / IPV6 / UDP / VXLAN / END
* - ETH / VLAN / IPV4 / UDP / VXLAN / END
*
*/

Similar with doc/guides/prog_guide/rte_flow.rst.

With these specific RF7348 references it wouldn't be possible to support customer private implementations for VXLAN, i.e. a non compliant inner packet like eth/ipv4/udp/vxlan/no inner eth header/ipv4. The proposed format though, by specifying the protocol layer using the 'item' list does allow for listing of the complete stack including the inner packet format. This could be used to trigger the PMD to handle this flow differently than the RFC compliant VXLAN.

If the RFC reference is left in then one would have to create yet another VXLAN action, i.e. RTE_FLOW_ACTION_TYPE_VXLAN_CUSTOM_ENCAP/DECAP OR RTE_FLOW_ACTION_TYPE_NONCOMPLIANT_VXLAN_ENCAP/DECAP, which I find inappropriate even if its name describe the inner packet was missing the ethernet header.

Would it be possible to accept that the RFC7348 compliance is removed from these two comments as to allow for more flexibility so we do not, potentially, drown in custom cases ?

Thanks,
Michael

Quoted 207 lines · Declan Doherty

his patchset contains the revised proposal to manage tunnel endpoints hardware accleration based on community feedback on RFC
(http://dpdk.org/ml/archives/dev/2017-December/084676.html). This proposal is purely enabled through rte_flow APIs with the additions of some new features which were previously implemented by the proposed rte_tep APIs which were proposed in the original RFC. This patchset ultimately aims to enable the configuration of inline data path encapsulation and decapsulation of tunnel endpoint network overlays on accelerated IO devices.

V2:
- Split new functions into separate patches, and add additional documentaiton.

V3:

- Extended the description of group counter in documentation.
- Renamed VTEP to TUNNEL.
- Fixed C99 syntax.

V4:

- Modify encap/decap actions to be protocol specific
- rename group action type to jump
- add mark flow item type in place of metadata flow/action types
- add count action data structure
- modify query API to accept rte_flow_action structure in place of rte_flow_actio_type enumeration to support specification and querying of multiple actions of the same type

V5:
- Documentation and comment updates
- Mark new API structures as experimental
- squash new function testpmd enablement into relevant patches.

V6:
- rebased to head of next-net
- fixed whitespace issues add in previous revision

The summary of the additions to the rte_flow are as follows:

- Add new flow actions RTE_RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_ENCAP and RTE_FLOW_ACTION_TYPE_[VXLAN/NVGRE]_DECAP to rte_flow to support specfication of encapsulation and decapsulation of VXLAN and NVGRE tunnels in hardware.
- Introduces support for the use of pipeline metadata in
the flow pattern definition and the population of metadata fields from flow actions using the MARK flow and action items.
- Add shared flag to counters to enable statistics to be kept on groups offlows such as all ingress/egress flows of a tunnel
- Adds jump_action to allow a flows to be redirected to a group within the device.

A high level summary of the proposed usage model is as follows:

1. Decapsulation

1.1. Decapsulation of tunnel outer headers and forward all traffic
to the same queue/s or port, would have the follow flows paramteters, sudo code used here.

struct rte_flow_attr attr = { .ingress = 1 };

struct rte_flow_item pattern[] = {
        { .type = RTE_FLOW_ITEM_TYPE_ETH,  .spec = &eth_item },
        { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item },
        { .type = RTE_FLOW_ITEM_TYPE_UDP, .spec = &udp_item },
        { .type = RTE_FLOW_ITEM_TYPE_VxLAN, .spec = &vxlan_item },
        { .type = RTE_FLOW_ITEM_TYPE_END }
};

struct rte_flow_action actions[] = {
{ .type = RTE_FLOW_ACTION_TYPE_VXLAN_DECAP },
{ .type = RTE_FLOW_ACTION_TYPE_VF, .conf = &vf_action }, { .type = RTE_FLOW_ACTION_TYPE_END }
}

1.2.

Decapsulation of tunnel outer headers and matching on inner headers, and forwarding to the same queue/s or port.

1.2.1.

The same scenario as above but either the application or hardware requires configuration as 2 logically independent operations (viewing it as 2 logical tables). The first stage being the flow rule to define the pattern to match the tunnel and the action to decapsulate the packet, and the second stage stage table matches the inner header and defines the actions, forward to port etc.

flow rule for outer header on table 0

struct rte_flow_attr attr = { .ingress = 1, .table = 0 };

struct rte_flow_item pattern[] = {
        { .type = RTE_FLOW_ITEM_TYPE_ETH,  .spec = &eth_item },
        { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item },
        { .type = RTE_FLOW_ITEM_TYPE_UDP, .spec = &udp_item },
        { .type = RTE_FLOW_ITEM_TYPE_VxLAN, .spec = &vxlan_item },
        { .type = RTE_FLOW_ITEM_TYPE_END }
};
struct rte_flow_item_count shared_couter = {
        .shared = 1,
        .id = {counter_id}
}

struct rte_flow_action actions[] = {
{ .type = RTE_FLOW_ACTION_TYPE_COUNT, .conf = &shared_counter }, { .type = RTE_FLOW_ACTION_TYPE_MARK, .conf = &mark_action }, { .type = RTE_FLOW_ACTION_TYPE_VXLAN_DECAP },
{
.type = RTE_FLOW_ACTION_TYPE_JUMP,
.conf = { .group = 1 }
},
{ .type = RTE_FLOW_ACTION_TYPE_END }
}

flow rule for inner header on table 1

struct rte_flow_attr attr = { .ingress = 1, .group = 1 };

struct rte_flow_item_mark mark_item = { id = {mark_id} };

struct rte_flow_item pattern[] = {
        { .type = RTE_FLOW_ITEM_TYPE_MARK,  .spec = &mark_item },
        { .type = RTE_FLOW_ITEM_TYPE_ETH,  .spec = &eth_item },
        { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item },
        { .type = RTE_FLOW_ITEM_TYPE_TCP, .spec = &tcp_item },
        { .type = RTE_FLOW_ITEM_TYPE_END }
};
struct rte_flow_action actions[] = {
        {
          .type = RTE_FLOW_ACTION_TYPE_PORT_ID,
          .conf = &port_id_action = { port_id }
        },
        { .type = RTE_FLOW_ACTION_TYPE_END }
}

Note that the mark action in the flow rule in group 0 is generating the value in the pipeline which is then used in as part as the flow pattern in group 1 to specify the exact flow to match against. In the case where exact match rules are being provided by the application explicitly then the MARK item value can be provided by the application in the flow pattern for the flow rule in group 1 also.

2. Encapsulation

Encapsulation of all traffic matching a specific flow pattern to a specified tunnel and egressing to a particular port.

struct rte_flow_attr attr = { .egress = 1 };

struct rte_flow_item pattern[] = {
        { .type = RTE_FLOW_ITEM_TYPE_ETH, .spec = &eth_item },
        { .type = RTE_FLOW_ITEM_TYPE_IPV4, .spec = &ipv4_item },
        { .type = RTE_FLOW_ITEM_TYPE_TCP, .spec = &tcp_item },
        { .type = RTE_FLOW_ITEM_TYPE_END }
};
struct rte_flow_action_tunnel_encap vxlan_encap_action = {
        .definition = {
                { .type=eth, .spec={}, .mask={} },
                { .type=ipv4, .spec={}, .mask={} },
                { .type=udp, .spec={}, .mask={} },
                { .type=vxlan, .spec={}, .mask={} }
                { .type=end }
        }
};
struct rte_flow_action actions[] = {
        { .type = RTE_FLOW_ACTION_TYPE_COUNT, .conf = &count } },
        { .type = RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP, .conf = &vxlan_encap_action } },
        {
          .type = RTE_FLOW_ACTION_TYPE_PORT_ID,
          .conf = &port_id_action = { port_id }
        },
        { .type = RTE_FLOW_ACTION_TYPE_END }
};

Declan Doherty (4):
ethdev: Add tunnel encap/decap actions
ethdev: Add group JUMP action
ethdev: add mark flow item to rte_flow_item_types
ethdev: add shared counter support to rte_flow

 app/test-pmd/cmdline_flow.c                 |  51 +++++-
 app/test-pmd/config.c                       |  15 +-
 app/test-pmd/testpmd.h                      |   2 +-
 doc/guides/prog_guide/rte_flow.rst          | 257 ++++++++++++++++++++++++----
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   8 +
 drivers/net/bonding/rte_eth_bond_flow.c     |   9 +-
 drivers/net/failsafe/failsafe_flow.c        |   4 +-
 lib/librte_ether/rte_flow.c                 |   2 +-
 lib/librte_ether/rte_flow.h                 | 211 +++++++++++++++++++++--
 lib/librte_ether/rte_flow_driver.h          |   2 +-
 10 files changed, 500 insertions(+), 61 deletions(-)

--
2.14.3