Thread (11 messages) 11 messages, 4 authors, 2025-03-03

Re: [PATCH v7 net-next 4/5] net: ena: PHC stats through sysfs

From: Jakub Kicinski <kuba@kernel.org>
Date: 2025-02-21 02:08:14

On Tue, 18 Feb 2025 20:39:47 +0200 David Arinzon wrote:
+static ssize_t ena_phc_stats_show(struct device *dev,
+				  struct device_attribute *attr,
+				  char *buf)
+{
+	struct ena_adapter *adapter = dev_get_drvdata(dev);
+	int i, rc, chars_written = 0;
+
+	if (!ena_phc_is_active(adapter))
+		return 0;
+
+	for (i = 0; i < ena_stats_array_ena_com_phc_size; i++) {
+		const struct ena_stats *ena_stats;
+		u64 *ptr;
+
+		ena_stats = &ena_stats_ena_com_phc_strings[i];
+		ptr = (u64 *)&adapter->ena_dev->phc.stats +
+		      ena_stats->stat_offset;
+		rc = snprintf(buf,
+			      ETH_GSTRING_LEN + sizeof(u64),
+			      "%s: %llu\n",
+			      ena_stats->name,
+			      *ptr);
+
+		buf += rc;
+		chars_written += rc;
+	}
+
+	return chars_written;
+}
+
+static DEVICE_ATTR(phc_stats, S_IRUGO, ena_phc_stats_show, NULL);
In sysfs I'm afraid the rule is one value per file.
So the stats have to have individual files.
-- 
pw-bot: cr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help