Skip to content

Commit

Permalink
feat(storage/nvme): pass port, pf, vf 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 329e7ea commit 1e65ac2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pydpu/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ 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)
click.echo(c)
res = c.create(ctx.obj["ADDRESS"])
click.echo(res)
Expand Down
17 changes: 12 additions & 5 deletions pydpu/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,25 @@ 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.
"""

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)}, port={str(self.port)}, pf={str(self.pf)}, vf={self.vf})"

def __init__(self, subsystem: NvmeSubsystem, queue: int) -> None:
def __init__(self, subsystem: NvmeSubsystem, queue: int,
pf: int, vf: int, port: 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

def create(self, address):
with grpc.insecure_channel(address) as channel:
Expand All @@ -133,9 +140,9 @@ 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,
Expand Down

0 comments on commit 1e65ac2

Please sign in to comment.