Acc
Threads by month
- ----- 2025 -----
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2022
- 5 participants
- 5 discussions
qemu:
https://github.com/luxis1999/qemu/tree/qemu-for-5.17-rc6-vm-rfcv2.
kernel:
>> https://github.com/luxis1999/iommufd/tree/iommufd-v5.18-rc4-nesting
-------- Forwarded Message --------
Subject: [RFC v2 00/15] vfio: Adopt iommufd
Date: Wed, 8 Jun 2022 05:31:24 -0700
From: Yi Liu <yi.l.liu(a)intel.com>
To: alex.williamson(a)redhat.com, cohuck(a)redhat.com, qemu-devel(a)nongnu.org
CC: david(a)gibson.dropbear.id.au, thuth(a)redhat.com,
farman(a)linux.ibm.com, mjrosato(a)linux.ibm.com, akrowiak(a)linux.ibm.com,
pasic(a)linux.ibm.com, jjherne(a)linux.ibm.com, jasowang(a)redhat.com,
kvm(a)vger.kernel.org, jgg(a)nvidia.com, nicolinc(a)nvidia.com,
eric.auger(a)redhat.com, eric.auger.pro(a)gmail.com, kevin.tian(a)intel.com,
yi.l.liu(a)intel.com, chao.p.peng(a)intel.com, yi.y.sun(a)intel.com,
peterx(a)redhat.com, shameerali.kolothum.thodi(a)huawei.com,
zhangfei.gao(a)linaro.org, berrange(a)redhat.com
With the introduction of iommufd[1], the Linux kernel provides a generic
interface for userspace drivers to propagate their DMA mappings to kernel
for assigned devices. This series does the porting of the VFIO devices
onto the /dev/iommu uapi and let it coexist with the legacy implementation.
Other devices like vpda, vfio mdev and etc. are not considered yet.
At QEMU level, interactions with the /dev/iommu are abstracted by a new
iommufd object (compiled in with the CONFIG_IOMMUFD option).
Any QEMU device (e.g. vfio device) wishing to use /dev/iommu must be
linked with an iommufd object. In this series, the vfio-pci device is
granted with such capability:
It gets a new optional parameter named iommufd which allows to pass
an iommufd object:
-object iommufd,id=iommufd0
-device vfio-pci,host=0000:02:00.0,iommufd=iommufd0
Note the /dev/iommu can be externally opened by a management layer.
In such a case the fd is passed along with the iommufd object:
-object iommufd,id=iommufd0,fd=22
-device vfio-pci,host=0000:02:00.0,iommufd=iommufd0
If the fd parameter is not passed, the fd (/dev/iommu) is opened by QEMU.
If no iommufd option is passed to the vfio-pci device, iommufd is not
used and the end-user gets the behavior based on the legacy vfio iommu
interfaces:
-device vfio-pci,host=0000:02:00.0
While the legacy kernel interface is group-centric, the new iommufd
interface is device-centric, relying on device fd and iommufd.
To support both interfaces in the QEMU VFIO device we reworked the vfio
container abstraction so that the generic VFIO code can use either
backend.
The VFIOContainer object becomes a base object derived into
a) the legacy VFIO container and
b) the new iommufd based container.
The base object implements generic code such as code related to
memory_listener and address space management whereas the derived
objects implement callbacks specific to either BE, legacy and
iommufd. Indeed each backend has its own way to setup secure context
and dma management interface. The below diagram shows how it looks
like with both BEs.
VFIO AddressSpace/Memory
+-------+ +----------+ +-----+ +-----+
| pci | | platform | | ap | | ccw |
+---+---+ +----+-----+ +--+--+ +--+--+ +----------------------+
| | | | | AddressSpace |
| | | | +------------+---------+
+---V-----------V-----------V--------V----+ /
| VFIOAddressSpace | <------------+
| | | MemoryListener
| VFIOContainer list |
+-------+----------------------------+----+
| |
| |
+-------V------+ +--------V----------+
| iommufd | | vfio legacy |
| container | | container |
+-------+------+ +--------+----------+
| |
| /dev/iommu | /dev/vfio/vfio
| /dev/vfio/devices/vfioX | /dev/vfio/$group_id
Userspace | |
===========+============================+================================
Kernel | device fd |
+---------------+ | group/container fd
| (BIND_IOMMUFD | | (SET_CONTAINER/SET_IOMMU)
| ATTACH_IOAS) | | device fd
| | |
| +-------V------------V-----------------+
iommufd | | vfio |
(map/unmap | +---------+--------------------+-------+
ioas_copy) | | | map/unmap
| | |
+------V------+ +-----V------+ +------V--------+
| iommfd core | | device | | vfio iommu |
+-------------+ +------------+ +---------------+
[Secure Context setup]
- iommufd BE: uses device fd and iommufd to setup secure context
(bind_iommufd, attach_ioas)
- vfio legacy BE: uses group fd and container fd to setup secure context
(set_container, set_iommu)
[Device access]
- iommufd BE: device fd is opened through /dev/vfio/devices/vfioX
- vfio legacy BE: device fd is retrieved from group fd ioctl
[DMA Mapping flow]
- VFIOAddressSpace receives MemoryRegion add/del via MemoryListener
- VFIO populates DMA map/unmap via the container BEs
*) iommufd BE: uses iommufd
*) vfio legacy BE: uses container fd
Test done:
- PCI and Platform device were tested
- ccw and ap were only compile-tested
- limited device hotplug test
- vIOMMU test run for both legacy and iommufd backends (limited tests)
This series was co-developed by Eric Auger and me based on the iommufd
exploration
kernel (https://github.com/luxis1999/iommufd/tree/iommufd-v5.17-rc6)
which encompasses:
- Jason’s IOMMUFD Generic interface series
<https://lore.kernel.org/kvm/0-v1-e79cd8d168e8+6-iommufd_jgg@nvidia.com/>
- Jason's vfio ccw life circle cleanup (Eric Farman has renewed it recently)
<https://lore.kernel.org/all/0-v3-57c1502c62fd+2190-ccw_mdev_jgg@nvidia.com/
https://lore.kernel.org/kvm/20220602171948.2790690-1-farman@linux.ibm.com/>
- Yi's move vfio_device allo/free into vfio core (not pushed to upstream
yet)
- Yi's vfio device cdev (introduces device-centric interface, not pushed
to upstream yet)
- Nicolin's vfio iommufd compat code (not pushed to upstream yet)
This QEMU series can be fount at
https://github.com/luxis1999/qemu/tree/qemu-for-5.17-rc6-vm-rfcv2.
As iommufd kernel is in the early step (only iommufd generic interface is
in mailing list), so this series hasn't made the iommufd backend fully on
par with legacy backend w.r.t. features like:
- p2p mappings
- coherency tracking
- live migration
- vfio pci device hot reset
- and etc.
Only vfio-pci device supports iommufd BE, other types of devices still
uses legacy BE.
TODOs:
- Add DMA alias check for iommufd BE (group level)
- Make pci.c to be BE agnostic. Needs kernel change as well to fix the
VFIO_DEVICE_PCI_HOT_RESET gap
- Cleanup the VFIODevice fields as it's used in both backends
- Add device fd parameter to vfio-device in case the iommufd option is used
- Add locks
- Replace list with g_tree
- More tests
Change log:
v2:
- remove the first three patches of rfcv1
- add open cdev helper suggested by Jason
- remove the QOMification of the VFIOContainer and simply use standard
ops (David)
- add "-object iommufd" suggested by Alex
v1:
https://lore.kernel.org/qemu-devel/20220414104710.28534-1-yi.l.liu@intel.co…
Thanks,
Yi & Eric
Eric Auger (10):
scripts/update-linux-headers: Add iommufd.h
linux-headers: Import latest vfio.h and iommufd.h
vfio/container: Introduce vfio_[attach/detach]_device
vfio/platform: Use vfio_[attach/detach]_device
vfio/ap: Use vfio_[attach/detach]_device
vfio/ccw: Use vfio_[attach/detach]_device
vfio/container-base: Introduce [attach/detach]_device container
callbacks
vfio/container-base: Introduce VFIOContainer reset callback
backends/iommufd: Introduce the iommufd object
vfio/as: Allow the selection of a given iommu backend
Yi Liu (5):
vfio/common: Split common.c into common.c, container.c and as.c
vfio: Add base container
util/char_dev: Add open_cdev()
vfio/iommufd: Implement the iommufd backend
vfio/iommufd: Add IOAS_COPY_DMA support
MAINTAINERS | 13 +
backends/Kconfig | 5 +
backends/iommufd.c | 265 +++
backends/meson.build | 1 +
backends/trace-events | 12 +
hw/vfio/ap.c | 62 +-
hw/vfio/as.c | 1035 +++++++++++
hw/vfio/ccw.c | 118 +-
hw/vfio/common.c | 2365 ++-----------------------
hw/vfio/container-base.c | 172 ++
hw/vfio/container.c | 1298 ++++++++++++++
hw/vfio/iommufd.c | 546 ++++++
hw/vfio/meson.build | 6 +
hw/vfio/migration.c | 5 +-
hw/vfio/pci.c | 83 +-
hw/vfio/platform.c | 42 +-
hw/vfio/spapr.c | 22 +-
hw/vfio/trace-events | 11 +
include/hw/vfio/vfio-common.h | 101 +-
include/hw/vfio/vfio-container-base.h | 148 ++
include/qemu/char_dev.h | 16 +
include/sysemu/iommufd.h | 47 +
linux-headers/linux/iommufd.h | 223 +++
linux-headers/linux/vfio.h | 84 +
qapi/qom.json | 16 +-
qemu-options.hx | 12 +
scripts/update-linux-headers.sh | 2 +-
util/chardev_open.c | 58 +
util/meson.build | 1 +
29 files changed, 4291 insertions(+), 2478 deletions(-)
create mode 100644 backends/iommufd.c
create mode 100644 hw/vfio/as.c
create mode 100644 hw/vfio/container-base.c
create mode 100644 hw/vfio/container.c
create mode 100644 hw/vfio/iommufd.c
create mode 100644 include/hw/vfio/vfio-container-base.h
create mode 100644 include/qemu/char_dev.h
create mode 100644 include/sysemu/iommufd.h
create mode 100644 linux-headers/linux/iommufd.h
create mode 100644 util/chardev_open.c
Base commit: 9b1f58854959c5a9bdb347e3e04c252ab7fc9ef5
--
2.27.0
1
0
qemu:
https://github.com/luxis1999/qemu/tree/qemu-for-5.17-rc6-vm-rfcv2.
kernel:
>> https://github.com/luxis1999/iommufd/tree/iommufd-v5.18-rc4-nesting
-------- Forwarded Message --------
Subject: [RFC v2 00/15] vfio: Adopt iommufd
Date: Wed, 8 Jun 2022 05:31:24 -0700
From: Yi Liu <yi.l.liu(a)intel.com>
To: alex.williamson(a)redhat.com, cohuck(a)redhat.com, qemu-devel(a)nongnu.org
CC: david(a)gibson.dropbear.id.au, thuth(a)redhat.com,
farman(a)linux.ibm.com, mjrosato(a)linux.ibm.com, akrowiak(a)linux.ibm.com,
pasic(a)linux.ibm.com, jjherne(a)linux.ibm.com, jasowang(a)redhat.com,
kvm(a)vger.kernel.org, jgg(a)nvidia.com, nicolinc(a)nvidia.com,
eric.auger(a)redhat.com, eric.auger.pro(a)gmail.com, kevin.tian(a)intel.com,
yi.l.liu(a)intel.com, chao.p.peng(a)intel.com, yi.y.sun(a)intel.com,
peterx(a)redhat.com, shameerali.kolothum.thodi(a)huawei.com,
zhangfei.gao(a)linaro.org, berrange(a)redhat.com
With the introduction of iommufd[1], the Linux kernel provides a generic
interface for userspace drivers to propagate their DMA mappings to kernel
for assigned devices. This series does the porting of the VFIO devices
onto the /dev/iommu uapi and let it coexist with the legacy implementation.
Other devices like vpda, vfio mdev and etc. are not considered yet.
At QEMU level, interactions with the /dev/iommu are abstracted by a new
iommufd object (compiled in with the CONFIG_IOMMUFD option).
Any QEMU device (e.g. vfio device) wishing to use /dev/iommu must be
linked with an iommufd object. In this series, the vfio-pci device is
granted with such capability:
It gets a new optional parameter named iommufd which allows to pass
an iommufd object:
-object iommufd,id=iommufd0
-device vfio-pci,host=0000:02:00.0,iommufd=iommufd0
Note the /dev/iommu can be externally opened by a management layer.
In such a case the fd is passed along with the iommufd object:
-object iommufd,id=iommufd0,fd=22
-device vfio-pci,host=0000:02:00.0,iommufd=iommufd0
If the fd parameter is not passed, the fd (/dev/iommu) is opened by QEMU.
If no iommufd option is passed to the vfio-pci device, iommufd is not
used and the end-user gets the behavior based on the legacy vfio iommu
interfaces:
-device vfio-pci,host=0000:02:00.0
While the legacy kernel interface is group-centric, the new iommufd
interface is device-centric, relying on device fd and iommufd.
To support both interfaces in the QEMU VFIO device we reworked the vfio
container abstraction so that the generic VFIO code can use either
backend.
The VFIOContainer object becomes a base object derived into
a) the legacy VFIO container and
b) the new iommufd based container.
The base object implements generic code such as code related to
memory_listener and address space management whereas the derived
objects implement callbacks specific to either BE, legacy and
iommufd. Indeed each backend has its own way to setup secure context
and dma management interface. The below diagram shows how it looks
like with both BEs.
VFIO AddressSpace/Memory
+-------+ +----------+ +-----+ +-----+
| pci | | platform | | ap | | ccw |
+---+---+ +----+-----+ +--+--+ +--+--+ +----------------------+
| | | | | AddressSpace |
| | | | +------------+---------+
+---V-----------V-----------V--------V----+ /
| VFIOAddressSpace | <------------+
| | | MemoryListener
| VFIOContainer list |
+-------+----------------------------+----+
| |
| |
+-------V------+ +--------V----------+
| iommufd | | vfio legacy |
| container | | container |
+-------+------+ +--------+----------+
| |
| /dev/iommu | /dev/vfio/vfio
| /dev/vfio/devices/vfioX | /dev/vfio/$group_id
Userspace | |
===========+============================+================================
Kernel | device fd |
+---------------+ | group/container fd
| (BIND_IOMMUFD | | (SET_CONTAINER/SET_IOMMU)
| ATTACH_IOAS) | | device fd
| | |
| +-------V------------V-----------------+
iommufd | | vfio |
(map/unmap | +---------+--------------------+-------+
ioas_copy) | | | map/unmap
| | |
+------V------+ +-----V------+ +------V--------+
| iommfd core | | device | | vfio iommu |
+-------------+ +------------+ +---------------+
[Secure Context setup]
- iommufd BE: uses device fd and iommufd to setup secure context
(bind_iommufd, attach_ioas)
- vfio legacy BE: uses group fd and container fd to setup secure context
(set_container, set_iommu)
[Device access]
- iommufd BE: device fd is opened through /dev/vfio/devices/vfioX
- vfio legacy BE: device fd is retrieved from group fd ioctl
[DMA Mapping flow]
- VFIOAddressSpace receives MemoryRegion add/del via MemoryListener
- VFIO populates DMA map/unmap via the container BEs
*) iommufd BE: uses iommufd
*) vfio legacy BE: uses container fd
Test done:
- PCI and Platform device were tested
- ccw and ap were only compile-tested
- limited device hotplug test
- vIOMMU test run for both legacy and iommufd backends (limited tests)
This series was co-developed by Eric Auger and me based on the iommufd
exploration
kernel (https://github.com/luxis1999/iommufd/tree/iommufd-v5.17-rc6)
which encompasses:
- Jason’s IOMMUFD Generic interface series
<https://lore.kernel.org/kvm/0-v1-e79cd8d168e8+6-iommufd_jgg@nvidia.com/>
- Jason's vfio ccw life circle cleanup (Eric Farman has renewed it recently)
<https://lore.kernel.org/all/0-v3-57c1502c62fd+2190-ccw_mdev_jgg@nvidia.com/
https://lore.kernel.org/kvm/20220602171948.2790690-1-farman@linux.ibm.com/>
- Yi's move vfio_device allo/free into vfio core (not pushed to upstream
yet)
- Yi's vfio device cdev (introduces device-centric interface, not pushed
to upstream yet)
- Nicolin's vfio iommufd compat code (not pushed to upstream yet)
This QEMU series can be fount at
https://github.com/luxis1999/qemu/tree/qemu-for-5.17-rc6-vm-rfcv2.
As iommufd kernel is in the early step (only iommufd generic interface is
in mailing list), so this series hasn't made the iommufd backend fully on
par with legacy backend w.r.t. features like:
- p2p mappings
- coherency tracking
- live migration
- vfio pci device hot reset
- and etc.
Only vfio-pci device supports iommufd BE, other types of devices still
uses legacy BE.
TODOs:
- Add DMA alias check for iommufd BE (group level)
- Make pci.c to be BE agnostic. Needs kernel change as well to fix the
VFIO_DEVICE_PCI_HOT_RESET gap
- Cleanup the VFIODevice fields as it's used in both backends
- Add device fd parameter to vfio-device in case the iommufd option is used
- Add locks
- Replace list with g_tree
- More tests
Change log:
v2:
- remove the first three patches of rfcv1
- add open cdev helper suggested by Jason
- remove the QOMification of the VFIOContainer and simply use standard
ops (David)
- add "-object iommufd" suggested by Alex
v1:
https://lore.kernel.org/qemu-devel/20220414104710.28534-1-yi.l.liu@intel.co…
Thanks,
Yi & Eric
Eric Auger (10):
scripts/update-linux-headers: Add iommufd.h
linux-headers: Import latest vfio.h and iommufd.h
vfio/container: Introduce vfio_[attach/detach]_device
vfio/platform: Use vfio_[attach/detach]_device
vfio/ap: Use vfio_[attach/detach]_device
vfio/ccw: Use vfio_[attach/detach]_device
vfio/container-base: Introduce [attach/detach]_device container
callbacks
vfio/container-base: Introduce VFIOContainer reset callback
backends/iommufd: Introduce the iommufd object
vfio/as: Allow the selection of a given iommu backend
Yi Liu (5):
vfio/common: Split common.c into common.c, container.c and as.c
vfio: Add base container
util/char_dev: Add open_cdev()
vfio/iommufd: Implement the iommufd backend
vfio/iommufd: Add IOAS_COPY_DMA support
MAINTAINERS | 13 +
backends/Kconfig | 5 +
backends/iommufd.c | 265 +++
backends/meson.build | 1 +
backends/trace-events | 12 +
hw/vfio/ap.c | 62 +-
hw/vfio/as.c | 1035 +++++++++++
hw/vfio/ccw.c | 118 +-
hw/vfio/common.c | 2365 ++-----------------------
hw/vfio/container-base.c | 172 ++
hw/vfio/container.c | 1298 ++++++++++++++
hw/vfio/iommufd.c | 546 ++++++
hw/vfio/meson.build | 6 +
hw/vfio/migration.c | 5 +-
hw/vfio/pci.c | 83 +-
hw/vfio/platform.c | 42 +-
hw/vfio/spapr.c | 22 +-
hw/vfio/trace-events | 11 +
include/hw/vfio/vfio-common.h | 101 +-
include/hw/vfio/vfio-container-base.h | 148 ++
include/qemu/char_dev.h | 16 +
include/sysemu/iommufd.h | 47 +
linux-headers/linux/iommufd.h | 223 +++
linux-headers/linux/vfio.h | 84 +
qapi/qom.json | 16 +-
qemu-options.hx | 12 +
scripts/update-linux-headers.sh | 2 +-
util/chardev_open.c | 58 +
util/meson.build | 1 +
29 files changed, 4291 insertions(+), 2478 deletions(-)
create mode 100644 backends/iommufd.c
create mode 100644 hw/vfio/as.c
create mode 100644 hw/vfio/container-base.c
create mode 100644 hw/vfio/container.c
create mode 100644 hw/vfio/iommufd.c
create mode 100644 include/hw/vfio/vfio-container-base.h
create mode 100644 include/qemu/char_dev.h
create mode 100644 include/sysemu/iommufd.h
create mode 100644 linux-headers/linux/iommufd.h
create mode 100644 util/chardev_open.c
Base commit: 9b1f58854959c5a9bdb347e3e04c252ab7fc9ef5
--
2.27.0
1
0
When uacce is working, uacce parent module can be rmmod, parent
device can also be removed anytime, which may cause concurrency issues.
Here solve the concurrency issue.
Jean-Philippe Brucker (1):
uacce: Handle parent device removal
Zhangfei Gao (1):
uacce: Handle parent driver module removal
drivers/misc/uacce/uacce.c | 135 ++++++++++++++++++++++++-------------
include/linux/uacce.h | 6 +-
2 files changed, 92 insertions(+), 49 deletions(-)
--
2.36.1
2
5
1. Add the function of setting the uadk log level, include error,
info, debug by syslog.
2. The number of packets in a queue can be read through the
'uadk_tool'.
3. The 'uadk_tool' supports displaying the library build date. supports
displaying the environment variables.
Signed-off-by: Kai Ye <yekai13(a)huawei.com>
---
0 | 0
Makefile.am | 7 +-
include/drv/wd_aead_drv.h | 1 +
include/drv/wd_cipher_drv.h | 1 +
include/drv/wd_dh_drv.h | 1 +
include/drv/wd_digest_drv.h | 1 +
include/drv/wd_ecc_drv.h | 1 +
include/drv/wd_rsa_drv.h | 1 +
include/wd.h | 69 +++--
include/wd_util.h | 25 +-
test/hisi_zip_test/test_lib.c | 2 +
uadk_tool/Makefile.am | 11 +-
.../{ => benchmark}/sec_soft_benchmark.c | 0
.../{ => benchmark}/sec_soft_benchmark.h | 0
.../{ => benchmark}/sec_uadk_benchmark.c | 0
.../{ => benchmark}/sec_uadk_benchmark.h | 0
uadk_tool/{ => benchmark}/sec_wd_benchmark.c | 0
uadk_tool/{ => benchmark}/sec_wd_benchmark.h | 0
uadk_tool/{ => benchmark}/uadk_benchmark.c | 3 +-
uadk_tool/{ => benchmark}/uadk_benchmark.h | 2 +-
uadk_tool/dfx/uadk_dfx.c | 253 ++++++++++++++++++
uadk_tool/{ => dfx}/uadk_dfx.h | 3 -
uadk_tool/uadk_dfx.c | 79 ------
uadk_tool/uadk_tool.c | 21 +-
wd.c | 79 +++++-
wd_aead.c | 9 +-
wd_cipher.c | 8 +
wd_comp.c | 2 +
wd_dh.c | 7 +
wd_digest.c | 7 +
wd_ecc.c | 11 +-
wd_rsa.c | 7 +
wd_util.c | 91 ++++++-
33 files changed, 564 insertions(+), 138 deletions(-)
create mode 100644 0
rename uadk_tool/{ => benchmark}/sec_soft_benchmark.c (100%)
rename uadk_tool/{ => benchmark}/sec_soft_benchmark.h (100%)
rename uadk_tool/{ => benchmark}/sec_uadk_benchmark.c (100%)
rename uadk_tool/{ => benchmark}/sec_uadk_benchmark.h (100%)
rename uadk_tool/{ => benchmark}/sec_wd_benchmark.c (100%)
rename uadk_tool/{ => benchmark}/sec_wd_benchmark.h (100%)
rename uadk_tool/{ => benchmark}/uadk_benchmark.c (99%)
rename uadk_tool/{ => benchmark}/uadk_benchmark.h (97%)
create mode 100644 uadk_tool/dfx/uadk_dfx.c
rename uadk_tool/{ => dfx}/uadk_dfx.h (59%)
delete mode 100644 uadk_tool/uadk_dfx.c
diff --git a/0 b/0
new file mode 100644
index 0000000..e69de29
diff --git a/Makefile.am b/Makefile.am
index 0bda2f7..05d6bc7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,11 @@ MINOR = 3
REVISION = 34
UADK_VERSION = -version-number ${MAJOR}:${MINOR}:${REVISION}
-AM_CFLAGS+= -DUADK_VERSION_NUMBER="\"libwd version: ${MAJOR}.${MINOR}.${REVISION}\""
+DAY = 11
+MONTH = Jun
+YEAR = 2022
+AM_CFLAGS+= -DUADK_VERSION_NUMBER="\"UADK version: ${MAJOR}.${MINOR}.${REVISION}\""
+AM_CFLAGS+= -DUADK_RELEASED_TIME="\"Released ${MONTH} ${DAY}, ${YEAR}\""
include_HEADERS = include/wd.h include/wd_cipher.h include/wd_aead.h \
include/wd_comp.h include/wd_dh.h include/wd_digest.h \
@@ -78,6 +82,7 @@ libhisi_hpre_la_SOURCES=drv/hisi_hpre.c drv/hisi_qm_udrv.c \
hisi_qm_udrv.h wd_hpre_drv.h
if WD_STATIC_DRV
AM_CFLAGS += -DWD_STATIC_DRV
+AM_CFLAGS += -DWD_NO_LOG
libwd_la_LIBADD = $(libwd_la_OBJECTS) -lnuma
diff --git a/include/drv/wd_aead_drv.h b/include/drv/wd_aead_drv.h
index cca28ba..de4a7d7 100644
--- a/include/drv/wd_aead_drv.h
+++ b/include/drv/wd_aead_drv.h
@@ -76,6 +76,7 @@ struct wd_aead_driver {
void wd_aead_set_driver(struct wd_aead_driver *drv);
struct wd_aead_driver *wd_aead_get_driver(void);
+struct wd_aead_msg *wd_aead_get_msg(__u32 idx, __u32 tag);
#ifdef WD_STATIC_DRV
#define WD_AEAD_SET_DRIVER(drv) \
diff --git a/include/drv/wd_cipher_drv.h b/include/drv/wd_cipher_drv.h
index 84c9844..a8da8cc 100644
--- a/include/drv/wd_cipher_drv.h
+++ b/include/drv/wd_cipher_drv.h
@@ -62,6 +62,7 @@ struct wd_cipher_driver {
void wd_cipher_set_driver(struct wd_cipher_driver *drv);
struct wd_cipher_driver *wd_cipher_get_driver(void);
+struct wd_cipher_msg *wd_cipher_get_msg(__u32 idx, __u32 tag);
#ifdef WD_STATIC_DRV
#define WD_CIPHER_SET_DRIVER(drv) \
diff --git a/include/drv/wd_dh_drv.h b/include/drv/wd_dh_drv.h
index f8e3065..57f774d 100644
--- a/include/drv/wd_dh_drv.h
+++ b/include/drv/wd_dh_drv.h
@@ -36,6 +36,7 @@ struct wd_dh_driver {
void wd_dh_set_driver(struct wd_dh_driver *drv);
struct wd_dh_driver *wd_dh_get_driver(void);
+struct wd_dh_msg *wd_dh_get_msg(__u32 idx, __u32 tag);
#ifdef WD_STATIC_DRV
#define WD_DH_SET_DRIVER(drv) \
diff --git a/include/drv/wd_digest_drv.h b/include/drv/wd_digest_drv.h
index 10ce6e1..39839f6 100644
--- a/include/drv/wd_digest_drv.h
+++ b/include/drv/wd_digest_drv.h
@@ -64,6 +64,7 @@ struct wd_digest_driver {
void wd_digest_set_driver(struct wd_digest_driver *drv);
struct wd_digest_driver *wd_digest_get_driver(void);
+struct wd_digest_msg *wd_digest_get_msg(__u32 idx, __u32 tag);
#ifdef WD_STATIC_DRV
#define WD_DIGEST_SET_DRIVER(drv) \
diff --git a/include/drv/wd_ecc_drv.h b/include/drv/wd_ecc_drv.h
index ef98606..c72cd8f 100644
--- a/include/drv/wd_ecc_drv.h
+++ b/include/drv/wd_ecc_drv.h
@@ -190,6 +190,7 @@ struct wd_ecc_driver {
void wd_ecc_set_driver(struct wd_ecc_driver *drv);
struct wd_ecc_driver *wd_ecc_get_driver(void);
+struct wd_ecc_msg *wd_ecc_get_msg(__u32 idx, __u32 tag);
#ifdef WD_STATIC_DRV
#define WD_ECC_SET_DRIVER(drv) \
diff --git a/include/drv/wd_rsa_drv.h b/include/drv/wd_rsa_drv.h
index 28c3337..22aa159 100644
--- a/include/drv/wd_rsa_drv.h
+++ b/include/drv/wd_rsa_drv.h
@@ -59,6 +59,7 @@ struct wd_rsa_driver {
void wd_rsa_set_driver(struct wd_rsa_driver *drv);
struct wd_rsa_driver *wd_rsa_get_driver(void);
+struct wd_rsa_msg *wd_rsa_get_msg(__u32 idx, __u32 tag);
#ifdef WD_STATIC_DRV
#define WD_RSA_SET_DRIVER(drv) \
diff --git a/include/wd.h b/include/wd.h
index 56c4109..8c45522 100644
--- a/include/wd.h
+++ b/include/wd.h
@@ -8,9 +8,11 @@
#define __WD_H
#include <errno.h>
#include <fcntl.h>
+#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
+#include <syslog.h>
#include <unistd.h>
#include <asm/types.h>
#include "uacce.h"
@@ -25,39 +27,37 @@ extern "C" {
#define MAX_DEV_NAME_LEN 256
#define LINUX_CRTDIR_SIZE 1
#define LINUX_PRTDIR_SIZE 2
+#define WD_CTX_CNT_NUM 1024
+#define WD_IPC_KEY 0x500011
typedef void (*wd_log)(const char *format, ...);
-#ifndef WD_ERR
-#ifndef WITH_LOG_FILE
-extern wd_log log_out;
-
-#define __WD_FILENAME__ (strrchr(__FILE__, '/') ? \
- ((char *)((uintptr_t)strrchr(__FILE__, '/') + 1)) : __FILE__)
-
-#define WD_ERR(format, args...) \
- (log_out ? log_out("[%s, %d, %s]:"format, \
- __WD_FILENAME__, __LINE__, __func__, ##args) : \
- fprintf(stderr, format, ##args))
+#ifndef WD_NO_LOG
+#define WD_DEBUG(fmt, args...) \
+ do {\
+ openlog("uadk-debug", LOG_CONS | LOG_PID, LOG_LOCAL5);\
+ syslog(LOG_DEBUG, fmt, ##args);\
+ } while (0)
+
+#define WD_INFO(fmt, args...) \
+ do {\
+ openlog("uadk-info", LOG_CONS | LOG_PID, LOG_LOCAL5);\
+ syslog(LOG_INFO, fmt, ##args);\
+ } while (0)
+
+#define WD_ERR(fmt, args...) \
+ do {\
+ openlog("uadk-err", LOG_CONS | LOG_PID, LOG_LOCAL5);\
+ syslog(LOG_ERR, fmt, ##args);\
+ } while (0)
#else
-extern FILE *flog_fd;
-#define WD_ERR(format, args...) do { \
- if (!flog_fd) \
- flog_fd = fopen(WITH_LOG_FILE, "a+"); \
- if (flog_fd) \
- fprintf(flog_fd, format, ##args); \
- else \
- fprintf(stderr, "log %s not exists!", \
- WITH_LOG_FILE); \
-} while (0)
-#endif
+#define OPEN_LOG(s)
+#define WD_DEBUG(fmt, args...) fprintf(stderr, fmt, ##args)
+#define WD_INFO(fmt, args...) fprintf(stderr, fmt, ##args)
+#define WD_ERR(fmt, args...) fprintf(stderr, fmt, ##args)
#endif
-#ifdef DEBUG_LOG
-#define dbg(msg, ...) fprintf(stderr, msg, ##__VA_ARGS__)
-#else
-#define dbg(msg, ...)
-#endif
+#define WD_CONSOLE printf
/* WD error code */
#define WD_SUCCESS 0
@@ -488,6 +488,21 @@ void wd_mempool_stats(handle_t mempool, struct wd_mempool_stats *stats);
*/
void wd_blockpool_stats(handle_t blkpool, struct wd_blockpool_stats *stats);
+/**
+ * wd_get_version() - Get the libwd version number and released time.
+ */
+void wd_get_version(void);
+
+/**
+ * wd_need_debug() - Get the debug flag from rsyslog.cnf
+ */
+bool wd_need_debug(void);
+
+/**
+ * wd_need_info() - Get the info flag from rsyslog.cnf
+ */
+bool wd_need_info(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/wd_util.h b/include/wd_util.h
index eb250f0..83a9684 100644
--- a/include/wd_util.h
+++ b/include/wd_util.h
@@ -8,6 +8,8 @@
#define __WD_UTIL_H
#include <stdbool.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
#include <asm/types.h>
#include "wd_alg_common.h"
@@ -292,7 +294,7 @@ int wd_add_task_to_async_queue(struct wd_env_config *config, __u32 idx);
*/
void dump_env_info(struct wd_env_config *config);
-/*
+/**
* wd_alg_get_env_param() - get specific ctx number.
* @config: Pointer of wd_env_config which is used to store environment
* variable information.
@@ -304,7 +306,7 @@ int wd_alg_get_env_param(struct wd_env_config *env_config,
struct wd_ctx_attr attr,
__u32 *num, __u8 *is_enable);
-/*
+/**
* wd_set_ctx_attr() - set node type and mode for ctx
* @ctx_attr: ctx attributes pointer.
* @node: numa id.
@@ -315,7 +317,7 @@ int wd_alg_get_env_param(struct wd_env_config *env_config,
int wd_set_ctx_attr(struct wd_ctx_attr *ctx_attr,
__u32 node, __u32 type, __u8 mode, __u32 num);
-/*
+/**
* wd_check_ctx() - check ctx mode and index
* @config: ctx config pointer.
* @mode: synchronous or asynchronous mode.
@@ -354,6 +356,23 @@ int wd_handle_msg_sync(struct wd_msg_handle *msg_handle, handle_t ctx,
*/
int wd_init_param_check(struct wd_ctx_config *config, struct wd_sched *sched);
+/**
+ * wd_dfx_msg_cnt() - Message counter interface for ctx
+ * @msg: Shared memory addr.
+ * @numSize: Number of elements.
+ * @index: Indicates the CTX index.
+ */
+static inline void wd_dfx_msg_cnt(unsigned long *msg, __u32 numsize, __u32 idx)
+{
+ bool ret;
+
+ ret = wd_need_info();
+ if (idx > numsize || !ret)
+ return;
+
+ msg[idx]++;
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/test/hisi_zip_test/test_lib.c b/test/hisi_zip_test/test_lib.c
index 374244a..5918699 100644
--- a/test/hisi_zip_test/test_lib.c
+++ b/test/hisi_zip_test/test_lib.c
@@ -22,6 +22,8 @@ struct check_rand_ctx {
unsigned short state[3];
};
+#define dbg(msg, ...) fprintf(stderr, msg, ##__VA_ARGS__)
+
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_spinlock_t lock;
static int count = 0;
diff --git a/uadk_tool/Makefile.am b/uadk_tool/Makefile.am
index da5b229..f04b2f0 100644
--- a/uadk_tool/Makefile.am
+++ b/uadk_tool/Makefile.am
@@ -1,13 +1,16 @@
ACLOCAL_AMFLAGS = -I m4 -I./include
-AM_CFLAGS=-Wall -fno-strict-aliasing -I$(top_srcdir) -I$(top_srcdir)/include \
+AUTOMAKE_OPTIONS = foreign subdir-objects
+AM_CFLAGS=-Wall -fno-strict-aliasing -I$(top_srcdir) -I$(top_srcdir)/benchmark/include \
-pthread
#AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS=uadk_tool
-uadk_tool_SOURCES=uadk_tool.c uadk_dfx.c uadk_benchmark.c \
- sec_uadk_benchmark.c sec_wd_benchmark.c
+uadk_tool_SOURCES=uadk_tool.c dfx/uadk_dfx.c dfx/uadk_dfx.h \
+ benchmark/uadk_benchmark.c benchmark/uadk_benchmark.h \
+ benchmark/sec_uadk_benchmark.c benchmark/sec_uadk_benchmark.h \
+ benchmark/sec_wd_benchmark.c benchmark/sec_wd_benchmark.h
if WD_STATIC_DRV
AM_CFLAGS+=-Bstatic
@@ -27,7 +30,7 @@ uadk_tool_LDFLAGS=-Wl,-rpath,'/usr/local/lib'
if WITH_OPENSSL_DIR
AM_CFLAGS+= -DWITH_OPENSSL_DIR -I$(with_openssl_dir)/include
-uadk_tool_SOURCES+=sec_soft_benchmark.c
+uadk_tool_SOURCES+=benchmark/sec_soft_benchmark.c benchmark/sec_soft_benchmark.h
if WD_STATIC_DRV
uadk_tool_LDADD+= $(with_openssl_dir)/libcrypto.a
diff --git a/uadk_tool/sec_soft_benchmark.c b/uadk_tool/benchmark/sec_soft_benchmark.c
similarity index 100%
rename from uadk_tool/sec_soft_benchmark.c
rename to uadk_tool/benchmark/sec_soft_benchmark.c
diff --git a/uadk_tool/sec_soft_benchmark.h b/uadk_tool/benchmark/sec_soft_benchmark.h
similarity index 100%
rename from uadk_tool/sec_soft_benchmark.h
rename to uadk_tool/benchmark/sec_soft_benchmark.h
diff --git a/uadk_tool/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
similarity index 100%
rename from uadk_tool/sec_uadk_benchmark.c
rename to uadk_tool/benchmark/sec_uadk_benchmark.c
diff --git a/uadk_tool/sec_uadk_benchmark.h b/uadk_tool/benchmark/sec_uadk_benchmark.h
similarity index 100%
rename from uadk_tool/sec_uadk_benchmark.h
rename to uadk_tool/benchmark/sec_uadk_benchmark.h
diff --git a/uadk_tool/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c
similarity index 100%
rename from uadk_tool/sec_wd_benchmark.c
rename to uadk_tool/benchmark/sec_wd_benchmark.c
diff --git a/uadk_tool/sec_wd_benchmark.h b/uadk_tool/benchmark/sec_wd_benchmark.h
similarity index 100%
rename from uadk_tool/sec_wd_benchmark.h
rename to uadk_tool/benchmark/sec_wd_benchmark.h
diff --git a/uadk_tool/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
similarity index 99%
rename from uadk_tool/uadk_benchmark.c
rename to uadk_tool/benchmark/uadk_benchmark.c
index 8c3c96f..84941d5 100644
--- a/uadk_tool/uadk_benchmark.c
+++ b/uadk_tool/benchmark/uadk_benchmark.c
@@ -567,7 +567,7 @@ static void print_help(void)
ACC_TST_PRT("UPDATE:2021-7-28\n");
}
-void benchmark_cmd_parse(int argc, char *argv[], struct acc_option *option)
+int acc_cmd_parse(int argc, char *argv[], struct acc_option *option)
{
int option_index = 0;
int c;
@@ -638,6 +638,7 @@ void benchmark_cmd_parse(int argc, char *argv[], struct acc_option *option)
exit(-1);
}
}
+ return 0;
}
int acc_option_convert(struct acc_option *option)
diff --git a/uadk_tool/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
similarity index 97%
rename from uadk_tool/uadk_benchmark.h
rename to uadk_tool/benchmark/uadk_benchmark.h
index 7ce0426..2cb3dc0 100644
--- a/uadk_tool/uadk_benchmark.h
+++ b/uadk_tool/benchmark/uadk_benchmark.h
@@ -170,7 +170,7 @@ extern void add_recv_data(u32 cnt);
extern void add_send_complete(void);
extern u32 get_recv_time(void);
-void benchmark_cmd_parse(int argc, char *argv[], struct acc_option *option);
+int acc_cmd_parse(int argc, char *argv[], struct acc_option *option);
int acc_default_case(struct acc_option *option);
int acc_option_convert(struct acc_option *option);
int acc_benchmark_run(struct acc_option *option);
diff --git a/uadk_tool/dfx/uadk_dfx.c b/uadk_tool/dfx/uadk_dfx.c
new file mode 100644
index 0000000..796135a
--- /dev/null
+++ b/uadk_tool/dfx/uadk_dfx.c
@@ -0,0 +1,253 @@
+/* SPDX-License-Identifier: Apache-2.0 */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <getopt.h>
+#include <unistd.h>
+#include <limits.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#include "include/wd.h"
+#include "uadk_dfx.h"
+
+#define uadk_build_date() printf("built on: %s %s\n", __DATE__, __TIME__)
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#define PRIVILEGE_FLAG 666
+
+struct uadk_env_var {
+ const char *module;
+ const char *alg;
+ const char *ctx_num_var;
+ const char *epoll_en_var;
+};
+
+struct uadk_env_table {
+ int sync_ctx_num;
+ int sync_numa;
+ int async_ctx_num;
+ int async_numa;
+ int poll_en;
+};
+
+enum dfx_op_type {
+ DISPLAY_VERSION = 2,
+ DISPLAY_DATE,
+ DISPLAY_DIR,
+ DISPLAY_ENV,
+ DISPLAY_COUNT,
+ DISPLAY_HELP,
+};
+
+const char *uadk_modules[] = {"sec", "hpre", "zip"};
+
+const struct uadk_env_var env_vars[] = {
+ {.module = "sec", .alg = "CIPHER", .ctx_num_var = "WD_CIPHER_CTX_NUM",
+ .epoll_en_var = "WD_CIPHER_EPOLL_EN"},
+ {.module = "sec", .alg = "AEAD", .ctx_num_var = "WD_AEAD_CTX_NUM",
+ .epoll_en_var = "WD_AEAD_EPOLL_EN"},
+ {.module = "sec", .alg = "DIGEST", .ctx_num_var = "WD_DIGEST_CTX_NUM",
+ .epoll_en_var = "WD_DIGEST_EPOLL_EN"},
+ {.module = "hpre", .alg = "DH", .ctx_num_var = "WD_DH_CTX_NUM",
+ .epoll_en_var = "WD_DH_EPOLL_EN"},
+ {.module = "hpre", .alg = "RSA", .ctx_num_var = "WD_RSA_CTX_NUM",
+ .epoll_en_var = "WD_RSA_EPOLL_EN"},
+ {.module = "hpre", .alg = "ECC", .ctx_num_var = "WD_ECC_CTX_NUM",
+ .epoll_en_var = "WD_ECC_EPOLL_EN"},
+ {.module = "zip", .alg = "COMP", .ctx_num_var = "WD_COMP_CTX_NUM",
+ .epoll_en_var = "WD_COMP_EPOLL_EN"},
+};
+
+static void dump_ctx_count(unsigned long *count)
+{
+ __u32 idx = 0;
+ int i;
+
+ if (!count)
+ return;
+
+ printf("displays the ctx counter value...\n");
+ for (i = 0; i < WD_CTX_CNT_NUM; i++) {
+ if (count[i]) {
+ printf("ctx-[%d]:%lu \t", i, count[i]);
+ idx++;
+ } else {
+ continue;
+ }
+
+ if ((idx & 0x3) == 0)
+ printf("\n");
+ }
+ printf("\n");
+}
+
+static int get_shared_id(void)
+{
+ int shm;
+
+ shm = shmget(WD_IPC_KEY, sizeof(unsigned long) * WD_CTX_CNT_NUM,
+ IPC_CREAT | PRIVILEGE_FLAG);
+ if (shm < 0) {
+ printf("failed to get the shared memory id.\n");
+ return -EINVAL;
+ }
+
+ return shm;
+}
+
+static int uadk_shared_read(void)
+{
+ unsigned long *shared;
+ void *ptr;
+ int shm;
+
+ shm = get_shared_id();
+ if (shm < 0)
+ return -EINVAL;
+
+ ptr = (int *)shmat(shm, NULL, 0);
+ if (ptr < 0) {
+ printf("failed to get the shared memory addr.\n");
+ return -EINVAL;
+ }
+
+ shared = (unsigned long *)ptr;
+
+ printf("get the shared memory addr successful.\n");
+ dump_ctx_count(shared);
+
+ shmdt(ptr);
+
+ return 0;
+}
+
+bool uadk_check_module(const char *module)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(uadk_modules); i++) {
+ if (!strncmp(module, uadk_modules[i], strlen(module)))
+ return true;
+ }
+
+ return false;
+}
+
+static void uadk_ctx_env_config(const char *s)
+{
+ char *env_setion;
+
+ if (!s) {
+ printf("input ctx env config is NULL.\n");
+ return;
+ }
+
+ env_setion = getenv(s);
+ if (!env_setion) {
+ printf("not found the %s env config!\n", s);
+ return;
+ }
+
+ printf("%s=%s\n", s, env_setion);
+}
+
+static void uadk_parse_env_config(const char *module)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(env_vars); i++) {
+ if (!strncmp(module, env_vars[i].module, strlen(module))) {
+ uadk_ctx_env_config(env_vars[i].ctx_num_var);
+ uadk_ctx_env_config(env_vars[i].epoll_en_var);
+ }
+ }
+}
+
+static void uadk_exe_path(void)
+{
+ char dir[PATH_MAX] = {0};
+ int n;
+
+ n = readlink("/proc/self/exe", dir, PATH_MAX);
+ if (n < 0 || n >= PATH_MAX)
+ printf("uadk tool failed to get the exe path.\n");
+
+ dir[PATH_MAX - 1] = '\0';
+ printf("exe path: %s\n", dir);
+}
+
+void print_dfx_help(void)
+{
+ printf("NAME\n");
+ printf(" uadk_tool dfx : uadk library dfx function, etc\n");
+ printf("USAGE\n");
+ printf(" uadk_tool dfx [--version] = Show library version\n");
+ printf(" uadk_tool dfx [--date] = Show build date\n");
+ printf(" uadk_tool dfx [--dir] = Show library dir\n");
+ printf(" uadk_tool dfx [--env] = Show environment variables\n");
+ printf(" uadk_tool dfx [--count] = Show the ctx message count\n");
+ printf(" uadk_tool dfx [--help] = usage\n");
+ printf("Example\n");
+ printf(" uadk_tool dfx --version\n");
+ printf(" uadk_tool dfx --env sec\n");
+ printf(" uadk_tool dfx --count\n");
+}
+
+void dfx_cmd_parse(int argc, char *argv[])
+{
+ bool check_module = false;
+ char *input_module = NULL;
+ int option_index = 0;
+ int opt;
+
+ static struct option long_options[] = {
+ {"version", no_argument, 0, 2},
+ {"date", no_argument, 0, 3},
+ {"dir", no_argument, 0, 4},
+ {"env", required_argument, 0, 5},
+ {"count", no_argument, 0, 6},
+ {"help", no_argument, 0, 7},
+ {0, 0, 0, 0}
+ };
+
+ while (1) {
+ opt = getopt_long(argc, argv, "", long_options, &option_index);
+ if (opt == -1)
+ break;
+
+ switch (opt) {
+ case DISPLAY_VERSION:
+ wd_get_version();
+ break;
+ case DISPLAY_DATE:
+ uadk_build_date();
+ break;
+ case DISPLAY_DIR:
+ uadk_exe_path();
+ break;
+ case DISPLAY_ENV:
+ input_module = optarg;
+ check_module = uadk_check_module(input_module);
+ if (check_module) {
+ uadk_parse_env_config(input_module);
+ } else {
+ print_dfx_help();
+ printf("failed to parse module parameter!\n");
+ }
+ break;
+ case DISPLAY_COUNT:
+ uadk_shared_read();
+ break;
+ case DISPLAY_HELP:
+ print_dfx_help();
+ break;
+ default:
+ printf("bad input parameter, exit!\n");
+ print_dfx_help();
+ break;
+ }
+ }
+}
diff --git a/uadk_tool/uadk_dfx.h b/uadk_tool/dfx/uadk_dfx.h
similarity index 59%
rename from uadk_tool/uadk_dfx.h
rename to uadk_tool/dfx/uadk_dfx.h
index 5f5d9e7..8dc1da1 100644
--- a/uadk_tool/uadk_dfx.h
+++ b/uadk_tool/dfx/uadk_dfx.h
@@ -2,9 +2,6 @@
#ifndef UADK_DFX_H
#define UADK_DFX_H
-#define UADK_VERSION_TEXT "UADK 2.3.22, Released Dec 20th, 2021"
-#define UADK_VERSION_TAG "4b9c69d"
-
void print_dfx_help(void);
void dfx_cmd_parse(int argc, char *argv[]);
#endif
diff --git a/uadk_tool/uadk_dfx.c b/uadk_tool/uadk_dfx.c
deleted file mode 100644
index 96c4919..0000000
--- a/uadk_tool/uadk_dfx.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* SPDX-License-Identifier: Apache-2.0 */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <getopt.h>
-#include <unistd.h>
-#include <limits.h>
-#include "uadk_dfx.h"
-
-#define print_date() printf("built on: %s %s\n", __DATE__, __TIME__)
-
-static void print_version(void)
-{
- printf("%s\n", UADK_VERSION_TEXT);
- printf("%s\n", UADK_VERSION_TAG);
-}
-
-static void print_exe_path(void)
-{
- char dir[PATH_MAX] = {0};
- int n;
-
- n = readlink("/proc/self/exe", dir, PATH_MAX);
- if (n < 0 || n >= PATH_MAX)
- printf("uadk tool failed to get the exe path.\n");
-
- printf("exe path: %s\n", dir);
-}
-
-void print_dfx_help(void)
-{
- printf("NAME\n");
- printf(" uadk_tool --dfx : uadk library dfx function, etc\n");
- printf("USAGE\n");
- printf(" uadk_tool --dfx [--version] = Show library version\n");
- printf(" uadk_tool --dfx [--date] = Show build date\n");
- printf(" uadk_tool --dfx [--dir] = Show library dir\n");
- printf(" uadk_tool --dfx [--help] = usage\n");
-}
-
-void dfx_cmd_parse(int argc, char *argv[])
-{
- int option_index = 0;
- int c;
-
- static struct option long_options[] = {
- {"version", no_argument, 0, 2},
- {"date", no_argument, 0, 3},
- {"dir", no_argument, 0, 4},
- {"help", no_argument, 0, 5},
- {0, 0, 0, 0}
- };
-
- while (1) {
- c = getopt_long(argc, argv, "", long_options, &option_index);
- if (c == -1)
- break;
-
- switch (c) {
- case 2:
- print_version();
- break;
- case 3:
- print_date();
- break;
- case 4:
- print_exe_path();
- break;
- case 5:
- print_dfx_help();
- break;
- default:
- printf("bad input parameter, exit\n");
- exit(-1);
- }
- }
-}
diff --git a/uadk_tool/uadk_tool.c b/uadk_tool/uadk_tool.c
index 88beeba..ce83d7a 100644
--- a/uadk_tool/uadk_tool.c
+++ b/uadk_tool/uadk_tool.c
@@ -1,12 +1,9 @@
/* SPDX-License-Identifier: Apache-2.0 */
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include <time.h>
-#include <limits.h>
-#include "uadk_dfx.h"
-#include "uadk_benchmark.h"
+#include "dfx/uadk_dfx.h"
+#include "benchmark/uadk_benchmark.h"
static void print_tool_help(void)
{
@@ -18,17 +15,21 @@ static void print_tool_help(void)
int main(int argc, char **argv)
{
struct acc_option option = {0};
+ int index = 1;
int ret;
- if (argc > 1) {
- if (!strcmp("dfx", argv[1])) {
+ if (argc > index) {
+ if (!strcmp("dfx", argv[index])) {
dfx_cmd_parse(argc, argv);
- } else if (!strcmp("benchmark", argv[1])) {
+ } else if (!strcmp("benchmark", argv[index])) {
printf("start UADK benchmark test.\n");
- if (!argv[2])
+ if (!argv[++index])
acc_default_case(&option);
- benchmark_cmd_parse(argc, argv, &option);
+ ret = acc_cmd_parse(argc, argv, &option);
+ if (ret)
+ return ret;
+
ret = acc_option_convert(&option);
if (ret)
return ret;
diff --git a/wd.c b/wd.c
index 3ce9c1e..2dbb2ab 100644
--- a/wd.c
+++ b/wd.c
@@ -14,6 +14,7 @@
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
+#include <sys/stat.h>
#include <numa.h>
#include <sched.h>
@@ -22,7 +23,14 @@
#define SYS_CLASS_DIR "/sys/class/uacce"
-const char *WD_VERSION = UADK_VERSION_NUMBER;
+enum UADK_LOG_LEVEL {
+ LOG_NONE = 0,
+ WD_LOG_ERROR,
+ WD_LOG_INFO,
+ WD_LOG_DEBUG,
+};
+
+static int uadk_log_level;
struct wd_ctx_h {
int fd;
@@ -35,6 +43,54 @@ struct wd_ctx_h {
void *priv;
};
+static void wd_parse_log_level(void)
+{
+ const char *syslog_file = "/etc/rsyslog.conf";
+ const char *log_dir = "/var/log/uadk.log";
+ bool log_debug = false;
+ bool log_info = false;
+ struct stat file_info;
+ char *file_contents;
+ FILE *in_file;
+
+ in_file = fopen(syslog_file, "r");
+ if (!in_file) {
+ WD_ERR("failed to open the rsyslog.conf file.\n");
+ return;
+ }
+
+ if (stat(syslog_file, &file_info) == -1) {
+ WD_ERR("failed to get file information.\n");
+ goto close_file;
+ }
+
+ file_contents = malloc(file_info.st_size);
+ if (!file_contents) {
+ WD_ERR("failed to get file contents memory.\n");
+ goto close_file;
+ }
+
+ while (fscanf(in_file, "%[^\n ] ", file_contents) != EOF) {
+ if (!strcmp("local5.debug", file_contents))
+ log_debug = true;
+ else if (!strcmp("local5.info", file_contents))
+ log_info = true;
+
+ if (log_debug && !strcmp(log_dir, file_contents)) {
+ uadk_log_level = WD_LOG_DEBUG;
+ break;
+ } else if (log_info && !strcmp(log_dir, file_contents)) {
+ uadk_log_level = WD_LOG_INFO;
+ break;
+ }
+ }
+
+ free(file_contents);
+
+close_file:
+ fclose(in_file);
+}
+
static int get_raw_attr(const char *dev_root, const char *attr, char *buf,
size_t sz)
{
@@ -189,6 +245,8 @@ static struct uacce_dev *read_uacce_sysfs(const char *dev_name)
if (!dev_name)
return NULL;
+ wd_parse_log_level();
+
dev = calloc(1, sizeof(struct uacce_dev));
if (!dev)
return NULL;
@@ -731,3 +789,22 @@ int wd_ctx_set_io_cmd(handle_t h_ctx, unsigned long cmd, void *arg)
return ioctl(ctx->fd, cmd, arg);
}
+
+void wd_get_version(void)
+{
+ const char *wd_released_time = UADK_RELEASED_TIME;
+ const char *wd_version = UADK_VERSION_NUMBER;
+
+ WD_CONSOLE("%s\n", wd_version);
+ WD_CONSOLE("%s\n", wd_released_time);
+}
+
+bool wd_need_debug(void)
+{
+ return uadk_log_level >= WD_LOG_DEBUG;
+}
+
+bool wd_need_info(void)
+{
+ return uadk_log_level >= WD_LOG_INFO;
+}
diff --git a/wd_aead.c b/wd_aead.c
index 7c07271..d43ace1 100644
--- a/wd_aead.c
+++ b/wd_aead.c
@@ -413,7 +413,7 @@ int wd_aead_init(struct wd_ctx_config *config, struct wd_sched *sched)
wd_aead_set_static_drv();
#endif
- /* init sync request pool */
+ /* init async request pool */
ret = wd_init_async_request_pool(&wd_aead_setting.pool,
config->ctx_num, WD_POOL_MAX_ENTRIES,
sizeof(struct wd_aead_msg));
@@ -531,6 +531,7 @@ int wd_do_aead_sync(handle_t h_sess, struct wd_aead_req *req)
if (unlikely(ret))
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
ret = send_recv_sync(ctx, &msg);
req->state = msg.result;
@@ -563,6 +564,7 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req)
if (ret)
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
msg_id = wd_get_msg_from_pool(&wd_aead_setting.pool,
@@ -594,6 +596,11 @@ fail_with_msg:
return ret;
}
+struct wd_aead_msg *wd_aead_get_msg(__u32 idx, __u32 tag)
+{
+ return wd_find_msg_in_pool(&wd_aead_setting.pool, idx, tag);
+}
+
int wd_aead_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
{
struct wd_ctx_config_internal *config = &wd_aead_setting.config;
diff --git a/wd_cipher.c b/wd_cipher.c
index a7e393b..3d00598 100644
--- a/wd_cipher.c
+++ b/wd_cipher.c
@@ -442,7 +442,9 @@ int wd_do_cipher_sync(handle_t h_sess, struct wd_cipher_req *req)
if (unlikely(ret))
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
+
ret = send_recv_sync(ctx, &msg);
req->state = msg.result;
@@ -472,6 +474,7 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req)
return ret;
ctx = config->ctxs + idx;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
msg_id = wd_get_msg_from_pool(&wd_cipher_setting.pool, idx,
(void **)&msg);
@@ -502,6 +505,11 @@ fail_with_msg:
return ret;
}
+struct wd_cipher_msg *wd_cipher_get_msg(__u32 idx, __u32 tag)
+{
+ return wd_find_msg_in_pool(&wd_cipher_setting.pool, idx, tag);
+}
+
int wd_cipher_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
{
struct wd_ctx_config_internal *config = &wd_cipher_setting.config;
diff --git a/wd_comp.c b/wd_comp.c
index 9107d60..eacebd3 100644
--- a/wd_comp.c
+++ b/wd_comp.c
@@ -406,6 +406,7 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess,
if (unlikely(ret))
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
msg_handle.send = wd_comp_setting.driver->comp_send;
@@ -656,6 +657,7 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
if (unlikely(ret))
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
tag = wd_get_msg_from_pool(&wd_comp_setting.pool, idx, (void **)&msg);
diff --git a/wd_dh.c b/wd_dh.c
index 9571ab6..cfe294d 100644
--- a/wd_dh.c
+++ b/wd_dh.c
@@ -212,6 +212,7 @@ int wd_do_dh_sync(handle_t sess, struct wd_dh_req *req)
if (ret)
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
memset(&msg, 0, sizeof(struct wd_dh_msg));
@@ -257,6 +258,7 @@ int wd_do_dh_async(handle_t sess, struct wd_dh_req *req)
if (ret)
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
mid = wd_get_msg_from_pool(&wd_dh_setting.pool, idx, (void **)&msg);
@@ -288,6 +290,11 @@ fail_with_msg:
return ret;
}
+struct wd_dh_msg *wd_dh_get_msg(__u32 idx, __u32 tag)
+{
+ return wd_find_msg_in_pool(&wd_dh_setting.pool, idx, tag);
+}
+
int wd_dh_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
{
struct wd_ctx_config_internal *config = &wd_dh_setting.config;
diff --git a/wd_digest.c b/wd_digest.c
index 0fff7c8..43b4bc5 100644
--- a/wd_digest.c
+++ b/wd_digest.c
@@ -340,6 +340,7 @@ int wd_do_digest_sync(handle_t h_sess, struct wd_digest_req *req)
if (unlikely(ret))
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
ret = send_recv_sync(ctx, dsess, &msg);
req->state = msg.result;
@@ -372,6 +373,7 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req)
if (ret)
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
msg_id = wd_get_msg_from_pool(&wd_digest_setting.pool, idx,
@@ -403,6 +405,11 @@ fail_with_msg:
return ret;
}
+struct wd_digest_msg *wd_digest_get_msg(__u32 idx, __u32 tag)
+{
+ return wd_find_msg_in_pool(&wd_digest_setting.pool, idx, tag);
+}
+
int wd_digest_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
{
struct wd_ctx_config_internal *config = &wd_digest_setting.config;
diff --git a/wd_ecc.c b/wd_ecc.c
index 76c9d5f..9d30607 100644
--- a/wd_ecc.c
+++ b/wd_ecc.c
@@ -853,14 +853,14 @@ static int fill_user_curve_cfg(struct wd_ecc_curve *param,
if (setup->cv.type == WD_CV_CFG_ID) {
curve_id = setup->cv.cfg.id;
ret = fill_param_by_id(param, setup->key_bits, curve_id);
- dbg("set curve id %u!\n", curve_id);
+ WD_DEBUG("set curve id %u!\n", curve_id);
} else if (setup->cv.type == WD_CV_CFG_PARAM) {
ret = set_key_cv(param, src_param);
if (ret) {
WD_ERR("failed to set key cv!\n");
return ret;
}
- dbg("set curve by user param!\n");
+ WD_DEBUG("set curve by user param!\n");
} else {
WD_ERR("invalid: fill curve cfg type %u is error!\n", setup->cv.type);
return -WD_EINVAL;
@@ -1407,6 +1407,7 @@ int wd_do_ecc_sync(handle_t h_sess, struct wd_ecc_req *req)
if (ret)
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
memset(&msg, 0, sizeof(struct wd_ecc_msg));
@@ -2086,6 +2087,7 @@ int wd_do_ecc_async(handle_t sess, struct wd_ecc_req *req)
if (ret)
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
mid = wd_get_msg_from_pool(&wd_ecc_setting.pool, idx, (void **)&msg);
@@ -2116,6 +2118,11 @@ fail_with_msg:
return ret;
}
+struct wd_ecc_msg *wd_ecc_get_msg(__u32 idx, __u32 tag)
+{
+ return wd_find_msg_in_pool(&wd_ecc_setting.pool, idx, tag);
+}
+
int wd_ecc_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
{
struct wd_ctx_config_internal *config = &wd_ecc_setting.config;
diff --git a/wd_rsa.c b/wd_rsa.c
index 868e78b..d65b01d 100644
--- a/wd_rsa.c
+++ b/wd_rsa.c
@@ -272,6 +272,7 @@ int wd_do_rsa_sync(handle_t h_sess, struct wd_rsa_req *req)
if (ret)
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
memset(&msg, 0, sizeof(struct wd_rsa_msg));
@@ -317,6 +318,7 @@ int wd_do_rsa_async(handle_t sess, struct wd_rsa_req *req)
if (ret)
return ret;
+ wd_dfx_msg_cnt(config->msg_cnt, WD_CTX_CNT_NUM, idx);
ctx = config->ctxs + idx;
mid = wd_get_msg_from_pool(&wd_rsa_setting.pool, idx, (void **)&msg);
@@ -347,6 +349,11 @@ fail_with_msg:
return ret;
}
+struct wd_rsa_msg *wd_rsa_get_msg(__u32 idx, __u32 tag)
+{
+ return wd_find_msg_in_pool(&wd_rsa_setting.pool, idx, tag);
+}
+
int wd_rsa_poll_ctx(__u32 idx, __u32 expt, __u32 *count)
{
struct wd_ctx_config_internal *config = &wd_rsa_setting.config;
diff --git a/wd_util.c b/wd_util.c
index de77d1e..04a2a5b 100644
--- a/wd_util.c
+++ b/wd_util.c
@@ -20,6 +20,7 @@
#define WD_BALANCE_THRHD 1280
#define WD_RECV_MAX_CNT_SLEEP 60000000
#define WD_RECV_MAX_CNT_NOSLEEP 200000000
+#define PRIVILEGE_FLAG 600
struct msg_pool {
/* message array allocated dynamically */
@@ -70,11 +71,76 @@ static void clone_ctx_to_internal(struct wd_ctx *ctx,
ctx_in->ctx_mode = ctx->ctx_mode;
}
+static int get_shared_memory_id(__u32 numsize)
+{
+ int shm;
+
+ shm = shmget(WD_IPC_KEY, sizeof(unsigned long) * numsize,
+ IPC_CREAT | PRIVILEGE_FLAG);
+ if (shm < 0) {
+ WD_ERR("failed to get shared memory id.\n");
+ return -WD_EINVAL;
+ }
+
+ return shm;
+}
+
+static unsigned long *wd_shared_create(__u32 numsize)
+{
+ bool need_info = wd_need_info();
+ void *ptr;
+ int shm;
+
+ if (!need_info)
+ return NULL;
+
+ if (numsize > WD_CTX_CNT_NUM) {
+ WD_ERR("invalid: input parameter is err!\n");
+ return NULL;
+ }
+
+ shm = get_shared_memory_id(numsize);
+ if (shm < 0)
+ return NULL;
+
+ ptr = shmat(shm, NULL, 0);
+ if (ptr == (void *)-1) {
+ WD_ERR("failed to get shared memory addr.\n");
+ return NULL;
+ }
+
+ memset(ptr, 0, sizeof(unsigned long) * numsize);
+
+ return ptr;
+}
+
+static void wd_shared_delete(__u32 numsize)
+{
+ bool need_info = wd_need_info();
+ int shm;
+
+ if (!need_info)
+ return;
+
+ if (numsize > WD_CTX_CNT_NUM) {
+ WD_ERR("invalid: input parameter is err!\n");
+ return;
+ }
+
+ shm = get_shared_memory_id(numsize);
+ if (shm < 0)
+ return;
+
+ /* deleted shared memory */
+ shmctl(shm, IPC_RMID, NULL);
+}
+
int wd_init_ctx_config(struct wd_ctx_config_internal *in,
struct wd_ctx_config *cfg)
{
+ bool need_info = wd_need_info();
struct wd_ctx_internal *ctxs;
- int i, ret;
+ int i, j, ret;
if (!cfg->ctx_num) {
WD_ERR("invalid: ctx_num is 0!\n");
@@ -87,25 +153,29 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
return -WD_EEXIST;
}
+ in->msg_cnt = wd_shared_create(WD_CTX_CNT_NUM);
+ if (!in->msg_cnt && need_info)
+ return -WD_EINVAL;
+
ctxs = calloc(1, cfg->ctx_num * sizeof(struct wd_ctx_internal));
if (!ctxs) {
WD_ERR("failed to alloc memory for internal ctxs!\n");
+ wd_shared_delete(WD_CTX_CNT_NUM);
return -WD_ENOMEM;
}
for (i = 0; i < cfg->ctx_num; i++) {
if (!cfg->ctxs[i].ctx) {
WD_ERR("invalid: ctx is NULL!\n");
- free(ctxs);
- return -WD_EINVAL;
+ ret = -WD_EINVAL;
+ goto err_out;
}
clone_ctx_to_internal(cfg->ctxs + i, ctxs + i);
ret = pthread_spin_init(&ctxs[i].lock, PTHREAD_PROCESS_SHARED);
if (ret) {
WD_ERR("failed to init ctxs lock!\n");
- free(ctxs);
- return ret;
+ goto err_out;
}
}
@@ -115,6 +185,14 @@ int wd_init_ctx_config(struct wd_ctx_config_internal *in,
in->ctx_num = cfg->ctx_num;
return 0;
+
+err_out:
+ for (j = 0; j < i; j++)
+ pthread_spin_destroy(&ctxs[j].lock);
+
+ wd_shared_delete(WD_CTX_CNT_NUM);
+ free(ctxs);
+ return ret;
}
int wd_init_sched(struct wd_sched *in, struct wd_sched *from)
@@ -161,6 +239,9 @@ void wd_clear_ctx_config(struct wd_ctx_config_internal *in)
free(in->ctxs);
in->ctxs = NULL;
}
+
+ wd_shared_delete(WD_CTX_CNT_NUM);
+ in->msg_cnt = NULL;
}
void wd_memset_zero(void *data, __u32 size)
--
2.33.0
1
4
After a series of modification, the 'hw_msg->low_tag' is used to
represent the sequence of sync or async task element now.
In async mode, the value of 'hw_msg->low_tag' comes from async task
pool, refers to wd_get_msg_from_pool(). In sync mode, the value of
'hw_msg->low_tag' is a random number, refers to hisi_set_msg_id().
Therefore, whether 'hw_msg->low_tag' is zero cannot be used as the
judgment condition for different modes, so 'hw_msg->low_tag' cannot
be set to zero directly. This is the reason why the async task of
sm2 failed.
To fix this problem, we remove the operation of setting tag to zero,
use 'qp_mode' to distinguish between sync and async modes.
Signed-off-by: Zhiqi Song <songzhiqi1(a)huawei.com>
---
drv/hisi_hpre.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c
index 5d6e537..116097d 100644
--- a/drv/hisi_hpre.c
+++ b/drv/hisi_hpre.c
@@ -827,7 +827,6 @@ static int ecc_prepare_alg(struct wd_ecc_msg *msg,
return 0;
}
-
static int trans_cv_param_to_hpre_bin(struct wd_dtb *p, struct wd_dtb *a,
struct wd_dtb *b, struct wd_dtb *n,
struct wd_ecc_point *g)
@@ -1942,13 +1941,12 @@ static int sm2_enc_out_transfer(struct wd_ecc_msg *msg,
}
static int ecc_out_transfer(struct wd_ecc_msg *msg,
- struct hisi_hpre_sqe *hw_msg)
+ struct hisi_hpre_sqe *hw_msg, __u8 qp_mode)
{
int ret = -WD_EINVAL;
void *va;
- /* async */
- if (LW_U16(hw_msg->low_tag)) {
+ if (qp_mode == CTX_MODE_ASYNC) {
va = VA_ADDR(hw_msg->hi_out, hw_msg->low_out);
msg->req.dst = container_of(va, struct wd_ecc_out, data);
}
@@ -2240,7 +2238,8 @@ static int sm2_convert_dec_out(struct wd_ecc_msg *src,
return ret;
}
-static int ecc_sqe_parse(struct hisi_qp *qp, struct wd_ecc_msg *msg, struct hisi_hpre_sqe *hw_msg)
+static int ecc_sqe_parse(struct hisi_qp *qp, struct wd_ecc_msg *msg,
+ struct hisi_hpre_sqe *hw_msg)
{
struct wd_ecc_msg *temp_msg;
__u64 tag;
@@ -2262,7 +2261,7 @@ static int ecc_sqe_parse(struct hisi_qp *qp, struct wd_ecc_msg *msg, struct hisi
hpre_result_check(hw_msg, &msg->result);
if (!msg->result) {
- ret = ecc_out_transfer(msg, hw_msg);
+ ret = ecc_out_transfer(msg, hw_msg, qp->q_info.qp_mode);
if (ret) {
msg->result = WD_OUT_EPARA;
WD_ERR("failed to transfer out ecc BD, ret = %d!\n", ret);
@@ -2306,7 +2305,7 @@ static int parse_second_sqe(handle_t h_qp,
hsz = (hw_msg.task_len1 + 1) * BYTE_BITS;
dst = *(struct wd_ecc_msg **)((uintptr_t)data +
hsz * ECDH_OUT_PARAM_NUM);
- hw_msg.low_tag = 0; /* use sync mode */
+
ret = ecc_sqe_parse((struct hisi_qp *)h_qp, dst, &hw_msg);
msg->result = dst->result;
*second = dst;
@@ -2325,6 +2324,7 @@ static int sm2_enc_parse(handle_t h_qp,
__u32 hsz;
int ret;
+ msg->tag = tag;
data = VA_ADDR(hw_msg->hi_out, hw_msg->low_out);
hsz = (hw_msg->task_len1 + 1) * BYTE_BITS;
first = *(struct wd_ecc_msg **)((uintptr_t)data +
@@ -2332,7 +2332,6 @@ static int sm2_enc_parse(handle_t h_qp,
memcpy(&src, first + 1, sizeof(src));
/* parse first sqe */
- hw_msg->low_tag = 0; /* use sync mode */
ret = ecc_sqe_parse((struct hisi_qp *)h_qp, first, hw_msg);
if (ret) {
WD_ERR("failed to parse first BD, ret = %d!\n", ret);
@@ -2351,11 +2350,12 @@ static int sm2_enc_parse(handle_t h_qp,
WD_ERR("failed to convert sm2 std format, ret = %d!\n", ret);
goto free_second;
}
+
free_second:
free_req(second);
free_first:
free_req(first);
- msg->tag = tag;
+
return ret;
}
@@ -2376,21 +2376,21 @@ static int sm2_dec_parse(handle_t ctx, struct wd_ecc_msg *msg,
memcpy(&src, dst + 1, sizeof(src));
/* parse first sqe */
- hw_msg->low_tag = 0; /* use sync mode */
ret = ecc_sqe_parse((struct hisi_qp *)ctx, dst, hw_msg);
if (ret) {
WD_ERR("failed to parse decode BD, ret = %d!\n", ret);
goto fail;
}
msg->result = dst->result;
+ msg->tag = tag;
ret = sm2_convert_dec_out(&src, dst);
if (unlikely(ret)) {
WD_ERR("failed to convert sm2 decode out, ret = %d!\n", ret);
goto fail;
}
+
fail:
- msg->tag = tag;
free(dst->req.dst);
free(dst);
--
2.30.0
1
2