"get_5tuple_filter (port_id) index (idx)\n"
" get info of a 5tuple filter.\n\n"
- "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
- " add syn filter.\n\n"
-
- "remove_syn_filter (port_id)"
- " remove syn filter.\n\n"
-
- "get_syn_filter (port_id) "
- " get syn filter info.\n\n"
+ "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
+ " Add/Del syn filter.\n\n"
"flex_filter (port_id) (add|del) len (len_value)"
" bytes (bytes_value) mask (mask_value)"
},
};
-/* *** set SYN filter *** */
-struct cmd_set_syn_filter_result {
+/* *** Add/Del syn filter *** */
+struct cmd_syn_filter_result {
cmdline_fixed_string_t filter;
uint8_t port_id;
+ cmdline_fixed_string_t ops;
cmdline_fixed_string_t priority;
cmdline_fixed_string_t high;
cmdline_fixed_string_t queue;
- uint16_t queue_id;
+ uint16_t queue_id;
};
static void
-cmd_set_syn_filter_parsed(void *parsed_result,
+cmd_syn_filter_parsed(void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
+ struct cmd_syn_filter_result *res = parsed_result;
+ struct rte_eth_syn_filter syn_filter;
int ret = 0;
- struct cmd_set_syn_filter_result *res = parsed_result;
- struct rte_syn_filter filter;
- if (!strcmp(res->filter, "add_syn_filter")) {
+ ret = rte_eth_dev_filter_supported(res->port_id,
+ RTE_ETH_FILTER_SYN);
+ if (ret < 0) {
+ printf("syn filter is not supported on port %u.\n",
+ res->port_id);
+ return;
+ }
+
+ memset(&syn_filter, 0, sizeof(syn_filter));
+
+ if (!strcmp(res->ops, "add")) {
if (!strcmp(res->high, "high"))
- filter.hig_pri = 1;
+ syn_filter.hig_pri = 1;
else
- filter.hig_pri = 0;
- ret = rte_eth_dev_add_syn_filter(res->port_id,
- &filter, res->queue_id);
- } else if (!strcmp(res->filter, "remove_syn_filter"))
- ret = rte_eth_dev_remove_syn_filter(res->port_id);
- else if (!strcmp(res->filter, "get_syn_filter"))
- get_syn_filter(res->port_id);
- if (ret < 0)
- printf("syn filter setting error: (%s)\n", strerror(-ret));
+ syn_filter.hig_pri = 0;
+
+ syn_filter.queue = res->queue_id;
+ ret = rte_eth_dev_filter_ctrl(res->port_id,
+ RTE_ETH_FILTER_SYN,
+ RTE_ETH_FILTER_ADD,
+ &syn_filter);
+ } else
+ ret = rte_eth_dev_filter_ctrl(res->port_id,
+ RTE_ETH_FILTER_SYN,
+ RTE_ETH_FILTER_DELETE,
+ &syn_filter);
+ if (ret < 0)
+ printf("syn filter programming error: (%s)\n",
+ strerror(-ret));
}
-cmdline_parse_token_num_t cmd_syn_filter_portid =
- TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
- port_id, UINT8);
+
+cmdline_parse_token_string_t cmd_syn_filter_filter =
+ TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
+ filter, "syn_filter");
+cmdline_parse_token_num_t cmd_syn_filter_port_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
+ port_id, UINT8);
+cmdline_parse_token_string_t cmd_syn_filter_ops =
+ TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
+ ops, "add#del");
cmdline_parse_token_string_t cmd_syn_filter_priority =
- TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
+ TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
priority, "priority");
cmdline_parse_token_string_t cmd_syn_filter_high =
- TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
+ TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
high, "high#low");
cmdline_parse_token_string_t cmd_syn_filter_queue =
- TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
+ TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
queue, "queue");
cmdline_parse_token_num_t cmd_syn_filter_queue_id =
- TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
+ TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
queue_id, UINT16);
-cmdline_parse_token_string_t cmd_syn_filter_add_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
- filter, "add_syn_filter");
-cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
- filter, "remove_syn_filter");
-cmdline_parse_inst_t cmd_add_syn_filter = {
- .f = cmd_set_syn_filter_parsed,
- .data = NULL,
- .help_str = "add syn filter",
- .tokens = {
- (void *)&cmd_syn_filter_add_filter,
- (void *)&cmd_syn_filter_portid,
- (void *)&cmd_syn_filter_priority,
- (void *)&cmd_syn_filter_high,
- (void *)&cmd_syn_filter_queue,
- (void *)&cmd_syn_filter_queue_id,
- NULL,
- },
-};
-cmdline_parse_inst_t cmd_remove_syn_filter = {
- .f = cmd_set_syn_filter_parsed,
- .data = NULL,
- .help_str = "remove syn filter",
- .tokens = {
- (void *)&cmd_syn_filter_remove_filter,
- (void *)&cmd_syn_filter_portid,
- NULL,
- },
-};
-
-cmdline_parse_token_string_t cmd_syn_filter_get_filter =
- TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
- filter, "get_syn_filter");
-cmdline_parse_inst_t cmd_get_syn_filter = {
- .f = cmd_set_syn_filter_parsed,
- .data = NULL,
- .help_str = "get syn filter",
- .tokens = {
- (void *)&cmd_syn_filter_get_filter,
- (void *)&cmd_syn_filter_portid,
- NULL,
- },
+cmdline_parse_inst_t cmd_syn_filter = {
+ .f = cmd_syn_filter_parsed,
+ .data = NULL,
+ .help_str = "add/delete syn filter",
+ .tokens = {
+ (void *)&cmd_syn_filter_filter,
+ (void *)&cmd_syn_filter_port_id,
+ (void *)&cmd_syn_filter_ops,
+ (void *)&cmd_syn_filter_priority,
+ (void *)&cmd_syn_filter_high,
+ (void *)&cmd_syn_filter_queue,
+ (void *)&cmd_syn_filter_queue_id,
+ NULL,
+ },
};
/* *** ADD/REMOVE A 2tuple FILTER *** */
(cmdline_parse_inst_t *)&cmd_dump,
(cmdline_parse_inst_t *)&cmd_dump_one,
(cmdline_parse_inst_t *)&cmd_ethertype_filter,
- (cmdline_parse_inst_t *)&cmd_add_syn_filter,
- (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
- (cmdline_parse_inst_t *)&cmd_get_syn_filter,
+ (cmdline_parse_inst_t *)&cmd_syn_filter,
(cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
(cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
(cmdline_parse_inst_t *)&cmd_get_2tuple_filter,