From 91579e389e195367e034b03ea80d671db722e54b Mon Sep 17 00:00:00 2001 From: Artsiom Koltun Date: Tue, 28 Nov 2023 14:00:15 +0100 Subject: [PATCH] feat(storage/nvme): pass max_nsq, max_ncq to controller Signed-off-by: Artsiom Koltun --- pydpu/cli.py | 4 +++- pydpu/storage.py | 28 +++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/pydpu/cli.py b/pydpu/cli.py index ac7e093..daddefb 100644 --- a/pydpu/cli.py +++ b/pydpu/cli.py @@ -144,7 +144,9 @@ def controller(ctx, **kwargs): nqn="nqn.2022-09.io.spdk:opi1", model="OPI Model", serial="OPI SN" ) click.echo(s) - c = NvmeController(subsystem=s, queue=1024, pf=0, vf=0, port=0) + c = NvmeController( + subsystem=s, queue=1024, pf=0, vf=0, port=0, max_nsq=8, max_ncq=8 + ) click.echo(c) res = c.create(ctx.obj["ADDRESS"]) click.echo(res) diff --git a/pydpu/storage.py b/pydpu/storage.py index f7777c9..51718fa 100644 --- a/pydpu/storage.py +++ b/pydpu/storage.py @@ -113,13 +113,29 @@ class NvmeController: pf: physical_function of PciEndpoint. vf: virtual_function of PciEndpoint. port: port_id of PciEndpoint. + max_nsq: maximum number of host submission queues allowed. + For 0 the xPU will provide a default. + max_ncq: maximum number of host completion queues allowed. + For 0 the xPU will provide a default. """ def __repr__(self) -> str: - return f"{type(self).__name__}({str(self.id)}, nqn={str(self.queue)}, port={str(self.port)}, pf={str(self.pf)}, vf={self.vf})" + return ( + f"{type(self).__name__}({str(self.id)}, nqn={str(self.queue)}, " + + f"port={str(self.port)}, pf={str(self.pf)}, vf={self.vf}, " + + f"max_nsq={str(self.max_nsq)}, max_ncq={self.max_ncq})" + ) - def __init__(self, subsystem: NvmeSubsystem, queue: int, - pf: int, vf: int, port: int = 0) -> None: + def __init__( + self, + subsystem: NvmeSubsystem, + queue: int, + pf: int, + vf: int, + port: int = 0, + max_nsq: int = 0, + max_ncq: int = 0, + ) -> None: self.id = "opi-" + str(uuid.uuid1()) self.fullname = "//storage.opiproject.org/subsystems/{}/controllers{}".format( subsystem.id, self.id @@ -129,6 +145,8 @@ def __init__(self, subsystem: NvmeSubsystem, queue: int, self.pf = pf self.vf = vf self.port = port + self.max_nsq = max_nsq + self.max_ncq = max_ncq def create(self, address): with grpc.insecure_channel(address) as channel: @@ -146,8 +164,8 @@ def create(self, address): virtual_function=wrappers_pb2.Int32Value(value=self.vf), port_id=wrappers_pb2.Int32Value(value=self.port), ), - max_nsq=5, - max_ncq=6, + max_nsq=self.max_nsq, + max_ncq=self.max_ncq, sqes=7, cqes=8, nvme_controller_id=1,