From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 1CE3B3DC for ; Tue, 27 Dec 2016 07:27:13 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP; 26 Dec 2016 22:27:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,414,1477983600"; d="scan'208";a="1086959751" Received: from unknown (HELO dpdk9.sh.intel.com) ([10.239.129.31]) by fmsmga001.fm.intel.com with ESMTP; 26 Dec 2016 22:27:12 -0800 From: Beilei Xing To: jingjing.wu@intel.com, helin.zhang@intel.com Cc: dev@dpdk.org Date: Tue, 27 Dec 2016 14:26:20 +0800 Message-Id: <1482819984-14120-14-git-send-email-beilei.xing@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1482819984-14120-1-git-send-email-beilei.xing@intel.com> References: <1480679625-4157-1-git-send-email-beilei.xing@intel.com> <1482819984-14120-1-git-send-email-beilei.xing@intel.com> Subject: [dpdk-dev] [PATCH v2 13/17] net/i40e: destroy tunnel filter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2016 06:27:14 -0000 This patch adds i40e_dev_destroy_tunnel_filter function to destroy a tunnel filter for users. Signed-off-by: Beilei Xing --- drivers/net/i40e/i40e_ethdev.c | 10 ++-------- drivers/net/i40e/i40e_ethdev.h | 5 +++++ drivers/net/i40e/i40e_flow.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index fbab2a1..38e0713 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -413,14 +413,8 @@ static int i40e_sw_ethertype_filter_insert(struct i40e_pf *pf, static int i40e_tunnel_filter_convert( struct i40e_aqc_add_remove_cloud_filters_element_data *cld_filter, struct i40e_tunnel_filter *tunnel_filter); -static struct i40e_tunnel_filter * -i40e_sw_tunnel_filter_lookup(struct i40e_tunnel_rule *tunnel_rule, - const struct i40e_tunnel_filter_input *input); static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf, struct i40e_tunnel_filter *tunnel_filter); -static int i40e_sw_tunnel_filter_del(struct i40e_pf *pf, - struct i40e_tunnel_filter *tunnel_filter); - static void i40e_ethertype_filter_restore(struct i40e_pf *pf); static void i40e_tunnel_filter_restore(struct i40e_pf *pf); static void i40e_filter_restore(struct i40e_pf *pf); @@ -6553,7 +6547,7 @@ i40e_tunnel_filter_convert(struct i40e_aqc_add_remove_cloud_filters_element_data } /* Check if there exists the tunnel filter */ -static struct i40e_tunnel_filter * +struct i40e_tunnel_filter * i40e_sw_tunnel_filter_lookup(struct i40e_tunnel_rule *tunnel_rule, const struct i40e_tunnel_filter_input *input) { @@ -6588,7 +6582,7 @@ i40e_sw_tunnel_filter_insert(struct i40e_pf *pf, } /* Delete a tunnel filter from the SW list */ -static int +int i40e_sw_tunnel_filter_del(struct i40e_pf *pf, struct i40e_tunnel_filter *tunnel_filter) { diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h index 997527a..b8c7d41 100644 --- a/drivers/net/i40e/i40e_ethdev.h +++ b/drivers/net/i40e/i40e_ethdev.h @@ -781,6 +781,11 @@ i40e_sw_ethertype_filter_lookup(struct i40e_ethertype_rule *ethertype_rule, const struct i40e_ethertype_filter_input *input); int i40e_sw_ethertype_filter_del(struct i40e_pf *pf, struct i40e_ethertype_filter *filter); +struct i40e_tunnel_filter * +i40e_sw_tunnel_filter_lookup(struct i40e_tunnel_rule *tunnel_rule, + const struct i40e_tunnel_filter_input *input); +int i40e_sw_tunnel_filter_del(struct i40e_pf *pf, + struct i40e_tunnel_filter *tunnel_filter); /* I40E_DEV_PRIVATE_TO */ #define I40E_DEV_PRIVATE_TO_PF(adapter) \ diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 732c411..6a22deb 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -93,6 +93,8 @@ static int i40e_parse_attr(const struct rte_flow_attr *attr, struct rte_flow_error *error); static int i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf, struct i40e_ethertype_filter *filter); +static int i40e_dev_destroy_tunnel_filter(struct i40e_pf *pf, + struct i40e_tunnel_filter *filter); const struct rte_flow_ops i40e_flow_ops = { .validate = i40e_flow_validate, @@ -1505,6 +1507,10 @@ i40e_flow_destroy(__rte_unused struct rte_eth_dev *dev, ret = i40e_dev_destroy_ethertype_filter(pf, (struct i40e_ethertype_filter *)pmd_flow->rule); break; + case RTE_ETH_FILTER_TUNNEL: + ret = i40e_dev_destroy_tunnel_filter(pf, + (struct i40e_tunnel_filter *)pmd_flow->rule); + break; default: PMD_DRV_LOG(WARNING, "Filter type (%d) not supported", filter_type); @@ -1558,3 +1564,38 @@ i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf, return ret; } + +static int +i40e_dev_destroy_tunnel_filter(struct i40e_pf *pf, + struct i40e_tunnel_filter *filter) +{ + struct i40e_hw *hw = I40E_PF_TO_HW(pf); + struct i40e_vsi *vsi = pf->main_vsi; + struct i40e_aqc_add_remove_cloud_filters_element_data cld_filter; + struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel; + struct i40e_tunnel_filter *node; + int ret = 0; + + memset(&cld_filter, 0, sizeof(cld_filter)); + ether_addr_copy((struct ether_addr *)&filter->input.outer_mac, + (struct ether_addr *)&cld_filter.outer_mac); + ether_addr_copy((struct ether_addr *)&filter->input.inner_mac, + (struct ether_addr *)&cld_filter.inner_mac); + cld_filter.inner_vlan = filter->input.inner_vlan; + cld_filter.flags = filter->input.flags; + cld_filter.tenant_id = filter->input.tenant_id; + cld_filter.queue_number = filter->queue; + + ret = i40e_aq_remove_cloud_filters(hw, vsi->seid, + &cld_filter, 1); + if (ret < 0) + return ret; + + node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &filter->input); + if (node) + ret = i40e_sw_tunnel_filter_del(pf, node); + else + return -EINVAL; + + return ret; +} -- 2.5.5