[dpdk-dev,1/4] ixgbe: support UDP tunnel add/del

Message ID 1452496044-17524-2-git-send-email-wenzhuo.lu@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Wenzhuo Lu Jan. 11, 2016, 7:07 a.m. UTC
  Add UDP tunnel add/del support on ixgbe. Now it only support
VxLAN port configuration.
Although the VxLAN port has a default value 4789, it can be
changed. We support VxLAN port configuration to meet the
change.
Note, the default value of VxLAN port in ixgbe NICs is 0. So
please set it when using VxLAN off-load.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 93 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)
  

Comments

Vincent Jardin Jan. 11, 2016, 7:40 a.m. UTC | #1
see inline

Le 11 janv. 2016 08:08, "Wenzhuo Lu" <wenzhuo.lu@intel.com> a écrit :
>
> Add UDP tunnel add/del support on ixgbe. Now it only support
> VxLAN port configuration.
> Although the VxLAN port has a default value 4789, it can be
> changed. We support VxLAN port configuration to meet the
> change.
> Note, the default value of VxLAN port in ixgbe NICs is 0. So
> please set it when using VxLAN off-load.
>
> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 93
++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 93 insertions(+)
>
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 4c4c6df..381cbad 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -337,6 +337,10 @@ static int ixgbe_timesync_read_time(struct
rte_eth_dev *dev,
>                                    struct timespec *timestamp);
>  static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
>                                    const struct timespec *timestamp);
> +static int ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,
> +                                   struct rte_eth_udp_tunnel
*udp_tunnel);
> +static int ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,
> +                                   struct rte_eth_udp_tunnel
*udp_tunnel);
>
>  /*
>   * Define VF Stats MACRO for Non "cleared on read" register
> @@ -495,6 +499,8 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
>         .timesync_adjust_time = ixgbe_timesync_adjust_time,
>         .timesync_read_time   = ixgbe_timesync_read_time,
>         .timesync_write_time  = ixgbe_timesync_write_time,
> +       .udp_tunnel_add       = ixgbe_dev_udp_tunnel_add,
> +       .udp_tunnel_del       = ixgbe_dev_udp_tunnel_del,
>  };
>

Your patch is not adding HW tunnel support but port management.

>  /*
> @@ -6191,6 +6197,93 @@ ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
>         return 0;
>  }
>
> +#define DEFAULT_VXLAN_PORT 4789
> +
> +/* on x550, there's only one register for VxLAN UDP port.
> + * So, we cannot add or del the port. We only update it.
> + */
> +static int
> +ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
> +                       uint16_t port)
> +{
> +       IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
> +       IXGBE_WRITE_FLUSH(hw);
> +
> +       return 0;
> +}
> +
> +/* Add UDP tunneling port */
> +static int
> +ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,
> +                        struct rte_eth_udp_tunnel *udp_tunnel)
> +{
> +       int ret = 0;
> +       struct ixgbe_hw *hw =
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +
> +       if (hw->mac.type != ixgbe_mac_X550 &&
> +           hw->mac.type != ixgbe_mac_X550EM_x) {
> +               return -ENOTSUP;
> +       }
> +
> +       if (udp_tunnel == NULL)
> +               return -EINVAL;
> +
> +       switch (udp_tunnel->prot_type) {
> +       case RTE_TUNNEL_TYPE_VXLAN:
> +               /* cannot add a port, update the port value */
> +               ret = ixgbe_update_vxlan_port(hw, udp_tunnel->udp_port);
> +               break;
> +
> +       case RTE_TUNNEL_TYPE_GENEVE:
> +       case RTE_TUNNEL_TYPE_TEREDO:
> +               PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
> +               ret = -1;
> +               break;
> +
> +       default:
> +               PMD_DRV_LOG(ERR, "Invalid tunnel type");
> +               ret = -1;
> +               break;
> +       }
> +
> +       return ret;
> +}

Is tunnel_add a proper naming? We need to keep flexibility for NICs that
will support full HW tunneling support.

Here it is about setting registers.

