From patchwork Wed Jan 4 03:23:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xing, Beilei" X-Patchwork-Id: 18831 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id E8556F943; Wed, 4 Jan 2017 04:24:40 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 2B9364CC5 for ; Wed, 4 Jan 2017 04:23:56 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 03 Jan 2017 19:23:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,458,1477983600"; d="scan'208";a="804865239" Received: from unknown (HELO dpdk9.sh.intel.com) ([10.239.129.31]) by FMSMGA003.fm.intel.com with ESMTP; 03 Jan 2017 19:23:54 -0800 From: Beilei Xing To: jingjing.wu@intel.com, helin.zhang@intel.com Cc: dev@dpdk.org Date: Wed, 4 Jan 2017 11:23:02 +0800 Message-Id: <1483500187-124740-13-git-send-email-beilei.xing@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1483500187-124740-1-git-send-email-beilei.xing@intel.com> References: <1483068352-32272-1-git-send-email-beilei.xing@intel.com> <1483500187-124740-1-git-send-email-beilei.xing@intel.com> Subject: [dpdk-dev] [PATCH v5 12/17] net/i40e: destroy ethertype 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch adds i40e_dev_destroy_ethertype_filter function to destroy a ethertype filter for users. Signed-off-by: Beilei Xing --- drivers/net/i40e/i40e_flow.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index ece9f89..2940058 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -49,6 +49,7 @@ #include "i40e_logs.h" #include "base/i40e_type.h" +#include "base/i40e_prototype.h" #include "i40e_ethdev.h" #define I40E_IPV4_TC_SHIFT 4 @@ -96,6 +97,8 @@ static int i40e_parse_tunnel_act(struct rte_eth_dev *dev, struct rte_eth_tunnel_filter_conf *filter); 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); const struct rte_flow_ops i40e_flow_ops = { .validate = i40e_flow_validate, @@ -1539,6 +1542,10 @@ i40e_flow_destroy(struct rte_eth_dev *dev, int ret = 0; switch (filter_type) { + case RTE_ETH_FILTER_ETHERTYPE: + ret = i40e_dev_destroy_ethertype_filter(pf, + (struct i40e_ethertype_filter *)pmd_flow->rule); + break; default: PMD_DRV_LOG(WARNING, "Filter type (%d) not supported", filter_type); @@ -1556,3 +1563,38 @@ i40e_flow_destroy(struct rte_eth_dev *dev, return ret; } + +static int +i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf, + struct i40e_ethertype_filter *filter) +{ + struct i40e_hw *hw = I40E_PF_TO_HW(pf); + struct i40e_ethertype_rule *ethertype_rule = &pf->ethertype; + struct i40e_ethertype_filter *node; + struct i40e_control_filter_stats stats; + uint16_t flags = 0; + int ret = 0; + + if (!(filter->flags & RTE_ETHTYPE_FLAGS_MAC)) + flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC; + if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) + flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP; + flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE; + + memset(&stats, 0, sizeof(stats)); + ret = i40e_aq_add_rem_control_packet_filter(hw, + filter->input.mac_addr.addr_bytes, + filter->input.ether_type, + flags, pf->main_vsi->seid, + filter->queue, 0, &stats, NULL); + if (ret < 0) + return ret; + + node = i40e_sw_ethertype_filter_lookup(ethertype_rule, &filter->input); + if (!node) + return -EINVAL; + + ret = i40e_sw_ethertype_filter_del(pf, &node->input); + + return ret; +}