[dpdk-dev,v2,09/18] net/ixgbe: store and restore L2 tunnel configuration

Message ID 1483084390-53159-10-git-send-email-wei.zhao1@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation fail Compilation issues

Commit Message

Zhao1, Wei Dec. 30, 2016, 7:53 a.m. UTC
  Add support for store and restore L2 tunnel filter in SW.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 36 ++++++++++++++++++++++++++++++++++++
 drivers/net/ixgbe/ixgbe_ethdev.h |  3 +++
 2 files changed, 39 insertions(+)
  

Comments

Xing, Beilei Jan. 2, 2017, 10:18 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wei Zhao
> Sent: Friday, December 30, 2016 3:53 PM
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Zhao1, Wei <wei.zhao1@intel.com>
> Subject: [dpdk-dev] [PATCH v2 09/18] net/ixgbe: store and restore L2 tunnel
> configuration
> 
> Add support for store and restore L2 tunnel filter in SW.

The whole patch set is related to filter, so do you think it's better to move the patch from his patch set since it's related to configuration? Please help to check.

> 
> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 36
> ++++++++++++++++++++++++++++++++++++
>  drivers/net/ixgbe/ixgbe_ethdev.h |  3 +++
>  2 files changed, 39 insertions(+)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
> b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 5c39ffa..d68de65 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -385,6 +385,7 @@ static int ixgbe_dev_udp_tunnel_port_add(struct
> rte_eth_dev *dev,  static int ixgbe_dev_udp_tunnel_port_del(struct
> rte_eth_dev *dev,
>  					 struct rte_eth_udp_tunnel *udp_tunnel);  static int
> ixgbe_filter_restore(struct rte_eth_dev *dev);
> +static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
> 
>  /*
>   * Define VF Stats MACRO for Non "cleared on read" register @@ -1444,6
> +1445,9 @@ static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
>  			"Failed to allocate memory for L2 TN hash map!");
>  		return -ENOMEM;
>  	}
> +	l2_tn_info->e_tag_en = FALSE;
> +	l2_tn_info->e_tag_fwd_en = FALSE;
> +	l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE;
> 
>  	return 0;
>  }
> @@ -2502,6 +2506,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
> 
>  	/* resume enabled intr since hw reset */
>  	ixgbe_enable_intr(dev);
> +	ixgbe_l2_tunnel_conf(dev);
>  	ixgbe_filter_restore(dev);
> 
>  	return 0;
> @@ -7038,12 +7043,15 @@ ixgbe_dev_l2_tunnel_eth_type_conf(struct
> rte_eth_dev *dev,  {
>  	int ret = 0;
>  	struct ixgbe_hw *hw =
> IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	struct ixgbe_l2_tn_info *l2_tn_info =
> +		IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
> 
>  	if (l2_tunnel == NULL)
>  		return -EINVAL;
> 
>  	switch (l2_tunnel->l2_tunnel_type) {
>  	case RTE_L2_TUNNEL_TYPE_E_TAG:
> +		l2_tn_info->e_tag_ether_type = l2_tunnel->ether_type;
>  		ret = ixgbe_update_e_tag_eth_type(hw, l2_tunnel->ether_type);
>  		break;
>  	default:
> @@ -7082,9 +7090,12 @@ ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev
> *dev,  {
>  	int ret = 0;
>  	struct ixgbe_hw *hw =
> IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	struct ixgbe_l2_tn_info *l2_tn_info =
> +		IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
> 
>  	switch (l2_tunnel_type) {
>  	case RTE_L2_TUNNEL_TYPE_E_TAG:
> +		l2_tn_info->e_tag_en = TRUE;
>  		ret = ixgbe_e_tag_enable(hw);
>  		break;
>  	default:
> @@ -7123,9 +7134,12 @@ ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev
> *dev,  {
>  	int ret = 0;
>  	struct ixgbe_hw *hw =
> IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	struct ixgbe_l2_tn_info *l2_tn_info =
> +		IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
> 
>  	switch (l2_tunnel_type) {
>  	case RTE_L2_TUNNEL_TYPE_E_TAG:
> +		l2_tn_info->e_tag_en = FALSE;
>  		ret = ixgbe_e_tag_disable(hw);
>  		break;
>  	default:
> @@ -7432,10 +7446,13 @@ ixgbe_dev_l2_tunnel_forwarding_enable
>  	(struct rte_eth_dev *dev,
>  	 enum rte_eth_tunnel_type l2_tunnel_type)  {
> +	struct ixgbe_l2_tn_info *l2_tn_info =
> +		IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
>  	int ret = 0;
> 
>  	switch (l2_tunnel_type) {
>  	case RTE_L2_TUNNEL_TYPE_E_TAG:
> +		l2_tn_info->e_tag_fwd_en = TRUE;
>  		ret = ixgbe_e_tag_forwarding_en_dis(dev, 1);
>  		break;
>  	default:
> @@ -7453,10 +7470,13 @@ ixgbe_dev_l2_tunnel_forwarding_disable
>  	(struct rte_eth_dev *dev,
>  	 enum rte_eth_tunnel_type l2_tunnel_type)  {
> +	struct ixgbe_l2_tn_info *l2_tn_info =
> +		IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
>  	int ret = 0;
> 
>  	switch (l2_tunnel_type) {
>  	case RTE_L2_TUNNEL_TYPE_E_TAG:
> +		l2_tn_info->e_tag_fwd_en = FALSE;
>  		ret = ixgbe_e_tag_forwarding_en_dis(dev, 0);
>  		break;
>  	default:
> @@ -7950,6 +7970,22 @@ ixgbe_filter_restore(struct rte_eth_dev *dev)
>  	return 0;
>  }
> 
> +static void
> +ixgbe_l2_tunnel_conf(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_hw *hw =
> IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +
> +	if (l2_tn_info->e_tag_en)
> +		(void)ixgbe_e_tag_enable(hw);
> +
> +	if (l2_tn_info->e_tag_fwd_en)
> +		(void)ixgbe_e_tag_forwarding_en_dis(dev, 1);
> +
> +	(void)ixgbe_update_e_tag_eth_type(hw, l2_tn_info->e_tag_ether_type); }
> +
>  RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd.pci_drv);
> RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
> RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic |
> vfio"); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h
> b/drivers/net/ixgbe/ixgbe_ethdev.h
> index d6253ad..6327962 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.h
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.h
> @@ -307,6 +307,9 @@ struct ixgbe_l2_tn_info {
>  	struct ixgbe_l2_tn_filter_list      l2_tn_list;
>  	struct ixgbe_l2_tn_filter         **hash_map;
>  	struct rte_hash                    *hash_handle;
> +	bool e_tag_en; /* e-tag enabled */
> +	bool e_tag_fwd_en; /* e-tag based forwarding enabled */
> +	bool e_tag_ether_type; /* ether type for e-tag */
>  };
> 
>  /*
> --
> 2.5.5
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 5c39ffa..d68de65 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -385,6 +385,7 @@  static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
 					 struct rte_eth_udp_tunnel *udp_tunnel);
 static int ixgbe_filter_restore(struct rte_eth_dev *dev);
+static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
 
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
@@ -1444,6 +1445,9 @@  static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
 			"Failed to allocate memory for L2 TN hash map!");
 		return -ENOMEM;
 	}
+	l2_tn_info->e_tag_en = FALSE;
+	l2_tn_info->e_tag_fwd_en = FALSE;
+	l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE;
 
 	return 0;
 }
@@ -2502,6 +2506,7 @@  ixgbe_dev_start(struct rte_eth_dev *dev)
 
 	/* resume enabled intr since hw reset */
 	ixgbe_enable_intr(dev);
+	ixgbe_l2_tunnel_conf(dev);
 	ixgbe_filter_restore(dev);
 
 	return 0;
@@ -7038,12 +7043,15 @@  ixgbe_dev_l2_tunnel_eth_type_conf(struct rte_eth_dev *dev,
 {
 	int ret = 0;
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ixgbe_l2_tn_info *l2_tn_info =
+		IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
 
 	if (l2_tunnel == NULL)
 		return -EINVAL;
 
 	switch (l2_tunnel->l2_tunnel_type) {
 	case RTE_L2_TUNNEL_TYPE_E_TAG:
+		l2_tn_info->e_tag_ether_type = l2_tunnel->ether_type;
 		ret = ixgbe_update_e_tag_eth_type(hw, l2_tunnel->ether_type);
 		break;
 	default:
@@ -7082,9 +7090,12 @@  ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev *dev,
 {
 	int ret = 0;
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ixgbe_l2_tn_info *l2_tn_info =
+		IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
 
 	switch (l2_tunnel_type) {
 	case RTE_L2_TUNNEL_TYPE_E_TAG:
+		l2_tn_info->e_tag_en = TRUE;
 		ret = ixgbe_e_tag_enable(hw);
 		break;
 	default:
@@ -7123,9 +7134,12 @@  ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev *dev,
 {
 	int ret = 0;
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ixgbe_l2_tn_info *l2_tn_info =
+		IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
 
 	switch (l2_tunnel_type) {
 	case RTE_L2_TUNNEL_TYPE_E_TAG:
+		l2_tn_info->e_tag_en = FALSE;
 		ret = ixgbe_e_tag_disable(hw);
 		break;
 	default:
@@ -7432,10 +7446,13 @@  ixgbe_dev_l2_tunnel_forwarding_enable
 	(struct rte_eth_dev *dev,
 	 enum rte_eth_tunnel_type l2_tunnel_type)
 {
+	struct ixgbe_l2_tn_info *l2_tn_info =
+		IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
 	int ret = 0;
 
 	switch (l2_tunnel_type) {
 	case RTE_L2_TUNNEL_TYPE_E_TAG:
+		l2_tn_info->e_tag_fwd_en = TRUE;
 		ret = ixgbe_e_tag_forwarding_en_dis(dev, 1);
 		break;
 	default:
@@ -7453,10 +7470,13 @@  ixgbe_dev_l2_tunnel_forwarding_disable
 	(struct rte_eth_dev *dev,
 	 enum rte_eth_tunnel_type l2_tunnel_type)
 {
+	struct ixgbe_l2_tn_info *l2_tn_info =
+		IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
 	int ret = 0;
 
 	switch (l2_tunnel_type) {
 	case RTE_L2_TUNNEL_TYPE_E_TAG:
+		l2_tn_info->e_tag_fwd_en = FALSE;
 		ret = ixgbe_e_tag_forwarding_en_dis(dev, 0);
 		break;
 	default:
@@ -7950,6 +7970,22 @@  ixgbe_filter_restore(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static void
+ixgbe_l2_tunnel_conf(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_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (l2_tn_info->e_tag_en)
+		(void)ixgbe_e_tag_enable(hw);
+
+	if (l2_tn_info->e_tag_fwd_en)
+		(void)ixgbe_e_tag_forwarding_en_dis(dev, 1);
+
+	(void)ixgbe_update_e_tag_eth_type(hw, l2_tn_info->e_tag_ether_type);
+}
+
 RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd.pci_drv);
 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio");
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index d6253ad..6327962 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -307,6 +307,9 @@  struct ixgbe_l2_tn_info {
 	struct ixgbe_l2_tn_filter_list      l2_tn_list;
 	struct ixgbe_l2_tn_filter         **hash_map;
 	struct rte_hash                    *hash_handle;
+	bool e_tag_en; /* e-tag enabled */
+	bool e_tag_fwd_en; /* e-tag based forwarding enabled */
+	bool e_tag_ether_type; /* ether type for e-tag */
 };
 
 /*