Skip to content

Commit

Permalink
feat(storage/nvme): pass max_nsq, max_ncq to controller
Browse files Browse the repository at this point in the history
Signed-off-by: Artsiom Koltun <[email protected]>
  • Loading branch information
artek-koltun committed Nov 29, 2023
1 parent 1e65ac2 commit 8b8f3e4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
4 changes: 3 additions & 1 deletion pydpu/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 23 additions & 5 deletions pydpu/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -144,8 +162,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,
Expand Down

0 comments on commit 8b8f3e4

Please sign in to comment.