From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 7B5081C0B for ; Tue, 22 May 2018 08:33:38 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2018 23:33:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,429,1520924400"; d="scan'208";a="56469522" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga004.fm.intel.com with ESMTP; 21 May 2018 23:33:36 -0700 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 21 May 2018 23:33:36 -0700 Received: from bgsmsx106.gar.corp.intel.com (10.223.43.196) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 21 May 2018 23:33:36 -0700 Received: from bgsmsx101.gar.corp.intel.com ([169.254.1.244]) by BGSMSX106.gar.corp.intel.com ([169.254.1.135]) with mapi id 14.03.0319.002; Tue, 22 May 2018 12:03:32 +0530 From: "Varghese, Vipin" To: Ophir Munk , "dev@dpdk.org" , "Wiles, Keith" , "Yigit, Ferruh" CC: Thomas Monjalon , Olga Shern Thread-Topic: [PATCH v2] net/tap: perform proto field update for tun only Thread-Index: AQHT7Cw2u6LUf1uHOUijlW4QklPdMqQxA5OAgApRcyA= Date: Tue, 22 May 2018 06:33:32 +0000 Message-ID: <4C9E0AB70F954A408CC4ADDBF0F8FA7D4D1F8241@BGSMSX101.gar.corp.intel.com> References: <1526273615-154067-1-git-send-email-vipin.varghese@intel.com> <1526395780-105792-1-git-send-email-vipin.varghese@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjA3MDY4MTItNzM0ZC00ZjRiLWE5ODUtNWUzZjBmYmJjMDc0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoieFlRNDlucXBqNkdCcTBDemJXYVBRYnRCREVUdkp1b2ZjbVBTb1FBOFQ1MU16d0prelp1RHhLdEduNU5hXC9NbUEifQ== dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.223.10.10] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] net/tap: perform proto field update for tun only 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: Tue, 22 May 2018 06:33:39 -0000 Hi Ophir, Thanks for the suggestion, once these are merged to dpdk or dpdk-net mainli= ne, I can start the modifications. Thanks Vipin Varghese > -----Original Message----- > From: Ophir Munk [mailto:ophirmu@mellanox.com] > Sent: Wednesday, May 16, 2018 3:59 AM > To: Varghese, Vipin ; dev@dpdk.org; Wiles, Keit= h > ; Yigit, Ferruh > Cc: Thomas Monjalon ; Olga Shern > > Subject: RE: [PATCH v2] net/tap: perform proto field update for tun only >=20 > Hi, > I am adding my review although this patch has already been acked. > Please find some comments inline. Otherwise it looks OK. >=20 > Regards, > Ophir >=20 > > -----Original Message----- > > From: Vipin Varghese [mailto:vipin.varghese@intel.com] > > Sent: Tuesday, May 15, 2018 5:50 PM > > To: dev@dpdk.org; keith.wiles@intel.com; ferruh.yigit@intel.com; Ophir > > Munk > > Cc: Vipin Varghese > > Subject: [PATCH v2] net/tap: perform proto field update for tun only > > > > The TX function is shared between TAP and TUN PMD. Checking TUN-TAP > > type field will ensure the TAP PMD will always have protocol field as 0= . > > > > Signed-off-by: Vipin Varghese > > Suggested-by: Ferruh Yigit > > --- > > > > Changes in V2: > > updated in comment wording - Keith Wiles remove debug print from tx > > code > > - Keith Wiles > > --- > > drivers/net/tap/rte_eth_tap.c | 48 > > ++++++++++++++++++++++++++----------- > > ------ > > drivers/net/tap/rte_eth_tap.h | 10 +++++++++ > > 2 files changed, 39 insertions(+), 19 deletions(-) > > > > diff --git a/drivers/net/tap/rte_eth_tap.c > > b/drivers/net/tap/rte_eth_tap.c index ea6d899..fafd557 100644 > > --- a/drivers/net/tap/rte_eth_tap.c > > +++ b/drivers/net/tap/rte_eth_tap.c > > @@ -115,7 +115,8 @@ tun_alloc(struct pmd_internals *pmd) > > * Do not set IFF_NO_PI as packet information header will be needed > > * to check if a received packet has been truncated. > > */ > > - ifr.ifr_flags =3D (tap_type) ? IFF_TAP : IFF_TUN | IFF_POINTOPOINT; > > + ifr.ifr_flags =3D (pmd->type =3D=3D ETH_TUNTAP_TYPE_TAP) ? > > + IFF_TAP : IFF_TUN | IFF_POINTOPOINT; > > snprintf(ifr.ifr_name, IFNAMSIZ, "%s", pmd->name); > > > > TAP_LOG(DEBUG, "ifr_name '%s'", ifr.ifr_name); @@ -502,20 > > +503,22 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t > > nb_pkts) > > if (rte_pktmbuf_pkt_len(mbuf) > max_size) > > break; > > > > - /* > > - * TUN and TAP are created with IFF_NO_PI disabled. > > - * For TUN PMD this mandatory as fields are used by > > - * Kernel tun.c to determine whether its IP or non IP > > - * packets. > > - * > > - * The logic fetches the first byte of data from mbuf. > > - * compares whether its v4 or v6. If none matches default > > - * value 0x00 is taken for protocol field. > > - */ > > - char *buff_data =3D rte_pktmbuf_mtod(seg, void *); > > - j =3D (*buff_data & 0xf0); > > - pi.proto =3D (j =3D=3D 0x40) ? 0x0008 : > > - (j =3D=3D 0x60) ? 0xdd86 : 0x00; > > + if (txq->type =3D=3D ETH_TUNTAP_TYPE_TUN) { > > + /* > > + * TUN and TAP are created with IFF_NO_PI disabled. > > + * For TUN PMD this mandatory as fields are used by > > + * Kernel tun.c to determine whether its IP or non IP > > + * packets. > > + * > > + * The logic fetches the first byte of data from mbuf > > + * then compares whether its v4 or v6. If first byte > > + * is 4 or 6, then protocol field is updated. > > + */ > > + char *buff_data =3D rte_pktmbuf_mtod(seg, void *); > > + j =3D (*buff_data & 0xf0); > > + pi.proto =3D (j =3D=3D 0x40) ? 0x0008 : > > + (j =3D=3D 0x60) ? 0xdd86 : 0x00; > > + } > > > > iovecs[0].iov_base =3D π > > iovecs[0].iov_len =3D sizeof(pi); > > @@ -1052,6 +1055,9 @@ tap_setup_queue(struct rte_eth_dev *dev, > > tx->mtu =3D &dev->data->mtu; > > rx->rxmode =3D &dev->data->dev_conf.rxmode; > > > > + tx->type =3D pmd->type; > > + rx->type =3D pmd->type; >=20 > It seems there is no usage for rx->type in TAP code. Therefore - can you = please > remove rx->type assignment? > > + > > return *fd; > > } > > > > @@ -1386,6 +1392,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, > > char *tap_name, > > pmd =3D dev->data->dev_private; > > pmd->dev =3D dev; > > snprintf(pmd->name, sizeof(pmd->name), "%s", tap_name); > > + pmd->type =3D ETH_TUNTAP_TYPE_UNKNOWN; > > > > pmd->ioctl_sock =3D socket(AF_INET, SOCK_DGRAM, 0); > > if (pmd->ioctl_sock =3D=3D -1) { > > @@ -1421,7 +1428,9 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, > > char *tap_name, > > pmd->txq[i].fd =3D -1; > > } > > > > - if (tap_type) { > > + pmd->type =3D (tap_type) ? ETH_TUNTAP_TYPE_TAP : > > ETH_TUNTAP_TYPE_TUN; >=20 > 1. It seem you are using 'tap_type' as a global static variable to pass a= value to > eth_dev_tap_create(). > Can you please pass this value by adding a parameter to eth_dev_tap_creat= e() > call and remove the global static variable? > 2. You are using tap_type with values 0 and 1 which are converted to enum= s > ETH_TUNTAP_TYPE_TUN and ETH_TUNTAP_TYPE_TAP respectively. Can you > please always just use the enums (avoiding the conversion)? >=20 > > + > > + if (pmd->type =3D=3D ETH_TUNTAP_TYPE_TAP) { > > if (is_zero_ether_addr(mac_addr)) > > eth_random_addr((uint8_t *)&pmd->eth_addr); > > else > > @@ -1440,7 +1449,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, > > char *tap_name, > > if (tap_ioctl(pmd, SIOCSIFMTU, &ifr, 1, LOCAL_AND_REMOTE) < 0) > > goto error_exit; > > > > - if (tap_type) { > > + if (pmd->type =3D=3D ETH_TUNTAP_TYPE_TAP) { > > memset(&ifr, 0, sizeof(struct ifreq)); > > ifr.ifr_hwaddr.sa_family =3D AF_LOCAL; > > rte_memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr, @@ - > > 1812,7 +1821,9 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) > > struct pmd_internals *internals; > > int i; > > > > - TAP_LOG(DEBUG, "Closing TUN/TAP Ethernet device on numa %u", > > + internals =3D eth_dev->data->dev_private; > > + TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u", > > + (internals->type =3D=3D ETH_TUNTAP_TYPE_TAP) ? "TAP" : > > "TUN", > > rte_socket_id()); > > > > /* find the ethdev entry */ > > @@ -1820,7 +1831,6 @@ rte_pmd_tap_remove(struct rte_vdev_device > > *dev) > > if (!eth_dev) > > return 0; > > > > - internals =3D eth_dev->data->dev_private; > > if (internals->nlsk_fd) { > > tap_flow_flush(eth_dev, NULL); > > tap_flow_implicit_flush(internals, NULL); diff --git > > a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h index > > 67c9d4b..8b0da5a 100644 > > --- a/drivers/net/tap/rte_eth_tap.h > > +++ b/drivers/net/tap/rte_eth_tap.h > > @@ -23,6 +23,13 @@ > > #define RTE_PMD_TAP_MAX_QUEUES 1 > > #endif > > > > +enum rte_tuntap_type { > > + ETH_TUNTAP_TYPE_UNKNOWN, > > + ETH_TUNTAP_TYPE_TUN, > > + ETH_TUNTAP_TYPE_TAP, > > + ETH_TUNTAP_TYPE_MAX, > > +}; > > + > > struct pkt_stats { > > uint64_t opackets; /* Number of output packets */ > > uint64_t ipackets; /* Number of input packets */ > > @@ -38,6 +45,7 @@ struct rx_queue { > > uint32_t trigger_seen; /* Last seen Rx trigger value */ > > uint16_t in_port; /* Port ID */ > > int fd; > > + int type; /* Type field - TUN|TAP */ >=20 > In seems there is no usage for 'type' field from rx_queue struct in the c= ode. If so > - can you please remove it? >=20 > > struct pkt_stats stats; /* Stats for this RX queue */ > > uint16_t nb_rx_desc; /* max number of mbufs available */ > > struct rte_eth_rxmode *rxmode; /* RX features */ @@ -48,6 +56,7 > @@ > > struct rx_queue { > > > > struct tx_queue { > > int fd; > > + int type; /* Type field - TUN|TAP */ >=20 > Please use spaces (like all other fields in this struct) instead of tabs,= so all fields > look aligned. >=20 > > uint16_t *mtu; /* Pointer to MTU from dev_data */ > > uint16_t csum:1; /* Enable checksum offloading */ > > struct pkt_stats stats; /* Stats for this TX queue */ > > @@ -57,6 +66,7 @@ struct pmd_internals { > > struct rte_eth_dev *dev; /* Ethernet device. */ > > char remote_iface[RTE_ETH_NAME_MAX_LEN]; /* Remote netdevice > name */ > > char name[RTE_ETH_NAME_MAX_LEN]; /* Internal Tap device name */ > > + int type; /* Type field - TUN|TAP */ >=20 > Same comment here about replacing tabs with spaces >=20 > > struct ether_addr eth_addr; /* Mac address of the device port *= / > > struct ifreq remote_initial_flags; /* Remote netdevice flags on ini= t > > */ > > int remote_if_index; /* remote netdevice IF_INDEX */ > > -- > > 2.7.4