From patchwork Mon Dec 16 03:08:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 181636 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp3799131ile; Sun, 15 Dec 2019 19:08:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwCjJz44EqdGepRkbyVR6YeHq5Z2fswjjgwGaFQHv9H1dXV6acSPTEI+Rp1qV+v3fwcLK1F X-Received: by 2002:a05:6830:1d1:: with SMTP id r17mr31242874ota.151.1576465737506; Sun, 15 Dec 2019 19:08:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576465737; cv=none; d=google.com; s=arc-20160816; b=ItxucIN7i/j0h/O0B0/rdGI4frmbsWU8e+ynfc5D0BfwUaiPBdHKQ2sYrCSbfFrO4g R0+Wl21g2nScvziUbRq+kCMhPy8yTfKHu8GQbcNzdsNr8mGi9QN+rMRV4gw9h1uvRaFb IjWZCTQ7fTzXbBeKPuDlWoN6k6ZWn5KhpafztT8giPKD8oRPoGGnO6PJh8I4FeKE2REM tOuhM9zzSWP4QUjzp4zLwprjBLRwPzV29baBMFZlfwnOxreoDRl2UEIaWUgscvzLHuwe JRXmNdI2w56K+ihd8c1WZNhm/dIeq4gBUzVyxqA+8oHX7+UqZeTfVGzhzW87NlditUfO /0aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=+pVRv0zmwM6r6qh3u7jefx+roN9IpRfJikQs29Fs7Mc=; b=qgjjqqYLkRfVglDndAGaGwO7/vxSPpQaGfwZpk/edAk2VZW6c/Bmt8fAVvy9xa+uKD t12dQDxhhxrhBqUTAPMXUjp0k1nwZ3EzZ7KKyslCNaxQJulytu6Zh/xDU6ySBZR4O0gu g/tNfdvynxf76vezEHoxwcLjiUwAVBOlPUlVjZX0qrdkxcVZkmt2RFTT0LIp28coq701 dF/UxH5Qu9P0o/Yx2Z1fNxqn9kZ/EXRkZ96sdWNMcA4ArdM70UOYgqmDunFRENlH1/SC +fnTa7lnhGYsvyOIsLkuxLXXlvLcHz1nQaXFIAEXR59TnNTEiKiRZRlzrqnShJZju3IR mOmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y51yvKbr; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v76si9466148oif.207.2019.12.15.19.08.57; Sun, 15 Dec 2019 19:08:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y51yvKbr; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726704AbfLPDI4 (ORCPT + 3 others); Sun, 15 Dec 2019 22:08:56 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41925 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726691AbfLPDI4 (ORCPT ); Sun, 15 Dec 2019 22:08:56 -0500 Received: by mail-pg1-f195.google.com with SMTP id x8so2809261pgk.8 for ; Sun, 15 Dec 2019 19:08:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+pVRv0zmwM6r6qh3u7jefx+roN9IpRfJikQs29Fs7Mc=; b=Y51yvKbrnD++XbXPywM5pMZt9Rl8HAHT6g3uKnBoSx38luv1lMjCByWZ9VlPl06/2S p+r5TUabfg4tKUmnrxlvt5DcCr/mOtyX+SPg7ZWBOPNwzAeZUh4lxllU1Tm3QpkqqMcR SuENlKwzq24z1a/U5bW8URWgduT6yjL9rHPMz3krEB1oIUpO3EByVEZJIAUBrJXXgVV1 B2uOutodhoP931SDkaC0E6GtfvkP6SoE1UgPa5knuo0axMfYlamSHQO4KpUAPKoFV6mo RnNUJMN4KLwXAEfX4sVONDQ7qdUEFFQ7fyevDnD+nMX3VAUMBfypKoTPViYiEAr+wPPn qoUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+pVRv0zmwM6r6qh3u7jefx+roN9IpRfJikQs29Fs7Mc=; b=nYn/1kvX0Ygakgc/4N8cfhsYQdeXmU8/oNf/zA4bmDkT8kxOOBGrUDSVj8Hrva93hd rG4in0mRN07b6vkCn+iHpL9Zdy9r7m790KRjlMB7VZTaJzZALw27Vv9mi0liGMgKYccC QrPyiKHp6jw8YEJ5vf7jP/fiPLt9QjSjYry8HUwZdFflQ52iGSXlWZEc2AsakR10oQpu gPnctl6Jlg1MeZTFKy5QUwu8iOnluj0yWDEvAwhBLhG97Srhk4+Pi4e4VIN4Kd+u72Mt M3Vqb/9sj65sy0lfXzM5DhkNmWm89FglfNroK3p88UlQjMlUHeBY/Uc/TzWnq7GPQPGz /1yA== X-Gm-Message-State: APjAAAUX9C19kOmrV6q8kRoM7wtcxjc1HkZa8IzvISzxKqEoyCuNe2n4 79N8L6W6rfFUmAqEnShp1RgY5g== X-Received: by 2002:a63:184d:: with SMTP id 13mr15500852pgy.132.1576465735555; Sun, 15 Dec 2019 19:08:55 -0800 (PST) Received: from localhost.localdomain ([240e:362:4f3:9700:194a:b273:fdd9:92e0]) by smtp.gmail.com with ESMTPSA id k60sm18021687pjh.22.2019.12.15.19.08.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 Dec 2019 19:08:54 -0800 (PST) From: Zhangfei Gao To: Greg Kroah-Hartman , Arnd Bergmann , Herbert Xu , jonathan.cameron@huawei.com, grant.likely@arm.com, jean-philippe , Jerome Glisse , ilias.apalodimas@linaro.org, francois.ozog@linaro.org, kenneth-lee-2012@foxmail.com, Wangzhou , "haojian . zhuang" , guodong.xu@linaro.org Cc: linux-accelerators@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, iommu@lists.linux-foundation.org, Kenneth Lee , Zaibo Xu , Zhangfei Gao Subject: [PATCH v10 1/4] uacce: Add documents for uacce Date: Mon, 16 Dec 2019 11:08:14 +0800 Message-Id: <1576465697-27946-2-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576465697-27946-1-git-send-email-zhangfei.gao@linaro.org> References: <1576465697-27946-1-git-send-email-zhangfei.gao@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Kenneth Lee Uacce (Unified/User-space-access-intended Accelerator Framework) is a kernel module targets to provide Shared Virtual Addressing (SVA) between the accelerator and process. This patch add document to explain how it works. Signed-off-by: Kenneth Lee Signed-off-by: Zaibo Xu Signed-off-by: Zhou Wang Signed-off-by: Zhangfei Gao --- Documentation/misc-devices/uacce.rst | 176 +++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 Documentation/misc-devices/uacce.rst -- 2.7.4 diff --git a/Documentation/misc-devices/uacce.rst b/Documentation/misc-devices/uacce.rst new file mode 100644 index 0000000..1db412e --- /dev/null +++ b/Documentation/misc-devices/uacce.rst @@ -0,0 +1,176 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Introduction of Uacce +--------------------- + +Uacce (Unified/User-space-access-intended Accelerator Framework) targets to +provide Shared Virtual Addressing (SVA) between accelerators and processes. +So accelerator can access any data structure of the main cpu. +This differs from the data sharing between cpu and io device, which share +only data content rather than address. +Because of the unified address, hardware and user space of process can +share the same virtual address in the communication. +Uacce takes the hardware accelerator as a heterogeneous processor, while +IOMMU share the same CPU page tables and as a result the same translation +from va to pa. + +:: + + __________________________ __________________________ + | | | | + | User application (CPU) | | Hardware Accelerator | + |__________________________| |__________________________| + + | | + | va | va + V V + __________ __________ + | | | | + | MMU | | IOMMU | + |__________| |__________| + | | + | | + V pa V pa + _______________________________________ + | | + | Memory | + |_______________________________________| + + + +Architecture +------------ + +Uacce is the kernel module, taking charge of iommu and address sharing. +The user drivers and libraries are called WarpDrive. + +The uacce device, built around the IOMMU SVA API, can access multiple +address spaces, including the one without PASID. + +A virtual concept, queue, is used for the communication. It provides a +FIFO-like interface. And it maintains a unified address space between the +application and all involved hardware. + +:: + + ___________________ ________________ + | | user API | | + | WarpDrive library | ------------> | user driver | + |___________________| |________________| + | | + | | + | queue fd | + | | + | | + v | + ___________________ _________ | + | | | | | mmap memory + | Other framework | | uacce | | r/w interface + | crypto/nic/others | |_________| | + |___________________| | + | | | + | register | register | + | | | + | | | + | _________________ __________ | + | | | | | | + ------------- | Device Driver | | IOMMU | | + |_________________| |__________| | + | | + | V + | ___________________ + | | | + -------------------------- | Device(Hardware) | + |___________________| + + +How does it work +---------------- + +Uacce uses mmap and IOMMU to play the trick. + +Uacce creates a chrdev for every device registered to it. New queue is +created when user application open the chrdev. The file descriptor is used +as the user handle of the queue. +The accelerator device present itself as an Uacce object, which exports as +a chrdev to the user space. The user application communicates with the +hardware by ioctl (as control path) or share memory (as data path). + +The control path to the hardware is via file operation, while data path is +via mmap space of the queue fd. + +The queue file address space: + +:: + + /** + * enum uacce_qfrt: qfrt type + * @UACCE_QFRT_MMIO: device mmio region + * @UACCE_QFRT_DUS: device user share region + */ + enum uacce_qfrt { + UACCE_QFRT_MMIO = 0, + UACCE_QFRT_DUS = 1, + }; + +All regions are optional and differ from device type to type. +Each region can be mmapped only once, otherwise -EEXIST returns. + +The device mmio region is mapped to the hardware mmio space. It is generally +used for doorbell or other notification to the hardware. It is not fast enough +as data channel. + +The device user share region is used for share data buffer between user process +and device. + + +The Uacce register API +---------------------- + +The register API is defined in uacce.h. + +:: + + struct uacce_interface { + char name[UACCE_MAX_NAME_SIZE]; + unsigned int flags; + const struct uacce_ops *ops; + }; + +According to the IOMMU capability, uacce_interface flags can be: + +:: + + /** + * UACCE Device flags: + * UACCE_DEV_SVA: Shared Virtual Addresses + * Support PASID + * Support device page faults (PCI PRI or SMMU Stall) + */ + #define UACCE_DEV_SVA BIT(0) + + struct uacce_device *uacce_alloc(struct device *parent, + struct uacce_interface *interface); + int uacce_register(struct uacce_device *uacce); + void uacce_remove(struct uacce_device *uacce); + +uacce_register results can be: + +a. If uacce module is not compiled, ERR_PTR(-ENODEV) + +b. Succeed with the desired flags + +c. Succeed with the negotiated flags, for example + + uacce_interface.flags = UACCE_DEV_SVA but uacce->flags = ~UACCE_DEV_SVA + + So user driver need check return value as well as the negotiated uacce->flags. + + +The user driver +--------------- + +The queue file mmap space will need a user driver to wrap the communication +protocol. Uacce provides some attributes in sysfs for the user driver to +match the right accelerator accordingly. +More details in Documentation/ABI/testing/sysfs-driver-uacce. From patchwork Mon Dec 16 03:08:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 181638 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp3799545ile; Sun, 15 Dec 2019 19:09:34 -0800 (PST) X-Google-Smtp-Source: APXvYqz2yocGJwxXK9OPKPMOqJAnrd0Qh/NadGrOafMWPne8TTwz/6pV1maW1xlPcB0WTv0rGs5a X-Received: by 2002:a05:6830:120c:: with SMTP id r12mr30215734otp.327.1576465774473; Sun, 15 Dec 2019 19:09:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576465774; cv=none; d=google.com; s=arc-20160816; b=L7+GIgfkyeTufSXmLgX7biIbN5kq6pD5kZbC4UIGFszJsItqAT0gfq6d0QCgT0w4MW IN0S3Q05N49x6IT5KiWI5siQ2Dk/YlcUu6FWxdClbIX5Tx44QwQd8BjZO19fY/PfVdWH zLVKdSWIAuO8DQinNUnCazP5Ct86r8Buckyvq5SwblKHOrbFNBZ4srcM/p01sE48KqvC 92y7s4d1ay8aAvUiQdNC8g+FoxH1sFyGgZHl/YT9MGrqkbrxWqZLYkD5C/kT1EhHvAt2 xO5k1/cFx0qn6IWPCNM0Eo/WpZppY+E3Ay3dL21kXJq4LHdtvcdp0ejgdgDDxXdgDGCX R+Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=W9XtgUwCaqLhMYMb2ALmzrvWt2lsT7N00PF81eXUGSY=; b=UNy1plWzpZH7SVacs4Nt4n3xk6WhDyRhwIiI4EWluk2LgU0O2SwBBLmOfKYw4t15SL xOUrY5xb4Lgha8tqvCAtTsSvUSe9yX5tXQjUnciKDwvuIUZFwObqag0Cs8n6PIm3IDqR 1T2ykBZWRnjvDWHW8OuwWC+SrMcc+zXiO7GYvB9KAXoyxUK3D5WjKahJrh9uHjvsaC7/ CRKAgx4Y/vcso4dAopN1Xi55d4oTE3C0sbnrOdakeqcbTkjkgkW4d/6AkltAAsgiGLIu MvwdM7KgUpyyVpC+4WQc55oBZNNdOjWk16VRPO8lIuuoZ2I/+TsoV+pL/gBUuhCq5+hr +HQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d4C45TMh; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m82si9603000oig.129.2019.12.15.19.09.34; Sun, 15 Dec 2019 19:09:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d4C45TMh; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726560AbfLPDJd (ORCPT + 3 others); Sun, 15 Dec 2019 22:09:33 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42579 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726551AbfLPDJd (ORCPT ); Sun, 15 Dec 2019 22:09:33 -0500 Received: by mail-pf1-f196.google.com with SMTP id 4so4775487pfz.9 for ; Sun, 15 Dec 2019 19:09:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W9XtgUwCaqLhMYMb2ALmzrvWt2lsT7N00PF81eXUGSY=; b=d4C45TMhLG17otkNIqcQIV7myR2FtJM/oxZV8H1jZ8G04hESxsdbJdsUP8hGHY8/Gf jghQRrKOidpVDRa71k7UJo+l0aZ4HJ7b5WrAzGsTk5cRD1h3BubA1I+J5rytAGtG3b59 m/kyp6LOdgYQsuxMDuQ+NJkEvyGSTNVLngOhtAokUSTFUdXetMIgcFr3FNzCFF2oJNpP jm3XpW4gTy+sitnHuEgFmEQ61tmyzqeuJotRRLWTn/6mSKI+jXcVPFTagB08Q2jKbkOI 5P1go0kcwaf6IrhKIxol3dskN4rl37kp4uOwoRH0eWY6gdy2XK6FBeWCqQDckqz0HM9L CKWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W9XtgUwCaqLhMYMb2ALmzrvWt2lsT7N00PF81eXUGSY=; b=WI/jorlkzUGQHfdQCgbvWOnu2e0hwWt0g5AjXHPDp0PhZNZ/xSOQ22YbuyefEzBdfX gmt5ZuNtKTdNViwORD/YYHZXOJwm4MVh1wWgHDXUOpUOgNozi4AYfc/CgG5Q9gEdy5VL DClCTmOWoBTFd2SmSazfSZ40698qjwkaqQ6kqJSNqpaqKQDJ+CkNOZH79bbbbpxgZVQe YgtJM+aLHZYEatHx1vW6srQKhPszXXdw6e5EAk6qgOXXUwH8g1GzQpJK95e1E0oSr5M4 XIBFS/wzlREBdUZQ9sWuH/uTLFJJtq/Iw071UESZNdB2KWDKsUvskVDCra1anDeEtMIM WoXQ== X-Gm-Message-State: APjAAAVcvnzRTtf9Ge8+ssprqFbaRvOkHleTUPoP+NKTXbFWNnCu2gB9 PuuyvXSGMbigB7UPsxMVNPh2rg== X-Received: by 2002:a63:3645:: with SMTP id d66mr15533541pga.337.1576465773063; Sun, 15 Dec 2019 19:09:33 -0800 (PST) Received: from localhost.localdomain ([240e:362:4f3:9700:194a:b273:fdd9:92e0]) by smtp.gmail.com with ESMTPSA id k60sm18021687pjh.22.2019.12.15.19.09.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 Dec 2019 19:09:32 -0800 (PST) From: Zhangfei Gao To: Greg Kroah-Hartman , Arnd Bergmann , Herbert Xu , jonathan.cameron@huawei.com, grant.likely@arm.com, jean-philippe , Jerome Glisse , ilias.apalodimas@linaro.org, francois.ozog@linaro.org, kenneth-lee-2012@foxmail.com, Wangzhou , "haojian . zhuang" , guodong.xu@linaro.org Cc: linux-accelerators@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, iommu@lists.linux-foundation.org, Zhangfei Gao Subject: [PATCH v10 3/4] crypto: hisilicon - Remove module_param uacce_mode Date: Mon, 16 Dec 2019 11:08:16 +0800 Message-Id: <1576465697-27946-4-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576465697-27946-1-git-send-email-zhangfei.gao@linaro.org> References: <1576465697-27946-1-git-send-email-zhangfei.gao@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Remove the module_param uacce_mode, which is not used currently. Signed-off-by: Zhangfei Gao Signed-off-by: Zhou Wang --- drivers/crypto/hisilicon/zip/zip_main.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) -- 2.7.4 diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c index e1bab1a..93345f0 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -297,9 +297,6 @@ static u32 pf_q_num = HZIP_PF_DEF_Q_NUM; module_param_cb(pf_q_num, &pf_q_num_ops, &pf_q_num, 0444); MODULE_PARM_DESC(pf_q_num, "Number of queues in PF(v1 1-4096, v2 1-1024)"); -static int uacce_mode; -module_param(uacce_mode, int, 0); - static u32 vfs_num; module_param(vfs_num, uint, 0444); MODULE_PARM_DESC(vfs_num, "Number of VFs to enable(1-63)"); @@ -791,6 +788,7 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_drvdata(pdev, hisi_zip); qm = &hisi_zip->qm; + qm->use_dma_api = true; qm->pdev = pdev; qm->ver = rev_id; @@ -798,20 +796,6 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) qm->dev_name = hisi_zip_name; qm->fun_type = (pdev->device == PCI_DEVICE_ID_ZIP_PF) ? QM_HW_PF : QM_HW_VF; - switch (uacce_mode) { - case 0: - qm->use_dma_api = true; - break; - case 1: - qm->use_dma_api = false; - break; - case 2: - qm->use_dma_api = true; - break; - default: - return -EINVAL; - } - ret = hisi_qm_init(qm); if (ret) { dev_err(&pdev->dev, "Failed to init qm!\n"); @@ -1010,12 +994,10 @@ static int __init hisi_zip_init(void) goto err_pci; } - if (uacce_mode == 0 || uacce_mode == 2) { - ret = hisi_zip_register_to_crypto(); - if (ret < 0) { - pr_err("Failed to register driver to crypto.\n"); - goto err_crypto; - } + ret = hisi_zip_register_to_crypto(); + if (ret < 0) { + pr_err("Failed to register driver to crypto.\n"); + goto err_crypto; } return 0; @@ -1030,8 +1012,7 @@ static int __init hisi_zip_init(void) static void __exit hisi_zip_exit(void) { - if (uacce_mode == 0 || uacce_mode == 2) - hisi_zip_unregister_from_crypto(); + hisi_zip_unregister_from_crypto(); pci_unregister_driver(&hisi_zip_pci_driver); hisi_zip_unregister_debugfs(); } From patchwork Mon Dec 16 03:08:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 181639 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp3799742ile; Sun, 15 Dec 2019 19:09:53 -0800 (PST) X-Google-Smtp-Source: APXvYqw9ArxB2B2gPy9QWHGVODDKO2IYXAdvXc5cDNvpqI6mltm0eQMePOG0Yr9P5qcUSgzFIWai X-Received: by 2002:a9d:708f:: with SMTP id l15mr30992790otj.286.1576465793195; Sun, 15 Dec 2019 19:09:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576465793; cv=none; d=google.com; s=arc-20160816; b=c/IvgSmIMhDJGolW6AYAYoYQIHmaqeEH3Q9vVvDYQNFI9i2kw30YqnKusiUzoj57vi /Hs8sp7QJ/rAsF2EmzgKGzVPqxzLlnplIlLw1/YLZMWmn/HkiQOsISYrQkA9YLjE6wd3 XAr80J2eBGmdxZFVvq3LQ69JUUaUEj6Do1FQZVmbQy+q+sILBvH6/4cB52eTsP2zNoYh SBICiOIULDTxVu3bV4TuW7FkPi5kaj8JBOfTq01mFtM5S67+OyI1yW0ugSri+Maxg+9G dkIUkipGFN2CntVii4Yec3/tsH97ve3qii6Zzzxd3VvSycE8X2bzSXjLZ/py6nXnM8aK dx8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=9QAIIvcs+0eL+0Dsa/lZmst12pgp/hIsmpBvPxRjH8Q=; b=1JfGMuKYNceEqBjMm4E6ffuWA3Dq4Bqmke1SGFpU4KMrDPjgsZbO5xeYjcDUC4o1Lg O1jd90nH2OZbV0X6sTF4CStqJFlU2fdvgyuxCxT416iCqAVeq1o0NHdIZxChIGXxieQ3 xL2My9wedWEKwCMGNnahUekzWQZwjBrmHVuZWzKBKXspR8F59D1KmTjt7G+gvVM7vGVX MEQuPqYSGhqZvdXAMWsQJ++HHX8y50DliCQ6LaGB9tP4uRtbj8FWNY0C/SocTHtKH/Mn /Yo3q0zL8KMQth8hwYs2aaOX44QdYaqVwIHCREgA7SVJCDlGiABDD+gFVP1uCZP953zu Uzfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vk+WWskq; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r202si9798837oie.247.2019.12.15.19.09.53; Sun, 15 Dec 2019 19:09:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vk+WWskq; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726437AbfLPDJw (ORCPT + 3 others); Sun, 15 Dec 2019 22:09:52 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:38280 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726559AbfLPDJv (ORCPT ); Sun, 15 Dec 2019 22:09:51 -0500 Received: by mail-pj1-f68.google.com with SMTP id l4so2322926pjt.5 for ; Sun, 15 Dec 2019 19:09:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9QAIIvcs+0eL+0Dsa/lZmst12pgp/hIsmpBvPxRjH8Q=; b=vk+WWskqQx1I5ZK+nzCjzBQx0DK1WEF2uFQmHg1tq6IqNamfEUBpC994gz+GPbYsZZ ONHf5Zj8Us4pmENwnBqaj7pWpskfOiO7c5fMvJZP6XkKGzSMdOIO+Dio6937yMhbwkFr Kfl1EYwNCznC54mIpwsShEwSTHIspyJIbJQF2vCrvHjaUQV59SqoVzM9ZfGEvaHAu62n GTumUS8PSnwwB+qDJLooZNR6Rtd46Ksfeq+WDUytYBardCLB41lwJDUMwjMKxSt9OuF1 mlQz32DoAvOL7c/qM6pSEcViGjM5rQGYq8zn3lKLWq0cEi4N9ZkJm+c80XiJfbge7hJG ER/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9QAIIvcs+0eL+0Dsa/lZmst12pgp/hIsmpBvPxRjH8Q=; b=DcGD8OeNTUC0zQdzgJoKpeD7gpOo6z9OhnWpJqOw4AFJunnfP8eU/OXsGxHs2Gm23R PS+yEDiG9DAX4XJZPe+T48TVe3obSmFMsFfA6Fei2ZIGrJi/N9ewWmEiApbeAjKbkmY1 k+fY5ojW6vhHrvSQh87kT2cgyOiljC9TNiOYyzIC2BngeH65/1tgGApQ1KEyC15K8wTN p0WRXVIQSiaRmxDgILuQosRNEjq35cRBg0nD9sYi+gvI7JLa23tRRRe4nIiD+yHpR8o8 L0zki0LxpSPM00QMjJDbM32hgGwGnkrPjjJvRxQV/oTsmZK3dNmVacuDVLBJ7dwU6F/X 7VKA== X-Gm-Message-State: APjAAAUyo27WBbwSBxfpr8hEdn5Rgwd5FFElcykzIa8kYS+iTiEZPLH+ wXN5jlB4ev1q+IthaNrR9rmt9w== X-Received: by 2002:a17:90a:374f:: with SMTP id u73mr15201729pjb.22.1576465790674; Sun, 15 Dec 2019 19:09:50 -0800 (PST) Received: from localhost.localdomain ([240e:362:4f3:9700:194a:b273:fdd9:92e0]) by smtp.gmail.com with ESMTPSA id k60sm18021687pjh.22.2019.12.15.19.09.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 Dec 2019 19:09:50 -0800 (PST) From: Zhangfei Gao To: Greg Kroah-Hartman , Arnd Bergmann , Herbert Xu , jonathan.cameron@huawei.com, grant.likely@arm.com, jean-philippe , Jerome Glisse , ilias.apalodimas@linaro.org, francois.ozog@linaro.org, kenneth-lee-2012@foxmail.com, Wangzhou , "haojian . zhuang" , guodong.xu@linaro.org Cc: linux-accelerators@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, iommu@lists.linux-foundation.org, Zhangfei Gao Subject: [PATCH v10 4/4] crypto: hisilicon - register zip engine to uacce Date: Mon, 16 Dec 2019 11:08:17 +0800 Message-Id: <1576465697-27946-5-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1576465697-27946-1-git-send-email-zhangfei.gao@linaro.org> References: <1576465697-27946-1-git-send-email-zhangfei.gao@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Register qm to uacce framework for user crypto driver Signed-off-by: Zhangfei Gao Signed-off-by: Zhou Wang --- drivers/crypto/hisilicon/qm.c | 236 +++++++++++++++++++++++++++++++- drivers/crypto/hisilicon/qm.h | 11 ++ drivers/crypto/hisilicon/zip/zip_main.c | 16 ++- include/uapi/misc/uacce/hisi_qm.h | 23 ++++ 4 files changed, 278 insertions(+), 8 deletions(-) create mode 100644 include/uapi/misc/uacce/hisi_qm.h -- 2.7.4 diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index b57da5e..1e923bc 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -9,6 +9,9 @@ #include #include #include +#include +#include +#include #include "qm.h" /* eq/aeq irq enable */ @@ -465,9 +468,14 @@ static void qm_cq_head_update(struct hisi_qp *qp) static void qm_poll_qp(struct hisi_qp *qp, struct hisi_qm *qm) { - struct qm_cqe *cqe = qp->cqe + qp->qp_status.cq_head; + if (qp->event_cb) { + qp->event_cb(qp); + return; + } if (qp->req_cb) { + struct qm_cqe *cqe = qp->cqe + qp->qp_status.cq_head; + while (QM_CQE_PHASE(cqe) == qp->qp_status.cqc_phase) { dma_rmb(); qp->req_cb(qp, qp->sqe + qm->sqe_size * @@ -1269,7 +1277,7 @@ static int qm_qp_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid) * @qp: The qp we want to start to run. * @arg: Accelerator specific argument. * - * After this function, qp can receive request from user. Return qp_id if + * After this function, qp can receive request from user. Return 0 if * successful, Return -EBUSY if failed. */ int hisi_qm_start_qp(struct hisi_qp *qp, unsigned long arg) @@ -1314,7 +1322,7 @@ int hisi_qm_start_qp(struct hisi_qp *qp, unsigned long arg) dev_dbg(dev, "queue %d started\n", qp_id); - return qp_id; + return 0; } EXPORT_SYMBOL_GPL(hisi_qm_start_qp); @@ -1395,6 +1403,213 @@ static void hisi_qm_cache_wb(struct hisi_qm *qm) } } +static void qm_qp_event_notifier(struct hisi_qp *qp) +{ + wake_up_interruptible(&qp->uacce_q->wait); +} + +static int hisi_qm_get_available_instances(struct uacce_device *uacce) +{ + int i, ret; + struct hisi_qm *qm = uacce->priv; + + read_lock(&qm->qps_lock); + for (i = 0, ret = 0; i < qm->qp_num; i++) + if (!qm->qp_array[i]) + ret++; + read_unlock(&qm->qps_lock); + + return ret; +} + +static int hisi_qm_uacce_get_queue(struct uacce_device *uacce, + unsigned long arg, + struct uacce_queue *q) +{ + struct hisi_qm *qm = uacce->priv; + struct hisi_qp *qp; + u8 alg_type = 0; + + qp = hisi_qm_create_qp(qm, alg_type); + if (IS_ERR(qp)) + return PTR_ERR(qp); + + q->priv = qp; + q->uacce = uacce; + qp->uacce_q = q; + qp->event_cb = qm_qp_event_notifier; + qp->pasid = arg; + + return 0; +} + +static void hisi_qm_uacce_put_queue(struct uacce_queue *q) +{ + struct hisi_qp *qp = q->priv; + + hisi_qm_cache_wb(qp->qm); + hisi_qm_release_qp(qp); +} + +/* map sq/cq/doorbell to user space */ +static int hisi_qm_uacce_mmap(struct uacce_queue *q, + struct vm_area_struct *vma, + struct uacce_qfile_region *qfr) +{ + struct hisi_qp *qp = q->priv; + struct hisi_qm *qm = qp->qm; + size_t sz = vma->vm_end - vma->vm_start; + struct pci_dev *pdev = qm->pdev; + struct device *dev = &pdev->dev; + unsigned long vm_pgoff; + int ret; + + switch (qfr->type) { + case UACCE_QFRT_MMIO: + if (qm->ver == QM_HW_V2) { + if (sz > PAGE_SIZE * (QM_DOORBELL_PAGE_NR + + QM_DOORBELL_SQ_CQ_BASE_V2 / PAGE_SIZE)) + return -EINVAL; + } else { + if (sz > PAGE_SIZE * QM_DOORBELL_PAGE_NR) + return -EINVAL; + } + + vma->vm_flags |= VM_IO; + + return remap_pfn_range(vma, vma->vm_start, + qm->phys_base >> PAGE_SHIFT, + sz, pgprot_noncached(vma->vm_page_prot)); + case UACCE_QFRT_DUS: + if (sz != qp->qdma.size) + return -EINVAL; + + /* + * dma_mmap_coherent() requires vm_pgoff as 0 + * restore vm_pfoff to initial value for mmap() + */ + vm_pgoff = vma->vm_pgoff; + vma->vm_pgoff = 0; + ret = dma_mmap_coherent(dev, vma, qp->qdma.va, + qp->qdma.dma, sz); + vma->vm_pgoff = vm_pgoff; + return ret; + + default: + return -EINVAL; + } +} + +static int hisi_qm_uacce_start_queue(struct uacce_queue *q) +{ + struct hisi_qp *qp = q->priv; + + return hisi_qm_start_qp(qp, qp->pasid); +} + +static void hisi_qm_uacce_stop_queue(struct uacce_queue *q) +{ + hisi_qm_stop_qp(q->priv); +} + +static int qm_set_sqctype(struct uacce_queue *q, u16 type) +{ + struct hisi_qm *qm = q->uacce->priv; + struct hisi_qp *qp = q->priv; + + write_lock(&qm->qps_lock); + qp->alg_type = type; + write_unlock(&qm->qps_lock); + + return 0; +} + +static long hisi_qm_uacce_ioctl(struct uacce_queue *q, unsigned int cmd, + unsigned long arg) +{ + struct hisi_qp *qp = q->priv; + struct hisi_qp_ctx qp_ctx; + + if (cmd == UACCE_CMD_QM_SET_QP_CTX) { + if (copy_from_user(&qp_ctx, (void __user *)arg, + sizeof(struct hisi_qp_ctx))) + return -EFAULT; + + if (qp_ctx.qc_type != 0 && qp_ctx.qc_type != 1) + return -EINVAL; + + qm_set_sqctype(q, qp_ctx.qc_type); + qp_ctx.id = qp->qp_id; + + if (copy_to_user((void __user *)arg, &qp_ctx, + sizeof(struct hisi_qp_ctx))) + return -EFAULT; + } else { + return -EINVAL; + } + + return 0; +} + +static const struct uacce_ops uacce_qm_ops = { + .get_available_instances = hisi_qm_get_available_instances, + .get_queue = hisi_qm_uacce_get_queue, + .put_queue = hisi_qm_uacce_put_queue, + .start_queue = hisi_qm_uacce_start_queue, + .stop_queue = hisi_qm_uacce_stop_queue, + .mmap = hisi_qm_uacce_mmap, + .ioctl = hisi_qm_uacce_ioctl, +}; + +static int qm_alloc_uacce(struct hisi_qm *qm) +{ + struct pci_dev *pdev = qm->pdev; + struct uacce_device *uacce; + unsigned long mmio_page_nr; + unsigned long dus_page_nr; + struct uacce_interface interface = { + .flags = UACCE_DEV_SVA, + .ops = &uacce_qm_ops, + }; + + strncpy(interface.name, pdev->driver->name, sizeof(interface.name)); + + uacce = uacce_alloc(&pdev->dev, &interface); + if (IS_ERR(uacce)) + return PTR_ERR(uacce); + + if (uacce->flags & UACCE_DEV_SVA) { + qm->use_sva = true; + } else { + /* only consider sva case */ + uacce_remove(uacce); + return -EINVAL; + } + + uacce->is_vf = pdev->is_virtfn; + uacce->priv = qm; + uacce->algs = qm->algs; + + if (qm->ver == QM_HW_V1) { + mmio_page_nr = QM_DOORBELL_PAGE_NR; + uacce->api_ver = HISI_QM_API_VER_BASE; + } else { + mmio_page_nr = QM_DOORBELL_PAGE_NR + + QM_DOORBELL_SQ_CQ_BASE_V2 / PAGE_SIZE; + uacce->api_ver = HISI_QM_API_VER2_BASE; + } + + dus_page_nr = (PAGE_SIZE - 1 + qm->sqe_size * QM_Q_DEPTH + + sizeof(struct qm_cqe) * QM_Q_DEPTH) >> PAGE_SHIFT; + + uacce->qf_pg_num[UACCE_QFRT_MMIO] = mmio_page_nr; + uacce->qf_pg_num[UACCE_QFRT_DUS] = dus_page_nr; + + qm->uacce = uacce; + + return 0; +} + /** * hisi_qm_get_free_qp_num() - Get free number of qp in qm. * @qm: The qm which want to get free qp. @@ -1437,10 +1652,14 @@ int hisi_qm_init(struct hisi_qm *qm) return -EINVAL; } + ret = qm_alloc_uacce(qm); + if (ret < 0) + dev_warn(&pdev->dev, "fail to alloc uacce (%d)\n", ret); + ret = pci_enable_device_mem(pdev); if (ret < 0) { dev_err(&pdev->dev, "Failed to enable device mem!\n"); - return ret; + goto err_remove_uacce; } ret = pci_request_mem_regions(pdev, qm->dev_name); @@ -1449,8 +1668,9 @@ int hisi_qm_init(struct hisi_qm *qm) goto err_disable_pcidev; } - qm->io_base = ioremap(pci_resource_start(pdev, PCI_BAR_2), - pci_resource_len(qm->pdev, PCI_BAR_2)); + qm->phys_base = pci_resource_start(pdev, PCI_BAR_2); + qm->phys_size = pci_resource_len(qm->pdev, PCI_BAR_2); + qm->io_base = ioremap(qm->phys_base, qm->phys_size); if (!qm->io_base) { ret = -EIO; goto err_release_mem_regions; @@ -1493,6 +1713,8 @@ int hisi_qm_init(struct hisi_qm *qm) pci_release_mem_regions(pdev); err_disable_pcidev: pci_disable_device(pdev); +err_remove_uacce: + uacce_remove(qm->uacce); return ret; } @@ -1509,6 +1731,8 @@ void hisi_qm_uninit(struct hisi_qm *qm) struct pci_dev *pdev = qm->pdev; struct device *dev = &pdev->dev; + uacce_remove(qm->uacce); + if (qm->use_dma_api && qm->qdma.va) { hisi_qm_cache_wb(qm); dma_free_coherent(dev, qm->qdma.size, diff --git a/drivers/crypto/hisilicon/qm.h b/drivers/crypto/hisilicon/qm.h index 078b8f1..c096f80 100644 --- a/drivers/crypto/hisilicon/qm.h +++ b/drivers/crypto/hisilicon/qm.h @@ -77,6 +77,9 @@ #define HISI_ACC_SGL_SGE_NR_MAX 255 +/* page number for queue file region */ +#define QM_DOORBELL_PAGE_NR 1 + enum qp_state { QP_STOP, }; @@ -162,7 +165,12 @@ struct hisi_qm { u32 error_mask; u32 msi_mask; + const char *algs; bool use_dma_api; + bool use_sva; + resource_size_t phys_base; + resource_size_t phys_size; + struct uacce_device *uacce; }; struct hisi_qp_status { @@ -192,10 +200,13 @@ struct hisi_qp { struct hisi_qp_ops *hw_ops; void *qp_ctx; void (*req_cb)(struct hisi_qp *qp, void *data); + void (*event_cb)(struct hisi_qp *qp); struct work_struct work; struct workqueue_struct *wq; struct hisi_qm *qm; + u16 pasid; + struct uacce_queue *uacce_q; }; int hisi_qm_init(struct hisi_qm *qm); diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c index 93345f0..575faa3 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "zip.h" #define PCI_DEVICE_ID_ZIP_PF 0xa250 @@ -350,8 +351,14 @@ static void hisi_zip_set_user_domain_and_cache(struct hisi_zip *hisi_zip) writel(AXUSER_BASE, base + HZIP_BD_RUSER_32_63); writel(AXUSER_BASE, base + HZIP_SGL_RUSER_32_63); writel(AXUSER_BASE, base + HZIP_BD_WUSER_32_63); - writel(AXUSER_BASE, base + HZIP_DATA_RUSER_32_63); - writel(AXUSER_BASE, base + HZIP_DATA_WUSER_32_63); + + if (hisi_zip->qm.use_sva) { + writel(AXUSER_BASE | AXUSER_SSV, base + HZIP_DATA_RUSER_32_63); + writel(AXUSER_BASE | AXUSER_SSV, base + HZIP_DATA_WUSER_32_63); + } else { + writel(AXUSER_BASE, base + HZIP_DATA_RUSER_32_63); + writel(AXUSER_BASE, base + HZIP_DATA_WUSER_32_63); + } /* let's open all compression/decompression cores */ writel(DECOMP_CHECK_ENABLE | ALL_COMP_DECOMP_EN, @@ -792,6 +799,7 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) qm->pdev = pdev; qm->ver = rev_id; + qm->algs = "zlib\ngzip"; qm->sqe_size = HZIP_SQE_SIZE; qm->dev_name = hisi_zip_name; qm->fun_type = (pdev->device == PCI_DEVICE_ID_ZIP_PF) ? QM_HW_PF : @@ -835,6 +843,10 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) hisi_zip_add_to_list(hisi_zip); + ret = uacce_register(qm->uacce); + if (ret) + goto err_qm_uninit; + if (qm->fun_type == QM_HW_PF && vfs_num > 0) { ret = hisi_zip_sriov_enable(pdev, vfs_num); if (ret < 0) diff --git a/include/uapi/misc/uacce/hisi_qm.h b/include/uapi/misc/uacce/hisi_qm.h new file mode 100644 index 0000000..6435f0b --- /dev/null +++ b/include/uapi/misc/uacce/hisi_qm.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +#ifndef _UAPI_HISI_QM_H +#define _UAPI_HISI_QM_H + +#include + +/** + * struct hisi_qp_ctx - User data for hisi qp. + * @id: qp_index return to user space + * @qc_type: Accelerator algorithm type + */ +struct hisi_qp_ctx { + __u16 id; + __u16 qc_type; +}; + +#define HISI_QM_API_VER_BASE "hisi_qm_v1" +#define HISI_QM_API_VER2_BASE "hisi_qm_v2" + +/* UACCE_CMD_QM_SET_QP_CTX: Set qp algorithm type */ +#define UACCE_CMD_QM_SET_QP_CTX _IOWR('H', 10, struct hisi_qp_ctx) + +#endif