app/testpmd: fix bonding start
[dpdk.git] / app / test-pmd / cmdline.c
index 95a8f95..5799c9c 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   Copyright(c) 2014 6WIND S.A.
  *   All rights reserved.
  *
@@ -84,7 +84,6 @@
 #include <cmdline_parse_etheraddr.h>
 #include <cmdline_socket.h>
 #include <cmdline.h>
-#include <rte_pci_dev_ids.h>
 #ifdef RTE_LIBRTE_PMD_BOND
 #include <rte_eth_bond.h>
 #endif
@@ -412,7 +411,7 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "    Set rate limit for queues in VF of a port\n\n"
 
                        "set port (port_id) mirror-rule (rule_id)"
-                       "(pool-mirror|vlan-mirror)\n"
+                       " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
                        " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
                        "   Set pool or vlan type mirror rule on a port.\n"
                        "   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
@@ -652,6 +651,12 @@ static void cmd_help_long_parsed(void *parsed_result,
                        " queue (queue_id) fd_id (fd_id_value)\n"
                        "    Add/Del a SCTP type flow director filter.\n\n"
 
+                       "flow_director_filter (port_id) (add|del|update)"
+                       " flow l2_payload ether (ethertype)"
+                       " flexbytes (flexbytes_value) (drop|fwd)"
+                       " queue (queue_id) fd_id (fd_id_value)\n"
+                       "    Add/Del a l2 payload type flow director filter.\n\n"
+
                        "flush_flow_director (port_id)\n"
                        "    Flush all flow director entries of a device.\n\n"
 
@@ -662,7 +667,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 
                        "flow_director_flex_mask (port_id)"
                        " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
-                       "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|all)"
+                       "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
                        " (mask)\n"
                        "    Configure mask of flex payload.\n\n"
 
@@ -4013,6 +4018,7 @@ static void cmd_add_bonding_slave_parsed(void *parsed_result,
                return;
        }
        init_port_config();
+       set_port_slave_flag(slave_port_id);
 }
 
 cmdline_parse_token_string_t cmd_addbonding_slave_add =
@@ -4069,6 +4075,7 @@ static void cmd_remove_bonding_slave_parsed(void *parsed_result,
                return;
        }
        init_port_config();
+       clear_port_slave_flag(slave_port_id);
 }
 
 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
@@ -6647,7 +6654,8 @@ cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
                                rule_id, UINT8);
 cmdline_parse_token_string_t cmd_mirror_mask_what =
        TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
-                               what, "pool-mirror#vlan-mirror");
+                               what, "pool-mirror-up#pool-mirror-down"
+                                     "#vlan-mirror");
 cmdline_parse_token_string_t cmd_mirror_mask_value =
        TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
                                value, NULL);
