/*
 ***************************************************************************
 * Copyright (c) 2021, The Linux Foundation. All rights reserved.
 *
 * Permission to use, copy, modify, and/or distribute this software for
 * any purpose with or without fee is hereby granted, provided that the
 * above copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 ***************************************************************************
 */

#include "nss_stats.h"
#include "nss_core.h"
#include "nss_ppe.h"
#include "nss_strings.h"
#include "nss_ppe_strings.h"

/*
 * nss_ppe_stats_str_conn
 *	PPE statistics strings for nss flow stats
 */
struct nss_stats_info nss_ppe_stats_str_conn[NSS_PPE_STATS_CONN_MAX] = {
	{"v4 routed flows",			NSS_STATS_TYPE_SPECIAL},
	{"v4 bridge flows",			NSS_STATS_TYPE_SPECIAL},
	{"v4 conn create req",			NSS_STATS_TYPE_SPECIAL},
	{"v4 conn create fail",			NSS_STATS_TYPE_SPECIAL},
	{"v4 conn destroy req",			NSS_STATS_TYPE_SPECIAL},
	{"v4 conn destroy fail",		NSS_STATS_TYPE_SPECIAL},
	{"v4 conn MC create req",		NSS_STATS_TYPE_SPECIAL},
	{"v4 conn MC create fail",		NSS_STATS_TYPE_SPECIAL},
	{"v4 conn MC update req",		NSS_STATS_TYPE_SPECIAL},
	{"v4 conn MC update fail",		NSS_STATS_TYPE_SPECIAL},
	{"v4 conn MC delete req",		NSS_STATS_TYPE_SPECIAL},
	{"v4 conn MC delete fail",		NSS_STATS_TYPE_SPECIAL},
	{"v4 conn unknown if",			NSS_STATS_TYPE_SPECIAL},
	{"v6 routed flows",			NSS_STATS_TYPE_SPECIAL},
	{"v6 bridge flows",			NSS_STATS_TYPE_SPECIAL},
	{"v6 conn create req",			NSS_STATS_TYPE_SPECIAL},
	{"v6 conn create fail",			NSS_STATS_TYPE_SPECIAL},
	{"v6 conn destroy req",			NSS_STATS_TYPE_SPECIAL},
	{"v6 conn destroy fail",		NSS_STATS_TYPE_SPECIAL},
	{"v6 conn MC create req",		NSS_STATS_TYPE_SPECIAL},
	{"v6 conn MC create fail",		NSS_STATS_TYPE_SPECIAL},
	{"v6 conn MC update req",		NSS_STATS_TYPE_SPECIAL},
	{"v6 conn MC update fail",		NSS_STATS_TYPE_SPECIAL},
	{"v6 conn MC delete req",		NSS_STATS_TYPE_SPECIAL},
	{"v6 conn MC delete fail",		NSS_STATS_TYPE_SPECIAL},
	{"v6 conn unknown if",			NSS_STATS_TYPE_SPECIAL},
	{"conn fail - vp full",			NSS_STATS_TYPE_SPECIAL},
	{"conn fail - nexthop full",		NSS_STATS_TYPE_SPECIAL},
	{"conn fail - flow full",		NSS_STATS_TYPE_SPECIAL},
	{"conn fail - host full",		NSS_STATS_TYPE_SPECIAL},
	{"conn fail - pub-ip full",		NSS_STATS_TYPE_SPECIAL},
	{"conn fail - port not setup",		NSS_STATS_TYPE_SPECIAL},
	{"conn fail - rw fifo full",		NSS_STATS_TYPE_SPECIAL},
	{"conn fail - flow cmd failure",	NSS_STATS_TYPE_SPECIAL},
	{"conn fail - unknown proto",		NSS_STATS_TYPE_SPECIAL},
	{"conn fail - ppe not responding",	NSS_STATS_TYPE_SPECIAL},
	{"conn fail - CE opaque invalid",	NSS_STATS_TYPE_SPECIAL},
	{"conn fail - fqg full",		NSS_STATS_TYPE_SPECIAL}
};

/*
 * nss_ppe_stats_str_conn_strings_read()
 *	Read ppe NSS flow statistics names
 */
static ssize_t nss_ppe_stats_str_conn_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
{
	return nss_strings_print(ubuf, sz, ppos, nss_ppe_stats_str_conn, NSS_PPE_STATS_CONN_MAX);
}

/*
 * nss_ppe_stats_str_conn_strings_ops
 */
