Received: by 10.223.185.116 with SMTP id b49csp1478789wrg; Wed, 21 Feb 2018 20:19:45 -0800 (PST) X-Google-Smtp-Source: AH8x226mBqPOVkU3p7XFJqu2elkfIlE4Y6i/89PmayIx/93tn93kZ553r4keabSz82mY7owgAEoa X-Received: by 2002:a17:902:9a98:: with SMTP id w24-v6mr5166147plp.188.1519273185434; Wed, 21 Feb 2018 20:19:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519273185; cv=none; d=google.com; s=arc-20160816; b=wKIoMZN7gDt7B9fdHv6FKuPcWeDuTGUgC/AYZCF/fU1YQSPaz7JnzgNdw3MB2uAl8m Lnttj94rVsutWkm+GP/5TV+vp4KEEXU1zsv8lMR5N93NPEVG76/m7nHw77+ZikD0TTe4 +ioA3EP1s8es7H8qRM86D0NDXzbrA3cKZPpM69v4GecDDhhkR4IpL1nhwRzcLoNHV7QZ CAF2QCUXZ7RW4pl++z498liDeCVi/z4DWJyk3Roxjvfkv2hpnMyzTqLS+3EICYGMz8jX oWVTOjRQ32oMrSRArKb8VHcH+mfni0mVdmKIcDdcmK7BX0obbcufedvnYWDErzJ3TUqg Qndg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=kvIUuC7fc/eohLdOKHQXiz4+/88cqty8rqWPJrycARs=; b=YknkCOrB9u5LFZl7pUN5XlurpGUNev7kURKvHEPh9X4PYmVVHJutG4lu+Z6Zsuy0qO npQz2XWYzTTYlHFGU0tp13UbEu8Lb4wkDiBaY3SRcJnyBpqhvplNTM3uQroVu0x9cIcl qFgpSbTq9RGEzZFHQP6s1NHNFC8dTepuECXuWhM78Yi9G1jrGBNqOo4/jDmVnB2UhVeo +V23QojbmjZ9w2ztWZsj7jSJkcghH5cdmZ6goz1/noT6yng7KVwsj/JbEJOQGZOYqS7j FYzX3eKm7mzRIU1jW1/+6TCFK0cfAS+k3uONi3kQAMU69vdNSYGRAx3Yq+B+038i3ffi KNrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11si675492pgu.96.2018.02.21.20.19.31; Wed, 21 Feb 2018 20:19:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752278AbeBVESa (ORCPT + 99 others); Wed, 21 Feb 2018 23:18:30 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40220 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752109AbeBVES1 (ORCPT ); Wed, 21 Feb 2018 23:18:27 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1M4FBJk059614 for ; Wed, 21 Feb 2018 23:18:27 -0500 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g9gga43x1-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 21 Feb 2018 23:18:27 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Feb 2018 04:18:24 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 22 Feb 2018 04:18:21 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1M4IL7l50462926; Thu, 22 Feb 2018 04:18:21 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C03DAE04D; Thu, 22 Feb 2018 04:09:14 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD604AE053; Thu, 22 Feb 2018 04:09:13 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Feb 2018 04:09:13 +0000 (GMT) Received: from adsilva.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 33B96A027B; Thu, 22 Feb 2018 15:18:19 +1100 (AEDT) From: "Alastair D'Silva" To: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org Cc: frederic.barrat@fr.ibm.com, andrew.donnellan@au1.ibm.com, arnd@arndb.de, gregkh@linuxfoundation.org, alastair@au1.ibm.com, "Alastair D'Silva" Subject: [PATCH v3 1/2] ocxl: Add get_metadata IOCTL to share OCXL information to userspace Date: Thu, 22 Feb 2018 15:17:38 +1100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180222041739.27899-1-alastair@au1.ibm.com> References: <20180222030334.14060-1-alastair@au1.ibm.com> <20180222041739.27899-1-alastair@au1.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18022204-0020-0000-0000-000003FA57FF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022204-0021-0000-0000-0000428E6B25 Message-Id: <20180222041739.27899-2-alastair@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-22_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802220053 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alastair D'Silva Some required information is not exposed to userspace currently (eg. the PASID), pass this information back, along with other information which is currently communicated via sysfs, which saves some parsing effort in userspace. Signed-off-by: Alastair D'Silva --- drivers/misc/ocxl/file.c | 27 +++++++++++++++++++++++++++ include/uapi/misc/ocxl.h | 17 +++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index d9aa407db06a..90df1be5ef3f 100644 --- a/drivers/misc/ocxl/file.c +++ b/drivers/misc/ocxl/file.c @@ -102,10 +102,32 @@ static long afu_ioctl_attach(struct ocxl_context *ctx, return rc; } +static long afu_ioctl_get_metadata(struct ocxl_context *ctx, + struct ocxl_ioctl_metadata __user *uarg) +{ + struct ocxl_ioctl_metadata arg; + + memset(&arg, 0, sizeof(arg)); + + arg.version = 0; + + arg.afu_version_major = ctx->afu->config.version_major; + arg.afu_version_minor = ctx->afu->config.version_minor; + arg.pasid = ctx->pasid; + arg.pp_mmio_size = ctx->afu->config.pp_mmio_stride; + arg.global_mmio_size = ctx->afu->config.global_mmio_size; + + if (copy_to_user(uarg, &arg, sizeof(arg))) + return -EFAULT; + + return 0; +} + #define CMD_STR(x) (x == OCXL_IOCTL_ATTACH ? "ATTACH" : \ x == OCXL_IOCTL_IRQ_ALLOC ? "IRQ_ALLOC" : \ x == OCXL_IOCTL_IRQ_FREE ? "IRQ_FREE" : \ x == OCXL_IOCTL_IRQ_SET_FD ? "IRQ_SET_FD" : \ + x == OCXL_IOCTL_GET_METADATA ? "GET_METADATA" : \ "UNKNOWN") static long afu_ioctl(struct file *file, unsigned int cmd, @@ -157,6 +179,11 @@ static long afu_ioctl(struct file *file, unsigned int cmd, irq_fd.eventfd); break; + case OCXL_IOCTL_GET_METADATA: + rc = afu_ioctl_get_metadata(ctx, + (struct ocxl_ioctl_metadata __user *) args); + break; + default: rc = -EINVAL; } diff --git a/include/uapi/misc/ocxl.h b/include/uapi/misc/ocxl.h index 4b0b0b756f3e..0af83d80fb3e 100644 --- a/include/uapi/misc/ocxl.h +++ b/include/uapi/misc/ocxl.h @@ -32,6 +32,22 @@ struct ocxl_ioctl_attach { __u64 reserved3; }; +struct ocxl_ioctl_metadata { + __u16 version; // struct version, always backwards compatible + + // Version 0 fields + __u8 afu_version_major; + __u8 afu_version_minor; + __u32 pasid; // PASID assigned to the current context + + __u64 pp_mmio_size; // Per PASID MMIO size + __u64 global_mmio_size; + + // End version 0 fields + + __u64 reserved[13]; // Total of 16*u64 +}; + struct ocxl_ioctl_irq_fd { __u64 irq_offset; __s32 eventfd; @@ -45,5 +61,6 @@ struct ocxl_ioctl_irq_fd { #define OCXL_IOCTL_IRQ_ALLOC _IOR(OCXL_MAGIC, 0x11, __u64) #define OCXL_IOCTL_IRQ_FREE _IOW(OCXL_MAGIC, 0x12, __u64) #define OCXL_IOCTL_IRQ_SET_FD _IOW(OCXL_MAGIC, 0x13, struct ocxl_ioctl_irq_fd) +#define OCXL_IOCTL_GET_METADATA _IOR(OCXL_MAGIC, 0x14, struct ocxl_ioctl_metadata) #endif /* _UAPI_MISC_OCXL_H */ -- 2.14.3