> +
> +/* Remove UDP tunneling port */
> +static int
> +ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,
> +                        struct rte_eth_udp_tunnel *udp_tunnel)
> +{
> +       int ret = 0;
> +       struct ixgbe_hw *hw =
IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +
> +       if (hw->mac.type != ixgbe_mac_X550 &&
> +           hw->mac.type != ixgbe_mac_X550EM_x) {
> +               return -ENOTSUP;
> +       }
> +
> +       if (udp_tunnel == NULL)
> +               return -EINVAL;
> +
> +       switch (udp_tunnel->prot_type) {
> +       case RTE_TUNNEL_TYPE_VXLAN:
> +               /* cannot del the port, reset it to default */
> +               ret = ixgbe_update_vxlan_port(hw, DEFAULT_VXLAN_PORT);
> +               break;
> +       case RTE_TUNNEL_TYPE_GENEVE:
> +       case RTE_TUNNEL_TYPE_TEREDO:
> +               PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
> +               ret = -1;
> +               break;
> +       default:
> +               PMD_DRV_LOG(ERR, "Invalid tunnel type");
> +               ret = -1;
> +               break;
> +       }
> +
> +       return ret;
> +}
> +
>  static struct rte_driver rte_ixgbe_driver = {
>         .type = PMD_PDEV,
>         .init = rte_ixgbe_pmd_init,
> --
> 1.9.3
>

I think the semantic of this serie should be revisited. It is about adding
the support of inner/outer checksum for encapsulated packets but not the
support of HW encap/decap (tunnel?).

Thank you,
  Vincent
  
Wenzhuo Lu Jan. 11, 2016, 8:28 a.m. UTC | #2
Hi Vincent,

From: Vincent JARDIN [mailto:vincent.jardin@6wind.com]

Sent: Monday, January 11, 2016 3:41 PM
To: Lu, Wenzhuo <wenzhuo.lu@intel.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 1/4] ixgbe: support UDP tunnel add/del


see inline

Le 11 janv. 2016 08:08, "Wenzhuo Lu" <wenzhuo.lu@intel.com<mailto:wenzhuo.lu@intel.com>> a écrit :
>

> Add UDP tunnel add/del support on ixgbe. Now it only support

> VxLAN port configuration.

> Although the VxLAN port has a default value 4789, it can be

> changed. We support VxLAN port configuration to meet the

> change.

> Note, the default value of VxLAN port in ixgbe NICs is 0. So

> please set it when using VxLAN off-load.

>

> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com<mailto:wenzhuo.lu@intel.com>>

> ---

>  drivers/net/ixgbe/ixgbe_ethdev.c | 93 ++++++++++++++++++++++++++++++++++++++++

>  1 file changed, 93 insertions(+)

>

> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c

> index 4c4c6df..381cbad 100644

> --- a/drivers/net/ixgbe/ixgbe_ethdev.c

> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c

> @@ -337,6 +337,10 @@ static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,

>                                    struct timespec *timestamp);

>  static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,

>                                    const struct timespec *timestamp);

> +static int ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,

> +                                   struct rte_eth_udp_tunnel *udp_tunnel);

> +static int ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,

> +                                   struct rte_eth_udp_tunnel *udp_tunnel);

>

>  /*

>   * Define VF Stats MACRO for Non "cleared on read" register

> @@ -495,6 +499,8 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {

>         .timesync_adjust_time = ixgbe_timesync_adjust_time,

>         .timesync_read_time   = ixgbe_timesync_read_time,

>         .timesync_write_time  = ixgbe_timesync_write_time,

> +       .udp_tunnel_add       = ixgbe_dev_udp_tunnel_add,

> +       .udp_tunnel_del       = ixgbe_dev_udp_tunnel_del,

>  };

>


Your patch is not adding HW tunnel support but port management.

>  /*

> @@ -6191,6 +6197,93 @@ ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,

>         return 0;

>  }

>

> +#define DEFAULT_VXLAN_PORT 4789

> +

> +/* on x550, there's only one register for VxLAN UDP port.

> + * So, we cannot add or del the port. We only update it.

> + */

> +static int

> +ixgbe_update_vxlan_port(struct ixgbe_hw *hw,

> +                       uint16_t port)

> +{

> +       IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);

> +       IXGBE_WRITE_FLUSH(hw);

> +

> +       return 0;

> +}

> +

> +/* Add UDP tunneling port */

> +static int

> +ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,

> +                        struct rte_eth_udp_tunnel *udp_tunnel)

> +{

> +       int ret = 0;

> +       struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);

> +

> +       if (hw->mac.type != ixgbe_mac_X550 &&

> +           hw->mac.type != ixgbe_mac_X550EM_x) {

> +               return -ENOTSUP;

> +       }

> +

> +       if (udp_tunnel == NULL)

> +               return -EINVAL;

> +

