Skip to content

Commit 4ad3df7

Browse files
Jijie Shaokuba-moo
authored andcommitted
net: hibmcge: fix the share of irq statistics among different network ports issue
hbg_irqs is a global array which contains irq statistics. However, the irq statistics of different network ports point to the same global array. As a result, the statistics are incorrect. This patch allocates a statistics array for each network port to prevent the statistics of different network ports from affecting each other. irq statistics are removed from hbg_irq_info. Therefore, all data in hbg_irq_info remains unchanged. Therefore, the input parameter of some functions is changed to const. Fixes: 4d08903 ("net: hibmcge: Add interrupt supported in this module") Signed-off-by: Jijie Shao <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9afaaa5 commit 4ad3df7

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
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: 2 additions & 2 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;

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_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: 1 addition & 1 deletion
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++) {

0 commit comments

Comments
 (0)