struct rte_flow *flow;
static uint8_t flow_group;
+static uint64_t encap_data;
+static uint64_t decap_data;
+
static uint64_t flow_items[MAX_ITEMS_NUM];
static uint64_t flow_actions[MAX_ACTIONS_NUM];
static uint64_t flow_attrs[MAX_ATTRS_NUM];
static uint8_t items_idx, actions_idx, attrs_idx;
+static uint64_t ports_mask;
static volatile bool force_quit;
static bool dump_iterations;
static bool delete_flag;
printf(" --dump-socket-mem: To dump all socket memory\n");
printf(" --enable-fwd: To enable packets forwarding"
" after insertion\n");
+ printf(" --portmask=N: hexadecimal bitmask of ports used\n");
printf("To set flow attributes:\n");
printf(" --ingress: set ingress attribute in flows\n");
printf(" --gtp: add gtp layer in flow items\n");
printf(" --meta: add meta layer in flow items\n");
printf(" --tag: add tag layer in flow items\n");
+ printf(" --icmpv4: add icmpv4 layer in flow items\n");
+ printf(" --icmpv6: add icmpv6 layer in flow items\n");
printf("To set flow actions:\n");
printf(" --port-id: add port-id action in flow actions\n");
printf(" --set-ipv6-dscp: add set ipv6 dscp action to flow actions\n"
"ipv6 dscp value to be set is random each flow\n");
printf(" --flag: add flag action to flow actions\n");
+ printf(" --raw-encap=<data>: add raw encap action to flow actions\n"
+ "Data is the data needed to be encaped\n"
+ "Example: raw-encap=ether,ipv4,udp,vxlan\n");
+ printf(" --raw-decap=<data>: add raw decap action to flow actions\n"
+ "Data is the data needed to be decaped\n"
+ "Example: raw-decap=ether,ipv4,udp,vxlan\n");
+ printf(" --vxlan-encap: add vxlan-encap action to flow actions\n"
+ "Encapped data is fixed with pattern: ether,ipv4,udp,vxlan\n"
+ "With fixed values\n");
+ printf(" --vxlan-decap: add vxlan_decap action to flow actions\n");
}
static void
args_parse(int argc, char **argv)
{
+ uint64_t pm;
char **argvopt;
+ char *token;
+ char *end;
int n, opt;
int opt_idx;
size_t i;
.map = &flow_items[0],
.map_idx = &items_idx
},
+ {
+ .str = "icmpv4",
+ .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ICMP),
+ .map = &flow_items[0],
+ .map_idx = &items_idx
+ },
+ {
+ .str = "icmpv6",
+ .mask = FLOW_ITEM_MASK(RTE_FLOW_ITEM_TYPE_ICMP6),
+ .map = &flow_items[0],
+ .map_idx = &items_idx
+ },
{
.str = "ingress",
.mask = INGRESS,
.map = &flow_actions[0],
.map_idx = &actions_idx
},
+ {
+ .str = "vxlan-encap",
+ .mask = FLOW_ACTION_MASK(
+ RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
+ ),
+ .map = &flow_actions[0],
+ .map_idx = &actions_idx
+ },
+ {
+ .str = "vxlan-decap",
+ .mask = FLOW_ACTION_MASK(
+ RTE_FLOW_ACTION_TYPE_VXLAN_DECAP
+ ),
+ .map = &flow_actions[0],
+ .map_idx = &actions_idx
+ },
};
static const struct option lgopts[] = {
{ "deletion-rate", 0, 0, 0 },
{ "dump-socket-mem", 0, 0, 0 },
{ "enable-fwd", 0, 0, 0 },
+ { "portmask", 1, 0, 0 },
/* Attributes */
{ "ingress", 0, 0, 0 },
{ "egress", 0, 0, 0 },
{ "gtp", 0, 0, 0 },
{ "meta", 0, 0, 0 },
{ "tag", 0, 0, 0 },
+ { "icmpv4", 0, 0, 0 },
+ { "icmpv6", 0, 0, 0 },
/* Actions */
{ "port-id", 0, 0, 0 },
{ "rss", 0, 0, 0 },
{ "set-ipv4-dscp", 0, 0, 0 },
{ "set-ipv6-dscp", 0, 0, 0 },
{ "flag", 0, 0, 0 },
+ { "raw-encap", 1, 0, 0 },
+ { "raw-decap", 1, 0, 0 },
+ { "vxlan-encap", 0, 0, 0 },
+ { "vxlan-decap", 0, 0, 0 },
};
+ RTE_ETH_FOREACH_DEV(i)
+ ports_mask |= 1 << i;
+
hairpin_queues_num = 0;
argvopt = argv;
printf("hairpin-queue / ");
}
+ if (strcmp(lgopts[opt_idx].name, "raw-encap") == 0) {
+ printf("raw-encap ");
+ flow_actions[actions_idx++] =
+ FLOW_ITEM_MASK(
+ RTE_FLOW_ACTION_TYPE_RAW_ENCAP
+ );
+
+ token = strtok(optarg, ",");
+ while (token != NULL) {
+ for (i = 0; i < RTE_DIM(flow_options); i++) {
+ if (strcmp(flow_options[i].str, token) == 0) {
+ printf("%s,", token);
+ encap_data |= flow_options[i].mask;
+ break;
+ }
+ /* Reached last item with no match */
+ if (i == (RTE_DIM(flow_options) - 1)) {
+ fprintf(stderr, "Invalid encap item: %s\n", token);
+ usage(argv[0]);
+ rte_exit(EXIT_SUCCESS, "Invalid encap item\n");
+ }
+ }
+ token = strtok(NULL, ",");
+ }
+ printf(" / ");
+ }
+ if (strcmp(lgopts[opt_idx].name, "raw-decap") == 0) {
+ printf("raw-decap ");
+ flow_actions[actions_idx++] =
+ FLOW_ITEM_MASK(
+ RTE_FLOW_ACTION_TYPE_RAW_DECAP
+ );
+
+ token = strtok(optarg, ",");
+ while (token != NULL) {
+ for (i = 0; i < RTE_DIM(flow_options); i++) {
+ if (strcmp(flow_options[i].str, token) == 0) {
+ printf("%s,", token);
+ encap_data |= flow_options[i].mask;
+ break;
+ }
+ /* Reached last item with no match */
+ if (i == (RTE_DIM(flow_options) - 1)) {
+ fprintf(stderr, "Invalid decap item: %s\n", token);
+ usage(argv[0]);
+ rte_exit(EXIT_SUCCESS, "Invalid decap item\n");
+ }
+ }
+ token = strtok(NULL, ",");
+ }
+ printf(" / ");
+ }
/* Control */
if (strcmp(lgopts[opt_idx].name,
"flows-count") == 0) {
if (strcmp(lgopts[opt_idx].name,
"enable-fwd") == 0)
enable_fwd = true;
+ if (strcmp(lgopts[opt_idx].name,
+ "portmask") == 0) {
+ /* parse hexadecimal string */
+ end = NULL;
+ pm = strtoull(optarg, &end, 16);
+ if ((optarg[0] == '\0') || (end == NULL) || (*end != '\0'))
+ rte_exit(EXIT_FAILURE, "Invalid fwd port mask\n");
+ ports_mask = pm;
+ }
break;
default:
fprintf(stderr, "Invalid option: %s\n", argv[optind]);
rte_exit(EXIT_FAILURE, "No Memory available!");
for (port_id = 0; port_id < nr_ports; port_id++) {
+ /* If port outside portmask */
+ if (!((ports_mask >> port_id) & 0x1))
+ continue;
cpu_time_used = 0;
flow_index = 0;
if (flow_group > 0) {
*/
flow = generate_flow(port_id, 0, flow_attrs,
global_items, global_actions,
- flow_group, 0, 0, &error);
+ flow_group, 0, 0, 0, 0, &error);
if (flow == NULL) {
print_flow_error(error);
flow = generate_flow(port_id, flow_group,
flow_attrs, flow_items, flow_actions,
JUMP_ACTION_TABLE, i,
- hairpin_queues_num, &error);
+ hairpin_queues_num,
+ encap_data, decap_data,
+ &error);
if (force_quit)
i = flows_count;
if (enable_fwd) {
init_lcore_info();
- rte_eal_mp_remote_launch(start_forwarding, NULL, CALL_MASTER);
+ rte_eal_mp_remote_launch(start_forwarding, NULL, CALL_MAIN);
}
RTE_ETH_FOREACH_DEV(port) {
rte_flow_flush(port, &error);
- rte_eth_dev_stop(port);
+ if (rte_eth_dev_stop(port) != 0)
+ printf("Failed to stop device on port %u\n", port);
rte_eth_dev_close(port);
}
return 0;