> +       switch (udp_tunnel->prot_type) {

> +       case RTE_TUNNEL_TYPE_VXLAN:

> +               /* cannot add a port, update the port value */

> +               ret = ixgbe_update_vxlan_port(hw, udp_tunnel->udp_port);

> +               break;

> +

> +       case RTE_TUNNEL_TYPE_GENEVE:

> +       case RTE_TUNNEL_TYPE_TEREDO:

> +               PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");

> +               ret = -1;

> +               break;

> +

> +       default:

> +               PMD_DRV_LOG(ERR, "Invalid tunnel type");

> +               ret = -1;

> +               break;

> +       }

> +

> +       return ret;

> +}


Is tunnel_add a proper naming? We need to keep flexibility for NICs that will support full HW tunneling support.

Here it is about setting registers.

> +

> +/* Remove UDP tunneling port */

> +static int

> +ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,

> +                        struct rte_eth_udp_tunnel *udp_tunnel)

> +{

> +       int ret = 0;

> +       struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);

> +

> +       if (hw->mac.type != ixgbe_mac_X550 &&

> +           hw->mac.type != ixgbe_mac_X550EM_x) {

> +               return -ENOTSUP;

> +       }

> +

> +       if (udp_tunnel == NULL)

> +               return -EINVAL;

> +

> +       switch (udp_tunnel->prot_type) {

> +       case RTE_TUNNEL_TYPE_VXLAN:

> +               /* cannot del the port, reset it to default */

> +               ret = ixgbe_update_vxlan_port(hw, DEFAULT_VXLAN_PORT);

> +               break;

> +       case RTE_TUNNEL_TYPE_GENEVE:

> +       case RTE_TUNNEL_TYPE_TEREDO:

> +               PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");

> +               ret = -1;

> +               break;

> +       default:

> +               PMD_DRV_LOG(ERR, "Invalid tunnel type");

> +               ret = -1;

> +               break;

> +       }

> +

> +       return ret;

> +}

> +

>  static struct rte_driver rte_ixgbe_driver = {

>         .type = PMD_PDEV,

>         .init = rte_ixgbe_pmd_init,

> --

> 1.9.3

>


I think the semantic of this serie should be revisited. It is about adding the support of inner/outer checksum for encapsulated packets but not the support of HW encap/decap (tunnel?).

[Wenzhuo] The udp_tunnel_add and udp_tunnel_del have already existed. I just use them. Honestly I agree with you they are not accurate name. Better change them to udp_tunnel_port_add and udp_tunnel_port_del. But it should be a ABI change if I’m not wrong. I think we can announce it this release and change them in the next release. Would you agree?  Thanks.

Thank you,
  Vincent
  
Vincent Jardin Jan. 11, 2016, 8:41 a.m. UTC | #3
> [Wenzhuo] The udp_tunnel_add and udp_tunnel_del have already existed. I
just use them. Honestly I agree with you they are not accurate name. Better
change them to udp_tunnel_port_add and udp_tunnel_port_del. But it should
be a ABI change if I’m not wrong. I think we can announce it this release
and change them in the next release. Would you agree?  Thanks.

Yes you are right.
  
Thomas Monjalon Jan. 12, 2016, 12:37 p.m. UTC | #4
Hi,

2016-01-11 08:28, Lu, Wenzhuo:
> [Wenzhuo] The udp_tunnel_add and udp_tunnel_del have already existed. I just use them. Honestly I agree with you they are not accurate name. Better change them to udp_tunnel_port_add and udp_tunnel_port_del. But it should be a ABI change if I’m not wrong. I think we can announce it this release and change them in the next release. Would you agree?  Thanks.

You can introduce the new name and keep the old one for backward compat
while announcing its deprecation.
Thanks
  
Wenzhuo Lu Jan. 13, 2016, 2:50 a.m. UTC | #5
Hi Thomas,

> -----Original Message-----

> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]

> Sent: Tuesday, January 12, 2016 8:37 PM

> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>

> Cc: dev@dpdk.org; Vincent JARDIN <vincent.jardin@6wind.com>

> Subject: Re: [dpdk-dev] [PATCH 1/4] ixgbe: support UDP tunnel add/del

> 

> Hi,

> 

> 2016-01-11 08:28, Lu, Wenzhuo:

> > [Wenzhuo] The udp_tunnel_add and udp_tunnel_del have already existed.

> I just use them. Honestly I agree with you they are not accurate name. Better

> change them to udp_tunnel_port_add and udp_tunnel_port_del. But it

> should be a ABI change if I’m not wrong. I think we can announce it this

> release and change them in the next release. Would you agree?  Thanks.

