Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(storage/nvme): add nvme ctrl parameters #154

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
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
41 changes: 34 additions & 7 deletions pydpu/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,43 @@ class NvmeController:
Args:
subsystem: substsem name that controller belongs to.
queue: queue depth for both SQ (submition) and CQ (completion).
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)})"
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) -> 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
)
self.subsystem = subsystem
self.queue = queue
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 @@ -133,12 +158,14 @@ def create(self, address):
nvme_controller=frontend_nvme_pb2.NvmeController(
spec=frontend_nvme_pb2.NvmeControllerSpec(
pcie_id=opicommon_pb2.PciEndpoint(
physical_function=wrappers_pb2.Int32Value(value=1),
virtual_function=wrappers_pb2.Int32Value(value=2),
port_id=wrappers_pb2.Int32Value(value=3),
physical_function=wrappers_pb2.Int32Value(
value=self.pf
),
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