Skip to content

Commit b551bac

Browse files
Farhan Aliherbertx
authored andcommitted
crypto: virtio - Read crypto services and algorithm masks
Read the crypto services and algorithm masks which provides information about the services and algorithms supported by virtio-crypto backend. Signed-off-by: Farhan Ali <alifm@linux.ibm.com> Acked-by: Gonglei <arei.gonglei@huawei.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 0917b87 commit b551bac

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

drivers/crypto/virtio/virtio_crypto_common.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ struct virtio_crypto {
5555
/* Number of queue currently used by the driver */
5656
u32 curr_queue;
5757

58+
/*
59+
* Specifies the services mask which the device support,
60+
* see VIRTIO_CRYPTO_SERVICE_*
61+
*/
62+
u32 crypto_services;
63+
64+
/* Detailed algorithms mask */
65+
u32 cipher_algo_l;
66+
u32 cipher_algo_h;
67+
u32 hash_algo;
68+
u32 mac_algo_l;
69+
u32 mac_algo_h;
70+
u32 aead_algo;
71+
5872
/* Maximum length of cipher key */
5973
u32 max_cipher_key_len;
6074
/* Maximum length of authenticated key */

drivers/crypto/virtio/virtio_crypto_core.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,13 @@ static int virtcrypto_probe(struct virtio_device *vdev)
303303
u32 max_data_queues = 0, max_cipher_key_len = 0;
304304
u32 max_auth_key_len = 0;
305305
u64 max_size = 0;
306+
u32 cipher_algo_l = 0;
307+
u32 cipher_algo_h = 0;
308+
u32 hash_algo = 0;
309+
u32 mac_algo_l = 0;
310+
u32 mac_algo_h = 0;
311+
u32 aead_algo = 0;
312+
u32 crypto_services = 0;
306313

307314
if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1))
308315
return -ENODEV;
@@ -339,6 +346,20 @@ static int virtcrypto_probe(struct virtio_device *vdev)
339346
max_auth_key_len, &max_auth_key_len);
340347
virtio_cread(vdev, struct virtio_crypto_config,
341348
max_size, &max_size);
349+
virtio_cread(vdev, struct virtio_crypto_config,
350+
crypto_services, &crypto_services);
351+
virtio_cread(vdev, struct virtio_crypto_config,
352+
cipher_algo_l, &cipher_algo_l);
353+
virtio_cread(vdev, struct virtio_crypto_config,
354+
cipher_algo_h, &cipher_algo_h);
355+
virtio_cread(vdev, struct virtio_crypto_config,
356+
hash_algo, &hash_algo);
357+
virtio_cread(vdev, struct virtio_crypto_config,
358+
mac_algo_l, &mac_algo_l);
359+
virtio_cread(vdev, struct virtio_crypto_config,
360+
mac_algo_h, &mac_algo_h);
361+
virtio_cread(vdev, struct virtio_crypto_config,
362+
aead_algo, &aead_algo);
342363

343364
/* Add virtio crypto device to global table */
344365
err = virtcrypto_devmgr_add_dev(vcrypto);
@@ -358,6 +379,14 @@ static int virtcrypto_probe(struct virtio_device *vdev)
358379
vcrypto->max_cipher_key_len = max_cipher_key_len;
359380
vcrypto->max_auth_key_len = max_auth_key_len;
360381
vcrypto->max_size = max_size;
382+
vcrypto->crypto_services = crypto_services;
383+
vcrypto->cipher_algo_l = cipher_algo_l;
384+
vcrypto->cipher_algo_h = cipher_algo_h;
385+
vcrypto->mac_algo_l = mac_algo_l;
386+
vcrypto->mac_algo_h = mac_algo_h;
387+
vcrypto->hash_algo = hash_algo;
388+
vcrypto->aead_algo = aead_algo;
389+
361390

362391
dev_info(&vdev->dev,
363392
"max_queues: %u, max_cipher_key_len: %u, max_auth_key_len: %u, max_size 0x%llx\n",

0 commit comments

Comments
 (0)