Re: [PATCH net-next v3 13/14] net: ethernet: qualcomm: Add PPE debugfs support for PPE counters

From: Jie Luo
Date: Tue Feb 18 2025 - 06:22:49 EST




On 2/14/2025 10:02 PM, Andrew Lunn wrote:
+/* The number of packets dropped because of no buffer available, no PPE
+ * buffer assigned to these packets.
+ */
+static void ppe_port_rx_drop_counter_get(struct ppe_device *ppe_dev,
+ struct seq_file *seq)
+{
+ u32 reg, drop_cnt = 0;
+ int ret, i, tag = 0;
+
+ PRINT_COUNTER_PREFIX("PRX_DROP_CNT", "SILENT_DROP:");
+ for (i = 0; i < PPE_DROP_CNT_TBL_ENTRIES; i++) {
+ reg = PPE_DROP_CNT_TBL_ADDR + i * PPE_DROP_CNT_TBL_INC;
+ ret = ppe_pkt_cnt_get(ppe_dev, reg, PPE_PKT_CNT_SIZE_1WORD,
+ &drop_cnt, NULL);
+ if (ret) {
+ seq_printf(seq, "ERROR %d\n", ret);
+ return;
+ }

This is an error getting the value from the hardware? You should not
put that into the debugfs itself, you want the read() call to return
it.


Yes, this error code is returned by regmap read functions in
ppe_pkt_cnt_get() when the hardware counter read fails. I will
remove it from debugfs file and instead log the error to the
console (dev_info).

and return it to user space via the read() call. These functions
normally return the number of bytes put into the buffer. But you can
also return a negative error code which gets passed back to user space
instead.

Andrew

OK, I will return the negative error code returned by the read() to the
user space, thanks.