diff options
| author | Suanming Mou <[email protected]> | 2024-02-06 10:06:24 +0800 |
|---|---|---|
| committer | Ferruh Yigit <[email protected]> | 2024-02-06 22:22:03 +0100 |
| commit | 58143b7b386dd15c7e5db5cf5b280bcd19f6241b (patch) | |
| tree | 1250c9ca6c583992c3d571c36f2c27767041fb1d /lib/ethdev | |
| parent | f8d14aab1aec366cffe5eafa68b42955b1a21248 (diff) | |
ethdev: add flow item for comparison
The new item type is added for the case user wants to match traffic
based on packet field compare result with other fields or immediate
value.
e.g. take advantage the compare item user will be able to accumulate
a IPv4/TCP packet's TCP data_offset and IPv4 IHL field to a tag
register, then compare the tag register with IPv4 header total length
to understand the packet has payload or not.
The supported operations can be as below:
- RTE_FLOW_ITEM_COMPARE_EQ (equal)
- RTE_FLOW_ITEM_COMPARE_NE (not equal)
- RTE_FLOW_ITEM_COMPARE_LT (less than)
- RTE_FLOW_ITEM_COMPARE_LE (less than or equal)
- RTE_FLOW_ITEM_COMPARE_GT (great than)
- RTE_FLOW_ITEM_COMPARE_GE (great than or equal)
A sample for create the comparison flow:
flow pattern_template 0 create ingress pattern_template_id 1 template \
compare op mask le a_type mask tag a_tag_index mask 1 b_type \
mask tag b_tag_index mask 2 width mask 0xffffffff / end
flow actions_template 0 create ingress actions_template_id 1 template \
count / drop / end mask count / drop / end
flow template_table 0 create table_id 1 group 2 priority 1 ingress \
rules_number 1 pattern_template 1 actions_template 1
flow queue 0 create 0 template_table 1 pattern_template 0 \
actions_template 0 postpone no pattern compare op is le \
a_type is tag a_tag_index is 1 b_type is tag b_tag_index is 2 \
width is 32 / end actions count / drop / end
Signed-off-by: Suanming Mou <[email protected]>
Acked-by: Ori Kam <[email protected]>
Acked-by: Andrew Rybchenko <[email protected]>
Acked-by: Ferruh Yigit <[email protected]>
Diffstat (limited to 'lib/ethdev')
| -rw-r--r-- | lib/ethdev/rte_flow.c | 1 | ||||
| -rw-r--r-- | lib/ethdev/rte_flow.h | 40 |
2 files changed, 39 insertions, 2 deletions
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 8d795de02d..b6fc6a33e9 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -171,6 +171,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(TX_QUEUE, sizeof(struct rte_flow_item_tx_queue)), MK_FLOW_ITEM(IB_BTH, sizeof(struct rte_flow_item_ib_bth)), MK_FLOW_ITEM(PTYPE, sizeof(struct rte_flow_item_ptype)), + MK_FLOW_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 21fd404d8f..fda927adee 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -714,6 +714,13 @@ enum rte_flow_item_type { * @see struct rte_flow_item_random. */ RTE_FLOW_ITEM_TYPE_RANDOM, + + /** + * Match packet with various comparison types. + * + * See struct rte_flow_item_compare. + */ + RTE_FLOW_ITEM_TYPE_COMPARE, }; /** @@ -2366,7 +2373,8 @@ static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = { #endif /** - * Packet header field IDs, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. + * Packet header field IDs, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD + * and RTE_FLOW_ITEM_TYPE_COMPARE. */ enum rte_flow_field_id { RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */ @@ -2420,7 +2428,8 @@ enum rte_flow_field_id { * @warning * @b EXPERIMENTAL: this structure may change without prior notice. * - * Packet header field descriptions, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD. + * Packet header field descriptions, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD + * and RTE_FLOW_ITEM_TYPE_COMPARE. */ struct rte_flow_field_data { enum rte_flow_field_id field; /**< Field or memory type ID. */ @@ -2511,6 +2520,33 @@ struct rte_flow_field_data { }; /** + * Expected operation types for compare item. + */ +enum rte_flow_item_compare_op { + RTE_FLOW_ITEM_COMPARE_EQ, /* Compare result equal. */ + RTE_FLOW_ITEM_COMPARE_NE, /* Compare result not equal. */ + RTE_FLOW_ITEM_COMPARE_LT, /* Compare result less than. */ + RTE_FLOW_ITEM_COMPARE_LE, /* Compare result less than or equal. */ + RTE_FLOW_ITEM_COMPARE_GT, /* Compare result great than. */ + RTE_FLOW_ITEM_COMPARE_GE, /* Compare result great than or equal. */ +}; + +/** + * + * RTE_FLOW_ITEM_TYPE_COMPARE + * + * Matches the packet with compare result. + * + * The operation means a compare with b result. + */ +struct rte_flow_item_compare { + enum rte_flow_item_compare_op operation; /* The compare operation. */ + struct rte_flow_field_data a; /* Field be compared. */ + struct rte_flow_field_data b; /* Field as comparator. */ + uint32_t width; /* Compare width. */ +}; + +/** * Action types. * * Each possible action is represented by a type. |
