Skip to content

Commit 0ddff06

Browse files
aleks-kozyrevferruhy
authored andcommitted
ethdev: add packet type matching item
Add RTE_FLOW_ITEM_TYPE_PTYPE to allow matching on L2/L3/L4 and tunnel information as defined in mbuf. To match on RTE_PTYPE_L4_TCP and RTE_PTYPE_INNER_L4_UDP: flow pattern_template 0 create pattern_template_id 1 ingress template ptype packet_type mask 0x0f000f00 / end flow queue 0 create 0 template_table 1 pattern_template 0 actions_template 0 pattern ptype packet_type is 0x02000100 / end actions queue index 1 / end Signed-off-by: Alexander Kozyrev <[email protected]> Acked-by: Ori Kam <[email protected]>
1 parent 63ce6cb commit 0ddff06

File tree

6 files changed

+66
-0
lines changed

6 files changed

+66
-0
lines changed

app/test-pmd/cmdline_flow.c

+28
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,8 @@ enum index {
533533
ITEM_IB_BTH_PSN,
534534
ITEM_IPV6_PUSH_REMOVE_EXT,
535535
ITEM_IPV6_PUSH_REMOVE_EXT_TYPE,
536+
ITEM_PTYPE,
537+
ITEM_PTYPE_VALUE,
536538

537539
/* Validate/create actions. */
538540
ACTIONS,
@@ -1578,6 +1580,7 @@ static const enum index next_item[] = {
15781580
ITEM_AGGR_AFFINITY,
15791581
ITEM_TX_QUEUE,
15801582
ITEM_IB_BTH,
1583+
ITEM_PTYPE,
15811584
END_SET,
15821585
ZERO,
15831586
};
@@ -2097,6 +2100,12 @@ static const enum index item_ib_bth[] = {
20972100
ZERO,
20982101
};
20992102

2103+
static const enum index item_ptype[] = {
2104+
ITEM_PTYPE_VALUE,
2105+
ITEM_NEXT,
2106+
ZERO,
2107+
};
2108+
21002109
static const enum index next_action[] = {
21012110
ACTION_END,
21022111
ACTION_VOID,
@@ -5896,6 +5905,22 @@ static const struct token token_list[] = {
58965905
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
58975906
hdr.psn)),
58985907
},
5908+
[ITEM_PTYPE] = {
5909+
.name = "ptype",
5910+
.help = "match L2/L3/L4 and tunnel information",
5911+
.priv = PRIV_ITEM(PTYPE,
5912+
sizeof(struct rte_flow_item_ptype)),
5913+
.next = NEXT(item_ptype),
5914+
.call = parse_vc,
5915+
},
5916+
[ITEM_PTYPE_VALUE] = {
5917+
.name = "packet_type",
5918+
.help = "packet type as defined in rte_mbuf_ptype",
5919+
.next = NEXT(item_ptype, NEXT_ENTRY(COMMON_UNSIGNED),
5920+
item_param),
5921+
.args = ARGS(ARGS_ENTRY(struct rte_flow_item_ptype, packet_type)),
5922+
},
5923+
58995924
/* Validate/create actions. */
59005925
[ACTIONS] = {
59015926
.name = "actions",
@@ -12810,6 +12835,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
1281012835
case RTE_FLOW_ITEM_TYPE_IB_BTH:
1281112836
mask = &rte_flow_item_ib_bth_mask;
1281212837
break;
12838+
case RTE_FLOW_ITEM_TYPE_PTYPE:
12839+
mask = &rte_flow_item_ptype_mask;
12840+
break;
1281312841
default:
1281412842
break;
1281512843
}

doc/guides/nics/features/default.ini

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ ppp =
137137
pppoed =
138138
pppoes =
139139
pppoe_proto_id =
140+
ptype =
140141
quota =
141142
raw =
142143
represented_port =

doc/guides/prog_guide/rte_flow.rst

+7
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,13 @@ Matches an InfiniBand base transport header in RoCE packet.
15661566

15671567
- ``hdr``: InfiniBand base transport header definition (``rte_ib.h``).
15681568

1569+
Item: ``PTYPE``
1570+
^^^^^^^^^^^^^^^
1571+
1572+
Matches the packet type as defined in rte_mbuf_ptype.
1573+
1574+
- ``packet_type``: L2/L3/L4 and tunnel information.
1575+
15691576
Actions
15701577
~~~~~~~
15711578

doc/guides/testpmd_app_ug/testpmd_funcs.rst

+4
Original file line numberDiff line numberDiff line change
@@ -3815,6 +3815,10 @@ This section lists supported pattern items and their attributes, if any.
38153815

38163816
- ``send_to_kernel``: send packets to kernel.
38173817

3818+
- ``ptype``: match the packet type (L2/L3/L4 and tunnel information).
3819+
3820+
- ``packet_type {unsigned}``: packet type.
3821+
38183822

38193823
Actions list
38203824
^^^^^^^^^^^^

lib/ethdev/rte_flow.c

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
167167
MK_FLOW_ITEM(AGGR_AFFINITY, sizeof(struct rte_flow_item_aggr_affinity)),
168168
MK_FLOW_ITEM(TX_QUEUE, sizeof(struct rte_flow_item_tx_queue)),
169169
MK_FLOW_ITEM(IB_BTH, sizeof(struct rte_flow_item_ib_bth)),
170+
MK_FLOW_ITEM(PTYPE, sizeof(struct rte_flow_item_ptype)),
170171
};
171172

172173
/** Generate flow_action[] entry. */

lib/ethdev/rte_flow.h

+25
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,14 @@ enum rte_flow_item_type {
694694
* @see struct rte_flow_item_ib_bth.
695695
*/
696696
RTE_FLOW_ITEM_TYPE_IB_BTH,
697+
698+
/**
699+
* Matches the packet type as defined in rte_mbuf_ptype.
700+
*
701+
* See struct rte_flow_item_ptype.
702+
*
703+
*/
704+
RTE_FLOW_ITEM_TYPE_PTYPE,
697705
};
698706

699707
/**
@@ -2309,6 +2317,23 @@ static const struct rte_flow_item_tx_queue rte_flow_item_tx_queue_mask = {
23092317
};
23102318
#endif
23112319

2320+
/**
2321+
*
2322+
* RTE_FLOW_ITEM_TYPE_PTYPE
2323+
*
2324+
* Matches the packet type as defined in rte_mbuf_ptype.
2325+
*/
2326+
struct rte_flow_item_ptype {
2327+
uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
2328+
};
2329+
2330+
/** Default mask for RTE_FLOW_ITEM_TYPE_PTYPE. */
2331+
#ifndef __cplusplus
2332+
static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
2333+
.packet_type = 0xffffffff,
2334+
};
2335+
#endif
2336+
23122337
/**
23132338
* Action types.
23142339
*

0 commit comments

Comments
 (0)