-/* vf mac address configuration */
-
-/* Common result structure for vf mac address */
-struct cmd_set_vf_mac_addr_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t vf;
- cmdline_fixed_string_t mac;
- cmdline_fixed_string_t addr;
- portid_t port_id;
- uint16_t vf_id;
- struct ether_addr mac_addr;
-
-};
-
-/* Common CLI fields for vf split drop enable disable */
-cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_mac_addr_result,
- set, "set");
-cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_mac_addr_result,
- vf, "vf");
-cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_mac_addr_result,
- mac, "mac");
-cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_mac_addr_result,
- addr, "addr");
-cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_set_vf_mac_addr_result,
- port_id, UINT16);
-cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_set_vf_mac_addr_result,
- vf_id, UINT16);
-cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
- TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
- mac_addr);
-
-static void
-cmd_set_vf_mac_addr_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_set_vf_mac_addr_result *res = parsed_result;
- int ret = -ENOTSUP;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
-#ifdef RTE_LIBRTE_IXGBE_PMD
- if (ret == -ENOTSUP)
- ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
- &res->mac_addr);
-#endif
-#ifdef RTE_LIBRTE_I40E_PMD
- if (ret == -ENOTSUP)
- ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
- &res->mac_addr);
-#endif
-#ifdef RTE_LIBRTE_BNXT_PMD
- if (ret == -ENOTSUP)
- ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
- &res->mac_addr);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid vf_id %d or mac_addr\n", res->vf_id);
- 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_set_vf_mac_addr = {
- .f = cmd_set_vf_mac_addr_parsed,
- .data = NULL,
- .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
- .tokens = {
- (void *)&cmd_set_vf_mac_addr_set,
- (void *)&cmd_set_vf_mac_addr_vf,
- (void *)&cmd_set_vf_mac_addr_mac,
- (void *)&cmd_set_vf_mac_addr_addr,
- (void *)&cmd_set_vf_mac_addr_port_id,
- (void *)&cmd_set_vf_mac_addr_vf_id,
- (void *)&cmd_set_vf_mac_addr_mac_addr,
- NULL,
- },
-};
-
-/* MACsec configuration */
-
-/* Common result structure for MACsec offload enable */
-struct cmd_macsec_offload_on_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t macsec;
- cmdline_fixed_string_t offload;
- portid_t port_id;
- cmdline_fixed_string_t on;
- cmdline_fixed_string_t encrypt;
- cmdline_fixed_string_t en_on_off;
- cmdline_fixed_string_t replay_protect;
- cmdline_fixed_string_t rp_on_off;
-};
-
-/* Common CLI fields for MACsec offload disable */
-cmdline_parse_token_string_t cmd_macsec_offload_on_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_on_result,
- set, "set");
-cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_on_result,
- macsec, "macsec");
-cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_on_result,
- offload, "offload");
-cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_macsec_offload_on_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_macsec_offload_on_on =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_on_result,
- on, "on");
-cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_on_result,
- encrypt, "encrypt");
-cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_on_result,
- en_on_off, "on#off");
-cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_on_result,
- replay_protect, "replay-protect");
-cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_on_result,
- rp_on_off, "on#off");
-
-static void
-cmd_set_macsec_offload_on_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_macsec_offload_on_result *res = parsed_result;
- int ret = -ENOTSUP;
- portid_t port_id = res->port_id;
- int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
- int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
- struct rte_eth_dev_info dev_info;
-
- if (port_id_is_invalid(port_id, ENABLED_WARN))
- return;
- if (!port_is_stopped(port_id)) {
- printf("Please stop port %d first\n", port_id);
- return;
- }
-
- rte_eth_dev_info_get(port_id, &dev_info);
- if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
-#ifdef RTE_LIBRTE_IXGBE_PMD
- ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
-#endif
- }
- RTE_SET_USED(en);
- RTE_SET_USED(rp);
-
- switch (ret) {
- case 0:
- ports[port_id].dev_conf.txmode.offloads |=
- DEV_TX_OFFLOAD_MACSEC_INSERT;
- cmd_reconfig_device_queue(port_id, 1, 1);
- break;
- case -ENODEV:
- printf("invalid port_id %d\n", port_id);
- break;
- case -ENOTSUP:
- printf("not supported on port %d\n", port_id);
- break;
- default:
- printf("programming error: (%s)\n", strerror(-ret));
- }
-}
-
-cmdline_parse_inst_t cmd_set_macsec_offload_on = {
- .f = cmd_set_macsec_offload_on_parsed,
- .data = NULL,
- .help_str = "set macsec offload <port_id> on "
- "encrypt on|off replay-protect on|off",
- .tokens = {
- (void *)&cmd_macsec_offload_on_set,
- (void *)&cmd_macsec_offload_on_macsec,
- (void *)&cmd_macsec_offload_on_offload,
- (void *)&cmd_macsec_offload_on_port_id,
- (void *)&cmd_macsec_offload_on_on,
- (void *)&cmd_macsec_offload_on_encrypt,
- (void *)&cmd_macsec_offload_on_en_on_off,
- (void *)&cmd_macsec_offload_on_replay_protect,
- (void *)&cmd_macsec_offload_on_rp_on_off,
- NULL,
- },
-};
-
-/* Common result structure for MACsec offload disable */
-struct cmd_macsec_offload_off_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t macsec;
- cmdline_fixed_string_t offload;
- portid_t port_id;
- cmdline_fixed_string_t off;
-};
-
-/* Common CLI fields for MACsec offload disable */
-cmdline_parse_token_string_t cmd_macsec_offload_off_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_off_result,
- set, "set");
-cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_off_result,
- macsec, "macsec");
-cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_off_result,
- offload, "offload");
-cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_macsec_offload_off_result,
- port_id, UINT16);
-cmdline_parse_token_string_t cmd_macsec_offload_off_off =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_offload_off_result,
- off, "off");
-
-static void
-cmd_set_macsec_offload_off_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_macsec_offload_off_result *res = parsed_result;
- int ret = -ENOTSUP;
- struct rte_eth_dev_info dev_info;
- portid_t port_id = res->port_id;
-
- if (port_id_is_invalid(port_id, ENABLED_WARN))
- return;
- if (!port_is_stopped(port_id)) {
- printf("Please stop port %d first\n", port_id);
- return;
- }
-
- rte_eth_dev_info_get(port_id, &dev_info);
- if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
-#ifdef RTE_LIBRTE_IXGBE_PMD
- ret = rte_pmd_ixgbe_macsec_disable(port_id);
-#endif
- }
- switch (ret) {
- case 0:
- ports[port_id].dev_conf.txmode.offloads &=
- ~DEV_TX_OFFLOAD_MACSEC_INSERT;
- cmd_reconfig_device_queue(port_id, 1, 1);
- break;
- case -ENODEV:
- printf("invalid port_id %d\n", port_id);
- break;
- case -ENOTSUP:
- printf("not supported on port %d\n", port_id);
- break;
- default:
- printf("programming error: (%s)\n", strerror(-ret));
- }
-}
-
-cmdline_parse_inst_t cmd_set_macsec_offload_off = {
- .f = cmd_set_macsec_offload_off_parsed,
- .data = NULL,
- .help_str = "set macsec offload <port_id> off",
- .tokens = {
- (void *)&cmd_macsec_offload_off_set,
- (void *)&cmd_macsec_offload_off_macsec,
- (void *)&cmd_macsec_offload_off_offload,
- (void *)&cmd_macsec_offload_off_port_id,
- (void *)&cmd_macsec_offload_off_off,
- NULL,
- },
-};
-
-/* Common result structure for MACsec secure connection configure */
-struct cmd_macsec_sc_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t macsec;
- cmdline_fixed_string_t sc;
- cmdline_fixed_string_t tx_rx;
- portid_t port_id;
- struct ether_addr mac;
- uint16_t pi;
-};
-
-/* Common CLI fields for MACsec secure connection configure */
-cmdline_parse_token_string_t cmd_macsec_sc_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_sc_result,
- set, "set");
-cmdline_parse_token_string_t cmd_macsec_sc_macsec =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_sc_result,
- macsec, "macsec");
-cmdline_parse_token_string_t cmd_macsec_sc_sc =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_sc_result,
- sc, "sc");
-cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_sc_result,
- tx_rx, "tx#rx");
-cmdline_parse_token_num_t cmd_macsec_sc_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_macsec_sc_result,
- port_id, UINT16);
-cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
- TOKEN_ETHERADDR_INITIALIZER
- (struct cmd_macsec_sc_result,
- mac);
-cmdline_parse_token_num_t cmd_macsec_sc_pi =
- TOKEN_NUM_INITIALIZER
- (struct cmd_macsec_sc_result,
- pi, UINT16);
-
-static void
-cmd_set_macsec_sc_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_macsec_sc_result *res = parsed_result;
- int ret = -ENOTSUP;
- int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
-
-#ifdef RTE_LIBRTE_IXGBE_PMD
- ret = is_tx ?
- rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
- res->mac.addr_bytes) :
- rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
- res->mac.addr_bytes, res->pi);
-#endif
- RTE_SET_USED(is_tx);
-
- switch (ret) {
- case 0:
- break;
- case -ENODEV:
- printf("invalid port_id %d\n", res->port_id);
- break;
- case -ENOTSUP:
- printf("not supported on port %d\n", res->port_id);
- break;
- default:
- printf("programming error: (%s)\n", strerror(-ret));
- }
-}
-
-cmdline_parse_inst_t cmd_set_macsec_sc = {
- .f = cmd_set_macsec_sc_parsed,
- .data = NULL,
- .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
- .tokens = {
- (void *)&cmd_macsec_sc_set,
- (void *)&cmd_macsec_sc_macsec,
- (void *)&cmd_macsec_sc_sc,
- (void *)&cmd_macsec_sc_tx_rx,
- (void *)&cmd_macsec_sc_port_id,
- (void *)&cmd_macsec_sc_mac,
- (void *)&cmd_macsec_sc_pi,
- NULL,
- },
-};
-
-/* Common result structure for MACsec secure connection configure */
-struct cmd_macsec_sa_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t macsec;
- cmdline_fixed_string_t sa;
- cmdline_fixed_string_t tx_rx;
- portid_t port_id;
- uint8_t idx;
- uint8_t an;
- uint32_t pn;
- cmdline_fixed_string_t key;
-};
-
-/* Common CLI fields for MACsec secure connection configure */
-cmdline_parse_token_string_t cmd_macsec_sa_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_sa_result,
- set, "set");
-cmdline_parse_token_string_t cmd_macsec_sa_macsec =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_sa_result,
- macsec, "macsec");
-cmdline_parse_token_string_t cmd_macsec_sa_sa =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_sa_result,
- sa, "sa");
-cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_sa_result,
- tx_rx, "tx#rx");
-cmdline_parse_token_num_t cmd_macsec_sa_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_macsec_sa_result,
- port_id, UINT16);
-cmdline_parse_token_num_t cmd_macsec_sa_idx =
- TOKEN_NUM_INITIALIZER
- (struct cmd_macsec_sa_result,
- idx, UINT8);
-cmdline_parse_token_num_t cmd_macsec_sa_an =
- TOKEN_NUM_INITIALIZER
- (struct cmd_macsec_sa_result,
- an, UINT8);
-cmdline_parse_token_num_t cmd_macsec_sa_pn =
- TOKEN_NUM_INITIALIZER
- (struct cmd_macsec_sa_result,
- pn, UINT32);
-cmdline_parse_token_string_t cmd_macsec_sa_key =
- TOKEN_STRING_INITIALIZER
- (struct cmd_macsec_sa_result,
- key, NULL);
-
-static void
-cmd_set_macsec_sa_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_macsec_sa_result *res = parsed_result;
- int ret = -ENOTSUP;
- int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
- uint8_t key[16] = { 0 };
- uint8_t xdgt0;
- uint8_t xdgt1;
- int key_len;
- int i;
-
- key_len = strlen(res->key) / 2;
- if (key_len > 16)
- key_len = 16;
-
- for (i = 0; i < key_len; i++) {
- xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
- if (xdgt0 == 0xFF)
- return;
- xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
- if (xdgt1 == 0xFF)
- return;
- key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
- }
-
-#ifdef RTE_LIBRTE_IXGBE_PMD
- ret = is_tx ?
- rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
- res->idx, res->an, res->pn, key) :
- rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
- res->idx, res->an, res->pn, key);
-#endif
- RTE_SET_USED(is_tx);
- RTE_SET_USED(key);
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid idx %d or an %d\n", res->idx, res->an);
- break;
- case -ENODEV:
- printf("invalid port_id %d\n", res->port_id);
- break;
- case -ENOTSUP:
- printf("not supported on port %d\n", res->port_id);
- break;
- default:
- printf("programming error: (%s)\n", strerror(-ret));
- }
-}
-
-cmdline_parse_inst_t cmd_set_macsec_sa = {
- .f = cmd_set_macsec_sa_parsed,
- .data = NULL,
- .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
- .tokens = {
- (void *)&cmd_macsec_sa_set,
- (void *)&cmd_macsec_sa_macsec,
- (void *)&cmd_macsec_sa_sa,
- (void *)&cmd_macsec_sa_tx_rx,
- (void *)&cmd_macsec_sa_port_id,
- (void *)&cmd_macsec_sa_idx,
- (void *)&cmd_macsec_sa_an,
- (void *)&cmd_macsec_sa_pn,
- (void *)&cmd_macsec_sa_key,
- NULL,
- },
-};
-
-/* VF unicast promiscuous mode configuration */
-
-/* Common result structure for VF unicast promiscuous mode */
-struct cmd_vf_promisc_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t vf;
- cmdline_fixed_string_t promisc;
- portid_t port_id;
- uint32_t vf_id;
- cmdline_fixed_string_t on_off;
-};
-
-/* Common CLI fields for VF unicast promiscuous mode enable disable */
-cmdline_parse_token_string_t cmd_vf_promisc_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_promisc_result,
- set, "set");
-cmdline_parse_token_string_t cmd_vf_promisc_vf =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_promisc_result,
- vf, "vf");
-cmdline_parse_token_string_t cmd_vf_promisc_promisc =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_promisc_result,
- promisc, "promisc");
-cmdline_parse_token_num_t cmd_vf_promisc_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_vf_promisc_result,
- port_id, UINT16);
-cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_vf_promisc_result,
- vf_id, UINT32);
-cmdline_parse_token_string_t cmd_vf_promisc_on_off =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_promisc_result,
- on_off, "on#off");
-
-static void
-cmd_set_vf_promisc_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_vf_promisc_result *res = parsed_result;
- int ret = -ENOTSUP;
-
- __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
-#ifdef RTE_LIBRTE_I40E_PMD
- ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
- res->vf_id, is_on);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid vf_id %d\n", res->vf_id);
- 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_set_vf_promisc = {
- .f = cmd_set_vf_promisc_parsed,
- .data = NULL,
- .help_str = "set vf promisc <port_id> <vf_id> on|off: "
- "Set unicast promiscuous mode for a VF from the PF",
- .tokens = {
- (void *)&cmd_vf_promisc_set,
- (void *)&cmd_vf_promisc_vf,
- (void *)&cmd_vf_promisc_promisc,
- (void *)&cmd_vf_promisc_port_id,
- (void *)&cmd_vf_promisc_vf_id,
- (void *)&cmd_vf_promisc_on_off,
- NULL,
- },
-};
-
-/* VF multicast promiscuous mode configuration */
-
-/* Common result structure for VF multicast promiscuous mode */
-struct cmd_vf_allmulti_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t vf;
- cmdline_fixed_string_t allmulti;
- portid_t port_id;
- uint32_t vf_id;
- cmdline_fixed_string_t on_off;
-};
-
-/* Common CLI fields for VF multicast promiscuous mode enable disable */
-cmdline_parse_token_string_t cmd_vf_allmulti_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_allmulti_result,
- set, "set");
-cmdline_parse_token_string_t cmd_vf_allmulti_vf =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_allmulti_result,
- vf, "vf");
-cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_allmulti_result,
- allmulti, "allmulti");
-cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_vf_allmulti_result,
- port_id, UINT16);
-cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_vf_allmulti_result,
- vf_id, UINT32);
-cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_allmulti_result,
- on_off, "on#off");
-
-static void
-cmd_set_vf_allmulti_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_vf_allmulti_result *res = parsed_result;
- int ret = -ENOTSUP;
-
- __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
-#ifdef RTE_LIBRTE_I40E_PMD
- ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
- res->vf_id, is_on);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid vf_id %d\n", res->vf_id);
- 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_set_vf_allmulti = {
- .f = cmd_set_vf_allmulti_parsed,
- .data = NULL,
- .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
- "Set multicast promiscuous mode for a VF from the PF",
- .tokens = {
- (void *)&cmd_vf_allmulti_set,
- (void *)&cmd_vf_allmulti_vf,
- (void *)&cmd_vf_allmulti_allmulti,
- (void *)&cmd_vf_allmulti_port_id,
- (void *)&cmd_vf_allmulti_vf_id,
- (void *)&cmd_vf_allmulti_on_off,
- NULL,
- },
-};
-
-/* vf broadcast mode configuration */
-
-/* Common result structure for vf broadcast */
-struct cmd_set_vf_broadcast_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t vf;
- cmdline_fixed_string_t broadcast;
- portid_t port_id;
- uint16_t vf_id;
- cmdline_fixed_string_t on_off;
-};
-
-/* Common CLI fields for vf broadcast enable disable */
-cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_broadcast_result,
- set, "set");
-cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_broadcast_result,
- vf, "vf");
-cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_broadcast_result,
- broadcast, "broadcast");
-cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_set_vf_broadcast_result,
- port_id, UINT16);
-cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_set_vf_broadcast_result,
- vf_id, UINT16);
-cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_broadcast_result,
- on_off, "on#off");
-
-static void
-cmd_set_vf_broadcast_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_set_vf_broadcast_result *res = parsed_result;
- int ret = -ENOTSUP;
-
- __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
-#ifdef RTE_LIBRTE_I40E_PMD
- ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
- res->vf_id, is_on);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
- 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_set_vf_broadcast = {
- .f = cmd_set_vf_broadcast_parsed,
- .data = NULL,
- .help_str = "set vf broadcast <port_id> <vf_id> on|off",
- .tokens = {
- (void *)&cmd_set_vf_broadcast_set,
- (void *)&cmd_set_vf_broadcast_vf,
- (void *)&cmd_set_vf_broadcast_broadcast,
- (void *)&cmd_set_vf_broadcast_port_id,
- (void *)&cmd_set_vf_broadcast_vf_id,
- (void *)&cmd_set_vf_broadcast_on_off,
- NULL,
- },
-};
-
-/* vf vlan tag configuration */
-
-/* Common result structure for vf vlan tag */
-struct cmd_set_vf_vlan_tag_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t vf;
- cmdline_fixed_string_t vlan;
- cmdline_fixed_string_t tag;
- portid_t port_id;
- uint16_t vf_id;
- cmdline_fixed_string_t on_off;
-};
-
-/* Common CLI fields for vf vlan tag enable disable */
-cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- set, "set");
-cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- vf, "vf");
-cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- vlan, "vlan");
-cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- tag, "tag");
-cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- port_id, UINT16);
-cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- vf_id, UINT16);
-cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
- TOKEN_STRING_INITIALIZER
- (struct cmd_set_vf_vlan_tag_result,
- on_off, "on#off");
-
-static void
-cmd_set_vf_vlan_tag_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_set_vf_vlan_tag_result *res = parsed_result;
- int ret = -ENOTSUP;
-
- __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
-#ifdef RTE_LIBRTE_I40E_PMD
- ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
- res->vf_id, is_on);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
- 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_set_vf_vlan_tag = {
- .f = cmd_set_vf_vlan_tag_parsed,
- .data = NULL,
- .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
- .tokens = {
- (void *)&cmd_set_vf_vlan_tag_set,
- (void *)&cmd_set_vf_vlan_tag_vf,
- (void *)&cmd_set_vf_vlan_tag_vlan,
- (void *)&cmd_set_vf_vlan_tag_tag,
- (void *)&cmd_set_vf_vlan_tag_port_id,
- (void *)&cmd_set_vf_vlan_tag_vf_id,
- (void *)&cmd_set_vf_vlan_tag_on_off,
- NULL,
- },
-};
-
-/* Common definition of VF and TC TX bandwidth configuration */
-struct cmd_vf_tc_bw_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t vf;
- cmdline_fixed_string_t tc;
- cmdline_fixed_string_t tx;
- cmdline_fixed_string_t min_bw;
- cmdline_fixed_string_t max_bw;
- cmdline_fixed_string_t strict_link_prio;
- portid_t port_id;
- uint16_t vf_id;
- uint8_t tc_no;
- uint32_t bw;
- cmdline_fixed_string_t bw_list;
- uint8_t tc_map;
-};
-
-cmdline_parse_token_string_t cmd_vf_tc_bw_set =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- set, "set");
-cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- vf, "vf");
-cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- tc, "tc");
-cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- tx, "tx");
-cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- strict_link_prio, "strict-link-priority");
-cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- min_bw, "min-bandwidth");
-cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- max_bw, "max-bandwidth");
-cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
- TOKEN_NUM_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- port_id, UINT16);
-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,
- bw, UINT32);
-cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
- TOKEN_STRING_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- bw_list, NULL);
-cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
- TOKEN_NUM_INITIALIZER
- (struct cmd_vf_tc_bw_result,
- tc_map, UINT8);
-
-/* VF max bandwidth setting */
-static void
-cmd_vf_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_max_bw(res->port_id,
- res->vf_id, res->bw);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid vf_id %d or bandwidth %d\n",
- res->vf_id, 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_max_bw = {
- .f = cmd_vf_max_bw_parsed,
- .data = NULL,
- .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
- .tokens = {
- (void *)&cmd_vf_tc_bw_set,
- (void *)&cmd_vf_tc_bw_vf,
- (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_bw,
- NULL,
- },
-};
-
-static int
-vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
- uint8_t *tc_num,
- char *str)
-{
- uint32_t size;
- const char *p, *p0 = str;
- char s[256];
- char *end;
- char *str_fld[16];
- uint16_t i;
- int ret;
-
- p = strchr(p0, '(');
- if (p == NULL) {
- printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
- return -1;
- }
- p++;
- p0 = strchr(p, ')');
- if (p0 == NULL) {
- printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
- return -1;
- }
- size = p0 - p;
- if (size >= sizeof(s)) {
- printf("The string size exceeds the internal buffer size\n");
- return -1;
- }
- snprintf(s, sizeof(s), "%.*s", size, p);
- ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
- if (ret <= 0) {
- printf("Failed to get the bandwidth list. ");
- return -1;
- }
- *tc_num = ret;
- for (i = 0; i < ret; i++)
- bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
-
- return 0;
-}
-
-/* TC min bandwidth setting */
-static void
-cmd_vf_tc_min_bw_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_vf_tc_bw_result *res = parsed_result;
- uint8_t tc_num;
- uint8_t bw[16];
- int ret = -ENOTSUP;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
- ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
- if (ret)
- return;
-
-#ifdef RTE_LIBRTE_I40E_PMD
- ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
- tc_num, bw);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid vf_id %d or bandwidth\n", res->vf_id);
- 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_min_bw = {
- .f = cmd_vf_tc_min_bw_parsed,
- .data = NULL,
- .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
- " <bw1, bw2, ...>",
- .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_min_bw,
- (void *)&cmd_vf_tc_bw_port_id,
- (void *)&cmd_vf_tc_bw_vf_id,
- (void *)&cmd_vf_tc_bw_bw_list,
- NULL,
- },
-};
-
-static void
-cmd_tc_min_bw_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_vf_tc_bw_result *res = parsed_result;
- struct rte_port *port;
- uint8_t tc_num;
- uint8_t bw[16];
- int ret = -ENOTSUP;
-
- if (port_id_is_invalid(res->port_id, ENABLED_WARN))
- return;
-
- port = &ports[res->port_id];
- /** Check if the port is not started **/
- if (port->port_status != RTE_PORT_STOPPED) {
- printf("Please stop port %d first\n", res->port_id);
- return;
- }
-
- ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
- if (ret)
- return;
-
-#ifdef RTE_LIBRTE_IXGBE_PMD
- ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
-#endif
-
- switch (ret) {
- case 0:
- break;
- case -EINVAL:
- printf("invalid bandwidth\n");
- 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_tc_min_bw = {
- .f = cmd_tc_min_bw_parsed,
- .data = NULL,
- .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
- .tokens = {
- (void *)&cmd_vf_tc_bw_set,
- (void *)&cmd_vf_tc_bw_tc,
- (void *)&cmd_vf_tc_bw_tx,
- (void *)&cmd_vf_tc_bw_min_bw,
- (void *)&cmd_vf_tc_bw_port_id,
- (void *)&cmd_vf_tc_bw_bw_list,
- NULL,
- },
-};
-
-/* 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,
- },
-};
-
-
-#if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
-
-/* *** Set Port default Traffic Management Hierarchy *** */
-struct cmd_set_port_tm_hierarchy_default_result {
- cmdline_fixed_string_t set;
- cmdline_fixed_string_t port;
- cmdline_fixed_string_t tm;
- cmdline_fixed_string_t hierarchy;
- cmdline_fixed_string_t def;
- portid_t port_id;
-};
-
-cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
- TOKEN_STRING_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result, set, "set");
-cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
- TOKEN_STRING_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result, port, "port");
-cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
- TOKEN_STRING_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
-cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
- TOKEN_STRING_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result,
- hierarchy, "hierarchy");
-cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
- TOKEN_STRING_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result,
- def, "default");
-cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
- TOKEN_NUM_INITIALIZER(
- struct cmd_set_port_tm_hierarchy_default_result,
- port_id, UINT16);
-
-static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
- struct rte_port *p;
- portid_t port_id = res->port_id;
-
- if (port_id_is_invalid(port_id, ENABLED_WARN))
- return;
-
- p = &ports[port_id];
-
- /* Forward mode: tm */
- if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
- printf(" softnicfwd mode not enabled(error)\n");
- return;
- }
-
- /* Set the default tm hierarchy */
- p->softport.default_tm_hierarchy_enable = 1;
-}
-
-cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
- .f = cmd_set_port_tm_hierarchy_default_parsed,
- .data = NULL,
- .help_str = "set port tm hierarchy default <port_id>",
- .tokens = {
- (void *)&cmd_set_port_tm_hierarchy_default_set,
- (void *)&cmd_set_port_tm_hierarchy_default_port,
- (void *)&cmd_set_port_tm_hierarchy_default_tm,
- (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
- (void *)&cmd_set_port_tm_hierarchy_default_default,
- (void *)&cmd_set_port_tm_hierarchy_default_port_id,
- NULL,
- },
-};
-#endif
-
-/** Set VXLAN encapsulation details */
-struct cmd_set_vxlan_result {