xref: /linux/drivers/dma/idxd/defaults.c (revision 45d8b572fac3aa8b49d53c946b3685eaf78a2824)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2023 Intel Corporation. All rights rsvd. */
3 #include <linux/kernel.h>
4 #include "idxd.h"
5 
6 int idxd_load_iaa_device_defaults(struct idxd_device *idxd)
7 {
8 	struct idxd_engine *engine;
9 	struct idxd_group *group;
10 	struct idxd_wq *wq;
11 
12 	if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
13 		return 0;
14 
15 	wq = idxd->wqs[0];
16 
17 	if (wq->state != IDXD_WQ_DISABLED)
18 		return -EPERM;
19 
20 	/* set mode to "dedicated" */
21 	set_bit(WQ_FLAG_DEDICATED, &wq->flags);
22 	wq->threshold = 0;
23 
24 	/* only setting up 1 wq, so give it all the wq space */
25 	wq->size = idxd->max_wq_size;
26 
27 	/* set priority to 10 */
28 	wq->priority = 10;
29 
30 	/* set type to "kernel" */
31 	wq->type = IDXD_WQT_KERNEL;
32 
33 	/* set wq group to 0 */
34 	group = idxd->groups[0];
35 	wq->group = group;
36 	group->num_wqs++;
37 
38 	/* set name to "iaa_crypto" */
39 	memset(wq->name, 0, WQ_NAME_SIZE + 1);
40 	strscpy(wq->name, "iaa_crypto", WQ_NAME_SIZE + 1);
41 
42 	/* set driver_name to "crypto" */
43 	memset(wq->driver_name, 0, DRIVER_NAME_SIZE + 1);
44 	strscpy(wq->driver_name, "crypto", DRIVER_NAME_SIZE + 1);
45 
46 	engine = idxd->engines[0];
47 
48 	/* set engine group to 0 */
49 	engine->group = idxd->groups[0];
50 	engine->group->num_engines++;
51 
52 	return 0;
53 }
54