/* * Description: PP Infrastructure Driver Debug FS Interface * * SPDX-License-Identifier: GPL-2.0-only * Copyright (C) 2018-2020 Intel Corporation */ #define pr_fmt(fmt) "[PP_PARSER_DBG]: %s:%d: " fmt, __func__, __LINE__ #include #include #include #include #include #include #include #include "pp_debugfs_common.h" #include "parser.h" #include "pp_fv.h" #include "classifier.h" #include "parser_internal.h" /* Infra Debug FS directories */ static struct dentry *dbgfs; static struct dentry *protos_dir; static struct dentry *tables_dir; static struct dentry *protos_dbgfs[PRSR_PROTOS_NUM]; static struct buf_fld_info prsr_stw_flds[STW_PRSR_FLDS_NUM]; const char *const l2_cmp_op_str[L2_CMP_OP_NUM] = { "EQ", "LT", }; const char *const np_logic_str[NP_LOGICS_NUM] = { "TUNNEL", "IPV4", "IPV6", "IP_SEL", "IPV4_2", "IPV6_2", "UDP", "END", }; const char *const etype_str[ETYPE_NUM] = { "NONE", "IPV4", "IPV6", "OTHER_L3", "UDP", "TCP", "RSRV_L4", "OTHER_L4", "L2", "PAYLOAD", "IPV6_FR", "IPV6_EXT", }; const char *const skip_logic_str[SKIP_LOGICS_NUM] = { "ALU", "LOOKUP", "IM1", }; /** * @brief Print a pit info into a sequential file * @param f the file * @param pit the info * @param align alignment */ static inline void __pit_seq_printf(struct seq_file *f, const struct pit_info *pit, u8 align) { switch (pit->cnt) { case 0: seq_printf(f, " | %-*s", align, "none"); break; case 1: seq_printf(f, " | %-*u", align, pit->base); break; default: align -= 1; align /= 2; seq_printf(f, " | %0*u-%0*u", align, pit->base, align, pit->base + pit->cnt - 1); break; } } const char *const err_flag_str[PRSR_NUM_ERR_FLAGS] = { "Abort on Payload Timeout", "Abort on L3 Processing Timeout", "Abort on IP Len Error", "Abort on IMEM protocol Overflow", "Abort on L3 hdr len longer than cfg", "Abort on Unknown Last Ethertype", NULL, NULL, NULL, "Error on Payload Timeout", "Error on L3 Processing Timeout", "Error on IP Len Error", "Error on IMEM protocol Overflow", "Error on L3 hdr len longer than cfg", "Error on L3 hdr len exceeds min-max", "Error on Unknown Last Ethertype", "Error on RPB Zero Len", "Error on RPB Error", "Error on RPB Discard", "Drop on Payload Timeout", "Drop on L3 Processing Timeout", "Drop on IP Len Error", "Drop on IMEM protocol Overflow", "Drop on L3 hdr len longer than cfg", "Drop on L3 hdr len exceeds min-max", "Drop on Unknown Last Ethertype", "Drop on RPB Zero Len", "Drop on RPB Error", "Drop on RPB Discard", NULL, NULL, "FW Fallback on Error", }; /** * @brief Dump status word */ void __prsr_stw_show(struct seq_file *f) { struct buf_fld_info *fld; struct prsr_hw_stw hw_stw; u32 fld_val[STW_PRSR_FLDS_NUM]; u32 i; if (unlikely(prsr_last_stw_get(&hw_stw))) return; seq_puts(f, " Parser Status Word:\n"); seq_puts(f, " =======================\n"); for (i = 0; i < STW_PRSR_FLDS_NUM; i++) { fld = &prsr_stw_flds[i]; fld_val[i] = buf_fld_get(fld, hw_stw.word); if (i == STW_PRSR_FLD_DROP_PKT) seq_printf(f, " %-35s: %s (%u)\n", fld->desc, STW_DROP_PKT_STR(fld_val[i]), fld_val[i]); else if (fld->msb == fld->lsb) seq_printf(f, " %-35s: %s\n", fld->desc, BOOL2STR(fld_val[i])); else seq_printf(f, " %-35s: %u [%#x]\n", fld->desc, fld_val[i], fld_val[i]); } } PP_DEFINE_DEBUGFS(stw_show, __prsr_stw_show, NULL); /** * @brief Reset stw stickiness */ void __prsr_stw_sticky_reset(struct seq_file *f) { prsr_stw_sticky_reset(); } PP_DEFINE_DEBUGFS(stw_sticky_reset, __prsr_stw_sticky_reset, NULL); /** * @brief Dump stats */ void __prsr_stats_show(struct seq_file *f) { struct prsr_stats st; s32 ret; ret = prsr_stats_get(&st); if (unlikely(ret)) return; seq_puts(f, "\n"); seq_puts(f, " +----------------------------------------+\n"); seq_puts(f, " | Parser Stats |\n"); seq_puts(f, " +----------------------------------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "RX Packets from RPB", st.rx_pkts); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "Valid RX Packets from RPB", st.rx_valid_pkts); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "TX Packets", st.tx_pkts); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "TX to Classifier", st.tx_pkts_to_cls); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "TX to UC", st.tx_pkts_to_uc); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "Discarded Prior to Parser", st.rpb_discard); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "Discarded by RPB", st.pprs_discard); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "Discarded by UC", st.uc_discard); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "RPB Error", st.rpb_err); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "Zero Length Packets", st.zero_len); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "No Last ETH Type", st.last_eth_err); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "L3 Hdr Exceeds Min-Max", st.proto_len_err); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "L3 Hdr Longer Than Cfg", st.hdr_len_err); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "Protocol Overflow", st.proto_overflow); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "IP Length Error", st.ip_len_err); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "Payload Error", st.payload_err); seq_puts(f, " +---------------------------+------------+\n"); seq_printf(f, " | %-25s | %10u |\n", "Aborted Packets", st.aborted_pkts); seq_puts(f, " +----------------------------------------+\n"); seq_puts(f, "\n"); seq_puts(f, " Legend:\n"); seq_puts(f, " -------\n"); seq_puts(f, " rpb discard - packets marked by the rpb with discard flag\n"); seq_puts(f, " rpb error - packets marked by the rpb with error flag\n"); seq_puts(f, " no last eth - packets that no last ethernet type was found\n"); seq_puts(f, " protocol length error - packets with layer 3 too big or too small than max or min\n"); seq_puts(f, " protocol header error - packets with layer 3 header too big or too small than imem configuration\n"); seq_puts(f, " protocol overflow - packets with too much imem protocols found\n"); seq_puts(f, " ip len error - packets with mismatch between the IP header packets length to rpb packet length\n"); seq_puts(f, " payload error - packets with no payload\n"); seq_puts(f, "\n"); } PP_DEFINE_DEBUGFS(stats_show, __prsr_stats_show, NULL); enum global_opts { global_opt_help, global_opt_dflt_proto, global_opt_fv_swap, global_opt_fv_block_swap, global_opt_fv_mask_en, global_opt_fv_mask_swap, global_opt_max_hdr_len, global_opt_max_imem_hdr_len, global_opt_prefetch_hdr_len, global_opt_ipv6_nexthdr, global_opt_err_flag, global_opt_err_flags, global_opt_rst_err_flags, }; static const match_table_t global_tokens = { { global_opt_help, "help" }, { global_opt_dflt_proto, "dflt=%u" }, { global_opt_fv_swap, "fv_swap" }, { global_opt_fv_block_swap, "fv_bswap" }, { global_opt_fv_mask_en, "fv_mask" }, { global_opt_fv_mask_swap, "fv_mswap" }, { global_opt_max_hdr_len, "max_hdr_len=%u" }, { global_opt_max_imem_hdr_len, "max_imem=%u" }, { global_opt_prefetch_hdr_len, "pre_len=%u" }, { global_opt_ipv6_nexthdr, "nexthdr=%u" }, { global_opt_err_flag, "err_flag=%u" }, { global_opt_err_flags, "err_flags=%u" }, { global_opt_rst_err_flags, "rst_err_flags" }, }; /** * @brief Print parser global configuration help, how to change global * configuration settings */ static void __prsr_global_cfg_help(void) { pr_info("\n"); pr_info(" Usage: echo