Skip to content

Commit 8c941f1

Browse files
committed
Merge branch 'there-are-some-bugfix-for-hibmcge-driver'
Jijie Shao says: ==================== There are some bugfix for hibmcge driver v2: https://lore.kernel.org/[email protected]/ v1: https://lore.kernel.org/[email protected]/ ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents f7a11cb + e1d0b52 commit 8c941f1

File tree

9 files changed

+55
-22
lines changed

9 files changed

+55
-22
lines changed

drivers/net/ethernet/hisilicon/hibmcge/hbg_common.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,16 @@ struct hbg_irq_info {
108108
bool re_enable;
109109
bool need_print;
110110
bool need_reset;
111-
u64 count;
112111

113-
void (*irq_handle)(struct hbg_priv *priv, struct hbg_irq_info *info);
112+
void (*irq_handle)(struct hbg_priv *priv,
113+
const struct hbg_irq_info *info);
114114
};
115115

116116
struct hbg_vector {
117117
char name[HBG_VECTOR_NUM][32];
118-
struct hbg_irq_info *info_array;
118+
119+
u64 *stats_array;
120+
const struct hbg_irq_info *info_array;
119121
u32 info_array_len;
120122
};
121123

drivers/net/ethernet/hisilicon/hibmcge/hbg_debugfs.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int hbg_dbg_irq_info(struct seq_file *s, void *unused)
6161
{
6262
struct net_device *netdev = dev_get_drvdata(s->private);
6363
struct hbg_priv *priv = netdev_priv(netdev);
64-
struct hbg_irq_info *info;
64+
const struct hbg_irq_info *info;
6565
u32 i;
6666

6767
for (i = 0; i < priv->vectors.info_array_len; i++) {
@@ -73,7 +73,7 @@ static int hbg_dbg_irq_info(struct seq_file *s, void *unused)
7373
info->mask)),
7474
str_true_false(info->need_reset),
7575
str_true_false(info->need_print),
76-
info->count);
76+
priv->vectors.stats_array[i]);
7777
}
7878

7979
return 0;
@@ -106,6 +106,7 @@ static int hbg_dbg_nic_state(struct seq_file *s, void *unused)
106106
{
107107
struct net_device *netdev = dev_get_drvdata(s->private);
108108
struct hbg_priv *priv = netdev_priv(netdev);
109+
bool np_link_fail;
109110

110111
seq_printf(s, "event handling state: %s\n",
111112
state_str_true_false(priv, HBG_NIC_STATE_EVENT_HANDLING));
@@ -117,8 +118,10 @@ static int hbg_dbg_nic_state(struct seq_file *s, void *unused)
117118
reset_type_str[priv->reset_type]);
118119
seq_printf(s, "need reset state: %s\n",
119120
state_str_true_false(priv, HBG_NIC_STATE_NEED_RESET));
120-
seq_printf(s, "np_link fail state: %s\n",
121-
state_str_true_false(priv, HBG_NIC_STATE_NP_LINK_FAIL));
121+
122+
np_link_fail = !hbg_reg_read_field(priv, HBG_REG_AN_NEG_STATE_ADDR,
123+
HBG_REG_AN_NEG_STATE_NP_LINK_OK_B);
124+
seq_printf(s, "np_link fail state: %s\n", str_true_false(np_link_fail));
122125

123126
return 0;
124127
}

drivers/net/ethernet/hisilicon/hibmcge/hbg_diagnose.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static u64 hbg_get_irq_stats(struct hbg_vector *vectors, u32 mask)
234234

235235
for (i = 0; i < vectors->info_array_len; i++)
236236
if (vectors->info_array[i].mask == mask)
237-
return vectors->info_array[i].count;
237+
return vectors->stats_array[i];
238238

239239
return 0;
240240
}

drivers/net/ethernet/hisilicon/hibmcge/hbg_err.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ static void hbg_restore_mac_table(struct hbg_priv *priv)
2626

2727
static void hbg_restore_user_def_settings(struct hbg_priv *priv)
2828
{
29+
/* The index of host mac is always 0. */
30+
u64 rx_pause_addr = ether_addr_to_u64(priv->filter.mac_table[0].addr);
2931
struct ethtool_pauseparam *pause_param = &priv->user_def.pause_param;
3032

3133
hbg_restore_mac_table(priv);
3234
hbg_hw_set_mtu(priv, priv->netdev->mtu);
3335
hbg_hw_set_pause_enable(priv, pause_param->tx_pause,
3436
pause_param->rx_pause);
37+
hbg_hw_set_rx_pause_mac_addr(priv, rx_pause_addr);
3538
}
3639

3740
int hbg_rebuild(struct hbg_priv *priv)

