From patchwork Wed Aug 21 20:47:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavan Nikhilesh Bhagavatula X-Patchwork-Id: 57782 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 888811BF1B; Wed, 21 Aug 2019 22:48:07 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 604301BF12 for ; Wed, 21 Aug 2019 22:48:05 +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 x7LKj8WD014341; Wed, 21 Aug 2019 13:48:04 -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=h2KdXtY6iRgb44Y8TqbdsIe1ooKWzxE2YAB7yws1hMw=; b=viVEERHGPx/tjcLXWge7fZpnx/x4Go7osVxPVY6p6JAM+kzRNOhV5xlugpQEYe9Nzh/u 0XTQqxJHexaB9J8EBV18ztJKlMrKF4RbhHk6ckCgtpjnLgztJvA6xjHWbWuvWHj4rzXj VzGJz/tTSkwKshVsfukfhc/LZDuhyHOt2OOmbjVeanTsLvwqyFStbTAdPWQ7Jrrd6xjc I19sn74x2BdS5p2AdZJxHBIJMZ968jPn71eXVgXYF0OS8XZ6Op4+lUNDiA6t4LuMyH8n lMTtbch9PMPfVMckiZ0MgSTxyz3fVq2uec0pNe6EWytR3rH0DKPDmpF6WNJIQBgvjKLa Cg== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2uhag20p9d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 21 Aug 2019 13:48:04 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 21 Aug 2019 13:48:02 -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; Wed, 21 Aug 2019 13:48:02 -0700 Received: from BG-LT7430.marvell.com (unknown [10.28.17.62]) by maili.marvell.com (Postfix) with ESMTP id 0A18B3F703F; Wed, 21 Aug 2019 13:47:59 -0700 (PDT) From: To: , , John McNamara , Marko Kovacevic , Thomas Monjalon , Ferruh Yigit CC: , Pavan Nikhilesh Date: Thu, 22 Aug 2019 02:17:49 +0530 Message-ID: <20190821204755.1990-2-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190821204755.1990-1-pbhagavatula@marvell.com> References: <20190821204755.1990-1-pbhagavatula@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-21_06:2019-08-19,2019-08-21 signatures=0 Subject: [dpdk-dev] [PATCH v2 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 ++++++--- doc/guides/rel_notes/release_19_11.rst | 7 ++++++ lib/librte_ethdev/rte_ethdev.c | 32 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 16 ++++++++++++ lib/librte_ethdev/rte_ethdev_core.h | 6 +++++ lib/librte_ethdev/rte_ethdev_version.map | 3 +++ 6 files changed, 72 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/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst index 8490d897c..a7cec1fe8 100644 --- a/doc/guides/rel_notes/release_19_11.rst +++ b/doc/guides/rel_notes/release_19_11.rst @@ -56,6 +56,13 @@ New Features Also, make sure to start the actual text at the margin. ========================================================= +* **Added API in ethdev to set supported packet types** + + * Added new API ``rte_eth_dev_set_supported_ptypes`` that allows an + application to request PMD to set specific ptypes defined + through ``rte_eth_dev_set_supported_ptypes`` in ``rte_mbuf::packet_type``. + * This scheme will allow PMDs to avoid lookup to internal ptype table on Rx + and thereby improve Rx performance if application wishes do so. Removed Items ------------- diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 17d183e1f..f529cbe9f 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -2602,6 +2602,38 @@ rte_eth_dev_get_supported_ptypes(uint16_t port_id, uint32_t ptype_mask, return j; } +uint32_t +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; + uint32_t supp_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_get, 0); + + if (ptype_mask == 0) { + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_supported_ptypes_set, + 0); + return (*dev->dev_ops->dev_supported_ptypes_set)(dev, + ptype_mask); + } + + all_ptypes = (*dev->dev_ops->dev_supported_ptypes_get)(dev); + if (all_ptypes == NULL) + return 0; + + for (i = 0; all_ptypes[i] != RTE_PTYPE_UNKNOWN; ++i) + all_ptype_mask |= all_ptypes[i]; + + supp_ptype_mask = all_ptype_mask & ptype_mask; + + return (*dev->dev_ops->dev_supported_ptypes_set)(dev, supp_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..1ab0af4d8 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -2431,6 +2431,22 @@ 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) Ptype mask that has been set successfully. + */ +__rte_experimental +uint32_t 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..e65ae983d 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 uint32_t (*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. */ diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index 6df42a47b..e14745b9c 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -283,4 +283,7 @@ EXPERIMENTAL { # added in 19.08 rte_eth_read_clock; + + # added in 19.11 + rte_eth_dev_set_supported_ptypes; };