app/testpmd: set VF TC Tx max bandwidth
authorWenzhuo Lu <wenzhuo.lu@intel.com>
Fri, 24 Feb 2017 03:24:34 +0000 (11:24 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 4 Apr 2017 16:59:50 +0000 (18:59 +0200)
Add CLI to set a specific TC's max bandwidth
on a specific VF from PF.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
app/test-pmd/cmdline.c
doc/guides/testpmd_app_ug/testpmd_funcs.rst

index 41d057f..f025472 100644 (file)
@@ -321,6 +321,9 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
                        "    Set all TCs' min bandwidth(%%) on a VF.\n\n"
 
+                       "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
+                       "    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
+
                        "vlan set filter (on|off) (port_id)\n"
                        "    Set the VLAN filter on a port.\n\n"
 
@@ -12417,6 +12420,7 @@ struct cmd_vf_tc_bw_result {
        cmdline_fixed_string_t max_bw;
        uint8_t port_id;
        uint16_t vf_id;
+       uint8_t tc_no;
        uint32_t bw;
        cmdline_fixed_string_t bw_list;
 };
@@ -12453,6 +12457,10 @@ cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
        TOKEN_NUM_INITIALIZER
                (struct cmd_vf_tc_bw_result,
                 vf_id, UINT16);
+cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
+       TOKEN_NUM_INITIALIZER
+               (struct cmd_vf_tc_bw_result,
+                tc_no, UINT8);
 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
        TOKEN_NUM_INITIALIZER
                (struct cmd_vf_tc_bw_result,
@@ -12615,6 +12623,61 @@ cmdline_parse_inst_t cmd_vf_tc_min_bw = {
        },
 };
 
+/* TC max bandwidth setting */
+static void
+cmd_vf_tc_max_bw_parsed(
+       void *parsed_result,
+       __attribute__((unused)) struct cmdline *cl,
+       __attribute__((unused)) void *data)
+{
+       struct cmd_vf_tc_bw_result *res = parsed_result;
+       int ret = -ENOTSUP;
+
+       if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+               return;
+
+#ifdef RTE_LIBRTE_I40E_PMD
+       ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
+                                           res->tc_no, res->bw);
+#endif
+
+       switch (ret) {
+       case 0:
+               break;
+       case -EINVAL:
+               printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
+                      res->vf_id, res->tc_no, res->bw);
+               break;
+       case -ENODEV:
+               printf("invalid port_id %d\n", res->port_id);
+               break;
+       case -ENOTSUP:
+               printf("function not implemented\n");
+               break;
+       default:
+               printf("programming error: (%s)\n", strerror(-ret));
+       }
+}
+
+cmdline_parse_inst_t cmd_vf_tc_max_bw = {
+       .f = cmd_vf_tc_max_bw_parsed,
+       .data = NULL,
+       .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
+                   " <bandwidth>",
+       .tokens = {
+               (void *)&cmd_vf_tc_bw_set,
+               (void *)&cmd_vf_tc_bw_vf,
+               (void *)&cmd_vf_tc_bw_tc,
+               (void *)&cmd_vf_tc_bw_tx,
+               (void *)&cmd_vf_tc_bw_max_bw,
+               (void *)&cmd_vf_tc_bw_port_id,
+               (void *)&cmd_vf_tc_bw_vf_id,
+               (void *)&cmd_vf_tc_bw_tc_no,
+               (void *)&cmd_vf_tc_bw_bw,
+               NULL,
+       },
+};
+
 
 /* ******************************************************************************** */
 
@@ -12793,6 +12856,7 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
        (cmdline_parse_inst_t *)&cmd_vf_max_bw,
        (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
+       (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
        NULL,
 };
 
index b9a99e4..6e281d2 100644 (file)
@@ -907,6 +907,13 @@ Set all TCs' TX min relative bandwidth (%) for a VF from PF::
 
    testpmd> set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)
 
+set tc tx max bandwidth (for VF)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Set a TC's TX max absolute bandwidth (Mbps) for a VF from PF::
+
+   testpmd> set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (max_bandwidth)
+
 set flow_ctrl rx
 ~~~~~~~~~~~~~~~~