RE: [PATCH v7 net-next 4/5] net: ena: PHC stats through sysfs
From: "Arinzon, David" <darinzon@amazon.com>
Date: 2025-02-25 17:53:29
quoted
The patch allows retrieving PHC statistics through sysfs. In case the feature is not enabled (through `phc_enable` sysfs entry), no output will be written. Signed-off-by: David Arinzon <darinzon@amazon.com>...quoted
diff --git a/drivers/net/ethernet/amazon/ena/ena_sysfs.cb/drivers/net/ethernet/amazon/ena/ena_sysfs.c index d0ded92d..10993594 100644--- a/drivers/net/ethernet/amazon/ena/ena_sysfs.c +++ b/drivers/net/ethernet/amazon/ena/ena_sysfs.c@@ -65,6 +65,52 @@ static ssize_t ena_phc_enable_get(struct device*dev, static DEVICE_ATTR(phc_enable, S_IRUGO | S_IWUSR,ena_phc_enable_get,quoted
ena_phc_enable_set); +#define ENA_STAT_ENA_COM_PHC_ENTRY(stat) { \ + .name = #stat, \ + .stat_offset = offsetof(struct ena_com_stats_phc, stat) / +sizeof(u64) \ } + +const struct ena_stats ena_stats_ena_com_phc_strings[] = { + ENA_STAT_ENA_COM_PHC_ENTRY(phc_cnt), + ENA_STAT_ENA_COM_PHC_ENTRY(phc_exp), + ENA_STAT_ENA_COM_PHC_ENTRY(phc_skp), + ENA_STAT_ENA_COM_PHC_ENTRY(phc_err), +};Hi David, Some very minor nits from my side: Is seems that ena_stats_ena_com_phc_strings is only used in this file and thus should be static.
Thanks Simon, I also saw it in the compilation warnings in patchwork. This code will be modified/removed in v8. Thanks, David
quoted
+ +u16 ena_stats_array_ena_com_phc_size = +ARRAY_SIZE(ena_stats_ena_com_phc_strings);Likewise for ena_stats_array_ena_com_phc_size. ...