NSS_STRINGS_DECLARE_FILE_OPERATIONS(ppe_stats_str_conn);

/*
 * nss_ppe_stats_str_l3
 *	PPE statistics strings for nss debug stats
 */
struct nss_stats_info nss_ppe_stats_str_l3[NSS_PPE_STATS_L3_MAX] = {
	{"L3 dbg reg 0",	NSS_STATS_TYPE_SPECIAL},
	{"L3 dbg reg 1",	NSS_STATS_TYPE_SPECIAL},
	{"L3 dbg reg 2",	NSS_STATS_TYPE_SPECIAL},
	{"L3 dbg reg 3",	NSS_STATS_TYPE_SPECIAL},
	{"L3 dbg reg 4",	NSS_STATS_TYPE_SPECIAL},
	{"L3 dbg reg port",	NSS_STATS_TYPE_SPECIAL}
};

/*
 * nss_ppe_stats_str_l3_strings_read()
 *	Read ppe NSS debug statistics names
 */
static ssize_t nss_ppe_stats_str_l3_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
{
	return nss_strings_print(ubuf, sz, ppos, nss_ppe_stats_str_l3, NSS_PPE_STATS_L3_MAX);
}

/*
 * nss_ppe_stats_str_l3_strings_ops
 */
NSS_STRINGS_DECLARE_FILE_OPERATIONS(ppe_stats_str_l3);

/*
 * nss_ppe_stats_str_code
 *	PPE statistics strings for nss debug stats
 */
struct nss_stats_info nss_ppe_stats_str_code[NSS_PPE_STATS_CODE_MAX] = {
	{"CPU_CODE",	NSS_STATS_TYPE_SPECIAL},
	{"DROP_CODE",	NSS_STATS_TYPE_SPECIAL}
};

/*
 * nss_ppe_stats_str_code_strings_read()
 *	Read ppe NSS debug statistics names
 */
static ssize_t nss_ppe_stats_str_code_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
{
	return nss_strings_print(ubuf, sz, ppos, nss_ppe_stats_str_code, NSS_PPE_STATS_CODE_MAX);
}

/*
 * nss_ppe_stats_str_code_strings_ops
 */
NSS_STRINGS_DECLARE_FILE_OPERATIONS(ppe_stats_str_code);

/*
 * nss_ppe_stats_str_dc
 *	PPE statistics strings for drop code
 */