drivers/net/ethernet/hisilicon/hibmcge/hbg_hw.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ void hbg_hw_set_mac_filter_enable(struct hbg_priv *priv, u32 enable)
234234
{
235235
hbg_reg_write_field(priv, HBG_REG_REC_FILT_CTRL_ADDR,
236236
HBG_REG_REC_FILT_CTRL_UC_MATCH_EN_B, enable);
237+
238+
/* only uc filter is supported, so set all bits of mc mask reg to 1 */
239+
hbg_reg_write64(priv, HBG_REG_STATION_ADDR_LOW_MSK_0, U64_MAX);
240+
hbg_reg_write64(priv, HBG_REG_STATION_ADDR_LOW_MSK_1, U64_MAX);
237241
}
238242

239243
void hbg_hw_set_pause_enable(struct hbg_priv *priv, u32 tx_en, u32 rx_en)
@@ -242,6 +246,9 @@ void hbg_hw_set_pause_enable(struct hbg_priv *priv, u32 tx_en, u32 rx_en)
242246
HBG_REG_PAUSE_ENABLE_TX_B, tx_en);
243247
hbg_reg_write_field(priv, HBG_REG_PAUSE_ENABLE_ADDR,
244248
HBG_REG_PAUSE_ENABLE_RX_B, rx_en);
249+
250+
hbg_reg_write_field(priv, HBG_REG_REC_FILT_CTRL_ADDR,
251+
HBG_REG_REC_FILT_CTRL_PAUSE_FRM_PASS_B, rx_en);
245252
}
246253

247254
void hbg_hw_get_pause_enable(struct hbg_priv *priv, u32 *tx_en, u32 *rx_en)

drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "hbg_hw.h"
77

88
static void hbg_irq_handle_err(struct hbg_priv *priv,
9-
struct hbg_irq_info *irq_info)
9+
const struct hbg_irq_info *irq_info)
1010
{
1111
if (irq_info->need_print)
1212
dev_err(&priv->pdev->dev,
@@ -17,30 +17,30 @@ static void hbg_irq_handle_err(struct hbg_priv *priv,
1717
}
1818

1919
static void hbg_irq_handle_tx(struct hbg_priv *priv,
20-
struct hbg_irq_info *irq_info)
20+
const struct hbg_irq_info *irq_info)
2121
{
2222
napi_schedule(&priv->tx_ring.napi);
2323
}
2424

2525
static void hbg_irq_handle_rx(struct hbg_priv *priv,
26-
struct hbg_irq_info *irq_info)
26+
const struct hbg_irq_info *irq_info)
2727
{
2828
napi_schedule(&priv->rx_ring.napi);
2929
}
3030

3131
static void hbg_irq_handle_rx_buf_val(struct hbg_priv *priv,
32-
struct hbg_irq_info *irq_info)
32+
const struct hbg_irq_info *irq_info)
3333
{
3434
priv->stats.rx_fifo_less_empty_thrsld_cnt++;
3535
}
3636

