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 54ACF433B9 for ; Fri, 24 Nov 2023 15:09:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B4AE432C8; Fri, 24 Nov 2023 15:09:17 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id F3E5D40283; Fri, 24 Nov 2023 15:09:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700834954; x=1732370954; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=Z6dlZy6XZXeYB5mFXjnaWBeULB6WED91R7XJ85kWGsQ=; b=Xt9h5QKSbZn8ZjBKdWViZ17w1GiRTOHd0w/RZd+Gzh3UZ3TLCP33DRdK /3ulv3QMYVdTrTv7HKlAkCnTIZTlIk6Mde5OOa/QMqCwl/m+8CbZtD20F cfCh3Th5MgBhmefTDiUH8TQy2jqcHbqakDD6hbETibjcQIIT8xAudgOCB jjl2V1QgaZ9Ff+/JzkZKBAeYz5qRYGHDjy5quoMe/NWWwq1xJSRaQBr4A GlSj0V175SLp4y/MQMy0T1/xRAR6MFZhXPNR0P0NA/4IdBe0kjng/vCtj TsrVgwtI2QB753GtQRGLB//XGJez0Eqq56fn6UlPMbIgQcpORTkWqKZ40 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10904"; a="372591766" X-IronPort-AV: E=Sophos;i="6.04,224,1695711600"; d="scan'208";a="372591766" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2023 06:09:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10904"; a="858398985" X-IronPort-AV: E=Sophos;i="6.04,224,1695711600"; d="scan'208";a="858398985" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by FMSMGA003.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 24 Nov 2023 06:09:12 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 24 Nov 2023 06:09:11 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 24 Nov 2023 06:09:11 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Fri, 24 Nov 2023 06:09:11 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Fri, 24 Nov 2023 06:09:11 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JYiYyDHDclPhdrv+VdK/dJ/5COYqFqJlnNmhtXCCXDH3mUwjzzbbTVUXowOWS3lEgPwk6eQAyvr3Xru2d3ybZb2KDKFR540bCUHUFGsKw0qF90z0PT5m3EJ4TyHGSUWoyF89RkPXjx1z0MZnjgf2S/x5o4l4o/gWF0YuQNu4SAbcTlMvCh3puvP4C6npcz4Oa5+YS53k2t6yAGNEm5exwLxx5B668pgFlxN/0B1P3Kj9HmvGG2CbpqdUkXFTxCPJDhbmbbNcZVNklVlFskeuzkhv2TVX2ov8pX1ox26UQCRA4RABELREZrOHvlE1ivnr1NKl/spA0IwlcFLGELJ76A== 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=q8i/r7hRsqt27fO+KBezn09F2mHMn+oeNzZun8/ffc8=; b=evDUtWRV1CZhiwDdljGulRd+F84CVVDAWzm+dAfQvfDjgj81/Z+zt5z0j6Nn0AQc4WhhcwXr/73bNjMIXYdgaTCJlJXvIW2vuU9hIo+lKzpEfx+yF6FM4ROBi67Gn2WfcBaxHsxLM6l807QsGsK2bQLhpqu8n4x/104A2Y956YngxfSUB1RFntOwHWYmIFryvLX89yMf1zziUwvIqv/9D54f0KayynIyMhiOLa9qUEYbiuxzzRgeeeNaI6gBmMjX7tf11H+wVzx1zymh/Udx4gVoUXriM+sspUSexvXZtKTd8IXvLTss9g7Atf2MKz06x8Fw2s5mLfMQkSug+lmVxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB6502.namprd11.prod.outlook.com (2603:10b6:8:89::7) by CH0PR11MB5476.namprd11.prod.outlook.com (2603:10b6:610:d7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.21; Fri, 24 Nov 2023 14:09:09 +0000 Received: from DM4PR11MB6502.namprd11.prod.outlook.com ([fe80::550f:7dff:c595:98e1]) by DM4PR11MB6502.namprd11.prod.outlook.com ([fe80::550f:7dff:c595:98e1%5]) with mapi id 15.20.7025.020; Fri, 24 Nov 2023 14:09:09 +0000 Message-ID: Date: Fri, 24 Nov 2023 15:09:03 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.15.1 Subject: Re: [PATCH] vfio: add get device info API To: Mingjin Ye , CC: , References: <20231114104816.527818-1-mingjinx.ye@intel.com> Content-Language: en-US From: "Burakov, Anatoly" In-Reply-To: <20231114104816.527818-1-mingjinx.ye@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P123CA0050.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::14) To DM4PR11MB6502.namprd11.prod.outlook.com (2603:10b6:8:89::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB6502:EE_|CH0PR11MB5476:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b37ab4f-6050-406f-59dc-08dbecf6ed2f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jdRszwHA0b9Gy0CNSlyGmb4GWDbs/NGFQ5TMoWQdsBNiAHgRHelz4+HDAtt936j1Fbe3fAyWxh6PES/EXt3Sp+9E5RCvDrQt3k+mEVWhJ4RBUQ9gAg6O8JiLsT/z+P9DttolPfG7L5WuvCTJ8d2odR+rKur1AISdIRkrscTCSrwD9A3yYLhd6piPo2XEJD4oNnq8wnjHmXY/4dGoEnQYqjKq43nW21FZIOdkuFqzFbuFU/4XUiXhWSiP0HAMA0ECla5/Uv58VuVULBak81y74OYuuUbyssXYdtMJNi0BV2x0poM94PQTmULcjIncCEqwGxTiruIeFwcZ98eJSH4cRwjnvm4d6ZgdTvGD4Ja+SjZN3bkKFzRreeo1ox9ZCzClWFTmo0Rr60B6BiWMlwRiSkqzZdlFw77MXAdDcDxWvOuBLos8urEtUhHDOSrP9LVZIbGfULWsTcfOZ2p7G3XgGMSv3ISIHpYFjE4LKbUiMev94I7Vv1J6vv5CsFcNnYpSTX2MzXBrpiSCAEJFms4CZW4n31Am02Qtyur9DC+UCVQxJX/EgRKkOD5M6X+1YP9mrrfk9ISl5Mhwy+iek4GPcHfefQxJjp8udlwa7xs7kFqTdojwTs4aFPPQZJjsVGyPz5koKjLkQbb1i9YqGM5jpQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB6502.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376002)(346002)(366004)(39860400002)(396003)(136003)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(38100700002)(6486002)(82960400001)(478600001)(41300700001)(8936002)(8676002)(4326008)(450100002)(86362001)(66476007)(66946007)(316002)(31696002)(66556008)(26005)(6506007)(2616005)(83380400001)(53546011)(6666004)(6512007)(36756003)(31686004)(2906002)(5660300002)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?T09CN1lrZFphanJXK21iOFU4azlMNlM4QTZnY3MwVkNVS3JTb2NObVgzeVcv?= =?utf-8?B?Mk9sb05pV1pEL213VzNhZS8xVEpnaHhNOE05Y1pJQm0yM3ZOOWpMMDlPeTNM?= =?utf-8?B?UE9qN0Y0MzZ5VkhGbGFQMGRNZklTTkk5WUZVdzVVRTkzZzlxQ01YWnF2MUNv?= =?utf-8?B?bTl1QzdBdk1XZng1dXVTemlVSUdHdllLMHZnSmZDTnJSb2ZPUmdJRTJsaUN1?= =?utf-8?B?aDBVZk1kZHNvTWtqRU1JWGQyVFp1YWFncXZoRGZraFNxNXVxSUt2bXp5VHZZ?= =?utf-8?B?SDFyS1IwS3ByTGwybzJ0WTdSQ29QUmhPT0E1MG43a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Hp4RlpTUEtoR1AveEFVbnMyRUYxb0c3T1Q3ZnVGaHpTMkdD?= =?utf-8?B?dFE9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5b37ab4f-6050-406f-59dc-08dbecf6ed2f X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB6502.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2023 14:09:08.9840 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vyg0DJc9MKEykm9Ud5fbnYhdvB+GlyssPI+cVpHqfEqb+y7scuXZpRU2xsn4a/oHa3Gvp+SoCPN/pbaJu0+hUGGcK1j/0Z1kQ1dwEAtupHo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR11MB5476 X-OriginatorOrg: intel.com X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On 11/14/2023 11:48 AM, Mingjin Ye wrote: > This patch adds an API to support getting device information. > > The driver can use the "rte_vfio_get_device_info" helper to get > device information from EAL. > > Cc: stable@dpdk.org > > Signed-off-by: Mingjin Ye > --- > lib/eal/include/rte_vfio.h | 26 ++++++++++++++++++++++++++ > lib/eal/linux/eal_vfio.c | 19 +++++++++++++++++++ > lib/eal/version.map | 1 + > 3 files changed, 46 insertions(+) > > diff --git a/lib/eal/include/rte_vfio.h b/lib/eal/include/rte_vfio.h > index 3487c4f2a2..b3f55963e3 100644 > --- a/lib/eal/include/rte_vfio.h > +++ b/lib/eal/include/rte_vfio.h > @@ -212,6 +212,32 @@ int > rte_vfio_get_group_num(const char *sysfs_base, > const char *dev_addr, int *iommu_group_num); > > +/** > + * Get device information > + * > + * This function is only relevant to linux and will return > + * an error on BSD. > + * > + * @param sysfs_base > + * sysfs path prefix. > + * > + * @param dev_addr > + * device location. > + * > + * @param vfio_dev_fd > + * VFIO fd. > + * > + * @param device_info > + * Device information. > + * > + * @return > + * 0 on success. > + * <0 on failure. > + */ > +int > +rte_vfio_get_device_info(const char *sysfs_base, const char *dev_addr, > + int *vfio_dev_fd, struct vfio_device_info *device_info); > + > /** > * Open a new VFIO container fd > * > diff --git a/lib/eal/linux/eal_vfio.c b/lib/eal/linux/eal_vfio.c > index ad3c1654b2..5810d9fcd7 100644 > --- a/lib/eal/linux/eal_vfio.c > +++ b/lib/eal/linux/eal_vfio.c > @@ -1222,6 +1222,25 @@ vfio_set_iommu_type(int vfio_container_fd) > return NULL; > } > > +int > +rte_vfio_get_device_info(const char *sysfs_base, const char *dev_addr, > + int *vfio_dev_fd, struct vfio_device_info *device_info) > +{ > + if (!device_info || *vfio_dev_fd < 0) > + return -1; Do we not need to check other parameters? E.g. sysfs_base, dev_addr, vfio_dev_fd itself (could be NULL dereference). > + > + if (*vfio_dev_fd == 0) { > + if (rte_vfio_setup_device(sysfs_base, dev_addr, > + vfio_dev_fd, device_info)) > + return -1; > + } else { > + if (ioctl(*vfio_dev_fd, VFIO_DEVICE_GET_INFO, &device_info)) > + return -1; > + } Couldn't this just be an `else if`? Would also be nice to have some DEBUG output here. With all of the above addressed, Acked-by: Anatoly Burakov > + > + return 0; > +} > + > int > vfio_has_supported_extensions(int vfio_container_fd) > { > diff --git a/lib/eal/version.map b/lib/eal/version.map > index e00a844805..8b4a9c237e 100644 > --- a/lib/eal/version.map > +++ b/lib/eal/version.map > @@ -300,6 +300,7 @@ DPDK_24 { > rte_vfio_noiommu_is_enabled; # WINDOWS_NO_EXPORT > rte_vfio_release_device; # WINDOWS_NO_EXPORT > rte_vfio_setup_device; # WINDOWS_NO_EXPORT > + rte_vfio_get_device_info; # WINDOWS_NO_EXPORT > rte_zmalloc; > rte_zmalloc_socket; > -- Thanks, Anatoly