ethdev: add meter color flow matching item
Provide an ability to use a Color Marker set by a Meter as a matching item in Flow API. The Color Marker reflects the metering result by setting the metadata for a packet to a particular codepoint: green, yellow or red. Add testpmd command line to match on a meter color: flow create 0 ingress group 0 pattern meter color is green / end Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com> Acked-by: Ori Kam <orika@nvidia.com> Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
This commit is contained in:
parent
d971cf02cd
commit
3af7a4af1a
@ -459,6 +459,9 @@ enum index {
|
|||||||
ITEM_PPP_ADDR,
|
ITEM_PPP_ADDR,
|
||||||
ITEM_PPP_CTRL,
|
ITEM_PPP_CTRL,
|
||||||
ITEM_PPP_PROTO_ID,
|
ITEM_PPP_PROTO_ID,
|
||||||
|
ITEM_METER,
|
||||||
|
ITEM_METER_COLOR,
|
||||||
|
ITEM_METER_COLOR_NAME,
|
||||||
|
|
||||||
/* Validate/create actions. */
|
/* Validate/create actions. */
|
||||||
ACTIONS,
|
ACTIONS,
|
||||||
@ -799,6 +802,10 @@ static const char *const modify_field_ids[] = {
|
|||||||
"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", NULL
|
"ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *const meter_colors[] = {
|
||||||
|
"green", "yellow", "red", "all", NULL
|
||||||
|
};
|
||||||
|
|
||||||
/** Maximum number of subsequent tokens and arguments on the stack. */
|
/** Maximum number of subsequent tokens and arguments on the stack. */
|
||||||
#define CTX_STACK_SIZE 16
|
#define CTX_STACK_SIZE 16
|
||||||
|
|
||||||
@ -1337,6 +1344,7 @@ static const enum index next_item[] = {
|
|||||||
ITEM_FLEX,
|
ITEM_FLEX,
|
||||||
ITEM_L2TPV2,
|
ITEM_L2TPV2,
|
||||||
ITEM_PPP,
|
ITEM_PPP,
|
||||||
|
ITEM_METER,
|
||||||
END_SET,
|
END_SET,
|
||||||
ZERO,
|
ZERO,
|
||||||
};
|
};
|
||||||
@ -1797,6 +1805,12 @@ static const enum index item_ppp[] = {
|
|||||||
ZERO,
|
ZERO,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const enum index item_meter[] = {
|
||||||
|
ITEM_METER_COLOR,
|
||||||
|
ITEM_NEXT,
|
||||||
|
ZERO,
|
||||||
|
};
|
||||||
|
|
||||||
static const enum index next_action[] = {
|
static const enum index next_action[] = {
|
||||||
ACTION_END,
|
ACTION_END,
|
||||||
ACTION_VOID,
|
ACTION_VOID,
|
||||||
@ -2357,6 +2371,9 @@ static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
|
|||||||
static int parse_mp(struct context *, const struct token *,
|
static int parse_mp(struct context *, const struct token *,
|
||||||
const char *, unsigned int,
|
const char *, unsigned int,
|
||||||
void *, unsigned int);
|
void *, unsigned int);
|
||||||
|
static int parse_meter_color(struct context *ctx, const struct token *token,
|
||||||
|
const char *str, unsigned int len, void *buf,
|
||||||
|
unsigned int size);
|
||||||
static int comp_none(struct context *, const struct token *,
|
static int comp_none(struct context *, const struct token *,
|
||||||
unsigned int, char *, unsigned int);
|
unsigned int, char *, unsigned int);
|
||||||
static int comp_boolean(struct context *, const struct token *,
|
static int comp_boolean(struct context *, const struct token *,
|
||||||
@ -2387,6 +2404,8 @@ static int comp_table_id(struct context *, const struct token *,
|
|||||||
unsigned int, char *, unsigned int);
|
unsigned int, char *, unsigned int);
|
||||||
static int comp_queue_id(struct context *, const struct token *,
|
static int comp_queue_id(struct context *, const struct token *,
|
||||||
unsigned int, char *, unsigned int);
|
unsigned int, char *, unsigned int);
|
||||||
|
static int comp_meter_color(struct context *, const struct token *,
|
||||||
|
unsigned int, char *, unsigned int);
|
||||||
|
|
||||||
/** Token definitions. */
|
/** Token definitions. */
|
||||||
static const struct token token_list[] = {
|
static const struct token token_list[] = {
|
||||||
@ -5038,6 +5057,29 @@ static const struct token token_list[] = {
|
|||||||
.args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp,
|
.args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp,
|
||||||
hdr.proto_id)),
|
hdr.proto_id)),
|
||||||
},
|
},
|
||||||
|
[ITEM_METER] = {
|
||||||
|
.name = "meter",
|
||||||
|
.help = "match meter color",
|
||||||
|
.priv = PRIV_ITEM(METER_COLOR,
|
||||||
|
sizeof(struct rte_flow_item_meter_color)),
|
||||||
|
.next = NEXT(item_meter),
|
||||||
|
.call = parse_vc,
|
||||||
|
},
|
||||||
|
[ITEM_METER_COLOR] = {
|
||||||
|
.name = "color",
|
||||||
|
.help = "meter color",
|
||||||
|
.next = NEXT(item_meter,
|
||||||
|
NEXT_ENTRY(ITEM_METER_COLOR_NAME),
|
||||||
|
item_param),
|
||||||
|
.args = ARGS(ARGS_ENTRY(struct rte_flow_item_meter_color,
|
||||||
|
color)),
|
||||||
|
},
|
||||||
|
[ITEM_METER_COLOR_NAME] = {
|
||||||
|
.name = "color_name",
|
||||||
|
.help = "meter color name",
|
||||||
|
.call = parse_meter_color,
|
||||||
|
.comp = comp_meter_color,
|
||||||
|
},
|
||||||
/* Validate/create actions. */
|
/* Validate/create actions. */
|
||||||
[ACTIONS] = {
|
[ACTIONS] = {
|
||||||
.name = "actions",
|
.name = "actions",
|
||||||
@ -9819,6 +9861,30 @@ parse_flex_handle(struct context *ctx, const struct token *token,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Parse Meter color name */
|
||||||
|
static int
|
||||||
|
parse_meter_color(struct context *ctx, const struct token *token,
|
||||||
|
const char *str, unsigned int len, void *buf,
|
||||||
|
unsigned int size)
|
||||||
|
{
|
||||||
|
struct rte_flow_item_meter_color *meter_color;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
(void)token;
|
||||||
|
(void)buf;
|
||||||
|
(void)size;
|
||||||
|
for (i = 0; meter_colors[i]; ++i)
|
||||||
|
if (!strcmp_partial(meter_colors[i], str, len))
|
||||||
|
break;
|
||||||
|
if (!meter_colors[i])
|
||||||
|
return -1;
|
||||||
|
if (!ctx->object)
|
||||||
|
return len;
|
||||||
|
meter_color = ctx->object;
|
||||||
|
meter_color->color = (enum rte_color)i;
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
/** No completion. */
|
/** No completion. */
|
||||||
static int
|
static int
|
||||||
comp_none(struct context *ctx, const struct token *token,
|
comp_none(struct context *ctx, const struct token *token,
|
||||||
@ -10110,6 +10176,20 @@ comp_queue_id(struct context *ctx, const struct token *token,
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Complete available Meter colors. */
|
||||||
|
static int
|
||||||
|
comp_meter_color(struct context *ctx, const struct token *token,
|
||||||
|
unsigned int ent, char *buf, unsigned int size)
|
||||||
|
{
|
||||||
|
RTE_SET_USED(ctx);
|
||||||
|
RTE_SET_USED(token);
|
||||||
|
if (!buf)
|
||||||
|
return RTE_DIM(meter_colors);
|
||||||
|
if (ent < RTE_DIM(meter_colors) - 1)
|
||||||
|
return strlcpy(buf, meter_colors[ent], size);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/** Internal context. */
|
/** Internal context. */
|
||||||
static struct context cmd_flow_context;
|
static struct context cmd_flow_context;
|
||||||
|
|
||||||
@ -10727,6 +10807,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
|
|||||||
case RTE_FLOW_ITEM_TYPE_PPP:
|
case RTE_FLOW_ITEM_TYPE_PPP:
|
||||||
mask = &rte_flow_item_ppp_mask;
|
mask = &rte_flow_item_ppp_mask;
|
||||||
break;
|
break;
|
||||||
|
case RTE_FLOW_ITEM_TYPE_METER_COLOR:
|
||||||
|
mask = &rte_flow_item_meter_color_mask;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1542,6 +1542,13 @@ Matches a PPP header.
|
|||||||
- ``proto_id``: PPP protocol identifier.
|
- ``proto_id``: PPP protocol identifier.
|
||||||
- Default ``mask`` matches addr, ctrl, proto_id.
|
- Default ``mask`` matches addr, ctrl, proto_id.
|
||||||
|
|
||||||
|
Item: ``METER_COLOR``
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Matches Color Marker set by a Meter.
|
||||||
|
|
||||||
|
- ``color``: Metering color marker.
|
||||||
|
|
||||||
Actions
|
Actions
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
|
||||||
|
@ -74,6 +74,10 @@ New Features
|
|||||||
Added new function ``rte_flow_async_action_handle_query()``,
|
Added new function ``rte_flow_async_action_handle_query()``,
|
||||||
to query the action asynchronously.
|
to query the action asynchronously.
|
||||||
|
|
||||||
|
* **Extended metering and marking support in the flow API.**
|
||||||
|
|
||||||
|
* Added METER_COLOR item to match color marker set by a meter.
|
||||||
|
|
||||||
* **Updated Intel iavf driver.**
|
* **Updated Intel iavf driver.**
|
||||||
|
|
||||||
* Added flow subscription support.
|
* Added flow subscription support.
|
||||||
|
@ -3687,6 +3687,10 @@ This section lists supported pattern items and their attributes, if any.
|
|||||||
- ``ctrl {unsigned}``: PPP control.
|
- ``ctrl {unsigned}``: PPP control.
|
||||||
- ``proto_id {unsigned}``: PPP protocol identifier.
|
- ``proto_id {unsigned}``: PPP protocol identifier.
|
||||||
|
|
||||||
|
- ``meter``: match meter color.
|
||||||
|
|
||||||
|
- ``color {value}``: meter color value (green/yellow/red).
|
||||||
|
|
||||||
Actions list
|
Actions list
|
||||||
^^^^^^^^^^^^
|
^^^^^^^^^^^^
|
||||||
|
|
||||||
|
@ -156,6 +156,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
|
|||||||
rte_flow_item_flex_conv),
|
rte_flow_item_flex_conv),
|
||||||
MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
|
MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
|
||||||
MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
|
MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
|
||||||
|
MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)),
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Generate flow_action[] entry. */
|
/** Generate flow_action[] entry. */
|
||||||
|
@ -634,6 +634,13 @@ enum rte_flow_item_type {
|
|||||||
* See struct rte_flow_item_macsec.
|
* See struct rte_flow_item_macsec.
|
||||||
*/
|
*/
|
||||||
RTE_FLOW_ITEM_TYPE_MACSEC,
|
RTE_FLOW_ITEM_TYPE_MACSEC,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matches Meter Color Marker.
|
||||||
|
*
|
||||||
|
* See struct rte_flow_item_meter_color.
|
||||||
|
*/
|
||||||
|
RTE_FLOW_ITEM_TYPE_METER_COLOR,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2097,6 +2104,22 @@ struct rte_flow_item_flex_conf {
|
|||||||
uint32_t nb_outputs;
|
uint32_t nb_outputs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RTE_FLOW_ITEM_TYPE_METER_COLOR.
|
||||||
|
*
|
||||||
|
* Matches Color Marker set by a Meter.
|
||||||
|
*/
|
||||||
|
struct rte_flow_item_meter_color {
|
||||||
|
enum rte_color color; /**< Meter color marker. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Default mask for RTE_FLOW_ITEM_TYPE_METER_COLOR. */
|
||||||
|
#ifndef __cplusplus
|
||||||
|
static const struct rte_flow_item_meter_color rte_flow_item_meter_color_mask = {
|
||||||
|
.color = RTE_COLORS,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action types.
|
* Action types.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user