Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 550ee90ac61c ("net: ti: icssg-prueth: Add support for PA Stats")
Signed-off-by: MD Danish Anwar <danishanwar@ti.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20240906093649.870883-1-danishanwar@ti.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

MD Danish Anwar and committed by
Jakub Kicinski
9e70eb4a 5aa3b55b

+26 -14
+12 -5
drivers/net/ethernet/ti/icssg/icssg_ethtool.c
··· 68 68 69 69 static int emac_get_sset_count(struct net_device *ndev, int stringset) 70 70 { 71 + struct prueth_emac *emac = netdev_priv(ndev); 71 72 switch (stringset) { 72 73 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; 74 78 default: 75 79 return -EOPNOTSUPP; 76 80 } ··· 82 78 83 79 static void emac_get_strings(struct net_device *ndev, u32 stringset, u8 *data) 84 80 { 81 + struct prueth_emac *emac = netdev_priv(ndev); 85 82 u8 *p = data; 86 83 int i; 87 84 ··· 91 86 for (i = 0; i < ARRAY_SIZE(icssg_all_miig_stats); i++) 92 87 if (!icssg_all_miig_stats[i].standard_stats) 93 88 ethtool_puts(&p, icssg_all_miig_stats[i].name); 94 - for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) 95 - ethtool_puts(&p, icssg_all_pa_stats[i].name); 89 + if (emac->prueth->pa_stats) 90 + for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) 91 + ethtool_puts(&p, icssg_all_pa_stats[i].name); 96 92 break; 97 93 default: 98 94 break; ··· 112 106 if (!icssg_all_miig_stats[i].standard_stats) 113 107 *(data++) = emac->stats[i]; 114 108 115 - for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) 116 - *(data++) = emac->pa_stats[i]; 109 + if (emac->prueth->pa_stats) 110 + for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) 111 + *(data++) = emac->pa_stats[i]; 117 112 } 118 113 119 114 static int emac_get_ts_info(struct net_device *ndev,
+1 -1
drivers/net/ethernet/ti/icssg/icssg_prueth.c
··· 1185 1185 prueth->pa_stats = syscon_regmap_lookup_by_phandle(np, "ti,pa-stats"); 1186 1186 if (IS_ERR(prueth->pa_stats)) { 1187 1187 dev_err(dev, "couldn't get ti,pa-stats syscon regmap\n"); 1188 - return -ENODEV; 1188 + prueth->pa_stats = NULL; 1189 1189 } 1190 1190 1191 1191 if (eth0_node) {
+13 -8
drivers/net/ethernet/ti/icssg/icssg_stats.c
··· 42 42 emac->stats[i] -= tx_pkt_cnt * 8; 43 43 } 44 44 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 + } 50 53 } 51 54 } 52 55 ··· 73 70 return emac->stats[icssg_all_miig_stats[i].offset / sizeof(u32)]; 74 71 } 75 72 76 - for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) { 77 - if (!strcmp(icssg_all_pa_stats[i].name, stat_name)) 78 - return emac->pa_stats[icssg_all_pa_stats[i].offset / sizeof(u32)]; 73 + if (emac->prueth->pa_stats) { 74 + for (i = 0; i < ARRAY_SIZE(icssg_all_pa_stats); i++) { 75 + if (!strcmp(icssg_all_pa_stats[i].name, stat_name)) 76 + return emac->pa_stats[icssg_all_pa_stats[i].offset / sizeof(u32)]; 77 + } 79 78 } 80 79 81 80 netdev_err(emac->ndev, "Invalid stats %s\n", stat_name);