ethdev: add protocol parameter to color table update
Using rte_mtr_color_in_protocol_set(), user can configure combination of protocol headers, like outer_vlan and outer_ip, can be enabled on given meter object. But rte_mtr_meter_vlan_table_update() and rte_mtr_meter_dscp_table_update() do not have information that which table needs to be updated corresponding to protocol header i.e. inner or outer. Adding protocol paramreter will allow user to provide required protocol information so that corresponding inner or outer table can be updated corresponding to protocol header. If user wishes to configure both inner and outer table then API must be called twice with correct protocol information. Signed-off-by: Sunil Kumar Kori <skori@marvell.com> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
This commit is contained in:
parent
9c4a0c1859
commit
204daeea01
@ -299,8 +299,8 @@ parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
|
||||
}
|
||||
|
||||
static int
|
||||
parse_multi_token_string(char *t_str, uint16_t *port_id,
|
||||
uint32_t *mtr_id, enum rte_color **dscp_table)
|
||||
parse_multi_token_string(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
|
||||
enum rte_mtr_color_in_protocol *proto, enum rte_color **dscp_table)
|
||||
{
|
||||
char *token;
|
||||
uint64_t val;
|
||||
@ -328,6 +328,16 @@ parse_multi_token_string(char *t_str, uint16_t *port_id,
|
||||
|
||||
*mtr_id = val;
|
||||
|
||||
/* Third token: protocol */
|
||||
token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
|
||||
if (token == NULL)
|
||||
return 0;
|
||||
|
||||
if (strcmp(token, "outer_ip") == 0)
|
||||
*proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
|
||||
else if (strcmp(token, "inner_ip") == 0)
|
||||
*proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
|
||||
|
||||
ret = parse_dscp_table_entries(t_str, dscp_table);
|
||||
if (ret != 0)
|
||||
return -1;
|
||||
@ -337,7 +347,7 @@ parse_multi_token_string(char *t_str, uint16_t *port_id,
|
||||
|
||||
static int
|
||||
parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
|
||||
enum rte_color **vlan_table)
|
||||
enum rte_mtr_color_in_protocol *proto, enum rte_color **vlan_table)
|
||||
{
|
||||
uint64_t val;
|
||||
char *token;
|
||||
@ -365,6 +375,16 @@ parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
|
||||
|
||||
*mtr_id = val;
|
||||
|
||||
/* Third token: protocol */
|
||||
token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
|
||||
if (token == NULL)
|
||||
return 0;
|
||||
|
||||
if (strcmp(token, "outer_vlan") == 0)
|
||||
*proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
|
||||
else if (strcmp(token, "inner_vlan") == 0)
|
||||
*proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
|
||||
|
||||
ret = parse_vlan_table_entries(t_str, vlan_table);
|
||||
if (ret != 0)
|
||||
return -1;
|
||||
@ -1390,6 +1410,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
|
||||
__rte_unused void *data)
|
||||
{
|
||||
struct cmd_set_port_meter_dscp_table_result *res = parsed_result;
|
||||
enum rte_mtr_color_in_protocol proto = 0;
|
||||
struct rte_mtr_error error;
|
||||
enum rte_color *dscp_table = NULL;
|
||||
char *t_str = res->token_string;
|
||||
@ -1398,7 +1419,8 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
|
||||
int ret;
|
||||
|
||||
/* Parse string */
|
||||
ret = parse_multi_token_string(t_str, &port_id, &mtr_id, &dscp_table);
|
||||
ret = parse_multi_token_string(t_str, &port_id, &mtr_id, &proto,
|
||||
&dscp_table);
|
||||
if (ret) {
|
||||
fprintf(stderr, " Multi token string parse error\n");
|
||||
return;
|
||||
@ -1408,7 +1430,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
|
||||
goto free_table;
|
||||
|
||||
/* Update Meter DSCP Table*/
|
||||
ret = rte_mtr_meter_dscp_table_update(port_id, mtr_id,
|
||||
ret = rte_mtr_meter_dscp_table_update(port_id, mtr_id, proto,
|
||||
dscp_table, &error);
|
||||
if (ret != 0)
|
||||
print_err_msg(&error);
|
||||
@ -1420,7 +1442,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
|
||||
cmdline_parse_inst_t cmd_set_port_meter_dscp_table = {
|
||||
.f = cmd_set_port_meter_dscp_table_parsed,
|
||||
.data = NULL,
|
||||
.help_str = "set port meter dscp table <port_id> <mtr_id> "
|
||||
.help_str = "set port meter dscp table <port_id> <mtr_id> <proto> "
|
||||
"[<dscp_tbl_entry0> <dscp_tbl_entry1> ... <dscp_tbl_entry63>]",
|
||||
.tokens = {
|
||||
(void *)&cmd_set_port_meter_dscp_table_set,
|
||||
@ -1463,6 +1485,7 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
|
||||
__rte_unused void *data)
|
||||
{
|
||||
struct cmd_set_port_meter_vlan_table_result *res = parsed_result;
|
||||
enum rte_mtr_color_in_protocol proto = 0;
|
||||
struct rte_mtr_error error;
|
||||
enum rte_color *vlan_table = NULL;
|
||||
char *t_str = res->token_string;
|
||||
@ -1471,7 +1494,8 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
|
||||
int ret;
|
||||
|
||||
/* Parse string */
|
||||
ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &vlan_table);
|
||||
ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &proto,
|
||||
&vlan_table);
|
||||
if (ret) {
|
||||
fprintf(stderr, " Multi token string parse error\n");
|
||||
return;
|
||||
@ -1481,7 +1505,7 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
|
||||
goto free_table;
|
||||
|
||||
/* Update Meter VLAN Table*/
|
||||
ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id,
|
||||
ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id, proto,
|
||||
vlan_table, &error);
|
||||
if (ret != 0)
|
||||
print_err_msg(&error);
|
||||
@ -1493,7 +1517,7 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
|
||||
cmdline_parse_inst_t cmd_set_port_meter_vlan_table = {
|
||||
.f = cmd_set_port_meter_vlan_table_parsed,
|
||||
.data = NULL,
|
||||
.help_str = "set port meter vlan table <port_id> <mtr_id> "
|
||||
.help_str = "set port meter vlan table <port_id> <mtr_id> <proto> "
|
||||
"[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>]",
|
||||
.tokens = {
|
||||
(void *)&cmd_set_port_meter_vlan_table_set,
|
||||
|
@ -2428,15 +2428,15 @@ set port meter dscp table
|
||||
|
||||
Set meter dscp table for the ethernet device::
|
||||
|
||||
testpmd> set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0) \
|
||||
(dscp_tbl_entry1)...(dscp_tbl_entry63)]
|
||||
testpmd> set port meter dscp table (port_id) (mtr_id) (proto) \
|
||||
[(dscp_tbl_entry0) (dscp_tbl_entry1)...(dscp_tbl_entry63)]
|
||||
|
||||
set port meter vlan table
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Set meter VLAN table for the Ethernet device::
|
||||
|
||||
testpmd> set port meter vlan table (port_id) (mtr_id) [(vlan_tbl_entry0) \
|
||||
(vlan_tbl_entry1)...(vlan_tbl_entry15)]
|
||||
testpmd> set port meter vlan table (port_id) (mtr_id) (proto) \
|
||||
[(vlan_tbl_entry0) (vlan_tbl_entry1)...(vlan_tbl_entry15)]
|
||||
|
||||
set port meter protocol
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -720,6 +720,7 @@ cnxk_nix_mtr_disable(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
|
||||
|
||||
static int
|
||||
cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
|
||||
enum rte_mtr_color_in_protocol proto,
|
||||
enum rte_color *dscp_table,
|
||||
struct rte_mtr_error *error)
|
||||
{
|
||||
@ -750,7 +751,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
|
||||
|
||||
table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP;
|
||||
|
||||
switch (dev->proto) {
|
||||
switch (proto) {
|
||||
case RTE_MTR_COLOR_IN_PROTO_OUTER_IP:
|
||||
table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER;
|
||||
break;
|
||||
@ -764,6 +765,13 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (dev->proto != proto) {
|
||||
rc = -rte_mtr_error_set(error, EINVAL,
|
||||
RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
|
||||
"input color protocol is not configured");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++)
|
||||
table.color[i] = nix_dscp_tbl[i];
|
||||
|
||||
@ -784,6 +792,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
|
||||
|
||||
static int
|
||||
cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
|
||||
enum rte_mtr_color_in_protocol proto,
|
||||
enum rte_color *vlan_table,
|
||||
struct rte_mtr_error *error)
|
||||
{
|
||||
@ -814,7 +823,7 @@ cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
|
||||
|
||||
table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN;
|
||||
|
||||
switch (dev->proto) {
|
||||
switch (proto) {
|
||||
case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN:
|
||||
table.mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER;
|
||||
break;
|
||||
@ -828,6 +837,13 @@ cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (dev->proto != proto) {
|
||||
rc = -rte_mtr_error_set(error, EINVAL,
|
||||
RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
|
||||
"input color protocol is not configured");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++)
|
||||
table.color[i] = nix_vlan_tbl[i];
|
||||
|
||||
|
@ -238,25 +238,25 @@ rte_mtr_meter_policy_update(uint16_t port_id,
|
||||
/** MTR object meter DSCP table update */
|
||||
int
|
||||
rte_mtr_meter_dscp_table_update(uint16_t port_id,
|
||||
uint32_t mtr_id,
|
||||
uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
|
||||
enum rte_color *dscp_table,
|
||||
struct rte_mtr_error *error)
|
||||
{
|
||||
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
|
||||
return RTE_MTR_FUNC(port_id, meter_dscp_table_update)(dev,
|
||||
mtr_id, dscp_table, error);
|
||||
mtr_id, proto, dscp_table, error);
|
||||
}
|
||||
|
||||
/** MTR object meter VLAN table update */
|
||||
int
|
||||
rte_mtr_meter_vlan_table_update(uint16_t port_id,
|
||||
uint32_t mtr_id,
|
||||
uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
|
||||
enum rte_color *vlan_table,
|
||||
struct rte_mtr_error *error)
|
||||
{
|
||||
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
|
||||
return RTE_MTR_FUNC(port_id, meter_vlan_table_update)(dev,
|
||||
mtr_id, vlan_table, error);
|
||||
mtr_id, proto, vlan_table, error);
|
||||
}
|
||||
|
||||
/** Set the input color protocol on MTR object */
|
||||
|
@ -953,6 +953,8 @@ rte_mtr_meter_policy_update(uint16_t port_id,
|
||||
* The port identifier of the Ethernet device.
|
||||
* @param[in] mtr_id
|
||||
* MTR object ID. Needs to be valid.
|
||||
* @param[in] proto
|
||||
* Input color protocol.
|
||||
* @param[in] dscp_table
|
||||
* When non-NULL: it points to a pre-allocated and pre-populated table with
|
||||
* exactly 64 elements providing the input color for each value of the
|
||||
@ -967,7 +969,7 @@ rte_mtr_meter_policy_update(uint16_t port_id,
|
||||
__rte_experimental
|
||||
int
|
||||
rte_mtr_meter_dscp_table_update(uint16_t port_id,
|
||||
uint32_t mtr_id,
|
||||
uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
|
||||
enum rte_color *dscp_table,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
@ -978,6 +980,8 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
|
||||
* The port identifier of the Ethernet device.
|
||||
* @param[in] mtr_id
|
||||
* MTR object ID. Needs to be valid.
|
||||
* @param[in] proto
|
||||
* Input color protocol.
|
||||
* @param[in] vlan_table
|
||||
* When non-NULL: it points to a pre-allocated and pre-populated table with
|
||||
* exactly 16 elements providing the input color for each value of the
|
||||
@ -992,6 +996,7 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
|
||||
__rte_experimental
|
||||
int
|
||||
rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
|
||||
enum rte_mtr_color_in_protocol proto,
|
||||
enum rte_color *vlan_table,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
|
@ -106,13 +106,13 @@ typedef int (*rte_mtr_meter_policy_update_t)(struct rte_eth_dev *dev,
|
||||
|
||||
/** @internal MTR object meter DSCP table update. */
|
||||
typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
|
||||
uint32_t mtr_id,
|
||||
uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
|
||||
enum rte_color *dscp_table,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
/** @internal mtr object meter vlan table update. */
|
||||
typedef int (*rte_mtr_meter_vlan_table_update_t)(struct rte_eth_dev *dev,
|
||||
uint32_t mtr_id,
|
||||
uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
|
||||
enum rte_color *vlan_table,
|
||||
struct rte_mtr_error *error);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user