Skip to content

Commit 70ab873

Browse files
author
Paolo Abeni
committed
Merge branch 'correcting-switch-hardware-versions-and-reported-speeds'
Justin Lai says: ==================== Correcting switch hardware versions and reported speeds This patch set mainly involves correcting switch hardware versions and reported speeds. Details are as follows: 1. Refactor the rtase_check_mac_version_valid() function. 2. Correct the speed for RTL907XD-V1 3. Corrects error handling of the rtase_check_mac_version_valid() v1 -> v2: - Add Fixes: tag. - Add defines for hardware version id. - Modify the error message for an invalid hardware version ID. v2 -> v3: - Remove the patch "Add support for RTL907XD-VA PCIe port". v3 -> v4: - Modify commit message to describe the main reason for the fix. v4 -> v5 - Integrate the addition of defines for hardware version ID into the patch "rtase: Refactor the rtase_check_mac_version_valid() function." ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents ebaf813 + a01cfcf commit 70ab873

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

drivers/net/ethernet/realtek/rtase/rtase.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
#ifndef RTASE_H
1010
#define RTASE_H
1111

12-
#define RTASE_HW_VER_MASK 0x7C800000
12+
#define RTASE_HW_VER_MASK 0x7C800000
13+
#define RTASE_HW_VER_906X_7XA 0x00800000
14+
#define RTASE_HW_VER_906X_7XC 0x04000000
15+
#define RTASE_HW_VER_907XD_V1 0x04800000
1316

1417
#define RTASE_RX_DMA_BURST_256 4
1518
#define RTASE_TX_DMA_BURST_UNLIMITED 7
@@ -327,6 +330,8 @@ struct rtase_private {
327330
u16 int_nums;
328331
u16 tx_int_mit;
329332
u16 rx_int_mit;
333+
334+
u32 hw_ver;
330335
};
331336

332337
#define RTASE_LSO_64K 64000

drivers/net/ethernet/realtek/rtase/rtase_main.c

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,10 +1714,21 @@ static int rtase_get_settings(struct net_device *dev,
17141714
struct ethtool_link_ksettings *cmd)
17151715
{
17161716
u32 supported = SUPPORTED_MII | SUPPORTED_Pause | SUPPORTED_Asym_Pause;
1717+
const struct rtase_private *tp = netdev_priv(dev);
17171718

17181719
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
17191720
supported);
1720-
cmd->base.speed = SPEED_5000;
1721+
1722+
switch (tp->hw_ver) {
1723+
case RTASE_HW_VER_906X_7XA:
1724+
case RTASE_HW_VER_906X_7XC:
1725+
cmd->base.speed = SPEED_5000;
1726+
break;
1727+
case RTASE_HW_VER_907XD_V1:
1728+
cmd->base.speed = SPEED_10000;
1729+
break;
1730+
}
1731+
17211732
cmd->base.duplex = DUPLEX_FULL;
17221733
cmd->base.port = PORT_MII;
17231734
cmd->base.autoneg = AUTONEG_DISABLE;
@@ -1972,20 +1983,21 @@ static void rtase_init_software_variable(struct pci_dev *pdev,
19721983
tp->dev->max_mtu = RTASE_MAX_JUMBO_SIZE;
19731984
}
19741985

1975-
static bool rtase_check_mac_version_valid(struct rtase_private *tp)
1986+
static int rtase_check_mac_version_valid(struct rtase_private *tp)
19761987
{
1977-
u32 hw_ver = rtase_r32(tp, RTASE_TX_CONFIG_0) & RTASE_HW_VER_MASK;
1978-
bool known_ver = false;
1988+
int ret = -ENODEV;
1989+
1990+
tp->hw_ver = rtase_r32(tp, RTASE_TX_CONFIG_0) & RTASE_HW_VER_MASK;
19791991

1980-
switch (hw_ver) {
1981-
case 0x00800000:
1982-
case 0x04000000:
1983-
case 0x04800000:
1984-
known_ver = true;
1992+
switch (tp->hw_ver) {
1993+
case RTASE_HW_VER_906X_7XA:
1994+
case RTASE_HW_VER_906X_7XC:
1995+
case RTASE_HW_VER_907XD_V1:
1996+
ret = 0;
19851997
break;
19861998
}
19871999

1988-
return known_ver;
2000+
return ret;
19892001
}
19902002

19912003
static int rtase_init_board(struct pci_dev *pdev, struct net_device **dev_out,
@@ -2105,9 +2117,13 @@ static int rtase_init_one(struct pci_dev *pdev,
21052117
tp->pdev = pdev;
21062118

21072119
/* identify chip attached to board */
2108-
if (!rtase_check_mac_version_valid(tp))
2109-
return dev_err_probe(&pdev->dev, -ENODEV,
2110-
"unknown chip version, contact rtase maintainers (see MAINTAINERS file)\n");
2120+
ret = rtase_check_mac_version_valid(tp);
2121+
if (ret != 0) {
2122+
dev_err(&pdev->dev,
2123+
"unknown chip version: 0x%08x, contact rtase maintainers (see MAINTAINERS file)\n",
2124+
tp->hw_ver);
2125+
goto err_out_release_board;
2126+
}
21112127

21122128
rtase_init_software_variable(pdev, tp);
21132129
rtase_init_hardware(tp);
@@ -2181,6 +2197,7 @@ static int rtase_init_one(struct pci_dev *pdev,
21812197
netif_napi_del(&ivec->napi);
21822198
}
21832199

2200+
err_out_release_board:
21842201
rtase_release_board(pdev, dev, ioaddr);
21852202

21862203
return ret;

0 commit comments

Comments
 (0)