From: Andrew Rybchenko Date: Thu, 22 Oct 2020 09:42:31 +0000 (+0100) Subject: ethdev: remove legacy tunnel filter type support X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=251baec367016412d55d6025ba1c1385cf48fa8b;p=dpdk.git ethdev: remove legacy tunnel filter type support Instead of TUNNEL filter RTE flow API should be used. Move corresponding defines and helper structure to ethdev driver interface since it is still used by drivers internally. Preserve RTE_ETH_FILTER_TUNNEL because of usage in drivers. Signed-off-by: Andrew Rybchenko Acked-by: Ajit Khaparde Reviewed-by: Ferruh Yigit --- diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index d3806cef79..a416890b8d 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -408,16 +408,6 @@ static void cmd_help_long_parsed(void *parsed_result, " Remove a vlan_id, to the set of VLAN identifiers" "filtered for VF(s) from port_id.\n\n" - "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " - "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" - "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" - " add a tunnel filter of a port.\n\n" - - "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " - "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|" - "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" - " remove a tunnel filter of a port.\n\n" - "rx_vxlan_port add (udp_port) (port_id)\n" " Add an UDP port for VXLAN packet filter on a port\n\n" @@ -9195,157 +9185,6 @@ cmdline_parse_inst_t cmd_vf_rate_limit = { }, }; -/* *** ADD TUNNEL FILTER OF A PORT *** */ -struct cmd_tunnel_filter_result { - cmdline_fixed_string_t cmd; - cmdline_fixed_string_t what; - portid_t port_id; - struct rte_ether_addr outer_mac; - struct rte_ether_addr inner_mac; - cmdline_ipaddr_t ip_value; - uint16_t inner_vlan; - cmdline_fixed_string_t tunnel_type; - cmdline_fixed_string_t filter_type; - uint32_t tenant_id; - uint16_t queue_num; -}; - -static void -cmd_tunnel_filter_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, - __rte_unused void *data) -{ - struct cmd_tunnel_filter_result *res = parsed_result; - struct rte_eth_tunnel_filter_conf tunnel_filter_conf; - int ret = 0; - - memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); - - rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); - rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); - tunnel_filter_conf.inner_vlan = res->inner_vlan; - - if (res->ip_value.family == AF_INET) { - tunnel_filter_conf.ip_addr.ipv4_addr = - res->ip_value.addr.ipv4.s_addr; - tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; - } else { - memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), - &(res->ip_value.addr.ipv6), - sizeof(struct in6_addr)); - tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; - } - - if (!strcmp(res->filter_type, "imac-ivlan")) - tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; - else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) - tunnel_filter_conf.filter_type = - RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; - else if (!strcmp(res->filter_type, "imac-tenid")) - tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; - else if (!strcmp(res->filter_type, "imac")) - tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; - else if (!strcmp(res->filter_type, "omac-imac-tenid")) - tunnel_filter_conf.filter_type = - RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; - else if (!strcmp(res->filter_type, "oip")) - tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; - else if (!strcmp(res->filter_type, "iip")) - tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; - else { - printf("The filter type is not supported"); - return; - } - - if (!strcmp(res->tunnel_type, "vxlan")) - tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; - else if (!strcmp(res->tunnel_type, "vxlan-gpe")) - tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE; - else if (!strcmp(res->tunnel_type, "nvgre")) - tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; - else if (!strcmp(res->tunnel_type, "ipingre")) - tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; - else { - printf("The tunnel type %s not supported.\n", res->tunnel_type); - return; - } - - tunnel_filter_conf.tenant_id = res->tenant_id; - tunnel_filter_conf.queue_id = res->queue_num; - if (!strcmp(res->what, "add")) - ret = rte_eth_dev_filter_ctrl(res->port_id, - RTE_ETH_FILTER_TUNNEL, - RTE_ETH_FILTER_ADD, - &tunnel_filter_conf); - else - ret = rte_eth_dev_filter_ctrl(res->port_id, - RTE_ETH_FILTER_TUNNEL, - RTE_ETH_FILTER_DELETE, - &tunnel_filter_conf); - if (ret < 0) - printf("cmd_tunnel_filter_parsed error: (%s)\n", - strerror(-ret)); - -} -cmdline_parse_token_string_t cmd_tunnel_filter_cmd = - TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, - cmd, "tunnel_filter"); -cmdline_parse_token_string_t cmd_tunnel_filter_what = - TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, - what, "add#rm"); -cmdline_parse_token_num_t cmd_tunnel_filter_port_id = - TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, - port_id, UINT16); -cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = - TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, - outer_mac); -cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = - TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, - inner_mac); -cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = - TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, - inner_vlan, UINT16); -cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = - TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, - ip_value); -cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = - TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, - tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe"); - -cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = - TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, - filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" - "imac#omac-imac-tenid"); -cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = - TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, - tenant_id, UINT32); -cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = - TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, - queue_num, UINT16); - -cmdline_parse_inst_t cmd_tunnel_filter = { - .f = cmd_tunnel_filter_parsed, - .data = (void *)0, - .help_str = "tunnel_filter add|rm " - " vxlan|nvgre|ipingre oip|iip|imac-ivlan|" - "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid " - ": Add/Rm tunnel filter of a port", - .tokens = { - (void *)&cmd_tunnel_filter_cmd, - (void *)&cmd_tunnel_filter_what, - (void *)&cmd_tunnel_filter_port_id, - (void *)&cmd_tunnel_filter_outer_mac, - (void *)&cmd_tunnel_filter_inner_mac, - (void *)&cmd_tunnel_filter_ip_value, - (void *)&cmd_tunnel_filter_innner_vlan, - (void *)&cmd_tunnel_filter_tunnel_type, - (void *)&cmd_tunnel_filter_filter_type, - (void *)&cmd_tunnel_filter_tenant_id, - (void *)&cmd_tunnel_filter_queue_num, - NULL, - }, -}; - /* *** CONFIGURE TUNNEL UDP PORT *** */ struct cmd_tunnel_udp_config { cmdline_fixed_string_t cmd; @@ -19164,7 +19003,6 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, (cmdline_parse_inst_t *)&cmd_queue_rate_limit, - (cmdline_parse_inst_t *)&cmd_tunnel_filter, (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, (cmdline_parse_inst_t *)&cmd_global_config, (cmdline_parse_inst_t *)&cmd_set_mirror_mask, diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index db14631504..ce01ec4540 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -91,7 +91,7 @@ Deprecation Notices * ethdev: the legacy filter API, including ``rte_eth_dev_filter_supported()``, ``rte_eth_dev_filter_ctrl()`` as well - as filter types TUNNEL, FDIR, + as filter types FDIR, HASH and L2_TUNNEL, is superseded by the generic flow API (rte_flow) in PMDs that implement the latter. The legacy API will be removed in DPDK 20.11. diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index dcf45a0e26..8483bf04f6 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1072,55 +1072,6 @@ Remove a VLAN ID, from the set of VLAN identifiers filtered for VF(s) for port I testpmd> rx_vlan rm (vlan_id) port (port_id) vf (vf_mask) -tunnel_filter add -~~~~~~~~~~~~~~~~~ - -Add a tunnel filter on a port:: - - testpmd> tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) \ - (inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|\ - imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id) - -The available information categories are: - -* ``vxlan``: Set tunnel type as VXLAN. - -* ``nvgre``: Set tunnel type as NVGRE. - -* ``ipingre``: Set tunnel type as IP-in-GRE. - -* ``vxlan-gpe``: Set tunnel type as VXLAN-GPE - -* ``imac-ivlan``: Set filter type as Inner MAC and VLAN. - -* ``imac-ivlan-tenid``: Set filter type as Inner MAC, VLAN and tenant ID. - -* ``imac-tenid``: Set filter type as Inner MAC and tenant ID. - -* ``imac``: Set filter type as Inner MAC. - -* ``omac-imac-tenid``: Set filter type as Outer MAC, Inner MAC and tenant ID. - -* ``oip``: Set filter type as Outer IP. - -* ``iip``: Set filter type as Inner IP. - -Example:: - - testpmd> tunnel_filter add 0 68:05:CA:28:09:82 00:00:00:00:00:00 \ - 192.168.2.2 0 ipingre oip 1 1 - - Set an IP-in-GRE tunnel on port 0, and the filter type is Outer IP. - -tunnel_filter remove -~~~~~~~~~~~~~~~~~~~~ - -Remove a tunnel filter on a port:: - - testpmd> tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) \ - (inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|\ - imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id) - rx_vxlan_port add ~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index c584ec7e9f..2a98b59873 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -3415,10 +3415,6 @@ bnxt_filter_ctrl_op(struct rte_eth_dev *dev, return ret; switch (filter_type) { - case RTE_ETH_FILTER_TUNNEL: - PMD_DRV_LOG(ERR, - "filter type: %d: To be implemented\n", filter_type); - break; case RTE_ETH_FILTER_FDIR: ret = bnxt_fdir_filter(dev, filter_op, arg); break; diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index aa87ad8dd5..2badd024f1 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -7863,145 +7863,6 @@ i40e_sw_tunnel_filter_del(struct i40e_pf *pf, return 0; } -int -i40e_dev_tunnel_filter_set(struct i40e_pf *pf, - struct rte_eth_tunnel_filter_conf *tunnel_filter, - uint8_t add) -{ - uint16_t ip_type; - uint32_t ipv4_addr, ipv4_addr_le; - uint8_t i, tun_type = 0; - /* internal varialbe to convert ipv6 byte order */ - uint32_t convert_ipv6[4]; - int val, ret = 0; - struct i40e_hw *hw = I40E_PF_TO_HW(pf); - struct i40e_vsi *vsi = pf->main_vsi; - struct i40e_aqc_cloud_filters_element_bb *cld_filter; - struct i40e_aqc_cloud_filters_element_bb *pfilter; - struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel; - struct i40e_tunnel_filter *tunnel, *node; - struct i40e_tunnel_filter check_filter; /* Check if filter exists */ - - cld_filter = rte_zmalloc("tunnel_filter", - sizeof(struct i40e_aqc_add_rm_cloud_filt_elem_ext), - 0); - - if (NULL == cld_filter) { - PMD_DRV_LOG(ERR, "Failed to alloc memory."); - return -ENOMEM; - } - pfilter = cld_filter; - - rte_ether_addr_copy(&tunnel_filter->outer_mac, - (struct rte_ether_addr *)&pfilter->element.outer_mac); - rte_ether_addr_copy(&tunnel_filter->inner_mac, - (struct rte_ether_addr *)&pfilter->element.inner_mac); - - pfilter->element.inner_vlan = - rte_cpu_to_le_16(tunnel_filter->inner_vlan); - if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) { - ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4; - ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr); - ipv4_addr_le = rte_cpu_to_le_32(ipv4_addr); - rte_memcpy(&pfilter->element.ipaddr.v4.data, - &ipv4_addr_le, - sizeof(pfilter->element.ipaddr.v4.data)); - } else { - ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6; - for (i = 0; i < 4; i++) { - convert_ipv6[i] = - rte_cpu_to_le_32(rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv6_addr[i])); - } - rte_memcpy(&pfilter->element.ipaddr.v6.data, - &convert_ipv6, - sizeof(pfilter->element.ipaddr.v6.data)); - } - - /* check tunneled type */ - switch (tunnel_filter->tunnel_type) { - case RTE_TUNNEL_TYPE_VXLAN: - tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN; - break; - case RTE_TUNNEL_TYPE_NVGRE: - tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_NVGRE_OMAC; - break; - case RTE_TUNNEL_TYPE_IP_IN_GRE: - tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_IP; - break; - case RTE_TUNNEL_TYPE_VXLAN_GPE: - tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_VXLAN_GPE; - break; - default: - /* Other tunnel types is not supported. */ - PMD_DRV_LOG(ERR, "tunnel type is not supported."); - rte_free(cld_filter); - return -EINVAL; - } - - val = i40e_dev_get_filter_type(tunnel_filter->filter_type, - &pfilter->element.flags); - if (val < 0) { - rte_free(cld_filter); - return -EINVAL; - } - - pfilter->element.flags |= rte_cpu_to_le_16( - I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | - ip_type | (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT)); - pfilter->element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id); - pfilter->element.queue_number = - rte_cpu_to_le_16(tunnel_filter->queue_id); - - /* Check if there is the filter in SW list */ - memset(&check_filter, 0, sizeof(check_filter)); - i40e_tunnel_filter_convert(cld_filter, &check_filter); - node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &check_filter.input); - if (add && node) { - PMD_DRV_LOG(ERR, "Conflict with existing tunnel rules!"); - rte_free(cld_filter); - return -EINVAL; - } - - if (!add && !node) { - PMD_DRV_LOG(ERR, "There's no corresponding tunnel filter!"); - rte_free(cld_filter); - return -EINVAL; - } - - if (add) { - ret = i40e_aq_add_cloud_filters(hw, - vsi->seid, &cld_filter->element, 1); - if (ret < 0) { - PMD_DRV_LOG(ERR, "Failed to add a tunnel filter."); - rte_free(cld_filter); - return -ENOTSUP; - } - tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0); - if (tunnel == NULL) { - PMD_DRV_LOG(ERR, "Failed to alloc memory."); - rte_free(cld_filter); - return -ENOMEM; - } - - rte_memcpy(tunnel, &check_filter, sizeof(check_filter)); - ret = i40e_sw_tunnel_filter_insert(pf, tunnel); - if (ret < 0) - rte_free(tunnel); - } else { - ret = i40e_aq_rem_cloud_filters(hw, vsi->seid, - &cld_filter->element, 1); - if (ret < 0) { - PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter."); - rte_free(cld_filter); - return -ENOTSUP; - } - ret = i40e_sw_tunnel_filter_del(pf, &node->input); - } - - rte_free(cld_filter); - return ret; -} - #define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_TR_WORD0 0x48 #define I40E_TR_VXLAN_GRE_KEY_MASK 0x4 #define I40E_TR_GENEVE_KEY_MASK 0x8 @@ -9004,40 +8865,6 @@ i40e_pf_config_rss(struct i40e_pf *pf) return i40e_hw_rss_hash_set(pf, &rss_conf); } -static int -i40e_tunnel_filter_param_check(struct i40e_pf *pf, - struct rte_eth_tunnel_filter_conf *filter) -{ - if (pf == NULL || filter == NULL) { - PMD_DRV_LOG(ERR, "Invalid parameter"); - return -EINVAL; - } - - if (filter->queue_id >= pf->dev_data->nb_rx_queues) { - PMD_DRV_LOG(ERR, "Invalid queue ID"); - return -EINVAL; - } - - if (filter->inner_vlan > RTE_ETHER_MAX_VLAN_ID) { - PMD_DRV_LOG(ERR, "Invalid inner VLAN ID"); - return -EINVAL; - } - - if ((filter->filter_type & ETH_TUNNEL_FILTER_OMAC) && - (rte_is_zero_ether_addr(&filter->outer_mac))) { - PMD_DRV_LOG(ERR, "Cannot add NULL outer MAC address"); - return -EINVAL; - } - - if ((filter->filter_type & ETH_TUNNEL_FILTER_IMAC) && - (rte_is_zero_ether_addr(&filter->inner_mac))) { - PMD_DRV_LOG(ERR, "Cannot add NULL inner MAC address"); - return -EINVAL; - } - - return 0; -} - #define I40E_GL_PRS_FVBM_MSK_ENA 0x80000000 #define I40E_GL_PRS_FVBM(_i) (0x00269760 + ((_i) * 4)) int @@ -9123,40 +8950,6 @@ i40e_filter_ctrl_global_config(struct rte_eth_dev *dev, return ret; } -static int -i40e_tunnel_filter_handle(struct rte_eth_dev *dev, - enum rte_filter_op filter_op, - void *arg) -{ - struct rte_eth_tunnel_filter_conf *filter; - struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); - int ret = I40E_SUCCESS; - - filter = (struct rte_eth_tunnel_filter_conf *)(arg); - - if (i40e_tunnel_filter_param_check(pf, filter) < 0) - return I40E_ERR_PARAM; - - switch (filter_op) { - case RTE_ETH_FILTER_NOP: - if (!(pf->flags & I40E_FLAG_VXLAN)) - ret = I40E_NOT_SUPPORTED; - break; - case RTE_ETH_FILTER_ADD: - ret = i40e_dev_tunnel_filter_set(pf, filter, 1); - break; - case RTE_ETH_FILTER_DELETE: - ret = i40e_dev_tunnel_filter_set(pf, filter, 0); - break; - default: - PMD_DRV_LOG(ERR, "unknown operation %u", filter_op); - ret = I40E_ERR_PARAM; - break; - } - - return ret; -} - /* Get the symmetric hash enable configurations per port */ static void i40e_get_symmetric_hash_enable_per_port(struct i40e_hw *hw, uint8_t *enable) @@ -10465,9 +10258,6 @@ i40e_dev_filter_ctrl(struct rte_eth_dev *dev, case RTE_ETH_FILTER_HASH: ret = i40e_hash_filter_ctrl(dev, filter_op, arg); break; - case RTE_ETH_FILTER_TUNNEL: - ret = i40e_tunnel_filter_handle(dev, filter_op, arg); - break; case RTE_ETH_FILTER_FDIR: ret = i40e_fdir_ctrl_func(dev, filter_op, arg); break; diff --git a/drivers/net/qede/qede_filter.c b/drivers/net/qede/qede_filter.c index 0c47407edd..ba4e4d9e16 100644 --- a/drivers/net/qede/qede_filter.c +++ b/drivers/net/qede/qede_filter.c @@ -696,36 +696,6 @@ qede_geneve_enable(struct rte_eth_dev *eth_dev, uint8_t clss, return rc; } -static int -qede_ipgre_enable(struct rte_eth_dev *eth_dev, uint8_t clss, - bool enable) -{ - struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev); - struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); - enum _ecore_status_t rc = ECORE_INVAL; - struct ecore_tunnel_info tunn; - - memset(&tunn, 0, sizeof(struct ecore_tunnel_info)); - tunn.ip_gre.b_update_mode = true; - tunn.ip_gre.b_mode_enabled = enable; - tunn.ip_gre.tun_cls = clss; - tunn.ip_gre.tun_cls = clss; - tunn.b_update_rx_cls = true; - tunn.b_update_tx_cls = true; - - rc = qede_tunnel_update(qdev, &tunn); - if (rc == ECORE_SUCCESS) { - qdev->ipgre.enable = enable; - DP_INFO(edev, "IPGRE is %s\n", - enable ? "enabled" : "disabled"); - } else { - DP_ERR(edev, "Failed to update tunn_clss %u\n", - clss); - } - - return rc; -} - int qede_udp_dst_port_del(struct rte_eth_dev *eth_dev, struct rte_eth_udp_tunnel *tunnel_udp) @@ -902,210 +872,6 @@ qede_udp_dst_port_add(struct rte_eth_dev *eth_dev, return 0; } -static void qede_get_ecore_tunn_params(uint32_t filter, uint32_t *type, - uint32_t *clss, char *str) -{ - uint16_t j; - *clss = MAX_ECORE_TUNN_CLSS; - - for (j = 0; j < RTE_DIM(qede_tunn_types); j++) { - if (filter == qede_tunn_types[j].rte_filter_type) { - *type = qede_tunn_types[j].qede_type; - *clss = qede_tunn_types[j].qede_tunn_clss; - strcpy(str, qede_tunn_types[j].string); - return; - } - } -} - -static int -qede_set_ucast_tunn_cmn_param(struct ecore_filter_ucast *ucast, - const struct rte_eth_tunnel_filter_conf *conf, - uint32_t type) -{ - /* Init commmon ucast params first */ - qede_set_ucast_cmn_params(ucast); - - /* Copy out the required fields based on classification type */ - ucast->type = type; - - switch (type) { - case ECORE_FILTER_VNI: - ucast->vni = conf->tenant_id; - break; - case ECORE_FILTER_INNER_VLAN: - ucast->vlan = conf->inner_vlan; - break; - case ECORE_FILTER_MAC: - memcpy(ucast->mac, conf->outer_mac.addr_bytes, - RTE_ETHER_ADDR_LEN); - break; - case ECORE_FILTER_INNER_MAC: - memcpy(ucast->mac, conf->inner_mac.addr_bytes, - RTE_ETHER_ADDR_LEN); - break; - case ECORE_FILTER_MAC_VNI_PAIR: - memcpy(ucast->mac, conf->outer_mac.addr_bytes, - RTE_ETHER_ADDR_LEN); - ucast->vni = conf->tenant_id; - break; - case ECORE_FILTER_INNER_MAC_VNI_PAIR: - memcpy(ucast->mac, conf->inner_mac.addr_bytes, - RTE_ETHER_ADDR_LEN); - ucast->vni = conf->tenant_id; - break; - case ECORE_FILTER_INNER_PAIR: - memcpy(ucast->mac, conf->inner_mac.addr_bytes, - RTE_ETHER_ADDR_LEN); - ucast->vlan = conf->inner_vlan; - break; - default: - return -EINVAL; - } - - return ECORE_SUCCESS; -} - -static int -_qede_tunn_filter_config(struct rte_eth_dev *eth_dev, - const struct rte_eth_tunnel_filter_conf *conf, - __rte_unused enum rte_filter_op filter_op, - enum ecore_tunn_clss *clss, - bool add) -{ - struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev); - struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); - struct ecore_filter_ucast ucast = {0}; - enum ecore_filter_ucast_type type; - uint16_t filter_type = 0; - char str[80]; - int rc; - - filter_type = conf->filter_type; - /* Determine if the given filter classification is supported */ - qede_get_ecore_tunn_params(filter_type, &type, clss, str); - if (*clss == MAX_ECORE_TUNN_CLSS) { - DP_ERR(edev, "Unsupported filter type\n"); - return -EINVAL; - } - /* Init tunnel ucast params */ - rc = qede_set_ucast_tunn_cmn_param(&ucast, conf, type); - if (rc != ECORE_SUCCESS) { - DP_ERR(edev, "Unsupported Tunnel filter type 0x%x\n", - conf->filter_type); - return rc; - } - DP_INFO(edev, "Rule: \"%s\", op %d, type 0x%x\n", - str, filter_op, ucast.type); - - ucast.opcode = add ? ECORE_FILTER_ADD : ECORE_FILTER_REMOVE; - - /* Skip MAC/VLAN if filter is based on VNI */ - if (!(filter_type & ETH_TUNNEL_FILTER_TENID)) { - rc = qede_mac_int_ops(eth_dev, &ucast, add); - if (rc == 0 && add) { - /* Enable accept anyvlan */ - qede_config_accept_any_vlan(qdev, true); - } - } else { - rc = qede_ucast_filter(eth_dev, &ucast, add); - if (rc == 0) - rc = ecore_filter_ucast_cmd(edev, &ucast, - ECORE_SPQ_MODE_CB, NULL); - } - - return rc; -} - -static int -qede_tunn_enable(struct rte_eth_dev *eth_dev, uint8_t clss, - enum rte_eth_tunnel_type tunn_type, bool enable) -{ - int rc = -EINVAL; - - switch (tunn_type) { - case RTE_TUNNEL_TYPE_VXLAN: - rc = qede_vxlan_enable(eth_dev, clss, enable); - break; - case RTE_TUNNEL_TYPE_GENEVE: - rc = qede_geneve_enable(eth_dev, clss, enable); - break; - case RTE_TUNNEL_TYPE_IP_IN_GRE: - rc = qede_ipgre_enable(eth_dev, clss, enable); - break; - default: - rc = -EINVAL; - break; - } - - return rc; -} - -static int -qede_tunn_filter_config(struct rte_eth_dev *eth_dev, - enum rte_filter_op filter_op, - const struct rte_eth_tunnel_filter_conf *conf) -{ - struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev); - struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); - enum ecore_tunn_clss clss = MAX_ECORE_TUNN_CLSS; - bool add; - int rc; - - PMD_INIT_FUNC_TRACE(edev); - - switch (filter_op) { - case RTE_ETH_FILTER_ADD: - add = true; - break; - case RTE_ETH_FILTER_DELETE: - add = false; - break; - default: - DP_ERR(edev, "Unsupported operation %d\n", filter_op); - return -EINVAL; - } - - if (IS_VF(edev)) - return qede_tunn_enable(eth_dev, - ECORE_TUNN_CLSS_MAC_VLAN, - conf->tunnel_type, add); - - rc = _qede_tunn_filter_config(eth_dev, conf, filter_op, &clss, add); - if (rc != ECORE_SUCCESS) - return rc; - - if (add) { - if (conf->tunnel_type == RTE_TUNNEL_TYPE_VXLAN) { - qdev->vxlan.num_filters++; - qdev->vxlan.filter_type = conf->filter_type; - } else { /* GENEVE */ - qdev->geneve.num_filters++; - qdev->geneve.filter_type = conf->filter_type; - } - - if (!qdev->vxlan.enable || !qdev->geneve.enable || - !qdev->ipgre.enable) - return qede_tunn_enable(eth_dev, clss, - conf->tunnel_type, - true); - } else { - if (conf->tunnel_type == RTE_TUNNEL_TYPE_VXLAN) - qdev->vxlan.num_filters--; - else /*GENEVE*/ - qdev->geneve.num_filters--; - - /* Disable VXLAN if VXLAN filters become 0 */ - if (qdev->vxlan.num_filters == 0 || - qdev->geneve.num_filters == 0) - return qede_tunn_enable(eth_dev, clss, - conf->tunnel_type, - false); - } - - return 0; -} - static int qede_flow_validate_attr(__rte_unused struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -1460,31 +1226,8 @@ int qede_dev_filter_ctrl(struct rte_eth_dev *eth_dev, { struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev); struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); - struct rte_eth_tunnel_filter_conf *filter_conf = - (struct rte_eth_tunnel_filter_conf *)arg; switch (filter_type) { - case RTE_ETH_FILTER_TUNNEL: - switch (filter_conf->tunnel_type) { - case RTE_TUNNEL_TYPE_VXLAN: - case RTE_TUNNEL_TYPE_GENEVE: - case RTE_TUNNEL_TYPE_IP_IN_GRE: - DP_INFO(edev, - "Packet steering to the specified Rx queue" - " is not supported with UDP tunneling"); - return(qede_tunn_filter_config(eth_dev, filter_op, - filter_conf)); - case RTE_TUNNEL_TYPE_TEREDO: - case RTE_TUNNEL_TYPE_NVGRE: - case RTE_L2_TUNNEL_TYPE_E_TAG: - DP_ERR(edev, "Unsupported tunnel type %d\n", - filter_conf->tunnel_type); - return -EINVAL; - case RTE_TUNNEL_TYPE_NONE: - default: - return 0; - } - break; case RTE_ETH_FILTER_FDIR: return qede_fdir_filter_conf(eth_dev, filter_op, arg); case RTE_ETH_FILTER_GENERIC: diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index d779453923..69e8c93ffa 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -1755,9 +1755,6 @@ sfc_dev_filter_ctrl(struct rte_eth_dev *dev, enum rte_filter_type filter_type, case RTE_ETH_FILTER_NONE: sfc_err(sa, "Global filters configuration not supported"); break; - case RTE_ETH_FILTER_TUNNEL: - sfc_err(sa, "Tunnel filters not supported"); - break; case RTE_ETH_FILTER_FDIR: sfc_err(sa, "Flow Director filters not supported"); break; diff --git a/lib/librte_ethdev/rte_eth_ctrl.h b/lib/librte_ethdev/rte_eth_ctrl.h index b4cc163e3e..10b176f39e 100644 --- a/lib/librte_ethdev/rte_eth_ctrl.h +++ b/lib/librte_ethdev/rte_eth_ctrl.h @@ -105,57 +105,6 @@ struct rte_eth_ntuple_filter { uint16_t queue; /**< Queue assigned to when match*/ }; -/** - * filter type of tunneling packet - */ -#define ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */ -#define ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */ -#define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */ -#define ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */ -#define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */ -#define ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */ - -#define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \ - ETH_TUNNEL_FILTER_IVLAN) -#define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \ - ETH_TUNNEL_FILTER_IVLAN | \ - ETH_TUNNEL_FILTER_TENID) -#define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \ - ETH_TUNNEL_FILTER_TENID) -#define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \ - ETH_TUNNEL_FILTER_TENID | \ - ETH_TUNNEL_FILTER_IMAC) - -/** - * Select IPv4 or IPv6 for tunnel filters. - */ -enum rte_tunnel_iptype { - RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */ - RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */ -}; - -/** - * Tunneling Packet filter configuration. - */ -struct rte_eth_tunnel_filter_conf { - struct rte_ether_addr outer_mac; /**< Outer MAC address to match. */ - struct rte_ether_addr inner_mac; /**< Inner MAC address to match. */ - uint16_t inner_vlan; /**< Inner VLAN to match. */ - enum rte_tunnel_iptype ip_type; /**< IP address type. */ - /** Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP - is set in filter_type, or inner destination IP address to match - if ETH_TUNNEL_FILTER_IIP is set in filter_type . */ - union { - uint32_t ipv4_addr; /**< IPv4 address in big endian. */ - uint32_t ipv6_addr[4]; /**< IPv6 address in big endian. */ - } ip_addr; - /** Flags from ETH_TUNNEL_FILTER_XX - see above. */ - uint16_t filter_type; - enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */ - uint32_t tenant_id; /**< Tenant ID to match. VNI, GRE key... */ - uint16_t queue_id; /**< Queue assigned to if match. */ -}; - /** * Global eth device configuration type. */ diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h index 436e7ead9c..7a54f0c81b 100644 --- a/lib/librte_ethdev/rte_ethdev_driver.h +++ b/lib/librte_ethdev/rte_ethdev_driver.h @@ -1375,6 +1375,59 @@ struct rte_eth_syn_filter { uint16_t queue; /**< Queue assigned to when match */ }; +/** + * filter type of tunneling packet + */ +#define ETH_TUNNEL_FILTER_OMAC 0x01 /**< filter by outer MAC addr */ +#define ETH_TUNNEL_FILTER_OIP 0x02 /**< filter by outer IP Addr */ +#define ETH_TUNNEL_FILTER_TENID 0x04 /**< filter by tenant ID */ +#define ETH_TUNNEL_FILTER_IMAC 0x08 /**< filter by inner MAC addr */ +#define ETH_TUNNEL_FILTER_IVLAN 0x10 /**< filter by inner VLAN ID */ +#define ETH_TUNNEL_FILTER_IIP 0x20 /**< filter by inner IP addr */ + +#define RTE_TUNNEL_FILTER_IMAC_IVLAN (ETH_TUNNEL_FILTER_IMAC | \ + ETH_TUNNEL_FILTER_IVLAN) +#define RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID (ETH_TUNNEL_FILTER_IMAC | \ + ETH_TUNNEL_FILTER_IVLAN | \ + ETH_TUNNEL_FILTER_TENID) +#define RTE_TUNNEL_FILTER_IMAC_TENID (ETH_TUNNEL_FILTER_IMAC | \ + ETH_TUNNEL_FILTER_TENID) +#define RTE_TUNNEL_FILTER_OMAC_TENID_IMAC (ETH_TUNNEL_FILTER_OMAC | \ + ETH_TUNNEL_FILTER_TENID | \ + ETH_TUNNEL_FILTER_IMAC) + +/** + * Select IPv4 or IPv6 for tunnel filters. + */ +enum rte_tunnel_iptype { + RTE_TUNNEL_IPTYPE_IPV4 = 0, /**< IPv4. */ + RTE_TUNNEL_IPTYPE_IPV6, /**< IPv6. */ +}; + +/** + * Tunneling Packet filter configuration. + */ +struct rte_eth_tunnel_filter_conf { + struct rte_ether_addr outer_mac; /**< Outer MAC address to match. */ + struct rte_ether_addr inner_mac; /**< Inner MAC address to match. */ + uint16_t inner_vlan; /**< Inner VLAN to match. */ + enum rte_tunnel_iptype ip_type; /**< IP address type. */ + /** + * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP + * is set in filter_type, or inner destination IP address to match + * if ETH_TUNNEL_FILTER_IIP is set in filter_type. + */ + union { + uint32_t ipv4_addr; /**< IPv4 address in big endian. */ + uint32_t ipv6_addr[4]; /**< IPv6 address in big endian. */ + } ip_addr; + /** Flags from ETH_TUNNEL_FILTER_XX - see above. */ + uint16_t filter_type; + enum rte_eth_tunnel_type tunnel_type; /**< Tunnel Type. */ + uint32_t tenant_id; /**< Tenant ID to match. VNI, GRE key... */ + uint16_t queue_id; /**< Queue assigned to if match. */ +}; + #ifdef __cplusplus } #endif