From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 010D92BA2 for ; Thu, 3 Mar 2016 07:57:53 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 02 Mar 2016 22:57:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,531,1449561600"; d="scan'208";a="757230984" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga003.jf.intel.com with ESMTP; 02 Mar 2016 22:57:51 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 2 Mar 2016 22:57:51 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.136]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.18]) with mapi id 14.03.0248.002; Thu, 3 Mar 2016 14:57:49 +0800 From: "Qiu, Michael" To: "Lu, Wenzhuo" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 1/4] ixgbe: support UDP tunnel add/del Thread-Index: AQHRTD7ifLvB848AeE2BZ9FZBOhcEA== Date: Thu, 3 Mar 2016 06:57:48 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E6028622F5BD7A@SHSMSX101.ccr.corp.intel.com> References: <1452496044-17524-1-git-send-email-wenzhuo.lu@intel.com> <1452496044-17524-2-git-send-email-wenzhuo.lu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 1/4] ixgbe: support UDP tunnel add/del X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2016 06:57:54 -0000 On 1/11/2016 3:08 PM, Wenzhuo Lu wrote:=0A= > Add UDP tunnel add/del support on ixgbe. Now it only support=0A= > VxLAN port configuration.=0A= > Although the VxLAN port has a default value 4789, it can be=0A= > changed. We support VxLAN port configuration to meet the=0A= > change.=0A= > Note, the default value of VxLAN port in ixgbe NICs is 0. So=0A= > please set it when using VxLAN off-load.=0A= >=0A= > Signed-off-by: Wenzhuo Lu =0A= > ---=0A= > drivers/net/ixgbe/ixgbe_ethdev.c | 93 ++++++++++++++++++++++++++++++++++= ++++++=0A= > 1 file changed, 93 insertions(+)=0A= >=0A= > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_e= thdev.c=0A= > index 4c4c6df..381cbad 100644=0A= > --- a/drivers/net/ixgbe/ixgbe_ethdev.c=0A= > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c=0A= > @@ -337,6 +337,10 @@ static int ixgbe_timesync_read_time(struct rte_eth_d= ev *dev,=0A= > struct timespec *timestamp);=0A= > static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,=0A= > const struct timespec *timestamp);=0A= > +static int ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,=0A= > + struct rte_eth_udp_tunnel *udp_tunnel);=0A= > +static int ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,=0A= > + struct rte_eth_udp_tunnel *udp_tunnel);=0A= > =0A= > /*=0A= > * Define VF Stats MACRO for Non "cleared on read" register=0A= > @@ -495,6 +499,8 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops =3D= {=0A= > .timesync_adjust_time =3D ixgbe_timesync_adjust_time,=0A= > .timesync_read_time =3D ixgbe_timesync_read_time,=0A= > .timesync_write_time =3D ixgbe_timesync_write_time,=0A= > + .udp_tunnel_add =3D ixgbe_dev_udp_tunnel_add,=0A= > + .udp_tunnel_del =3D ixgbe_dev_udp_tunnel_del,=0A= > };=0A= > =0A= > /*=0A= > @@ -6191,6 +6197,93 @@ ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,=0A= > return 0;=0A= > }=0A= > =0A= > +#define DEFAULT_VXLAN_PORT 4789=0A= > +=0A= > +/* on x550, there's only one register for VxLAN UDP port.=0A= > + * So, we cannot add or del the port. We only update it.=0A= > + */=0A= > +static int=0A= > +ixgbe_update_vxlan_port(struct ixgbe_hw *hw,=0A= > + uint16_t port)=0A= > +{=0A= > + IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);=0A= > + IXGBE_WRITE_FLUSH(hw);=0A= > +=0A= > + return 0;=0A= > +}=0A= > +=0A= > +/* Add UDP tunneling port */=0A= > +static int=0A= > +ixgbe_dev_udp_tunnel_add(struct rte_eth_dev *dev,=0A= > + struct rte_eth_udp_tunnel *udp_tunnel)=0A= > +{=0A= > + int ret =3D 0;=0A= > + struct ixgbe_hw *hw =3D IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private)= ;=0A= > +=0A= > + if (hw->mac.type !=3D ixgbe_mac_X550 &&=0A= > + hw->mac.type !=3D ixgbe_mac_X550EM_x) {=0A= > + return -ENOTSUP;=0A= > + }=0A= > +=0A= > + if (udp_tunnel =3D=3D NULL)=0A= > + return -EINVAL;=0A= > +=0A= > + switch (udp_tunnel->prot_type) {=0A= > + case RTE_TUNNEL_TYPE_VXLAN:=0A= > + /* cannot add a port, update the port value */=0A= > + ret =3D ixgbe_update_vxlan_port(hw, udp_tunnel->udp_port);=0A= > + break;=0A= > +=0A= > + case RTE_TUNNEL_TYPE_GENEVE:=0A= > + case RTE_TUNNEL_TYPE_TEREDO:=0A= > + PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");=0A= > + ret =3D -1;=0A= > + break;=0A= > +=0A= > + default:=0A= > + PMD_DRV_LOG(ERR, "Invalid tunnel type");=0A= > + ret =3D -1;=0A= > + break;=0A= > + }=0A= > +=0A= > + return ret;=0A= > +}=0A= > +=0A= > +/* Remove UDP tunneling port */=0A= > +static int=0A= > +ixgbe_dev_udp_tunnel_del(struct rte_eth_dev *dev,=0A= > + struct rte_eth_udp_tunnel *udp_tunnel)=0A= > +{=0A= > + int ret =3D 0;=0A= > + struct ixgbe_hw *hw =3D IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private)= ;=0A= > +=0A= > + if (hw->mac.type !=3D ixgbe_mac_X550 &&=0A= > + hw->mac.type !=3D ixgbe_mac_X550EM_x) {=0A= > + return -ENOTSUP;=0A= > + }=0A= > +=0A= > + if (udp_tunnel =3D=3D NULL)=0A= > + return -EINVAL;=0A= > +=0A= > + switch (udp_tunnel->prot_type) {=0A= > + case RTE_TUNNEL_TYPE_VXLAN:=0A= > + /* cannot del the port, reset it to default */=0A= > + ret =3D ixgbe_update_vxlan_port(hw, DEFAULT_VXLAN_PORT);=0A= > + break;=0A= > + case RTE_TUNNEL_TYPE_GENEVE:=0A= > + case RTE_TUNNEL_TYPE_TEREDO:=0A= > + PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");=0A= > + ret =3D -1;=0A= =0A= Better to use the -EINVAL or other, mixed style always not good.=0A= =0A= Thanks,=0A= Michael=0A= > + break;=0A= > + default:=0A= > + PMD_DRV_LOG(ERR, "Invalid tunnel type");=0A= > + ret =3D -1;=0A= > + break;=0A= > + }=0A= > +=0A= > + return ret;=0A= > +}=0A= > +=0A= > static struct rte_driver rte_ixgbe_driver =3D {=0A= > .type =3D PMD_PDEV,=0A= > .init =3D rte_ixgbe_pmd_init,=0A= =0A=