From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 10010F91D for ; Thu, 12 Jan 2017 09:19:01 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP; 12 Jan 2017 00:19:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,349,1477983600"; d="scan'208";a="1093088614" Received: from dpdk1.bj.intel.com ([172.16.182.84]) by fmsmga001.fm.intel.com with ESMTP; 12 Jan 2017 00:19:00 -0800 From: Wei Zhao To: dev@dpdk.org Cc: Wenzhuo Lu , Wei Zhao Date: Thu, 12 Jan 2017 16:13:48 +0800 Message-Id: <1484208838-58734-9-git-send-email-wei.zhao1@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1484208838-58734-1-git-send-email-wei.zhao1@intel.com> References: <1483084390-53159-2-git-send-email-wei.zhao1@intel.com> <1484208838-58734-1-git-send-email-wei.zhao1@intel.com> Subject: [dpdk-dev] [PATCH v3 08/18] net/ixgbe: restore L2 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: Thu, 12 Jan 2017 08:19:02 -0000 Add support for restoring L2 tunnel filter in SW. Signed-off-by: Wenzhuo Lu Signed-off-by: Wei Zhao --- drivers/net/ixgbe/ixgbe_ethdev.c | 69 ++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index f48e30c..0ad613b 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -7324,7 +7324,8 @@ ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info, /* Add l2 tunnel filter */ static int ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev, - struct rte_eth_l2_tunnel_conf *l2_tunnel) + struct rte_eth_l2_tunnel_conf *l2_tunnel, + bool restore) { int ret; struct ixgbe_l2_tn_info *l2_tn_info = @@ -7332,30 +7333,33 @@ ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev, struct ixgbe_l2_tn_key key; struct ixgbe_l2_tn_filter *node; - key.l2_tn_type = l2_tunnel->l2_tunnel_type; - key.tn_id = l2_tunnel->tunnel_id; + if (!restore) { + key.l2_tn_type = l2_tunnel->l2_tunnel_type; + key.tn_id = l2_tunnel->tunnel_id; - node = ixgbe_l2_tn_filter_lookup(l2_tn_info, &key); + node = ixgbe_l2_tn_filter_lookup(l2_tn_info, &key); - if (node) { - PMD_DRV_LOG(ERR, "The L2 tunnel filter already exists!"); - return -EINVAL; - } + if (node) { + PMD_DRV_LOG(ERR, + "The L2 tunnel filter already exists!"); + return -EINVAL; + } - node = rte_zmalloc("ixgbe_l2_tn", - sizeof(struct ixgbe_l2_tn_filter), - 0); - if (!node) - return -ENOMEM; + node = rte_zmalloc("ixgbe_l2_tn", + sizeof(struct ixgbe_l2_tn_filter), + 0); + if (!node) + return -ENOMEM; - (void)rte_memcpy(&node->key, - &key, - sizeof(struct ixgbe_l2_tn_key)); - node->pool = l2_tunnel->pool; - ret = ixgbe_insert_l2_tn_filter(l2_tn_info, node); - if (ret < 0) { - rte_free(node); - return ret; + (void)rte_memcpy(&node->key, + &key, + sizeof(struct ixgbe_l2_tn_key)); + node->pool = l2_tunnel->pool; + ret = ixgbe_insert_l2_tn_filter(l2_tn_info, node); + if (ret < 0) { + rte_free(node); + return ret; + } } switch (l2_tunnel->l2_tunnel_type) { @@ -7368,7 +7372,7 @@ ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev, break; } - if (ret < 0) + if ((!restore) && (ret < 0)) (void)ixgbe_remove_l2_tn_filter(l2_tn_info, &key); return ret; @@ -7429,7 +7433,8 @@ ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev, case RTE_ETH_FILTER_ADD: ret = ixgbe_dev_l2_tunnel_filter_add (dev, - (struct rte_eth_l2_tunnel_conf *)arg); + (struct rte_eth_l2_tunnel_conf *)arg, + FALSE); break; case RTE_ETH_FILTER_DELETE: ret = ixgbe_dev_l2_tunnel_filter_del @@ -7962,6 +7967,23 @@ ixgbe_syn_filter_restore(struct rte_eth_dev *dev) } } +/* restore L2 tunnel filter */ +static inline void +ixgbe_l2_tn_filter_restore(struct rte_eth_dev *dev) +{ + struct ixgbe_l2_tn_info *l2_tn_info = + IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private); + struct ixgbe_l2_tn_filter *node; + struct rte_eth_l2_tunnel_conf l2_tn_conf; + + TAILQ_FOREACH(node, &l2_tn_info->l2_tn_list, entries) { + l2_tn_conf.l2_tunnel_type = node->key.l2_tn_type; + l2_tn_conf.tunnel_id = node->key.tn_id; + l2_tn_conf.pool = node->pool; + (void)ixgbe_dev_l2_tunnel_filter_add(dev, &l2_tn_conf, TRUE); + } +} + static int ixgbe_filter_restore(struct rte_eth_dev *dev) { @@ -7969,6 +7991,7 @@ ixgbe_filter_restore(struct rte_eth_dev *dev) ixgbe_ethertype_filter_restore(dev); ixgbe_syn_filter_restore(dev); ixgbe_fdir_filter_restore(dev); + ixgbe_l2_tn_filter_restore(dev); return 0; } -- 2.5.5