struct nss_stats_info nss_ppe_stats_str_dc[NSS_PPE_STATS_DROP_CODE_MAX] = {
	{"DROP_CODE_NONE",					NSS_STATS_TYPE_SPECIAL},
	{"DROP_CODE_EXP_UNKNOWN_L2_PORT",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_PPPOE_WRONG_VER_TYPE",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_PPPOE_WRONG_CODE",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_WRONG_VER",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_SMALL_IHL",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_WITH_OPTION",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_HDR_INCOMPLETE",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_BAD_TOTAL_LEN",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_DATA_INCOMPLETE",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_FRAG",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_PING_OF_DEATH",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_SNALL_TTL",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_UNK_IP_PROT",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_CHECKSUM_ERR",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_INV_SIP",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_INV_DIP",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_LAND_ATTACK",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_AH_HDR_INCOMPLETE",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_AH_HDR_CROSS_BORDER",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_WRONG_VER",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_HDR_INCOMPLETE",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_BAD_PAYLOAD_LEN",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_DATA_INCOMPLETE",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_WITH_EXT_HDR",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_SMALL_HOP_LIMIT",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_INV_SIP",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_INV_DIP",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_LAND_ATTACK",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_FRAG",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_PING_OF_DEATH",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_WITH_MORE_EXT_HDR",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_UNK_LAST_NEXT_HDR",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_MOBILITY_HDR_CROSS_BORDER",	NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_AH_HDR_INCOMPLETE",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_AH_HDR_CROSS_BORDER",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_ESP_HDR_CROSS_BORDER",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_INCOMPLETE",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_CROSS_BORDER",	NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_HDR_INCOMPLETE",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_HDR_CROSS_BORDER",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_SMAE_SP_DP",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_SMALL_DATA_OFFSET",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_FLAGS_0",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_FLAGS_1",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_FLAGS_2",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_FLAGS_3",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_FLAGS_4",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_FLAGS_5",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_FLAGS_6",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_FLAGS_7",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_TCP_CHECKSUM_ERR",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_HDR_INCOMPLETE",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_HDR_CROSS_BORDER",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_SMAE_SP_DP",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_BAD_LEN",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_DATA_INCOMPLETE",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_CHECKSUM_ERR",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_LITE_HDR_INCOMPLETE",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_LITE_HDR_CROSS_BORDER",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_LITE_SMAE_SP_DP",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_LITE_CSM_COV_1_TO_7",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_LITE_CSM_COV_TOO_LONG",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_LITE_CSM_COV_CROSS_BORDER",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EXP_UDP_LITE_CHECKSUM_ERR",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_MC_BRIDGE_ACTION",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ACTION",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ERROR",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_ROUTE_ACTION",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_NO_ROUTE_ACTION",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_NO_ROUTE_NH_INVALID_ACTION",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_NO_ROUTE_PREHEAD_ACTION",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_BRIDGE_ACTION",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_FLOW_ACTION",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_FLOW_MISS_ACTION",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L2_EXP_MRU_FAIL",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L2_EXP_MTU_FAIL",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_EXP_IP_PREFIX_BC",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_EXP_MTU_FAIL",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_EXP_MRU_FAIL",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_EXP_ICMP_RDT",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_FAKE_MAC_HEADER_ERR",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_EXP_IP_RT_TTL_ZERO",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_FLOW_SERVICE_CODE_LOOP",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_FLOW_DE_ACCELEARTE",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_EXP_FLOW_SRC_IF_CHK_FAIL",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH",		NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_EXP_MTU_DF_FAIL",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L3_EXP_PPPOE_MULTICAST",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_IPV4_SG_UNKNOWN",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_IPV6_SG_UNKNOWN",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_ARP_SG_UNKNOWN",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_ND_SG_UNKNOWN",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_IPV4_SG_VIO",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_IPV6_SG_VIO",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_ARP_SG_VIO",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_ND_SG_VIO",					NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L2_NEW_MAC_ADDRESS",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L2_HASH_COLLISION",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L2_STATION_MOVE",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L2_LEARN_LIMIT",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L2_SA_LOOKUP_ACTION",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_L2_DA_LOOKUP_ACTION",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_APP_CTRL_ACTION",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_IN_VLAN_FILTER_ACTION",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_IN_VLAN_XLT_MISS",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_EG_VLAN_FILTER_DROP",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_ACL_PRE_ACTION",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_ACL_POST_ACTION",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_MC_BC_SA",					NSS_STATS_TYPE_DROP},
	{"DROP_CODE_NO_DESTINATION",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_STG_IN_FILTER",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_STG_EG_FILTER",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_SOURCE_FILTER_FAIL",			NSS_STATS_TYPE_DROP},
	{"DROP_CODE_TRUNK_SEL_FAIL",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_TX_EN_FAIL",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_VLAN_TAG_FMT",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_CRC_ERR",					NSS_STATS_TYPE_DROP},
	{"DROP_CODE_PAUSE_FRAME",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_PROMISC",					NSS_STATS_TYPE_DROP},
	{"DROP_CODE_ISOLATION",					NSS_STATS_TYPE_DROP},
	{"DROP_CODE_MGMT_APP",					NSS_STATS_TYPE_DROP},
	{"DROP_CODE_FAKE_L2_PROT_ERR",				NSS_STATS_TYPE_DROP},
	{"DROP_CODE_POLICER",					NSS_STATS_TYPE_DROP}
};

/*
 * nss_ppe_stats_str_dc_strings_read()
 *	Read ppe drop code statistics names
 */
static ssize_t nss_ppe_stats_str_dc_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
{
	return nss_strings_print(ubuf, sz, ppos, nss_ppe_stats_str_dc, NSS_PPE_STATS_DROP_CODE_MAX);
}

/*
 * nss_ppe_stats_str_dc_strings_ops
 */
NSS_STRINGS_DECLARE_FILE_OPERATIONS(ppe_stats_str_dc);

/*
 * nss_ppe_stats_str_sc
 *	PPE statistics strings for service-code stats
 */
struct nss_stats_info nss_ppe_stats_str_sc[NSS_PPE_STATS_SERVICE_CODE_MAX] = {
	{"cb_unregister",	NSS_STATS_TYPE_SPECIAL},
	{"process_ok",		NSS_STATS_TYPE_SPECIAL},
	{"process_fail",	NSS_STATS_TYPE_ERROR}
};

/*
 * nss_ppe_stats_str_sc_strings_read()
 *	Read ppe service code statistics names
 */
static ssize_t nss_ppe_stats_str_sc_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
{
	return nss_strings_print(ubuf, sz, ppos, nss_ppe_stats_str_sc, NSS_PPE_STATS_SERVICE_CODE_MAX);
}

/*
 * nss_ppe_stats_str_sc_strings_ops
 */
NSS_STRINGS_DECLARE_FILE_OPERATIONS(ppe_stats_str_sc);

/*
 * nss_ppe_stats_str_cc
 *	PPE statistics strings for cpu code
 */
struct nss_stats_info nss_ppe_stats_str_cc[NSS_PPE_STATS_CPU_CODE_MAX] = {
	{"CPU_CODE_FORWARDING",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_UNKNOWN_L2_PROT",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_PPPOE_WRONG_VER_TYPE",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_WRONG_CODE",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_WRONG_VER",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_SMALL_IHL",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_WITH_OPTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_HDR_INCOMPLETE",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV4_BAD_TOTAL_LEN",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_DATA_INCOMPLETE",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_IPV4_FRAG",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV4_PING_OF_DEATH",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_SNALL_TTL",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV4_UNK_IP_PROT",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_CHECKSUM_ERR",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_INV_SIP",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_INV_DIP",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_LAND_ATTACK",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV4_AH_HDR_INCOMPLETE",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV4_AH_CROSS_BORDER",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_WRONG_VER",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_HDR_INCOMPLETE",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_BAD_PAYLOAD_LEN",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_DATA_INCOMPLETE",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_WITH_EXT_HDR",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_SMALL_HOP_LIMIT",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_INV_SIP",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_INV_DIP",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_LAND_ATTACK",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_IPV6_FRAG",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_PING_OF_DEATH",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_WITH_EXT_HDR",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_UNK_NEXT_HDR",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_MOBILITY_CROSS_BORDER",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_AH_HDR_INCOMPLETE",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_AH_CROSS_BORDER",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_ESP_CROSS_BORDER",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_OTHER_HDR_INCOMPLETE",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_IPV6_OTHER_EXT_CROSS_BORDER",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_HDR_INCOMPLETE",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_TCP_HDR_CROSS_BORDER",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_TCP_SMAE_SP_DP",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_TCP_SMALL_DATA_OFFSET",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_FLAGS_0",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_FLAGS_1",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_FLAGS_2",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_FLAGS_3",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_FLAGS_4",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_FLAGS_5",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_FLAGS_6",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_FLAGS_7",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_CHECKSUM_ERR",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_HDR_INCOMPLETE",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_UDP_HDR_CROSS_BORDER",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_UDP_SMAE_SP_DP",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_BAD_LEN",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_DATA_INCOMPLETE",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_CHECKSUM_ERR",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_UDP_LITE_HDR_INCOMPLETE",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_UDP_LITE_CROSS_BORDER",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_UDP_LITE_SP_DP",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_UDP_LITE_CSM_COV_TO_7",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_UDP_LITE_CSM_TOO_LONG",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_UDP_LITE_CSM_CROSS_BORDER",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_UDP_LITE_CHECKSUM_ERR",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_FAKE_L2_PROT_ERR",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EXP_FAKE_MAC_HEADER_ERR",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_BITMAP_MAX",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L2_MRU_FAIL",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L2_MTU_FAIL",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_EXP_IP_PREFIX_BC",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_MTU_FAIL",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_MRU_FAIL",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_ICMP_RDT",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_EXP_IP_RT_TO_ME",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_EXP_IP_TTL_ZERO",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_FLOW_SERVICE_CODE_LOOP",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_DE_ACCELERATE",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_EXP_FLOW_SRC_CHK_FAIL",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_EXP_MTU_DF_FAIL",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_PPPOE_MULTICAST",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_MGMT_OFFSET",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_MGMT_EAPOL",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_PPPOE_DIS",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_MGMT_IGMP",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_ARP_REQ",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_ARP_REP",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_MGMT_DHCPv4",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_MGMT_MLD",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_MGMT_NS",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_MGMT_NA",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_MGMT_DHCPv6",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_PTP_OFFSET",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_PTP_SYNC",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_FOLLOW_UP",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_DELAY_REQ",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_DELAY_RESP",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_PDELAY_REQ",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_PDELAY_RESP",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_PTP_PDELAY_RESP_FOLLOW_UP",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_PTP_ANNOUNCE",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_PTP_MANAGEMENT",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_PTP_SIGNALING",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_PTP_RSV_MSG",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_SG_UNKNOWN",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_SG_UNKNOWN",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_SG_UNKNOWN",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_SG_UNKNOWN",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_SG_VIO",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_SG_VIO",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_SG_VIO",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_SG_VIO",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_ROUTING_IP_TO_ME",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_SNAT_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_DNAT_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_RT_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_BR_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_BRIDGE_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_ROUTE_PREHEAD_RT_ACTION",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_ROUTE_PREHEAD_SNAPT_ACTION",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_ROUTE_PREHEAD_DNAPT_ACTION",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_ROUTE_PREHEAD_SNAT_ACTION",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_ROUTE_PREHEAD_DNAT_ACTION",	NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_NO_ROUTE_NAT_ACTION",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_NO_ROUTE_NAT_ERROR",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_ROUTE_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_ROUTE_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_NO_ROUTE_INVALID_ACTION",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_NO_ROUTE_PREHEAD_ACTION",		NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_BRIDGE_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_FLOW_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L3_MISS_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L2_MAC_ADDRESS",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_HASH_COLLISION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_STATION_MOVE",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_LEARN_LIMIT",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L2_LOOKUP_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_L2_LOOKUP_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_CTRL_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_IN_FILTER_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_IN_XLT_MISS",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_EG_FILTER_DROP",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_PRE_ACTION",				NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_POST_ACTION",			NSS_STATS_TYPE_EXCEPTION},
	{"CPU_CODE_CODE_ACTION",			NSS_STATS_TYPE_EXCEPTION}
};

/*
 * nss_ppe_stats_str_cc_strings_read()
 *	Read ppe cpu code statistics names
 */
static ssize_t nss_ppe_stats_str_cc_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
{
	return nss_strings_print(ubuf, sz, ppos, nss_ppe_stats_str_cc, NSS_PPE_STATS_CPU_CODE_MAX);
}

/*
 * nss_ppe_stats_str_cc_strings_ops
 */
NSS_STRINGS_DECLARE_FILE_OPERATIONS(ppe_stats_str_cc);

/*
 * nss_ppe_strings_dentry_create()
 *	Create ppe statistics strings debug entry.
 */
void nss_ppe_strings_dentry_create(void)
{
	struct dentry *ppe_d = NULL;

	if (!nss_top_main.strings_dentry) {
		nss_warning("qca-nss-drv/strings is not present");
		return;
	}

	ppe_d = debugfs_create_dir("ppe", nss_top_main.strings_dentry);
	if (!ppe_d) {
		nss_warning("Failed to create qca-nss-drv/strings/ppe directory");
		return;
	}

	if (!debugfs_create_file("stats_str_conn", 0400, ppe_d, &nss_top_main, &nss_ppe_stats_str_conn_strings_ops)) {
		nss_warning("Failed to create qca-nss-drv/strings/ppe/stats_str_conn file");
		debugfs_remove_recursive(ppe_d);
		return;
	}

	if (!debugfs_create_file("stats_str_sc", 0400, ppe_d, &nss_top_main, &nss_ppe_stats_str_sc_strings_ops)) {
		nss_warning("Failed to create qca-nss-drv/strings/ppe/stats_str_sc file");
		debugfs_remove_recursive(ppe_d);
		return;
	}

	if (!debugfs_create_file("stats_str_l3", 0400, ppe_d, &nss_top_main, &nss_ppe_stats_str_l3_strings_ops)) {
		nss_warning("Failed to create qca-nss-drv/strings/ppe/stats_str_l3 file");
		debugfs_remove_recursive(ppe_d);
		return;
	}

	if (!debugfs_create_file("stats_str_code", 0400, ppe_d, &nss_top_main, &nss_ppe_stats_str_code_strings_ops)) {
		nss_warning("Failed to create qca-nss-drv/strings/ppe/stats_str_code file");
		debugfs_remove_recursive(ppe_d);
		return;
	}

	if (!debugfs_create_file("stats_str_dc", 0400, ppe_d, &nss_top_main, &nss_ppe_stats_str_dc_strings_ops)) {
		nss_warning("Failed to create qca-nss-drv/strings/ppe/stats_str_dc file");
		debugfs_remove_recursive(ppe_d);
		return;
	}

	if (!debugfs_create_file("stats_str_cc", 0400, ppe_d, &nss_top_main, &nss_ppe_stats_str_cc_strings_ops)) {
		nss_warning("Failed to create qca-nss-drv/strings/ppe/stats_str_cc file");
		debugfs_remove_recursive(ppe_d);
		return;
	}
}
