xref: /linux/drivers/dma/idxd/defaults.c (revision 3a2c4d55e32ad65efebdb6de44eef3bfa08bb49d)
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 	int i;
12 
13 	if (!test_bit(IDXD_FLAG_CONFIGURABLE, &idxd->flags))
14 		return 0;
15 
16 	wq = idxd->wqs[0];
17 
18 	if (wq->state != IDXD_WQ_DISABLED)
19 		return -EPERM;
20 
21 	/* set mode to "dedicated" */
22 	set_bit(WQ_FLAG_DEDICATED, &wq->flags);
23 	wq->threshold = 0;
24 
25 	/* only setting up 1 wq, so give it all the wq space */
26 	wq->size = idxd->max_wq_size;
27 
28 	/* set priority to 10 */
29 	wq->priority = 10;
30 
31 	/* set type to "kernel" */
32 	wq->type = IDXD_WQT_KERNEL;
33 
34 	/* set wq group to 0 */
35 	group = idxd->groups[0];
36 	wq->group = group;
37 	group->num_wqs++;
38 
39 	/* set name to "iaa_crypto" */
40 	strscpy_pad(wq->name, "iaa_crypto");
41 
42 	/* set driver_name to "crypto" */
43 	strscpy_pad(wq->driver_name, "crypto");
44 
45 	/* assign all engines to group 0 */
46 	for (i = 0; i < idxd->max_engines; i++) {
47 		engine = idxd->engines[i];
48 		engine->group = group;
49 		group->num_engines++;
50 	}
51 
52 	return 0;
53 }
54