summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Stockhausen2026-02-12 17:48:37 +0000
committerRobert Marko2026-02-19 09:47:55 +0000
commit626d3599757103a6043bde37a23dea003b98eac3 (patch)
tree665a368d5eee4f8e31aa3e6b165390f2363d4fd9
parent22db7540b730327858d08cb052ce3f58ba84525c (diff)
downloadopenwrt-626d3599757103a6043bde37a23dea003b98eac3.tar.gz
realtek: eth: merge RTL93xx ring counter handling
There is enough info in the control and config structures to derive the device specific counter freeing. No need to write two different functions. Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de> Link: https://github.com/openwrt/openwrt/pull/21999 Signed-off-by: Robert Marko <robimarko@gmail.com>
-rw-r--r--target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.c29
-rw-r--r--target/linux/realtek/files-6.12/drivers/net/ethernet/rtl838x_eth.h2
2 files changed, 9 insertions, 22 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 b013c23144..f3824f7f8d 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
@@ -235,30 +235,17 @@ static void rteth_enable_all_rx_irqs(struct rteth_ctrl *ctrl)
sw_w32_mask(0, mask << shift, ctrl->r->dma_if_intr_msk + reg * 4);
}
-/* On the RTL93XX, the RTL93XX_DMA_IF_RX_RING_CNTR track the fill level of
- * the rings. Writing x into these registers substracts x from its content.
- * When the content reaches the ring size, the ASIC no longer adds
- * packets to this receive queue.
- */
-static void rteth_83xx_update_counter(int r, int released)
+static void rteth_83xx_update_counter(struct rteth_ctrl *ctrl, int ring, int released)
{
/* Free floating rings without space tracking */
}
-static void rteth_930x_update_counter(int r, int released)
-{
- u32 reg = rtl930x_dma_if_rx_ring_cntr(r);
- int pos = (r % 3) * 10;
-
- sw_w32(released << pos, reg);
-}
-
-static void rteth_931x_update_counter(int r, int released)
+static void rteth_93xx_update_counter(struct rteth_ctrl *ctrl, int ring, int released)
{
- u32 reg = rtl931x_dma_if_rx_ring_cntr(r);
- int pos = (r % 3) * 10;
+ int pos = (ring % 3) * 10;
- sw_w32(released << pos, reg);
+ /* writing x to the ring counter increases ring free space by x */
+ sw_w32(released << pos, ctrl->r->dma_if_rx_ring_cntr(ring));
}
struct dsa_tag {
@@ -1120,7 +1107,7 @@ static int rteth_hw_receive(struct net_device *dev, int ring, int budget)
}
spin_lock(&ctrl->rx_lock);
- ctrl->r->update_counter(ring, work_done);
+ ctrl->r->update_counter(ctrl, ring, work_done);
dev->stats.rx_packets += rx_packets;
dev->stats.rx_bytes += rx_bytes;
spin_unlock(&ctrl->rx_lock);
@@ -1562,7 +1549,7 @@ static const struct rteth_config rteth_930x_cfg = {
.get_mac_tx_pause_sts = rtl930x_get_mac_tx_pause_sts,
.mac = RTL930X_MAC_L2_ADDR_CTRL,
.l2_tbl_flush_ctrl = RTL930X_L2_TBL_FLUSH_CTRL,
- .update_counter = rteth_930x_update_counter,
+ .update_counter = rteth_93xx_update_counter,
.create_tx_header = rteth_930x_create_tx_header,
.decode_tag = rteth_930x_decode_tag,
.hw_reset = &rteth_93xx_hw_reset,
@@ -1614,7 +1601,7 @@ static const struct rteth_config rteth_931x_cfg = {
.get_mac_tx_pause_sts = rtl931x_get_mac_tx_pause_sts,
.mac = RTL931X_MAC_L2_ADDR_CTRL,
.l2_tbl_flush_ctrl = RTL931X_L2_TBL_FLUSH_CTRL,
- .update_counter = rteth_931x_update_counter,
+ .update_counter = rteth_93xx_update_counter,
.create_tx_header = rteth_931x_create_tx_header,
.decode_tag = rteth_931x_decode_tag,
.hw_reset = &rteth_93xx_hw_reset,
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 d6790a6309..26ebcfd06a 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
@@ -455,7 +455,7 @@ struct rteth_config {
bool (*decode_tag)(struct rteth_packet *h, struct dsa_tag *tag);
void (*hw_reset)(struct rteth_ctrl *ctrl);
int (*init_mac)(struct rteth_ctrl *ctrl);
- void (*update_counter)(int r, int work_done);
+ void (*update_counter)(struct rteth_ctrl *ctrl, int ring, int released);
const struct net_device_ops *netdev_ops;
};