Configure the DSA instance with appropriate number of queues
(dsa_id, args)
| 78 | |
| 79 | |
| 80 | def configure_dsa(dsa_id, args): |
| 81 | "Configure the DSA instance with appropriate number of queues" |
| 82 | dsa_dir = SysfsDir(f"/sys/bus/dsa/devices/dsa{dsa_id}") |
| 83 | |
| 84 | max_groups = dsa_dir.read_int("max_groups") |
| 85 | max_engines = dsa_dir.read_int("max_engines") |
| 86 | max_queues = dsa_dir.read_int("max_work_queues") |
| 87 | max_work_queues_size = dsa_dir.read_int("max_work_queues_size") |
| 88 | |
| 89 | nb_queues = min(args.q, max_queues) |
| 90 | if args.q > nb_queues: |
| 91 | print(f"Setting number of queues to max supported value: {max_queues}") |
| 92 | |
| 93 | # we want one engine per group, and no more engines than queues |
| 94 | nb_groups = min(max_engines, max_groups, nb_queues) |
| 95 | for grp in range(nb_groups): |
| 96 | dsa_dir.write_values({f"engine{dsa_id}.{grp}/group_id": grp}) |
| 97 | |
| 98 | # configure each queue |
| 99 | for q in range(nb_queues): |
| 100 | wqcfg = {"group_id": q % nb_groups, |
| 101 | "type": "user", |
| 102 | "mode": "dedicated", |
| 103 | "name": f"{args.prefix}_wq{dsa_id}.{q}", |
| 104 | "priority": 1, |
| 105 | "max_batch_size": 1024, |
| 106 | "size": int(max_work_queues_size / nb_queues)} |
| 107 | wq_dir = SysfsDir(os.path.join(dsa_dir.path, f"wq{dsa_id}.{q}")) |
| 108 | if os.path.exists(os.path.join(wq_dir.path, f"driver_name")): |
| 109 | wqcfg.update({"driver_name": "user"}) |
| 110 | wqcfg.update(parse_wq_opts(args.wq_option)) |
| 111 | wq_dir.write_values(wqcfg) |
| 112 | |
| 113 | # enable device and then queues |
| 114 | idxd_dir = SysfsDir(get_drv_dir("idxd")) |
| 115 | idxd_dir.write_values({"bind": f"dsa{dsa_id}"}) |
| 116 | |
| 117 | user_dir = SysfsDir(get_drv_dir("user")) |
| 118 | for q in range(nb_queues): |
| 119 | user_dir.write_values({"bind": f"wq{dsa_id}.{q}"}) |
| 120 | |
| 121 | |
| 122 | def main(args): |
no test coverage detected