diff --git a/pydpu/cli.py b/pydpu/cli.py index 1a2cf1a..ac7e093 100644 --- a/pydpu/cli.py +++ b/pydpu/cli.py @@ -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) diff --git a/pydpu/storage.py b/pydpu/storage.py index 7f89286..1b79db2 100644 --- a/pydpu/storage.py +++ b/pydpu/storage.py @@ -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: @@ -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,