3737
#define HBG_IRQ_I(name, handle) \
38-
{#name, HBG_INT_MSK_##name##_B, false, false, false, 0, handle}
38+
{#name, HBG_INT_MSK_##name##_B, false, false, false, handle}
3939
#define HBG_ERR_IRQ_I(name, need_print, ndde_reset) \
4040
{#name, HBG_INT_MSK_##name##_B, true, need_print, \
41-
ndde_reset, 0, hbg_irq_handle_err}
41+
ndde_reset, hbg_irq_handle_err}
4242

43-
static struct hbg_irq_info hbg_irqs[] = {
43+
static const struct hbg_irq_info hbg_irqs[] = {
4444
HBG_IRQ_I(RX, hbg_irq_handle_rx),
4545
HBG_IRQ_I(TX, hbg_irq_handle_tx),
4646
HBG_ERR_IRQ_I(TX_PKT_CPL, true, true),
@@ -64,7 +64,7 @@ static struct hbg_irq_info hbg_irqs[] = {
6464

6565
static irqreturn_t hbg_irq_handle(int irq_num, void *p)
6666
{
67-
struct hbg_irq_info *info;
67+
const struct hbg_irq_info *info;
6868
struct hbg_priv *priv = p;
6969
u32 status;
7070
u32 i;
@@ -79,7 +79,7 @@ static irqreturn_t hbg_irq_handle(int irq_num, void *p)
7979
hbg_hw_irq_enable(priv, info->mask, false);
8080
hbg_hw_irq_clear(priv, info->mask);
8181

82-
info->count++;
82+
priv->vectors.stats_array[i]++;
8383
if (info->irq_handle)
8484
info->irq_handle(priv, info);
8585

@@ -132,6 +132,12 @@ int hbg_irq_init(struct hbg_priv *priv)
132132
irq_names_map[i]);
133133
}
134134

135+
vectors->stats_array = devm_kcalloc(&priv->pdev->dev,
136+
ARRAY_SIZE(hbg_irqs),
137+
sizeof(u64), GFP_KERNEL);
138+
if (!vectors->stats_array)
139+
return -ENOMEM;
140+
135141
vectors->info_array = hbg_irqs;
136142
vectors->info_array_len = ARRAY_SIZE(hbg_irqs);
137143
return 0;

drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
static void hbg_all_irq_enable(struct hbg_priv *priv, bool enabled)
2323
{
24-
struct hbg_irq_info *info;
24+
const struct hbg_irq_info *info;
2525
u32 i;
2626

2727
for (i = 0; i < priv->vectors.info_array_len; i++) {
@@ -203,12 +203,12 @@ static int hbg_net_change_mtu(struct net_device *netdev, int new_mtu)
203203
if (netif_running(netdev))
204204
return -EBUSY;
205205

206-
hbg_hw_set_mtu(priv, new_mtu);
207-
WRITE_ONCE(netdev->mtu, new_mtu);
208-
209206
dev_dbg(&priv->pdev->dev,
210207
"change mtu from %u to %u\n", netdev->mtu, new_mtu);
211208

209+
hbg_hw_set_mtu(priv, new_mtu);
210+
WRITE_ONCE(netdev->mtu, new_mtu);
211+
212212
return 0;
213213
}
214214

drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright (c) 2024 Hisilicon Limited.
33

44
#include <linux/phy.h>
5+
#include <linux/rtnetlink.h>
56
#include "hbg_common.h"
67
#include "hbg_hw.h"
78
#include "hbg_mdio.h"
@@ -133,12 +134,17 @@ void hbg_fix_np_link_fail(struct hbg_priv *priv)
133134
{
134135
struct device *dev = &priv->pdev->dev;
135136

137+
rtnl_lock();
138+
136139
if (priv->stats.np_link_fail_cnt >= HBG_NP_LINK_FAIL_RETRY_TIMES) {
137140
dev_err(dev, "failed to fix the MAC link status\n");
138141
priv->stats.np_link_fail_cnt = 0;
139-
return;
142+
goto unlock;
140143
}
141144

145+
if (!priv->mac.phydev->link)
146+
goto unlock;
147+
142148
priv->stats.np_link_fail_cnt++;
143149
dev_err(dev, "failed to link between MAC and PHY, try to fix...\n");
144150

@@ -147,6 +153,9 @@ void hbg_fix_np_link_fail(struct hbg_priv *priv)
147153
*/
148154
hbg_phy_stop(priv);
149155
hbg_phy_start(priv);
156+
157+
unlock:
158+
rtnl_unlock();
150159
}
151160

152161
static void hbg_phy_adjust_link(struct net_device *netdev)

drivers/net/ethernet/hisilicon/hibmcge/hbg_reg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#define HBG_REG_TRANSMIT_CTRL_AN_EN_B BIT(5)
6969
#define HBG_REG_REC_FILT_CTRL_ADDR (HBG_REG_SGMII_BASE + 0x0064)
7070
#define HBG_REG_REC_FILT_CTRL_UC_MATCH_EN_B BIT(0)
71+
#define HBG_REG_REC_FILT_CTRL_PAUSE_FRM_PASS_B BIT(4)
7172
#define HBG_REG_RX_OCTETS_TOTAL_OK_ADDR (HBG_REG_SGMII_BASE + 0x0080)
7273
#define HBG_REG_RX_OCTETS_BAD_ADDR (HBG_REG_SGMII_BASE + 0x0084)
7374
#define HBG_REG_RX_UC_PKTS_ADDR (HBG_REG_SGMII_BASE + 0x0088)
@@ -134,6 +135,8 @@
134135
#define HBG_REG_STATION_ADDR_HIGH_4_ADDR (HBG_REG_SGMII_BASE + 0x0224)
135136
#define HBG_REG_STATION_ADDR_LOW_5_ADDR (HBG_REG_SGMII_BASE + 0x0228)
136137
#define HBG_REG_STATION_ADDR_HIGH_5_ADDR (HBG_REG_SGMII_BASE + 0x022C)
138+
#define HBG_REG_STATION_ADDR_LOW_MSK_0 (HBG_REG_SGMII_BASE + 0x0230)
139+
#define HBG_REG_STATION_ADDR_LOW_MSK_1 (HBG_REG_SGMII_BASE + 0x0238)
137140

138141
/* PCU */
139142
#define HBG_REG_TX_FIFO_THRSLD_ADDR (HBG_REG_SGMII_BASE + 0x0420)

0 commit comments

Comments
 (0)