+ /* flow add qinq bulk */
+ if ((n_tokens >= 3) &&
+ (strcmp(tokens[0], "add") == 0) &&
+ (strcmp(tokens[1], "qinq") == 0) &&
+ (strcmp(tokens[2], "bulk") == 0)) {
+ struct pipeline_fc_key *keys;
+ uint32_t *port_ids, *flow_ids, n_keys, line;
+ char *filename;
+
+ if (n_tokens != 4) {
+ printf(CMD_MSG_MISMATCH_ARGS, "flow add qinq bulk");
+ return;
+ }
+
+ filename = tokens[3];
+
+ n_keys = APP_PIPELINE_FC_MAX_FLOWS_IN_FILE;
+ keys = malloc(n_keys * sizeof(struct pipeline_fc_key));
+ if (keys == NULL)
+ return;
+ memset(keys, 0, n_keys * sizeof(struct pipeline_fc_key));
+
+ port_ids = malloc(n_keys * sizeof(uint32_t));
+ if (port_ids == NULL) {
+ free(keys);
+ return;
+ }
+
+ flow_ids = malloc(n_keys * sizeof(uint32_t));
+ if (flow_ids == NULL) {
+ free(port_ids);
+ free(keys);
+ return;
+ }
+
+ status = app_pipeline_fc_load_file_qinq(filename,
+ keys,
+ port_ids,
+ flow_ids,
+ &n_keys,
+ &line);
+ if (status != 0) {
+ printf(CMD_MSG_FILE_ERR, filename, line);
+ free(flow_ids);
+ free(port_ids);
+ free(keys);
+ return;
+ }
+
+ status = app_pipeline_fc_add_bulk(app,
+ results->pipeline_id,
+ keys,
+ port_ids,
+ flow_ids,
+ n_keys);
+ if (status)
+ printf(CMD_MSG_FAIL, "flow add qinq bulk");
+
+ free(flow_ids);
+ free(port_ids);
+ free(keys);
+ return;
+ } /* flow add qinq bulk */
+
+ /* flow add ipv4 bulk */
+ if ((n_tokens >= 3) &&
+ (strcmp(tokens[0], "add") == 0) &&
+ (strcmp(tokens[1], "ipv4") == 0) &&
+ (strcmp(tokens[2], "bulk") == 0)) {
+ struct pipeline_fc_key *keys;
+ uint32_t *port_ids, *flow_ids, n_keys, line;
+ char *filename;
+
+ if (n_tokens != 4) {
+ printf(CMD_MSG_MISMATCH_ARGS, "flow add ipv4 bulk");
+ return;
+ }
+
+ filename = tokens[3];
+
+ n_keys = APP_PIPELINE_FC_MAX_FLOWS_IN_FILE;
+ keys = malloc(n_keys * sizeof(struct pipeline_fc_key));
+ if (keys == NULL)
+ return;
+ memset(keys, 0, n_keys * sizeof(struct pipeline_fc_key));
+
+ port_ids = malloc(n_keys * sizeof(uint32_t));
+ if (port_ids == NULL) {
+ free(keys);
+ return;
+ }
+
+ flow_ids = malloc(n_keys * sizeof(uint32_t));
+ if (flow_ids == NULL) {
+ free(port_ids);
+ free(keys);
+ return;
+ }
+
+ status = app_pipeline_fc_load_file_ipv4(filename,
+ keys,
+ port_ids,
+ flow_ids,
+ &n_keys,
+ &line);
+ if (status != 0) {
+ printf(CMD_MSG_FILE_ERR, filename, line);
+ free(flow_ids);
+ free(port_ids);
+ free(keys);
+ return;
+ }
+
+ status = app_pipeline_fc_add_bulk(app,
+ results->pipeline_id,
+ keys,
+ port_ids,
+ flow_ids,
+ n_keys);
+ if (status)
+ printf(CMD_MSG_FAIL, "flow add ipv4 bulk");
+
+ free(flow_ids);
+ free(port_ids);
+ free(keys);
+ return;
+ } /* flow add ipv4 bulk */
+
+ /* flow add ipv6 bulk */
+ if ((n_tokens >= 3) &&
+ (strcmp(tokens[0], "add") == 0) &&
+ (strcmp(tokens[1], "ipv6") == 0) &&
+ (strcmp(tokens[2], "bulk") == 0)) {
+ struct pipeline_fc_key *keys;
+ uint32_t *port_ids, *flow_ids, n_keys, line;
+ char *filename;
+
+ if (n_tokens != 4) {
+ printf(CMD_MSG_MISMATCH_ARGS, "flow add ipv6 bulk");
+ return;
+ }
+
+ filename = tokens[3];
+
+ n_keys = APP_PIPELINE_FC_MAX_FLOWS_IN_FILE;
+ keys = malloc(n_keys * sizeof(struct pipeline_fc_key));
+ if (keys == NULL)
+ return;
+ memset(keys, 0, n_keys * sizeof(struct pipeline_fc_key));
+
+ port_ids = malloc(n_keys * sizeof(uint32_t));
+ if (port_ids == NULL) {
+ free(keys);
+ return;
+ }
+
+ flow_ids = malloc(n_keys * sizeof(uint32_t));
+ if (flow_ids == NULL) {
+ free(port_ids);
+ free(keys);
+ return;
+ }
+
+ status = app_pipeline_fc_load_file_ipv6(filename,
+ keys,
+ port_ids,
+ flow_ids,
+ &n_keys,
+ &line);
+ if (status != 0) {
+ printf(CMD_MSG_FILE_ERR, filename, line);
+ free(flow_ids);
+ free(port_ids);
+ free(keys);
+ return;
+ }
+
+ status = app_pipeline_fc_add_bulk(app,
+ results->pipeline_id,
+ keys,
+ port_ids,
+ flow_ids,
+ n_keys);
+ if (status)
+ printf(CMD_MSG_FAIL, "flow add ipv6 bulk");
+
+ free(flow_ids);
+ free(port_ids);
+ free(keys);
+ return;
+ } /* flow add ipv6 bulk */
+
+ /* flow add default*/
+ if ((n_tokens >= 2) &&
+ (strcmp(tokens[0], "add") == 0) &&
+ (strcmp(tokens[1], "default") == 0)) {
+ uint32_t port_id;
+
+ if (n_tokens != 3) {
+ printf(CMD_MSG_MISMATCH_ARGS, "flow add default");
+ return;
+ }
+
+ if (parser_read_uint32(&port_id, tokens[2]) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "portid");
+ return;
+ }
+
+ status = app_pipeline_fc_add_default(app,
+ results->pipeline_id,
+ port_id);
+ if (status)
+ printf(CMD_MSG_FAIL, "flow add default");
+
+ return;
+ } /* flow add default */
+
+ /* flow del qinq */
+ if ((n_tokens >= 2) &&
+ (strcmp(tokens[0], "del") == 0) &&
+ (strcmp(tokens[1], "qinq") == 0)) {
+ struct pipeline_fc_key key;
+ uint32_t svlan;
+ uint32_t cvlan;
+
+ memset(&key, 0, sizeof(key));
+
+ if (n_tokens != 4) {
+ printf(CMD_MSG_MISMATCH_ARGS, "flow del qinq");
+ return;
+ }
+
+ if (parser_read_uint32(&svlan, tokens[2]) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "svlan");
+ return;
+ }
+
+ if (parser_read_uint32(&cvlan, tokens[3]) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "cvlan");
+ return;
+ }
+
+ key.type = FLOW_KEY_QINQ;
+ key.key.qinq.svlan = svlan;
+ key.key.qinq.cvlan = cvlan;
+
+ status = app_pipeline_fc_del(app,
+ results->pipeline_id,
+ &key);
+ if (status)
+ printf(CMD_MSG_FAIL, "flow del qinq");
+
+ return;
+ } /* flow del qinq */
+
+ /* flow del ipv4 */
+ if ((n_tokens >= 2) &&
+ (strcmp(tokens[0], "del") == 0) &&
+ (strcmp(tokens[1], "ipv4") == 0)) {
+ struct pipeline_fc_key key;
+ struct in_addr sipaddr;
+ struct in_addr dipaddr;
+ uint32_t sport;
+ uint32_t dport;
+ uint32_t proto;
+
+ memset(&key, 0, sizeof(key));
+
+ if (n_tokens != 7) {
+ printf(CMD_MSG_MISMATCH_ARGS, "flow del ipv4");
+ return;
+ }
+
+ if (parse_ipv4_addr(tokens[2], &sipaddr) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "sipv4addr");
+ return;
+ }
+ if (parse_ipv4_addr(tokens[3], &dipaddr) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "dipv4addr");
+ return;
+ }
+
+ if (parser_read_uint32(&sport, tokens[4]) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "sport");
+ return;
+ }
+
+ if (parser_read_uint32(&dport, tokens[5]) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "dport");
+ return;
+ }
+
+ if (parser_read_uint32(&proto, tokens[6]) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "proto");
+ return;
+ }
+
+ key.type = FLOW_KEY_IPV4_5TUPLE;
+ key.key.ipv4_5tuple.ip_src = rte_be_to_cpu_32(sipaddr.s_addr);
+ key.key.ipv4_5tuple.ip_dst = rte_be_to_cpu_32(dipaddr.s_addr);
+ key.key.ipv4_5tuple.port_src = sport;
+ key.key.ipv4_5tuple.port_dst = dport;
+ key.key.ipv4_5tuple.proto = proto;
+
+ status = app_pipeline_fc_del(app,
+ results->pipeline_id,
+ &key);
+ if (status)
+ printf(CMD_MSG_FAIL, "flow del ipv4");
+
+ return;
+ } /* flow del ipv4 */
+
+ /* flow del ipv6 */
+ if ((n_tokens >= 2) &&
+ (strcmp(tokens[0], "del") == 0) &&
+ (strcmp(tokens[1], "ipv6") == 0)) {
+ struct pipeline_fc_key key;
+ struct in6_addr sipaddr;
+ struct in6_addr dipaddr;
+ uint32_t sport;
+ uint32_t dport;
+ uint32_t proto;
+
+ memset(&key, 0, sizeof(key));
+
+ if (n_tokens != 7) {
+ printf(CMD_MSG_MISMATCH_ARGS, "flow del ipv6");
+ return;
+ }
+
+ if (parse_ipv6_addr(tokens[2], &sipaddr) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "sipv6addr");
+ return;
+ }
+
+ if (parse_ipv6_addr(tokens[3], &dipaddr) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "dipv6addr");
+ return;
+ }
+
+ if (parser_read_uint32(&sport, tokens[4]) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "sport");
+ return;
+ }
+
+ if (parser_read_uint32(&dport, tokens[5]) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "dport");
+ return;
+ }
+
+ if (parser_read_uint32(&proto, tokens[6]) != 0) {
+ printf(CMD_MSG_INVALID_ARG, "proto");
+ return;
+ }
+
+ key.type = FLOW_KEY_IPV6_5TUPLE;
+ memcpy(key.key.ipv6_5tuple.ip_src, &sipaddr, 16);
+ memcpy(key.key.ipv6_5tuple.ip_dst, &dipaddr, 16);
+ key.key.ipv6_5tuple.port_src = sport;
+ key.key.ipv6_5tuple.port_dst = dport;
+ key.key.ipv6_5tuple.proto = proto;
+
+ status = app_pipeline_fc_del(app,
+ results->pipeline_id,
+ &key);
+ if (status)
+ printf(CMD_MSG_FAIL, "flow del ipv6");
+
+ return;
+ } /* flow del ipv6 */
+
+ /* flow del default*/
+ if ((n_tokens >= 2) &&
+ (strcmp(tokens[0], "del") == 0) &&
+ (strcmp(tokens[1], "default") == 0)) {
+ if (n_tokens != 2) {
+ printf(CMD_MSG_MISMATCH_ARGS, "flow del default");
+ return;
+ }
+
+ status = app_pipeline_fc_del_default(app,
+ results->pipeline_id);
+ if (status)
+ printf(CMD_MSG_FAIL, "flow del default");
+
+ return;
+ } /* flow del default */
+
+ /* flow ls */
+ if ((n_tokens >= 1) && (strcmp(tokens[0], "ls") == 0)) {
+ if (n_tokens != 1) {
+ printf(CMD_MSG_MISMATCH_ARGS, "flow ls");
+ return;
+ }
+
+ status = app_pipeline_fc_ls(app, results->pipeline_id);
+ if (status)
+ printf(CMD_MSG_FAIL, "flow ls");
+
+ return;
+ } /* flow ls */
+
+ printf(CMD_MSG_MISMATCH_ARGS, "flow");