I am a student and currently working with BlueField-3 SuperNIC and DOCA-2.8.0, and I am attempting to sample (and mirror) a subset of packets into DPA using the FlexIO example’s packet processor. I am trying to use the mlx5dv_dr_action_create_flow_sampler action for sampling, but I have been unable to successfully apply the rules.
I have attached a snippet of my code below, and I am encountering an error when attempting to create a flow rule. The error message indicates a failure in creating the dr_rule with errno 95, which I believe corresponds to the “Operation not supported” error. I have verified that my hardware and software environment are correct, and the example code runs successfully except for this specific implementation.
Here is the relevant part of my code:
static struct flow_rule *create_flow_rule_rx_sample(struct flow_matcher *flow_matcher,
struct mlx5dv_devx_obj *tir_obj,
struct mlx5dv_flow_match_parameters *match_value)
{
struct flow_rule *flow_rule;
flow_rule = (struct flow_rule *)calloc(1, sizeof(*flow_rule));
assert(flow_rule);
struct mlx5dv_dr_action * tir_action = mlx5dv_dr_action_create_dest_devx_tir(tir_obj);
if (!tir_action) {
printf("Failed creating TIR action (errno %d).\n", errno);
goto err_out;
}
struct mlx5dv_dr_action *sample_actions[] = {tir_action};
struct mlx5dv_dr_flow_sampler_attr sampler_attr = {0};
sampler_attr.sample_ratio = 2;
sampler_attr.sample_actions = sample_actions;
sampler_attr.num_sample_actions = 1;
sampler_attr.default_next_table = flow_matcher->dr_table_sws; //level 1 table
sampler_attr.action = 0;
struct mlx5dv_dr_action * sample_action = mlx5dv_dr_action_create_flow_sampler(&sampler_attr);
if(!sample_action){
printf("Failed creating sampler action (errno %d).\n", errno);
goto err_out;
}
struct mlx5dv_dr_action *actions[] = {sample_action};
// add to level 0 table
flow_rule->dr_rule = mlx5dv_dr_rule_create(flow_matcher->dr_matcher_root, match_value, 1, actions);
if (!flow_rule->dr_rule) {
printf("Fail creating dr_rule (errno %d).\n", errno);
goto err_out;
}
return flow_rule;
err_out:
if (flow_rule->action)
mlx5dv_dr_action_destroy(flow_rule->action);
if (tir_action)
mlx5dv_dr_action_destroy(tir_action);
free(flow_rule);
return NULL;
}
And the error output:
Welcome to 'Flex IO SDK packet processing' sample app.
Use the token >>> 0x1f82fdb3f13d5c7e <<< for debugging
Fail creating dr_rule (errno 95).
I would greatly appreciate if you could provide some guidance or a usage example (even a pseudo-code) of how to correctly use the mlx5dv_dr_action_create_flow_sampler API. Your expertise in this area would be invaluable to help me resolve this issue.