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 3E12DA04B3; Fri, 8 Nov 2019 11:24:52 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A21EB1C07C; Fri, 8 Nov 2019 11:24:19 +0100 (CET) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 5110E1C030 for ; Fri, 8 Nov 2019 11:24:18 +0100 (CET) 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-us4.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 3575380062; Fri, 8 Nov 2019 10:24:16 +0000 (UTC) Received: from [192.168.38.17] (91.220.146.112) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 8 Nov 2019 10:24:09 +0000 To: Ferruh Yigit , , , , John McNamara , Marko Kovacevic CC: References: <20191029153722.4547-1-pbhagavatula@marvell.com> <20191106191803.15098-1-pbhagavatula@marvell.com> <20191106191803.15098-2-pbhagavatula@marvell.com> <1cedc5eb-2485-9c3b-bb02-b7a0fba3c483@intel.com> <0f209606-a5f0-cfdb-260e-bc81405c6a8e@solarflare.com> <07eae75b-b057-6a80-72bb-826b33aadbc7@intel.com> From: Andrew Rybchenko Openpgp: preference=signencrypt Autocrypt: addr=arybchenko@solarflare.com; keydata= mQINBF2681gBEACbdTxu8eLL3UX2oAelsnK9GkeaJeUYSOHPJQpV7RL/iaIskqTwBRnhjXt7 j9UEwGA+omnOmqQMpeQTb/F9Ma2dYE+Hw4/t/1KVjxr3ehFaASvwR4fWJfO4e2l/Rk4rG6Yi 5r6CWU2y8su2654F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CRDh/sUiyqRwS7PHEA LYC/UIWLMomI0Yvju3KA5v3RQVXhL+Gx2CzSj3GDz9xxGhJB2LfRfjzPbTR/Z27UpjCkd8z0 Ro3Ypmi1FLQwnRgoOKDbetTAIhugEShaLTITzJAP/iRDJCQsrZah5tE8oIl81qKEmBJEGcdt HYikbpQe7ydcXhqTj7+IECa3O7azI5OhCxUH2jNyonJ/phUslHH2G1TTBZK8y4Hrx5RpuRNS esn3P9uKu9DHqBAL7DMsCPwb2p1VNnapD72DBmRhzS/e6zS2R4+r9yNv03Hv7VCxKkmtE63H qpS//qpjfrtsIcHAjnKDaDtL1LYCtHoweI+DOpKKULSAYp/JE6F8LNibPQ0/P3S5ZIJNC4QZ uESjFOalJwFIqGQdkQB7ltRNJENLrHc+2jKGOuyFHm/Sbvp5EMGdaeQ0+u8CY0P+y6oXenwx 7WrJz/GvbNoFhJoJ6RzxCMQrFgxrssVZ7w5HcUj94lbnJ6osdYE/WpSd50B6jet6LKh5revg u9XI9CoqsPQ1V4wKYYdllPuogCye7KNYNKuiiuSNpaF4gHq1ZWGArwZtWHjgc2v3LegOpRQF SwOskMKmWsUyHIRMG1p8RpkBQTqY2rGSeUqPSvaqjT0nq+SUEM6qxEXD/2Wqri/X6bamuPDb S0PkBvFD2+0zr5Bc2YkMGPBYPNGZiTp3UjmZlLfn3TiBKIC92jherY563CULjSsiBEJCOSvv 4VPLn5aAcfbCXJnE3IGCp/hPl50iQqu7BPOYBbWXeb9ptDjGCAThNxSz0WAXkmcjAFE8gdE6 Znk9 Message-ID: <034523de-62e9-389b-658c-c17b0112fee9@solarflare.com> Date: Fri, 8 Nov 2019 13:24:04 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <07eae75b-b057-6a80-72bb-826b33aadbc7@intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Originating-IP: [91.220.146.112] 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-25028.003 X-TM-AS-Result: No-12.459800-8.000000-10 X-TMASE-MatchedRID: 8HTFlOrbAtHmLzc6AOD8DfHkpkyUphL9NV9S7O+u3KYRHgO3hlQeWerO SEJRBEaX+7oxQF5T5wUIl1lIQSnNKOzvTxSiXJG/6fUfELqFUH+8dr6FG8BQfeZAlRR6AIJ7eCN V1mMi/46MR3kDhegnTHzs73bFScRmtrQSlX9RxUXZ+i/tPCEvyald1ZriBTRLs4be7XhW2Z5yKM xmuvaJna3aC25avUuaHVVF1Gr4vCsij1rXhFZBDP9XRIMLUOjQv8jdqvFOu+J/KM1eVsG+dPeHa PJtCROSfsmDiqsX0CA4UoCJNJJ1MqHECosCGgdm/ccgt/EtX/1dt5rzpYPEDFSOymiJfTYXM/3+ TuDqaXdI8M5zLUF1/J7lXpQdUtjM6rh4F+X/sTxFM72aEhcbjW15iJF8eE6rHSxwDTuG6eBpcrN Tw4Vi6DW0O5xV4X32C1MkYihD/gGv8USvlgfn8iqwx8x+s5lFNW8jQhzoALUZSz1vvG+0msA9Xa jGjh60Oiycf7SOVO52w9nBs56maFlP3wf1xZicN19PjPJahlLM8zLNncnslfQkrXkUDmL1jKexi cEa6Xip39guhXyPnegbxsAtqXubQvmpg0wnSLMMOWxRtywg+snlJe2gk8vIsrDwfHQQaK3WPGf/ WCvRSFs82Lb7xnnIBVNIiJDsE6bAsE5JA1werFLFinzH90Wn+IfriO3cV8TSvnSpS9gcQD2j/N8 mMgrkJ8XHCuBDNHCfXkRn6wIX6NiuHxhZdW6KzNIobH2DzGED3pUvHwpyruLsQIDmr3S5Ayul3K MVU/qBA+mUA2qFzWc5FCFZQeubKznJl9qwvsOeAiCmPx4NwFkMvWAuahr8ylNXFsiN4FpJKW4mD lJsMSAHAopEd76vmP3jpxPPOLq2xcQshSJstJdnf0lHOZ6gShV2eCX817km4AaXIiky8Q== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--12.459800-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-25028.003 X-MDID: 1573208657-CHKKpoZDDncw Subject: Re: [dpdk-dev] [PATCH v16 1/8] 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" On 11/8/19 12:52 PM, Ferruh Yigit wrote: > On 11/8/2019 9:05 AM, Andrew Rybchenko wrote: >> On 11/7/19 9:28 PM, Ferruh Yigit wrote: >>> On 11/6/2019 7:17 PM, pbhagavatula@marvell.com wrote: >>>> From: Pavan Nikhilesh >>>> >>>> Add `rte_eth_dev_set_ptypes` function that will allow the application >>>> to inform the PMD about reduced range of packet types to handle. >>>> 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_ptypes(ethdev_id, RTE_PTYPE_UNKNOWN, NULL, 0)` >>>> and PMD may skip packet type processing and set rte_mbuf::packet_type to >>>> RTE_PTYPE_UNKNOWN. >>>> >>>> -If application doesn’t call `rte_eth_dev_set_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_ptypes(ethdev_id, >>>> RTE_PTYPE_L2_MASK | RTE_PTYPE_L3_MASK, NULL, 0)`. >>>> >>>> Suggested-by: Konstantin Ananyev >>>> Signed-off-by: Pavan Nikhilesh >>>> Reviewed-by: Andrew Rybchenko >>>> --- >>>> doc/guides/nics/features.rst | 7 +- >>>> doc/guides/rel_notes/release_19_11.rst | 8 +++ >>>> lib/librte_ethdev/rte_ethdev.c | 87 +++++++++++++++++++++++- >>>> lib/librte_ethdev/rte_ethdev.h | 36 ++++++++++ >>>> lib/librte_ethdev/rte_ethdev_core.h | 18 +++++ >>>> lib/librte_ethdev/rte_ethdev_version.map | 1 + >>>> 6 files changed, 154 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst >>>> index 7a31cf7c8..f33e8e6d4 100644 >>>> --- a/doc/guides/nics/features.rst >>>> +++ b/doc/guides/nics/features.rst >>>> @@ -583,9 +583,12 @@ Packet type parsing >>>> ------------------- >>>> >>>> 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``. >>>> -* **[related] API**: ``rte_eth_dev_get_supported_ptypes()``. >>>> +* **[implements] eth_dev_ops**: ``dev_supported_ptypes_get``, >>>> +* **[related] API**: ``rte_eth_dev_get_supported_ptypes()``, >>>> + ``rte_eth_dev_set_ptypes()``, ``dev_ptypes_set``. >>>> +* **[provides] mbuf**: ``mbuf.packet_type``. >>>> >>>> >>>> .. _nic_features_timesync: >>>> diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst >>>> index 23182d187..2fa54aadc 100644 >>>> --- a/doc/guides/rel_notes/release_19_11.rst >>>> +++ b/doc/guides/rel_notes/release_19_11.rst >>>> @@ -86,6 +86,13 @@ New Features >>>> SET_TAG action and TAG item have been added to support transient flow >>>> tag. >>>> >>>> +* **Added ethdev API to set supported packet types** >>>> + >>>> + * Added new API ``rte_eth_dev_set_ptypes`` that allows an application to >>>> + inform PMD about about reduced range of packet types to handle. >>>> + * This scheme will allow PMDs to avoid lookup to internal ptype table on Rx >>>> + and thereby improve Rx performance if application wishes do so. >>>> + >>>> * **Updated the enic driver.** >>>> >>>> * Added support for Geneve with options offload. >>>> @@ -258,6 +265,7 @@ New Features >>>> * Rx metadata is delivered to host via a dynamic field of ``rte_mbuf`` with >>>> PKT_RX_DYNF_METADATA. >>>> >>>> + >>>> Removed Items >>>> ------------- >>>> >>>> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c >>>> index 652c369e5..13e6daaf4 100644 >>>> --- a/lib/librte_ethdev/rte_ethdev.c >>>> +++ b/lib/librte_ethdev/rte_ethdev.c >>>> @@ -2879,6 +2879,92 @@ rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask, >>>> return j; >>>> } >>>> >>>> +int >>>> +rte_eth_dev_set_ptypes(uint16_t port_id, uint32_t ptype_mask, >>>> + uint32_t *set_ptypes, unsigned int num) >>>> +{ >>>> + const uint32_t valid_ptype_masks[] = { >>>> + RTE_PTYPE_L2_MASK, >>>> + RTE_PTYPE_L3_MASK, >>>> + RTE_PTYPE_L4_MASK, >>>> + RTE_PTYPE_TUNNEL_MASK, >>>> + RTE_PTYPE_INNER_L2_MASK, >>>> + RTE_PTYPE_INNER_L3_MASK, >>>> + RTE_PTYPE_INNER_L4_MASK, >>>> + }; >>>> + const uint32_t *all_ptypes; >>>> + struct rte_eth_dev *dev; >>>> + uint32_t unused_mask; >>>> + unsigned int i, j; >>>> + int ret; >>>> + >>>> + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); >>>> + dev = &rte_eth_devices[port_id]; >>>> + >>>> + if (num > 0 && set_ptypes == NULL) >>>> + return -EINVAL; >>>> + >>>> + if (*dev->dev_ops->dev_supported_ptypes_get == NULL || >>>> + *dev->dev_ops->dev_ptypes_set == NULL) { >>>> + ret = 0; >>>> + goto ptype_unknown; >>>> + } >>> >>> Hi Pavan, Andrew, >>> >>> Why API is not returning "-ENOTSUP" id dev_ops is not provided as done it other >>> APIs? >> >> As I understand the reason behind it is an optional nature >> of the callback. It is just an optimization and there is no >> point to complicate applications code to check and treat >> -ENOTSUP is OK. > > I was also thinking this is just an optimization but Jerin wants to call it > default in all samples first, now in testpmd by default. Why the optimization should not be applied in all samples? If sample does not use ptype information it may and should be applied since we are all keen for the best possible performance. > Although it makes simple to ignore the error this way, I think it can be good to > differentiate the success, not implemented and failed cases. No, it simplifies error tracking. We can check return value and if it is not zero say that it goes wrong (instead of not zero and not -ENOTSUP). >> >>>> + >>>> + if (ptype_mask == 0) { >>>> + ret = (*dev->dev_ops->dev_ptypes_set)(dev, >>>> + ptype_mask); >>>> + goto ptype_unknown; >>>> + } >>>> + >>>> + unused_mask = ptype_mask; >>>> + for (i = 0; i < RTE_DIM(valid_ptype_masks); i++) { >>>> + uint32_t mask = ptype_mask & valid_ptype_masks[i]; >>>> + if (mask && mask != valid_ptype_masks[i]) { >>>> + ret = -EINVAL; >>>> + goto ptype_unknown; >>>> + } >>>> + unused_mask &= ~valid_ptype_masks[i]; >>>> + } >>> >>> What does above block does? >>> Does it mean 'ptype_mask' only can be combination of 'valid_ptype_masks' items? >> >> Yes. >> >>> Let's say can't I set only 'RTE_PTYPE_L2_ETHER' as requested ptype? >> >> Yes >> >>> Why this limitation and is it documented anywhere, like the API documentation? >> >> It is simply incorrect to have non-mask bits here. >> RTE_PTYPE_L2_ETHER & RTE_PTYPE_L2_ETHER_ARP != 0 > > Right. > >> It is documented in the ptype_mask parameter description. > > OK, I missed it in ptype_mask description. > >> >>>> + >>>> + if (unused_mask) { >>>> + ret = -EINVAL; >>>> + goto ptype_unknown; >>>> + } >>>> + >>>> + all_ptypes = (*dev->dev_ops->dev_supported_ptypes_get)(dev); >>>> + if (all_ptypes == NULL) { >>>> + ret = 0; >>>> + goto ptype_unknown; >>>> + } >>>> + >>>> + /* >>>> + * Accodommodate as many set_ptypes as possible. If the supplied >>> >>> s/Accodommodate/Accommodate >>> >>>> + * set_ptypes array is insufficient fill it partially. >>>> + */ >>>> + for (i = 0, j = 0; set_ptypes != NULL && >>>> + (all_ptypes[i] != RTE_PTYPE_UNKNOWN); ++i) { >>>> + if (ptype_mask & all_ptypes[i]) { >>>> + if (j < num - 1) { >>>> + set_ptypes[j] = all_ptypes[i]; >>>> + j++; >>>> + continue; >>>> + } >>>> + break; >>>> + } >>>> + } >>>> + >>>> + if (set_ptypes != NULL && j < num) >>>> + set_ptypes[j] = RTE_PTYPE_UNKNOWN; >>>> + >>>> + return (*dev->dev_ops->dev_ptypes_set)(dev, ptype_mask); >>> >>> Only a question, at this stage API knows the supported ptypes by device, does it >>> make sense to check if 'ptype_mask' has anything unsupported instead of passing >>> it to the driver and expect driver to check it? >> >> It is also explained by the nature of the API. Application says: >> I'm interested in the following ptypes only to let PMD know that >> it could drop classification behind it. If PMD does not support >> some layers, it will not provide classification anyway. > > in "eth_dev_ptypes_set_t" documentation, it says: > "- (-EINVAL) if *ptype_mask* is invalid." > I thought PMD does a check on received 'ptype_mask', if expectation is PMD will > do the check, why not do the check in API commonly instead of each PMD. > What is the documented case "*ptype_mask* is invalid."? Not a combination of RTE_PTYPE_*_MASK. There are few cases above where -EINVAL is returned includes failed validation of ptype_mask. >> >>>> + >>>> +ptype_unknown: >>>> + if (num > 0) >>>> + set_ptypes[0] = RTE_PTYPE_UNKNOWN; >>>> + >>>> + return ret; >>>> +} >>>> + >>>> int >>>> rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr) >>>> { >>>> @@ -2891,7 +2977,6 @@ rte_eth_macaddr_get(uint16_t port_id, struct rte_ether_addr *mac_addr) >>>> return 0; >>>> } >>>> >>>> - >>>> int >>>> rte_eth_dev_get_mtu(uint16_t port_id, uint16_t *mtu) >>>> { >>>> diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h >>>> index 44d77b332..a7872819d 100644 >>>> --- a/lib/librte_ethdev/rte_ethdev.h >>>> +++ b/lib/librte_ethdev/rte_ethdev.h >>>> @@ -2604,6 +2604,42 @@ 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); >>>> +/** >>>> + * @warning >>>> + * @b EXPERIMENTAL: this API may change without prior notice. >>>> + * >>>> + * Inform Ethernet device about reduced range of packet types to handle. >>>> + * >>>> + * 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. >>>> + * >>>> + * The function accepts an array `set_ptypes` allocated by the caller to >>>> + * store the packet types set by the driver, the last element of the array >>>> + * is set to RTE_PTYPE_UNKNOWN. The size of the `set_ptype` array should be >>>> + * `rte_eth_dev_get_supported_ptypes() + 1` else it might only be filled >>>> + * partially. >>>> + * >>>> + * @param port_id >>>> + * The port identifier of the Ethernet device. >>>> + * @param ptype_mask >>>> + * The ptype family that application is interested in should be bitwise OR of >>>> + * RTE_PTYPE_*_MASK or 0. >>> >>> No strong opinion but is it really a mask? it doesn't used to mask any value, >>> but it is list of ptypes that application requests, in a bitwise ORed form, so I >>> this it can be ptypes. >> >> See above. > > OK, it is a mask really. > >> >>>> + * @param set_ptypes >>>> + * An array pointer to store set packet types, allocated by caller. The >>>> + * function marks the end of array with RTE_PTYPE_UNKNOWN. >>> >>> Not for this patch, but is an API also required to get current supported ptypes >>> from the driver? Even application keeps this list, something can reset in the >>> device/driver, supported pytpe list can be changed and it can differ with what >>> application knows. >> >> I would say that set_ptypes should not affected supported_ptypes. > > I expect same. I was asking should we have an API that returns list of ptypes > returned by PMD after 'rte_eth_dev_set_ptypes()' call? Can we know that list > without a new API? As I understand the only way right now is to get on when ptypes are set. I would add _get_ptypes() function when it is really required only. >> >>>> + * @param num >>>> + * Size of the array pointed by param ptypes. >>>> + * Should be rte_eth_dev_get_supported_ptypes() + 1 to accommodate the >>>> + * set ptypes. >>>> + * @return >>>> + * - (0) if Success. >>>> + * - (-ENODEV) if *port_id* invalid. >>>> + * - (-EINVAL) if *ptype_mask* is invalid (or) set_ptypes is NULL and >>>> + * num > 0. >>>> + */ >>>> +__rte_experimental >>>> +int rte_eth_dev_set_ptypes(uint16_t port_id, uint32_t ptype_mask, >>>> + uint32_t *set_ptypes, unsigned int num); >>>> >>>> /** >>>> * 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 f215af7c9..657c39b56 100644 >>>> --- a/lib/librte_ethdev/rte_ethdev_core.h >>>> +++ b/lib/librte_ethdev/rte_ethdev_core.h >>>> @@ -234,6 +234,22 @@ typedef int (*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. */ >>>> >>>> +/** >>>> + * @internal >>>> + * Inform Ethernet device about reduced range of packet types to handle. >>>> + * >>>> + * @param dev >>>> + * The Ethernet device identifier. >>>> + * @param ptype_mask >>>> + * The ptype family that application is interested in should be bitwise OR of >>>> + * RTE_PTYPE_*_MASK or 0. >>>> + * @return >>>> + * - (0) if Success. >>>> + * - (-EINVAL) if *ptype_mask* is invalid. >>>> + */ >>>> +typedef int (*eth_dev_ptypes_set_t)(struct rte_eth_dev *dev, >>>> + uint32_t ptype_mask); >>>> + >>>> 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. */ >>>> @@ -630,6 +646,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_ptypes_set_t dev_ptypes_set; >>>> + /**< Inform Ethernet device about reduced range of packet types to handle. */ >>>> >>>> vlan_filter_set_t vlan_filter_set; /**< Filter VLAN Setup. */ >>>> vlan_tpid_set_t vlan_tpid_set; /**< Outer/Inner VLAN TPID Setup. */ >>>> diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map >>>> index ee289ef13..ccfbeae23 100644 >>>> --- a/lib/librte_ethdev/rte_ethdev_version.map >>>> +++ b/lib/librte_ethdev/rte_ethdev_version.map >>>> @@ -292,4 +292,5 @@ EXPERIMENTAL { >>>> rte_flow_dynf_metadata_offs; >>>> rte_flow_dynf_metadata_mask; >>>> rte_flow_dynf_metadata_register; >>>> + rte_eth_dev_set_ptypes; >>>> }; >>>> >>