<snip> > > +/* *** Add Port TM Node WRED Profile *** */ struct > > +cmd_add_port_tm_node_wred_profile_result { > > + cmdline_fixed_string_t add; > > + cmdline_fixed_string_t port; > > + cmdline_fixed_string_t tm; > > + cmdline_fixed_string_t node; > > + cmdline_fixed_string_t wred; > > + cmdline_fixed_string_t profile; > > + uint16_t port_id; > > + uint32_t wred_profile_id; > > + cmdline_fixed_string_t color_g; > > + uint16_t min_th_g; > > + uint16_t max_th_g; > > + uint16_t maxp_inv_g; > > + uint16_t wq_log2_g; > > + cmdline_fixed_string_t color_y; > > + uint16_t min_th_y; > > + uint16_t max_th_y; > > + uint16_t maxp_inv_y; > > + uint16_t wq_log2_y; > > + cmdline_fixed_string_t color_r; > > + uint16_t min_th_r; > > + uint16_t max_th_r; > > + uint16_t maxp_inv_r; > > + uint16_t wq_log2_r; > > +}; > > + > > +cmdline_parse_token_string_t > cmd_add_port_tm_node_wred_profile_add = > > + TOKEN_STRING_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, add, > > "add"); > > +cmdline_parse_token_string_t > cmd_add_port_tm_node_wred_profile_port = > > + TOKEN_STRING_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, port, > > "port"); > > +cmdline_parse_token_string_t > cmd_add_port_tm_node_wred_profile_tm = > > + TOKEN_STRING_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, tm, > "tm"); > > +cmdline_parse_token_string_t > cmd_add_port_tm_node_wred_profile_node = > > + TOKEN_STRING_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, node, > > "node"); > > +cmdline_parse_token_string_t > cmd_add_port_tm_node_wred_profile_wred = > > + TOKEN_STRING_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, wred, > > "wred"); > > +cmdline_parse_token_string_t > > +cmd_add_port_tm_node_wred_profile_profile > > = > > + TOKEN_STRING_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + profile, "profile"); > > +cmdline_parse_token_num_t > cmd_add_port_tm_node_wred_profile_port_id > > = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + port_id, UINT16); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_wred_profile_id = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + wred_profile_id, UINT32); > > +cmdline_parse_token_string_t > > cmd_add_port_tm_node_wred_profile_color_g = > > + TOKEN_STRING_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + color_g, "G#g"); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_min_th_g = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + min_th_g, UINT16); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_max_th_g = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + max_th_g, UINT16); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_maxp_inv_g = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + maxp_inv_g, UINT16); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_wq_log2_g = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + wq_log2_g, UINT16); > > +cmdline_parse_token_string_t > > +cmd_add_port_tm_node_wred_profile_color_y > > = > > + TOKEN_STRING_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + color_y, "Y#y"); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_min_th_y = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + min_th_y, UINT16); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_max_th_y = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + max_th_y, UINT16); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_maxp_inv_y = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + maxp_inv_y, UINT16); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_wq_log2_y = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + wq_log2_y, UINT16); > > +cmdline_parse_token_string_t > > +cmd_add_port_tm_node_wred_profile_color_r > > = > > + TOKEN_STRING_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + color_r, "R#r"); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_min_th_r = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + min_th_r, UINT16); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_max_th_r = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + max_th_r, UINT16); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_maxp_inv_r = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + maxp_inv_r, UINT16); > > +cmdline_parse_token_num_t > > cmd_add_port_tm_node_wred_profile_wq_log2_r = > > + TOKEN_NUM_INITIALIZER( > > + struct cmd_add_port_tm_node_wred_profile_result, > > + wq_log2_r, UINT16); > > + > > + > > +static void cmd_add_port_tm_node_wred_profile_parsed(void > *parsed_result, > > + __attribute__((unused)) struct cmdline *cl, > > + __attribute__((unused)) void *data) > > +{ > > + struct cmd_add_port_tm_node_wred_profile_result *res = > > parsed_result; > > + struct rte_tm_wred_params wp; > > + enum rte_tm_color color; > > + struct rte_tm_error error; > > + uint32_t wred_profile_id = res->wred_profile_id; > > + portid_t port_id = res->port_id; > > + int ret; > > + > > + if (port_id_is_invalid(port_id, ENABLED_WARN)) > > + return; > > + > > + memset(&wp, 0, sizeof(struct rte_tm_wred_params)); > > + > > + /* WRED Params (Green Color)*/ > > + if ((strcmp(res->color_g, "G") == 0) || > > + (strcmp(res->color_g, "g") == 0)) { > > + color = RTE_TM_GREEN; > > + wp.red_params[color].min_th = res->min_th_g; > > + wp.red_params[color].max_th = res->max_th_g; > > + wp.red_params[color].maxp_inv = res->maxp_inv_g; > > + wp.red_params[color].wq_log2 = res->wq_log2_g; > > + } else { > > + printf("WRED profile error(G or g for green color)!\n"); > > + return; > > + } > > + > No need to check the res->color_g, because it already be checked by > cmdline. > Because you defined it like > cmd_add_port_tm_node_wred_profile_color_g = > TOKEN_STRING_INITIALIZER( > struct cmd_add_port_tm_node_wred_profile_result, > color_g, "G#g"); > You can just assign wp.red_params[RTE_TM_GREEN] directly. > The similar as color_y, color_r.
> And is that possible for you to set WERD with less than 3 colors? If so, you > may need to change your command definition. Ok, I will remove the extra check which seems unnecessary. Also, will try to simplify the command to single color instead of three color at a time. Thanks.