+static cmdline_parse_token_ipaddr_t cmd_route_add2_ip =
+ TOKEN_IPV4_INITIALIZER(struct cmd_route_add2_result, ip);
+
+static cmdline_parse_token_num_t cmd_route_add2_depth =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add2_result, depth, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add2_port_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add2_result, port_string,
+ "port");
+
+static cmdline_parse_token_num_t cmd_route_add2_port =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add2_result, port, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add2_ether_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add2_result, ether_string,
+ "ether");
+
+static cmdline_parse_token_ipaddr_t cmd_route_add2_nh_ip =
+ TOKEN_IPV4_INITIALIZER(struct cmd_route_add2_result, nh_ip);
+
+static cmdline_parse_inst_t cmd_route_add2 = {
+ .f = cmd_route_add2_parsed,
+ .data = NULL,
+ .help_str = "Route add (mpls = no, qinq = no, arp = yes)",
+ .tokens = {
+ (void *)&cmd_route_add2_p_string,
+ (void *)&cmd_route_add2_p,
+ (void *)&cmd_route_add2_route_string,
+ (void *)&cmd_route_add2_add_string,
+ (void *)&cmd_route_add2_ip,
+ (void *)&cmd_route_add2_depth,
+ (void *)&cmd_route_add2_port_string,
+ (void *)&cmd_route_add2_port,
+ (void *)&cmd_route_add2_ether_string,
+ (void *)&cmd_route_add2_nh_ip,
+ NULL,
+ },
+};
+
+/*
+ * route add (mpls = no, qinq = yes, arp = no)
+ */
+
+struct cmd_route_add3_result {
+ cmdline_fixed_string_t p_string;
+ uint32_t p;
+ cmdline_fixed_string_t route_string;
+ cmdline_fixed_string_t add_string;
+ cmdline_ipaddr_t ip;
+ uint32_t depth;
+ cmdline_fixed_string_t port_string;
+ uint32_t port;
+ cmdline_fixed_string_t ether_string;
+ struct ether_addr macaddr;
+ cmdline_fixed_string_t qinq_string;
+ uint32_t svlan;
+ uint32_t cvlan;
+};
+
+static void
+cmd_route_add3_parsed(
+ void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ void *data)
+{
+ struct cmd_route_add3_result *params = parsed_result;
+ struct app_params *app = data;
+ struct pipeline_routing_route_key key;
+ struct pipeline_routing_route_data route_data;
+ int status;
+
+ /* Create route */
+ key.type = PIPELINE_ROUTING_ROUTE_IPV4;
+ key.key.ipv4.ip = rte_bswap32((uint32_t) params->ip.addr.ipv4.s_addr);
+ key.key.ipv4.depth = params->depth;
+
+ route_data.flags = PIPELINE_ROUTING_ROUTE_QINQ;
+ route_data.port_id = params->port;
+ route_data.ethernet.macaddr = params->macaddr;
+ route_data.l2.qinq.svlan = params->svlan;
+ route_data.l2.qinq.cvlan = params->cvlan;
+
+ status = app_pipeline_routing_add_route(app,
+ params->p,
+ &key,
+ &route_data);
+
+ if (status != 0) {
+ printf("Command failed\n");
+ return;
+ }
+}
+
+static cmdline_parse_token_string_t cmd_route_add3_p_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add3_result, p_string,
+ "p");
+
+static cmdline_parse_token_num_t cmd_route_add3_p =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add3_result, p, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add3_route_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add3_result, route_string,
+ "route");
+
+static cmdline_parse_token_string_t cmd_route_add3_add_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add3_result, add_string,
+ "add");
+
+static cmdline_parse_token_ipaddr_t cmd_route_add3_ip =
+ TOKEN_IPV4_INITIALIZER(struct cmd_route_add3_result, ip);
+
+static cmdline_parse_token_num_t cmd_route_add3_depth =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add3_result, depth, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add3_port_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add3_result, port_string,
+ "port");
+
+static cmdline_parse_token_num_t cmd_route_add3_port =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add3_result, port, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add3_ether_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add3_result, ether_string,
+ "ether");
+
+static cmdline_parse_token_etheraddr_t cmd_route_add3_macaddr =
+ TOKEN_ETHERADDR_INITIALIZER(struct cmd_route_add3_result, macaddr);
+
+static cmdline_parse_token_string_t cmd_route_add3_qinq_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add3_result, qinq_string,
+ "qinq");
+
+static cmdline_parse_token_num_t cmd_route_add3_svlan =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add3_result, svlan, UINT32);
+
+static cmdline_parse_token_num_t cmd_route_add3_cvlan =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add3_result, cvlan, UINT32);
+
+static cmdline_parse_inst_t cmd_route_add3 = {
+ .f = cmd_route_add3_parsed,
+ .data = NULL,
+ .help_str = "Route add (qinq = yes, arp = no)",
+ .tokens = {
+ (void *)&cmd_route_add3_p_string,
+ (void *)&cmd_route_add3_p,
+ (void *)&cmd_route_add3_route_string,
+ (void *)&cmd_route_add3_add_string,
+ (void *)&cmd_route_add3_ip,
+ (void *)&cmd_route_add3_depth,
+ (void *)&cmd_route_add3_port_string,
+ (void *)&cmd_route_add3_port,
+ (void *)&cmd_route_add3_ether_string,
+ (void *)&cmd_route_add3_macaddr,
+ (void *)&cmd_route_add3_qinq_string,
+ (void *)&cmd_route_add3_svlan,
+ (void *)&cmd_route_add3_cvlan,
+ NULL,
+ },
+};
+
+/*
+ * route add (mpls = no, qinq = yes, arp = yes)
+ */
+
+struct cmd_route_add4_result {
+ cmdline_fixed_string_t p_string;
+ uint32_t p;
+ cmdline_fixed_string_t route_string;
+ cmdline_fixed_string_t add_string;
+ cmdline_ipaddr_t ip;
+ uint32_t depth;
+ cmdline_fixed_string_t port_string;
+ uint32_t port;
+ cmdline_fixed_string_t ether_string;
+ cmdline_ipaddr_t nh_ip;
+ cmdline_fixed_string_t qinq_string;
+ uint32_t svlan;
+ uint32_t cvlan;
+};
+
+static void
+cmd_route_add4_parsed(
+ void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ void *data)
+{
+ struct cmd_route_add4_result *params = parsed_result;
+ struct app_params *app = data;
+ struct pipeline_routing_route_key key;
+ struct pipeline_routing_route_data route_data;
+ int status;
+
+ /* Create route */
+ key.type = PIPELINE_ROUTING_ROUTE_IPV4;
+ key.key.ipv4.ip = rte_bswap32((uint32_t) params->ip.addr.ipv4.s_addr);
+ key.key.ipv4.depth = params->depth;
+
+ route_data.flags = PIPELINE_ROUTING_ROUTE_QINQ |
+ PIPELINE_ROUTING_ROUTE_ARP;
+ route_data.port_id = params->port;
+ route_data.ethernet.ip =
+ rte_bswap32((uint32_t) params->nh_ip.addr.ipv4.s_addr);
+ route_data.l2.qinq.svlan = params->svlan;
+ route_data.l2.qinq.cvlan = params->cvlan;
+
+ status = app_pipeline_routing_add_route(app,
+ params->p,
+ &key,
+ &route_data);
+
+ if (status != 0) {
+ printf("Command failed\n");
+ return;
+ }
+}
+
+static cmdline_parse_token_string_t cmd_route_add4_p_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add4_result, p_string,
+ "p");
+
+static cmdline_parse_token_num_t cmd_route_add4_p =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add4_result, p, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add4_route_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add4_result, route_string,
+ "route");
+
+static cmdline_parse_token_string_t cmd_route_add4_add_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add4_result, add_string,
+ "add");
+
+static cmdline_parse_token_ipaddr_t cmd_route_add4_ip =
+ TOKEN_IPV4_INITIALIZER(struct cmd_route_add4_result, ip);
+
+static cmdline_parse_token_num_t cmd_route_add4_depth =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add4_result, depth, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add4_port_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add4_result, port_string,
+ "port");
+
+static cmdline_parse_token_num_t cmd_route_add4_port =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add4_result, port, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add4_ether_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add4_result, ether_string,
+ "ether");
+
+static cmdline_parse_token_ipaddr_t cmd_route_add4_nh_ip =
+ TOKEN_IPV4_INITIALIZER(struct cmd_route_add4_result, nh_ip);
+
+static cmdline_parse_token_string_t cmd_route_add4_qinq_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add4_result, qinq_string,
+ "qinq");
+
+static cmdline_parse_token_num_t cmd_route_add4_svlan =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add4_result, svlan, UINT32);
+
+static cmdline_parse_token_num_t cmd_route_add4_cvlan =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add4_result, cvlan, UINT32);
+
+static cmdline_parse_inst_t cmd_route_add4 = {
+ .f = cmd_route_add4_parsed,
+ .data = NULL,
+ .help_str = "Route add (qinq = yes, arp = yes)",
+ .tokens = {
+ (void *)&cmd_route_add4_p_string,
+ (void *)&cmd_route_add4_p,
+ (void *)&cmd_route_add4_route_string,
+ (void *)&cmd_route_add4_add_string,
+ (void *)&cmd_route_add4_ip,
+ (void *)&cmd_route_add4_depth,
+ (void *)&cmd_route_add4_port_string,
+ (void *)&cmd_route_add4_port,
+ (void *)&cmd_route_add4_ether_string,
+ (void *)&cmd_route_add4_nh_ip,
+ (void *)&cmd_route_add4_qinq_string,
+ (void *)&cmd_route_add4_svlan,
+ (void *)&cmd_route_add4_cvlan,
+ NULL,
+ },
+};
+
+/*
+ * route add (mpls = yes, qinq = no, arp = no)
+ */
+
+struct cmd_route_add5_result {
+ cmdline_fixed_string_t p_string;
+ uint32_t p;
+ cmdline_fixed_string_t route_string;
+ cmdline_fixed_string_t add_string;
+ cmdline_ipaddr_t ip;
+ uint32_t depth;
+ cmdline_fixed_string_t port_string;
+ uint32_t port;
+ cmdline_fixed_string_t ether_string;
+ struct ether_addr macaddr;
+ cmdline_fixed_string_t mpls_string;
+ cmdline_fixed_string_t mpls_labels;
+};
+
+static void
+cmd_route_add5_parsed(
+ void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ void *data)
+{
+ struct cmd_route_add5_result *params = parsed_result;
+ struct app_params *app = data;
+ struct pipeline_routing_route_key key;
+ struct pipeline_routing_route_data route_data;
+ uint32_t mpls_labels[PIPELINE_ROUTING_MPLS_LABELS_MAX];
+ uint32_t n_labels = RTE_DIM(mpls_labels);
+ uint32_t i;
+ int status;
+
+ /* Parse MPLS labels */
+ status = parse_labels(params->mpls_labels, mpls_labels, &n_labels);
+ if (status) {
+ printf("MPLS labels parse error\n");
+ return;
+ }
+
+ /* Create route */
+ key.type = PIPELINE_ROUTING_ROUTE_IPV4;
+ key.key.ipv4.ip = rte_bswap32((uint32_t) params->ip.addr.ipv4.s_addr);
+ key.key.ipv4.depth = params->depth;
+
+ route_data.flags = PIPELINE_ROUTING_ROUTE_MPLS;
+ route_data.port_id = params->port;
+ route_data.ethernet.macaddr = params->macaddr;
+ for (i = 0; i < n_labels; i++)
+ route_data.l2.mpls.labels[i] = mpls_labels[i];
+ route_data.l2.mpls.n_labels = n_labels;
+
+ status = app_pipeline_routing_add_route(app,
+ params->p,
+ &key,
+ &route_data);
+
+ if (status != 0) {
+ printf("Command failed\n");
+ return;
+ }
+}
+
+static cmdline_parse_token_string_t cmd_route_add5_p_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add5_result, p_string,
+ "p");
+
+static cmdline_parse_token_num_t cmd_route_add5_p =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add5_result, p, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add5_route_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add5_result, route_string,
+ "route");
+
+static cmdline_parse_token_string_t cmd_route_add5_add_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add5_result, add_string,
+ "add");
+
+static cmdline_parse_token_ipaddr_t cmd_route_add5_ip =
+ TOKEN_IPV4_INITIALIZER(struct cmd_route_add5_result, ip);
+
+static cmdline_parse_token_num_t cmd_route_add5_depth =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add5_result, depth, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add5_port_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add5_result, port_string,
+ "port");
+
+static cmdline_parse_token_num_t cmd_route_add5_port =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add5_result, port, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add5_ether_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add5_result, ether_string,
+ "ether");
+
+static cmdline_parse_token_etheraddr_t cmd_route_add5_macaddr =
+ TOKEN_ETHERADDR_INITIALIZER(struct cmd_route_add5_result, macaddr);
+
+static cmdline_parse_token_string_t cmd_route_add5_mpls_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add5_result, mpls_string,
+ "mpls");
+
+static cmdline_parse_token_string_t cmd_route_add5_mpls_labels =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add5_result, mpls_labels,
+ NULL);
+
+static cmdline_parse_inst_t cmd_route_add5 = {
+ .f = cmd_route_add5_parsed,
+ .data = NULL,
+ .help_str = "Route add (mpls = yes, arp = no)",
+ .tokens = {
+ (void *)&cmd_route_add5_p_string,
+ (void *)&cmd_route_add5_p,
+ (void *)&cmd_route_add5_route_string,
+ (void *)&cmd_route_add5_add_string,
+ (void *)&cmd_route_add5_ip,
+ (void *)&cmd_route_add5_depth,
+ (void *)&cmd_route_add5_port_string,
+ (void *)&cmd_route_add5_port,
+ (void *)&cmd_route_add5_ether_string,
+ (void *)&cmd_route_add5_macaddr,
+ (void *)&cmd_route_add5_mpls_string,
+ (void *)&cmd_route_add5_mpls_labels,
+ NULL,
+ },
+};
+
+/*
+ * route add (mpls = yes, qinq = no, arp = yes)
+ */
+
+struct cmd_route_add6_result {
+ cmdline_fixed_string_t p_string;
+ uint32_t p;
+ cmdline_fixed_string_t route_string;
+ cmdline_fixed_string_t add_string;
+ cmdline_ipaddr_t ip;
+ uint32_t depth;
+ cmdline_fixed_string_t port_string;
+ uint32_t port;
+ cmdline_fixed_string_t ether_string;
+ cmdline_ipaddr_t nh_ip;
+ cmdline_fixed_string_t mpls_string;
+ cmdline_fixed_string_t mpls_labels;
+};
+
+static void
+cmd_route_add6_parsed(
+ void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ void *data)
+{
+ struct cmd_route_add6_result *params = parsed_result;
+ struct app_params *app = data;
+ struct pipeline_routing_route_key key;
+ struct pipeline_routing_route_data route_data;
+ uint32_t mpls_labels[PIPELINE_ROUTING_MPLS_LABELS_MAX];
+ uint32_t n_labels = RTE_DIM(mpls_labels);
+ uint32_t i;
+ int status;
+
+ /* Parse MPLS labels */
+ status = parse_labels(params->mpls_labels, mpls_labels, &n_labels);
+ if (status) {
+ printf("MPLS labels parse error\n");
+ return;
+ }
+
+ /* Create route */
+ key.type = PIPELINE_ROUTING_ROUTE_IPV4;
+ key.key.ipv4.ip = rte_bswap32((uint32_t) params->ip.addr.ipv4.s_addr);
+ key.key.ipv4.depth = params->depth;
+
+ route_data.flags = PIPELINE_ROUTING_ROUTE_MPLS |
+ PIPELINE_ROUTING_ROUTE_ARP;
+ route_data.port_id = params->port;
+ route_data.ethernet.ip =
+ rte_bswap32((uint32_t) params->nh_ip.addr.ipv4.s_addr);
+ for (i = 0; i < n_labels; i++)
+ route_data.l2.mpls.labels[i] = mpls_labels[i];
+ route_data.l2.mpls.n_labels = n_labels;
+
+ status = app_pipeline_routing_add_route(app,
+ params->p,
+ &key,
+ &route_data);
+
+ if (status != 0) {
+ printf("Command failed\n");
+ return;
+ }
+}
+
+static cmdline_parse_token_string_t cmd_route_add6_p_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add6_result, p_string,
+ "p");
+
+static cmdline_parse_token_num_t cmd_route_add6_p =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add6_result, p, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add6_route_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add6_result, route_string,
+ "route");
+
+static cmdline_parse_token_string_t cmd_route_add6_add_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add6_result, add_string,
+ "add");
+
+static cmdline_parse_token_ipaddr_t cmd_route_add6_ip =
+ TOKEN_IPV4_INITIALIZER(struct cmd_route_add6_result, ip);
+
+static cmdline_parse_token_num_t cmd_route_add6_depth =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add6_result, depth, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add6_port_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add6_result, port_string,
+ "port");
+
+static cmdline_parse_token_num_t cmd_route_add6_port =
+ TOKEN_NUM_INITIALIZER(struct cmd_route_add6_result, port, UINT32);
+
+static cmdline_parse_token_string_t cmd_route_add6_ether_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_route_add6_result, ether_string,
+ "ether");