From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F3DD643B91; Fri, 23 Feb 2024 03:42:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D684140EE2; Fri, 23 Feb 2024 03:42:48 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2115.outbound.protection.outlook.com [40.107.244.115]) by mails.dpdk.org (Postfix) with ESMTP id 15D45402BD for ; Fri, 23 Feb 2024 03:42:45 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cD+f0QTsykdpk/oQZ9bSBqLO9ghHWZ7uZEqEU4RuA8E730k4ELTYBGEcWQtTgFBjkNkaGvGSzkALO3+XaQdplxaHGJ1YP6ogpc8ag5oLz8iTm9Ljnfod6P1o2+tcNZviqoPHAW2xQVKGhAX4/8f6zojQzzVXuGTojdIGdsL/Ex9dVb10n7WBSTxxxPy6614V+DDTobdl2TIdi93N1wXpMlN+pEyMxNs8HqzshPlRgZAnysVw2FxWPlNb+yvKOLdjqfr60EglRTjT/SsZW4j2LMq8IG5HBsvyuCVkbyjQnNqPSoxt3cx//Og9W6y5adicmbto4LdJ8sk/kC9GIfG/+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JFH4wKvSx9giSwoPGwdQLywUY6V4dcBXkPTxyndNlv4=; b=lK5CtOZtX7Tz14oLAriA6NcMsgbgLeb3770EyOCEpRM6VQVugsnHvuVWqr8ZLxfMnk1X4RWISD1JI7m9S2+o9E1CvlJR44t+FLMTOHtBCt/RTNfKnH0Kb5uJyYpV0whNkSiyZ3ovYj4zJNZXbprv6AaZ58S4GLwfC1H1oTACgwYwFhSD+ose7RrkW+i5cZ/YS5kCjKUll89Msp2/M55JAuiPxJuOifASHldM4ed4YoFmPT70r88m1QC95u+o/xK3rWbFmzu9/uJoTKXljS0Hix38Aq8Tq58XFsPcP4nrDsCQO74A3jRvQeDLEtsB5empCut6siLCwCOh0dtreF//Kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JFH4wKvSx9giSwoPGwdQLywUY6V4dcBXkPTxyndNlv4=; b=Z4WmUWh29ox7r0hgYmo5s9Uz3GJqYEM+qx/0IA0aYS/NwBce9NhsjNTAIH8M7wkyB3AKgVYkIBfpq0+BJ7R7vHipOgsCSpvaq9rqX5TjUgpzCiO75otcdNVzld5lgG2OMJUYVKw55Qya1OpVmlOaDEM9r18Za6AqkyvA6FUv+JA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by SA1PR13MB6645.namprd13.prod.outlook.com (2603:10b6:806:3e6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 23 Feb 2024 02:42:41 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::8e02:f738:570a:f8aa]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::8e02:f738:570a:f8aa%7]) with mapi id 15.20.7316.023; Fri, 23 Feb 2024 02:42:41 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , Chaoyong He , Peng Zhang Subject: [PATCH v2 1/4] ethdev: add function to check representor port Date: Fri, 23 Feb 2024 10:42:14 +0800 Message-Id: <20240223024217.3052031-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240223024217.3052031-1-chaoyong.he@corigine.com> References: <20240210104214.1248772-1-chaoyong.he@corigine.com> <20240223024217.3052031-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR13CA0040.namprd13.prod.outlook.com (2603:10b6:a03:2c2::15) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SA1PR13MB6645:EE_ X-MS-Office365-Filtering-Correlation-Id: d036617a-cfbd-44f5-517b-08dc34191926 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 70TZKbiPmbiFJmSBBENKSK0IXFuuom6GvtzjgI1IWS7vqqn8DjBt87iqg7hZW2BU9OZDDoDnIGIFGK0aBXIQsBf149ZcfAX2sRfSU3e/ZXy4Fe2gOUDVQstjomqtBJ23AddUcUbfdMKx4q6DQJnXV76QT1GYuv/jRJRE9DU2/zvi3oyoLwgABOD5ppmDJK7WOpheHAOLfCYRWksw3IrcJK0AUiKXBOGESdbUlg66dXAkg++TEAR4ccqFyYKsMLViHkD5tLLmghXeSHPraihTNWSsvI5Qj5i80NPXBUDLnQX71voJpLoY94VsDLEStGCKVv7gUEI0qrcGBxqUCb25+W9IEj2aX437k5MefoTq6tmU87u5onlN70bdKYx1YnXX7pYP1YJqwBtv5yypjRK9UEmZOi2e3spXmi6+/2WIclH5BRTp4fi8y+c2027uFLW4cVvpfEnTxDYMCC7y89jOQPXaNqYuSc4vuHiCEo8lC/4hC1TQEyPm0UBNIuzyECGiHBZH5gF2UrjLofFBQ6mLNak73xGYlgE7TloOQFBL7BdqY/IzwXXKqtcpTxuaTqSJomiy39MqtiPWhbK4D0c+4nrzmu3RA+xOhzTeyc4Ub5z9SErqpSVRGTgD40NFe5Kv X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Z/GIMLNckanP+g6vjWgqNwKoW5U7NfsdSEjy3MM9CYA23pVz8WQtgbkgldZB?= =?us-ascii?Q?Mk60ltEgAwEobRrRBLtIQNcUg/23Vfa4CXXn99jcQz0ycf5Zd2JmJW9y5WVP?= =?us-ascii?Q?aA8VALK4pPI+hK46S3y9/zjJeDbsC9vDdOxkNBzZ+IlQGNZg6XOe4/zrkPpg?= =?us-ascii?Q?jPSWHs60ETzk/Et/CrC/QA43JoH0/Sa8AAeBSz9kH8DyIZPEzvOgipWG/j0w?= =?us-ascii?Q?fm9z48FBg0iLdov6Oh91QoZXUTRCmavA433pr2k00dv9QArh4YAXPFyJA042?= =?us-ascii?Q?Uf8we2EqQYuLMgrz3S3z2r798dC9Gv/OWjweKK4TvCWQTJ2GpxnDMLXQm4mr?= =?us-ascii?Q?hw4u+xgjjIUyxf9Xjp+tbYH/TRMHM5PHRH+9oOWZBVhL8A0jnJL2TWa13kVZ?= =?us-ascii?Q?FYyBimjsunXdNi5BxEcDxEUgO8X6orpxgOsAIX4V1E1aOYPbRewRLqDaCydw?= =?us-ascii?Q?Y8T5+vN/s5Rk+Kwbve9x/kmS2OQ/xtvABUhDxC8XHBS1wC1oiShXjZ4IDP3y?= =?us-ascii?Q?1/5YGI7s3HbveCPJZTJOep4N9Cf0CA7vWMasXgOYpfWwBq/DiKif0YzCDmqM?= =?us-ascii?Q?phIO1i/xtYBFLBoeyCs1lxWlkhRv8pLs4Pw7mw8UueM7nPyAOVQB3zuWPwY4?= =?us-ascii?Q?40u8qIMjjPd4od4on5ujFzR/pG38eGLa2n+Qv+tri04tnRD4d7Wt1hsU09hk?= =?us-ascii?Q?BS8ijOZs7GxJ1YjY2iBt5VNKPWKV9437xYNHl2AyIpeYsroG4y4UX/s21iZn?= =?us-ascii?Q?mr6JhUftiI7JTXcnKJyhpLsRIfIe8ruh4xPXtSEV4IOywvEaujRdjHOB8BRn?= =?us-ascii?Q?P7ObW9z776cjYE0Les2sxssIXWsGH9+UWqLqmaomeDRZa10JoKF6wlAgHrme?= =?us-ascii?Q?t93AparqZqnVx/ZfnwxCWdyenstvkxDfoOz5mFaI0eCvmz3nowrz3HdZpmn1?= =?us-ascii?Q?1RRAxXxh3zU1oc0VPZ2Evo9ornbJfEMRmjSg1UrteKC7LgLY41TKBdPqVsDV?= =?us-ascii?Q?p/3V721C+YLNUdqGZRyJNZbkSQU0YczCGMx7t9tJKsWOMnppIB+wyYjSMYTb?= =?us-ascii?Q?wNZl08x4CjNTRkEjY+gSDZR/3jxF1equ6Cge6F+UVoKB1bzRhXYiAE3aP9Bh?= =?us-ascii?Q?3IryULDu9unQ6RIpg+XHS68gGGaPl1jKzd8Hm0ENAD0aWoItVmc8Qn0X1plZ?= =?us-ascii?Q?/S+dyH6ccGmkymMdrg3cimGTYXnFxsip7hDxyZ/A87JMpEgTumLupsvFTyeP?= =?us-ascii?Q?UuvE8ed+meiyfsQG9uoljEYMWZu/VhvwYlTIHKtkbdHz/8NHZ1c6qJEuwTiy?= =?us-ascii?Q?ektHJ4b1CWtcLdTvzbLiyaXKqrCyB3cb3KX73ZbX05G+716ygigjPYddnd5H?= =?us-ascii?Q?rBAKQXcEH/0Jn2EKWZg9L5YsijCYiiljV6Av1YYo/jbTju+KG2RQgIWUKKHL?= =?us-ascii?Q?hw0iHXUTJPtF6Dlvlka65Lt8g/3icepTkY+6U4YsVoiKZglky7MexCd+AgYi?= =?us-ascii?Q?gzIz00UA0AgSzSeq+Zj4iVTO87YExfTdiW60fn6QeRqZ51ZKfbFtJFafy20y?= =?us-ascii?Q?dL41z+oK3z3Y+WU31k6M2JKJCEIa2J0sAwOocLMq7wr44kPSnbItd8uCZDwG?= =?us-ascii?Q?/g=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: d036617a-cfbd-44f5-517b-08dc34191926 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 02:42:38.3606 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ch6W/0PEG0SjY3AdWyGqCxRwOfG/e1j9Dkj5/wcLEEzrtTdyZgZZO3oPqhSxi/XJ4/4GMwkbdkysPr85eM3S/XRTgIxMC/MlvMvLNuIeSus= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR13MB6645 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Long Wu Add a function to check if a device is representor port, also modified the related codes for PMDs. Signed-off-by: Long Wu Reviewed-by: Chaoyong He Reviewed-by: Peng Zhang --- doc/guides/rel_notes/release_24_03.rst | 3 +++ drivers/net/bnxt/bnxt.h | 3 --- drivers/net/bnxt/bnxt_ethdev.c | 4 ++-- drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c | 12 ++++++------ drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 4 ++-- drivers/net/bnxt/tf_ulp/ulp_def_rules.c | 4 ++-- drivers/net/cpfl/cpfl_representor.c | 2 +- drivers/net/enic/enic.h | 5 ----- drivers/net/enic/enic_ethdev.c | 2 +- drivers/net/enic/enic_fm_flow.c | 20 ++++++++++---------- drivers/net/enic/enic_main.c | 4 ++-- drivers/net/i40e/i40e_ethdev.c | 2 +- drivers/net/ice/ice_dcf_ethdev.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/nfp/flower/nfp_flower_flow.c | 2 +- drivers/net/nfp/nfp_mtr.c | 2 +- drivers/net/nfp/nfp_net_common.c | 4 ++-- drivers/net/nfp/nfp_net_flow.c | 2 +- lib/ethdev/ethdev_driver.h | 17 +++++++++++++++++ 19 files changed, 54 insertions(+), 42 deletions(-) diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst index 879bb4944c..8178417b98 100644 --- a/doc/guides/rel_notes/release_24_03.rst +++ b/doc/guides/rel_notes/release_24_03.rst @@ -185,6 +185,9 @@ API Changes * ethdev: Renamed structure ``rte_flow_action_modify_data`` to be ``rte_flow_field_data`` for more generic usage. +* ethdev: Add new function ``rte_eth_dev_is_repr()`` to check if a device is + representor port. + ABI Changes ----------- diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index fcf2b8be97..82036a16a1 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -1204,9 +1204,6 @@ extern const struct rte_flow_ops bnxt_flow_meter_ops; } \ } while (0) -#define BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev) \ - ((eth_dev)->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) - extern int bnxt_logtype_driver; #define RTE_LOGTYPE_BNXT bnxt_logtype_driver #define PMD_DRV_LOG_RAW(level, fmt, args...) \ diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index f8d83662f4..825e9c1941 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -3525,7 +3525,7 @@ bnxt_flow_ops_get_op(struct rte_eth_dev *dev, if (!bp) return -EIO; - if (BNXT_ETH_DEV_IS_REPRESENTOR(dev)) { + if (rte_eth_dev_is_repr(dev)) { struct bnxt_representor *vfr = dev->data->dev_private; bp = vfr->parent_dev->data->dev_private; /* parent is deleted while children are still valid */ @@ -6781,7 +6781,7 @@ static int bnxt_pci_remove(struct rte_pci_device *pci_dev) PMD_DRV_LOG(DEBUG, "BNXT Port:%d pci remove\n", eth_dev->data->port_id); if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - if (eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) + if (rte_eth_dev_is_repr(eth_dev)) return rte_eth_dev_destroy(eth_dev, bnxt_representor_uninit); else diff --git a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c index 239191e14e..96d61c3ed2 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c @@ -202,7 +202,7 @@ bnxt_pmd_get_svif(uint16_t port_id, bool func_svif, struct bnxt *bp; eth_dev = &rte_eth_devices[port_id]; - if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) { + if (rte_eth_dev_is_repr(eth_dev)) { struct bnxt_representor *vfr = eth_dev->data->dev_private; if (!vfr) return 0; @@ -260,7 +260,7 @@ bnxt_pmd_get_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type) struct bnxt *bp; eth_dev = &rte_eth_devices[port]; - if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) { + if (rte_eth_dev_is_repr(eth_dev)) { struct bnxt_representor *vfr = eth_dev->data->dev_private; if (!vfr) return 0; @@ -285,7 +285,7 @@ bnxt_pmd_get_fw_func_id(uint16_t port, enum bnxt_ulp_intf_type type) struct bnxt *bp; eth_dev = &rte_eth_devices[port]; - if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) { + if (rte_eth_dev_is_repr(eth_dev)) { struct bnxt_representor *vfr = eth_dev->data->dev_private; if (!vfr) return 0; @@ -308,7 +308,7 @@ bnxt_pmd_get_interface_type(uint16_t port) struct bnxt *bp; eth_dev = &rte_eth_devices[port]; - if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) + if (rte_eth_dev_is_repr(eth_dev)) return BNXT_ULP_INTF_TYPE_VF_REP; bp = eth_dev->data->dev_private; @@ -330,7 +330,7 @@ bnxt_pmd_get_phy_port_id(uint16_t port_id) struct bnxt *bp; eth_dev = &rte_eth_devices[port_id]; - if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) { + if (rte_eth_dev_is_repr(eth_dev)) { vfr = eth_dev->data->dev_private; if (!vfr) return 0; @@ -350,7 +350,7 @@ bnxt_pmd_get_parif(uint16_t port_id, enum bnxt_ulp_intf_type type) struct bnxt *bp; eth_dev = &rte_eth_devices[port_id]; - if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) { + if (rte_eth_dev_is_repr(eth_dev)) { struct bnxt_representor *vfr = eth_dev->data->dev_private; if (!vfr) return 0; diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index 274e935a1f..33028c470f 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -1559,7 +1559,7 @@ bnxt_ulp_destroy_vfr_default_rules(struct bnxt *bp, bool global) struct rte_eth_dev *vfr_eth_dev; struct bnxt_representor *vfr_bp; - if (!BNXT_TRUFLOW_EN(bp) || BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev)) + if (!BNXT_TRUFLOW_EN(bp) || rte_eth_dev_is_repr(bp->eth_dev)) return; if (!bp->ulp_ctx || !bp->ulp_ctx->cfg_data) @@ -2316,7 +2316,7 @@ bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev) { struct bnxt *bp = (struct bnxt *)dev->data->dev_private; - if (BNXT_ETH_DEV_IS_REPRESENTOR(dev)) { + if (rte_eth_dev_is_repr(dev)) { struct bnxt_representor *vfr = dev->data->dev_private; bp = vfr->parent_dev->data->dev_private; diff --git a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c index fe1f65deb9..8237dbd294 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c +++ b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c @@ -449,7 +449,7 @@ bnxt_ulp_destroy_df_rules(struct bnxt *bp, bool global) uint16_t port_id; if (!BNXT_TRUFLOW_EN(bp) || - BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev)) + rte_eth_dev_is_repr(bp->eth_dev)) return; if (!bp->ulp_ctx || !bp->ulp_ctx->cfg_data) @@ -514,7 +514,7 @@ bnxt_ulp_create_df_rules(struct bnxt *bp) int rc = 0; if (!BNXT_TRUFLOW_EN(bp) || - BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev) || !bp->ulp_ctx) + rte_eth_dev_is_repr(bp->eth_dev) || !bp->ulp_ctx) return 0; port_id = bp->eth_dev->data->port_id; diff --git a/drivers/net/cpfl/cpfl_representor.c b/drivers/net/cpfl/cpfl_representor.c index e2ed9eda04..60b72b5ec1 100644 --- a/drivers/net/cpfl/cpfl_representor.c +++ b/drivers/net/cpfl/cpfl_representor.c @@ -339,7 +339,7 @@ cpfl_repr_link_update(struct rte_eth_dev *ethdev, struct cpfl_vport_id vi; int ret; - if (!(ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) { + if (!rte_eth_dev_is_repr(ethdev)) { PMD_INIT_LOG(ERR, "This ethdev is not representor."); return -EINVAL; } diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index 78778704f2..f46903ea9e 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -233,11 +233,6 @@ struct enic_vf_representor { #define VF_ENIC_TO_VF_REP(vf_enic) \ container_of(vf_enic, struct enic_vf_representor, enic) -static inline int enic_is_vf_rep(struct enic *enic) -{ - return !!(enic->rte_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR); -} - /* Compute ethdev's max packet size from MTU */ static inline uint32_t enic_mtu_to_max_rx_pktlen(uint32_t mtu) { diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 7e040c36c4..cad8db2f6f 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -1386,7 +1386,7 @@ static int eth_enic_pci_remove(struct rte_pci_device *pci_dev) ethdev = rte_eth_dev_allocated(pci_dev->device.name); if (!ethdev) return -ENODEV; - if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) + if (rte_eth_dev_is_repr(ethdev)) return rte_eth_dev_destroy(ethdev, enic_vf_representor_uninit); else return rte_eth_dev_destroy(ethdev, eth_enic_dev_uninit); diff --git a/drivers/net/enic/enic_fm_flow.c b/drivers/net/enic/enic_fm_flow.c index 90027dc676..8988148454 100644 --- a/drivers/net/enic/enic_fm_flow.c +++ b/drivers/net/enic/enic_fm_flow.c @@ -1535,14 +1535,14 @@ vf_egress_port_id_action(struct enic_flowman *fm, ENICPMD_FUNC_TRACE(); src_enic = fm->user_enic; dst_enic = pmd_priv(dst_dev); - if (!(src_enic->rte_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) { + if (!rte_eth_dev_is_repr(src_enic->rte_dev)) { return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "source port is not VF representor"); } /* VF -> PF uplink. dst is not VF representor */ - if (!(dst_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) { + if (!rte_eth_dev_is_repr(dst_dev)) { /* PF is the VF's PF? Then nothing to do */ vf = VF_ENIC_TO_VF_REP(src_enic); if (vf->pf == dst_enic) { @@ -1954,7 +1954,7 @@ enic_fm_copy_action(struct enic_flowman *fm, if (!(overlap & (FATE | PASSTHRU | COUNT | PORT_ID))) goto unsupported; /* Egress from VF: need implicit WQ match */ - if (enic_is_vf_rep(enic) && !ingress) { + if (rte_eth_dev_is_repr(enic->rte_dev) && !ingress) { fmt->ftm_data.fk_wq_id = 0; fmt->ftm_mask.fk_wq_id = 0xffff; fmt->ftm_data.fk_wq_vnic = enic->fm_vnic_handle; @@ -3226,7 +3226,7 @@ enic_fm_init(struct enic *enic) return 0; ENICPMD_FUNC_TRACE(); /* Get vnic handle and save for port-id action */ - if (enic_is_vf_rep(enic)) + if (rte_eth_dev_is_repr(enic->rte_dev)) addr = &VF_ENIC_TO_VF_REP(enic)->bdf; else addr = &RTE_ETH_DEV_TO_PCI(enic->rte_dev)->addr; @@ -3240,7 +3240,7 @@ enic_fm_init(struct enic *enic) enic->fm_vnic_uif = vnic_dev_uif(enic->vdev); ENICPMD_LOG(DEBUG, "uif %u", enic->fm_vnic_uif); /* Nothing else to do for representor. It will share the PF flowman */ - if (enic_is_vf_rep(enic)) + if (rte_eth_dev_is_repr(enic->rte_dev)) return 0; fm = calloc(1, sizeof(*fm)); if (fm == NULL) { @@ -3321,7 +3321,7 @@ enic_fm_destroy(struct enic *enic) struct enic_fm_fet *fet; ENICPMD_FUNC_TRACE(); - if (enic_is_vf_rep(enic)) { + if (rte_eth_dev_is_repr(enic->rte_dev)) { delete_rep_flows(enic); return; } @@ -3358,7 +3358,7 @@ enic_fm_allocate_switch_domain(struct enic *pf) int ret; ENICPMD_FUNC_TRACE(); - if (enic_is_vf_rep(pf)) + if (rte_eth_dev_is_repr(pf->rte_dev)) return -EINVAL; cur = pf; cur_a = &RTE_ETH_DEV_TO_PCI(cur->rte_dev)->addr; @@ -3367,7 +3367,7 @@ enic_fm_allocate_switch_domain(struct enic *pf) dev = &rte_eth_devices[pid]; if (!dev_is_enic(dev)) continue; - if (dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) + if (rte_eth_dev_is_repr(dev)) continue; if (dev == cur->rte_dev) continue; @@ -3597,7 +3597,7 @@ delete_rep_flows(struct enic *enic) struct rte_eth_dev *dev; uint32_t i; - RTE_ASSERT(enic_is_vf_rep(enic)); + RTE_ASSERT(rte_eth_dev_is_repr(enic->rte_dev)); vf = VF_ENIC_TO_VF_REP(enic); dev = vf->pf->rte_dev; for (i = 0; i < ARRAY_SIZE(vf->vf2rep_flow); i++) { @@ -3617,7 +3617,7 @@ begin_fm(struct enic *enic) struct enic_flowman *fm; /* Representor uses PF flowman */ - if (enic_is_vf_rep(enic)) { + if (rte_eth_dev_is_repr(enic->rte_dev)) { vf = VF_ENIC_TO_VF_REP(enic); fm = vf->pf->fm; } else { diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index a6aaa760ca..2f681315b6 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -824,7 +824,7 @@ int enic_alloc_rq(struct enic *enic, uint16_t queue_idx, * Representor uses a reserved PF queue. Translate representor * queue number to PF queue number. */ - if (enic_is_vf_rep(enic)) { + if (rte_eth_dev_is_repr(enic->rte_dev)) { RTE_ASSERT(queue_idx == 0); vf = VF_ENIC_TO_VF_REP(enic); sop_queue_idx = vf->pf_rq_sop_idx; @@ -1053,7 +1053,7 @@ int enic_alloc_wq(struct enic *enic, uint16_t queue_idx, * Representor uses a reserved PF queue. Translate representor * queue number to PF queue number. */ - if (enic_is_vf_rep(enic)) { + if (rte_eth_dev_is_repr(enic->rte_dev)) { RTE_ASSERT(queue_idx == 0); vf = VF_ENIC_TO_VF_REP(enic); queue_idx = vf->pf_wq_idx; diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 4d21341382..ddbc2962bc 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -706,7 +706,7 @@ static int eth_i40e_pci_remove(struct rte_pci_device *pci_dev) if (!ethdev) return 0; - if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) + if (rte_eth_dev_is_repr(ethdev)) return rte_eth_dev_pci_generic_remove(pci_dev, i40e_vf_representor_uninit); else diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index bebf356f4d..d58ec9d907 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -2131,7 +2131,7 @@ eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev) if (!eth_dev) return 0; - if (eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) + if (rte_eth_dev_is_repr(eth_dev)) return rte_eth_dev_pci_generic_remove(pci_dev, ice_dcf_vf_repr_uninit); else diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 0cd3d0b105..c61c52b296 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -1842,7 +1842,7 @@ static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev) if (!ethdev) return 0; - if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) + if (rte_eth_dev_is_repr(ethdev)) return rte_eth_dev_pci_generic_remove(pci_dev, ixgbe_vf_representor_uninit); else diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c index e26be30d18..501a8d87bd 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.c +++ b/drivers/net/nfp/flower/nfp_flower_flow.c @@ -4321,7 +4321,7 @@ int nfp_flow_ops_get(struct rte_eth_dev *dev, const struct rte_flow_ops **ops) { - if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) { + if (!rte_eth_dev_is_repr(dev)) { *ops = NULL; PMD_DRV_LOG(ERR, "Port is not a representor."); return -EINVAL; diff --git a/drivers/net/nfp/nfp_mtr.c b/drivers/net/nfp/nfp_mtr.c index 255977ec22..6abc6dc9bc 100644 --- a/drivers/net/nfp/nfp_mtr.c +++ b/drivers/net/nfp/nfp_mtr.c @@ -1066,7 +1066,7 @@ static const struct rte_mtr_ops nfp_mtr_ops = { int nfp_net_mtr_ops_get(struct rte_eth_dev *dev, void *arg) { - if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) { + if (!rte_eth_dev_is_repr(dev)) { PMD_DRV_LOG(ERR, "Port is not a representor"); return -EINVAL; } diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 99c319eb2d..0ee2811926 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -241,7 +241,7 @@ nfp_net_get_hw(const struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { + if (rte_eth_dev_is_repr(dev)) { struct nfp_flower_representor *repr; repr = dev->data->dev_private; hw = repr->app_fw_flower->pf_hw; @@ -2143,7 +2143,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, hw = nfp_net_get_hw(dev); - if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { + if (rte_eth_dev_is_repr(dev)) { snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d", hw->ver.extend, hw->ver.class, hw->ver.major, hw->ver.minor); diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c index 98e8499756..3b33f3b6e9 100644 --- a/drivers/net/nfp/nfp_net_flow.c +++ b/drivers/net/nfp/nfp_net_flow.c @@ -932,7 +932,7 @@ nfp_net_flow_ops_get(struct rte_eth_dev *dev, { struct nfp_net_hw *hw; - if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { + if (rte_eth_dev_is_repr(dev)) { *ops = NULL; PMD_DRV_LOG(ERR, "Port is a representor."); return -EINVAL; diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 0e4c1f0743..f46c102558 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -2120,6 +2120,23 @@ struct rte_eth_fdir_conf { struct rte_eth_fdir_flex_conf flex_conf; }; +/** + * @internal + * Check if the ethdev is a representor port. + * + * @param dev + * Pointer to struct rte_eth_dev. + * + * @return + * false the ethdev is not a representor port. + * true the ethdev is a representor port. + */ +static inline bool +rte_eth_dev_is_repr(const struct rte_eth_dev *dev) +{ + return ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0); +} + #ifdef __cplusplus } #endif -- 2.39.1