[netdevice-migration] Use ddk::base_protocol mixin
Use the ddk::base_protocol mixin class with
ddk::NetworkDeviceImplProtocol such that the netdevice-migration driver
can serve as a parent driver for the network-device driver.
Tested: fx test netdevice-migration-tests
Bug: 78293
Change-Id: I2872ab8b0e767dbde319506f6647914cd677c49b
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/637861
Reviewed-by: Bruno Dal Bo <brunodalbo@google.com>
Commit-Queue: Amanda Tait <atait@google.com>
diff --git a/src/connectivity/ethernet/drivers/ethernet/netdevice-migration/netdevice_migration.h b/src/connectivity/ethernet/drivers/ethernet/netdevice-migration/netdevice_migration.h
index 10e32f1..2fbb666 100644
--- a/src/connectivity/ethernet/drivers/ethernet/netdevice-migration/netdevice_migration.h
+++ b/src/connectivity/ethernet/drivers/ethernet/netdevice-migration/netdevice_migration.h
@@ -26,11 +26,12 @@
class NetdeviceMigration;
using DeviceType = ddk::Device<NetdeviceMigration>;
-class NetdeviceMigration : public DeviceType,
- public ddk::EthernetIfcProtocol<NetdeviceMigration>,
- public ddk::NetworkDeviceImplProtocol<NetdeviceMigration>,
- public ddk::NetworkPortProtocol<NetdeviceMigration>,
- public ddk::MacAddrProtocol<NetdeviceMigration> {
+class NetdeviceMigration
+ : public DeviceType,
+ public ddk::EthernetIfcProtocol<NetdeviceMigration>,
+ public ddk::NetworkDeviceImplProtocol<NetdeviceMigration, ddk::base_protocol>,
+ public ddk::NetworkPortProtocol<NetdeviceMigration>,
+ public ddk::MacAddrProtocol<NetdeviceMigration> {
public:
static constexpr uint8_t kPortId = 13;
// Equivalent to generic ethernet driver FIFO depth; see
diff --git a/src/connectivity/ethernet/drivers/ethernet/netdevice-migration/unit-tests.cc b/src/connectivity/ethernet/drivers/ethernet/netdevice-migration/unit-tests.cc
index 31d12f8..43c1a24 100644
--- a/src/connectivity/ethernet/drivers/ethernet/netdevice-migration/unit-tests.cc
+++ b/src/connectivity/ethernet/drivers/ethernet/netdevice-migration/unit-tests.cc
@@ -32,6 +32,9 @@
return netdev_.rx_started_;
}
const ethernet_ifc_protocol_t& EthernetIfcProto() { return netdev_.ethernet_ifc_proto_; }
+ const network_device_impl_protocol_ops_t& NetworkDeviceImplProtoOps() {
+ return netdev_.network_device_impl_protocol_ops_;
+ }
const std::array<uint8_t, MAC_SIZE>& Mac() { return netdev_.mac_; }
const zx::bti& Bti() { return netdev_.eth_bti_; }
template <typename T, typename F>
@@ -861,4 +864,10 @@
}
}
+TEST_F(NetdeviceMigrationDefaultSetupTest, NetworkDeviceImplProto) {
+ EXPECT_EQ(Device().ddk_proto_id_, ZX_PROTOCOL_NETWORK_DEVICE_IMPL);
+ netdevice_migration::NetdeviceMigrationTestHelper helper(Device());
+ EXPECT_EQ(Device().ddk_proto_ops_, &helper.NetworkDeviceImplProtoOps());
+}
+
} // namespace