In rtl_rx_init(), the configuration of RSS control and RX queue number
(which are specific to RTL8125) was incorrectly executed for all MAC
versions. Accessing RTL8125-specific registers (e.g., RSS_CTRL_8125)
on RTL8168 hardware causes a segmentation fault.

This patch fixes the issue by moving the RTL8125-specific RSS and VMQ
configurations into the existing `if (rtl_is_8125(hw))` block, ensuring
they are only executed on the correct hardware.

Fixes: 25e19d532b4b ("net/r8169: support multi-queues for 8126 and 8127")
Cc: [email protected]

Signed-off-by: Howard Wang <[email protected]>
---
 drivers/net/r8169/r8169_rxtx.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/r8169/r8169_rxtx.c b/drivers/net/r8169/r8169_rxtx.c
index e0154b7741..00de0471f4 100644
--- a/drivers/net/r8169/r8169_rxtx.c
+++ b/drivers/net/r8169/r8169_rxtx.c
@@ -672,7 +672,18 @@ rtl_rx_init(struct rte_eth_dev *dev)
 
        rtl_enable_cfg9346_write(hw);
 
-       if (!rtl_is_8125(hw)) {
+       if (rtl_is_8125(hw)) {
+               /* RSS_control_0 */
+               if (hw->EnableRss) {
+                       rtl_init_rss(hw, nb_rx_queues);
+                       rtl8125_config_rss(hw, nb_rx_queues);
+               } else {
+                       RTL_W32(hw, RSS_CTRL_8125, 0x00);
+               }
+
+               /* VMQ_control */
+               rtl8125_set_rx_q_num(hw, nb_rx_queues);
+       } else {
                /* RX ftr mcu enable */
                csi_tmp = rtl_eri_read(hw, 0xDC, 1, ERIAR_ExGMAC);
                csi_tmp &= ~BIT_0;
@@ -700,17 +711,6 @@ rtl_rx_init(struct rte_eth_dev *dev)
        else
                rtl_clear_rdu = rtl8168_clear_rdu;
 
-       /* RSS_control_0 */
-       if (hw->EnableRss) {
-               rtl_init_rss(hw, nb_rx_queues);
-               rtl8125_config_rss(hw, nb_rx_queues);
-       } else {
-               RTL_W32(hw, RSS_CTRL_8125, 0x00);
-       }
-
-       /* VMQ_control */
-       rtl8125_set_rx_q_num(hw, nb_rx_queues);
-
        RTL_W8(hw, ChipCmd, RTL_R8(hw, ChipCmd) | CmdRxEnb);
 
        return 0;
-- 
2.43.0

Reply via email to