Skip to content

Commit 9e70eb4

Browse files
danish-tikuba-moo
authored andcommitted
net: ti: icssg-prueth: Make pa_stats optional
pa_stats is optional in dt bindings, make it optional in driver as well. Currently if pa_stats syscon regmap is not found driver returns -ENODEV. Fix this by not returning an error in case pa_stats is not found and continue generating ethtool stats without pa_stats. Fixes: 550ee90 ("net: ti: icssg-prueth: Add support for PA Stats") Signed-off-by: MD Danish Anwar <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5aa3b55 commit 9e70eb4

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

drivers/net/ethernet/ti/icssg/icssg_ethtool.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,21 @@ static int emac_nway_reset(struct net_device *ndev)
6868

6969
static int emac_get_sset_count(struct net_device *ndev, int stringset)
7070
{
71+
struct prueth_emac *emac = netdev_priv(ndev);
7172
switch (stringset) {
7273
case ETH_SS_STATS:
73-
return ICSSG_NUM_ETHTOOL_STATS;
74+
if (emac->prueth->pa_stats)
75+
return ICSSG_NUM_ETHTOOL_STATS;
76+
else
77+
return ICSSG_NUM_ETHTOOL_STATS - ICSSG_NUM_PA_STATS;
7478
default:
7579
return -EOPNOTSUPP;
7680
}
7781
}
7882

7983
static void emac_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
8084
{
85+
struct prueth_emac *emac = netdev_priv(ndev);
8186
u8 *p = data;
8287
int i;
8388

@@ -86,8 +91,9 @@ static void emac_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
8691
for (i = 0; i < ARRAY_SIZE(icssg_all_miig_stats); i++)
8792
if (!icssg_all_miig_stats[i].standard_stats)
8893
ethtool_puts(&p, icssg_all_miig_stats[i].name);
89-
for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++)
90-
ethtool_puts(&p, icssg_all_pa_stats[i].name);
94+
if (emac->prueth->pa_stats)
95+
for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++)
96+
ethtool_puts(&p, icssg_all_pa_stats[i].name);
9197
break;
9298
default:
9399
break;
@@ -106,8 +112,9 @@ static void emac_get_ethtool_stats(struct net_device *ndev,
106112
if (!icssg_all_miig_stats[i].standard_stats)
107113
*(data++) = emac->stats[i];
108114

109-
for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++)
110-
*(data++) = emac->pa_stats[i];
115+
if (emac->prueth->pa_stats)
116+
for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++)
117+
*(data++) = emac->pa_stats[i];
111118
}
112119

113120
static int emac_get_ts_info(struct net_device *ndev,

drivers/net/ethernet/ti/icssg/icssg_prueth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ static int prueth_probe(struct platform_device *pdev)
11851185
prueth->pa_stats = syscon_regmap_lookup_by_phandle(np, "ti,pa-stats");
11861186
if (IS_ERR(prueth->pa_stats)) {
11871187
dev_err(dev, "couldn't get ti,pa-stats syscon regmap\n");
1188-
return -ENODEV;
1188+
prueth->pa_stats = NULL;
11891189
}
11901190

11911191
if (eth0_node) {

drivers/net/ethernet/ti/icssg/icssg_stats.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ void emac_update_hardware_stats(struct prueth_emac *emac)
4242
emac->stats[i] -= tx_pkt_cnt * 8;
4343
}
4444

45-
for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) {
46-
reg = ICSSG_FW_STATS_BASE + icssg_all_pa_stats[i].offset *
47-
PRUETH_NUM_MACS + slice * sizeof(u32);
48-
regmap_read(prueth->pa_stats, reg, &val);
49-
emac->pa_stats[i] += val;
45+
if (prueth->pa_stats) {
46+
for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) {
47+
reg = ICSSG_FW_STATS_BASE +
48+
icssg_all_pa_stats[i].offset *
49+
PRUETH_NUM_MACS + slice * sizeof(u32);
50+
regmap_read(prueth->pa_stats, reg, &val);
51+
emac->pa_stats[i] += val;
52+
}
5053
}
5154
}
5255

@@ -70,9 +73,11 @@ int emac_get_stat_by_name(struct prueth_emac *emac, char *stat_name)
7073
return emac->stats[icssg_all_miig_stats[i].offset / sizeof(u32)];
7174
}
7275

73-
for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) {
74-
if (!strcmp(icssg_all_pa_stats[i].name, stat_name))
75-
return emac->pa_stats[icssg_all_pa_stats[i].offset / sizeof(u32)];
76+
if (emac->prueth->pa_stats) {
77+
for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) {
78+
if (!strcmp(icssg_all_pa_stats[i].name, stat_name))
79+
return emac->pa_stats[icssg_all_pa_stats[i].offset / sizeof(u32)];
80+
}
7681
}
7782

7883
netdev_err(emac->ndev, "Invalid stats %s\n", stat_name);

0 commit comments

Comments
 (0)