From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 05F83A0471 for ; Fri, 16 Aug 2019 10:23:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1368A1BED9; Fri, 16 Aug 2019 10:23:19 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id F17CA375B for ; Fri, 16 Aug 2019 10:23:16 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us5.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 8C010580067; Fri, 16 Aug 2019 08:23:15 +0000 (UTC) Received: from [192.168.1.11] (85.187.13.152) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 16 Aug 2019 09:23:04 +0100 To: , , , John McNamara , "Marko Kovacevic" , Thomas Monjalon CC: References: <20190816055511.2322-1-pbhagavatula@marvell.com> <20190816055511.2322-2-pbhagavatula@marvell.com> From: Andrew Rybchenko Message-ID: <851302fb-0c2a-1b48-e37c-7ca6e69bdbf9@solarflare.com> Date: Fri, 16 Aug 2019 11:22:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190816055511.2322-2-pbhagavatula@marvell.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [85.187.13.152] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24850.003 X-TM-AS-Result: No-2.274400-8.000000-10 X-TMASE-MatchedRID: gjZGo2H/wj+2uvwZYhrIwG6HurDH4PpPnKpQna4coUBTHhSneq8wpyGU b2JNxi1qSYcwkmMXrHiwYSb8s4Rdab6g3g5+1F/exTpJ3OQjb3dKgIbix5+XxPkuQv9PIVnN2xL Yz19cST1vyfYBVbGZ7YM7zVCe86C9xYdYUaRWp+twju9EALAXQpnaxzJFBx6vRu2i7U96I/tyKM xmuvaJna3aC25avUua6JvL/XA5QkZdwKvR2QLJ9jIHIyLCTr7e+ma2kEuhRFogUEQTkIWiYlwLn kRcnM55ZrH99sffMd8Zcgwva3xJZJE4FU2ZdQO49Ib/6w+1lWTguJLkGXjcboTGTpzirPHyIycc KU/UgpuvC6Q/Yp92kIG/r5v6uFm8BC/qhcduELqInASnzB5VfN2Emh5Z2S/N5kyJys6UhUlcpkb 9zUI7BAdvPN/micTvB7WfodhyMN1r/egrjSxRKpeZMgaIw04OxPjS55tgjy4M74Nf6tTB9nY2Ws QTo6ONmzBhrebgmW6wARtZLO63Y49oUcx9VMLggxsfzkNRlfLaf1N18C+ZAhe9CQaLe2PPjoczm uoPCq2PNYFy7qKZFT9OERsWW0kCdpJgl/GB24lk8HdV2vTu+ohQbSpYdUlX2gk0q8U+r0RfG96z PeO/iYhuK/Qtzg+XK9o6TCpCSAfi+fTMx9KaNitss6PUa4/cD6GAt+UbooSj1CO4X0Eqed8x3qz oMNxx X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--2.274400-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24850.003 X-MDID: 1565943796-mgOx5EbAzsWx Subject: Re: [dpdk-dev] [PATCH 1/7] ethdev: add set ptype function 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The patch should add item in release notes (as well as all other subsequent patches which add more features). On 8/16/19 8:55 AM, pbhagavatula@marvell.com wrote: > From: Pavan Nikhilesh > > Add `rte_eth_dev_set_supported_ptypes` function that will allow the > application to inform the PMD the packet types it is interested in. > Based on the ptypes set PMDs can optimize their Rx path. > > -If application doesn’t want any ptype information it can call > `rte_eth_dev_set_supported_ptypes(ethdev_id, RTE_PTYPE_UNKNOWN)` and PMD > will set rte_mbuf::packet_type to 0. As I understand PMD may provide more reach classification than set. So, it is not obliged to set packet type to 0. > -If application doesn’t call `rte_eth_dev_set_supported_ptypes` PMD can > return `rte_mbuf::packet_type` with `rte_eth_dev_get_supported_ptypes`. > > -If application is interested only in L2/L3 layer, it can inform the PMD > to update `rte_mbuf::packet_type` with L2/L3 ptype by calling > `rte_eth_dev_set_supported_ptypes(ethdev_id, > RTE_PTYPE_L2_MASK | RTE_PTYPE_L3_MASK)`. > > Suggested-by: Konstantin Ananyev > Signed-off-by: Pavan Nikhilesh > --- > doc/guides/nics/features.rst | 12 ++++++++---- > lib/librte_ethdev/rte_ethdev.c | 28 ++++++++++++++++++++++++++++ > lib/librte_ethdev/rte_ethdev.h | 17 +++++++++++++++++ > lib/librte_ethdev/rte_ethdev_core.h | 6 ++++++ > 4 files changed, 59 insertions(+), 4 deletions(-) > > diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst > index c4e128d2f..d4d55f721 100644 > --- a/doc/guides/nics/features.rst > +++ b/doc/guides/nics/features.rst > @@ -582,10 +582,14 @@ Supports inner packet L4 checksum. > Packet type parsing > ------------------- > > -Supports packet type parsing and returns a list of supported types. > - > -* **[implements] eth_dev_ops**: ``dev_supported_ptypes_get``. > -* **[related] API**: ``rte_eth_dev_get_supported_ptypes()``. > +Supports packet type parsing and returns a list of supported types. Allows > +application to set ptypes it is interested in. > + > +* **[implements] eth_dev_ops**: ``dev_supported_ptypes_get``, > + ``dev_supported_ptypes_set``. > +* **[related] API**: ``rte_eth_dev_get_supported_ptypes()``, > + ``rte_eth_dev_set_supported_ptypes()``. > +* **[provides] mbuf**: ``mbuf.packet_type``. > > > .. _nic_features_timesync: > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c > index 17d183e1f..72fe660c3 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -2602,6 +2602,34 @@ rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask, > return j; > } > > +int > +rte_eth_dev_set_supported_ptypes(uint16_t port_id, uint32_t ptype_mask) > +{ > + int i; > + struct rte_eth_dev *dev; > + const uint32_t *all_ptypes; > + uint32_t all_ptype_mask = 0; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > + dev = &rte_eth_devices[port_id]; > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_supported_ptypes_set, > + -ENOTSUP); > + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_supported_ptypes_get, > + -ENOTSUP); > + all_ptypes = (*dev->dev_ops->dev_supported_ptypes_get)(dev); > + > + if (!all_ptypes) If I remember correctly DPDK style prefers to compare vs 0. > + return -ENOTSUP; > + > + for (i = 0; all_ptypes[i] != RTE_PTYPE_UNKNOWN; ++i) > + all_ptype_mask |= all_ptypes[i]; > + > + if ((all_ptype_mask & ptype_mask) != ptype_mask) > + return -ENOTSUP; Do we really want so strict check here? May be just check that intersection is not empty if ptype_mask is not empty? I think that setting ptype_mask to 0 could be pretty often and may be it makes sense to avoid get in the case. Also consider to return OK even if there is no get/set callbacks at all. > + > + return (*dev->dev_ops->dev_supported_ptypes_set)(dev, ptype_mask); > +} > + > void > rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr) > { > diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h > index dc6596bc9..f97f0a6e5 100644 > --- a/lib/librte_ethdev/rte_ethdev.h > +++ b/lib/librte_ethdev/rte_ethdev.h > @@ -2431,6 +2431,23 @@ int rte_eth_dev_fw_version_get(uint16_t port_id, > */ > int rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask, > uint32_t *ptypes, int num); > +/** > + * Request Ethernet device to set only specific packet types in the packet. > + * > + * Application can use this function to set only specific ptypes that it's > + * interested. This information can be used by the PMD to optimize Rx path. > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param ptype_mask > + * The ptype family that application is interested in. > + * @return > + * - (0) Successfully set supported ptypes. > + * - (-ENODEV) if *port_id* is invalid. > + * - (-ENOTSUP) Packet type mask supplied is not supported by the Ethernet > + * device. > + */ > +int rte_eth_dev_set_supported_ptypes(uint16_t port_id, uint32_t ptype_mask); Should it be experimental? Please, add it to .map file. > /** > * Retrieve the MTU of an Ethernet device. > diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h > index 2922d5b7c..02ee7c12c 100644 > --- a/lib/librte_ethdev/rte_ethdev_core.h > +++ b/lib/librte_ethdev/rte_ethdev_core.h > @@ -110,6 +110,10 @@ typedef void (*eth_dev_infos_get_t)(struct rte_eth_dev *dev, > typedef const uint32_t *(*eth_dev_supported_ptypes_get_t)(struct rte_eth_dev *dev); > /**< @internal Get supported ptypes of an Ethernet device. */ > > +typedef int (*eth_dev_supported_ptypes_set_t)(struct rte_eth_dev *dev, > + uint32_t ptype_mask); > +/**< @internal Set required ptypes of an Ethernet device. */ > + > typedef int (*eth_queue_start_t)(struct rte_eth_dev *dev, > uint16_t queue_id); > /**< @internal Start rx and tx of a queue of an Ethernet device. */ > @@ -421,6 +425,8 @@ struct eth_dev_ops { > eth_fw_version_get_t fw_version_get; /**< Get firmware version. */ > eth_dev_supported_ptypes_get_t dev_supported_ptypes_get; > /**< Get packet types supported and identified by device. */ > + eth_dev_supported_ptypes_set_t dev_supported_ptypes_set; > + /**< Inform device about the interested ptypes. */ > > vlan_filter_set_t vlan_filter_set; /**< Filter VLAN Setup. */ > vlan_tpid_set_t vlan_tpid_set; /**< Outer/Inner VLAN TPID Setup. */ > -- > 2.22.0 >