]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: libwx: move rss_field to struct wx
authorJiawen Wu <jiawenwu@trustnetic.com>
Fri, 26 Sep 2025 02:38:41 +0000 (10:38 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 30 Sep 2025 01:11:16 +0000 (18:11 -0700)
For global RSS and multiple RSS scheme, the RSS type fields are defined
identically in the registers. So they can be defined as the macros
WX_RSS_FIELD_* to cleanup the codes. And to prepare for the RXFH support
in the next patch, move the rss_field to struct wx.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Link: https://patch.msgid.link/20250926023843.34340-3-jiawenwu@trustnetic.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/wangxun/libwx/wx_hw.c
drivers/net/ethernet/wangxun/libwx/wx_type.h

index 0bb4cddf7809d2e4b44939ed8bf0ef5eee0b99b9..9bffa8984cbeb0f5829d9cc252f1b202b3299085 100644 (file)
@@ -2078,16 +2078,11 @@ void wx_config_rss_field(struct wx *wx)
 {
        u32 rss_field;
 
-       /* Global RSS and multiple RSS have the same type field */
-       rss_field = WX_RDB_RA_CTL_RSS_IPV4 |
-                   WX_RDB_RA_CTL_RSS_IPV4_TCP |
-                   WX_RDB_RA_CTL_RSS_IPV4_UDP |
-                   WX_RDB_RA_CTL_RSS_IPV6 |
-                   WX_RDB_RA_CTL_RSS_IPV6_TCP |
-                   WX_RDB_RA_CTL_RSS_IPV6_UDP;
-
        if (test_bit(WX_FLAG_SRIOV_ENABLED, wx->flags) &&
            test_bit(WX_FLAG_MULTI_64_FUNC, wx->flags)) {
+               rss_field = rd32(wx, WX_RDB_PL_CFG(wx->num_vfs));
+               rss_field &= ~WX_RDB_PL_CFG_RSS_MASK;
+               rss_field |= FIELD_PREP(WX_RDB_PL_CFG_RSS_MASK, wx->rss_flags);
                wr32(wx, WX_RDB_PL_CFG(wx->num_vfs), rss_field);
 
                /* Enable global RSS and multiple RSS to make the RSS
@@ -2097,6 +2092,9 @@ void wx_config_rss_field(struct wx *wx)
                      WX_RDB_RA_CTL_MULTI_RSS | WX_RDB_RA_CTL_RSS_EN,
                      WX_RDB_RA_CTL_MULTI_RSS | WX_RDB_RA_CTL_RSS_EN);
        } else {
+               rss_field = rd32(wx, WX_RDB_RA_CTL);
+               rss_field &= ~WX_RDB_RA_CTL_RSS_MASK;
+               rss_field |= FIELD_PREP(WX_RDB_RA_CTL_RSS_MASK, wx->rss_flags);
                wr32(wx, WX_RDB_RA_CTL, rss_field);
        }
 }
@@ -2450,6 +2448,9 @@ int wx_sw_init(struct wx *wx)
                wx_err(wx, "rss key allocation failed\n");
                return err;
        }
+       wx->rss_flags = WX_RSS_FIELD_IPV4 | WX_RSS_FIELD_IPV4_TCP |
+                       WX_RSS_FIELD_IPV6 | WX_RSS_FIELD_IPV6_TCP |
+                       WX_RSS_FIELD_IPV4_UDP | WX_RSS_FIELD_IPV6_UDP;
 
        wx->mac_table = kcalloc(wx->mac.num_rar_entries,
                                sizeof(struct wx_mac_addr),
index 0450e276ae28d3bc3a1e27f53b5e307c40eff154..bb03a9fdc711b0f2877dfe85866b4cc312bd649e 100644 (file)
 #define WX_RDB_PL_CFG_TUN_TUNHDR     BIT(4)
 #define WX_RDB_PL_CFG_TUN_OUTL2HDR   BIT(5)
 #define WX_RDB_PL_CFG_RSS_EN         BIT(24)
+#define WX_RDB_PL_CFG_RSS_MASK       GENMASK(23, 16)
 #define WX_RDB_RSSTBL(_i)            (0x19400 + ((_i) * 4))
 #define WX_RDB_RSSRK(_i)             (0x19480 + ((_i) * 4))
 #define WX_RDB_RA_CTL                0x194F4
 #define WX_RDB_RA_CTL_RSS_IPV6_TCP   BIT(21)
 #define WX_RDB_RA_CTL_RSS_IPV4_UDP   BIT(22)
 #define WX_RDB_RA_CTL_RSS_IPV6_UDP   BIT(23)
+#define WX_RDB_RA_CTL_RSS_MASK       GENMASK(23, 16)
 #define WX_RDB_FDIR_MATCH            0x19558
 #define WX_RDB_FDIR_MISS             0x1955C
 /* VM RSS */
@@ -1197,6 +1199,15 @@ struct vf_macvlans {
        u8 vf_macvlan[ETH_ALEN];
 };
 
+#define WX_RSS_FIELD_IPV4_TCP      BIT(0)
+#define WX_RSS_FIELD_IPV4          BIT(1)
+#define WX_RSS_FIELD_IPV4_SCTP     BIT(2)
+#define WX_RSS_FIELD_IPV6_SCTP     BIT(3)
+#define WX_RSS_FIELD_IPV6_TCP      BIT(4)
+#define WX_RSS_FIELD_IPV6          BIT(5)
+#define WX_RSS_FIELD_IPV4_UDP      BIT(6)
+#define WX_RSS_FIELD_IPV6_UDP      BIT(7)
+
 enum wx_pf_flags {
        WX_FLAG_MULTI_64_FUNC,
        WX_FLAG_SWFW_RING,
@@ -1307,6 +1318,7 @@ struct wx {
 #define WX_MAX_RETA_ENTRIES 128
 #define WX_RSS_INDIR_TBL_MAX 64
        u8 rss_indir_tbl[WX_MAX_RETA_ENTRIES];
+       u8 rss_flags;
        bool rss_enabled;
 #define WX_RSS_KEY_SIZE     40  /* size of RSS Hash Key in bytes */
        u32 *rss_key;