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 49D84A0471 for ; Fri, 16 Aug 2019 07:55:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DCCF81BEC3; Fri, 16 Aug 2019 07:55:21 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 93BBCA69 for ; Fri, 16 Aug 2019 07:55:19 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7G5tBSl020398; Thu, 15 Aug 2019 22:55:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pfpt0818; bh=M8gsWcWkpP1hFhqA5DjN0hsHRsg7a4mDalbgWe7A4yI=; b=vYA6Yw3KHvPbX+SCPCmgoT0wnZlxRQ/6xuI5vIxzNq8h2BcJjvsM6EKOued6Uf77+fbu zbbOTnDHtJaPMi2V0NM2y7X5NH5cgqXF2qTkHJUOz40YRz0/VtRu5r91Ms5ncGKq2SdB ZwUwpK2tt3kXygzmhJ60SuAvA2vaCcyrk7wsJYKalrIsZ0MsWNwI6XxlYAWy2lV5wakM E5/Qq1kdbrJo4rD92sJYh0dWdD9+Dv+c/RY+iZ7nNa9h3DccjTwZ9zqinOmJTV1zGUPN G24199/XgWp9uLWpkXkiYD1CkRp2/4rqjTbO/sbu5c7hd00+7RfYPem/7yfg9xiNwa71 0Q== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2udefw1jk6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 15 Aug 2019 22:55:18 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 15 Aug 2019 22:55:17 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 15 Aug 2019 22:55:17 -0700 Received: from BG-LT7430.marvell.com (bg-lt7430.marvell.com [10.28.10.255]) by maili.marvell.com (Postfix) with ESMTP id D6B593F703F; Thu, 15 Aug 2019 22:55:14 -0700 (PDT) From: To: , , John McNamara , Marko Kovacevic , Thomas Monjalon , Andrew Rybchenko CC: , Pavan Nikhilesh Date: Fri, 16 Aug 2019 11:25:04 +0530 Message-ID: <20190816055511.2322-2-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190816055511.2322-1-pbhagavatula@marvell.com> References: <20190816055511.2322-1-pbhagavatula@marvell.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-16_03:2019-08-14,2019-08-16 signatures=0 Subject: [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" 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. -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) + 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; + + 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); /** * 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