[PATCH net-next v1 3/3] r8169: add support for chip RTL9151AS

javen posted 3 patches 4 weeks, 1 day ago
[PATCH net-next v1 3/3] r8169: add support for chip RTL9151AS
Posted by javen 4 weeks, 1 day ago
From: Javen Xu <javen_xu@realsil.com.cn>

This patch adds support for chip RTL9151AS. Since lacking of Hardware
version IDs, we use TX_CONFIG_V2 to recognize RTL9151AS and coming chips.
rtl_chip_infos_extend is used to store IC information for RTL9151AS and
coming chips. The TxConfig value between RTL9151AS and RTL9151A is 
different.

Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
---
 drivers/net/ethernet/realtek/r8169.h      |  3 ++-
 drivers/net/ethernet/realtek/r8169_main.c | 28 +++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.h b/drivers/net/ethernet/realtek/r8169.h
index 2c1a0c21af8d..f66c279cbee6 100644
--- a/drivers/net/ethernet/realtek/r8169.h
+++ b/drivers/net/ethernet/realtek/r8169.h
@@ -72,7 +72,8 @@ enum mac_version {
 	RTL_GIGA_MAC_VER_70,
 	RTL_GIGA_MAC_VER_80,
 	RTL_GIGA_MAC_NONE,
-	RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1
+	RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1,
+	RTL_GIGA_MAC_VER_CHECK_EXTEND
 };
 
 struct rtl8169_private;
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 9b89bbf67198..164ad6570059 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -95,8 +95,8 @@
 #define JUMBO_16K	(SZ_16K - VLAN_ETH_HLEN - ETH_FCS_LEN)
 
 static const struct rtl_chip_info {
-	u16 mask;
-	u16 val;
+	u32 mask;
+	u32 val;
 	enum mac_version mac_version;
 	const char *name;
 	const char *fw_name;
@@ -205,10 +205,20 @@ static const struct rtl_chip_info {
 	{ 0xfc8, 0x040,	RTL_GIGA_MAC_VER_03, "RTL8110s" },
 	{ 0xfc8, 0x008,	RTL_GIGA_MAC_VER_02, "RTL8169s" },
 
+	/* extend chip version*/
+	{ 0x7cf, 0x7c8, RTL_GIGA_MAC_VER_CHECK_EXTEND },
+
 	/* Catch-all */
 	{ 0x000, 0x000,	RTL_GIGA_MAC_NONE }
 };
 
+static const struct rtl_chip_info rtl_chip_infos_extend[] = {
+	{ 0x7fffffff, 0x00000000, RTL_GIGA_MAC_VER_64, "RTL9151AS", FIRMWARE_9151A_1},
+
+	/* Catch-all */
+	{ 0x00000000, 0x00000000, RTL_GIGA_MAC_NONE }
+};
+
 static const struct pci_device_id rtl8169_pci_tbl[] = {
 	{ PCI_VDEVICE(REALTEK,	0x2502) },
 	{ PCI_VDEVICE(REALTEK,	0x2600) },
@@ -255,6 +265,8 @@ enum rtl_registers {
 	IntrStatus	= 0x3e,
 
 	TxConfig	= 0x40,
+	/* Extend version register */
+	TX_CONFIG_V2	= 0x60b0,
 #define	TXCFG_AUTO_FIFO			(1 << 7)	/* 8111e-vl */
 #define	TXCFG_EMPTY			(1 << 11)	/* 8111e-vl */
 
@@ -2351,6 +2363,15 @@ static const struct ethtool_ops rtl8169_ethtool_ops = {
 	.get_eth_ctrl_stats	= rtl8169_get_eth_ctrl_stats,
 };
 
+static const struct rtl_chip_info *rtl8169_get_extend_chip_version(u32 txconfigv2)
+{
+	const struct rtl_chip_info *p = rtl_chip_infos_extend;
+
+	while ((txconfigv2 & p->mask) != p->val)
+		p++;
+	return p;
+}
+
 static const struct rtl_chip_info *rtl8169_get_chip_version(u16 xid, bool gmii)
 {
 	/* Chips combining a 1Gbps MAC with a 100Mbps PHY */
@@ -5543,6 +5564,9 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	/* Identify chip attached to board */
 	chip = rtl8169_get_chip_version(xid, tp->supports_gmii);
+
+	if (chip->mac_version == RTL_GIGA_MAC_VER_CHECK_EXTEND)
+		chip = rtl8169_get_extend_chip_version(RTL_R32(tp, TX_CONFIG_V2));
 	if (chip->mac_version == RTL_GIGA_MAC_NONE)
 		return dev_err_probe(&pdev->dev, -ENODEV,
 				     "unknown chip XID %03x, contact r8169 maintainers (see MAINTAINERS file)\n",
-- 
2.43.0
Re: [PATCH net-next v1 3/3] r8169: add support for chip RTL9151AS
Posted by Heiner Kallweit 4 weeks ago
On 1/12/2026 3:45 AM, javen wrote:
> From: Javen Xu <javen_xu@realsil.com.cn>
> 
> This patch adds support for chip RTL9151AS. Since lacking of Hardware
> version IDs, we use TX_CONFIG_V2 to recognize RTL9151AS and coming chips.
> rtl_chip_infos_extend is used to store IC information for RTL9151AS and
> coming chips. The TxConfig value between RTL9151AS and RTL9151A is 
> 
> different.
> 
> Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
> ---
>  drivers/net/ethernet/realtek/r8169.h      |  3 ++-
>  drivers/net/ethernet/realtek/r8169_main.c | 28 +++++++++++++++++++++--
>  2 files changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/realtek/r8169.h b/drivers/net/ethernet/realtek/r8169.h
> index 2c1a0c21af8d..f66c279cbee6 100644
> --- a/drivers/net/ethernet/realtek/r8169.h
> +++ b/drivers/net/ethernet/realtek/r8169.h
> @@ -72,7 +72,8 @@ enum mac_version {
>  	RTL_GIGA_MAC_VER_70,
>  	RTL_GIGA_MAC_VER_80,
>  	RTL_GIGA_MAC_NONE,
> -	RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1
> +	RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1,
> +	RTL_GIGA_MAC_VER_CHECK_EXTEND
>  };
>  
>  struct rtl8169_private;
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index 9b89bbf67198..164ad6570059 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -95,8 +95,8 @@
>  #define JUMBO_16K	(SZ_16K - VLAN_ETH_HLEN - ETH_FCS_LEN)
>  
>  static const struct rtl_chip_info {
> -	u16 mask;
> -	u16 val;
> +	u32 mask;
> +	u32 val;
>  	enum mac_version mac_version;
>  	const char *name;
>  	const char *fw_name;
> @@ -205,10 +205,20 @@ static const struct rtl_chip_info {
>  	{ 0xfc8, 0x040,	RTL_GIGA_MAC_VER_03, "RTL8110s" },
>  	{ 0xfc8, 0x008,	RTL_GIGA_MAC_VER_02, "RTL8169s" },
>  
> +	/* extend chip version*/
> +	{ 0x7cf, 0x7c8, RTL_GIGA_MAC_VER_CHECK_EXTEND },
> +
>  	/* Catch-all */
>  	{ 0x000, 0x000,	RTL_GIGA_MAC_NONE }
>  };
>  
> +static const struct rtl_chip_info rtl_chip_infos_extend[] = {
> +	{ 0x7fffffff, 0x00000000, RTL_GIGA_MAC_VER_64, "RTL9151AS", FIRMWARE_9151A_1},
> +

Seems all bits except bit 31 are used for chip detection. However register is
named TX_CONFIG_V2, even though only bit 31 is left for actual tx configuration.
Is the register name misleading, or is the mask incorrect?


> +	/* Catch-all */
> +	{ 0x00000000, 0x00000000, RTL_GIGA_MAC_NONE }
> +};
> +
>  static const struct pci_device_id rtl8169_pci_tbl[] = {
>  	{ PCI_VDEVICE(REALTEK,	0x2502) },
>  	{ PCI_VDEVICE(REALTEK,	0x2600) },
> @@ -255,6 +265,8 @@ enum rtl_registers {
>  	IntrStatus	= 0x3e,
>  
>  	TxConfig	= 0x40,
> +	/* Extend version register */
> +	TX_CONFIG_V2	= 0x60b0,
>  #define	TXCFG_AUTO_FIFO			(1 << 7)	/* 8111e-vl */
>  #define	TXCFG_EMPTY			(1 << 11)	/* 8111e-vl */
>  
> @@ -2351,6 +2363,15 @@ static const struct ethtool_ops rtl8169_ethtool_ops = {
>  	.get_eth_ctrl_stats	= rtl8169_get_eth_ctrl_stats,
>  };
>  
> +static const struct rtl_chip_info *rtl8169_get_extend_chip_version(u32 txconfigv2)
> +{
> +	const struct rtl_chip_info *p = rtl_chip_infos_extend;
> +
> +	while ((txconfigv2 & p->mask) != p->val)
> +		p++;
> +	return p;
> +}
> +
>  static const struct rtl_chip_info *rtl8169_get_chip_version(u16 xid, bool gmii)
>  {
>  	/* Chips combining a 1Gbps MAC with a 100Mbps PHY */
> @@ -5543,6 +5564,9 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>  
>  	/* Identify chip attached to board */
>  	chip = rtl8169_get_chip_version(xid, tp->supports_gmii);
> +
> +	if (chip->mac_version == RTL_GIGA_MAC_VER_CHECK_EXTEND)
> +		chip = rtl8169_get_extend_chip_version(RTL_R32(tp, TX_CONFIG_V2));
>  	if (chip->mac_version == RTL_GIGA_MAC_NONE)
>  		return dev_err_probe(&pdev->dev, -ENODEV,
>  				     "unknown chip XID %03x, contact r8169 maintainers (see MAINTAINERS file)\n",
Re: [PATCH net-next v1 3/3] r8169: add support for chip RTL9151AS
Posted by Paolo Abeni 3 weeks, 4 days ago
On 1/12/26 11:20 PM, Heiner Kallweit wrote:
> On 1/12/2026 3:45 AM, javen wrote:
>> From: Javen Xu <javen_xu@realsil.com.cn>
>>
>> This patch adds support for chip RTL9151AS. Since lacking of Hardware
>> version IDs, we use TX_CONFIG_V2 to recognize RTL9151AS and coming chips.
>> rtl_chip_infos_extend is used to store IC information for RTL9151AS and
>> coming chips. The TxConfig value between RTL9151AS and RTL9151A is 
>>
>> different.
>>
>> Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
>> ---
>>  drivers/net/ethernet/realtek/r8169.h      |  3 ++-
>>  drivers/net/ethernet/realtek/r8169_main.c | 28 +++++++++++++++++++++--
>>  2 files changed, 28 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/realtek/r8169.h b/drivers/net/ethernet/realtek/r8169.h
>> index 2c1a0c21af8d..f66c279cbee6 100644
>> --- a/drivers/net/ethernet/realtek/r8169.h
>> +++ b/drivers/net/ethernet/realtek/r8169.h
>> @@ -72,7 +72,8 @@ enum mac_version {
>>  	RTL_GIGA_MAC_VER_70,
>>  	RTL_GIGA_MAC_VER_80,
>>  	RTL_GIGA_MAC_NONE,
>> -	RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1
>> +	RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1,
>> +	RTL_GIGA_MAC_VER_CHECK_EXTEND
>>  };
>>  
>>  struct rtl8169_private;
>> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
>> index 9b89bbf67198..164ad6570059 100644
>> --- a/drivers/net/ethernet/realtek/r8169_main.c
>> +++ b/drivers/net/ethernet/realtek/r8169_main.c
>> @@ -95,8 +95,8 @@
>>  #define JUMBO_16K	(SZ_16K - VLAN_ETH_HLEN - ETH_FCS_LEN)
>>  
>>  static const struct rtl_chip_info {
>> -	u16 mask;
>> -	u16 val;
>> +	u32 mask;
>> +	u32 val;
>>  	enum mac_version mac_version;
>>  	const char *name;
>>  	const char *fw_name;
>> @@ -205,10 +205,20 @@ static const struct rtl_chip_info {
>>  	{ 0xfc8, 0x040,	RTL_GIGA_MAC_VER_03, "RTL8110s" },
>>  	{ 0xfc8, 0x008,	RTL_GIGA_MAC_VER_02, "RTL8169s" },
>>  
>> +	/* extend chip version*/
>> +	{ 0x7cf, 0x7c8, RTL_GIGA_MAC_VER_CHECK_EXTEND },
>> +
>>  	/* Catch-all */
>>  	{ 0x000, 0x000,	RTL_GIGA_MAC_NONE }
>>  };
>>  
>> +static const struct rtl_chip_info rtl_chip_infos_extend[] = {
>> +	{ 0x7fffffff, 0x00000000, RTL_GIGA_MAC_VER_64, "RTL9151AS", FIRMWARE_9151A_1},
>> +
> 
> Seems all bits except bit 31 are used for chip detection. However register is
> named TX_CONFIG_V2, even though only bit 31 is left for actual tx configuration.
> Is the register name misleading, or is the mask incorrect?

@Heiner (double checking to avoid more confusion on my side): are you
fine with the register name? It's unclear to me if you are fine with
just the 2 merged patches or even with this one.

Thanks,

Paolo
RE: [PATCH net-next v1 3/3] r8169: add support for chip RTL9151AS
Posted by 许俊伟 2 weeks, 5 days ago
>On 1/12/26 11:20 PM, Heiner Kallweit wrote:
>> On 1/12/2026 3:45 AM, javen wrote:
>>> From: Javen Xu <javen_xu@realsil.com.cn>
>>>
>>> This patch adds support for chip RTL9151AS. Since lacking of Hardware
>>> version IDs, we use TX_CONFIG_V2 to recognize RTL9151AS and coming
>chips.
>>> rtl_chip_infos_extend is used to store IC information for RTL9151AS
>>> and coming chips. The TxConfig value between RTL9151AS and RTL9151A
>>> is
>>>
>>> different.
>>>
>>> Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
>>> ---
>>>  drivers/net/ethernet/realtek/r8169.h      |  3 ++-
>>>  drivers/net/ethernet/realtek/r8169_main.c | 28
>>> +++++++++++++++++++++--
>>>  2 files changed, 28 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/realtek/r8169.h
>>> b/drivers/net/ethernet/realtek/r8169.h
>>> index 2c1a0c21af8d..f66c279cbee6 100644
>>> --- a/drivers/net/ethernet/realtek/r8169.h
>>> +++ b/drivers/net/ethernet/realtek/r8169.h
>>> @@ -72,7 +72,8 @@ enum mac_version {
>>>      RTL_GIGA_MAC_VER_70,
>>>      RTL_GIGA_MAC_VER_80,
>>>      RTL_GIGA_MAC_NONE,
>>> -    RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1
>>> +    RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1,
>>> +    RTL_GIGA_MAC_VER_CHECK_EXTEND
>>>  };
>>>
>>>  struct rtl8169_private;
>>> diff --git a/drivers/net/ethernet/realtek/r8169_main.c
>>> b/drivers/net/ethernet/realtek/r8169_main.c
>>> index 9b89bbf67198..164ad6570059 100644
>>> --- a/drivers/net/ethernet/realtek/r8169_main.c
>>> +++ b/drivers/net/ethernet/realtek/r8169_main.c
>>> @@ -95,8 +95,8 @@
>>>  #define JUMBO_16K   (SZ_16K - VLAN_ETH_HLEN - ETH_FCS_LEN)
>>>
>>>  static const struct rtl_chip_info {
>>> -    u16 mask;
>>> -    u16 val;
>>> +    u32 mask;
>>> +    u32 val;
>>>      enum mac_version mac_version;
>>>      const char *name;
>>>      const char *fw_name;
>>> @@ -205,10 +205,20 @@ static const struct rtl_chip_info {
>>>      { 0xfc8, 0x040, RTL_GIGA_MAC_VER_03, "RTL8110s" },
>>>      { 0xfc8, 0x008, RTL_GIGA_MAC_VER_02, "RTL8169s" },
>>>
>>> +    /* extend chip version*/
>>> +    { 0x7cf, 0x7c8, RTL_GIGA_MAC_VER_CHECK_EXTEND },
>>> +
>>>      /* Catch-all */
>>>      { 0x000, 0x000, RTL_GIGA_MAC_NONE }  };
>>>
>>> +static const struct rtl_chip_info rtl_chip_infos_extend[] = {
>>> +    { 0x7fffffff, 0x00000000, RTL_GIGA_MAC_VER_64, "RTL9151AS",
>>> +FIRMWARE_9151A_1},
>>> +
>>
>> Seems all bits except bit 31 are used for chip detection. However
>> register is named TX_CONFIG_V2, even though only bit 31 is left for actual tx
>configuration.
>> Is the register name misleading, or is the mask incorrect?
>
>@Heiner (double checking to avoid more confusion on my side): are you fine
>with the register name? It's unclear to me if you are fine with just the 2
>merged patches or even with this one.
>
>Thanks,
>
>Paolo

Hi, Paolo & Heiner

It appears that this patch has not been accepted yet. Should I resubmit it as a 
separate  patch?

Thank,
Javen Xu
Re: [PATCH net-next v1 3/3] r8169: add support for chip RTL9151AS
Posted by Heiner Kallweit 2 weeks, 2 days ago
On 1/22/2026 2:42 AM, 许俊伟 wrote:
>> On 1/12/26 11:20 PM, Heiner Kallweit wrote:
>>> On 1/12/2026 3:45 AM, javen wrote:
>>>> From: Javen Xu <javen_xu@realsil.com.cn>
>>>>
>>>> This patch adds support for chip RTL9151AS. Since lacking of Hardware
>>>> version IDs, we use TX_CONFIG_V2 to recognize RTL9151AS and coming
>> chips.
>>>> rtl_chip_infos_extend is used to store IC information for RTL9151AS
>>>> and coming chips. The TxConfig value between RTL9151AS and RTL9151A
>>>> is
>>>>
>>>> different.
>>>>
>>>> Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
>>>> ---
>>>>  drivers/net/ethernet/realtek/r8169.h      |  3 ++-
>>>>  drivers/net/ethernet/realtek/r8169_main.c | 28
>>>> +++++++++++++++++++++--
>>>>  2 files changed, 28 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/realtek/r8169.h
>>>> b/drivers/net/ethernet/realtek/r8169.h
>>>> index 2c1a0c21af8d..f66c279cbee6 100644
>>>> --- a/drivers/net/ethernet/realtek/r8169.h
>>>> +++ b/drivers/net/ethernet/realtek/r8169.h
>>>> @@ -72,7 +72,8 @@ enum mac_version {
>>>>      RTL_GIGA_MAC_VER_70,
>>>>      RTL_GIGA_MAC_VER_80,
>>>>      RTL_GIGA_MAC_NONE,
>>>> -    RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1
>>>> +    RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1,
>>>> +    RTL_GIGA_MAC_VER_CHECK_EXTEND
>>>>  };
>>>>
>>>>  struct rtl8169_private;
>>>> diff --git a/drivers/net/ethernet/realtek/r8169_main.c
>>>> b/drivers/net/ethernet/realtek/r8169_main.c
>>>> index 9b89bbf67198..164ad6570059 100644
>>>> --- a/drivers/net/ethernet/realtek/r8169_main.c
>>>> +++ b/drivers/net/ethernet/realtek/r8169_main.c
>>>> @@ -95,8 +95,8 @@
>>>>  #define JUMBO_16K   (SZ_16K - VLAN_ETH_HLEN - ETH_FCS_LEN)
>>>>
>>>>  static const struct rtl_chip_info {
>>>> -    u16 mask;
>>>> -    u16 val;
>>>> +    u32 mask;
>>>> +    u32 val;
>>>>      enum mac_version mac_version;
>>>>      const char *name;
>>>>      const char *fw_name;
>>>> @@ -205,10 +205,20 @@ static const struct rtl_chip_info {
>>>>      { 0xfc8, 0x040, RTL_GIGA_MAC_VER_03, "RTL8110s" },
>>>>      { 0xfc8, 0x008, RTL_GIGA_MAC_VER_02, "RTL8169s" },
>>>>
>>>> +    /* extend chip version*/
>>>> +    { 0x7cf, 0x7c8, RTL_GIGA_MAC_VER_CHECK_EXTEND },
>>>> +
>>>>      /* Catch-all */
>>>>      { 0x000, 0x000, RTL_GIGA_MAC_NONE }  };
>>>>
>>>> +static const struct rtl_chip_info rtl_chip_infos_extend[] = {
>>>> +    { 0x7fffffff, 0x00000000, RTL_GIGA_MAC_VER_64, "RTL9151AS",
>>>> +FIRMWARE_9151A_1},
>>>> +
>>>
>>> Seems all bits except bit 31 are used for chip detection. However
>>> register is named TX_CONFIG_V2, even though only bit 31 is left for actual tx
>> configuration.
>>> Is the register name misleading, or is the mask incorrect?
>>
>> @Heiner (double checking to avoid more confusion on my side): are you fine
>> with the register name? It's unclear to me if you are fine with just the 2
>> merged patches or even with this one.
>>
>> Thanks,
>>
>> Paolo
> 
> Hi, Paolo & Heiner
> 
> It appears that this patch has not been accepted yet. Should I resubmit it as a 
> separate  patch?
> 
I will slightly extend your patch to display the new extended XID properly
in places where the XID is printed, and submit it on your behalf.

> Thank,
> Javen Xu

Heiner
Re: [PATCH net-next v1 3/3] r8169: add support for chip RTL9151AS
Posted by Heiner Kallweit 3 weeks, 4 days ago
On 1/15/2026 11:51 AM, Paolo Abeni wrote:
> On 1/12/26 11:20 PM, Heiner Kallweit wrote:
>> On 1/12/2026 3:45 AM, javen wrote:
>>> From: Javen Xu <javen_xu@realsil.com.cn>
>>>
>>> This patch adds support for chip RTL9151AS. Since lacking of Hardware
>>> version IDs, we use TX_CONFIG_V2 to recognize RTL9151AS and coming chips.
>>> rtl_chip_infos_extend is used to store IC information for RTL9151AS and
>>> coming chips. The TxConfig value between RTL9151AS and RTL9151A is 
>>>
>>> different.
>>>
>>> Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
>>> ---
>>>  drivers/net/ethernet/realtek/r8169.h      |  3 ++-
>>>  drivers/net/ethernet/realtek/r8169_main.c | 28 +++++++++++++++++++++--
>>>  2 files changed, 28 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/realtek/r8169.h b/drivers/net/ethernet/realtek/r8169.h
>>> index 2c1a0c21af8d..f66c279cbee6 100644
>>> --- a/drivers/net/ethernet/realtek/r8169.h
>>> +++ b/drivers/net/ethernet/realtek/r8169.h
>>> @@ -72,7 +72,8 @@ enum mac_version {
>>>  	RTL_GIGA_MAC_VER_70,
>>>  	RTL_GIGA_MAC_VER_80,
>>>  	RTL_GIGA_MAC_NONE,
>>> -	RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1
>>> +	RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1,
>>> +	RTL_GIGA_MAC_VER_CHECK_EXTEND
>>>  };
>>>  
>>>  struct rtl8169_private;
>>> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
>>> index 9b89bbf67198..164ad6570059 100644
>>> --- a/drivers/net/ethernet/realtek/r8169_main.c
>>> +++ b/drivers/net/ethernet/realtek/r8169_main.c
>>> @@ -95,8 +95,8 @@
>>>  #define JUMBO_16K	(SZ_16K - VLAN_ETH_HLEN - ETH_FCS_LEN)
>>>  
>>>  static const struct rtl_chip_info {
>>> -	u16 mask;
>>> -	u16 val;
>>> +	u32 mask;
>>> +	u32 val;
>>>  	enum mac_version mac_version;
>>>  	const char *name;
>>>  	const char *fw_name;
>>> @@ -205,10 +205,20 @@ static const struct rtl_chip_info {
>>>  	{ 0xfc8, 0x040,	RTL_GIGA_MAC_VER_03, "RTL8110s" },
>>>  	{ 0xfc8, 0x008,	RTL_GIGA_MAC_VER_02, "RTL8169s" },
>>>  
>>> +	/* extend chip version*/
>>> +	{ 0x7cf, 0x7c8, RTL_GIGA_MAC_VER_CHECK_EXTEND },
>>> +
>>>  	/* Catch-all */
>>>  	{ 0x000, 0x000,	RTL_GIGA_MAC_NONE }
>>>  };
>>>  
>>> +static const struct rtl_chip_info rtl_chip_infos_extend[] = {
>>> +	{ 0x7fffffff, 0x00000000, RTL_GIGA_MAC_VER_64, "RTL9151AS", FIRMWARE_9151A_1},
>>> +
>>
>> Seems all bits except bit 31 are used for chip detection. However register is
>> named TX_CONFIG_V2, even though only bit 31 is left for actual tx configuration.
>> Is the register name misleading, or is the mask incorrect?
> 
> @Heiner (double checking to avoid more confusion on my side): are you
> fine with the register name? It's unclear to me if you are fine with
> just the 2 merged patches or even with this one.
> 

I understand their motivation for the register name, even though I don't find it ideal.
But if their datasheet calls it like this, then ok.

So yes, patch is fine with me.

> Thanks,
> 
> Paolo
>
Re: [PATCH net-next v1 3/3] r8169: add support for chip RTL9151AS
Posted by javen 4 weeks ago
> On 1/12/2026 3:45 AM, javen wrote:
> > From: Javen Xu <javen_xu@realsil.com.cn>
> >
> > This patch adds support for chip RTL9151AS. Since lacking of Hardware
> > version IDs, we use TX_CONFIG_V2 to recognize RTL9151AS and coming
> chips.
> > rtl_chip_infos_extend is used to store IC information for RTL9151AS
> > and coming chips. The TxConfig value between RTL9151AS and RTL9151A is
> >
> > different.
> >
> > Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
> > ---
> >  drivers/net/ethernet/realtek/r8169.h      |  3 ++-
> >  drivers/net/ethernet/realtek/r8169_main.c | 28
> > +++++++++++++++++++++--
> >  2 files changed, 28 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/realtek/r8169.h
> > b/drivers/net/ethernet/realtek/r8169.h
> > index 2c1a0c21af8d..f66c279cbee6 100644
> > --- a/drivers/net/ethernet/realtek/r8169.h
> > +++ b/drivers/net/ethernet/realtek/r8169.h
> > @@ -72,7 +72,8 @@ enum mac_version {
> >       RTL_GIGA_MAC_VER_70,
> >       RTL_GIGA_MAC_VER_80,
> >       RTL_GIGA_MAC_NONE,
> > -     RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1
> > +     RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1,
> > +     RTL_GIGA_MAC_VER_CHECK_EXTEND
> >  };
> >
> >  struct rtl8169_private;
> > diff --git a/drivers/net/ethernet/realtek/r8169_main.c
> > b/drivers/net/ethernet/realtek/r8169_main.c
> > index 9b89bbf67198..164ad6570059 100644
> > --- a/drivers/net/ethernet/realtek/r8169_main.c
> > +++ b/drivers/net/ethernet/realtek/r8169_main.c
> > @@ -95,8 +95,8 @@
> >  #define JUMBO_16K    (SZ_16K - VLAN_ETH_HLEN - ETH_FCS_LEN)
> >
> >  static const struct rtl_chip_info {
> > -     u16 mask;
> > -     u16 val;
> > +     u32 mask;
> > +     u32 val;
> >       enum mac_version mac_version;
> >       const char *name;
> >       const char *fw_name;
> > @@ -205,10 +205,20 @@ static const struct rtl_chip_info {
> >       { 0xfc8, 0x040, RTL_GIGA_MAC_VER_03, "RTL8110s" },
> >       { 0xfc8, 0x008, RTL_GIGA_MAC_VER_02, "RTL8169s" },
> >
> > +     /* extend chip version*/
> > +     { 0x7cf, 0x7c8, RTL_GIGA_MAC_VER_CHECK_EXTEND },
> > +
> >       /* Catch-all */
> >       { 0x000, 0x000, RTL_GIGA_MAC_NONE }  };
> >
> > +static const struct rtl_chip_info rtl_chip_infos_extend[] = {
> > +     { 0x7fffffff, 0x00000000, RTL_GIGA_MAC_VER_64, "RTL9151AS",
> > +FIRMWARE_9151A_1},
> > +
> 
> Seems all bits except bit 31 are used for chip detection. However register is
> named TX_CONFIG_V2, even though only bit 31 is left for actual tx
> configuration.
> Is the register name misleading, or is the mask incorrect?
> 

Previously, we used TxConfig for chip detection. But considering that the 
remaining version IDs are limited, we need to extend it. To remain the 
consistency of name, we choose TX_CONFIG_V2 to extend it. Bit 31 is 
reserved and always 0. Only if nic link drop, it will be set to 1.
 
> > +     /* Catch-all */
> > +     { 0x00000000, 0x00000000, RTL_GIGA_MAC_NONE } };
> > +
> >  static const struct pci_device_id rtl8169_pci_tbl[] = {
> >       { PCI_VDEVICE(REALTEK,  0x2502) },
> >       { PCI_VDEVICE(REALTEK,  0x2600) }, @@ -255,6 +265,8 @@ enum
> > rtl_registers {
> >       IntrStatus      = 0x3e,
> >
> >       TxConfig        = 0x40,
> > +     /* Extend version register */
> > +     TX_CONFIG_V2    = 0x60b0,
> >  #define      TXCFG_AUTO_FIFO                 (1 << 7)        /* 8111e-vl */
> >  #define      TXCFG_EMPTY                     (1 << 11)       /* 8111e-vl */
> >
> > @@ -2351,6 +2363,15 @@ static const struct ethtool_ops
> rtl8169_ethtool_ops = {
> >       .get_eth_ctrl_stats     = rtl8169_get_eth_ctrl_stats,
> >  };
> >
> > +static const struct rtl_chip_info
> > +*rtl8169_get_extend_chip_version(u32 txconfigv2) {
> > +     const struct rtl_chip_info *p = rtl_chip_infos_extend;
> > +
> > +     while ((txconfigv2 & p->mask) != p->val)
> > +             p++;
> > +     return p;
> > +}
> > +
> >  static const struct rtl_chip_info *rtl8169_get_chip_version(u16 xid,
> > bool gmii)  {
> >       /* Chips combining a 1Gbps MAC with a 100Mbps PHY */ @@ -5543,6
> > +5564,9 @@ static int rtl_init_one(struct pci_dev *pdev, const struct
> > pci_device_id *ent)
> >
> >       /* Identify chip attached to board */
> >       chip = rtl8169_get_chip_version(xid, tp->supports_gmii);
> > +
> > +     if (chip->mac_version == RTL_GIGA_MAC_VER_CHECK_EXTEND)
> > +             chip = rtl8169_get_extend_chip_version(RTL_R32(tp,
> > + TX_CONFIG_V2));
> >       if (chip->mac_version == RTL_GIGA_MAC_NONE)
> >               return dev_err_probe(&pdev->dev, -ENODEV,
> >                                    "unknown chip XID %03x, contact
> > r8169 maintainers (see MAINTAINERS file)\n",