// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. #include #include #include #include namespace nb = nanobind; using namespace mscclpp; void register_port_channel(nb::module_& m) { nb::class_(m, "CppBaseProxyService") .def("start_proxy", &BaseProxyService::startProxy, nb::arg("blocking") = false) .def("stop_proxy", &BaseProxyService::stopProxy); nb::class_(m, "CppProxyService") .def(nb::init(), nb::arg("fifo_size") = DEFAULT_FIFO_SIZE) .def("start_proxy", &ProxyService::startProxy, nb::arg("blocking") = false) .def("stop_proxy", &ProxyService::stopProxy) .def("build_and_add_semaphore", &ProxyService::buildAndAddSemaphore, nb::arg("comm"), nb::arg("connection")) .def("add_semaphore", static_cast(&ProxyService::addSemaphore), nb::arg("semaphore")) .def("add_semaphore", static_cast)>( &ProxyService::addSemaphore), nb::arg("semaphore")) .def("add_memory", &ProxyService::addMemory, nb::arg("memory")) .def("semaphore", &ProxyService::semaphore, nb::arg("id")) .def("base_port_channel", &ProxyService::basePortChannel, nb::arg("id")) .def("port_channel", &ProxyService::portChannel, nb::arg("id"), nb::arg("dst"), nb::arg("src")); nb::class_(m, "CppBasePortChannel") .def(nb::init<>()) .def(nb::init, std::shared_ptr>(), nb::arg("semaphore_id"), nb::arg("semaphore"), nb::arg("proxy")) .def("device_handle", &BasePortChannel::deviceHandle); nb::class_(m, "CppBasePortChannelDeviceHandle") .def(nb::init<>()) .def_rw("semaphore_id_", &BasePortChannel::DeviceHandle::semaphoreId_) .def_rw("semaphore_", &BasePortChannel::DeviceHandle::semaphore_) .def_rw("fifo_", &BasePortChannel::DeviceHandle::fifo_) .def_prop_ro("raw", [](const BasePortChannel::DeviceHandle& self) -> nb::bytes { return nb::bytes(reinterpret_cast(&self), sizeof(self)); }); nb::class_(m, "CppPortChannel") .def(nb::init<>()) .def(nb::init, std::shared_ptr, MemoryId, MemoryId>(), nb::arg("semaphore_id"), nb::arg("semaphore"), nb::arg("proxy"), nb::arg("dst"), nb::arg("src")) .def("device_handle", &PortChannel::deviceHandle); nb::class_(m, "CppPortChannelDeviceHandle") .def(nb::init<>()) .def_rw("semaphore_id_", &PortChannel::DeviceHandle::semaphoreId_) .def_rw("semaphore_", &PortChannel::DeviceHandle::semaphore_) .def_rw("fifo_", &PortChannel::DeviceHandle::fifo_) .def_rw("src_", &PortChannel::DeviceHandle::src_) .def_rw("dst_", &PortChannel::DeviceHandle::dst_) .def_prop_ro("raw", [](const PortChannel::DeviceHandle& self) -> nb::bytes { return nb::bytes(reinterpret_cast(&self), sizeof(self)); }); };