+#define PRINT_COUNTER_PREFIX(desc, cnt_type) \
+ seq_printf(seq, "%-16s %16s", desc, cnt_type)
+
+#define PRINT_CPU_CODE_COUNTER(cnt, code) \
+ seq_printf(seq, "%10u(cpucode:%d)", cnt, code)
+
+#define PRINT_DROP_CODE_COUNTER(cnt, port, code) \
+ seq_printf(seq, "%10u(port=%d),dropcode:%d", cnt, port, code)
+
+#define PRINT_SINGLE_COUNTER(tag, cnt, str, index) \
+do { \
+ if (!((tag) % 4)) \
+ seq_printf(seq, "\n%-16s %16s", "", ""); \
+ seq_printf(seq, "%10u(%s=%04d)", cnt, str, index); \
+} while (0)
+
+#define PRINT_TWO_COUNTERS(tag, cnt0, cnt1, str, index) \
+do { \
+ if (!((tag) % 4)) \
+ seq_printf(seq, "\n%-16s %16s", "", ""); \
+ seq_printf(seq, "%10u/%u(%s=%04d)", cnt0, cnt1, str, index); \
+} while (0)
I don't think these make the code any more readable. Just inline it.
+/* 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.
+/* Display the various packet counters of PPE. */
+static int ppe_packet_counter_show(struct seq_file *seq, void *v)
+{
+ struct ppe_device *ppe_dev = seq->private;
+
+ ppe_port_rx_drop_counter_get(ppe_dev, seq);
+ ppe_port_rx_bm_drop_counter_get(ppe_dev, seq);
+ ppe_port_rx_bm_port_counter_get(ppe_dev, seq);
+ ppe_parse_pkt_counter_get(ppe_dev, seq);
+ ppe_port_rx_counter_get(ppe_dev, seq);
+ ppe_vp_rx_counter_get(ppe_dev, seq);
+ ppe_pre_l2_counter_get(ppe_dev, seq);
+ ppe_vlan_counter_get(ppe_dev, seq);
+ ppe_cpu_code_counter_get(ppe_dev, seq);
+ ppe_eg_vsi_counter_get(ppe_dev, seq);
+ ppe_vp_tx_counter_get(ppe_dev, seq);
+ ppe_port_tx_counter_get(ppe_dev, seq);
+ ppe_queue_tx_counter_get(ppe_dev, seq);
It would be more normal to have one debugfs file per group of
counters.
Andrew