From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 8CEF0591F for ; Fri, 2 Dec 2016 05:13:31 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 01 Dec 2016 20:13:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,284,1477983600"; d="scan'208";a="907853596" Received: from dpdk9.sh.intel.com ([10.239.129.141]) by orsmga003.jf.intel.com with ESMTP; 01 Dec 2016 20:13:17 -0800 From: Beilei Xing To: jingjing.wu@intel.com, helin.zhang@intel.com Cc: dev@dpdk.org, wenzhuo.lu@intel.com Date: Fri, 2 Dec 2016 06:53:38 -0500 Message-Id: <1480679625-4157-18-git-send-email-beilei.xing@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1480679625-4157-1-git-send-email-beilei.xing@intel.com> References: <1480679625-4157-1-git-send-email-beilei.xing@intel.com> Subject: [dpdk-dev] [PATCH 17/24] 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: , X-List-Received-Date: Fri, 02 Dec 2016 04:13:31 -0000 This patch adds a function to destroy the ethertype filter. And this patch also adds flow destroy function. Signed-off-by: Beilei Xing --- drivers/net/i40e/i40e_ethdev.c | 69 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index ac93489..a3ed1f0 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -517,6 +517,11 @@ static struct i40e_flow *i40e_flow_create(struct rte_eth_dev *dev, const struct rte_flow_item *pattern, const struct rte_flow_action *actions, struct rte_flow_error *error); +static int i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf, + struct i40e_ethertype_filter *filter); +static int i40e_flow_destroy(struct rte_eth_dev *dev, + struct rte_flow *flow, + struct rte_flow_error *error); struct i40e_flow { enum rte_filter_type filter_type; @@ -621,6 +626,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = { static const struct rte_flow_ops i40e_flow_ops = { .validate = i40e_flow_validate, .create = (void *)i40e_flow_create, + .destroy = i40e_flow_destroy, }; /* store statistics names and its offset in stats structure */ @@ -11665,3 +11671,66 @@ i40e_flow_create(struct rte_eth_dev *dev, rte_free(flow); return NULL; } + +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_info *ethertype_info = &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_info, &filter->input); + if (node) + ret = i40e_sw_ethertype_filter_del(pf, node); + else + return -EINVAL; + + return ret; +} + +static int +i40e_flow_destroy(struct rte_eth_dev *dev, + struct rte_flow *flow, + struct rte_flow_error *error) +{ + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct i40e_flow *pmd_flow = (struct i40e_flow *)flow; + enum rte_filter_type filter_type = pmd_flow->filter_type; + int ret; + + 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); + ret = -EINVAL; + break; + } + + if (ret) + error->type = RTE_FLOW_ERROR_TYPE_HANDLE; + + return ret; +} -- 2.5.5