From 81b193aba8f9d12b57997cbaee71b747a390bba4 Mon Sep 17 00:00:00 2001 From: Markus Stockhausen Date: Sat, 14 Mar 2026 19:05:48 +0100 Subject: [PATCH] realtek: eth: drop family_id The RTL839x notify ring buffer setup is the last consumer of family_id. Convert it to a device specific callback and drop family_id from the configuration structure. Signed-off-by: Markus Stockhausen Link: https://github.com/openwrt/openwrt/pull/22421 Signed-off-by: Robert Marko --- .../drivers/net/ethernet/rtl838x_eth.c | 19 ++++++++----------- .../drivers/net/ethernet/rtl838x_eth.h | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c b/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c index 6cd823f680..af39d8c7f9 100644 --- a/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c +++ b/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c @@ -647,7 +647,7 @@ static void rteth_setup_ring_buffer(struct rteth_ctrl *ctrl) } } -static void rtl839x_setup_notify_ring_buffer(struct rteth_ctrl *ctrl) +static void rteth_839x_setup_notify_ring_buffer(struct rteth_ctrl *ctrl) { struct notify_b *b = ctrl->membase; @@ -664,6 +664,10 @@ static void rtl839x_setup_notify_ring_buffer(struct rteth_ctrl *ctrl) /* Enable Notification */ sw_w32_mask(0, 1 << 0, RTL839X_L2_NOTIFICATION_CTRL); ctrl->lastEvent = 0; + + /* Make sure the ring structure is visible to the ASIC */ + mb(); + flush_cache_all(); } static void rteth_838x_hw_init(struct rteth_ctrl *ctrl) @@ -714,12 +718,8 @@ static int rteth_open(struct net_device *ndev) ctrl->r->hw_reset(ctrl); rteth_setup_cpu_rx_rings(ctrl); rteth_setup_ring_buffer(ctrl); - if (ctrl->r->family_id == RTL8390_FAMILY_ID) { - rtl839x_setup_notify_ring_buffer(ctrl); - /* Make sure the ring structure is visible to the ASIC */ - mb(); - flush_cache_all(); - } + if (ctrl->r->setup_notify_ring_buffer) + ctrl->r->setup_notify_ring_buffer(ctrl); rteth_hw_ring_setup(ctrl); phylink_start(ctrl->phylink); @@ -1300,7 +1300,6 @@ static const struct net_device_ops rteth_838x_netdev_ops = { }; static const struct rteth_config rteth_838x_cfg = { - .family_id = RTL8380_FAMILY_ID, .cpu_port = RTETH_838X_CPU_PORT, .rx_rings = 8, .tx_rx_enable = 0xc, @@ -1346,7 +1345,6 @@ static const struct net_device_ops rteth_839x_netdev_ops = { }; static const struct rteth_config rteth_839x_cfg = { - .family_id = RTL8390_FAMILY_ID, .cpu_port = RTETH_839X_CPU_PORT, .rx_rings = 8, .tx_rx_enable = 0xc, @@ -1373,6 +1371,7 @@ static const struct rteth_config rteth_839x_cfg = { .hw_stop = &rteth_839x_hw_stop, .hw_reset = &rteth_839x_hw_reset, .init_mac = &rteth_839x_init_mac, + .setup_notify_ring_buffer = &rteth_839x_setup_notify_ring_buffer, .netdev_ops = &rteth_839x_netdev_ops, }; @@ -1390,7 +1389,6 @@ static const struct net_device_ops rteth_930x_netdev_ops = { }; static const struct rteth_config rteth_930x_cfg = { - .family_id = RTL9300_FAMILY_ID, .cpu_port = RTETH_930X_CPU_PORT, .rx_rings = 32, .tx_rx_enable = 0x30, @@ -1435,7 +1433,6 @@ static const struct net_device_ops rteth_931x_netdev_ops = { }; static const struct rteth_config rteth_931x_cfg = { - .family_id = RTL9310_FAMILY_ID, .cpu_port = RTETH_931X_CPU_PORT, .rx_rings = 32, .tx_rx_enable = 0x30, diff --git a/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.h b/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.h index 72665f0a09..8507ebfb0a 100644 --- a/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.h +++ b/target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.h @@ -239,7 +239,6 @@ struct rteth_ctrl; struct rteth_packet; struct rteth_config { - int family_id; int cpu_port; int rx_rings; int tx_rx_enable; @@ -267,6 +266,7 @@ struct rteth_config { void (*hw_stop)(struct rteth_ctrl *ctrl); void (*hw_reset)(struct rteth_ctrl *ctrl); int (*init_mac)(struct rteth_ctrl *ctrl); + void (*setup_notify_ring_buffer)(struct rteth_ctrl *ctrl); void (*update_counter)(struct rteth_ctrl *ctrl, int ring, int released); const struct net_device_ops *netdev_ops; };