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 25D14A0093; Fri, 23 Dec 2022 00:25:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2253742D35; Fri, 23 Dec 2022 00:25:00 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id D2CB442D1A for ; Fri, 23 Dec 2022 00:24:57 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BMH0ExE027040; Thu, 22 Dec 2022 15:24:57 -0800 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-transfer-encoding : content-type; s=pfpt0220; bh=vT+bmdgT70fTgc+V//R+oBjuhCMUYW8ckf9NSjvHz3U=; b=b7b0WulJyxVcbLrHD3J/w9hpXCY8URmPJTy0JCM5zZA/MyJkRlM50RcHVumUJAoswpjx PpydAsSHJgrR+OjacF9GxMjSTZ4WerwXUPMd/W8NlcpZNx70zDGB1Ju1Yp0PzwDv/P+n OdZ3OILuYOeqq6k3dZNAfZpa32Vf8fJ0bIcCeDpWCZ1Gw9rW26VdTY6tmNahsByeBZGp TcehrTwlesRxVDpjiHpVNDOb7Ra9SAaWjuMNIstyrpe5OF6NO1gIDUMLDO9Ka2Hc2b9I KBinZhhm6RKA2rRyUDvK4yFtbChVoVCDRm5I6vyf3CE2wUpxAvCUOui0wYm6VREaFqGx HA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3mhe5runy5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 22 Dec 2022 15:24:57 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 22 Dec 2022 15:24:55 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Thu, 22 Dec 2022 15:24:55 -0800 Received: from localhost.localdomain (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id BE82B3F7052; Thu, 22 Dec 2022 15:24:53 -0800 (PST) From: Tomasz Duszynski To: CC: , , Tomasz Duszynski Subject: [RFC PATCH 6/7] raw/vfio_platform: support rawdev device info Date: Fri, 23 Dec 2022 00:24:34 +0100 Message-ID: <20221222232436.643514-7-tduszynski@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221222232436.643514-1-tduszynski@marvell.com> References: <20221222232436.643514-1-tduszynski@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: h32Qf6Qs5DizGqdDuq67URX8QxnRZtdB X-Proofpoint-ORIG-GUID: h32Qf6Qs5DizGqdDuq67URX8QxnRZtdB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-22_10,2022-12-22_03,2022-06-22_01 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 Add support for querying rawdev device info. Signed-off-by: Tomasz Duszynski --- .../raw/vfio_platform/rte_pmd_vfio_platform.h | 34 ++++++++++++++ drivers/raw/vfio_platform/vfio_platform.c | 45 +++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/drivers/raw/vfio_platform/rte_pmd_vfio_platform.h b/drivers/raw/vfio_platform/rte_pmd_vfio_platform.h index b595171af6..377cebde08 100644 --- a/drivers/raw/vfio_platform/rte_pmd_vfio_platform.h +++ b/drivers/raw/vfio_platform/rte_pmd_vfio_platform.h @@ -17,6 +17,40 @@ extern "C" { #endif +#include +#include + +/** + * vfio platform device region info + * + * Caller uses that to retrieve information about device memory regions. + * Caller provides either resource name or an index, both of which can + * be extracted from the device tree. The former is equivalent to + * 'reg-names' property while the latter is a 0-based index into 'reg' + * array. + */ +struct vfio_platform_dev_region_info { + /**< mmapped memory resource */ + struct rte_mem_resource mem; + /**< name of the resource */ + const char *name; + /**< index of the resource */ + int index; +}; + +enum vfio_platform_info { + INFO_REGION_INDEX, + INFO_REGION_NAME, +}; + +/**< vfio platform device info */ +struct vfio_platform_dev_info { + /**< Type of device info */ + enum vfio_platform_info type; + /**< Memory region info */ + struct vfio_platform_dev_region_info reg_info; +}; + /** vfio platform device configuration */ struct vfio_platform_dev_config { /** logical value representing the vfio container */ diff --git a/drivers/raw/vfio_platform/vfio_platform.c b/drivers/raw/vfio_platform/vfio_platform.c index ab5b96a0b0..8148dce06b 100644 --- a/drivers/raw/vfio_platform/vfio_platform.c +++ b/drivers/raw/vfio_platform/vfio_platform.c @@ -94,6 +94,50 @@ rte_pmd_vfio_platform_container_destroy(int container) return 0; } +static int +vfio_rawdev_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info, + size_t dev_private_size) +{ + struct vfio_platform_dev_info *info = (struct vfio_platform_dev_info *)dev_info; + struct vfio_platform_dev_region_info *reg_info = &info->reg_info; + struct vfio_platform *plat = dev->dev_private; + int i; + + if (dev_private_size != sizeof(*info)) + return -EINVAL; + + if (plat->num_resource == 0) + return -ENODATA; + + switch (info->type) { + case INFO_REGION_INDEX: + if (reg_info->index < 0 || reg_info->index >= plat->num_resource) + return -EINVAL; + + i = reg_info->index; + break; + case INFO_REGION_NAME: + if (!reg_info->name) + return -EINVAL; + + for (i = 0; i < plat->num_resource; i++) { + if (!strcmp(reg_info->name, plat->resource[i].name)) + break; + } + + if (i == plat->num_resource) + return -ENODATA; + + break; + default: + return -EINVAL; + } + + memcpy(®_info->mem, &plat->resource[i].mem, sizeof(reg_info->mem)); + + return 0; +} + static char * of_resource_name(const char *dev_name, int index) { @@ -277,6 +321,7 @@ vfio_rawdev_dev_close(struct rte_rawdev *dev) } static const struct rte_rawdev_ops vfio_platform_rawdev_ops = { + .dev_info_get = vfio_rawdev_dev_info_get, .dev_configure = vfio_rawdev_dev_configure, .dev_close = vfio_rawdev_dev_close, }; -- 2.25.1