> 

> You can introduce the new name and keep the old one for backward compat

> while announcing its deprecation.

Good suggestion, I'll send a new patch set for this change. Thanks.

> Thanks
  
Michael Qiu March 3, 2016, 6:57 a.m. UTC | #6
On 1/11/2016 3:08 PM, Wenzhuo Lu wrote:
> Add UDP tunnel add/del support on ixgbe. Now it only support
> VxLAN port configuration.
> Although the VxLAN port has a default value 4789, it can be
> changed. We support VxLAN port configuration to meet the
> change.
> Note, the default value of VxLAN port in ixgbe NICs is 0. So
> please set it when using VxLAN off-load.
>
> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 93 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 93 insertions(+)
>
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 4c4c6df..381cbad 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -337,6 +337,10 @@ static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
>  				   struct timespec *timestamp);
>  static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
>  				   const struct timespec *timestamp);
> +static int ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,
> +				    struct rte_eth_udp_tunnel *udp_tunnel);
> +static int ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,
> +				    struct rte_eth_udp_tunnel *udp_tunnel);
>  
>  /*
>   * Define VF Stats MACRO for Non "cleared on read" register
> @@ -495,6 +499,8 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
>  	.timesync_adjust_time = ixgbe_timesync_adjust_time,
>  	.timesync_read_time   = ixgbe_timesync_read_time,
>  	.timesync_write_time  = ixgbe_timesync_write_time,
> +	.udp_tunnel_add       = ixgbe_dev_udp_tunnel_add,
> +	.udp_tunnel_del       = ixgbe_dev_udp_tunnel_del,
>  };
>  
>  /*
> @@ -6191,6 +6197,93 @@ ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
>  	return 0;
>  }
>  
> +#define DEFAULT_VXLAN_PORT 4789
> +
> +/* on x550, there's only one register for VxLAN UDP port.
> + * So, we cannot add or del the port. We only update it.
> + */
> +static int
> +ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
> +			uint16_t port)
> +{
> +	IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
> +	IXGBE_WRITE_FLUSH(hw);
> +
> +	return 0;
> +}
> +
> +/* Add UDP tunneling port */
> +static int
> +ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,
> +			 struct rte_eth_udp_tunnel *udp_tunnel)
> +{
> +	int ret = 0;
> +	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +
> +	if (hw->mac.type != ixgbe_mac_X550 &&
> +	    hw->mac.type != ixgbe_mac_X550EM_x) {
> +		return -ENOTSUP;
> +	}
> +
> +	if (udp_tunnel == NULL)
> +		return -EINVAL;
> +
> +	switch (udp_tunnel->prot_type) {
> +	case RTE_TUNNEL_TYPE_VXLAN:
> +		/* cannot add a port, update the port value */
> +		ret = ixgbe_update_vxlan_port(hw, udp_tunnel->udp_port);
> +		break;
> +
> +	case RTE_TUNNEL_TYPE_GENEVE:
> +	case RTE_TUNNEL_TYPE_TEREDO:
> +		PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
> +		ret = -1;
> +		break;
> +
> +	default:
> +		PMD_DRV_LOG(ERR, "Invalid tunnel type");
> +		ret = -1;
> +		break;
> +	}
> +
> +	return ret;
> +}
> +
> +/* Remove UDP tunneling port */
> +static int
> +ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,
> +			 struct rte_eth_udp_tunnel *udp_tunnel)
> +{
> +	int ret = 0;
> +	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +
> +	if (hw->mac.type != ixgbe_mac_X550 &&
> +	    hw->mac.type != ixgbe_mac_X550EM_x) {
> +		return -ENOTSUP;
> +	}
> +
> +	if (udp_tunnel == NULL)
> +		return -EINVAL;
> +
> +	switch (udp_tunnel->prot_type) {
> +	case RTE_TUNNEL_TYPE_VXLAN:
> +		/* cannot del the port, reset it to default */
> +		ret = ixgbe_update_vxlan_port(hw, DEFAULT_VXLAN_PORT);
> +		break;
> +	case RTE_TUNNEL_TYPE_GENEVE:
> +	case RTE_TUNNEL_TYPE_TEREDO:
> +		PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
> +		ret = -1;

Better to use the -EINVAL or other, mixed style always not good.

Thanks,
Michael
> +		break;
> +	default:
> +		PMD_DRV_LOG(ERR, "Invalid tunnel type");
> +		ret = -1;
> +		break;
> +	}
> +
> +	return ret;
> +}
> +
>  static struct rte_driver rte_ixgbe_driver = {
>  	.type = PMD_PDEV,
>  	.init = rte_ixgbe_pmd_init,
  
Wenzhuo Lu March 3, 2016, 7:14 a.m. UTC | #7
Hi Michael,

> -----Original Message-----
> From: Qiu, Michael
> Sent: Thursday, March 3, 2016 2:58 PM
> To: Lu, Wenzhuo; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 1/4] ixgbe: support UDP tunnel add/del
> 
> On 1/11/2016 3:08 PM, Wenzhuo Lu wrote:
> > Add UDP tunnel add/del support on ixgbe. Now it only support VxLAN
> > port configuration.
> > Although the VxLAN port has a default value 4789, it can be changed.
> > We support VxLAN port configuration to meet the change.
> > Note, the default value of VxLAN port in ixgbe NICs is 0. So please
> > set it when using VxLAN off-load.
> >
> > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> > ---
> >  drivers/net/ixgbe/ixgbe_ethdev.c | 93
> > ++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 93 insertions(+)
> >
> > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
> > b/drivers/net/ixgbe/ixgbe_ethdev.c
> > index 4c4c6df..381cbad 100644
> > --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> > @@ -337,6 +337,10 @@ static int ixgbe_timesync_read_time(struct
> rte_eth_dev *dev,
> >  				   struct timespec *timestamp);
> >  static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
> >  				   const struct timespec *timestamp);
> > +static int ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,
> > +				    struct rte_eth_udp_tunnel *udp_tunnel);
> static int
> > +ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,
> > +				    struct rte_eth_udp_tunnel *udp_tunnel);
> >
> >  /*
> >   * Define VF Stats MACRO for Non "cleared on read" register @@ -495,6
> > +499,8 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
> >  	.timesync_adjust_time = ixgbe_timesync_adjust_time,
> >  	.timesync_read_time   = ixgbe_timesync_read_time,
> >  	.timesync_write_time  = ixgbe_timesync_write_time,
> > +	.udp_tunnel_add       = ixgbe_dev_udp_tunnel_add,
> > +	.udp_tunnel_del       = ixgbe_dev_udp_tunnel_del,
> >  };
> >
> >  /*
> > @@ -6191,6 +6197,93 @@ ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
> >  	return 0;
> >  }
> >
> > +#define DEFAULT_VXLAN_PORT 4789
> > +
> > +/* on x550, there's only one register for VxLAN UDP port.
> > + * So, we cannot add or del the port. We only update it.
> > + */
> > +static int
> > +ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
> > +			uint16_t port)
> > +{
> > +	IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
> > +	IXGBE_WRITE_FLUSH(hw);
> > +
> > +	return 0;
> > +}
> > +
> > +/* Add UDP tunneling port */
> > +static int
> > +ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,
> > +			 struct rte_eth_udp_tunnel *udp_tunnel) {
> > +	int ret = 0;
> > +	struct ixgbe_hw *hw =
> > +IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> > +
> > +	if (hw->mac.type != ixgbe_mac_X550 &&
> > +	    hw->mac.type != ixgbe_mac_X550EM_x) {
> > +		return -ENOTSUP;
> > +	}
> > +
> > +	if (udp_tunnel == NULL)
> > +		return -EINVAL;
> > +
> > +	switch (udp_tunnel->prot_type) {
> > +	case RTE_TUNNEL_TYPE_VXLAN:
> > +		/* cannot add a port, update the port value */
> > +		ret = ixgbe_update_vxlan_port(hw, udp_tunnel->udp_port);
> > +		break;
> > +
> > +	case RTE_TUNNEL_TYPE_GENEVE:
> > +	case RTE_TUNNEL_TYPE_TEREDO:
> > +		PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
> > +		ret = -1;
> > +		break;
> > +
> > +	default:
> > +		PMD_DRV_LOG(ERR, "Invalid tunnel type");
> > +		ret = -1;
> > +		break;
> > +	}
> > +
> > +	return ret;
> > +}
> > +
> > +/* Remove UDP tunneling port */
> > +static int
> > +ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,
> > +			 struct rte_eth_udp_tunnel *udp_tunnel) {
> > +	int ret = 0;
> > +	struct ixgbe_hw *hw =
> > +IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> > +
> > +	if (hw->mac.type != ixgbe_mac_X550 &&
> > +	    hw->mac.type != ixgbe_mac_X550EM_x) {
> > +		return -ENOTSUP;
> > +	}
> > +
> > +	if (udp_tunnel == NULL)
> > +		return -EINVAL;
> > +
> > +	switch (udp_tunnel->prot_type) {
> > +	case RTE_TUNNEL_TYPE_VXLAN:
> > +		/* cannot del the port, reset it to default */
> > +		ret = ixgbe_update_vxlan_port(hw, DEFAULT_VXLAN_PORT);
> > +		break;
> > +	case RTE_TUNNEL_TYPE_GENEVE:
> > +	case RTE_TUNNEL_TYPE_TEREDO:
> > +		PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
> > +		ret = -1;
> 
> Better to use the -EINVAL or other, mixed style always not good.
Good suggestion, thanks. I'll change it.

> 
> Thanks,
> Michael
> > +		break;
> > +	default:
> > +		PMD_DRV_LOG(ERR, "Invalid tunnel type");
> > +		ret = -1;
> > +		break;
> > +	}
> > +
> > +	return ret;
> > +}
> > +
> >  static struct rte_driver rte_ixgbe_driver = {
> >  	.type = PMD_PDEV,
> >  	.init = rte_ixgbe_pmd_init,
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 4c4c6df..381cbad 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -337,6 +337,10 @@  static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
 				   struct timespec *timestamp);
 static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
 				   const struct timespec *timestamp);