@@ -6668,25 +6676,28 @@ cmd_set_mirror_mask_parsed(void *parsed_result,
 {
        int ret,nb_item,i;
        struct cmd_set_mirror_mask_result *res = parsed_result;
-       struct rte_eth_vmdq_mirror_conf mr_conf;
+       struct rte_eth_mirror_conf mr_conf;
 
-       memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
+       memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
 
-       unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
+       unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
 
        mr_conf.dst_pool = res->dstpool_id;
 
-       if (!strcmp(res->what, "pool-mirror")) {
-               mr_conf.pool_mask = strtoull(res->value,NULL,16);
-               mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
-       } else if(!strcmp(res->what, "vlan-mirror")) {
-               mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
-               nb_item = parse_item_list(res->value, "core",
-                                       ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
+       if (!strcmp(res->what, "pool-mirror-up")) {
+               mr_conf.pool_mask = strtoull(res->value, NULL, 16);
+               mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
+       } else if (!strcmp(res->what, "pool-mirror-down")) {
+               mr_conf.pool_mask = strtoull(res->value, NULL, 16);
+               mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
+       } else if (!strcmp(res->what, "vlan-mirror")) {
+               mr_conf.rule_type = ETH_MIRROR_VLAN;
+               nb_item = parse_item_list(res->value, "vlan",
+                               ETH_MIRROR_MAX_VLANS, vlan_list, 1);
                if (nb_item <= 0)
                        return;
 
-               for(i=0; i < nb_item; i++) {
+               for (i = 0; i < nb_item; i++) {
                        if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
                                printf("Invalid vlan_id: must be < 4096\n");
                                return;
@@ -6697,21 +6708,21 @@ cmd_set_mirror_mask_parsed(void *parsed_result,
                }
        }
 
-       if(!strcmp(res->on, "on"))
-               ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
+       if (!strcmp(res->on, "on"))
+               ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
                                                res->rule_id, 1);
        else
-               ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
+               ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
                                                res->rule_id, 0);
-       if(ret < 0)
+       if (ret < 0)
                printf("mirror rule add error: (%s)\n", strerror(-ret));
 }
 
 cmdline_parse_inst_t cmd_set_mirror_mask = {
                .f = cmd_set_mirror_mask_parsed,
                .data = NULL,
-               .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
-                               "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
+               .help_str = "set port X mirror-rule Y pool-mirror-up|pool-mirror-down|vlan-mirror"
+                           pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
                .tokens = {
                        (void *)&cmd_mirror_mask_set,
                        (void *)&cmd_mirror_mask_port,
@@ -6775,25 +6786,25 @@ cmd_set_mirror_link_parsed(void *parsed_result,
 {
        int ret;
        struct cmd_set_mirror_link_result *res = parsed_result;
-       struct rte_eth_vmdq_mirror_conf mr_conf;
+       struct rte_eth_mirror_conf mr_conf;
 
-       memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
-       if(!strcmp(res->what, "uplink-mirror")) {
-               mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
-       }else if(!strcmp(res->what, "downlink-mirror"))
-               mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
+       memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
+       if (!strcmp(res->what, "uplink-mirror"))
+               mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
+       else
+               mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
 
        mr_conf.dst_pool = res->dstpool_id;
 
-       if(!strcmp(res->on, "on"))
-               ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
+       if (!strcmp(res->on, "on"))
+               ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
                                                res->rule_id, 1);
        else
-               ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
+               ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
                                                res->rule_id, 0);
 
        /* check the return value and print it if is < 0 */
-       if(ret < 0)
+       if (ret < 0)
                printf("mirror rule add error: (%s)\n", strerror(-ret));
 
 }
@@ -7717,6 +7728,8 @@ struct cmd_flow_director_result {
        cmdline_fixed_string_t ops;
        cmdline_fixed_string_t flow;
        cmdline_fixed_string_t flow_type;
+       cmdline_fixed_string_t ether;
+       uint16_t ether_type;
        cmdline_fixed_string_t src;
        cmdline_ipaddr_t ip_src;
        uint16_t port_src;
@@ -7875,6 +7888,12 @@ cmd_flow_director_filter_parsed(void *parsed_result,
                IPV4_ADDR_TO_UINT(res->ip_src,
                        entry.input.flow.sctp4_flow.ip.src_ip);
                /* need convert to big endian. */
+#ifdef RTE_NEXT_ABI
+               entry.input.flow.sctp4_flow.dst_port =
+                               rte_cpu_to_be_16(res->port_dst);
+               entry.input.flow.sctp4_flow.src_port =
+                               rte_cpu_to_be_16(res->port_src);
+#endif
                entry.input.flow.sctp4_flow.verify_tag =
                                rte_cpu_to_be_32(res->verify_tag_value);
                break;
@@ -7898,9 +7917,19 @@ cmd_flow_director_filter_parsed(void *parsed_result,
                IPV6_ADDR_TO_ARRAY(res->ip_src,
                        entry.input.flow.sctp6_flow.ip.src_ip);
                /* need convert to big endian. */
+#ifdef RTE_NEXT_ABI
+               entry.input.flow.sctp6_flow.dst_port =
+                               rte_cpu_to_be_16(res->port_dst);
+               entry.input.flow.sctp6_flow.src_port =
+                               rte_cpu_to_be_16(res->port_src);
+#endif
                entry.input.flow.sctp6_flow.verify_tag =
                                rte_cpu_to_be_32(res->verify_tag_value);
                break;
+       case RTE_ETH_FLOW_L2_PAYLOAD:
+               entry.input.flow.l2_flow.ether_type =
+                       rte_cpu_to_be_16(res->ether_type);
+               break;
        default:
                printf("invalid parameter.\n");
                return;
@@ -7949,7 +7978,13 @@ cmdline_parse_token_string_t cmd_flow_director_flow =
 cmdline_parse_token_string_t cmd_flow_director_flow_type =
        TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
                flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
-               "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp");
+               "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
+cmdline_parse_token_string_t cmd_flow_director_ether =
+       TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
+                                ether, "ether");
+cmdline_parse_token_num_t cmd_flow_director_ether_type =
+       TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
+                             ether_type, UINT16);
 cmdline_parse_token_string_t cmd_flow_director_src =
        TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
                                 src, "src");
@@ -8089,6 +8124,29 @@ cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
        },
 };
 
+cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
+       .f = cmd_flow_director_filter_parsed,
+       .data = NULL,
+       .help_str = "add or delete a L2 flow director entry on NIC",
+       .tokens = {
+               (void *)&cmd_flow_director_filter,
+               (void *)&cmd_flow_director_port_id,
+               (void *)&cmd_flow_director_ops,
+               (void *)&cmd_flow_director_flow,
+               (void *)&cmd_flow_director_flow_type,
+               (void *)&cmd_flow_director_ether,
+               (void *)&cmd_flow_director_ether_type,
+               (void *)&cmd_flow_director_flexbytes,
+               (void *)&cmd_flow_director_flexbytes_value,
+               (void *)&cmd_flow_director_drop,
+               (void *)&cmd_flow_director_queue,
+               (void *)&cmd_flow_director_queue_id,
+               (void *)&cmd_flow_director_fd_id,
+               (void *)&cmd_flow_director_fd_id_value,
+               NULL,
+       },
+};
+
 struct cmd_flush_flow_director_result {
        cmdline_fixed_string_t flush_flow_director;
        uint8_t port_id;
@@ -8342,7 +8400,7 @@ cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
        TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
                flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
-               "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#all");
+               "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
        TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
                                 mask, NULL);
@@ -8970,6 +9028,7 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
        (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
        (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
+       (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
        (cmdline_parse_inst_t *)&cmd_flush_flow_director,
        (cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
        (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
@@ -9024,6 +9083,7 @@ cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
 }
 
 #ifdef RTE_NIC_BYPASS
+#include <rte_pci_dev_ids.h>
 uint8_t
 bypass_is_supported(portid_t port_id)
 {