+static int ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,
+				    struct rte_eth_udp_tunnel *udp_tunnel);
+static int ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,
+				    struct rte_eth_udp_tunnel *udp_tunnel);
 
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
@@ -495,6 +499,8 @@  static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.timesync_adjust_time = ixgbe_timesync_adjust_time,
 	.timesync_read_time   = ixgbe_timesync_read_time,
 	.timesync_write_time  = ixgbe_timesync_write_time,
+	.udp_tunnel_add       = ixgbe_dev_udp_tunnel_add,
+	.udp_tunnel_del       = ixgbe_dev_udp_tunnel_del,
 };
 
 /*
@@ -6191,6 +6197,93 @@  ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
 	return 0;
 }
 
+#define DEFAULT_VXLAN_PORT 4789
+
+/* on x550, there's only one register for VxLAN UDP port.
+ * So, we cannot add or del the port. We only update it.
+ */
+static int
+ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
+			uint16_t port)
+{
+	IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
+	IXGBE_WRITE_FLUSH(hw);
+
+	return 0;
+}
+
+/* Add UDP tunneling port */
+static int
+ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,
+			 struct rte_eth_udp_tunnel *udp_tunnel)
+{
+	int ret = 0;
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (hw->mac.type != ixgbe_mac_X550 &&
+	    hw->mac.type != ixgbe_mac_X550EM_x) {
+		return -ENOTSUP;
+	}
+
+	if (udp_tunnel == NULL)
+		return -EINVAL;
+
+	switch (udp_tunnel->prot_type) {
+	case RTE_TUNNEL_TYPE_VXLAN:
+		/* cannot add a port, update the port value */
+		ret = ixgbe_update_vxlan_port(hw, udp_tunnel->udp_port);
+		break;
+
+	case RTE_TUNNEL_TYPE_GENEVE:
+	case RTE_TUNNEL_TYPE_TEREDO:
+		PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
+		ret = -1;
+		break;
+
+	default:
+		PMD_DRV_LOG(ERR, "Invalid tunnel type");
+		ret = -1;
+		break;
+	}
+
+	return ret;
+}
+
+/* Remove UDP tunneling port */
+static int
+ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,
+			 struct rte_eth_udp_tunnel *udp_tunnel)
+{
+	int ret = 0;
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (hw->mac.type != ixgbe_mac_X550 &&
+	    hw->mac.type != ixgbe_mac_X550EM_x) {
+		return -ENOTSUP;
+	}
+
+	if (udp_tunnel == NULL)
+		return -EINVAL;
+
+	switch (udp_tunnel->prot_type) {
+	case RTE_TUNNEL_TYPE_VXLAN:
+		/* cannot del the port, reset it to default */
+		ret = ixgbe_update_vxlan_port(hw, DEFAULT_VXLAN_PORT);
+		break;
+	case RTE_TUNNEL_TYPE_GENEVE:
+	case RTE_TUNNEL_TYPE_TEREDO:
+		PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
+		ret = -1;
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Invalid tunnel type");
+		ret = -1;
+		break;
+	}
+
+	return ret;
+}
+
 static struct rte_driver rte_ixgbe_driver = {
 	.type = PMD_PDEV,
 	.init = rte_ixgbe_pmd_init,