From c351b5cbcdcf3287a80755234a68445b674c850e Mon Sep 17 00:00:00 2001 From: SqTER-PL Date: Wed, 5 Mar 2025 19:03:24 +0100 Subject: [PATCH] Update and minor fixes for QCA-NSS drivers. Currently working and tested modules: nss-ifb qca-nss-drv qca-nss-drv-igs (new) qca-nss-drv-pppoe qca-nss-drv-qdisc qca-nss-drv-tun6rd (new) qca-nss-drv-tunipip6 (new) qca-nss-gmac qca-nss-ecm-standard qca-mcs --- package/qca-nss/qca-nss-clients/Makefile | 18 +- .../patches/100-kernel-5.15-support.patch | 17345 +++--- package/qca-nss/qca-nss-drv/Makefile | 15 +- .../patches/100-kernel-5.15-support.patch | 47280 +++++++--------- .../patches/110-kernel-6.x-support.patch | 28 +- .../patches/120-fix-conversion.patch | 16 +- package/qca-nss/qca-nss-ecm/Makefile | 6 +- package/qca-nss/qca-nss-gmac/Makefile | 7 +- 8 files changed, 26492 insertions(+), 38223 deletions(-) diff --git a/package/qca-nss/qca-nss-clients/Makefile b/package/qca-nss/qca-nss-clients/Makefile index cf689e8731..3ba0349b40 100644 --- a/package/qca-nss/qca-nss-clients/Makefile +++ b/package/qca-nss/qca-nss-clients/Makefile @@ -1,4 +1,4 @@ -# NHSS.QSDK.12.2 +# NHSS.QSDK 11.2 - 12.2 # by SqTER include $(TOPDIR)/rules.mk @@ -7,10 +7,10 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=qca-nss-clients PKG_RELEASE:=2 PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/nss-clients.git -PKG_SOURCE_DATE:=2023-06-01 +PKG_SOURCE_DATE:=2020-10-29 PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=4cc5d7687c69ef1fbc53d5492d9d672d2d8ef030 -PKG_MIRROR_HASH:=cc1904bd90a0fc137b114b3232245c973e84068ea52caeaac66c49d958739a4e +PKG_SOURCE_VERSION:=ef082a735fad96bd2f6f59b94d6ea81defc4796e +PKG_MIRROR_HASH:=9375f2bbdd17826b6ddebc77607ec73c98626570243a9831a1e34e1051eb436c PKG_BUILD_DEPENDS:=qca-nss-drv PKG_BUILD_PARALLEL:=1 @@ -108,7 +108,7 @@ define KernelPackage/qca-nss-drv-tunipip6 TITLE:=Kernel driver for NSS (connection manager) - DS-lite and ipip6 Tunnel DEPENDS:=+@NSS_DRV_TUNIPIP6_ENABLE +kmod-iptunnel6 +kmod-ip6-tunnel \ +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv - FILES:=$(PKG_BUILD_DIR)/qca-nss-tunipip6.ko + FILES:=$(PKG_BUILD_DIR)/tunipip6/qca-nss-tunipip6.ko AUTOLOAD:=$(call AutoLoad,60,qca-nss-tunipip6) endef @@ -210,7 +210,7 @@ define KernelPackage/qca-nss-drv-igs SUBMENU:=Network Devices TITLE:=Action for offloading traffic to an IFB interface to perform ingress shaping. DEPENDS:=@TARGET_ipq806x||TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_64||TARGET_ipq_ipq60xx||TARGET_ipq_ipq60xx_64||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64 \ - +@NSS_DRV_IGS_ENABLE +kmod-sched-core +kmod-ifb +kmod-qca-nss-drv-qdisc \ + +@NSS_DRV_IGS_ENABLE +kmod-sched-core +kmod-nf-conntrack +kmod-ifb +kmod-qca-nss-drv-qdisc \ +PACKAGE_kmod-qca-nss-drv:kmod-qca-nss-drv FILES:=$(PKG_BUILD_DIR)/nss_qdisc/igs/act_nssmirred.ko endef @@ -467,11 +467,7 @@ endif # endif define Build/Compile - +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" $(strip $(MAKE_OPTS)) \ - CROSS_COMPILE="$(TARGET_CROSS)" \ - ARCH="$(LINUX_KARCH)" \ - $(KERNEL_MAKE_FLAGS) \ - $(PKG_MAKE_FLAGS) \ + $(KERNEL_MAKE) $(strip $(MAKE_OPTS)) \ M="$(PKG_BUILD_DIR)" \ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ SoC="$(subtarget)" \ diff --git a/package/qca-nss/qca-nss-clients/patches/100-kernel-5.15-support.patch b/package/qca-nss/qca-nss-clients/patches/100-kernel-5.15-support.patch index c100d02222..f1d6512fc1 100644 --- a/package/qca-nss/qca-nss-clients/patches/100-kernel-5.15-support.patch +++ b/package/qca-nss/qca-nss-clients/patches/100-kernel-5.15-support.patch @@ -1,2013 +1,23 @@ --- a/Makefile +++ b/Makefile -@@ -5,27 +5,25 @@ ccflags-y := -I$(obj) -I$(obj)/.. - export BUILD_ID = \"Build Id: $(shell date +'%m/%d/%y, %H:%M:%S')\" - ccflags-y += -DNSS_CLIENT_BUILD_ID="$(BUILD_ID)" - -+qca-nss-tunipip6-objs := nss_connmgr_tunipip6.o - qca-nss-tun6rd-objs := nss_connmgr_tun6rd.o - -+ccflags-y += -DNSS_TUNIPIP6_DEBUG_LEVEL=0 +@@ -10,14 +10,11 @@ qca-nss-tun6rd-objs := nss_connmgr_tun6r ccflags-y += -DNSS_TUN6RD_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror -- --KERNELVERSION := $(word 1, $(subst ., ,$(KERNELVERSION))).$(word 2, $(subst ., ,$(KERNELVERSION))) -+ccflags-y += -Werror + ccflags-y += -Werror +-KERNELVERSION := $(word 1, $(subst ., ,$(KERNELVERSION))).$(word 2, $(subst ., ,$(KERNELVERSION))) +- obj-$(bridge-mgr)+= bridge/ obj-$(capwapmgr)+= capwapmgr/ obj-$(dtlsmgr)+= dtls/$(DTLSMGR_DIR)/ obj-$(gre)+= gre/ obj-$(ipsecmgr)+= ipsecmgr/$(IPSECMGR_DIR)/ -obj-$(ipsecmgr-klips)+= ipsecmgr/$(IPSECMGR_DIR)/plugins/klips/ --obj-$(ipsecmgr-xfrm)+= ipsecmgr/$(IPSECMGR_DIR)/plugins/xfrm/ obj-$(l2tpv2)+= l2tp/l2tpv2/ obj-$(lag-mgr)+= lag/ obj-$(map-t)+= map/map-t/ - obj-$(portifmgr)+= portifmgr/ - obj-$(pptp)+= pptp/ - obj-$(profile)+= profiler/ --obj-$(tunipip6)+= tunipip6/ -+obj-$(tunipip6)+= qca-nss-tunipip6.o - obj-$(tun6rd)+= qca-nss-tun6rd.o - obj-$(qdisc)+= nss_qdisc/ - obj-$(vlan-mgr)+= vlan/ -@@ -38,8 +36,6 @@ obj-$(clmapmgr)+= clmapmgr/ - obj-$(match)+= match/ - obj-$(tlsmgr)+= tls/ - obj-$(mirror)+= mirror/ --obj-$(mscs)+= mscs/ --obj-$(wifi-meshmgr)+= wifi_meshmgr/ - - #NSS NETLINK - obj-$(netlink)+= netlink/ ---- a/bridge/Makefile -+++ b/bridge/Makefile -@@ -9,7 +9,7 @@ qca-nss-bridge-mgr-objs += nss_bridge_mg - endif - - ccflags-y += -DNSS_BRIDGE_MGR_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - - ifeq ($(SoC),$(filter $(SoC),ipq807x ipq807x_64 ipq60xx ipq60xx_64)) - ccflags-y += -DNSS_BRIDGE_MGR_PPE_SUPPORT ---- a/bridge/nss_bridge_mgr.c -+++ b/bridge/nss_bridge_mgr.c -@@ -1,12 +1,9 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2016-2020, 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 -@@ -418,37 +415,6 @@ static int nss_bridge_mgr_del_bond_slave - } - - /* -- * nss_bridge_mgr_bond_fdb_join() -- * Update FDB state when a bond interface joining bridge. -- */ --static int nss_bridge_mgr_bond_fdb_join(struct nss_bridge_pvt *b_pvt) --{ -- /* -- * If already other bond devices are attached to bridge, -- * only increment bond_slave_num, -- */ -- spin_lock(&br_mgr_ctx.lock); -- if (b_pvt->bond_slave_num) { -- b_pvt->bond_slave_num++; -- spin_unlock(&br_mgr_ctx.lock); -- return NOTIFY_DONE; -- } -- b_pvt->bond_slave_num = 1; -- spin_unlock(&br_mgr_ctx.lock); -- -- /* -- * This is the first bond device being attached to bridge. In order to enforce Linux -- * bond slave selection in bridge flows involving bond interfaces, we need to disable -- * fdb learning on this bridge master to allow flow based bridging. -- */ -- if (nss_bridge_mgr_disable_fdb_learning(b_pvt) < 0) { -- return NOTIFY_BAD; -- } -- -- return NOTIFY_DONE; --} -- --/* - * nss_bridge_mgr_bond_master_join() - * Add a bond interface to bridge - */ -@@ -481,7 +447,28 @@ static int nss_bridge_mgr_bond_master_jo - } - } - -- if (nss_bridge_mgr_bond_fdb_join(b_pvt) == NOTIFY_DONE) { -+ /* -+ * If already other bond devices are attached to bridge, -+ * only increment bond_slave_num, -+ */ -+ spin_lock(&br_mgr_ctx.lock); -+ if (b_pvt->bond_slave_num) { -+ b_pvt->bond_slave_num++; -+ spin_unlock(&br_mgr_ctx.lock); -+ return NOTIFY_DONE; -+ } -+ spin_unlock(&br_mgr_ctx.lock); -+ -+ /* -+ * This is the first bond device being attached to bridge. In order to enforce Linux -+ * bond slave selection in bridge flows involving bond interfaces, we need to disable -+ * fdb learning on this bridge master to allow flow based bridging. -+ */ -+ if (!nss_bridge_mgr_disable_fdb_learning(b_pvt)) { -+ spin_lock(&br_mgr_ctx.lock); -+ b_pvt->bond_slave_num = 1; -+ spin_unlock(&br_mgr_ctx.lock); -+ - return NOTIFY_DONE; - } - -@@ -501,40 +488,6 @@ cleanup: - } - - /* -- * nss_bridge_mgr_bond_fdb_leave() -- * Update FDB state when a bond interface leaving bridge. -- */ --static int nss_bridge_mgr_bond_fdb_leave(struct nss_bridge_pvt *b_pvt) --{ -- -- nss_bridge_mgr_assert(b_pvt->bond_slave_num == 0); -- -- /* -- * If more than one bond devices are attached to bridge, -- * only decrement the bond_slave_num -- */ -- spin_lock(&br_mgr_ctx.lock); -- if (b_pvt->bond_slave_num > 1) { -- b_pvt->bond_slave_num--; -- spin_unlock(&br_mgr_ctx.lock); -- return NOTIFY_DONE; -- } -- b_pvt->bond_slave_num = 0; -- spin_unlock(&br_mgr_ctx.lock); -- -- /* -- * The last bond interface is removed from bridge, we can switch back to FDB -- * learning mode. -- */ -- if (nss_bridge_mgr_enable_fdb_learning(b_pvt) < 0) { -- return NOTIFY_BAD; -- } -- -- return NOTIFY_DONE; --} -- -- --/* - * nss_bridge_mgr_bond_master_leave() - * Remove a bond interface from bridge - */ -@@ -563,7 +516,27 @@ static int nss_bridge_mgr_bond_master_le - } - } - -- if (nss_bridge_mgr_bond_fdb_leave(b_pvt) == NOTIFY_DONE) { -+ /* -+ * If more than one bond devices are attached to bridge, -+ * only decrement the bond_slave_num -+ */ -+ spin_lock(&br_mgr_ctx.lock); -+ if (b_pvt->bond_slave_num > 1) { -+ b_pvt->bond_slave_num--; -+ spin_unlock(&br_mgr_ctx.lock); -+ return NOTIFY_DONE; -+ } -+ spin_unlock(&br_mgr_ctx.lock); -+ -+ /* -+ * The last bond interface is removed from bridge, we can switch back to FDB -+ * learning mode. -+ */ -+ if (!nss_bridge_mgr_enable_fdb_learning(b_pvt)) { -+ spin_lock(&br_mgr_ctx.lock); -+ b_pvt->bond_slave_num = 0; -+ spin_unlock(&br_mgr_ctx.lock); -+ - return NOTIFY_DONE; - } - -@@ -782,6 +755,10 @@ int nss_bridge_mgr_join_bridge(struct ne - * This is done by not sending join message to the bridge in NSS. - */ - if (br_mgr_ctx.wan_if_num == ifnum) { -+ if (!nss_bridge_mgr_l2_exception_acl_enable()) { -+ nss_bridge_mgr_warn("%px: failed to enable ACL\n", br); -+ return -EIO; -+ } - br->wan_if_enabled = true; - br->wan_if_num = ifnum; - nss_bridge_mgr_info("if_num %d is added as WAN interface \n", ifnum); -@@ -830,10 +807,9 @@ int nss_bridge_mgr_join_bridge(struct ne - } - - /* -- * Update FDB state of the bridge. No need to add individual interfaces of bond to the bridge. -- * VLAN interface verifies that all interfaces are physical so, no need to verify again. -+ * Add the bond_master to bridge. - */ -- if (nss_bridge_mgr_bond_fdb_join(br) != NOTIFY_DONE) { -+ if (nss_bridge_mgr_bond_master_join(real_dev, br) != NOTIFY_DONE) { - nss_bridge_mgr_warn("%px: Slaves of bond interface %s join bridge failed\n", br, real_dev->name); - nss_bridge_tx_leave_msg(br->ifnum, dev); - nss_vlan_mgr_leave_bridge(dev, br->vsi); -@@ -888,6 +864,7 @@ int nss_bridge_mgr_leave_bridge(struct n - * Hence a leave message should also be avaoided. - */ - if ((br->wan_if_enabled) && (br->wan_if_num == ifnum)) { -+ nss_bridge_mgr_l2_exception_acl_disable(); - br->wan_if_enabled = false; - br->wan_if_num = -1; - nss_bridge_mgr_info("if_num %d is added as WAN interface\n", ifnum); -@@ -933,10 +910,9 @@ int nss_bridge_mgr_leave_bridge(struct n - } - - /* -- * Update FDB state of the bridge. No need to add individual interfaces of bond to the bridge. -- * VLAN interface verifies that all interfaces are physical so, no need to verify again. -+ * Remove the bond_master from bridge. - */ -- if (nss_bridge_mgr_bond_fdb_leave(br) != NOTIFY_DONE) { -+ if (nss_bridge_mgr_bond_master_leave(real_dev, br) != NOTIFY_DONE) { - nss_bridge_mgr_warn("%px: Slaves of bond interface %s leave bridge failed\n", br, real_dev->name); - nss_vlan_mgr_join_bridge(dev, br->vsi); - nss_bridge_tx_join_msg(br->ifnum, dev); -@@ -1046,45 +1022,44 @@ int nss_bridge_mgr_register_br(struct ne - - b_pvt->dev = dev; - --#if defined(NSS_BRIDGE_MGR_PPE_SUPPORT) -- err = ppe_vsi_alloc(NSS_BRIDGE_MGR_SWITCH_ID, &vsi_id); -- if (err) { -- nss_bridge_mgr_warn("%px: failed to alloc bridge vsi, error = %d\n", b_pvt, err); -- goto fail; -- } -- -- b_pvt->vsi = vsi_id; --#endif -- - ifnum = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_BRIDGE); - if (ifnum < 0) { - nss_bridge_mgr_warn("%px: failed to alloc bridge di\n", b_pvt); -- goto fail_1; -+ nss_bridge_mgr_delete_instance(b_pvt); -+ return -EFAULT; - } - - if (!nss_bridge_register(ifnum, dev, NULL, NULL, 0, b_pvt)) { - nss_bridge_mgr_warn("%px: failed to register bridge di to NSS\n", b_pvt); -- goto fail_2; -+ goto fail; - } - - #if defined(NSS_BRIDGE_MGR_PPE_SUPPORT) -+ err = ppe_vsi_alloc(NSS_BRIDGE_MGR_SWITCH_ID, &vsi_id); -+ if (err) { -+ nss_bridge_mgr_warn("%px: failed to alloc bridge vsi, error = %d\n", b_pvt, err); -+ goto fail_1; -+ } -+ -+ b_pvt->vsi = vsi_id; -+ - err = nss_bridge_tx_vsi_assign_msg(ifnum, vsi_id); - if (err != NSS_TX_SUCCESS) { - nss_bridge_mgr_warn("%px: failed to assign vsi msg, error = %d\n", b_pvt, err); -- goto fail_3; -+ goto fail_2; - } - #endif - - err = nss_bridge_tx_set_mac_addr_msg(ifnum, dev->dev_addr); - if (err != NSS_TX_SUCCESS) { - nss_bridge_mgr_warn("%px: failed to set mac_addr msg, error = %d\n", b_pvt, err); -- goto fail_4; -+ goto fail_3; - } - - err = nss_bridge_tx_set_mtu_msg(ifnum, dev->mtu); - if (err != NSS_TX_SUCCESS) { - nss_bridge_mgr_warn("%px: failed to set mtu msg, error = %d\n", b_pvt, err); -- goto fail_4; -+ goto fail_3; - } - - /* -@@ -1092,8 +1067,10 @@ int nss_bridge_mgr_register_br(struct ne - */ - b_pvt->ifnum = ifnum; - b_pvt->mtu = dev->mtu; -+#if defined(NSS_BRIDGE_MGR_PPE_SUPPORT) - b_pvt->wan_if_num = -1; - b_pvt->wan_if_enabled = false; -+#endif - ether_addr_copy(b_pvt->dev_addr, dev->dev_addr); - spin_lock(&br_mgr_ctx.lock); - list_add(&b_pvt->list, &br_mgr_ctx.list); -@@ -1110,29 +1087,25 @@ int nss_bridge_mgr_register_br(struct ne - #endif - return 0; - --fail_4: -+fail_3: - #if defined(NSS_BRIDGE_MGR_PPE_SUPPORT) - if (nss_bridge_tx_vsi_unassign_msg(ifnum, vsi_id) != NSS_TX_SUCCESS) { - nss_bridge_mgr_warn("%px: failed to unassign vsi\n", b_pvt); - } --fail_3: --#endif - -+fail_2: -+ ppe_vsi_free(NSS_BRIDGE_MGR_SWITCH_ID, vsi_id); -+ -+fail_1: -+#endif - nss_bridge_unregister(ifnum); - --fail_2: -+fail: - if (nss_dynamic_interface_dealloc_node(ifnum, NSS_DYNAMIC_INTERFACE_TYPE_BRIDGE) != NSS_TX_SUCCESS) { - nss_bridge_mgr_warn("%px: failed to dealloc bridge di\n", b_pvt); - } - --fail_1: --#if defined(NSS_BRIDGE_MGR_PPE_SUPPORT) -- ppe_vsi_free(NSS_BRIDGE_MGR_SWITCH_ID, vsi_id); --fail: --#endif -- - nss_bridge_mgr_delete_instance(b_pvt); -- - return -EFAULT; - } - -@@ -1159,6 +1132,7 @@ static int nss_bridge_mgr_bond_slave_cha - return NOTIFY_DONE; - } - -+#if defined(NSS_BRIDGE_MGR_PPE_SUPPORT) - /* - * Add or remove the slave based based on linking event - */ -@@ -1173,6 +1147,7 @@ static int nss_bridge_mgr_bond_slave_cha - cu_info->upper_dev->name, master->name); - } - } -+#endif - - return NOTIFY_DONE; - } -@@ -1200,7 +1175,7 @@ static int nss_bridge_mgr_changemtu_even - - if (nss_bridge_tx_set_mtu_msg(b_pvt->ifnum, dev->mtu) != NSS_TX_SUCCESS) { - nss_bridge_mgr_warn("%px: Failed to send change MTU message to NSS\n", b_pvt); -- return NOTIFY_DONE; -+ return NOTIFY_BAD; - } - - spin_lock(&br_mgr_ctx.lock); -@@ -1234,7 +1209,7 @@ static int nss_bridge_mgr_changeaddr_eve - - if (nss_bridge_tx_set_mac_addr_msg(b_pvt->ifnum, dev->dev_addr) != NSS_TX_SUCCESS) { - nss_bridge_mgr_warn("%px: Failed to send change MAC address message to NSS\n", b_pvt); -- return NOTIFY_DONE; -+ return NOTIFY_BAD; - } - - spin_lock(&br_mgr_ctx.lock); -@@ -1294,6 +1269,7 @@ static int nss_bridge_mgr_changeupper_ev - nss_bridge_mgr_trace("%px: Interface %s joining bridge %s\n", b_pvt, dev->name, master_dev->name); - if (nss_bridge_mgr_join_bridge(dev, b_pvt)) { - nss_bridge_mgr_warn("%px: Interface %s failed to join bridge %s\n", b_pvt, dev->name, master_dev->name); -+ return NOTIFY_BAD; - } - - return NOTIFY_DONE; -@@ -1302,6 +1278,7 @@ static int nss_bridge_mgr_changeupper_ev - nss_bridge_mgr_trace("%px: Interface %s leaving bridge %s\n", b_pvt, dev->name, master_dev->name); - if (nss_bridge_mgr_leave_bridge(dev, b_pvt)) { - nss_bridge_mgr_warn("%px: Interface %s failed to leave bridge %s\n", b_pvt, dev->name, master_dev->name); -+ return NOTIFY_BAD; - } - - return NOTIFY_DONE; -@@ -1627,14 +1604,6 @@ int __init nss_bridge_mgr_init_module(vo - br_mgr_ctx.wan_if_num = -1; - br_fdb_update_register_notify(&nss_bridge_mgr_fdb_update_notifier); - br_mgr_ctx.nss_bridge_mgr_header = register_sysctl_table(nss_bridge_mgr_root_dir); -- -- /* -- * Enable ACL rule to enable L2 exception. This is needed if PPE Virtual ports is added to bridge. -- * It is assumed that VP is using flow based bridging, hence L2 exceptions will need to be enabled on PPE bridge. -- */ -- if (!nss_bridge_mgr_l2_exception_acl_enable()) { -- nss_bridge_mgr_warn("Failed to enable ACL\n"); -- } - #endif - #if defined (NSS_BRIDGE_MGR_OVS_ENABLE) - nss_bridge_mgr_ovs_init(); -@@ -1656,12 +1625,6 @@ void __exit nss_bridge_mgr_exit_module(v - if (br_mgr_ctx.nss_bridge_mgr_header) { - unregister_sysctl_table(br_mgr_ctx.nss_bridge_mgr_header); - } -- -- /* -- * Disable the PPE L2 exceptions which were enabled during module init for PPE virtual ports. -- */ -- nss_bridge_mgr_l2_exception_acl_disable(); -- - #endif - #if defined (NSS_BRIDGE_MGR_OVS_ENABLE) - nss_bridge_mgr_ovs_exit(); ---- a/capwapmgr/Makefile -+++ b/capwapmgr/Makefile -@@ -14,4 +14,4 @@ qca-nss-capwapmgr-objs := nss_capwapmgr. - ccflags-y += -DNSS_CAPWAPMGR_DEBUG_LEVEL=6 - - ccflags-y += $(NSS_CCFLAGS) -DNSS_DEBUG_LEVEL=0 -DNSS_PKT_STATS_ENABLED=0 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror ---- a/capwapmgr/nss_capwapmgr.c -+++ b/capwapmgr/nss_capwapmgr.c -@@ -1,12 +1,9 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2014-2020, 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 -@@ -95,16 +92,17 @@ - #define NSS_CAPWAPMGR_BIND_BITMAP 0x7E - - /* -- * We need 4 ACL rules - 2 rules for each v4 and v6 classification. -+ * The number of rules supported by a list is 4. Since we need 2 rules for every -+ * dscp classification (v4 and v6). We set this value to 2. - */ --#define NSS_CAPWAPMGR_ACL_RULES_PER_LIST 4 -+#define NSS_CAPWAPMGR_ACL_RULES_PER_LIST 2 - - /* -- * We currently have list-id 60 reserved for this purpose. -+ * We currently have list-id 60 and 61 reserved for this purpose. - * TODO: Find a better approach to reserve list-id. - */ - #define NSS_CAPWAPMGR_ACL_LIST_START 60 --#define NSS_CAPWAPMGR_ACL_LIST_CNT 1 -+#define NSS_CAPWAPMGR_ACL_LIST_CNT 2 - - #define NSS_CAPWAPMGR_NORMAL_FRAME_MTU 1500 - -@@ -234,7 +232,7 @@ static void nss_capwapmgr_decongestion_c - - /* - * nss_capwapmgr_start_xmit() -- * Transmit's skb to NSS FW over CAPWAP if_num_inner. -+ * Transmit's skb to NSS FW over CAPWAP if_num. - * - * Please make sure to leave headroom of NSS_CAPWAP_HEADROOM with every - * packet so that NSS can encap eth,vlan,ip,udp,capwap headers. -@@ -246,7 +244,7 @@ static netdev_tx_t nss_capwapmgr_start_x - struct net_device_stats *stats = &dev->stats; - struct nss_capwapmgr_priv *priv; - struct nss_capwap_metaheader *pre; -- uint32_t if_num_inner; -+ uint32_t if_num; - nss_tx_status_t status; - - priv = netdev_priv(dev); -@@ -259,9 +257,9 @@ static netdev_tx_t nss_capwapmgr_start_x - return NETDEV_TX_OK; - } - -- if_num_inner = priv->tunnel[pre->tunnel_id].if_num_inner; -- if (unlikely(if_num_inner == -1)) { -- nss_capwapmgr_warn("%px: (CAPWAP packet) if_num_inner in the tunnel not set pre->tunnel_id %d\n", dev, -+ if_num = priv->tunnel[pre->tunnel_id].if_num; -+ if (unlikely(if_num == 0)) { -+ nss_capwapmgr_warn("%px: (CAPWAP packet) if_num in the tunnel not set pre->tunnel_id %d\n", dev, - pre->tunnel_id); - kfree_skb(skb); - stats->tx_dropped++; -@@ -277,7 +275,7 @@ static netdev_tx_t nss_capwapmgr_start_x - */ - skb_set_queue_mapping(skb, pre->flow_id & 0x1); - -- status = nss_capwap_tx_buf(priv->nss_ctx, skb, if_num_inner); -+ status = nss_capwap_tx_buf(priv->nss_ctx, skb, if_num); - if (unlikely(status != NSS_TX_SUCCESS)) { - if (status == NSS_TX_FAILURE_QUEUE) { - nss_capwapmgr_warn("%px: netdev :%px queue is full", dev, dev); -@@ -302,7 +300,7 @@ static void nss_capwapmgr_fill_up_stats( - stats->rx_dropped += tstats->pnode_stats.rx_dropped; - - /* rx_fifo_errors will appear as rx overruns in ifconfig */ -- stats->rx_fifo_errors += (tstats->rx_n2h_drops + tstats->rx_n2h_queue_full_drops); -+ stats->rx_fifo_errors += (tstats->rx_queue_full_drops + tstats->rx_n2h_queue_full_drops); - stats->rx_errors += (tstats->rx_mem_failure_drops + tstats->rx_oversize_drops + tstats->rx_frag_timeout_drops); - stats->rx_bytes += tstats->pnode_stats.rx_bytes; - -@@ -370,6 +368,20 @@ static void nss_capwapmgr_dev_tunnel_sta - } - #endif - -+/** -+ * nss_capwapmgr_change_mtu - set new MTU size -+ * @dev: network device -+ * @new_mtu: new Maximum Transfer Unit -+ * -+ * Allow changing MTU size. Needs to be overridden for devices -+ * supporting jumbo frames. -+ */ -+int nss_capwapmgr_change_mtu(struct net_device *dev, int new_mtu) -+{ -+ dev->mtu = new_mtu; -+ return 0; -+} -+ - /* - * nss_capwapmgr_netdev_ops - * Netdev operations. -@@ -379,7 +391,7 @@ static const struct net_device_ops nss_c - .ndo_stop = nss_capwapmgr_close, - .ndo_start_xmit = nss_capwapmgr_start_xmit, - .ndo_set_mac_address = eth_mac_addr, -- .ndo_change_mtu = eth_change_mtu, -+ .ndo_change_mtu = nss_capwapmgr_change_mtu, - .ndo_get_stats64 = nss_capwapmgr_dev_tunnel_stats, - }; - -@@ -559,12 +571,15 @@ static struct nss_capwapmgr_tunnel *nss_ - return NULL; - } - -+ dev_hold(dev); - priv = netdev_priv(dev); - t = &priv->tunnel[tunnel_id]; -- if ( (t->if_num_inner == -1) || (t->if_num_outer == -1) ) { -+ if (t->if_num == 0) { -+ dev_put(dev); - return NULL; - } - -+ dev_put(dev); - return t; - } - -@@ -607,10 +622,6 @@ struct net_device *nss_capwapmgr_netdev_ - goto fail1; - } - memset(priv->tunnel, 0, sizeof(struct nss_capwapmgr_tunnel) * NSS_CAPWAPMGR_MAX_TUNNELS); -- for (i = 0; i < NSS_CAPWAPMGR_MAX_TUNNELS; i++) { -- priv->tunnel[i].if_num_inner = -1; -- priv->tunnel[i].if_num_outer = -1; -- } - - priv->resp = kmalloc(sizeof(struct nss_capwapmgr_response) * NSS_MAX_DYNAMIC_INTERFACES, GFP_ATOMIC); - if (!priv->resp) { -@@ -870,10 +881,6 @@ static nss_tx_status_t nss_capwapmgr_cre - memcpy(nircm->conn_rule.return_mac, unic->dest_mac, 6); - } - -- nircm->valid_flags |= NSS_IPV4_RULE_CREATE_SRC_MAC_VALID; -- nircm->src_mac_rule.mac_valid_flags |=NSS_IPV4_SRC_MAC_FLOW_VALID; -- memcpy(nircm->src_mac_rule.flow_src_mac, nircm->conn_rule.return_mac, 6); -- - /* - * Copy over the DSCP rule parameters - */ -@@ -1009,10 +1016,6 @@ static nss_tx_status_t nss_capwapmgr_cre - memcpy(nircm->conn_rule.return_mac, unic->dest_mac, 6); - nircm->valid_flags |= NSS_IPV6_RULE_CREATE_CONN_VALID; - -- nircm->valid_flags |= NSS_IPV6_RULE_CREATE_SRC_MAC_VALID; -- nircm->src_mac_rule.mac_valid_flags |=NSS_IPV6_SRC_MAC_FLOW_VALID; -- memcpy(nircm->src_mac_rule.flow_src_mac, nircm->conn_rule.return_mac, 6); -- - /* - * Copy over the DSCP rule parameters - */ -@@ -1294,85 +1297,23 @@ static nss_capwapmgr_status_t nss_capwap - } - - /* -- * nss_capwapmgr_tx_msg_enable_tunnel() -- * Common function to send CAPWAP tunnel enable msg -- */ --static nss_tx_status_t nss_capwapmgr_tx_msg_enable_tunnel(struct nss_ctx_instance *ctx, struct net_device *dev, uint32_t if_num, uint32_t sibling_if_num) --{ -- struct nss_capwap_msg capwapmsg; -- nss_tx_status_t status; -- -- /* -- * Prepare the tunnel configuration parameter to send to NSS FW -- */ -- memset(&capwapmsg, 0, sizeof(struct nss_capwap_msg)); -- capwapmsg.msg.enable_tunnel.sibling_if_num = sibling_if_num; -- -- /* -- * Send CAPWAP data tunnel command to NSS -- */ -- nss_capwap_msg_init(&capwapmsg, if_num, NSS_CAPWAP_MSG_TYPE_ENABLE_TUNNEL, sizeof(struct nss_capwap_enable_tunnel_msg), nss_capwapmgr_msg_event_receive, dev); -- -- status = nss_capwapmgr_tx_msg_sync(ctx, dev, &capwapmsg); -- if (status != NSS_TX_SUCCESS) { -- nss_capwapmgr_warn("%px: ctx: CMD: %d Tunnel error : %d \n", ctx, NSS_CAPWAP_MSG_TYPE_ENABLE_TUNNEL, status); -- } -- -- return status; --} -- --/* -- * nss_capwapmgr_tunnel_action() -- * Common function for CAPWAP tunnel operation messages without -- * any message data structures. -- */ --static nss_tx_status_t nss_capwapmgr_tunnel_action(struct nss_ctx_instance *ctx, struct net_device *dev, uint32_t if_num, nss_capwap_msg_type_t cmd) --{ -- struct nss_capwap_msg capwapmsg; -- nss_tx_status_t status; -- -- /* -- * Prepare the tunnel configuration parameter to send to NSS FW -- */ -- memset(&capwapmsg, 0, sizeof(struct nss_capwap_msg)); -- -- /* -- * Send CAPWAP data tunnel command to NSS -- */ -- nss_capwap_msg_init(&capwapmsg, if_num, cmd, 0, nss_capwapmgr_msg_event_receive, dev); -- -- status = nss_capwapmgr_tx_msg_sync(ctx, dev, &capwapmsg); -- if (status != NSS_TX_SUCCESS) { -- nss_capwapmgr_warn("%px: ctx: CMD: %d Tunnel error : %d \n", ctx, cmd, status); -- } -- -- return status; --} -- --/* - * nss_capwapmgr_get_dtls_netdev() - * API for getting the dtls netdev associated to the capwap tunnel -- * -- * The caller is expected to do a dev_put() to release the reference. - */ - struct net_device *nss_capwapmgr_get_dtls_netdev(struct net_device *capwap_dev, uint8_t tunnel_id) - { - struct nss_capwapmgr_tunnel *t; - struct net_device *dtls_dev; - -- dev_hold(capwap_dev); - t = nss_capwapmgr_verify_tunnel_param(capwap_dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: can't find tunnel: %d\n", capwap_dev, tunnel_id); -- dev_put(capwap_dev); - return NULL; - } - - dtls_dev = t->dtls_dev; -- dev_hold(dtls_dev); -- -- dev_put(capwap_dev); - -+ dev_hold(dtls_dev); - return dtls_dev; - } - EXPORT_SYMBOL(nss_capwapmgr_get_dtls_netdev); -@@ -1394,16 +1335,15 @@ nss_capwapmgr_status_t nss_capwapmgr_upd - return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: can't find tunnel: %d\n", dev, tunnel_id); -- dev_put(dev); - return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -+ dev_hold(dev); - priv = netdev_priv(dev); -- nss_capwapmgr_info("%px: %d: tunnel update MTU is being called\n", dev, t->if_num_inner); -+ nss_capwapmgr_info("%px: %d: tunnel update MTU is being called\n", dev, t->if_num); - - /* - * Prepare the tunnel configuration parameter to send to NSS FW -@@ -1413,7 +1353,7 @@ nss_capwapmgr_status_t nss_capwapmgr_upd - /* - * Send CAPWAP data tunnel command to NSS - */ -- nss_capwap_msg_init(&capwapmsg, t->if_num_inner, NSS_CAPWAP_MSG_TYPE_UPDATE_PATH_MTU, -+ nss_capwap_msg_init(&capwapmsg, t->if_num, NSS_CAPWAP_MSG_TYPE_UPDATE_PATH_MTU, - sizeof(struct nss_capwap_path_mtu_msg), nss_capwapmgr_msg_event_receive, dev); - capwapmsg.msg.mtu.path_mtu = htonl(mtu); - status = nss_capwapmgr_tx_msg_sync(priv->nss_ctx, dev, &capwapmsg); -@@ -1473,22 +1413,20 @@ nss_capwapmgr_status_t nss_capwapmgr_upd - { - struct nss_capwapmgr_priv *priv; - struct nss_capwapmgr_tunnel *t; -+ nss_capwapmgr_status_t status; - nss_tx_status_t nss_status; -- nss_capwapmgr_status_t status = NSS_CAPWAPMGR_SUCCESS; - struct nss_ipv6_create *v6; - uint8_t mac_addr_old[ETH_ALEN]; - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: can't find tunnel: %d\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -- -+ dev_hold(dev); - priv = netdev_priv(dev); -- nss_capwapmgr_info("%px: %d: tunnel update mac Addr is being called\n", dev, tunnel_id); -+ nss_capwapmgr_info("%px: %d: tunnel update mac Addr is being called\n", dev, t->if_num); - - /* - * Update the IPv4/IPv6 rule with the new destination mac address for flow and return. -@@ -1505,10 +1443,11 @@ nss_capwapmgr_status_t nss_capwapmgr_upd - if (nss_status != NSS_TX_SUCCESS) { - nss_capwapmgr_warn("%px: Update Destination Mac for tunnel error : %d \n", dev, nss_status); - memcpy(t->ip_rule.v4.src_mac, mac_addr_old, ETH_ALEN); -- status = NSS_CAPWAPMGR_FAILURE_IP_RULE; - } - -- goto done; -+ dev_put(dev); -+ return status; -+ - } - - v6 = &t->ip_rule.v6; -@@ -1519,10 +1458,10 @@ nss_capwapmgr_status_t nss_capwapmgr_upd - if (nss_status != NSS_TX_SUCCESS) { - nss_capwapmgr_warn("%px: Update Destination Mac for tunnel error : %d \n", dev, nss_status); - memcpy(t->ip_rule.v6.src_mac, mac_addr_old, ETH_ALEN); -- status = NSS_CAPWAPMGR_FAILURE_IP_RULE; -+ dev_put(dev); -+ return NSS_CAPWAPMGR_FAILURE_IP_RULE; - } - --done: - dev_put(dev); - return status; - } -@@ -1532,24 +1471,23 @@ EXPORT_SYMBOL(nss_capwapmgr_update_dest_ - * nss_capwapmgr_update_src_interface() - * API for updating Source Interface - */ --nss_capwapmgr_status_t nss_capwapmgr_update_src_interface(struct net_device *dev, uint8_t tunnel_id, uint32_t src_interface_num) -+nss_capwapmgr_status_t nss_capwapmgr_update_src_interface(struct net_device *dev, uint8_t tunnel_id, int32_t src_interface_num) - { - struct nss_capwapmgr_priv *priv; - struct nss_capwapmgr_tunnel *t; -+ nss_capwapmgr_status_t status; - nss_tx_status_t nss_status; - uint32_t outer_trustsec_enabled, dtls_enabled, forward_if_num, src_interface_num_temp; - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: can't find tunnel: %d\n", dev, tunnel_id); -- dev_put(dev); - return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -- -+ dev_hold(dev); - priv = netdev_priv(dev); -- nss_capwapmgr_info("%px: %d: tunnel update source interface is being called\n", dev, tunnel_id); -+ nss_capwapmgr_info("%px: %d: tunnel update source interface is being called\n", dev, t->if_num); - outer_trustsec_enabled = t->capwap_rule.enabled_features & NSS_CAPWAPMGR_FEATURE_OUTER_TRUSTSEC_ENABLED; - dtls_enabled = t->capwap_rule.enabled_features & NSS_CAPWAPMGR_FEATURE_DTLS_ENABLED; - -@@ -1558,7 +1496,7 @@ nss_capwapmgr_status_t nss_capwapmgr_upd - */ - if (outer_trustsec_enabled) { - if (!dtls_enabled) { -- forward_if_num = nss_capwap_ifnum_with_core_id(t->if_num_outer); -+ forward_if_num = nss_capwap_ifnum_with_core_id(t->if_num); - } else { - forward_if_num = nss_dtlsmgr_get_interface(t->dtls_dev, NSS_DTLSMGR_INTERFACE_TYPE_OUTER); - } -@@ -1566,7 +1504,6 @@ nss_capwapmgr_status_t nss_capwapmgr_upd - nss_status = nss_trustsec_tx_update_nexthop(forward_if_num, src_interface_num, t->capwap_rule.outer_sgt_value); - if (nss_status != NSS_TX_SUCCESS) { - nss_capwapmgr_warn("%px: unconfigure trustsec_tx failed\n", dev); -- dev_put(dev); - return NSS_CAPWAPMGR_FAILURE_UNCONFIGURE_TRUSTSEC_TX; - } - -@@ -1575,7 +1512,6 @@ nss_capwapmgr_status_t nss_capwapmgr_upd - } else { - t->ip_rule.v6.src_interface_num = src_interface_num; - } -- dev_put(dev); - return NSS_CAPWAPMGR_SUCCESS; - } - -@@ -1659,8 +1595,7 @@ nss_capwapmgr_status_t nss_capwapmgr_upd - } - } - t->tunnel_state |= NSS_CAPWAPMGR_TUNNEL_STATE_IPRULE_CONFIGURED; -- dev_put(dev); -- return NSS_CAPWAPMGR_SUCCESS; -+ return status; - } - EXPORT_SYMBOL(nss_capwapmgr_update_src_interface); - -@@ -1997,7 +1932,7 @@ EXPORT_SYMBOL(nss_capwapmgr_dscp_rule_cr - nss_capwapmgr_status_t nss_capwapmgr_configure_dtls(struct net_device *dev, uint8_t tunnel_id, uint8_t enable_dtls, struct nss_dtlsmgr_config *in_data) - { - struct nss_capwapmgr_priv *priv; -- struct nss_capwap_msg capwapmsg_inner, capwapmsg_outer; -+ struct nss_capwap_msg capwapmsg; - struct nss_capwapmgr_tunnel *t; - struct nss_ipv4_destroy v4; - struct nss_ipv6_destroy v6; -@@ -2005,11 +1940,9 @@ nss_capwapmgr_status_t nss_capwapmgr_con - nss_capwapmgr_status_t status; - uint32_t ip_if_num, dtls_enabled, outer_trustsec_enabled; - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: can't find tunnel: %d\n", dev, tunnel_id); -- dev_put(dev); - return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -@@ -2017,7 +1950,6 @@ nss_capwapmgr_status_t nss_capwapmgr_con - dtls_enabled = t->capwap_rule.enabled_features & NSS_CAPWAPMGR_FEATURE_DTLS_ENABLED; - if ((enable_dtls && dtls_enabled) || (!enable_dtls && !dtls_enabled)) { - nss_capwapmgr_warn("%px: nothing changed for tunnel: %d\n", dev, tunnel_id); -- dev_put(dev); - return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -@@ -2027,31 +1959,23 @@ nss_capwapmgr_status_t nss_capwapmgr_con - */ - if (t->tunnel_state & NSS_CAPWAPMGR_TUNNEL_STATE_ENABLED) { - nss_capwapmgr_warn("%px: tunnel %d is already enabled\n", dev, tunnel_id); -- dev_put(dev); - return NSS_CAPWAPMGR_FAILURE_TUNNEL_ENABLED; - } - - /* - * Prepare DTLS configure message - */ -- memset(&capwapmsg_inner, 0, sizeof(struct nss_capwap_msg)); -- nss_capwap_msg_init(&capwapmsg_inner, t->if_num_inner, NSS_CAPWAP_MSG_TYPE_DTLS, -- sizeof(struct nss_capwap_dtls_msg), nss_capwapmgr_msg_event_receive, dev); -- -- memset(&capwapmsg_outer, 0, sizeof(struct nss_capwap_msg)); -- nss_capwap_msg_init(&capwapmsg_outer, t->if_num_outer, NSS_CAPWAP_MSG_TYPE_DTLS, -+ memset(&capwapmsg, 0, sizeof(struct nss_capwap_msg)); -+ nss_capwap_msg_init(&capwapmsg, t->if_num, NSS_CAPWAP_MSG_TYPE_DTLS, - sizeof(struct nss_capwap_dtls_msg), nss_capwapmgr_msg_event_receive, dev); - -- - if (!enable_dtls) { - nss_capwapmgr_info("%px disabling DTLS for tunnel: %d\n", dev, tunnel_id); - -- ip_if_num = nss_capwap_ifnum_with_core_id(t->if_num_outer); -- capwapmsg_inner.msg.dtls.enable = 0; -- capwapmsg_inner.msg.dtls.dtls_inner_if_num = t->capwap_rule.dtls_inner_if_num; -- capwapmsg_inner.msg.dtls.mtu_adjust = 0; -- -- capwapmsg_outer.msg.dtls.enable = 0; -+ ip_if_num = nss_capwap_ifnum_with_core_id(t->if_num); -+ capwapmsg.msg.dtls.enable = 0; -+ capwapmsg.msg.dtls.dtls_inner_if_num = t->capwap_rule.dtls_inner_if_num; -+ capwapmsg.msg.dtls.mtu_adjust = 0; - - /* - * Unconfigure trustsec tx first -@@ -2060,7 +1984,6 @@ nss_capwapmgr_status_t nss_capwapmgr_con - nss_status = nss_trustsec_tx_unconfigure_sgt(t->capwap_rule.dtls_inner_if_num, t->capwap_rule.outer_sgt_value); - if (nss_status != NSS_TX_SUCCESS) { - nss_capwapmgr_warn("%px: unconfigure trustsec_tx failed\n", dev); -- dev_put(dev); - return NSS_CAPWAPMGR_FAILURE_UNCONFIGURE_TRUSTSEC_TX; - } - } -@@ -2075,7 +1998,6 @@ nss_capwapmgr_status_t nss_capwapmgr_con - */ - if (!in_data) { - nss_capwapmgr_info("%px: dtls in_data required to create dtls tunnel\n", dev); -- dev_put(dev); - return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -@@ -2085,12 +2007,11 @@ nss_capwapmgr_status_t nss_capwapmgr_con - * ensure that the user does not configure this mode accidentally. - */ - in_data->flags &= ~NSS_DTLSMGR_ENCAP_METADATA; -- in_data->decap.nexthop_ifnum = nss_capwap_ifnum_with_core_id(t->if_num_outer); -+ in_data->decap.nexthop_ifnum = nss_capwap_ifnum_with_core_id(t->if_num); - - t->dtls_dev = nss_dtlsmgr_session_create(in_data); - if (!t->dtls_dev) { - nss_capwapmgr_warn("%px: cannot create DTLS session\n", dev); -- dev_put(dev); - return NSS_CAPWAPMGR_FAILURE_DI_ALLOC_FAILED; - } - -@@ -2104,20 +2025,17 @@ nss_capwapmgr_status_t nss_capwapmgr_con - - ip_if_num = nss_dtlsmgr_get_interface(t->dtls_dev, NSS_DTLSMGR_INTERFACE_TYPE_OUTER); - -- capwapmsg_inner.msg.dtls.enable = 1; -- capwapmsg_inner.msg.dtls.dtls_inner_if_num = t->capwap_rule.dtls_inner_if_num; -- capwapmsg_inner.msg.dtls.mtu_adjust = t->capwap_rule.mtu_adjust; -- -- capwapmsg_outer.msg.dtls.enable = 1; -+ capwapmsg.msg.dtls.enable = 1; -+ capwapmsg.msg.dtls.dtls_inner_if_num = t->capwap_rule.dtls_inner_if_num; -+ capwapmsg.msg.dtls.mtu_adjust = t->capwap_rule.mtu_adjust; - - /* - * Unconfigure trustsec tx first - */ - if (outer_trustsec_enabled) { -- nss_status = nss_trustsec_tx_unconfigure_sgt(t->if_num_outer, t->capwap_rule.outer_sgt_value); -+ nss_status = nss_trustsec_tx_unconfigure_sgt(t->if_num, t->capwap_rule.outer_sgt_value); - if (nss_status != NSS_TX_SUCCESS) { - nss_capwapmgr_warn("%px: unconfigure trustsec_tx failed\n", dev); -- dev_put(dev); - return NSS_CAPWAPMGR_FAILURE_UNCONFIGURE_TRUSTSEC_TX; - } - } -@@ -2130,11 +2048,11 @@ nss_capwapmgr_status_t nss_capwapmgr_con - nss_status = nss_trustsec_tx_configure_sgt(ip_if_num, t->capwap_rule.gmac_ifnum, t->capwap_rule.outer_sgt_value); - if (nss_status != NSS_TX_SUCCESS) { - nss_capwapmgr_warn("%px: configure trustsec_tx failed\n", dev); -- dev_put(dev); - return NSS_CAPWAPMGR_FAILURE_CONFIGURE_TRUSTSEC_TX; - } - } - -+ dev_hold(dev); - priv = netdev_priv(dev); - - /* -@@ -2200,18 +2118,11 @@ nss_capwapmgr_status_t nss_capwapmgr_con - * Now configure capwap dtls - */ - t->tunnel_state |= NSS_CAPWAPMGR_TUNNEL_STATE_IPRULE_CONFIGURED; -- status = nss_capwapmgr_tx_msg_sync(priv->nss_ctx, dev, &capwapmsg_inner); -- if (status != NSS_CAPWAPMGR_SUCCESS) { -- nss_capwapmgr_warn("%px: configure DTLS failed for inner node: %d\n", dev, status); -- dev_put(dev); -- return status; -- } -- -- status = nss_capwapmgr_tx_msg_sync(priv->nss_ctx, dev, &capwapmsg_outer); -+ status = nss_capwapmgr_tx_msg_sync(priv->nss_ctx, dev, &capwapmsg); - if (status != NSS_CAPWAPMGR_SUCCESS) { -- nss_capwapmgr_warn("%px: configure DTLS failed for outer node: %d\n", dev, status); -+ nss_capwapmgr_warn("%px: configure DTLS failed : %d\n", dev, status); - dev_put(dev); -- return status; -+ return nss_status; - } - - if (enable_dtls) { -@@ -2227,8 +2138,6 @@ EXPORT_SYMBOL(nss_capwapmgr_configure_dt - /* - * nss_capwapmgr_verify_dtls_rekey_param() - * Validate the rekey param for a DTLS tunnel and return the DTLS netdevice -- * -- * The caller should hold the reference on the net device before calling. - */ - static inline struct net_device *nss_capwapmgr_verify_dtls_rekey_param(struct net_device *dev, uint8_t tunnel_id, - struct nss_dtlsmgr_config_update *udata) -@@ -2261,27 +2170,16 @@ static inline struct net_device *nss_cap - nss_capwapmgr_status_t nss_capwapmgr_dtls_rekey_rx_cipher_update(struct net_device *dev, uint8_t tunnel_id, - struct nss_dtlsmgr_config_update *udata) - { -- struct net_device *dtls_ndev; -- -- dev_hold(dev); -- dtls_ndev = nss_capwapmgr_verify_dtls_rekey_param(dev, tunnel_id, udata); -- dev_put(dev); -- -- if (!dtls_ndev) { -- goto fail; -- } -+ struct net_device *dtls_ndev = nss_capwapmgr_verify_dtls_rekey_param(dev, tunnel_id, udata); - - /* - * Calling dtlsmgr for rekey - */ - if (nss_dtlsmgr_session_update_decap(dtls_ndev, udata) != NSS_DTLSMGR_OK) { -- goto fail; -+ nss_capwapmgr_warn("%px: tunnel: %d rekey rx cipher update failed\n", dtls_ndev, tunnel_id); -+ return NSS_CAPWAPMGR_FAILURE_INVALID_DTLS_CFG; - } - return NSS_CAPWAPMGR_SUCCESS; -- --fail: -- nss_capwapmgr_warn("%px: tunnel: %d rekey rx cipher update failed\n", dtls_ndev, tunnel_id); -- return NSS_CAPWAPMGR_FAILURE_INVALID_DTLS_CFG; - } - EXPORT_SYMBOL(nss_capwapmgr_dtls_rekey_rx_cipher_update); - -@@ -2292,27 +2190,16 @@ EXPORT_SYMBOL(nss_capwapmgr_dtls_rekey_r - nss_capwapmgr_status_t nss_capwapmgr_dtls_rekey_tx_cipher_update(struct net_device *dev, uint8_t tunnel_id, - struct nss_dtlsmgr_config_update *udata) - { -- struct net_device *dtls_ndev; -- -- dev_hold(dev); -- dtls_ndev = nss_capwapmgr_verify_dtls_rekey_param(dev, tunnel_id, udata); -- dev_put(dev); -- -- if (!dtls_ndev) { -- goto fail; -- } -+ struct net_device *dtls_ndev = nss_capwapmgr_verify_dtls_rekey_param(dev, tunnel_id, udata); - - /* - * Calling dtlsmgr for rekey - */ - if (nss_dtlsmgr_session_update_encap(dtls_ndev, udata) != NSS_DTLSMGR_OK) { -- goto fail; -+ nss_capwapmgr_warn("%px: tunnel: %d rekey tx cipher update failed\n", dtls_ndev, tunnel_id); -+ return NSS_CAPWAPMGR_FAILURE_INVALID_DTLS_CFG; - } - return NSS_CAPWAPMGR_SUCCESS; -- --fail: -- nss_capwapmgr_warn("%px: tunnel: %d rekey rx cipher update failed\n", dtls_ndev, tunnel_id); -- return NSS_CAPWAPMGR_FAILURE_INVALID_DTLS_CFG; - } - EXPORT_SYMBOL(nss_capwapmgr_dtls_rekey_tx_cipher_update); - -@@ -2323,20 +2210,16 @@ EXPORT_SYMBOL(nss_capwapmgr_dtls_rekey_t - nss_capwapmgr_status_t nss_capwapmgr_dtls_rekey_rx_cipher_switch(struct net_device *dev, uint8_t tunnel_id) - { - struct nss_capwapmgr_tunnel *t; -- nss_capwapmgr_status_t status = NSS_CAPWAPMGR_SUCCESS; - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: can't find tunnel: %d\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - - if (!(t->capwap_rule.enabled_features & NSS_CAPWAPMGR_FEATURE_DTLS_ENABLED)) { - nss_capwapmgr_warn("%px: tunnel does not enable DTLS: %d\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - - /* -@@ -2344,12 +2227,10 @@ nss_capwapmgr_status_t nss_capwapmgr_dtl - */ - if (!nss_dtlsmgr_session_switch_decap(t->dtls_dev)) { - nss_capwapmgr_warn("%px: tunnel: %d rekey rx cipher switch failed\n", t->dtls_dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_INVALID_DTLS_CFG; -+ return NSS_CAPWAPMGR_FAILURE_INVALID_DTLS_CFG; - } - --done: -- dev_put(dev); -- return status; -+ return NSS_CAPWAPMGR_SUCCESS; - } - EXPORT_SYMBOL(nss_capwapmgr_dtls_rekey_rx_cipher_switch); - -@@ -2360,20 +2241,16 @@ EXPORT_SYMBOL(nss_capwapmgr_dtls_rekey_r - nss_capwapmgr_status_t nss_capwapmgr_dtls_rekey_tx_cipher_switch(struct net_device *dev, uint8_t tunnel_id) - { - struct nss_capwapmgr_tunnel *t; -- nss_capwapmgr_status_t status = NSS_CAPWAPMGR_SUCCESS; - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: can't find tunnel: %d\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - - if (!(t->capwap_rule.enabled_features & NSS_CAPWAPMGR_FEATURE_DTLS_ENABLED)) { - nss_capwapmgr_warn("%px: tunnel does not enable DTLS: %d\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - - /* -@@ -2381,12 +2258,10 @@ nss_capwapmgr_status_t nss_capwapmgr_dtl - */ - if (!nss_dtlsmgr_session_switch_encap(t->dtls_dev)) { - nss_capwapmgr_warn("%px: tunnel: %d rekey tx cipher switch failed\n", t->dtls_dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_INVALID_DTLS_CFG; -+ return NSS_CAPWAPMGR_FAILURE_INVALID_DTLS_CFG; - } - --done: -- dev_put(dev); -- return status; -+ return NSS_CAPWAPMGR_SUCCESS; - } - EXPORT_SYMBOL(nss_capwapmgr_dtls_rekey_tx_cipher_switch); - -@@ -2400,22 +2275,20 @@ nss_capwapmgr_status_t nss_capwapmgr_cha - struct nss_capwapmgr_priv *priv; - struct nss_capwap_msg capwapmsg; - struct nss_capwapmgr_tunnel *t; -- nss_capwapmgr_status_t status = NSS_CAPWAPMGR_SUCCESS; -+ nss_capwapmgr_status_t status; - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: can't find tunnel: %d\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - - if (ver > NSS_CAPWAP_VERSION_V2) { - nss_capwapmgr_warn("%px: un-supported Version: %d\n", dev, ver); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -+ dev_hold(dev); - priv = netdev_priv(dev); - - /* -@@ -2426,21 +2299,50 @@ nss_capwapmgr_status_t nss_capwapmgr_cha - /* - * Send CAPWAP data tunnel command to NSS - */ -- nss_capwap_msg_init(&capwapmsg, t->if_num_inner, NSS_CAPWAP_MSG_TYPE_VERSION, -+ nss_capwap_msg_init(&capwapmsg, t->if_num, NSS_CAPWAP_MSG_TYPE_VERSION, - sizeof(struct nss_capwap_version_msg), nss_capwapmgr_msg_event_receive, dev); - capwapmsg.msg.version.version = ver; - status = nss_capwapmgr_tx_msg_sync(priv->nss_ctx, dev, &capwapmsg); - if (status != NSS_CAPWAPMGR_SUCCESS) { - nss_capwapmgr_warn("%px: Update Path MTU Tunnel error : %d \n", dev, status); -+ dev_put(dev); -+ return status; - } - --done: - dev_put(dev); - return status; - } - EXPORT_SYMBOL(nss_capwapmgr_change_version); - - /* -+ * nss_capwapmgr_tunnel_action() -+ * Common function for CAPWAP tunnel operation messages without -+ * any message data structures. -+ */ -+static nss_tx_status_t nss_capwapmgr_tunnel_action(struct nss_ctx_instance *ctx, struct net_device *dev, uint32_t if_num, nss_capwap_msg_type_t cmd) -+{ -+ struct nss_capwap_msg capwapmsg; -+ nss_tx_status_t status; -+ -+ /* -+ * Prepare the tunnel configuration parameter to send to NSS FW -+ */ -+ memset(&capwapmsg, 0, sizeof(struct nss_capwap_msg)); -+ -+ /* -+ * Send CAPWAP data tunnel command to NSS -+ */ -+ nss_capwap_msg_init(&capwapmsg, if_num, cmd, 0, nss_capwapmgr_msg_event_receive, dev); -+ status = nss_capwapmgr_tx_msg_sync(ctx, dev, &capwapmsg); -+ if (status != NSS_TX_SUCCESS) { -+ nss_capwapmgr_warn("%px: ctx: CMD: %d Tunnel error : %d \n", ctx, cmd, status); -+ return status; -+ } -+ -+ return status; -+} -+ -+/* - * nss_capwapmgr_enable_tunnel() - * API for enabling a data tunnel - */ -@@ -2448,41 +2350,28 @@ nss_capwapmgr_status_t nss_capwapmgr_ena - { - struct nss_capwapmgr_priv *priv; - struct nss_capwapmgr_tunnel *t; -- nss_capwapmgr_status_t status = NSS_CAPWAPMGR_SUCCESS; -+ nss_tx_status_t ret; - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: can't find tunnel: %d\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - - if (t->tunnel_state & NSS_CAPWAPMGR_TUNNEL_STATE_ENABLED) { - nss_capwapmgr_warn("%px: tunnel %d is already enabled\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_TUNNEL_ENABLED; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_TUNNEL_ENABLED; - } - -+ dev_hold(dev); - priv = netdev_priv(dev); -- nss_capwapmgr_info("%px: Inner:%d Outer:%d. Tunnel enable is being called\n", dev, t->if_num_inner, t->if_num_outer); -- -- status = nss_capwapmgr_tx_msg_enable_tunnel(priv->nss_ctx, dev, t->if_num_inner,t->if_num_outer); -- if (status != NSS_CAPWAPMGR_SUCCESS) { -- goto done; -+ nss_capwapmgr_info("%px: %d: tunnel enable is being called\n", dev, t->if_num); -+ ret = nss_capwapmgr_tunnel_action(priv->nss_ctx, dev, t->if_num, NSS_CAPWAP_MSG_TYPE_ENABLE_TUNNEL); -+ if (ret == NSS_TX_SUCCESS) { -+ t->tunnel_state |= NSS_CAPWAPMGR_TUNNEL_STATE_ENABLED; - } -- -- status = nss_capwapmgr_tx_msg_enable_tunnel(priv->nss_ctx, dev, t->if_num_outer,t->if_num_inner); -- if(status != NSS_CAPWAPMGR_SUCCESS) { -- nss_capwapmgr_tunnel_action(priv->nss_ctx, dev, t->if_num_inner,NSS_CAPWAP_MSG_TYPE_DISABLE_TUNNEL); -- goto done; -- } -- -- t->tunnel_state |= NSS_CAPWAPMGR_TUNNEL_STATE_ENABLED; -- --done: - dev_put(dev); -- return status; -+ return ret; - } - EXPORT_SYMBOL(nss_capwapmgr_enable_tunnel); - -@@ -2494,44 +2383,28 @@ nss_capwapmgr_status_t nss_capwapmgr_dis - { - struct nss_capwapmgr_priv *priv; - struct nss_capwapmgr_tunnel *t; -- nss_capwapmgr_status_t status = NSS_CAPWAPMGR_SUCCESS; -+ nss_tx_status_t ret; - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: can't find tunnel: %d\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - - if (!(t->tunnel_state & NSS_CAPWAPMGR_TUNNEL_STATE_ENABLED)) { -- nss_capwapmgr_warn("%px: tunnel %d is already disabled\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_TUNNEL_DISABLED; -- goto done; -+ nss_capwapmgr_warn("%px: tunnel %d is already enabled\n", dev, tunnel_id); -+ return NSS_CAPWAPMGR_FAILURE_TUNNEL_DISABLED; - } - -+ dev_hold(dev); - priv = netdev_priv(dev); -- nss_capwapmgr_info("%px: Inner:%d Outer:%d. Tunnel disable is being called\n", dev, t->if_num_inner, t->if_num_outer); -- -- status = nss_capwapmgr_tunnel_action(priv->nss_ctx, dev, t->if_num_inner,NSS_CAPWAP_MSG_TYPE_DISABLE_TUNNEL); -- if (status != NSS_CAPWAPMGR_SUCCESS) { -- status = NSS_CAPWAPMGR_FAILURE_TUNNEL_DISABLED; -- nss_capwapmgr_warn("%px: tunnel %d disable failed\n", dev, tunnel_id); -- goto done; -- } -- -- status = nss_capwapmgr_tunnel_action(priv->nss_ctx, dev, t->if_num_outer,NSS_CAPWAP_MSG_TYPE_DISABLE_TUNNEL); -- if (status != NSS_CAPWAPMGR_SUCCESS) { -- nss_capwapmgr_warn("%px: tunnel %d disable failed\n", dev, tunnel_id); -- nss_capwapmgr_tx_msg_enable_tunnel(priv->nss_ctx, dev, t->if_num_inner, t->if_num_outer); -- goto done; -+ nss_capwapmgr_info("%px: %d: tunnel disable is being called\n", dev, t->if_num); -+ ret = nss_capwapmgr_tunnel_action(priv->nss_ctx, dev, t->if_num, NSS_CAPWAP_MSG_TYPE_DISABLE_TUNNEL); -+ if (ret == NSS_TX_SUCCESS) { -+ t->tunnel_state &= ~NSS_CAPWAPMGR_TUNNEL_STATE_ENABLED; - } -- -- t->tunnel_state &= ~NSS_CAPWAPMGR_TUNNEL_STATE_ENABLED; -- --done: - dev_put(dev); -- return status; -+ return ret; - } - EXPORT_SYMBOL(nss_capwapmgr_disable_tunnel); - -@@ -2545,7 +2418,7 @@ static nss_capwapmgr_status_t nss_capwap - struct nss_capwapmgr_priv *priv; - struct nss_capwapmgr_tunnel *t; - nss_capwapmgr_status_t status = NSS_CAPWAPMGR_SUCCESS; -- int32_t capwap_if_num_inner, capwap_if_num_outer, forward_if_num; -+ int32_t capwap_if_num, forward_if_num; - uint16_t type_flags = 0; - nss_tx_status_t nss_status = NSS_TX_SUCCESS; - uint32_t dtls_enabled = capwap_rule->enabled_features & NSS_CAPWAPMGR_FEATURE_DTLS_ENABLED; -@@ -2578,44 +2451,28 @@ static nss_capwapmgr_status_t nss_capwap - return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (t) { - nss_capwapmgr_warn("%px: tunnel: %d already created\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_TUNNEL_EXISTS; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_TUNNEL_EXISTS; - } - -- capwap_if_num_inner = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_HOST_INNER); -- if (capwap_if_num_inner < 0) { -- nss_capwapmgr_warn("%px: di returned error : %d\n", dev, capwap_if_num_inner); -- status = NSS_CAPWAPMGR_FAILURE_DI_ALLOC_FAILED; -- goto done; -+ capwap_if_num = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP); -+ if (capwap_if_num < 0) { -+ nss_capwapmgr_warn("%px: di returned error : %d\n", dev, capwap_if_num); -+ return NSS_CAPWAPMGR_FAILURE_DI_ALLOC_FAILED; - } - -- if (nss_capwapmgr_register_with_nss(capwap_if_num_inner, dev) != NSS_CAPWAPMGR_SUCCESS) { -- nss_capwapmgr_warn("%d: NSS CAPWAP register with NSS failed", capwap_if_num_inner); -- status = NSS_CAPWAPMGR_FAILURE_REGISTER_NSS; -- goto fail1; -- } -- -- capwap_if_num_outer = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_OUTER); -- if (capwap_if_num_outer < 0) { -- nss_capwapmgr_warn("%px: di returned error : %d\n", dev, capwap_if_num_outer); -- status = NSS_CAPWAPMGR_FAILURE_DI_ALLOC_FAILED; -- goto fail2; -- } -- -- if (nss_capwapmgr_register_with_nss(capwap_if_num_outer, dev) != NSS_CAPWAPMGR_SUCCESS) { -- nss_capwapmgr_warn("%d: NSS CAPWAP register with NSS failed", capwap_if_num_outer); -- status = NSS_CAPWAPMGR_FAILURE_REGISTER_NSS; -- goto fail3; -+ if (nss_capwapmgr_register_with_nss(capwap_if_num, dev) != NSS_CAPWAPMGR_SUCCESS) { -+ nss_capwapmgr_warn("%d: NSS CAPWAP register with NSS failed", capwap_if_num); -+ (void)nss_dynamic_interface_dealloc_node(capwap_if_num, NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP); -+ return NSS_CAPWAPMGR_FAILURE_REGISTER_NSS; - } - - if (!dtls_enabled) { - capwap_rule->mtu_adjust = 0; - capwap_rule->dtls_inner_if_num = 0; -- forward_if_num = nss_capwap_ifnum_with_core_id(capwap_if_num_outer); -+ forward_if_num = nss_capwap_ifnum_with_core_id(capwap_if_num); - } else { - /* - * We only support the METADATA mode for pure DTLS tunnels; in CAPWAP-DTLS -@@ -2623,13 +2480,14 @@ static nss_capwapmgr_status_t nss_capwap - * ensure that the user does not configure this mode accidentally. - */ - in_data->flags &= ~NSS_DTLSMGR_ENCAP_METADATA; -- in_data->decap.nexthop_ifnum = nss_capwap_ifnum_with_core_id(capwap_if_num_outer); -+ in_data->decap.nexthop_ifnum = nss_capwap_ifnum_with_core_id(capwap_if_num); - - t->dtls_dev = nss_dtlsmgr_session_create(in_data); - if (!t->dtls_dev) { - nss_capwapmgr_warn("%px: NSS DTLS node alloc failed\n", dev); -- status = NSS_CAPWAPMGR_FAILURE_DI_ALLOC_FAILED; -- goto fail4; -+ nss_capwapmgr_unregister_with_nss(capwap_if_num); -+ (void)nss_dynamic_interface_dealloc_node(capwap_if_num, NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP); -+ return NSS_CAPWAPMGR_FAILURE_DI_ALLOC_FAILED; - } - capwap_rule->dtls_inner_if_num = nss_dtlsmgr_get_interface(t->dtls_dev, NSS_DTLSMGR_INTERFACE_TYPE_INNER); - forward_if_num = nss_dtlsmgr_get_interface(t->dtls_dev, NSS_DTLSMGR_INTERFACE_TYPE_OUTER); -@@ -2650,7 +2508,7 @@ static nss_capwapmgr_status_t nss_capwap - if (nss_status != NSS_TX_SUCCESS) { - nss_capwapmgr_warn("%px: configure trustsectx node failed\n", dev); - status = NSS_CAPWAPMGR_FAILURE_CONFIGURE_TRUSTSEC_TX; -- goto fail5; -+ goto fail; - } - } - -@@ -2706,20 +2564,12 @@ static nss_capwapmgr_status_t nss_capwap - capwap_rule->encap.dest_ip.ip.ipv6[3] = htonl(v6->src_ip[3]); - } - -- status = nss_capwapmgr_create_capwap_rule(dev, capwap_if_num_inner, capwap_rule, type_flags); -- nss_capwapmgr_info("%px: dynamic interface if_num is :%d and capwap tunnel status:%d\n", dev, capwap_if_num_inner, status); -+ status = nss_capwapmgr_create_capwap_rule(dev, capwap_if_num, capwap_rule, type_flags); -+ nss_capwapmgr_info("%px: dynamic interface if_num is :%d and capwap tunnel status:%d\n", dev, capwap_if_num, status); - if (status != NSS_CAPWAPMGR_SUCCESS) { -- nss_capwapmgr_warn("%px: %d: CAPWAP rule create failed with status: %d", dev, capwap_if_num_inner, status); -+ nss_capwapmgr_warn("%px: %d: CAPWAP rule create failed with status: %d", dev, capwap_if_num, status); - status = NSS_CAPWAPMGR_FAILURE_CAPWAP_RULE; -- goto fail5; -- } -- -- status = nss_capwapmgr_create_capwap_rule(dev, capwap_if_num_outer, capwap_rule, type_flags); -- nss_capwapmgr_info("%px: dynamic interface if_num is :%d and capwap tunnel status:%d\n", dev, capwap_if_num_outer, status); -- if (status != NSS_CAPWAPMGR_SUCCESS) { -- nss_capwapmgr_warn("%px: %d: CAPWAP rule create failed with status: %d", dev, capwap_if_num_outer, status); -- status = NSS_CAPWAPMGR_FAILURE_CAPWAP_RULE; -- goto fail5; -+ goto fail; - } - - if (v4) { -@@ -2733,12 +2583,13 @@ static nss_capwapmgr_status_t nss_capwap - if (nss_status != NSS_TX_SUCCESS) { - nss_capwapmgr_warn("%px: %d: IPv4/IPv6 rule create failed with status: %d", dev, forward_if_num, nss_status); - status = NSS_CAPWAPMGR_FAILURE_IP_RULE; -- goto fail5; -+ goto fail; - } - -+ dev_hold(dev); - priv = netdev_priv(dev); - t = &priv->tunnel[tunnel_id]; -- nss_capwapmgr_info("%px: %d: %d: CAPWAP TUNNEL CREATE DONE tunnel_id:%d (%px)\n", dev, capwap_if_num_inner, capwap_if_num_outer, tunnel_id, t); -+ nss_capwapmgr_info("%px: %d: CAPWAP TUNNEL CREATE DONE tunnel_id:%d (%px)\n", dev, capwap_if_num, tunnel_id, t); - - /* - * Keep a copy of rule information. -@@ -2754,33 +2605,22 @@ static nss_capwapmgr_status_t nss_capwap - /* - * Make it globally visible inside the netdev. - */ -- t->if_num_inner = capwap_if_num_inner; -- t->if_num_outer = capwap_if_num_outer; -- priv->if_num_to_tunnel_id[capwap_if_num_inner] = tunnel_id; -- priv->if_num_to_tunnel_id[capwap_if_num_outer] = tunnel_id; -+ t->if_num = capwap_if_num; -+ priv->if_num_to_tunnel_id[capwap_if_num] = tunnel_id; - t->tunnel_state |= NSS_CAPWAPMGR_TUNNEL_STATE_CONFIGURED; - t->tunnel_state |= NSS_CAPWAPMGR_TUNNEL_STATE_IPRULE_CONFIGURED; -- t->type_flags = type_flags; - -- goto done; -+ dev_put(dev); -+ return status; - --fail5: -+fail: -+ nss_capwapmgr_unregister_with_nss(capwap_if_num); -+ (void)nss_dynamic_interface_dealloc_node(capwap_if_num, NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP); - if (dtls_enabled) { - if (nss_dtlsmgr_session_destroy(t->dtls_dev) != NSS_DTLSMGR_OK) { - nss_capwapmgr_warn("%px: failed to destroy DTLS session", t->dtls_dev); - } - } --fail4: -- nss_capwapmgr_unregister_with_nss(capwap_if_num_outer); --fail3: -- (void)nss_dynamic_interface_dealloc_node(capwap_if_num_outer, NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_OUTER); --fail2: -- nss_capwapmgr_unregister_with_nss(capwap_if_num_inner); --fail1: -- (void)nss_dynamic_interface_dealloc_node(capwap_if_num_inner, NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_HOST_INNER); -- --done: -- dev_put(dev); - return status; - } - -@@ -2819,7 +2659,7 @@ static void nss_capwapmgr_tunnel_save_st - save->rx_dup_frag += fstats->rx_dup_frag; - save->rx_oversize_drops += fstats->rx_oversize_drops; - save->rx_frag_timeout_drops += fstats->rx_frag_timeout_drops; -- save->rx_n2h_drops += fstats->rx_n2h_drops; -+ save->rx_queue_full_drops += fstats->rx_queue_full_drops; - save->rx_n2h_queue_full_drops += fstats->rx_n2h_queue_full_drops; - save->rx_mem_failure_drops += fstats->rx_mem_failure_drops; - save->rx_csum_drops += fstats->rx_csum_drops; -@@ -2857,21 +2697,18 @@ nss_capwapmgr_status_t nss_capwapmgr_tun - struct nss_capwapmgr_priv *priv; - struct nss_capwapmgr_tunnel *t; - nss_tx_status_t nss_status = NSS_TX_SUCCESS; -- uint32_t if_num_inner, if_num_outer; -+ uint32_t if_num; - nss_capwapmgr_status_t status = NSS_CAPWAPMGR_SUCCESS; - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: tunnel %d: wrong argument for tunnel destroy\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - - if (!(t->tunnel_state & NSS_CAPWAPMGR_TUNNEL_STATE_CONFIGURED)) { - nss_capwapmgr_warn("%px: tunnel %d is not configured yet\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_TUNNEL_NOT_CFG; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_TUNNEL_NOT_CFG; - } - - /* -@@ -2879,49 +2716,34 @@ nss_capwapmgr_status_t nss_capwapmgr_tun - */ - if (t->tunnel_state & NSS_CAPWAPMGR_TUNNEL_STATE_ENABLED) { - nss_capwapmgr_warn("%px: no destroy alloed for an eanbled tunnel: %d\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_TUNNEL_ENABLED; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_TUNNEL_ENABLED; - } - - if (!(t->capwap_rule.l3_proto == NSS_CAPWAP_TUNNEL_IPV4 || - t->capwap_rule.l3_proto == NSS_CAPWAP_TUNNEL_IPV6)) { - nss_capwapmgr_warn("%px: tunnel %d: wrong argument for l3_proto\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - - if (!(t->capwap_rule.which_udp == NSS_CAPWAP_TUNNEL_UDP || - t->capwap_rule.which_udp == NSS_CAPWAP_TUNNEL_UDPLite)) { - nss_capwapmgr_warn("%px: tunnel %d: wrong argument for which_udp(%d)\n", dev, tunnel_id, t->capwap_rule.which_udp); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -+ dev_hold(dev); - priv = netdev_priv(dev); -- nss_capwapmgr_info("%px: %d: tunnel destroy is being called\n", dev, tunnel_id); -- -- if_num_inner = t->if_num_inner; -- if_num_outer = t->if_num_outer; -+ nss_capwapmgr_info("%px: %d: tunnel destroy is being called\n", dev, t->if_num); -+ if_num = t->if_num; - -- if (priv->if_num_to_tunnel_id[if_num_inner] != tunnel_id) { -+ if (priv->if_num_to_tunnel_id[if_num] != tunnel_id) { - nss_capwapmgr_warn("%px: %d: tunnel_id %d didn't match with tunnel_id :%d\n", -- dev, if_num_inner, tunnel_id, priv->if_num_to_tunnel_id[if_num_inner]); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -- } -- -- if (priv->if_num_to_tunnel_id[if_num_outer] != tunnel_id) { -- nss_capwapmgr_warn("%px: %d: tunnel_id %d didn't match with tunnel_id :%d\n", -- dev, if_num_outer, tunnel_id, priv->if_num_to_tunnel_id[if_num_outer]); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -- } -- -- if (nss_capwap_get_stats(if_num_inner, &stats) == true) { -- nss_capwapmgr_tunnel_save_stats(&global.tunneld, &stats); -+ dev, if_num, tunnel_id, priv->if_num_to_tunnel_id[if_num]); -+ dev_put(dev); -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -- if (nss_capwap_get_stats(if_num_outer, &stats) == true) { -+ if (nss_capwap_get_stats(if_num, &stats) == true) { - nss_capwapmgr_tunnel_save_stats(&global.tunneld, &stats); - } - -@@ -2961,10 +2783,9 @@ nss_capwapmgr_status_t nss_capwapmgr_tun - } - - if (nss_status != NSS_TX_SUCCESS) { -- nss_capwapmgr_warn("%px: Unconfigure IP rule failed for tunnel : %d\n", -- dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_IP_DESTROY_RULE; -- goto done; -+ nss_capwapmgr_warn("%px: %d: Unconfigure IP rule failed for tunnel : %d\n", -+ dev, if_num, tunnel_id); -+ return NSS_CAPWAPMGR_FAILURE_IP_DESTROY_RULE; - } - t->tunnel_state &= ~NSS_CAPWAPMGR_TUNNEL_STATE_IPRULE_CONFIGURED; - } -@@ -2972,45 +2793,36 @@ nss_capwapmgr_status_t nss_capwapmgr_tun - /* - * Destroy CAPWAP rule now. - */ -- status = nss_capwapmgr_tunnel_action(priv->nss_ctx, dev, if_num_outer, NSS_CAPWAP_MSG_TYPE_UNCFG_RULE); -+ status = nss_capwapmgr_tunnel_action(priv->nss_ctx, dev, if_num, NSS_CAPWAP_MSG_TYPE_UNCFG_RULE); - if (status != NSS_CAPWAPMGR_SUCCESS) { - nss_capwapmgr_warn("%px: %d: Unconfigure CAPWAP rule failed for tunnel : %d\n", -- dev, if_num_outer, tunnel_id); -- goto fail; -- -- } -+ dev, if_num, tunnel_id); - -- status = nss_capwapmgr_tunnel_action(priv->nss_ctx, dev, if_num_inner, NSS_CAPWAP_MSG_TYPE_UNCFG_RULE); -- if (status != NSS_CAPWAPMGR_SUCCESS) { -- nss_capwapmgr_warn("%px: %d: Unconfigure CAPWAP rule failed for tunnel : %d\n", -- dev, if_num_inner, tunnel_id); -- status = nss_capwapmgr_create_capwap_rule(dev, if_num_outer, &(t->capwap_rule), t->type_flags); -- if (status != NSS_CAPWAPMGR_SUCCESS) { -- nss_capwapmgr_warn("%px: %d: re creating the CAPWAP rule failed for tunnel : %d\n", -- dev, if_num_inner, tunnel_id); -- goto done; -+ if (t->capwap_rule.l3_proto == NSS_CAPWAP_TUNNEL_IPV4) { -+ nss_status = nss_capwapmgr_configure_ipv4(&t->ip_rule.v4, 0, 0); -+ if (nss_status == NSS_TX_SUCCESS) { -+ t->tunnel_state |= NSS_CAPWAPMGR_TUNNEL_STATE_IPRULE_CONFIGURED; - } - -- goto fail; -+ } else { -+ nss_status = nss_capwapmgr_configure_ipv6(&t->ip_rule.v6, 0, 0); -+ if (nss_status == NSS_TX_SUCCESS) { -+ t->tunnel_state |= NSS_CAPWAPMGR_TUNNEL_STATE_IPRULE_CONFIGURED; -+ } -+ } - -+ return NSS_CAPWAPMGR_FAILURE_CAPWAP_DESTROY_RULE; - } - -- nss_capwapmgr_unregister_with_nss(if_num_outer); -- nss_capwapmgr_unregister_with_nss(if_num_inner); -+ nss_capwapmgr_unregister_with_nss(if_num); - - /* - * Deallocate dynamic interface - */ -- nss_status = nss_dynamic_interface_dealloc_node(if_num_outer, NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_OUTER); -- if (nss_status != NSS_TX_SUCCESS) { -- nss_capwapmgr_warn("%px: %d: Dealloc of dynamic interface failed for tunnel : %d\n", -- dev, if_num_outer, tunnel_id); -- } -- -- nss_status = nss_dynamic_interface_dealloc_node(if_num_inner, NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_HOST_INNER); -+ nss_status = nss_dynamic_interface_dealloc_node(if_num, NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP); - if (nss_status != NSS_TX_SUCCESS) { - nss_capwapmgr_warn("%px: %d: Dealloc of dynamic interface failed for tunnel : %d\n", -- dev, if_num_inner, tunnel_id); -+ dev, if_num, tunnel_id); - } - - /* -@@ -3020,9 +2832,8 @@ nss_capwapmgr_status_t nss_capwapmgr_tun - if (t->capwap_rule.enabled_features & NSS_CAPWAPMGR_FEATURE_DTLS_ENABLED) { - nss_status = nss_trustsec_tx_unconfigure_sgt(t->capwap_rule.dtls_inner_if_num, t->capwap_rule.outer_sgt_value); - } else { -- nss_status = nss_trustsec_tx_unconfigure_sgt(t->if_num_outer, t->capwap_rule.outer_sgt_value); -+ nss_status = nss_trustsec_tx_unconfigure_sgt(t->if_num, t->capwap_rule.outer_sgt_value); - } -- - if (nss_status != NSS_TX_SUCCESS) { - nss_capwapmgr_warn("%px: unconfigure trustsec_tx failed\n", dev); - } -@@ -3037,35 +2848,14 @@ nss_capwapmgr_status_t nss_capwapmgr_tun - } - } - -+ t->if_num = 0; - t->tunnel_state &= ~NSS_CAPWAPMGR_TUNNEL_STATE_CONFIGURED; -- priv->if_num_to_tunnel_id[if_num_inner] = -1; -- priv->if_num_to_tunnel_id[if_num_outer] = -1; -- -+ priv->if_num_to_tunnel_id[if_num] = 0; - memset(t, 0, sizeof(struct nss_capwapmgr_tunnel)); - -- t->if_num_inner = -1; -- t->if_num_outer = -1; -- -- nss_capwapmgr_info("%px: Tunnel %d is completely destroyed\n", dev , tunnel_id); -- status = NSS_CAPWAPMGR_SUCCESS; -- goto done; -- --fail: -- if (t->capwap_rule.l3_proto == NSS_CAPWAP_TUNNEL_IPV4) { -- nss_status = nss_capwapmgr_configure_ipv4(&t->ip_rule.v4, 0, 0); -- } else { -- nss_status = nss_capwapmgr_configure_ipv6(&t->ip_rule.v6, 0, 0); -- } -- -- if (nss_status == NSS_TX_SUCCESS) { -- t->tunnel_state |= NSS_CAPWAPMGR_TUNNEL_STATE_IPRULE_CONFIGURED; -- } -- -- status = NSS_CAPWAPMGR_FAILURE_CAPWAP_DESTROY_RULE; -- --done: -+ nss_capwapmgr_info("%px: %d: Tunnel %d is completely destroyed\n", dev, if_num, tunnel_id); - dev_put(dev); -- return status; -+ return NSS_CAPWAPMGR_SUCCESS; - } - EXPORT_SYMBOL(nss_capwapmgr_tunnel_destroy); - -@@ -3083,18 +2873,17 @@ static inline nss_capwapmgr_status_t nss - struct nss_capwapmgr_tunnel *t; - nss_capwapmgr_status_t status; - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_warn("%px: can't find tunnel: %d\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -+ dev_hold(dev); - priv = netdev_priv(dev); - - memset(&capwapmsg, 0, sizeof(struct nss_capwap_msg)); -- nss_capwap_msg_init(&capwapmsg, t->if_num_outer, cmd, -+ nss_capwap_msg_init(&capwapmsg, t->if_num, cmd, - sizeof(struct nss_capwap_flow_rule_msg), nss_capwapmgr_msg_event_receive, dev); - - /* -@@ -3121,7 +2910,6 @@ static inline nss_capwapmgr_status_t nss - nss_capwapmgr_warn("%px: send flow rule message failed with error: %d\n", dev, status); - } - --done: - dev_put(dev); - return status; - } -@@ -3160,85 +2948,29 @@ nss_capwapmgr_status_t nss_capwapmgr_tun - uint8_t tunnel_id, struct nss_capwap_tunnel_stats *stats) - { - struct nss_capwapmgr_tunnel *t; -- struct nss_capwap_tunnel_stats stats_temp; -- nss_capwapmgr_status_t status = NSS_CAPWAPMGR_SUCCESS; - - if (!stats) { - nss_capwapmgr_warn("%px: invalid rtnl structure\n", dev); - return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - -- dev_hold(dev); - t = nss_capwapmgr_verify_tunnel_param(dev, tunnel_id); - if (!t) { - nss_capwapmgr_trace("%px: can't find tunnel: %d\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_BAD_PARAM; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_BAD_PARAM; - } - - if (!(t->tunnel_state & NSS_CAPWAPMGR_TUNNEL_STATE_CONFIGURED)) { - nss_capwapmgr_trace("%px: tunnel: %d not configured yet\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_TUNNEL_NOT_CFG; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_TUNNEL_NOT_CFG; - } - -- /* -- * Copy the inner interface stats. -- */ -- if (nss_capwap_get_stats(t->if_num_inner, &stats_temp) == false) { -+ if (nss_capwap_get_stats(t->if_num, stats) == false) { - nss_capwapmgr_warn("%px: tunnel %d not ready yet\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_NOT_READY; -- goto done; -+ return NSS_CAPWAPMGR_FAILURE_NOT_READY; - } - -- stats->dtls_pkts += stats_temp.dtls_pkts; -- stats->tx_segments += stats_temp.tx_segments; -- stats->tx_queue_full_drops += stats_temp.tx_queue_full_drops; -- stats->tx_mem_failure_drops += stats_temp.tx_mem_failure_drops; -- stats->tx_dropped_sg_ref += stats_temp.tx_dropped_sg_ref; -- stats->tx_dropped_ver_mis += stats_temp.tx_dropped_ver_mis; -- stats->tx_dropped_hroom += stats_temp.tx_dropped_hroom; -- stats->tx_dropped_dtls += stats_temp.tx_dropped_dtls; -- stats->tx_dropped_nwireless += stats_temp.tx_dropped_nwireless; -- -- /* -- * Pnode tx stats for Inner node. -- */ -- stats->pnode_stats.tx_packets += stats_temp.pnode_stats.tx_packets; -- stats->pnode_stats.tx_bytes += stats_temp.pnode_stats.tx_bytes; -- stats->tx_dropped_inner += stats_temp.tx_dropped_inner; -- -- /* -- * Copy the outer interface stats. -- */ -- if (nss_capwap_get_stats(t->if_num_outer, &stats_temp) == false) { -- nss_capwapmgr_warn("%px: tunnel %d not ready yet\n", dev, tunnel_id); -- status = NSS_CAPWAPMGR_FAILURE_NOT_READY; -- goto done; -- } -- -- stats->rx_segments += stats_temp.rx_segments; -- stats->dtls_pkts += stats_temp.dtls_pkts; -- stats->rx_dup_frag += stats_temp.rx_dup_frag; -- stats->rx_oversize_drops += stats_temp.rx_oversize_drops; -- stats->rx_frag_timeout_drops += stats_temp.rx_frag_timeout_drops; -- stats->rx_n2h_drops += stats_temp.rx_n2h_drops; -- stats->rx_n2h_queue_full_drops += stats_temp.rx_n2h_queue_full_drops; -- stats->rx_mem_failure_drops += stats_temp.rx_mem_failure_drops; -- stats->rx_csum_drops += stats_temp.rx_csum_drops; -- stats->rx_malformed += stats_temp.rx_malformed; -- stats->rx_frag_gap_drops += stats_temp.rx_frag_gap_drops; -- -- /* -- * Pnode rx stats for outer node. -- */ -- stats->pnode_stats.rx_packets += stats_temp.pnode_stats.rx_packets; -- stats->pnode_stats.rx_bytes += stats_temp.pnode_stats.rx_bytes; -- stats->pnode_stats.rx_dropped += stats_temp.pnode_stats.rx_dropped; -- --done: -- dev_put(dev); -- return status; -+ return NSS_CAPWAPMGR_SUCCESS; - } - EXPORT_SYMBOL(nss_capwapmgr_tunnel_stats); - -@@ -3341,7 +3073,10 @@ EXPORT_SYMBOL(nss_capwapmgr_get_netdev); - */ - static int nss_capwapmgr_netdev_up(struct net_device *netdev) - { -+ struct nss_capwapmgr_priv *priv; - uint8_t i; -+ -+ priv = netdev_priv(netdev); - for (i = 0; i < NSS_CAPWAPMGR_MAX_TUNNELS; i++) { - (void)nss_capwapmgr_enable_tunnel(nss_capwapmgr_ndev, i); - } -@@ -3355,7 +3090,10 @@ static int nss_capwapmgr_netdev_up(struc - */ - static int nss_capwapmgr_netdev_down(struct net_device *netdev) - { -+ struct nss_capwapmgr_priv *priv; - uint8_t i; -+ -+ priv = netdev_priv(netdev); - for (i = 0; i < NSS_CAPWAPMGR_MAX_TUNNELS; i++) { - (void)nss_capwapmgr_disable_tunnel(nss_capwapmgr_ndev, i); - } -@@ -3367,7 +3105,7 @@ static int nss_capwapmgr_netdev_down(str - * nss_capwapmgr_netdev_event() - * Net device notifier for NSS CAPWAP manager module - */ --static int nss_capwapmgr_netdev_event(struct notifier_block *nb, unsigned long event, void *dev) -+static int nss_capwapmgr_netdev_event(struct notifier_block *nb, unsigned long event, void *dev) - { - struct net_device *netdev = (struct net_device *)dev; - ---- a/clmapmgr/nss_clmapmgr.c -+++ b/clmapmgr/nss_clmapmgr.c -@@ -84,17 +84,16 @@ fail: - } - - /* -- * nss_clmapmgr_get_dev_stats64() -+ * nss_clmapmgr_dev_stats64() - * Netdev ops function to retrieve stats. - */ --static struct rtnl_link_stats64 *nss_clmapmgr_get_dev_stats64(struct net_device *dev, -+void nss_clmapmgr_dev_stats64(struct net_device *dev, - struct rtnl_link_stats64 *stats) - { - struct nss_clmapmgr_priv_t *priv; - - if (!stats) { - nss_clmapmgr_warning("%px: invalid rtnl structure\n", dev); -- return stats; - } - - dev_hold(dev); -@@ -109,30 +108,7 @@ static struct rtnl_link_stats64 *nss_clm - memcpy(stats, &priv->stats, sizeof(struct rtnl_link_stats64)); - dev_put(dev); - -- return stats; --} -- --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) --/* -- * nss_clmapmgr_dev_stats64() -- * Netdev ops function to retrieve stats for kernel version < 4.6 -- */ --static struct rtnl_link_stats64 *nss_clmapmgr_dev_stats64(struct net_device *dev, -- struct rtnl_link_stats64 *tot) --{ -- return nss_clmapmgr_get_dev_stats64(dev, tot); --} --#else --/* -- * nss_clmapmgr_dev_stats64() -- * Netdev ops function to retrieve stats for kernel version >= 4.6 -- */ --static void nss_clmapmgr_dev_stats64(struct net_device *dev, -- struct rtnl_link_stats64 *tot) --{ -- nss_clmapmgr_get_dev_stats64(dev, tot); - } --#endif - - /* - * nss_clmapmgr_dev_init() ---- a/dtls/v1.0/nss_connmgr_dtls_netdev.c -+++ b/dtls/v1.0/nss_connmgr_dtls_netdev.c -@@ -160,7 +160,7 @@ static void nss_dtlsmgr_dev_setup(struct - dev->ethtool_ops = NULL; - dev->header_ops = NULL; - dev->netdev_ops = &nss_dtlsmgr_session_ops; -- dev->destructor = NULL; -+ dev->priv_destructor = NULL; - - memcpy(dev->dev_addr, "\xaa\xbb\xcc\xdd\xee\xff", dev->addr_len); - memset(dev->broadcast, 0xff, dev->addr_len); ---- a/dtls/v2.0/Makefile -+++ b/dtls/v2.0/Makefile -@@ -3,7 +3,7 @@ - ccflags-y += $(NSS_CCFLAGS) -I$(obj)/../../exports - ccflags-y += -DNSS_DTLSMGR_DEBUG_LEVEL=0 - ccflags-y += -DNSS_DTLSMGR_BUILD_ID=\"'Build_ID - $(shell date +'%m/%d/%y, %H:%M:%S') SoC=$(SoC)'\" --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - - obj-m += qca-nss-dtlsmgr.o - qca-nss-dtlsmgr-objs += nss_dtlsmgr.o ---- a/dtls/v2.0/nss_dtlsmgr_ctx.c -+++ b/dtls/v2.0/nss_dtlsmgr_ctx.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2020, 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. -@@ -627,7 +627,7 @@ struct net_device *nss_dtlsmgr_session_c - * so that the skb data pointer remains 4 byte aligned when the - * headroom/tailroom is adjusted. - */ -- dev->needed_headroom = ALIGN(ctx->encap.headroom, 4); -+ dev->needed_headroom = ALIGN(ctx->encap.headroom + NSS_DTLSMGR_EDMA_PRE_HDR_SZ, 4); - dev->needed_tailroom = ALIGN(ctx->encap.tailroom, 4); - - ctx->app_data = cfg->app_data; -@@ -643,7 +643,7 @@ struct net_device *nss_dtlsmgr_session_c - ctx->app_data = ctx; - } - -- error = register_netdev(dev); -+ error = rtnl_is_locked() ? register_netdevice(dev) : register_netdev(dev); - if (error < 0) { - nss_dtlsmgr_warn("%px: unable register net_device(%s)", ctx, dev->name); - goto destroy_decap; -@@ -708,7 +708,7 @@ nss_dtlsmgr_status_t nss_dtlsmgr_session - - NSS_DTLSMGR_SET_MAGIC(ctx, 0); - -- unregister_netdev(dev); -+ rtnl_is_locked() ? unregister_netdevice(dev) : unregister_netdev(dev); - - return NSS_DTLSMGR_OK; - } ---- a/dtls/v2.0/nss_dtlsmgr_ctx_dev.c -+++ b/dtls/v2.0/nss_dtlsmgr_ctx_dev.c -@@ -349,7 +349,7 @@ static netdev_tx_t nss_dtlsmgr_ctx_dev_t - stats = &encap->stats; - - nhead = dev->needed_headroom; -- ntail = dev->needed_tailroom + nhead; /* Firmware uses tailroom for header add */ -+ ntail = dev->needed_tailroom; - - /* - * Check if skb is shared; unshare in case it is shared --- a/eogremgr/nss_eogremgr.c +++ b/eogremgr/nss_eogremgr.c -@@ -19,10 +19,10 @@ +@@ -19,6 +19,7 @@ * NSS EOGRE manager */ @@ -2015,311 +25,9 @@ #include #include #include "nss_connmgr_gre_public.h" --#include - #include "nss_eogremgr.h" - #include "nss_eogremgr_priv.h" - -@@ -565,15 +565,12 @@ static void __exit nss_eogremgr_exit_mod - */ - static int __init nss_eogremgr_init_module(void) - { -- --#ifdef CONFIG_OF - /* - * If the node is not compatible, don't do anything. - */ - if (!of_find_node_by_name(NULL, "nss-common")) { - return 0; - } --#endif - - nss_eogremgr_info("module %s loaded\n", NSS_CLIENT_BUILD_ID); - ---- a/exports/nss_capwapmgr.h -+++ b/exports/nss_capwapmgr.h -@@ -61,10 +61,8 @@ struct nss_capwapmgr_response { - */ - struct nss_capwapmgr_tunnel { - struct net_device *dtls_dev; /**< DTLS netdevice */ -- uint32_t if_num_inner; /**< Interface number of the INNER CAPWAP node */ -- uint32_t if_num_outer; /**< Interface number of the OUTER CAPWAP node */ -+ uint32_t if_num; /**< Interface number of NSS */ - uint32_t tunnel_state; /**< Tunnel state */ -- uint16_t type_flags; /**< Tunnel Type to determine header size */ - union { - struct nss_ipv4_create v4; /**< IPv4 rule structure */ - struct nss_ipv6_create v6; /**< IPv6 rule struture */ -@@ -224,7 +222,7 @@ nss_capwapmgr_status_t nss_capwapmgr_upd - * - * @return nss_capwapmgr_status_t - */ --extern nss_capwapmgr_status_t nss_capwapmgr_update_src_interface(struct net_device *dev, uint8_t tunnel_id, uint32_t src_interface_num); -+extern nss_capwapmgr_status_t nss_capwapmgr_update_src_interface(struct net_device *dev, uint8_t tunnel_id, int32_t src_interface_num); - - /** - * @brief Delete a DSCP prioritization rule that was created. ---- a/exports/nss_dtlsmgr.h -+++ b/exports/nss_dtlsmgr.h -@@ -60,12 +60,6 @@ - #define NSS_DTLSMGR_METADATA_FLAG_SEQ 0x0002 /**< Metadata has a valid sequence no. */ - #define NSS_DTLSMGR_METADATA_FLAG_CTYPE 0x0004 /**< Metadata has a valid DTLS content type */ - --/* -- * NSS DTLS manager reserved size of header -- */ --#define NSS_DTLSMGR_NEEDED_HEADROOM_SZ 128 --#define NSS_DTLSMGR_NEEDED_TAILROOM_SZ 128 -- - /** - * NSS DTLS manager status - */ -@@ -134,7 +128,7 @@ enum nss_dtlsmgr_metadata_result { - * NSS DTLS manager cryptographic structure to represent key and its length. - */ - struct nss_dtlsmgr_crypto_data { -- const uint8_t *data; /**< Pointer to key or nonce. */ -+ uint8_t *data; /**< Pointer to key or nonce. */ - uint16_t len; /**< Length of the key. */ - }; - ---- a/exports/nss_ipsecmgr.h -+++ b/exports/nss_ipsecmgr.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2019, 2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2019, 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. -@@ -252,10 +252,7 @@ struct nss_ipsecmgr_sa_stats { - uint32_t pkt_count; /**< Number of packets processed. */ - uint32_t pkt_failed; /**< Number of packets failed in processing. */ - uint16_t window_size; /**< Current size of the window. */ -- uint16_t replay_fail_alarm; /**< Alarm for consecutive hash fail. */ -- uint32_t fail_replay_win; /**< Failure in anti-replay; packet outside the window */ -- uint32_t fail_replay_dup; /**< Failure in anti-replay; duplicate records */ -- uint32_t fail_auth; /**< Failure in authenticating the data */ -+ bool replay_fail_alarm; /**< Alarm for consecutive hash fail. */ - }; - - /** -@@ -270,20 +267,6 @@ struct nss_ipsecmgr_event { - }; - - /** -- * nss_ipsecmgr_sa_info -- * Crypto information for an already created SA. -- */ --struct nss_ipsecmgr_sa_info { -- uint16_t session_idx; /**< Crypto Session index */ -- uint16_t hdr_len; /**< Encap header length */ -- uint16_t trailer_len; /**< Encap Trailer length */ -- uint8_t blk_len; /**< Cipher Block length */ -- uint8_t iv_len; /**< Cipher IV lengh */ -- uint8_t hash_len; /**< Hash lengh */ -- uint8_t res[3]; /**< Reserved */ --}; -- --/** - * nss_ipsecmgr_sa_cmn_init_keys - * Fill and initialize common information for SA creation with crypto keys. - * -@@ -392,20 +375,6 @@ static inline bool nss_ipsecmgr_sa_cmn_i - return true; - } - --/** -- * nss_ipsecmgr_sa_set_transport -- * Enable transport mode for an SA thats is getting initialized. -- * -- * @datatypes -- * nss_ipsecmgr_sa_cmn \n -- * -- * @param[in/out] cmn Pointer to the common IPsec manager SA configuration information. -- */ --static inline void nss_ipsecmgr_sa_set_transport(struct nss_ipsecmgr_sa_cmn *cmn) --{ -- cmn->transport_mode = true; --} -- - #ifdef __KERNEL__ /* only kernel will use. */ - - /** -@@ -439,7 +408,6 @@ struct nss_ipsecmgr_callback { - struct net_device *skb_dev; /**< Net device to use for Socket Buffer. */ - nss_ipsecmgr_data_callback_t data_cb; /**< Data callback function. */ - nss_ipsecmgr_event_callback_t event_cb; /**< Event callback function. */ -- nss_ipsecmgr_data_callback_t except_cb; /**< Outer exception callback function. */ - }; - - /** -@@ -654,35 +622,5 @@ nss_ipsecmgr_status_t nss_ipsecmgr_sa_tx - nss_ipsecmgr_status_t nss_ipsecmgr_sa_tx_outer(struct net_device *tun, struct nss_ipsecmgr_sa_tuple *sa, - struct sk_buff *skb); - --/* -- * nss_ipsecmgr_cra_name2algo() -- * Get ipsecmgr algo from cra name. -- * -- * @param[in] cra_name Name of the crypto algo. -- * -- * @return -- * nss_ipsecmgr_algo -- */ --enum nss_ipsecmgr_algo nss_ipsecmgr_cra_name2algo(const char *cra_name); -- --/* -- * nss_ipsecmgr_sa_get_info() -- * Get Crypto information for an already created SA. -- * -- * @datatypes -- * net_device \n -- * nss_ipsecmgr_sa_tuple \n -- * nss_ipsecmgr_sa_info -- * -- * @param[in] tun Pointer to the network device associated with the tunnel. -- * @param[in] sa Pointer to the SA tuple for which info is to be retrieved. -- * @param[out] info Pointer to the SA info to fill. -- * -- * @return -- * Success or failure. -- */ --bool nss_ipsecmgr_sa_get_info(struct net_device *tun, struct nss_ipsecmgr_sa_tuple *sa, -- struct nss_ipsecmgr_sa_info *info); -- - #endif /* __KERNEL__ */ - #endif /* __NSS_IPSECMGR_H */ ---- a/exports/nss_l2tpmgr.h -+++ b/exports/nss_l2tpmgr.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019, 2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019 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. -@@ -16,25 +16,22 @@ - #ifndef __NSS_L2TPMGR_H__ - #define __NSS_L2TPMGR_H__ - --typedef int32_t (*get_ipsec_ifnum_by_dev_callback_t)(struct net_device *); --typedef int32_t (*get_ipsec_ifnum_by_ip_addr_callback_t)(uint8_t ipversion, uint32_t *src_ip, uint32_t *dest_ip); -+typedef struct net_device *(*get_ipsec_tundev_callback_t)(struct net_device *dev); - - /** - * l2tpmgr_ipsecmgr_cb -- * Callback to get the dummy IPSec interface number that was used to register with NSS -- * by the IPSec manager when given the IPSec Linux dev. -- * get_ifnum_by_dev: passes net_device ptr to get associated IPsec if_num in KLIPS -- * get_ifnum_by_ip_addr: passes IPv4 src & dest addr in Big-endian form to get IPsec if_num in XFRM -+ * Callback to get the dummy IPSec netdev that was -+ * used to register with NSS by the IPSec manager -+ * when given the IPSec Linux dev. - */ - struct l2tpmgr_ipsecmgr_cb { -- get_ipsec_ifnum_by_dev_callback_t get_ifnum_by_dev; -- get_ipsec_ifnum_by_ip_addr_callback_t get_ifnum_by_ip_addr; -+ get_ipsec_tundev_callback_t cb; -+ /**< IPSec mgr Callback> */ - }; - --#if defined(NSS_L2TP_IPSEC_BIND_BY_NETDEV) - /** -- * l2tpmgr_register_ipsecmgr_callback_by_netdev -- * Register IPSecmgr callback function with l2tpmgr by netdev for KLIPS. -+ * l2tpmgr_register_ipsecmgr_callback -+ * Register IPSecmgr callback function with l2tpmgr. - * - * @datatypes - * l2tpmgr_ipsecmgr_cb \n -@@ -44,38 +41,15 @@ struct l2tpmgr_ipsecmgr_cb { - * @return - * none - */ --void l2tpmgr_register_ipsecmgr_callback_by_netdev(struct l2tpmgr_ipsecmgr_cb *cb); -+void l2tpmgr_register_ipsecmgr_callback(struct l2tpmgr_ipsecmgr_cb *cb); - - /** - * l2tpmgr_unregister_ipsecmgr_callback -- * Unregister IPSecmgr callback function with l2tpmgr by netdev for KLIPS. -+ * Unregister IPSecmgr callback function with l2tpmgr. - * - * @return - * none - */ --void l2tpmgr_unregister_ipsecmgr_callback_by_netdev(void); --#endif -+void l2tpmgr_unregister_ipsecmgr_callback(void); - --/** -- * l2tpmgr_register_ipsecmgr_callback_by_ipaddr -- * Register IPSecmgr callback function with l2tpmgr by IP address for XFRM. -- * -- * @datatypes -- * l2tpmgr_ipsecmgr_cb \n -- * -- * @param[in] cb IPSecmgr callback function to be registered with l2tpmgr. -- * -- * @return -- * none -- */ --void l2tpmgr_register_ipsecmgr_callback_by_ipaddr(struct l2tpmgr_ipsecmgr_cb *cb); -- --/** -- * l2tpmgr_unregister_ipsecmgr_callback_by_ipaddr -- * Unregister IPSecmgr callback function with l2tpmgr by IP address for XFRM. -- * -- * @return -- * none -- */ --void l2tpmgr_unregister_ipsecmgr_callback_by_ipaddr(void); - #endif ---- a/gre/Makefile -+++ b/gre/Makefile -@@ -1,7 +1,7 @@ - # Makefile for gre client - ccflags-y += -I$(obj)/../../exports -I$(obj)/../.. - ccflags-y += -DNSS_GRE_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - obj-m += qca-nss-gre.o - qca-nss-gre-objs := nss_connmgr_gre.o nss_connmgr_gre_v4.o nss_connmgr_gre_v6.o - --- a/gre/nss_connmgr_gre_v4.c +++ b/gre/nss_connmgr_gre_v4.c -@@ -98,12 +98,9 @@ static int nss_connmgr_gre_v4_get_mac_ad - neigh = neigh_lookup(&arp_tbl, (const void *)&raddr, rt->dst.dev); - } - -- if (neigh) { -- if (!(neigh->nud_state & NUD_VALID) || !is_valid_ether_addr(neigh->ha)) { -- nss_connmgr_gre_info("neigh lookup failed for %pI4, state=%x, neigh->ha=%pM\n", &raddr, neigh->nud_state, neigh->ha); -- neigh_release(neigh); -- neigh = NULL; -- } -+ if (neigh && !is_valid_ether_addr(neigh->ha)) { -+ neigh_release(neigh); -+ neigh = NULL; - } - - /* -@@ -122,13 +119,6 @@ static int nss_connmgr_gre_v4_get_mac_ad - msleep(2000); - } - -- if (!(neigh->nud_state & NUD_VALID) || !is_valid_ether_addr(neigh->ha)) { -- ip_rt_put(rt); -- nss_connmgr_gre_warning("invalid neigh state (%x) or invalid MAC(%pM) for %pI4\n", neigh->nud_state, neigh->ha, &raddr); -- neigh_release(neigh); -- return GRE_ERR_NEIGH_CREATE; -- } -- - if (neigh->dev->type == ARPHRD_LOOPBACK) { - ip_rt_put(rt); - neigh_release(neigh); -@@ -172,14 +162,6 @@ int nss_connmgr_gre_v4_set_config(struct +@@ -162,14 +162,6 @@ int nss_connmgr_gre_v4_set_config(struct } } @@ -2354,23 +62,7 @@ rt = nss_connmgr_gre_v6_route_lookup(&init_net, &dst_addr); if (!rt) { nss_connmgr_gre_warning("Unable to find route lookup for %pI6", dest_ip); -@@ -118,12 +118,9 @@ static int nss_connmgr_gre_v6_get_mac_ad - #else - neigh = rt->dst.ops->neigh_lookup(&rt->dst, NULL, &dst_addr); - #endif -- if (neigh) { -- if (!(neigh->nud_state & NUD_VALID) || !is_valid_ether_addr(neigh->ha)) { -- nss_connmgr_gre_warning("neigh state is either invalid (%x) or mac address is null (%pM) for %pI6", neigh->nud_state, neigh->ha, dest_ip); -- neigh_release(neigh); -- neigh = NULL; -- } -+ if (neigh && !is_valid_ether_addr(neigh->ha)) { -+ neigh_release(neigh); -+ neigh = NULL; - } - - if (!neigh) { -@@ -143,8 +140,7 @@ static int nss_connmgr_gre_v6_get_mac_ad +@@ -140,8 +140,7 @@ static int nss_connmgr_gre_v6_get_mac_ad * Release hold on existing route entry, and find the route entry again */ ip6_rt_put(rt); @@ -2380,37 +72,6 @@ if (!rt) { nss_connmgr_gre_warning("Unable to find route lookup for %pI6\n", dest_ip); return GRE_ERR_NEIGH_LOOKUP; -@@ -155,19 +151,11 @@ static int nss_connmgr_gre_v6_get_mac_ad - #else - neigh = rt->dst.ops->neigh_lookup(&rt->dst, NULL, &dst_addr); - #endif -- -- if (!neigh) { -+ if (!neigh || !is_valid_ether_addr(neigh->ha)) { - ip6_rt_put(rt); - nss_connmgr_gre_warning("Err in MAC address, neighbour look up failed\n"); - return GRE_ERR_NEIGH_LOOKUP; - } -- -- if (!(neigh->nud_state & NUD_VALID) || !is_valid_ether_addr(neigh->ha)) { -- ip6_rt_put(rt); -- nss_connmgr_gre_warning("Err in MAC address, invalid neigh state (%x) or invalid mac(%pM)\n", neigh->nud_state, neigh->ha); -- neigh_release(neigh); -- return GRE_ERR_NEIGH_LOOKUP; -- } - } - - ether_addr_copy(dest_mac, neigh->ha); ---- a/gre/test/Makefile -+++ b/gre/test/Makefile -@@ -1,6 +1,6 @@ - # Makefile for custom gre test module - ccflags-y += -I$(obj)/../../../exports -I$(obj)/../../.. -I$(obj)/../ - ccflags-y += -DNSS_GRE_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - obj-m += qca-nss-gre-test.o - qca-nss-gre-test-objs := nss_connmgr_gre_test.o --- a/gre/test/nss_connmgr_gre_test.c +++ b/gre/test/nss_connmgr_gre_test.c @@ -229,10 +229,12 @@ static int nss_connmgr_gre_test_open_pro @@ -2430,17 +91,6 @@ }; /* ---- a/ipsecmgr/v1.0/Makefile -+++ b/ipsecmgr/v1.0/Makefile -@@ -2,7 +2,7 @@ - - ccflags-y := -I$(obj) -I$(obj)/../.. - ccflags-y += -DNSS_CLIENT_BUILD_ID="$(BUILD_ID)" --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - ifeq ($(SoC), fsm9010) - ccflags-y += -DNSS_IPSECMGR_PMTU_SUPPORT - endif --- a/ipsecmgr/v1.0/nss_ipsecmgr.c +++ b/ipsecmgr/v1.0/nss_ipsecmgr.c @@ -377,7 +377,7 @@ free: @@ -2470,1754 +120,57 @@ /* * get the MAC address from the ethernet device ---- a/ipsecmgr/v2.0/Makefile -+++ b/ipsecmgr/v2.0/Makefile -@@ -2,7 +2,7 @@ - - ccflags-y += $(NSS_CCFLAGS) -I$(obj)/../../exports - ccflags-y += -DNSS_CLIENT_BUILD_ID="$(BUILD_ID)" --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - - obj-m += qca-nss-ipsecmgr.o - qca-nss-ipsecmgr-objs := nss_ipsecmgr.o ---- a/ipsecmgr/v2.0/nss_ipsecmgr.c -+++ b/ipsecmgr/v2.0/nss_ipsecmgr.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2020, 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. -@@ -67,15 +67,6 @@ struct nss_ipsecmgr_drv *ipsecmgr_drv; - static const struct net_device_ops nss_ipsecmgr_dummy_ndev_ops; - - /* -- * nss_ipsecmgr_dummy_free() -- * Setup function for dummy netdevice. -- */ --static void nss_ipsecmgr_dummy_free(struct net_device *dev) --{ -- free_netdev(dev); --} -- --/* - * nss_ipsecmgr_dummy_setup() - * Setup function for dummy netdevice. - */ -@@ -86,11 +77,6 @@ static void nss_ipsecmgr_dummy_setup(str - * transform. - */ - dev->mtu = ETH_DATA_LEN; --#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 11, 8)) -- dev->destructor = nss_ipsecmgr_dummy_free; --#else -- dev->priv_destructor = nss_ipsecmgr_dummy_free; --#endif - } - - /* -@@ -110,9 +96,12 @@ static void nss_ipsecmgr_rx_notify(void - static void nss_ipsecmgr_configure(struct work_struct *work) - { - enum nss_ipsec_cmn_msg_type type = NSS_IPSEC_CMN_MSG_TYPE_NODE_CONFIG; -+ struct nss_ipsecmgr_tunnel *tun = netdev_priv(ipsecmgr_drv->dev); - uint32_t ifnum = ipsecmgr_drv->ifnum; - struct nss_ipsec_cmn_msg nicm = {0}; -+ struct nss_ipsecmgr_ctx *redir; - nss_tx_status_t status; -+ uint32_t vsi_num = 0; - - /* - * By making sure that cryptoapi is registered, -@@ -150,10 +139,6 @@ static void nss_ipsecmgr_configure(struc - if (ipsecmgr_drv->ipsec_inline) { - - #ifdef NSS_IPSECMGR_PPE_SUPPORT -- struct nss_ipsecmgr_tunnel *tun = netdev_priv(ipsecmgr_drv->dev); -- struct nss_ipsecmgr_ctx *redir; -- uint32_t vsi_num = 0; -- - redir = nss_ipsecmgr_ctx_alloc(tun, - NSS_IPSEC_CMN_CTX_TYPE_REDIR, - NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_REDIRECT, -@@ -213,7 +198,7 @@ static void nss_ipsecmgr_configure(struc - static int __init nss_ipsecmgr_init(void) - { - struct nss_ipsecmgr_tunnel *tun; -- struct net_device *dev = NULL; -+ struct net_device *dev; - int status; - - ipsecmgr_drv = vzalloc(sizeof(*ipsecmgr_drv)); -@@ -251,7 +236,7 @@ static int __init nss_ipsecmgr_init(void - status = register_netdev(dev); - if (status) { - nss_ipsecmgr_info("%px: Failed to register dummy netdevice(%px)", ipsecmgr_drv, dev); -- goto free; -+ goto netdev_free; - } - - ipsecmgr_drv->dev = dev; -@@ -269,31 +254,41 @@ static int __init nss_ipsecmgr_init(void - * Initialize debugfs. - */ - ipsecmgr_drv->dentry = debugfs_create_dir("qca-nss-ipsecmgr", NULL); -- if (ipsecmgr_drv->dentry) { -- tun->dentry = debugfs_create_dir(dev->name, ipsecmgr_drv->dentry); -+ if (!ipsecmgr_drv->dentry) { -+ nss_ipsecmgr_warn("%px: Failed to create root debugfs entry", ipsecmgr_drv); -+ nss_ipsec_cmn_notify_unregister(ipsecmgr_drv->nss_ctx, ipsecmgr_drv->ifnum); -+ goto unregister_dev; - } - - /* -+ * Create debugfs entry for tunnel -+ */ -+ tun->dentry = debugfs_create_dir(dev->name, ipsecmgr_drv->dentry); -+ -+ /* - * Configure inline mode and the DMA rings. - */ - nss_ipsecmgr_configure(&ipsecmgr_drv->cfg_work.work); - -- write_lock_bh(&ipsecmgr_drv->lock); -+ write_lock(&ipsecmgr_drv->lock); - list_add(&tun->list, &ipsecmgr_drv->tun_db); - - ipsecmgr_drv->max_mtu = dev->mtu; -- write_unlock_bh(&ipsecmgr_drv->lock); -+ write_unlock(&ipsecmgr_drv->lock); - - nss_ipsecmgr_info("NSS IPsec manager loaded: %s\n", NSS_CLIENT_BUILD_ID); - return 0; - -+unregister_dev: -+ unregister_netdev(ipsecmgr_drv->dev); -+ -+netdev_free: -+ free_netdev(ipsecmgr_drv->dev); -+ - free: --#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 11, 8)) -- if (dev) -- dev->destructor(dev); --#endif - vfree(ipsecmgr_drv); - ipsecmgr_drv = NULL; -+ - return -1; - } - ---- a/ipsecmgr/v2.0/nss_ipsecmgr_ctx.c -+++ b/ipsecmgr/v2.0/nss_ipsecmgr_ctx.c -@@ -1,6 +1,6 @@ - /* - * ******************************************************************************** -- * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2018-2020, 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. -@@ -92,7 +92,6 @@ static const struct nss_ipsecmgr_print i - {"\texceptioned", NSS_IPSECMGR_PRINT_DWORD}, - {"\tlinearized", NSS_IPSECMGR_PRINT_DWORD}, - {"\tredirected", NSS_IPSECMGR_PRINT_DWORD}, -- {"\tdropped", NSS_IPSECMGR_PRINT_DWORD}, - {"\tfail_sa", NSS_IPSECMGR_PRINT_DWORD}, - {"\tfail_flow", NSS_IPSECMGR_PRINT_DWORD}, - {"\tfail_stats", NSS_IPSECMGR_PRINT_DWORD}, -@@ -100,9 +99,6 @@ static const struct nss_ipsecmgr_print i - {"\tfail_transform", NSS_IPSECMGR_PRINT_DWORD}, - {"\tfail_linearized", NSS_IPSECMGR_PRINT_DWORD}, - {"\tfail_mdata_ver", NSS_IPSECMGR_PRINT_DWORD}, -- {"\tfail_ctx_active", NSS_IPSECMGR_PRINT_DWORD}, -- {"\tfail_pbuf_crypto", NSS_IPSECMGR_PRINT_DWORD}, -- {"\tfail_queue_crypto", NSS_IPSECMGR_PRINT_DWORD}, - }; - - /* -@@ -552,8 +548,8 @@ void nss_ipsecmgr_ctx_rx_redir(struct ne - * If, data callback is available then send the packet to the - * callback function - */ -- if (tun->cb.except_cb) { -- tun->cb.except_cb(tun->cb.app_data, skb); -+ if (tun->cb.data_cb) { -+ tun->cb.data_cb(tun->cb.app_data, skb); - ctx->hstats.redir_cb++; - return; - } -@@ -609,11 +605,6 @@ void nss_ipsecmgr_ctx_rx_outer(struct ne - } - - skb_set_transport_header(skb, sizeof(*iph)); -- if (tun->cb.except_cb) { -- tun->cb.except_cb(tun->cb.app_data, skb); -- ctx->hstats.outer_cb++; -- return; -- } - nss_ipsecmgr_ctx_route_ipv4(skb, ctx); - return; - } -@@ -631,11 +622,6 @@ void nss_ipsecmgr_ctx_rx_outer(struct ne - } - - skb_set_transport_header(skb, sizeof(*ip6h)); -- if (tun->cb.except_cb) { -- tun->cb.except_cb(tun->cb.app_data, skb); -- ctx->hstats.outer_cb++; -- return; -- } - nss_ipsecmgr_ctx_route_ipv6(skb, ctx); - return; - } -@@ -731,7 +717,6 @@ void nss_ipsecmgr_ctx_rx_stats(void *app - struct nss_ipsecmgr_sa *sa; - void *app_data; - -- event.type = NSS_IPSECMGR_EVENT_SA_STATS; - write_lock(&ipsecmgr_drv->lock); - - sa = nss_ipsecmgr_sa_find(sa_db, &sync->sa_tuple); -@@ -874,30 +859,13 @@ struct nss_ipsecmgr_ctx *nss_ipsecmgr_ct - } - - /* -- * nss_ipsecmgr_ctx_attach() -- * Attach context to the database -- */ --void nss_ipsecmgr_ctx_attach(struct list_head *db, struct nss_ipsecmgr_ctx *ctx) --{ -- struct nss_ipsecmgr_tunnel *tun = ctx->tun; -- -- list_add(&ctx->list, db); -- -- /* -- * Add ctx->ref to tun->ref -- */ -- write_lock_bh(&ipsecmgr_drv->lock); -- nss_ipsecmgr_ref_add(&ctx->ref, &tun->ref); -- write_unlock_bh(&ipsecmgr_drv->lock); --} -- --/* - * nss_ipsecmgr_ctx_config() - * Configure context - */ - bool nss_ipsecmgr_ctx_config(struct nss_ipsecmgr_ctx *ctx) - { - enum nss_ipsec_cmn_msg_type msg_type = NSS_IPSEC_CMN_MSG_TYPE_CTX_CONFIG; -+ struct nss_ipsecmgr_tunnel *tun = ctx->tun; - struct nss_ipsec_cmn_ctx *ctx_msg; - struct nss_ipsec_cmn_msg nicm; - nss_tx_status_t status; -@@ -907,7 +875,6 @@ bool nss_ipsecmgr_ctx_config(struct nss_ - ctx_msg = &nicm.msg.ctx; - ctx_msg->type = ctx->state.type; - ctx_msg->except_ifnum = ctx->state.except_ifnum; -- ctx_msg->sibling_ifnum = ctx->state.sibling_ifnum; - - status = nss_ipsec_cmn_tx_msg_sync(ctx->nss_ctx, ctx->ifnum, msg_type, sizeof(*ctx_msg), &nicm); - if (status != NSS_TX_SUCCESS) { -@@ -916,6 +883,10 @@ bool nss_ipsecmgr_ctx_config(struct nss_ - return false; - } - -+ write_lock_bh(&ipsecmgr_drv->lock); -+ nss_ipsecmgr_ref_add(&ctx->ref, &tun->ref); -+ write_unlock_bh(&ipsecmgr_drv->lock); -+ - return true; - } - -@@ -941,7 +912,6 @@ struct nss_ipsecmgr_ctx *nss_ipsecmgr_ct - uint32_t features) - { - struct nss_ipsecmgr_ctx *ctx; -- int32_t ifnum; - - ctx = kzalloc(sizeof(*ctx), in_atomic() ? GFP_ATOMIC : GFP_KERNEL); - if (!ctx) { -@@ -955,14 +925,13 @@ struct nss_ipsecmgr_ctx *nss_ipsecmgr_ct - ctx->state.type = ctx_type; - ctx->state.di_type = di_type; - -- ifnum = nss_dynamic_interface_alloc_node(di_type); -- if (ifnum < 0) { -+ ctx->ifnum = nss_dynamic_interface_alloc_node(di_type); -+ if (ctx->ifnum < 0) { - nss_ipsecmgr_warn("%px: failed to allocate dynamic interface(%d)", tun, di_type); - kfree(ctx); - return NULL; - } - -- ctx->ifnum = ifnum; - ctx->state.stats_len = ctx->state.print_len = nss_ipsecmgr_ctx_stats_size(); - nss_ipsecmgr_ref_init(&ctx->ref, nss_ipsecmgr_ctx_del_ref, nss_ipsecmgr_ctx_free_ref); - nss_ipsecmgr_ref_init_print(&ctx->ref, nss_ipsecmgr_ctx_print_len, nss_ipsecmgr_ctx_print); ---- a/ipsecmgr/v2.0/nss_ipsecmgr_ctx.h -+++ b/ipsecmgr/v2.0/nss_ipsecmgr_ctx.h -@@ -43,7 +43,7 @@ struct nss_ipsecmgr_ctx_host_stats { - uint64_t inner_fail_flow; /* Failed to find flow for inner packet */ - uint64_t outer_exp; /* Host processed inner IPv6 exceptioned packet */ - uint64_t outer_exp_drop; /* Host processed and dropped inner IPv6 exceptioned packet */ -- uint64_t outer_cb; /* Number of times exception call back called for outer packet */ -+ uint64_t outer_cb; /* Number of times data call back called for inner packet */ - uint64_t outer_fail_dev; /* Failed to find netdevice for inner packet */ - uint64_t outer_fail_sa; /* Failed to find SA for outer packet */ - uint64_t outer_fail_flow; /* Failed to find flow for outer packet */ -@@ -70,7 +70,6 @@ struct nss_ipsecmgr_ctx_stats_priv { - uint64_t exceptioned; /* Exceptioned to host */ - uint64_t linearized; /* Linearized packets */ - uint64_t redirected; /* Redirected from inline */ -- uint64_t dropped; /* Total dropped packets */ - uint64_t fail_sa; /* Failed to find SA */ - uint64_t fail_flow; /* Failed to find flow */ - uint64_t fail_stats; /* Failed to send statistics */ -@@ -78,9 +77,6 @@ struct nss_ipsecmgr_ctx_stats_priv { - uint64_t fail_transform; /* Failed to transform */ - uint64_t fail_linearized; /* Failed to linearized */ - uint64_t fail_mdata_ver; /* Invalid meta data version */ -- uint64_t fail_ctx_active; /* Failed to queue as ctx is not active. */ -- uint64_t fail_pbuf_crypto; /* Failed to allocate pbuf for crypto operation */ -- uint64_t fail_queue_crypto; /* Failed to queue pbuf to crypto pnode */ - }; - - /* -@@ -90,7 +86,6 @@ struct nss_ipsecmgr_ctx_state { - ssize_t print_len; /* Print buffer length */ - ssize_t stats_len; /* Total stats length */ - uint32_t except_ifnum; /* Exception interface number */ -- uint32_t sibling_ifnum; /* Sibling interface number */ - enum nss_ipsec_cmn_ctx_type type; /* Type */ - enum nss_dynamic_interface_type di_type; /* Dynamic interface type */ - }; -@@ -112,19 +107,20 @@ struct nss_ipsecmgr_ctx { - }; - - /* -- * Set the exception interface number for context -+ * nss_ipsecmgr_ctx_attach() -+ * Attach context to the database - */ --static inline void nss_ipsecmgr_ctx_set_except(struct nss_ipsecmgr_ctx *ctx, uint32_t except_ifnum) -+static inline void nss_ipsecmgr_ctx_attach(struct list_head *db, struct nss_ipsecmgr_ctx *ctx) - { -- ctx->state.except_ifnum = except_ifnum; -+ list_add(&ctx->list, db); - } - - /* -- * Set the sibling interface number for context -+ * Set the exception interface number for context - */ --static inline void nss_ipsecmgr_ctx_set_sibling(struct nss_ipsecmgr_ctx *ctx, uint32_t sibling_ifnum) -+static inline void nss_ipsecmgr_ctx_set_except(struct nss_ipsecmgr_ctx *ctx, uint32_t except_ifnum) - { -- ctx->state.sibling_ifnum = sibling_ifnum; -+ ctx->state.except_ifnum = except_ifnum; - } - - extern const struct file_operations ipsecmgr_ctx_file_ops; -@@ -135,7 +131,6 @@ extern void nss_ipsecmgr_ctx_rx_redir(st - extern void nss_ipsecmgr_ctx_rx_outer(struct net_device *dev, struct sk_buff *skb, struct napi_struct *napi); - extern void nss_ipsecmgr_ctx_rx_inner(struct net_device *dev, struct sk_buff *skb, struct napi_struct *napi); - --extern void nss_ipsecmgr_ctx_attach(struct list_head *db, struct nss_ipsecmgr_ctx *ctx); - extern bool nss_ipsecmgr_ctx_config(struct nss_ipsecmgr_ctx *ctx); - extern void nss_ipsecmgr_ctx_free(struct nss_ipsecmgr_ctx *ctx); - extern struct nss_ipsecmgr_ctx *nss_ipsecmgr_ctx_alloc(struct nss_ipsecmgr_tunnel *tun, ---- a/ipsecmgr/v2.0/nss_ipsecmgr_flow.c -+++ b/ipsecmgr/v2.0/nss_ipsecmgr_flow.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2020, 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. -@@ -149,10 +149,10 @@ static bool nss_ipsecmgr_flow_update_db( - - hash_idx = nss_ipsecmgr_flow_tuple2hash(&flow->state.tuple, NSS_IPSECMGR_FLOW_MAX); - -- write_lock_bh(&ipsecmgr_drv->lock); -+ write_lock(&ipsecmgr_drv->lock); - sa = nss_ipsecmgr_sa_find(ipsecmgr_drv->sa_db, sa_tuple); - if (!sa) { -- write_unlock_bh(&ipsecmgr_drv->lock); -+ write_unlock(&ipsecmgr_drv->lock); - nss_ipsecmgr_trace("%px: failed to find SA during flow update", flow); - return false; - } -@@ -163,7 +163,7 @@ static bool nss_ipsecmgr_flow_update_db( - */ - nss_ipsecmgr_ref_add(&flow->ref, &sa->ref); - list_add(&flow->list, &ipsecmgr_drv->flow_db[hash_idx]); -- write_unlock_bh(&ipsecmgr_drv->lock); -+ write_unlock(&ipsecmgr_drv->lock); - return true; - } - -@@ -215,7 +215,7 @@ static void nss_ipsecmgr_flow_del_ref(st - * Write lock needs to be held by the caller since flow db is - * getting modified. - */ -- nss_ipsecmgr_write_lock_is_held(&ipsecmgr_drv->lock); -+ BUG_ON(write_can_lock(&ipsecmgr_drv->lock)); - list_del_init(&flow->list); - } - ---- a/ipsecmgr/v2.0/nss_ipsecmgr_priv.h -+++ b/ipsecmgr/v2.0/nss_ipsecmgr_priv.h -@@ -1,6 +1,6 @@ - /* - * ******************************************************************************** -- * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2019, 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. -@@ -20,8 +20,6 @@ - #define __NSS_IPSECMGR_PRIV_H - - #include --#include --#include - - #define NSS_IPSECMGR_DEBUG_LVL_ERROR 1 /**< Turn on debug for an error. */ - #define NSS_IPSECMGR_DEBUG_LVL_WARN 2 /**< Turn on debug for a warning. */ -@@ -78,16 +76,6 @@ - #define NSS_IPSECMGR_PRINT_SHORT NSS_IPSECMGR_PRINT_BYTES(2) - #define NSS_IPSECMGR_PRINT_BYTE NSS_IPSECMGR_PRINT_BYTES(1) - #define NSS_IPSECMGR_PRINT_IPADDR (NSS_IPSECMGR_PRINT_WORD * 4) --/* -- * Check if lock is held -- */ --#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 14, 196)) --#define nss_ipsecmgr_write_lock_is_held(x) BUG_ON(write_can_lock(x)) --#define nss_ipsecmgr_lock_is_held(x) BUG_ON(read_can_lock(x)) --#else --#define nss_ipsecmgr_lock_is_held(x) lockdep_assert_held(x) --#define nss_ipsecmgr_write_lock_is_held(x) lockdep_assert_held_write(x) --#endif - - /* - * Statistics dump information ---- a/ipsecmgr/v2.0/nss_ipsecmgr_ref.c -+++ b/ipsecmgr/v2.0/nss_ipsecmgr_ref.c -@@ -140,7 +140,7 @@ ssize_t nss_ipsecmgr_ref_print(struct ns - /* - * DEBUG check to see if the lock is taken before touching the list - */ -- nss_ipsecmgr_write_lock_is_held(&ipsecmgr_drv->lock); -+ BUG_ON(write_can_lock(&ipsecmgr_drv->lock)); - - len += ref->print(ref, buf); - -@@ -163,7 +163,7 @@ ssize_t nss_ipsecmgr_ref_print_len(struc - /* - * DEBUG check to see if the lock is taken before touching the list - */ -- nss_ipsecmgr_write_lock_is_held(&ipsecmgr_drv->lock); -+ BUG_ON(write_can_lock(&ipsecmgr_drv->lock)); - - list_for_each_entry(entry, &ref->head, node) { - total_len += nss_ipsecmgr_ref_print_len(entry); -@@ -203,7 +203,7 @@ void nss_ipsecmgr_ref_del(struct nss_ips - /* - * DEBUG check to see if the lock is taken before touching the list - */ -- nss_ipsecmgr_write_lock_is_held(&ipsecmgr_drv->lock); -+ BUG_ON(write_can_lock(&ipsecmgr_drv->lock)); - - while (!list_empty(&ref->head)) { - entry = list_first_entry(&ref->head, struct nss_ipsecmgr_ref, node); -@@ -231,7 +231,7 @@ void nss_ipsecmgr_ref_add(struct nss_ips - /* - * DEBUG check to see if the lock is taken before touching the list - */ -- nss_ipsecmgr_write_lock_is_held(&ipsecmgr_drv->lock); -+ BUG_ON(write_can_lock(&ipsecmgr_drv->lock)); - - /* - * if child is already part of an existing chain then remove it before ---- a/ipsecmgr/v2.0/nss_ipsecmgr_ref.h -+++ b/ipsecmgr/v2.0/nss_ipsecmgr_ref.h -@@ -1,6 +1,6 @@ - /* - * ******************************************************************************** -- * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2019, 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. -@@ -42,12 +42,6 @@ struct nss_ipsecmgr_ref { - nss_ipsecmgr_ref_method_t del; /* unlink function */ - }; - --/* Check if the reference tree is empty */ --static inline bool nss_ipsecmgr_ref_is_empty(struct nss_ipsecmgr_ref *ref) --{ -- return list_empty(&ref->head); --} -- - /* functions to operate on reference object */ - extern ssize_t nss_ipsecmgr_ref_print_len(struct nss_ipsecmgr_ref *ref); - extern ssize_t nss_ipsecmgr_ref_print(struct nss_ipsecmgr_ref *ref, char *buf); ---- a/ipsecmgr/v2.0/nss_ipsecmgr_sa.c -+++ b/ipsecmgr/v2.0/nss_ipsecmgr_sa.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2020, 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. -@@ -130,7 +130,6 @@ static const struct nss_ipsecmgr_print i - {"\tfail_transform", NSS_IPSECMGR_PRINT_DWORD}, - {"\tfail_crypto", NSS_IPSECMGR_PRINT_DWORD}, - {"\tfail_classification", NSS_IPSECMGR_PRINT_DWORD}, -- {"\tis_stopped", NSS_IPSECMGR_PRINT_DWORD}, - }; - - /* -@@ -364,7 +363,6 @@ static nss_ipsecmgr_status_t nss_ipsecmg - if (!rt_keys) { - nss_ipsecmgr_warn("%px: failed to allocate key memory\n", sa); - crypto_free_aead(sa->aead); -- sa->aead = NULL; - return NSS_IPSECMGR_FAIL_NOMEM; - } - -@@ -390,7 +388,6 @@ static nss_ipsecmgr_status_t nss_ipsecmg - if (crypto_aead_setkey(sa->aead, rt_keys, keylen)) { - nss_ipsecmgr_warn("%px: failed to configure keys\n", sa); - crypto_free_aead(sa->aead); -- sa->aead = NULL; - vfree(rt_keys); - return NSS_IPSECMGR_INVALID_KEYLEN; - } -@@ -417,7 +414,6 @@ static nss_ipsecmgr_status_t nss_ipsecmg - if (crypto_ahash_setkey(sa->ahash, keys->auth_key, keys->auth_keylen)) { - nss_ipsecmgr_warn("%px: failed to configure keys\n", sa); - crypto_free_ahash(sa->ahash); -- sa->ahash = NULL; - return NSS_IPSECMGR_INVALID_KEYLEN; - } - -@@ -448,7 +444,6 @@ static nss_ipsecmgr_status_t nss_ipsecmg - if (!rt_keys) { - nss_ipsecmgr_warn("%px: failed to allocate key memory\n", sa); - crypto_free_aead(sa->aead); -- sa->aead = NULL; - return NSS_IPSECMGR_FAIL_NOMEM; - } - -@@ -458,7 +453,6 @@ static nss_ipsecmgr_status_t nss_ipsecmg - if (crypto_aead_setkey(sa->aead, rt_keys, keylen)) { - nss_ipsecmgr_warn("%px: failed to configure keys\n", sa); - crypto_free_aead(sa->aead); -- sa->aead = NULL; - vfree(rt_keys); - return NSS_IPSECMGR_INVALID_KEYLEN; - } -@@ -486,15 +480,11 @@ static nss_ipsecmgr_status_t nss_ipsecmg - */ - static void nss_ipsecmgr_sa_free(struct nss_ipsecmgr_sa *sa) - { -- if (sa->aead) { -+ if (sa->aead) - crypto_free_aead(sa->aead); -- sa->aead = NULL; -- } - -- if (sa->ahash) { -+ if (sa->ahash) - crypto_free_ahash(sa->ahash); -- sa->ahash = NULL; -- } - - kfree(sa); - } -@@ -513,7 +503,7 @@ static void nss_ipsecmgr_sa_del_ref(stru - * Linux does not provide any specific API(s) to test for RW locks. The caller - * being internal is assumed to hold write lock before initiating this. - */ -- nss_ipsecmgr_write_lock_is_held(&ipsecmgr_drv->lock); -+ BUG_ON(write_can_lock(&ipsecmgr_drv->lock)); - - list_del_init(&sa->list); - -@@ -789,10 +779,6 @@ void nss_ipsecmgr_sa_sync2stats(struct n - stats->seq_start = sync->replay.seq_start; - stats->seq_cur = sync->replay.seq_cur; - } -- -- stats->fail_replay_win = sa_stats->fail_replay_win; -- stats->fail_replay_dup = sa_stats->fail_replay_dup; -- stats->fail_auth = sa_stats->fail_auth; - } - - /* -@@ -809,7 +795,7 @@ void nss_ipsecmgr_sa_sync_state(struct n - * DEBUG check to see if the lock is taken before accessing - * SA entry in the database - */ -- nss_ipsecmgr_write_lock_is_held(&ipsecmgr_drv->lock); -+ BUG_ON(write_can_lock(&ipsecmgr_drv->lock)); - - for (num = 0; num < sizeof(sa->stats)/sizeof(*sa_stats); num++) { - sa_stats[num] += msg_stats[num]; -@@ -1082,85 +1068,6 @@ bool nss_ipsecmgr_sa_verify(struct net_d - EXPORT_SYMBOL(nss_ipsecmgr_sa_verify); - - /* -- * nss_ipsecmgr_cra_name2algo() -- * Returns nss_ipsecmgr_algo -- */ --enum nss_ipsecmgr_algo nss_ipsecmgr_cra_name2algo(const char *cra_name) --{ -- enum nss_ipsecmgr_algo algo = NSS_IPSECMGR_ALGO_AES_CBC_SHA1_HMAC; -- const char **algo_name = ipsecmgr_algo_name; -- -- for (; algo < NSS_IPSECMGR_ALGO_MAX; algo++, algo_name++) { -- if (!strncmp(cra_name, *algo_name, strlen(*algo_name))) { -- return algo; -- } -- } -- -- return NSS_IPSECMGR_ALGO_MAX; --} --EXPORT_SYMBOL(nss_ipsecmgr_cra_name2algo); -- --/* -- * nss_ipsecmgr_sa_get_info() -- * Get Crypto information for an already created SA. -- */ --bool nss_ipsecmgr_sa_get_info(struct net_device *dev, struct nss_ipsecmgr_sa_tuple *tuple, -- struct nss_ipsecmgr_sa_info *sa_info) --{ -- struct nss_ipsec_cmn_sa_tuple sa_tuple = {0}; -- struct nss_ipsecmgr_sa *sa; -- uint32_t mask; -- -- /* -- * Look for an existing SA. -- */ -- nss_ipsecmgr_sa2tuple(tuple, &sa_tuple); -- -- read_lock_bh(&ipsecmgr_drv->lock); -- sa = nss_ipsecmgr_sa_find(ipsecmgr_drv->sa_db, &sa_tuple); -- if (!sa) { -- read_unlock_bh(&ipsecmgr_drv->lock); -- return false; -- } -- -- sa_info->blk_len = sa->state.data.blk_len; -- sa_info->iv_len = sa->state.data.iv_len; -- sa_info->hash_len = sa->state.data.icv_len; -- sa_info->session_idx = sa->state.tuple.crypto_index; -- -- sa_info->hdr_len = sizeof(struct ip_esp_hdr) + sa_info->iv_len; -- mask = NSS_IPSEC_CMN_FLAG_HDR_MASK | NSS_IPSEC_CMN_FLAG_MODE_TRANS; -- -- switch (sa->state.data.flags & mask) { -- case NSS_IPSEC_CMN_FLAG_IPV4_NATT | NSS_IPSEC_CMN_FLAG_MODE_TRANS: -- sa_info->hdr_len += sizeof(struct udphdr); -- break; -- case NSS_IPSEC_CMN_FLAG_IPV6 | NSS_IPSEC_CMN_FLAG_MODE_TRANS: -- case NSS_IPSEC_CMN_FLAG_MODE_TRANS: -- break; -- case NSS_IPSEC_CMN_FLAG_IPV4_NATT: -- sa_info->hdr_len += sizeof(struct iphdr) + sizeof(struct udphdr); -- break; -- case NSS_IPSEC_CMN_FLAG_IPV6: -- sa_info->hdr_len += sizeof(struct ipv6hdr); -- break; -- default: -- sa_info->hdr_len += sizeof(struct iphdr); -- break; -- } -- -- read_unlock_bh(&ipsecmgr_drv->lock); -- -- /* -- * The user of trailer_len should take care of the odd length. -- */ -- sa_info->trailer_len = sa_info->blk_len + 1 + sa_info->hash_len; -- -- return true; --} --EXPORT_SYMBOL(nss_ipsecmgr_sa_get_info); -- --/* - * nss_ipsecmgr_sa_tx_inner() - * Offload given SKB to NSS for inner processing. - */ ---- a/ipsecmgr/v2.0/nss_ipsecmgr_sa.h -+++ b/ipsecmgr/v2.0/nss_ipsecmgr_sa.h -@@ -1,6 +1,6 @@ - /* - * ******************************************************************************** -- * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2019, 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. -@@ -62,8 +62,7 @@ struct nss_ipsecmgr_sa_stats_priv { - uint64_t fail_hash_len; /**< Failure in decap due to bad hash block len. */ - uint64_t fail_transform; /**< Failure in transformation; general error. */ - uint64_t fail_crypto; /**< Failure in crypto transformation. */ -- uint64_t fail_cle; /**< Failure in classification; general failure */ -- uint64_t is_stopped; /**< Indicates if SA is stopped; eg: seq overflow */ -+ uint64_t fail_cle; /* Failure in classification; general failure */ - }; - - /* ---- a/ipsecmgr/v2.0/nss_ipsecmgr_tunnel.c -+++ b/ipsecmgr/v2.0/nss_ipsecmgr_tunnel.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2020, 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. -@@ -128,14 +128,6 @@ static netdev_tx_t nss_ipsecmgr_tunnel_t - } - - /* -- * Linearize the nonlinear SKB. -- */ -- if (skb_linearize(skb)) { -- nss_ipsecmgr_trace("%s: unable to Linearize SKB\n", dev->name); -- goto free; -- } -- -- /* - * For all these cases - * - create a writable copy of buffer - * - increase the head room -@@ -227,10 +219,10 @@ free: - } - - /* -- * nss_ipsecmgr_tunnel_get_stats64() -+ * nss_ipsecmgr_tunnel_stats64() - * Get device statistics - */ --static struct rtnl_link_stats64 *nss_ipsecmgr_tunnel_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) -+static struct rtnl_link_stats64 *nss_ipsecmgr_tunnel_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) - { - struct nss_ipsecmgr_tunnel *tun = netdev_priv(dev); - struct list_head *head = &tun->ctx_db; -@@ -248,22 +240,6 @@ static struct rtnl_link_stats64 *nss_ips - } - - /* -- * nss_ipsecmgr_tunnel_stats64() -- * Sync statistics to linux -- */ --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) --static struct rtnl_link_stats64 *nss_ipsecmgr_tunnel_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) --{ -- return nss_ipsecmgr_tunnel_get_stats64(dev, stats); --} --#else --static void nss_ipsecmgr_tunnel_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) --{ -- nss_ipsecmgr_tunnel_get_stats64(dev, stats); --} --#endif -- --/* - * nss_ipsecmgr_tunnel_mtu_update() - * Update tunnel max MTU - */ -@@ -273,7 +249,7 @@ static void nss_ipsecmgr_tunnel_mtu_upda - uint16_t max_mtu = 0; - bool update_mtu = false; - -- write_lock_bh(&ipsecmgr_drv->lock); -+ write_lock(&ipsecmgr_drv->lock); - list_for_each_entry(tun, head, list) { - if (tun->dev->mtu > max_mtu) - max_mtu = tun->dev->mtu; -@@ -284,7 +260,7 @@ static void nss_ipsecmgr_tunnel_mtu_upda - update_mtu = true; - } - -- write_unlock_bh(&ipsecmgr_drv->lock); -+ write_unlock(&ipsecmgr_drv->lock); - - #ifdef NSS_IPSECMGR_PPE_SUPPORT - /* -@@ -337,29 +313,7 @@ static const struct net_device_ops ipsec - */ - static void nss_ipsecmgr_tunnel_free(struct net_device *dev) - { -- struct nss_ipsecmgr_tunnel *tun = netdev_priv(dev); -- struct nss_ipsecmgr_ref *ref, *tmp; -- struct list_head free_refs; -- - nss_ipsecmgr_info("IPsec tunnel device(%s) freed\n", dev->name); -- -- INIT_LIST_HEAD(&free_refs); -- -- /* -- * Remove context(s) from the tunnel reference tree if it has been -- * added -- */ -- write_lock_bh(&ipsecmgr_drv->lock); -- if (!nss_ipsecmgr_ref_is_empty(&tun->ref)) { -- nss_ipsecmgr_ref_del(&tun->ref, &free_refs); -- } -- -- write_unlock_bh(&ipsecmgr_drv->lock); -- -- list_for_each_entry_safe(ref, tmp, &free_refs, node) { -- ref->free(ref); -- } -- - free_netdev(dev); - } - -@@ -397,14 +351,13 @@ static void nss_ipsecmgr_tunnel_free_ref - { - struct nss_ipsecmgr_tunnel *tun = container_of(ref, struct nss_ipsecmgr_tunnel, ref); - -+ nss_ipsecmgr_tunnel_mtu_update(&ipsecmgr_drv->tun_db); -+ - /* - * The unregister should start here but the expectation is that the free would - * happen when the reference count goes down to '0' - */ -- if (tun->dev->reg_state == NETREG_REGISTERED) { -- nss_ipsecmgr_tunnel_mtu_update(&ipsecmgr_drv->tun_db); -- rtnl_is_locked() ? unregister_netdevice(tun->dev) : unregister_netdev(tun->dev); -- } -+ rtnl_is_locked() ? unregister_netdevice(tun->dev) : unregister_netdev(tun->dev); - } - - /* -@@ -436,11 +389,7 @@ static void nss_ipsecmgr_tunnel_setup(st - dev->header_ops = NULL; - dev->netdev_ops = &ipsecmgr_dev_ops; - --#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 11, 8)) - dev->destructor = nss_ipsecmgr_tunnel_free; --#else -- dev->priv_destructor = nss_ipsecmgr_tunnel_free; --#endif - - /* - * Get the MAC address from the ethernet device -@@ -524,11 +473,9 @@ struct net_device *nss_ipsecmgr_tunnel_a - NSS_IPSEC_CMN_FEATURE_INLINE_ACCEL); - if (!inner) { - nss_ipsecmgr_warn("%px: failed to allocate context inner\n", tun); -- goto free; -+ goto free_dev; - } - -- nss_ipsecmgr_ctx_attach(&tun->ctx_db, inner); -- - /* - * Inner Metadata context allocation - */ -@@ -540,10 +487,9 @@ struct net_device *nss_ipsecmgr_tunnel_a - 0); - if (!mdata_inner) { - nss_ipsecmgr_warn("%px: failed to allocate context metadata inner\n", tun); -- goto free; -+ goto free_inner; - } - -- nss_ipsecmgr_ctx_attach(&tun->ctx_db, mdata_inner); - /* - * Outer context allocation - */ -@@ -555,10 +501,9 @@ struct net_device *nss_ipsecmgr_tunnel_a - NSS_IPSEC_CMN_FEATURE_INLINE_ACCEL); - if (!outer) { - nss_ipsecmgr_warn("%px: failed to allocate context outer\n", tun); -- goto free; -+ goto free_mdata_inner; - } - -- nss_ipsecmgr_ctx_attach(&tun->ctx_db, outer); - /* - * Outer metadata context allocation - */ -@@ -570,9 +515,13 @@ struct net_device *nss_ipsecmgr_tunnel_a - 0); - if (!mdata_outer) { - nss_ipsecmgr_warn("%px: failed to allocate context metadata outer\n", tun); -- goto free; -+ goto free_outer; - } - -+ nss_ipsecmgr_ctx_attach(&tun->ctx_db, inner); -+ nss_ipsecmgr_ctx_attach(&tun->ctx_db, mdata_inner); -+ -+ nss_ipsecmgr_ctx_attach(&tun->ctx_db, outer); - nss_ipsecmgr_ctx_attach(&tun->ctx_db, mdata_outer); - - /* -@@ -587,49 +536,35 @@ struct net_device *nss_ipsecmgr_tunnel_a - nss_ipsecmgr_ctx_set_except(outer, inner->ifnum); - nss_ipsecmgr_ctx_set_except(mdata_outer, inner->ifnum); - -- /* -- * We need to setup the sibling interface number for inner & outer; -- * The sibling interface is used by the NSS to configure SA on sibling. -- */ -- nss_ipsecmgr_ctx_set_sibling(inner, mdata_inner->ifnum); -- nss_ipsecmgr_ctx_set_sibling(outer, mdata_outer->ifnum); -- - if (!nss_ipsecmgr_ctx_config(inner)) { - nss_ipsecmgr_warn("%px: failed to configure inner context\n", tun); -- goto free; -+ goto free_mdata_outer; - } - - if (!nss_ipsecmgr_ctx_config(mdata_inner)) { - nss_ipsecmgr_warn("%px: failed to configure metadata inner context\n", tun); -- goto free; -+ goto free_mdata_outer; - } - - if (!nss_ipsecmgr_ctx_config(outer)) { - nss_ipsecmgr_warn("%px: failed to configure outer context\n", tun); -- goto free; -+ goto free_mdata_outer; - } - - if (!nss_ipsecmgr_ctx_config(mdata_outer)) { - nss_ipsecmgr_warn("%px: failed to configure metadata outer context\n", tun); -- goto free; -+ goto free_mdata_outer; - } - - status = rtnl_is_locked() ? register_netdevice(dev) : register_netdev(dev); - if (status < 0) { - nss_ipsecmgr_warn("%px: register net dev failed :%s\n", tun, dev->name); --#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 11, 8)) -- goto free; --#else -- /* -- * Later kernels invoke the destructor upon failure -- */ -- return NULL; --#endif -+ goto free_mdata_outer; - } - -- write_lock_bh(&ipsecmgr_drv->lock); -+ write_lock(&ipsecmgr_drv->lock); - list_add(&tun->list, &ipsecmgr_drv->tun_db); -- write_unlock_bh(&ipsecmgr_drv->lock); -+ write_unlock(&ipsecmgr_drv->lock); - - nss_ipsecmgr_tunnel_mtu(dev, skb_dev ? skb_dev->mtu : dev->mtu); - -@@ -645,12 +580,16 @@ struct net_device *nss_ipsecmgr_tunnel_a - } - - return dev; --free: --#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 11, 8)) -- dev->destructor(dev); --#else -- dev->priv_destructor(dev); --#endif -+free_mdata_outer: -+ nss_ipsecmgr_ctx_free(mdata_outer); -+free_outer: -+ nss_ipsecmgr_ctx_free(outer); -+free_mdata_inner: -+ nss_ipsecmgr_ctx_free(mdata_inner); -+free_inner: -+ nss_ipsecmgr_ctx_free(inner); -+free_dev: -+ free_netdev(dev); - return NULL; - } - EXPORT_SYMBOL(nss_ipsecmgr_tunnel_add); ---- a/ipsecmgr/v2.0/plugins/klips/Makefile -+++ b/ipsecmgr/v2.0/plugins/klips/Makefile -@@ -10,7 +10,7 @@ ccflags-y += -I$(obj)/../../include - ccflags-y += -I$(obj)/ - ccflags-y += -DNSS_IPSEC_KLIPS_DEBUG_LEVEL=3 - ccflags-y += -DNSS_IPSEC_KLIPS_BUILD_ID="$(BUILD_ID)" --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - ifeq ($(SoC),$(filter $(SoC),ipq807x ipq807x_64)) - ccflags-y += -DNSS_CFI_IPQ807X_SUPPORT - endif -@@ -18,7 +18,3 @@ endif - ifeq ($(SoC),$(filter $(SoC),ipq60xx ipq60xx_64)) - ccflags-y += -DNSS_CFI_IPQ60XX_SUPPORT - endif -- --ifeq ($(SoC),$(filter $(SoC),ipq50xx ipq50xx_64)) --ccflags-y += -DNSS_CFI_IPQ50XX_SUPPORT --endif ---- a/ipsecmgr/v2.0/plugins/klips/nss_ipsec_klips.c -+++ b/ipsecmgr/v2.0/plugins/klips/nss_ipsec_klips.c -@@ -1,5 +1,4 @@ --/* -- * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. -+/* Copyright (c) 2018-2020, 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 -@@ -13,10 +12,11 @@ - * 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. -+ * -+ * - */ - --/* -- * nss_ipsec_klips.c -+/* nss_ipsec_klips.c - * NSS IPsec offload glue for Openswan/KLIPS - */ - #include -@@ -51,9 +51,6 @@ - #if defined(NSS_L2TPV2_ENABLED) - #include - #endif --#if defined(NSS_VXLAN_ENABLED) --#include --#endif - #include "nss_ipsec_klips.h" - - #define NSS_IPSEC_KLIPS_BASE_NAME "ipsec" -@@ -62,7 +59,6 @@ - #define NSS_IPSEC_KLIPS_FLAG_NATT 0x00000001 - #define NSS_IPSEC_KLIPS_FLAG_TRANSPORT_MODE 0x00000002 - #define NSS_IPSEC_KLIPS_SKB_CB_MAGIC 0xAAAB --#define NSS_IPSEC_KLIPS_IP6_ADDR_LEN 4 - - /* - * This is used by KLIPS for communicate the device along with the -@@ -348,32 +344,6 @@ static struct net_device *nss_ipsec_klip - return tun_dev; - } - --#if defined(NSS_L2TPV2_ENABLED) --/* -- * nss_ipsec_klips_get_inner_ifnum() -- * Get ipsecmgr interface number for klips netdevice -- * -- * Calls nss_ipsec_klips_get_tun_dev(), which holds reference for tunnel, -- * which gets released at the end of this function. -- */ --static int nss_ipsec_klips_get_inner_ifnum(struct net_device *klips_dev) --{ -- struct net_device *tun_dev; -- int32_t ipsec_ifnum; -- -- tun_dev = nss_ipsec_klips_get_tun_dev(klips_dev); -- if (!tun_dev) { -- nss_ipsec_klips_warn("%px: Tunnel device not found for klips dev", klips_dev); -- return -1; -- } -- -- ipsec_ifnum = nss_cmn_get_interface_number_by_dev_and_type(tun_dev, NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_INNER); -- dev_put(tun_dev); -- -- return ipsec_ifnum; --} --#endif -- - /* - * nss_ipsec_klips_get_tun_by_addr() - * Get the tunnel entry for given ip header from tunnel map table. -@@ -402,75 +372,6 @@ static struct nss_ipsec_klips_tun *nss_i - return NULL; - } - --#if defined(NSS_VXLAN_ENABLED) --/* -- * nss_ipsec_klips_tun_match_ip_addr() -- * Compare tunnel address with source & destination ip addresses. -- */ --static bool nss_ipsec_klips_tun_match_ip_addr(struct nss_ipsec_klips_tun *tun, uint8_t ip_ver, uint32_t *local_ip, uint32_t *remote_ip) --{ -- struct nss_ipsec_klips_tun_addr *addr = &tun->addr; -- uint32_t status = 0; -- uint8_t i; -- -- switch (ip_ver) { -- case IPVERSION: -- status += local_ip[0] ^ addr->dest[0]; -- status += remote_ip[0] ^ addr->src[0]; -- status += addr->ver ^ ip_ver; -- nss_ipsec_klips_trace("%px: tun dev comparing with IPV4 tunnel local_ip: %x & remote_ip: %x IP pair.\n", tun, addr->dest[0], addr->src[0]); -- return !status; -- -- case 6: -- status += addr->ver ^ ip_ver; -- for (i = 0; i < NSS_IPSEC_KLIPS_IP6_ADDR_LEN; i++) { -- status += local_ip[i] ^ addr->dest[i]; -- status += remote_ip[i] ^ addr->src[i]; -- nss_ipsec_klips_trace("%px: tun dev comparing with IPV6 tunnel local_ip[%u]: %x & remote_ip[%u]: %x IP pair.\n", tun, i, addr->dest[i], i, addr->src[i]); -- } -- return !status; -- -- default: -- nss_ipsec_klips_warn("%px: non ip version:%u received", tun, ip_ver); -- return false; -- } --} -- --/* -- * nss_ipsec_klips_get_ipsec_ifnum() -- * Get ipsecmgr tunnel interface num for klips netdevice -- */ --static int32_t __maybe_unused nss_ipsec_klips_get_ipsec_ifnum(uint8_t ip_ver, uint32_t *local_ip, uint32_t *remote_ip) --{ -- struct nss_ipsec_klips_tun *tun; -- struct net_device *tun_dev; -- uint32_t if_num = -1; -- uint32_t i; -- -- read_lock(&tunnel_map.lock); -- -- for (i = 0, tun = tunnel_map.tbl; i < tunnel_map.max; i++, tun++) { -- if (!tun->klips_dev) { -- nss_ipsec_klips_warn("%px: klips dev is NULL.\n", tun); -- continue; -- } -- -- if (nss_ipsec_klips_tun_match_ip_addr(tun, ip_ver, local_ip, remote_ip)) { -- tun_dev = tun->nss_dev; -- if_num = nss_cmn_get_interface_number_by_dev_and_type(tun_dev, NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_INNER); -- nss_ipsec_klips_warn("%px: tun dev(with ifnum:%d) is mapped with local & remote IP pair.\n", tun, if_num); -- read_unlock(&tunnel_map.lock); -- return if_num; -- } -- } -- -- read_unlock(&tunnel_map.lock); -- -- nss_ipsec_klips_warn("%px: tun dev not found with the local(%pI4) & remote(%pI4) IP pair.\n", tun, local_ip, remote_ip); -- return -1; --} --#endif -- - /* - * nss_ipsec_klips_get_index() - * given an interface name retrived the numeric suffix -@@ -2070,14 +1971,7 @@ static struct notifier_block nss_ipsec_k - - #if defined(NSS_L2TPV2_ENABLED) - static struct l2tpmgr_ipsecmgr_cb nss_ipsec_klips_l2tp = { -- .get_ifnum_by_dev = nss_ipsec_klips_get_inner_ifnum, -- .get_ifnum_by_ip_addr = NULL --}; --#endif -- --#if defined(NSS_VXLAN_ENABLED) --static struct nss_vxlanmgr_get_ipsec_if_num nss_ipsec_klips_vxlan_cb = { -- .get_ifnum_by_ip = nss_ipsec_klips_get_ipsec_ifnum -+ .cb = nss_ipsec_klips_get_tun_dev - }; - #endif - -@@ -2116,11 +2010,7 @@ int __init nss_ipsec_klips_init_module(v - ecm_interface_ipsec_register_callbacks(&nss_ipsec_klips_ecm); - ecm_notifier_register_connection_notify(&nss_ipsec_klips_ecm_conn_notifier); - #if defined(NSS_L2TPV2_ENABLED) -- l2tpmgr_register_ipsecmgr_callback_by_netdev(&nss_ipsec_klips_l2tp); --#endif -- --#if defined(NSS_VXLAN_ENABLED) -- nss_vxlanmgr_register_ipsecmgr_callback_by_ip(&nss_ipsec_klips_vxlan_cb); -+ l2tpmgr_register_ipsecmgr_callback(&nss_ipsec_klips_l2tp); - #endif - return 0; - } -@@ -2142,11 +2032,7 @@ void __exit nss_ipsec_klips_exit_module( - ecm_notifier_unregister_connection_notify(&nss_ipsec_klips_ecm_conn_notifier); - ecm_interface_ipsec_unregister_callbacks(); - #if defined(NSS_L2TPV2_ENABLED) -- l2tpmgr_unregister_ipsecmgr_callback_by_netdev(); --#endif -- --#if defined(NSS_VXLAN_ENABLED) -- nss_vxlanmgr_unregister_ipsecmgr_callback_by_ip(); -+ l2tpmgr_unregister_ipsecmgr_callback(); - #endif - - nss_cfi_ocf_unregister_ipsec(); ---- a/l2tp/l2tpv2/Makefile -+++ b/l2tp/l2tpv2/Makefile -@@ -1,7 +1,7 @@ - # Makefile for l2tp client - ccflags-y += -I$(obj)/../../exports -I$(obj)/../.. -I$(obj)/nss_hal/include - ccflags-y += -DNSS_L2TP_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - ifneq (,$(filter $(CONFIG_L2TP),m y)) - obj-m += qca-nss-l2tpv2.o - qca-nss-l2tpv2-objs := nss_connmgr_l2tpv2.o nss_l2tpv2_stats.o --- a/l2tp/l2tpv2/nss_connmgr_l2tpv2.c +++ b/l2tp/l2tpv2/nss_connmgr_l2tpv2.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2015-2017, 2019-2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2015-2017, 2019-2020 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. -@@ -35,7 +35,6 @@ - #include - #include - #include --#include - #include - - #include -@@ -100,11 +99,8 @@ - - static DEFINE_HASHTABLE(l2tpv2_session_data_hash_table, HASH_BUCKET_SIZE); - static int ip_ttl_max = 255; -- --#if defined(NSS_L2TP_IPSEC_BIND_BY_NETDEV) - static char l2tpoipsec_config[L2TP_SYSCTL_STR_LEN_MAX]; - static struct ctl_table_header *ctl_tbl_hdr; /* l2tpv2 sysctl */ --#endif - static struct l2tpmgr_ipsecmgr_cb __rcu ipsecmgr_cb; - - /* -@@ -248,23 +244,24 @@ static struct nss_connmgr_l2tpv2_session +@@ -244,7 +244,7 @@ static struct nss_connmgr_l2tpv2_session */ data->l2tpv2.session.session_id = session->session_id; data->l2tpv2.session.peer_session_id = session->peer_session_id; +- data->l2tpv2.session.offset = session->offset; + data->l2tpv2.session.offset = 0; data->l2tpv2.session.hdr_len = session->hdr_len; data->l2tpv2.session.reorder_timeout = session->reorder_timeout; data->l2tpv2.session.recv_seq = session->recv_seq; - data->l2tpv2.session.send_seq = session->send_seq; - -- nss_connmgr_l2tpv2_info("sess %u, peer=%u nr=%u ns=%u hdr_len=%u timeout=%x" -+ nss_connmgr_l2tpv2_info("sess %u, peer=%u nr=%u ns=%u off=%u hdr_len=%u timeout=%x" +@@ -253,7 +253,7 @@ static struct nss_connmgr_l2tpv2_session + nss_connmgr_l2tpv2_info("sess %u, peer=%u nr=%u ns=%u off=%u hdr_len=%u timeout=%x" " recv_seq=%x send_seq=%x\n", session->session_id, session->peer_session_id, session->nr, -- session->ns, session->hdr_len, +- session->ns, session->offset, session->hdr_len, + session->ns, 0, session->hdr_len, session->reorder_timeout, session->recv_seq, session->send_seq); -- /* -- * tunnel->sock->sk_no_check/sk_no_check_tx is set to true -- * if UDP checksum is not needed for the L2TP socket. -- */ -- data->l2tpv2.tunnel.udp_csum = !tunnel->sock->sk_no_check_tx; -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 16, 0)) -+ data->l2tpv2.tunnel.udp_csum = tunnel->sock->sk_no_check; -+#else -+ data->l2tpv2.tunnel.udp_csum = tunnel->sock->sk_no_check_tx; -+#endif - - inet = inet_sk(tunnel->sock); - -@@ -359,6 +356,9 @@ static void nss_connmgr_l2tpv2_exception - { - const struct iphdr *iph_outer, *iph_inner; - struct nss_connmgr_l2tpv2_session_data *ptr; -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 8, 0)) -+ struct hlist_node *node; -+#endif - uint16_t *l2tp_hdr; - uint16_t l2tp_flags; - int l2tp_hdr_len = L2TP_HDR_MIN_LEN; -@@ -374,6 +374,9 @@ static void nss_connmgr_l2tpv2_exception - - rcu_read_lock(); - hash_for_each_possible_rcu(l2tpv2_session_data_hash_table, ptr, -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 8, 0)) -+ node, -+#endif - hash_list, dev->ifindex) { - if (ptr->dev == dev) { - tunnel_local_ip = ptr->data.ip.v4.saddr.s_addr; -@@ -477,56 +480,6 @@ static void nss_connmgr_l2tpv2_event_rec - } - - /* -- * nss_connmgr_l2tpv2_bind_ipsec_by_ipaddr() -- * Bind L2TP tunnel with IPsec(xfrm) based on IP Address -- */ --static void nss_connmgr_l2tpv2_bind_ipsec_by_ipaddr(struct nss_ctx_instance *nss_ctx, struct nss_connmgr_l2tpv2_data *l2tpv2_data, uint32_t l2tp_ifnum) --{ -- struct nss_l2tpv2_msg l2tpv2msg; -- nss_tx_status_t status; -- struct nss_l2tpv2_bind_ipsec_if_msg *l2tpv2_bind_ipsec_msg; -- int32_t ipsec_ifnum = -1; -- get_ipsec_ifnum_by_ip_addr_callback_t ipsec_cb; -- -- /* -- * Check if the L2TP interface is applied over an IPsec (XFRM) interface by querying the IPsec -- * client by using the L2TP tunnel IPv4 source/destination addresses. -- */ -- rcu_read_lock(); -- ipsec_cb = rcu_dereference(ipsecmgr_cb.get_ifnum_by_ip_addr); -- ipsec_ifnum = ipsec_cb ? ipsec_cb(IPVERSION, &l2tpv2_data->ip.v4.saddr.s_addr, &l2tpv2_data->ip.v4.daddr.s_addr) : -1; -- rcu_read_unlock(); -- -- if (ipsec_ifnum < 0) { -- nss_connmgr_l2tpv2_info("%px: Invalid IPsec interface no.(0x%x) based on local & remote IP-address\n", nss_ctx, ipsec_ifnum); -- return; -- } -- -- /* -- * For, l2tpoipsec, send the command to bind the l2tp session with the IPsec interface. -- */ -- memset(&l2tpv2msg, 0, sizeof(struct nss_l2tpv2_msg)); -- nss_l2tpv2_msg_init(&l2tpv2msg, l2tp_ifnum, NSS_L2TPV2_MSG_BIND_IPSEC_IF, -- sizeof(struct nss_l2tpv2_bind_ipsec_if_msg), (void *)nss_connmgr_l2tpv2_msg_cb, NULL); -- l2tpv2_bind_ipsec_msg = &l2tpv2msg.msg.bind_ipsec_if_msg; -- l2tpv2_bind_ipsec_msg->ipsec_ifnum = ipsec_ifnum; -- -- status = nss_l2tpv2_tx(nss_ctx, &l2tpv2msg); -- if (status != NSS_TX_SUCCESS) { -- /* -- * TODO: Add retry logic. Currently it sends a warning message to user. -- * In case of bind fails, then we don't bring down L2TP tunnel, instead we give a warning log -- * to user, as this introduces a potential risk of not having a per packet check for source -- * interface number in firmware. -- */ -- nss_connmgr_l2tpv2_warning("%px: L2TPv2 interface binding with IPSec interface(0x%x) failed.\n", nss_ctx, ipsec_ifnum); -- return; -- } -- -- nss_connmgr_l2tpv2_info("%px: L2TPv2 interface is bound to IPsec interface with if_num(0x%x)\n", nss_ctx, ipsec_ifnum); --} -- --/* - * nss_connmgr_l2tpv2_dev_up() - * pppol2tpv2 interface's up event handler - */ -@@ -630,12 +583,7 @@ static int nss_connmgr_l2tpv2_dev_up(str - return NOTIFY_BAD; - } - -- nss_connmgr_l2tpv2_info("%px: nss_l2tpv2_tx() CREATE successful\n", nss_ctx); -- -- /* -- * Check if we need to bind the L2TP to an IPsec interface. This is required as per RFC3193 -- */ -- nss_connmgr_l2tpv2_bind_ipsec_by_ipaddr(nss_ctx, data, if_number); -+ nss_connmgr_l2tpv2_info("%px: nss_l2tpv2_tx() successful\n", nss_ctx); - - return NOTIFY_DONE; - } -@@ -648,6 +596,9 @@ static int nss_connmgr_l2tpv2_dev_down(s - { - struct nss_connmgr_l2tpv2_session_data *ptr; - struct hlist_node *tmp; -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 8, 0)) -+ struct hlist_node *node; -+#endif - struct nss_l2tpv2_msg l2tpv2msg; - struct nss_l2tpv2_session_destroy_msg *l2tpv2cfg; - int if_number; -@@ -671,6 +622,9 @@ static int nss_connmgr_l2tpv2_dev_down(s - } - - hash_for_each_possible_safe(l2tpv2_session_data_hash_table, ptr, -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 8, 0)) -+ node, -+#endif - tmp, hash_list, dev->ifindex) { - if (ptr->dev == dev) { - dev_put(dev); -@@ -713,7 +667,11 @@ static int nss_connmgr_l2tpv2_dev_event( - unsigned long event, void *dev) - { - struct net_device *netdev; -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 10, 0)) -+ netdev = (struct net_device *)dev; -+#else - netdev = netdev_notifier_info_to_dev(dev); -+#endif - - switch (event) { - case NETDEV_UP: -@@ -736,6 +694,9 @@ static int nss_connmgr_l2tpv2_dev_event( - int nss_connmgr_l2tpv2_get_data(struct net_device *dev, struct nss_connmgr_l2tpv2_data *data) - { - struct nss_connmgr_l2tpv2_session_data *ptr; -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 8, 0)) -+ struct hlist_node *node; -+#endif - if (!data) { - nss_connmgr_l2tpv2_info("nss_connmgr_l2tpv2_data ptr is null\n"); - return -EINVAL; -@@ -743,6 +704,9 @@ int nss_connmgr_l2tpv2_get_data(struct n - - rcu_read_lock(); - hash_for_each_possible_rcu(l2tpv2_session_data_hash_table, ptr, -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 8, 0)) -+ node, -+#endif - hash_list, dev->ifindex) { - if (ptr->dev == dev) { - memcpy(data, &ptr->data, sizeof(struct nss_connmgr_l2tpv2_data)); -@@ -763,9 +727,15 @@ EXPORT_SYMBOL(nss_connmgr_l2tpv2_get_dat - int nss_connmgr_l2tpv2_does_connmgr_track(const struct net_device *dev) - { - struct nss_connmgr_l2tpv2_session_data *ptr; -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 8, 0)) -+ struct hlist_node *node; -+#endif - - rcu_read_lock(); - hash_for_each_possible_rcu(l2tpv2_session_data_hash_table, ptr, -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 8, 0)) -+ node, -+#endif - hash_list, dev->ifindex) { - if (ptr->dev == dev) { - rcu_read_unlock(); -@@ -779,83 +749,6 @@ int nss_connmgr_l2tpv2_does_connmgr_trac - EXPORT_SYMBOL(nss_connmgr_l2tpv2_does_connmgr_track); - - /* -- * l2tpmgr_register_ipsecmgr_callback_by_ipaddr() -- * Register IPSecmgr callback. -- */ --void l2tpmgr_register_ipsecmgr_callback_by_ipaddr(struct l2tpmgr_ipsecmgr_cb *cb) --{ -- get_ipsec_ifnum_by_ip_addr_callback_t ipsec_get_ifnum_by_ip_addr; -- -- rcu_read_lock(); -- ipsec_get_ifnum_by_ip_addr = rcu_dereference(ipsecmgr_cb.get_ifnum_by_ip_addr); -- if (ipsec_get_ifnum_by_ip_addr) { -- rcu_read_unlock(); -- nss_connmgr_l2tpv2_info("%px: IPSecmgr Callback get_ifnum_by_ip_addr is already registered\n", cb); -- return; -- } -- rcu_read_unlock(); -- -- if (cb->get_ifnum_by_ip_addr == NULL) { -- nss_connmgr_l2tpv2_warning("%px: IPSecmgr Callback get_ifnum_by_ip_addr is NULL\n", cb); -- return; -- } -- -- rcu_assign_pointer(ipsecmgr_cb.get_ifnum_by_ip_addr, cb->get_ifnum_by_ip_addr); -- synchronize_rcu(); --} --EXPORT_SYMBOL(l2tpmgr_register_ipsecmgr_callback_by_ipaddr); -- --/* -- * l2tpmgr_unregister_ipsecmgr_callback_by_ipaddr -- * Unregister callback. -- */ --void l2tpmgr_unregister_ipsecmgr_callback_by_ipaddr(void) --{ -- rcu_assign_pointer(ipsecmgr_cb.get_ifnum_by_ip_addr, NULL); -- synchronize_rcu(); --} --EXPORT_SYMBOL(l2tpmgr_unregister_ipsecmgr_callback_by_ipaddr); -- --#if defined(NSS_L2TP_IPSEC_BIND_BY_NETDEV) --/* -- * l2tpmgr_register_ipsecmgr_callback_by_netdev() -- * Register IPSecmgr callback. -- */ --void l2tpmgr_register_ipsecmgr_callback_by_netdev(struct l2tpmgr_ipsecmgr_cb *cb) --{ -- get_ipsec_ifnum_by_dev_callback_t ipsec_get_ifnum_by_dev; -- -- rcu_read_lock(); -- ipsec_get_ifnum_by_dev = rcu_dereference(ipsecmgr_cb.get_ifnum_by_dev); -- if (ipsec_get_ifnum_by_dev) { -- rcu_read_unlock(); -- nss_connmgr_l2tpv2_info("%px: IPSecmgr Callback get_ifnum_by_dev is already registered\n", cb); -- return; -- } -- rcu_read_unlock(); -- -- if (cb->get_ifnum_by_dev == NULL) { -- nss_connmgr_l2tpv2_warning("%px: IPSecmgr Callback get_ifnum_by_dev is NULL\n", cb); -- return; -- } -- -- rcu_assign_pointer(ipsecmgr_cb.get_ifnum_by_dev, cb->get_ifnum_by_dev); -- synchronize_rcu(); --} --EXPORT_SYMBOL(l2tpmgr_register_ipsecmgr_callback_by_netdev); -- --/* -- * l2tpmgr_unregister_ipsecmgr_callback_by_netdev -- * Unregister callback. -- */ --void l2tpmgr_unregister_ipsecmgr_callback_by_netdev(void) --{ -- rcu_assign_pointer(ipsecmgr_cb.get_ifnum_by_dev, NULL); -- synchronize_rcu(); --} --EXPORT_SYMBOL(l2tpmgr_unregister_ipsecmgr_callback_by_netdev); -- --/* - * nss_connmgr_l2tpv2_proc_handler() - * Read and write handler for sysctl. - */ -@@ -866,14 +759,13 @@ static int nss_connmgr_l2tpv2_proc_handl - char *l2tp_device_name, *ipsec_device_name; - char *input_str = l2tpoipsec_config; - int32_t l2tp_ifnum, ipsec_ifnum; -- struct net_device *l2tpdev, *ipsecdev; -+ struct net_device *l2tpdev, *ipsecdev, *ipsectundev; - nss_tx_status_t status; - struct nss_l2tpv2_msg l2tpv2msg; -- get_ipsec_ifnum_by_dev_callback_t ipsec_cb; -- struct nss_l2tpv2_bind_ipsec_if_msg *l2tpv2_bind_ipsec_msg; -+ get_ipsec_tundev_callback_t ipsec_cb; -+ struct nss_l2tpv2_bind_ipsec_if_msg *l2tpv2_bind_ipsec_if; - struct nss_ctx_instance *nss_ctx = nss_l2tpv2_get_context(); - int ret = proc_dostring(ctl, write, buffer, lenp, ppos); -- struct nss_connmgr_l2tpv2_session_data *ptr; - - if (!write) { - nss_connmgr_l2tpv2_info("command to write is echo > \n"); -@@ -900,19 +792,6 @@ static int nss_connmgr_l2tpv2_proc_handl - return -EINVAL; - } - -- rcu_read_lock(); -- hash_for_each_possible_rcu(l2tpv2_session_data_hash_table, ptr, -- hash_list, l2tpdev->ifindex) { -- if (ptr->dev != l2tpdev) { -- continue; -- } -- -- if (ptr->data.l2tpv2.tunnel.udp_csum) { -- nss_connmgr_l2tpv2_info("Enabling UDP checksum in L2TP packet is not supported for l2tpoipsec flow\n"); -- } -- } -- rcu_read_unlock(); -- - ipsecdev = dev_get_by_name(&init_net, ipsec_device_name); - if (!ipsecdev) { - nss_connmgr_l2tpv2_info("Cannot find the netdevice associated with %s\n", ipsec_device_name); -@@ -931,7 +810,7 @@ static int nss_connmgr_l2tpv2_proc_handl - } - - rcu_read_lock(); -- ipsec_cb = rcu_dereference(ipsecmgr_cb.get_ifnum_by_dev); -+ ipsec_cb = rcu_dereference(ipsecmgr_cb.cb); - if (!ipsec_cb) { - rcu_read_unlock(); - nss_connmgr_l2tpv2_info("Callback to get IPsec tun device not registered"); -@@ -940,13 +819,27 @@ static int nss_connmgr_l2tpv2_proc_handl - } - - /* -- * Get NSS ifnum for IPsec interface. -+ * Get the dummy netdevice used to register this IPSec -+ * device with NSS from the ipsecmgr module. This is -+ * needed for looking up the NSS ifnum for the IPSec -+ * netdevice. - */ -- ipsec_ifnum = ipsec_cb(ipsecdev); -+ ipsectundev = ipsec_cb(ipsecdev); - rcu_read_unlock(); -+ if (!ipsectundev) { -+ nss_connmgr_l2tpv2_info("Cannot get the device from IPSecmgr for %s\n", ipsec_device_name); -+ ret = -ENODEV; -+ goto exit; -+ } -+ -+ /* -+ * Get NSS ifnum for IPsec interface. -+ */ -+ ipsec_ifnum = nss_cmn_get_interface_number_by_dev_and_type(ipsectundev, NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_INNER); - if (ipsec_ifnum == -1) { - nss_connmgr_l2tpv2_info("Cannot find the NSS interface associated with %s\n", ipsec_device_name); - ret = -ENODEV; -+ dev_put(ipsectundev); - goto exit; - } - -@@ -955,14 +848,15 @@ static int nss_connmgr_l2tpv2_proc_handl - */ - memset(&l2tpv2msg, 0, sizeof(struct nss_l2tpv2_msg)); - nss_l2tpv2_msg_init(&l2tpv2msg, l2tp_ifnum, NSS_L2TPV2_MSG_BIND_IPSEC_IF, sizeof(struct nss_l2tpv2_bind_ipsec_if_msg), (void *)nss_connmgr_l2tpv2_msg_cb, NULL); -- l2tpv2_bind_ipsec_msg = &l2tpv2msg.msg.bind_ipsec_if_msg; -- l2tpv2_bind_ipsec_msg->ipsec_ifnum = ipsec_ifnum; -+ l2tpv2_bind_ipsec_if = &l2tpv2msg.msg.bind_ipsec_if_msg; -+ l2tpv2_bind_ipsec_if->ipsec_ifnum = ipsec_ifnum; - status = nss_l2tpv2_tx(nss_ctx, &l2tpv2msg); - if (status != NSS_TX_SUCCESS) { - nss_connmgr_l2tpv2_info("%px IPSec interface bind failed\n", nss_ctx); - ret = -EAGAIN; - } - -+ dev_put(ipsectundev); - exit: - dev_put(l2tpdev); - dev_put(ipsecdev); -@@ -970,6 +864,38 @@ exit: - } - - /* -+ * l2tpmgr_register_ipsecmgr_callback() -+ * Register IPSecmgr callback. -+ */ -+void l2tpmgr_register_ipsecmgr_callback(struct l2tpmgr_ipsecmgr_cb *cb) -+{ -+ get_ipsec_tundev_callback_t ipsec_cb; -+ rcu_read_lock(); -+ ipsec_cb = rcu_dereference(ipsecmgr_cb.cb); -+ if (ipsec_cb) { -+ rcu_read_unlock(); -+ nss_connmgr_l2tpv2_info("IPSecmgr Callback is already registered\n"); -+ return; -+ } -+ -+ rcu_assign_pointer(ipsecmgr_cb.cb, cb->cb); -+ rcu_read_unlock(); -+} -+EXPORT_SYMBOL(l2tpmgr_register_ipsecmgr_callback); -+ -+/* -+ * l2tpmgr_unregister_ipsecmgr_callback -+ * Unregister callback. -+ */ -+void l2tpmgr_unregister_ipsecmgr_callback(void) -+{ -+ rcu_read_lock(); -+ rcu_assign_pointer(ipsecmgr_cb.cb, NULL); -+ rcu_read_unlock(); -+} -+EXPORT_SYMBOL(l2tpmgr_unregister_ipsecmgr_callback); -+ -+/* - * nss_connmgr_l2tpv2_table - */ - static struct ctl_table nss_connmgr_l2tpv2_table[] = { -@@ -1006,7 +932,6 @@ static struct ctl_table nss_connmgr_l2tp - }, - { } - }; --#endif - - /* - * Linux Net device Notifier -@@ -1029,20 +954,18 @@ int __init nss_connmgr_l2tpv2_init_modul - return 0; - } - #endif --#if defined(NSS_L2TP_IPSEC_BIND_BY_NETDEV) - ctl_tbl_hdr = register_sysctl_table(nss_connmgr_l2tpv2_sysroot); - if (!ctl_tbl_hdr) { - nss_connmgr_l2tpv2_info("Unable to register sysctl table for L2TP conn mgr\n"); - return -EFAULT; - } - --#endif - /* - * Initialize ipsecmgr callback. - */ -- rcu_assign_pointer(ipsecmgr_cb.get_ifnum_by_dev, NULL); -- rcu_assign_pointer(ipsecmgr_cb.get_ifnum_by_ip_addr, NULL); -- synchronize_rcu(); -+ rcu_read_lock(); -+ rcu_assign_pointer(ipsecmgr_cb.cb, NULL); -+ rcu_read_unlock(); - register_netdevice_notifier(&nss_connmgr_l2tpv2_notifier); - return 0; - } --- a/l2tp/l2tpv2/nss_connmgr_l2tpv2.h +++ b/l2tp/l2tpv2/nss_connmgr_l2tpv2.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2015, 2020, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2015, 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. -@@ -27,21 +27,13 @@ - #include - #include - #include --#include +@@ -30,10 +30,10 @@ #define L2TP_V_2 2 --#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 12, 0)) -#define tunnel_hold(tunnel) atomic_inc(&tunnel->ref_count) -#define tunnel_put(tunnel) atomic_dec(&tunnel->ref_count) -#define session_hold(session) atomic_inc(&session->ref_count) -#define session_put(session) atomic_dec(&session->ref_count) --#else - #define tunnel_hold(tunnel) refcount_inc(&tunnel->ref_count) - #define tunnel_put(tunnel) refcount_dec(&tunnel->ref_count) - #define session_hold(session) refcount_inc(&session->ref_count) - #define session_put(session) refcount_dec(&session->ref_count) --#endif ++#define tunnel_hold(tunnel) refcount_inc(&tunnel->ref_count) ++#define tunnel_put(tunnel) refcount_dec(&tunnel->ref_count) ++#define session_hold(session) refcount_inc(&session->ref_count) ++#define session_put(session) refcount_dec(&session->ref_count) /* * ---------------------------------------------------------------------------------- -@@ -54,6 +46,7 @@ - */ - struct session_info { - u32 session_id, peer_session_id; /* local & remote session id */ -+ u16 offset; /* offset to data */ - u16 hdr_len; /* header length */ - int reorder_timeout; /* reorder timeout */ - unsigned send_seq:1; /* enable tx sequence number ? */ --- a/l2tp/l2tpv2/nss_l2tpv2_stats.c +++ b/l2tp/l2tpv2/nss_l2tpv2_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2015, 2020, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2015, 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. -@@ -21,9 +21,7 @@ +@@ -21,6 +21,7 @@ */ #include --#if IS_ENABLED(CONFIG_NF_FLOW_TABLE) --#include --#endif +#include #include #include #include -@@ -94,8 +92,6 @@ void nss_l2tpv2_update_dev_stats(struct - - dev_hold(dev); - -- memset(&l2tp_stats, 0, sizeof(struct l2tp_stats)); -- - /* - * Get tunnel id - */ -@@ -108,35 +104,37 @@ void nss_l2tpv2_update_dev_stats(struct +@@ -103,14 +104,14 @@ void nss_l2tpv2_update_dev_stats(struct /* * Update tunnel & session stats */ --#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 12, 0)) - tunnel = l2tp_tunnel_find(dev_net(dev), data.l2tpv2.tunnel.tunnel_id); + tunnel = l2tp_tunnel_get(dev_net(dev), data.l2tpv2.tunnel.tunnel_id); if (!tunnel) { @@ -4231,301 +184,16 @@ if (!session) { tunnel_put(tunnel); dev_put(dev); - return; - } -+ -+ memset(&l2tp_stats, 0, sizeof(struct l2tp_stats)); -+ - session_hold(session); --#else -- tunnel = l2tp_tunnel_get(dev_net(dev), data.l2tpv2.tunnel.tunnel_id); -- if (!tunnel) { -- dev_put(dev); -- return; -- } -- session = l2tp_tunnel_get_session(tunnel, data.l2tpv2.session.session_id); -- if (!session) { -- tunnel_put(tunnel); -- dev_put(dev); -- return; -- } --#endif +--- a/match/nss_match.c ++++ b/match/nss_match.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 8, 0)) -+ /* valid session found. Update stats */ -+ l2tp_stats.tx_packets = (u64)sync_stats->node_stats.tx_packets; -+ l2tp_stats.tx_bytes = (u64)sync_stats->node_stats.tx_bytes; -+ l2tp_stats.tx_errors = (u64)sync_stats->tx_errors; -+ -+ l2tp_stats.rx_packets = (u64)sync_stats->node_stats.rx_packets; -+ l2tp_stats.rx_bytes = (u64)sync_stats->node_stats.rx_bytes; -+ l2tp_stats.rx_errors = (u64)sync_stats->rx_errors; -+ -+ l2tp_stats.rx_seq_discards = (u64)sync_stats->rx_seq_discards; -+ l2tp_stats.rx_oos_packets = (u64)sync_stats->rx_oos_packets; -+#else - atomic_long_set(&l2tp_stats.tx_packets, (long)sync_stats->node_stats.tx_packets); - atomic_long_set(&l2tp_stats.tx_bytes, (long)sync_stats->node_stats.tx_bytes); - atomic_long_set(&l2tp_stats.tx_errors, (long)sync_stats->tx_errors); -@@ -148,6 +146,7 @@ void nss_l2tpv2_update_dev_stats(struct - atomic_long_set(&l2tp_stats.rx_seq_discards, (long)sync_stats->rx_seq_discards); - atomic_long_set(&l2tp_stats.rx_oos_packets, (long)(sync_stats->rx_oos_packets)); - -+#endif - l2tp_stats_update(tunnel, session, &l2tp_stats); - - session_put(session); ---- a/lag/Makefile -+++ b/lag/Makefile -@@ -7,7 +7,7 @@ endif - ccflags-y := -I$(obj) -I$(obj)/.. - ccflags-y += -DNSS_CLIENT_BUILD_ID="$(BUILD_ID)" - ccflags-y += -DNSS_LAG_MGR_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - - obj-m += qca-nss-lag-mgr.o - qca-nss-lag-mgr-objs := nss_lag.o ---- a/map/map-t/Makefile -+++ b/map/map-t/Makefile -@@ -1,7 +1,7 @@ - # Makefile for map-t client - ccflags-y += -I$(obj)/../../exports -I$(obj)/../.. -I$(obj)/nss_hal/include - ccflags-y += -DNSS_MAP_T_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - obj-m += qca-nss-map-t.o - qca-nss-map-t-objs := nss_connmgr_map_t.o - ---- a/map/map-t/nss_connmgr_map_t.c -+++ b/map/map-t/nss_connmgr_map_t.c -@@ -1,6 +1,6 @@ /* - ************************************************************************** -- * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2020, 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. -@@ -424,15 +424,12 @@ static void nss_connmgr_map_t_decap_exce - struct ipv6hdr ip6_hdr_r; - uint8_t next_hdr, hop_limit, tclass, l4_proto; - int total_len; -- uint32_t identifier = 0; -+ uint32_t identifier; - bool df_bit = false; - uint16_t skip_sz = 0; -- struct nss_map_t_mdata *mdata; - -- mdata = (struct nss_map_t_mdata *)skb->data; -- -- /* discard meta data header */ -- skb_pull(skb, sizeof(struct nss_map_t_mdata)); -+ /* discard L2 header */ -+ skb_pull(skb, sizeof(struct ethhdr)); - skb_reset_mac_header(skb); - - skb_reset_network_header(skb); -@@ -462,12 +459,7 @@ static void nss_connmgr_map_t_decap_exce - tclass = nss_connmgr_map_t_ipv6_get_tclass(ip6_hdr); - - if (likely(next_hdr != NEXTHDR_FRAGMENT)) { -- -- /* -- * Set DF bit -- */ -- df_bit = !!(mdata->flags & NSS_MAPT_MDATA_FLAG_DF_BIT); -- -+ df_bit = true; - l4_proto = next_hdr; - } else { - struct frag_hdr tmp_fh, *fh; -@@ -504,16 +496,8 @@ static void nss_connmgr_map_t_decap_exce - ip4_hdr->tos = tclass; - if (unlikely(df_bit)) { - ip4_hdr->frag_off = htons(IP_DF); -- } -- -- if (unlikely(identifier)) { -- ip4_hdr->id = htons(identifier & 0xffff); - } else { -- /* -- * Generate the new identifier value and set it -- * in the IPv4 Identification field. -- */ -- __ip_select_ident(dev_net(dev), ip4_hdr, 1); -+ ip4_hdr->id = htons(identifier & 0xffff); - } - - skb->pkt_type = PACKET_HOST; -@@ -531,7 +515,7 @@ static void nss_connmgr_map_t_decap_exce - /* - * nss_connmgr_map_t_encap_exception() - * Exception handler registered to NSS for handling map_t ipv4 pkts -- * Send the translated ipv4 packets to the stack directly. -+ * Translates ipv4 packet back to ipv6 and send to nat46 device directly. - */ - static void nss_connmgr_map_t_encap_exception(struct net_device *dev, - struct sk_buff *skb, -@@ -539,32 +523,147 @@ static void nss_connmgr_map_t_encap_exce - - { - struct iphdr *ip4_hdr; -+ struct ipv6hdr *ip6_hdr; -+ uint8_t v6saddr[16], v6daddr[16]; -+ struct tcphdr *tcph = NULL; -+ struct udphdr *udph = NULL; -+ struct iphdr ip4_hdr_r; -+ __be16 sport, dport; -+ uint8_t nexthdr, hop_limit, tos; -+ int payload_len; -+ bool df_bit = false; -+ uint16_t append_hdr_sz = 0; -+ uint16_t identifier; -+ uint32_t l4_csum; -+ uint16_t csum; - -+ /* discard L2 header */ - skb_pull(skb, sizeof(struct ethhdr)); - skb_reset_mac_header(skb); -+ - skb_reset_network_header(skb); - - ip4_hdr = ip_hdr(skb); -- skb_set_transport_header(skb, ip4_hdr->ihl * 4); -+ skb_set_transport_header(skb, ip4_hdr->ihl*4); -+ -+ if (ip4_hdr->protocol == IPPROTO_TCP) { -+ tcph = tcp_hdr(skb); -+ l4_csum = tcph->check; -+ sport = tcph->source; -+ dport = tcph->dest; -+ } else if (ip4_hdr->protocol == IPPROTO_UDP) { -+ udph = udp_hdr(skb); -+ l4_csum = udph->check; -+ sport = udph->source; -+ dport = udph->dest; -+ } else { -+ nss_connmgr_map_t_warning("%px: Unsupported protocol, free it up\n", dev); -+ dev_kfree_skb_any(skb); -+ return; -+ } - - /* -- * IP Header checksum is not generated yet, calculate it now. -+ * Undo the checksum of the IPv4 source and destinationIPv4 address. - */ -- ip4_hdr->check = 0; -- ip4_hdr->check = ip_fast_csum((unsigned char *)ip4_hdr, ip4_hdr->ihl); -+ csum = ip_compute_csum(&ip4_hdr->saddr, 2 * sizeof(ip4_hdr->saddr)); -+ l4_csum += ((~csum) & 0xFFFF); -+ -+ /* -+ * IPv6 packet is xlated to ipv4 packet by acceleration engine. But there is no ipv4 rule. -+ * Call xlate_4_to_6() [ which is exported by nat46.ko ] to find original ipv6 src and ipv6 dest address. -+ * These functions is designed for packets from lan to wan. Since this packet is from wan, need to call -+ * this function with parameters reversed. ipv4_hdr_r is used for reversing ip addresses. -+ */ -+ ip4_hdr_r.daddr = ip4_hdr->saddr; -+ ip4_hdr_r.saddr = ip4_hdr->daddr; -+ -+ if (unlikely(!xlate_4_to_6(dev, &ip4_hdr_r, dport, sport, v6saddr, v6daddr))) { /* exception happened after packet got xlated */ -+ nss_connmgr_map_t_warning("%px: Martian ipv4 packet !!..free it. (saddr = 0x%x daddr = 0x%x sport = %d dport = %d)\n", dev,\ -+ ip4_hdr->saddr, ip4_hdr->daddr, sport, dport); -+ dev_kfree_skb_any(skb); -+ return; -+ } -+ -+ nexthdr = ip4_hdr->protocol; -+ payload_len = ntohs(ip4_hdr->tot_len) - sizeof(struct iphdr); -+ hop_limit = ip4_hdr->ttl; -+ tos = ip4_hdr->tos; -+ identifier = ntohs(ip4_hdr->id); -+ -+ if (ip4_hdr->frag_off & htons(IP_DF)) { -+ df_bit = true; -+ } else if (map_t_flags & MAPT_FLAG_ADD_DUMMY_HDR) { -+ append_hdr_sz = sizeof(struct frag_hdr); -+ } -+ -+ if (!pskb_may_pull(skb, sizeof(struct ipv6hdr) + append_hdr_sz - sizeof(struct iphdr))) { -+ nss_connmgr_map_t_warning("%px: Not enough headroom for ipv6 packet...Freeing the packet\n", dev); -+ dev_kfree_skb_any(skb); -+ return; -+ } -+ -+ skb_push(skb, sizeof(struct ipv6hdr) + append_hdr_sz - sizeof(struct iphdr)); -+ skb_reset_network_header(skb); -+ skb_reset_mac_header(skb); -+ -+ skb->protocol = htons(ETH_P_IPV6); -+ -+ ip6_hdr = ipv6_hdr(skb); -+ memset(ip6_hdr, 0, sizeof(struct ipv6hdr)); -+ -+ ip6_hdr->version = 6; -+ ip6_hdr->payload_len = htons(payload_len + append_hdr_sz); -+ ip6_hdr->hop_limit = hop_limit; -+ -+ nss_connmgr_map_t_ipv6_set_tclass(ip6_hdr, tos); -+ memcpy(&ip6_hdr->daddr, v6saddr, sizeof(struct in6_addr)); -+ memcpy(&ip6_hdr->saddr, v6daddr, sizeof(struct in6_addr)); -+ -+ if (unlikely(df_bit) || !(map_t_flags & MAPT_FLAG_ADD_DUMMY_HDR)) { -+ ip6_hdr->nexthdr = nexthdr; -+ } else { -+ struct frag_hdr tmp_fh, *fh; -+ const __be32 *fh_addr = skb_header_pointer(skb, sizeof(struct ipv6hdr), sizeof(struct frag_hdr), &tmp_fh); -+ if (!fh_addr) { -+ nss_connmgr_map_t_warning("%px: Not able to offset to frag header\n", dev); -+ dev_kfree_skb_any(skb); -+ return; -+ } -+ fh = (struct frag_hdr *)fh_addr; -+ memset(fh, 0, sizeof(struct frag_hdr)); -+ fh->identification = htonl(identifier); -+ fh->nexthdr = nexthdr; -+ ip6_hdr->nexthdr = NEXTHDR_FRAGMENT; -+ } -+ -+ skb_set_transport_header(skb, sizeof(struct ipv6hdr) + append_hdr_sz); -+ -+ /* -+ * Add the checksum of the IPv6 source and destination address. -+ */ -+ l4_csum += ip_compute_csum(ip6_hdr->saddr.s6_addr16, 2 * sizeof(ip6_hdr->saddr)); -+ -+ /* -+ * Fold the 32 bits checksum to 16 bits -+ */ -+ l4_csum = (l4_csum & 0x0000FFFF) + (l4_csum >> 16); -+ l4_csum = (l4_csum & 0x0000FFFF) + (l4_csum >> 16); -+ -+ if (nexthdr == IPPROTO_TCP) { -+ tcph->check = (uint16_t)l4_csum; -+ } else { -+ udph->check = (uint16_t)l4_csum; -+ } - -- skb->protocol = htons(ETH_P_IP); - skb->pkt_type = PACKET_HOST; - skb->skb_iif = dev->ifindex; - skb->ip_summed = CHECKSUM_NONE; - skb->dev = dev; - -- nss_connmgr_map_t_trace("%px: ipv4 packet exceptioned after v6/v4xlat src=%pI4 dest=%pI4 proto=%d\n", -- dev, &ip4_hdr->saddr, &ip4_hdr->daddr, ip4_hdr->protocol); -- /* -- * Go through Linux network stack. -- */ -- netif_receive_skb(skb); -+ nss_connmgr_map_t_trace("%px: ipv4 packet exceptioned after v6 ---> v4 xlate, created original ipv6 packet\n", dev); -+ nss_connmgr_map_t_trace("%p: Calculted ipv6 params: src_addr=%pI6, dest_addr=%pI6, payload_len=%d, checksum=%x\n", dev, v6saddr, v6daddr, payload_len, l4_csum); -+ -+ dev_queue_xmit(skb); - return; - } - + * nss_match_verify_config_msg() --- a/match/nss_match_priv.h +++ b/match/nss_match_priv.h @@ -29,19 +29,19 @@ @@ -4551,542 +219,342 @@ #define nss_match_trace(s, ...) #else #define nss_match_trace(s, ...) pr_info("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) ---- a/mirror/Makefile -+++ b/mirror/Makefile -@@ -2,7 +2,7 @@ - - ccflags-y += $(NSS_CCFLAGS) -I$(obj)/../../exports - ccflags-y += -DNSS_MIRROR_DEBUG_LEVEL=2 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - - obj-m += qca-nss-mirror.o - qca-nss-mirror-objs := \ ---- a/mirror/nss_mirror.c -+++ b/mirror/nss_mirror.c -@@ -1,6 +1,6 @@ - /* - *************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -180,28 +180,6 @@ static struct rtnl_link_stats64 *nss_mir - return stats; +--- a/portifmgr/nss_portifmgr.c ++++ b/portifmgr/nss_portifmgr.c +@@ -187,16 +187,20 @@ drop: } --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) --/* -- * nss_mirror_netdev_stats64() -- * Netdev ops function to retrieve stats for kernel version < 4.6 -- */ --static struct rtnl_link_stats64 *nss_mirror_netdev_stats64(struct net_device *dev, -- struct rtnl_link_stats64 *tot) --{ -- return nss_mirror_get_stats(dev, tot); --} --#else --/* -- * nss_mirror_netdev_stats64() -- * Netdev ops function to retrieve stats -- */ --static void nss_mirror_netdev_stats64(struct net_device *dev, -- struct rtnl_link_stats64 *tot) --{ -- nss_mirror_get_stats(dev, tot); --} --#endif -- /* - * nss_mirror_netdev_ops - * Mirror net device operations. -@@ -209,7 +187,7 @@ static void nss_mirror_netdev_stats64(st - static const struct net_device_ops nss_mirror_netdev_ops = { - .ndo_open = nss_mirror_netdev_up, - .ndo_stop = nss_mirror_netdev_down, -- .ndo_get_stats64 = nss_mirror_netdev_stats64, -+ .ndo_get_stats64 = nss_mirror_get_stats, +- * nss_portifmgr_get_stats() ++ * nss_portifmgr_get_stats64() + * Netdev get stats function to get port stats + */ +-static struct rtnl_link_stats64 *nss_portifmgr_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) ++/* ++ * nss_nlgre_redir_cmn_dev_stats64 ++ * Report packet statistics to linux ++ */ ++static void nss_portifmgr_get_stats64(struct net_device *dev, ++ struct rtnl_link_stats64 *stats) + { + struct nss_portifmgr_priv *priv = (struct nss_portifmgr_priv *)netdev_priv(dev); + BUG_ON(priv == NULL); + + nss_portid_get_stats(priv->if_num, stats); +- return stats; + } + + /* +@@ -225,7 +229,7 @@ static const struct net_device_ops nss_p + .ndo_start_xmit = nss_portifmgr_start_xmit, + .ndo_set_mac_address = eth_mac_addr, + .ndo_change_mtu = nss_portifmgr_change_mtu, +- .ndo_get_stats64 = nss_portifmgr_get_stats, ++ .ndo_get_stats64 = nss_portifmgr_get_stats64, }; /* -@@ -300,6 +278,10 @@ static void nss_mirror_data_cb(struct ne - return; +--- a/profiler/profile.c ++++ b/profiler/profile.c +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -937,12 +938,26 @@ static ssize_t debug_if(struct file *fil + return count; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) ++#define HAVE_PROC_OPS ++#endif ++ ++#ifdef HAVE_PROC_OPS ++static const struct proc_ops profile_fops = { ++ .proc_open = profile_open, ++ .proc_read = profile_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = profile_release, ++ .proc_write = debug_if, ++}; ++#else + static const struct file_operations profile_fops = { + .open = profile_open, + .read = profile_read, + .release = profile_release, + .write = debug_if, + }; ++#endif + + /* + * showing sample status on Linux console +@@ -971,6 +986,15 @@ static ssize_t profile_rate_write(struct + return 0; + } + ++#ifdef HAVE_PROC_OPS ++static const struct proc_ops profile_rate_fops = { ++ .proc_open = profile_rate_open, ++ .proc_read = seq_read, ++ .proc_lseek = seq_lseek, ++ .proc_release = single_release, ++ .proc_write = profile_rate_write, ++}; ++#else + static const struct file_operations profile_rate_fops = { + .open = profile_rate_open, + .read = seq_read, +@@ -978,6 +1002,7 @@ static const struct file_operations prof + .release = single_release, + .write = profile_rate_write, + }; ++#endif + + /* + * hexdump +--- a/vlan/Makefile ++++ b/vlan/Makefile +@@ -8,7 +8,7 @@ ifeq ($(SoC),$(filter $(SoC),ipq807x ipq + ccflags-y += -DNSS_VLAN_MGR_PPE_SUPPORT + endif + +-ccflags-y += -DNSS_VLAN_MGR_DEBUG_LEVEL=0 ++ccflags-y += -DNSS_VLAN_MGR_DEBUG_LEVEL=4 + ccflags-y += -Werror + + ifneq (,$(filter $(CONFIG_BONDING),y m)) +--- a/vlan/nss_vlan_mgr.c ++++ b/vlan/nss_vlan_mgr.c +@@ -821,8 +821,10 @@ static struct nss_vlan_pvt *nss_vlan_mgr + */ + static void nss_vlan_mgr_instance_free(struct nss_vlan_pvt *v) + { ++#ifdef NSS_VLAN_MGR_PPE_SUPPORT + int32_t i; + int ret = 0; ++#endif + + spin_lock(&vlan_mgr_ctx.lock); + BUG_ON(--v->refs); +@@ -980,8 +982,11 @@ static int nss_vlan_mgr_register_event(s + int ret; + #endif + uint32_t vlan_tag; ++#ifdef NSS_VLAN_MGR_PPE_SUPPORT + struct net_device *slave; +- int32_t port, port_if; ++ int32_t port; ++#endif ++ int32_t port_if; + struct vlan_dev_priv *vlan; + struct net_device *real_dev; + bool is_bond_master = false; +@@ -1355,8 +1360,10 @@ return_with_error: + int nss_vlan_mgr_join_bridge(struct net_device *dev, uint32_t bridge_vsi) + { + struct nss_vlan_pvt *v = nss_vlan_mgr_instance_find_and_ref(dev); ++#ifdef NSS_VLAN_MGR_PPE_SUPPORT + struct net_device *real_dev; + int ret; ++#endif + + if (!v) + return 0; +@@ -1416,8 +1423,10 @@ EXPORT_SYMBOL(nss_vlan_mgr_join_bridge); + int nss_vlan_mgr_leave_bridge(struct net_device *dev, uint32_t bridge_vsi) + { + struct nss_vlan_pvt *v = nss_vlan_mgr_instance_find_and_ref(dev); ++#ifdef NSS_VLAN_MGR_PPE_SUPPORT + struct net_device *real_dev; + int ret; ++#endif + + if (!v) + return 0; +--- a/bridge/nss_bridge_mgr.c ++++ b/bridge/nss_bridge_mgr.c +@@ -1067,8 +1067,10 @@ int nss_bridge_mgr_register_br(struct ne + */ + b_pvt->ifnum = ifnum; + b_pvt->mtu = dev->mtu; ++#if defined(NSS_BRIDGE_MGR_PPE_SUPPORT) + b_pvt->wan_if_num = -1; + b_pvt->wan_if_enabled = false; ++#endif + ether_addr_copy(b_pvt->dev_addr, dev->dev_addr); + spin_lock(&br_mgr_ctx.lock); + list_add(&b_pvt->list, &br_mgr_ctx.list); +@@ -1130,6 +1132,7 @@ static int nss_bridge_mgr_bond_slave_cha + return NOTIFY_DONE; } -+ nss_mirror_info("Printing 64 bytes of data\n"); -+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, -+ skb->data, 64, 0); -+ - dev_hold(netdev); - ++#if defined(NSS_BRIDGE_MGR_PPE_SUPPORT) /* ---- a/mscs/Makefile -+++ /dev/null -@@ -1,7 +0,0 @@ --# Makefile for mscs client --ccflags-y += -I$(obj)/../exports -I$(obj)/.. --ccflags-y += -DNSS_CLIENT_BUILD_ID="$(BUILD_ID)" --ccflags-y += -DNSS_MSCS_DEBUG_LEVEL=2 --ccflags-y += -Wall -Werror --obj-m += qca-nss-mscs.o --qca-nss-mscs-objs := nss_mscs.o ---- a/mscs/nss_mscs.c -+++ /dev/null -@@ -1,144 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2020-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 --#include --#include --#include --#include -- --#include --#include --#include --#include --#include --#include -- --#if defined(CONFIG_DYNAMIC_DEBUG) -- --/* -- * Compile messakes for dynamic enable/disable -- */ --#define nss_mscs_warning(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) --#define nss_mscs_info(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) --#define nss_mscs_trace(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) --#else -- --/* -- * Statically compile messages at different levels -- */ --#if (NSS_MSCS_DEBUG_LEVEL < 2) --#define nss_mscs_warning(s, ...) --#else --#define nss_mscs_warning(s, ...) pr_warn("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) --#endif -- --#if (NSS_MSCS_DEBUG_LEVEL < 3) --#define nss_mscs_info(s, ...) --#else --#define nss_mscs_info(s, ...) pr_notice("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) --#endif -- --#if (NSS_MSCS_DEBUG_LEVEL < 4) --#define nss_mscs_trace(s, ...) --#else --#define nss_mscs_trace(s, ...) pr_info("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) --#endif --#endif -- --/* -- * nss_mscs_ecm -- * Register MSCS client callback with ECM MSCS classifier to support MSCS wifi peer lookup. -- */ --static struct ecm_classifier_mscs_callbacks nss_mscs_ecm = { -- .get_peer_priority = qca_mscs_peer_lookup_n_get_priority, -- .update_skb_priority = qca_scs_peer_lookup_n_rule_match, --}; -- --/* -- * nss_emesh_ecm -- * Register EMESH client callback with ECM EMSH-SAWF classifier to update peer mesh latency parameters. -- */ --static struct ecm_classifier_emesh_sawf_callbacks nss_emesh_ecm = { -- .update_peer_mesh_latency_params = qca_mesh_latency_update_peer_parameter, --}; -- --/* -- * nss_mscs_init_module() -- * MSCS clinet module init function -- */ --int __init nss_mscs_init_module(void) --{ --#ifdef CONFIG_OF -- /* -- * If the node is not compatible, don't do anything. -- */ -- if (!of_find_node_by_name(NULL, "nss-common")) { -- return 0; -- } --#endif -- -- /* -- * MSCS is enabled only on supported platform -- */ -- if (!nss_cmn_get_nss_enabled()) { -- nss_mscs_warning("MSCS client is not compatible with this Platform\n"); -- return -1; -- } -- -- if (ecm_classifier_mscs_callback_register(&nss_mscs_ecm)) { -- nss_mscs_warning("ecm mscs classifier callback registration failed.\n"); -- return -1; -- } -- -- if (ecm_classifier_emesh_latency_config_callback_register(&nss_emesh_ecm)) { -- ecm_classifier_mscs_callback_unregister(); -- nss_mscs_warning("ecm mesh classifier callback registration failed.\n"); -- return -1; -- } -- -- nss_mscs_info("NSS MSCS Client loaded: %s\n", NSS_CLIENT_BUILD_ID); -- return 0; -- --} -- --/* -- * nss_mscs_exit_module() -- * MSCS module exit function -- */ --void __exit nss_mscs_exit_module(void) --{ --#ifdef CONFIG_OF -- -- /* -- * If the node is not compatible, don't do anything. -- */ -- if (!of_find_node_by_name(NULL, "nss-common")) { -- return; -- } --#endif -- -- ecm_classifier_mscs_callback_unregister(); -- ecm_classifier_emesh_latency_config_callback_unregister(); -- nss_mscs_info("MSCS Client unloaded\n"); -- --} -- --module_init(nss_mscs_init_module); --module_exit(nss_mscs_exit_module); -- --MODULE_LICENSE("Dual BSD/GPL"); --MODULE_DESCRIPTION("NSS MSCS client module"); ---- a/netlink/Makefile -+++ b/netlink/Makefile -@@ -1,8 +1,9 @@ -+GRE_ENABLED := $(strip $(if $(filter $(gre), y), 1 , 0)) - CAPWAP_ENABLED := $(strip $(if $(filter $(capwapmgr), y), 1 , 0)) --IPSEC_ENABLED := $(strip $(if $(filter $(ipsecmgr), y), 1 , 0)) -+IPSEC_ENABLED := 0 - DTLS_ENABLED := $(strip $(if $(filter $(dtlsmgr), y), 1 , 0)) + * Add or remove the slave based based on linking event + */ +@@ -1144,6 +1147,7 @@ static int nss_bridge_mgr_bond_slave_cha + cu_info->upper_dev->name, master->name); + } + } ++#endif --ccflags-y := -Wall -Werror -+ccflags-y := -Werror - ccflags-y += -I$(obj)/include - ccflags-y += -I$(obj)/../exports - ccflags-y += -DNSS_NL_DEBUG_LEVEL=4 -@@ -10,48 +11,39 @@ ccflags-y += -DNSS_CLIENT_BUILD_ID="$(BU + return NOTIFY_DONE; + } +--- a/dtls/v1.0/nss_connmgr_dtls_netdev.c ++++ b/dtls/v1.0/nss_connmgr_dtls_netdev.c +@@ -160,7 +160,7 @@ static void nss_dtlsmgr_dev_setup(struct + dev->ethtool_ops = NULL; + dev->header_ops = NULL; + dev->netdev_ops = &nss_dtlsmgr_session_ops; +- dev->destructor = NULL; ++ dev->priv_destructor = NULL; - ccflags-y += -DCONFIG_NSS_NLIPV4=1 - ccflags-y += -DCONFIG_NSS_NLIPV6=1 --ccflags-y += -DCONFIG_NSS_NLOAM=1 --ccflags-y += -DCONFIG_NSS_NLGRE_REDIR_FAMILY=1 -+ccflags-y += -DCONFIG_NSS_NLOAM=0 -+ccflags-y += -DCONFIG_NSS_NLGRE_REDIR_FAMILY=${GRE_ENABLED} - ccflags-y += -DCONFIG_NSS_NLETHRX=1 - ccflags-y += -DCONFIG_NSS_NLDYNAMIC_INTERFACE=1 - ccflags-y += -DCONFIG_NSS_NLN2H=1 --ccflags-y += -DCONFIG_NSS_NLIPV4_REASM=1 --ccflags-y += -DCONFIG_NSS_NLIPV6_REASM=1 -+ccflags-y += -DCONFIG_NSS_NLIPV4_REASM=0 -+ccflags-y += -DCONFIG_NSS_NLIPV6_REASM=0 - ccflags-y += -DCONFIG_NSS_NLWIFILI=1 - ccflags-y += -DCONFIG_NSS_NLLSO_RX=1 --ccflags-y += -DCONFIG_NSS_NLMAP_T=1 --ccflags-y += -DCONFIG_NSS_NLPPPOE=1 --ccflags-y += -DCONFIG_NSS_NLL2TPV2=1 --ccflags-y += -DCONFIG_NSS_NLQRFS=1 --ccflags-y += -DCONFIG_NSS_NLPPTP=1 -+ccflags-y += -DCONFIG_NSS_NLMAP_T=0 -+ccflags-y += -DCONFIG_NSS_NLPPPOE=0 -+ccflags-y += -DCONFIG_NSS_NLL2TPV2=0 -+ccflags-y += -DCONFIG_NSS_NLPPTP=0 - ccflags-y += -DCONFIG_NSS_NLCAPWAP=${CAPWAP_ENABLED} - ccflags-y += -DCONFIG_NSS_NLIPSEC=${IPSEC_ENABLED} - ccflags-y += -DCONFIG_NSS_NLDTLS=${DTLS_ENABLED} --ccflags-y += -DCONFIG_NSS_NLUDP_ST=1 + memcpy(dev->dev_addr, "\xaa\xbb\xcc\xdd\xee\xff", dev->addr_len); + memset(dev->broadcast, 0xff, dev->addr_len); +--- a/exports/nss_dtlsmgr.h ++++ b/exports/nss_dtlsmgr.h +@@ -128,7 +128,7 @@ enum nss_dtlsmgr_metadata_result { + * NSS DTLS manager cryptographic structure to represent key and its length. + */ + struct nss_dtlsmgr_crypto_data { +- const uint8_t *data; /**< Pointer to key or nonce. */ ++ uint8_t *data; /**< Pointer to key or nonce. */ + uint16_t len; /**< Length of the key. */ + }; - qca-nss-netlink-objs := nss_nl.o --qca-nss-netlink-objs += nss_nlgre_redir_family.o --qca-nss-netlink-objs += nss_nlgre_redir_cmd.o --qca-nss-netlink-objs += nss_nlgre_redir_cmn.o --qca-nss-netlink-objs += nss_nlgre_redir.o --qca-nss-netlink-objs += nss_nlgre_redir_lag.o - qca-nss-netlink-objs += nss_nlipv4.o - qca-nss-netlink-objs += nss_nlipv6.o --qca-nss-netlink-objs += nss_nloam.o -+# qca-nss-netlink-objs += nss_nloam.o - qca-nss-netlink-objs += nss_nlethrx.o - qca-nss-netlink-objs += nss_nldynamic_interface.o - qca-nss-netlink-objs += nss_nln2h.o --qca-nss-netlink-objs += nss_nlipv4_reasm.o --qca-nss-netlink-objs += nss_nlipv6_reasm.o -+# qca-nss-netlink-objs += nss_nlipv4_reasm.o -+# qca-nss-netlink-objs += nss_nlipv6_reasm.o - qca-nss-netlink-objs += nss_nlwifili.o - qca-nss-netlink-objs += nss_nllso_rx.o --qca-nss-netlink-objs += nss_nlmap_t.o --qca-nss-netlink-objs += nss_nlpppoe.o --qca-nss-netlink-objs += nss_nll2tpv2.o --qca-nss-netlink-objs += nss_nlpptp.o --qca-nss-netlink-objs += nss_nludp_st.o --qca-nss-netlink-objs += nss_nlqrfs.o -- -+# qca-nss-netlink-objs += nss_nlmap_t.o -+# qca-nss-netlink-objs += nss_nlpppoe.o -+# qca-nss-netlink-objs += nss_nll2tpv2.o -+# qca-nss-netlink-objs += nss_nlpptp.o -+# - ifneq (,$(filter $(capwapmgr), y)) - qca-nss-netlink-objs += nss_nlcapwap.o - endif -@@ -60,8 +52,12 @@ ifneq (,$(filter $(dtlsmgr), y)) - qca-nss-netlink-objs += nss_nldtls.o - endif +--- a/clmapmgr/nss_clmapmgr.c ++++ b/clmapmgr/nss_clmapmgr.c +@@ -87,14 +87,13 @@ fail: + * nss_clmapmgr_dev_stats64() + * Netdev ops function to retrieve stats. + */ +-struct rtnl_link_stats64 *nss_clmapmgr_dev_stats64(struct net_device *dev, ++void nss_clmapmgr_dev_stats64(struct net_device *dev, + struct rtnl_link_stats64 *stats) + { + struct nss_clmapmgr_priv_t *priv; --ifneq (,$(filter $(ipsecmgr), y)) --qca-nss-netlink-objs += nss_nlipsec.o -+ifneq (,$(filter $(gre), y)) -+qca-nss-netlink-objs += nss_nlgre_redir_family.o -+qca-nss-netlink-objs += nss_nlgre_redir_cmd.o -+qca-nss-netlink-objs += nss_nlgre_redir_cmn.o -+qca-nss-netlink-objs += nss_nlgre_redir.o -+qca-nss-netlink-objs += nss_nlgre_redir_lag.o - endif + if (!stats) { + nss_clmapmgr_warning("%px: invalid rtnl structure\n", dev); +- return stats; + } - ifeq ($(SoC),$(filter $(SoC),ipq807x ipq807x_64)) ---- a/netlink/nss_nl.c -+++ b/netlink/nss_nl.c + dev_hold(dev); +@@ -109,7 +108,6 @@ struct rtnl_link_stats64 *nss_clmapmgr_d + memcpy(stats, &priv->stats, sizeof(struct rtnl_link_stats64)); + dev_put(dev); + +- return stats; + } + + /* +--- a/tls/nss_tlsmgr_tun.c ++++ b/tls/nss_tlsmgr_tun.c +@@ -102,7 +102,7 @@ static int nss_tlsmgr_tun_open(struct ne + * nss_tlsmgr_tun_stats64() + * TLS manager tunnel device + */ +-static struct rtnl_link_stats64 *nss_tlsmgr_tun_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) ++void nss_tlsmgr_tun_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) + { + struct nss_tlsmgr_tun *tun = netdev_priv(dev); + +@@ -113,7 +113,6 @@ static struct rtnl_link_stats64 *nss_tls + nss_tlsmgr_ctx_stats_copy(&tun->ctx_dec, stats); + read_unlock_bh(&tun->lock); + +- return stats; + } + + /* +--- a/netlink/include/nss_nldtls_if.h ++++ b/netlink/include/nss_nldtls_if.h +@@ -34,9 +34,9 @@ + #define NSS_NLDTLS_DECAP_SIDE 1 + #define NSS_NLDTLS_TX_PKTS_MODE_END_TO_END 0 + #define NSS_NLDTLS_TX_PKTS_MODE_HOST_TO_HOST 1 +-#define NSS_NLDTLS_CKD_MAX 32 +-#define NSS_NLDTLS_AKD_MAX 32 +-#define NSS_NLDTLS_ND_MAX 20 ++#define NSS_NLDTLS_CIPHER_KEY_MAX 32 ++#define NSS_NLDTLS_AUTH_KEY_MAX 64 ++#define NSS_NLDTLS_NONCE_SIZE_MAX 4 + + /** + * @brief Enumeration for all command types. +@@ -51,11 +51,36 @@ enum nss_nldtls_cmd_type { + }; + + /** ++ * @brief Parameters for crypto keys ++ */ ++struct nss_nldtls_crypto_keys { ++ uint8_t cipher[NSS_NLDTLS_CIPHER_KEY_MAX]; /**< Cipher key data */ ++ uint8_t auth[NSS_NLDTLS_CIPHER_KEY_MAX]; /**< Cipher key data */ ++ uint8_t nonce[NSS_NLDTLS_CIPHER_KEY_MAX]; /**< Cipher key data */ ++}; ++ ++/** ++ * @brief Parameters for encap configuration ++ */ ++struct nss_nldtls_encap_config { ++ struct nss_dtlsmgr_encap_config cfg; ++ struct nss_nldtls_crypto_keys keys; ++}; ++ ++/** ++ * @brief Parameter for decap configuration ++ */ ++struct nss_nldtls_decap_config { ++ struct nss_dtlsmgr_decap_config cfg; ++ struct nss_nldtls_crypto_keys keys; ++}; ++ ++/** + * @brief Parameters to create a tunnel. + */ + struct nss_nldtls_create_tun { +- struct nss_dtlsmgr_encap_config encap; /**< Encap data. */ +- struct nss_dtlsmgr_decap_config decap; /**< Decap data. */ ++ struct nss_nldtls_encap_config encap; /**< Encap data. */ ++ struct nss_nldtls_decap_config decap; /**< Decap data. */ + uint32_t flags; /**< DTLS header flags. */ + uint32_t from_mtu; /**< Mtu of incoming interface. */ + uint32_t to_mtu; /**< Mtu of outgoing interface. */ +@@ -77,6 +102,7 @@ struct nss_nldtls_destroy_tun { + */ + struct nss_nldtls_update_config { + struct nss_dtlsmgr_config_update config_update; /**< Update config params */ ++ struct nss_nldtls_crypto_keys keys; /**< Crypto keys. */ + uint16_t epoch; /**< Dtls encap epoch. */ + uint16_t window_sz; /**< Dtls window size parameter. */ + char dev_name[IFNAMSIZ]; /**< Device whose config to be updated. */ +@@ -88,10 +114,11 @@ struct nss_nldtls_update_config { + */ + struct nss_nldtls_tx_pkts { + uint32_t num_pkts; /**< Number of packets to be transmitted */ ++ uint32_t seq_num; /**< starting sequence number */ + uint16_t pkt_sz; /**< Size of packet to be transmitted */ + char dev_name[IFNAMSIZ]; /**< Device used for transmission */ +- uint8_t ip_version; /**< Ip version [4 or 6] */ + uint8_t mode; /**< Can be end_to_end or host_to_host*/ ++ uint8_t ctype; /**< dtls content type */ + bool log_en; /**< Enable or disable wireless info */ + }; + +--- a/netlink/nss_nl.h ++++ b/netlink/nss_nl.h @@ -1,6 +1,6 @@ /* ************************************************************************** -- * Copyright (c) 2015-2016,2018-2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2015-2016,2018-2020 The Linux Foundation. All rights reserved. +- * Copyright (c) 2015,2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2015,2018, 2020, 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. -@@ -35,8 +35,6 @@ - #include "nss_nlcmn_if.h" - #include "nss_nldtls.h" - #include "nss_nldtls_if.h" --#include "nss_nlgre_redir_if.h" --#include "nss_nlgre_redir_family.h" - #include "nss_nlipsec.h" - #include "nss_nlipsec_if.h" - #include "nss_nlipv4.h" -@@ -59,10 +57,6 @@ - #include "nss_nlc2c_tx_if.h" - #include "nss_nlc2c_rx.h" - #include "nss_nlc2c_rx_if.h" --#include "nss_nlipv4_reasm.h" --#include "nss_nlipv4_reasm_if.h" --#include "nss_nlipv6_reasm.h" --#include "nss_nlipv6_reasm_if.h" - #include "nss_nlwifili.h" - #include "nss_nlwifili_if.h" - #include "nss_nllso_rx.h" -@@ -75,10 +69,6 @@ - #include "nss_nll2tpv2_if.h" - #include "nss_nlpptp.h" - #include "nss_nlpptp_if.h" --#include "nss_nludp_st.h" --#include "nss_nludp_st_if.h" --#include "nss_nlqrfs.h" --#include "nss_nlqrfs_if.h" - - /* - * nss_nl.c -@@ -110,24 +100,6 @@ static struct nss_nl_family family_handl - }, - { - /* -- * NSS_NLIPSEC -- */ -- .name = NSS_NLIPSEC_FAMILY, /* ipsec */ -- .entry = NSS_NLIPSEC_INIT, /* init */ -- .exit = NSS_NLIPSEC_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLIPSEC /* 1 or 0 */ -- }, -- { -- /* -- * NSS_NLOAM -- */ -- .name = NSS_NLOAM_FAMILY, /* oam */ -- .entry = NSS_NLOAM_INIT, /* init */ -- .exit = NSS_NLOAM_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLOAM /* 1 or 0 */ -- }, -- { -- /* - * NSS_NLIPV6 - */ - .name = NSS_NLIPV6_FAMILY, /* ipv6 */ -@@ -137,24 +109,6 @@ static struct nss_nl_family family_handl - }, - { - /* -- * NSS_NLGRE_REDIR -- */ -- .name = NSS_NLGRE_REDIR_FAMILY, /* gre_redir */ -- .entry = NSS_NLGRE_REDIR_FAMILY_INIT, /* init */ -- .exit = NSS_NLGRE_REDIR_FAMILY_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLGRE_REDIR_FAMILY /* 1 or 0 */ -- }, -- { -- /* -- * NSS_NLCAPWAP -- */ -- .name = NSS_NLCAPWAP_FAMILY, /* capwap */ -- .entry = NSS_NLCAPWAP_INIT, /* init */ -- .exit = NSS_NLCAPWAP_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLCAPWAP /* 1 or 0 */ -- }, -- { -- /* - * NSS_NLDTLS - */ - .name = NSS_NLDTLS_FAMILY, /* dtls */ -@@ -173,15 +127,6 @@ static struct nss_nl_family family_handl - }, - { - /* -- * NSS_NLEDMA -- */ -- .name = NSS_NLEDMA_FAMILY, /* edma */ -- .entry = NSS_NLEDMA_INIT, /* init */ -- .exit = NSS_NLEDMA_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLEDMA /* 1 or 0 */ -- }, -- { -- /* - * NSS_NLDYNAMIC_INTERFACE - */ - .name = NSS_NLDYNAMIC_INTERFACE_FAMILY, /* dynamic interface */ -@@ -200,42 +145,6 @@ static struct nss_nl_family family_handl - }, - { - /* -- * NSS_NLC2C_TX -- */ -- .name = NSS_NLC2C_TX_FAMILY, /* c2c_tx */ -- .entry = NSS_NLC2C_TX_INIT, /* init */ -- .exit = NSS_NLC2C_TX_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLC2C_TX /* 1 or 0 */ -- }, -- { -- /* -- * NSS_NLC2C_RX -- */ -- .name = NSS_NLC2C_RX_FAMILY, /* c2c_rx */ -- .entry = NSS_NLC2C_RX_INIT, /* init */ -- .exit = NSS_NLC2C_RX_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLC2C_RX /* 1 or 0 */ -- }, -- { -- /* -- * NSS_NLIPV4_REASM -- */ -- .name = NSS_NLIPV4_REASM_FAMILY, /* ipv4_reasm */ -- .entry = NSS_NLIPV4_REASM_INIT, /* init */ -- .exit = NSS_NLIPV4_REASM_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLIPV4_REASM /* 1 or 0 */ -- }, -- { -- /* -- * NSS_NLIPV6_REASM -- */ -- .name = NSS_NLIPV6_REASM_FAMILY, /* ipv6_reasm */ -- .entry = NSS_NLIPV6_REASM_INIT, /* init */ -- .exit = NSS_NLIPV6_REASM_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLIPV6_REASM /* 1 or 0 */ -- }, -- { -- /* - * NSS_NLWIFILI - */ - .name = NSS_NLWIFILI_FAMILY, /* wifili */ -@@ -252,62 +161,6 @@ static struct nss_nl_family family_handl - .exit = NSS_NLLSO_RX_EXIT, /* exit */ - .valid = CONFIG_NSS_NLLSO_RX /* 1 or 0 */ - }, -- { -- /* -- * NSS_NLMAP_T -- */ -- .name = NSS_NLMAP_T_FAMILY, /* map_t */ -- .entry = NSS_NLMAP_T_INIT, /* init */ -- .exit = NSS_NLMAP_T_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLMAP_T /* 1 or 0 */ -- }, -- { -- /* -- * NSS_NLPPPOE -- */ -- .name = NSS_NLPPPOE_FAMILY, /* pppoe */ -- .entry = NSS_NLPPPOE_INIT, /* init */ -- .exit = NSS_NLPPPOE_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLPPPOE /* 1 or 0 */ -- }, -- { -- /* -- * NSS_NLL2TPV2 -- */ -- .name = NSS_NLL2TPV2_FAMILY, /* l2tpv2 */ -- .entry = NSS_NLL2TPV2_INIT, /* init */ -- .exit = NSS_NLL2TPV2_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLL2TPV2 /* 1 or 0 */ -- }, -- { -- /* -- * NSS_NLPPTP -- */ -- .name = NSS_NLPPTP_FAMILY, /* pptp */ -- .entry = NSS_NLPPTP_INIT, /* init */ -- .exit = NSS_NLPPTP_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLPPTP /* 1 or 0 */ -- }, -- { -- /* -- * NSS_NLUDP_ST -- */ -- .name = NSS_NLUDP_ST_FAMILY, /* udp_st */ -- .entry = NSS_NLUDP_ST_INIT, /* init */ -- .exit = NSS_NLUDP_ST_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLUDP_ST /* 1 or 0 */ -- }, -- { -- /* -- * NSS_NLQRFS -- */ -- .name = NSS_NLQRFS_FAMILY, /* qrfs */ -- .entry = NSS_NLQRFS_INIT, /* init */ -- .exit = NSS_NLQRFS_EXIT, /* exit */ -- .valid = CONFIG_NSS_NLQRFS /* 1 or 0 */ -- }, -- -- - }; - - #define NSS_NL_FAMILY_HANDLER_SZ ARRAY_SIZE(family_handlers) ---- a/netlink/nss_nl.h -+++ b/netlink/nss_nl.h @@ -25,6 +25,7 @@ #define NSS_NL_DEBUG_LVL_WARN 2 #define NSS_NL_DEBUG_LVL_INFO 3 @@ -5095,322 +563,1587 @@ #if defined(CONFIG_DYNAMIC_DEBUG) ---- a/netlink/nss_nlcapwap.c -+++ b/netlink/nss_nlcapwap.c -@@ -1,12 +1,9 @@ - /* - ************************************************************************** - * Copyright (c) 2015-2016,2018-2020 The Linux Foundation. All rights reserved. -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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 -@@ -39,7 +36,6 @@ - #include - #include - #include --#include "nss_crypto_defines.h" - #include "nss_nl.h" - #include "nss_nlcapwap_if.h" - #include "nss_nlcapwap.h" -@@ -162,17 +158,6 @@ struct nss_nlcapwap_hdr { - */ - static struct nss_nlcapwap_global_ctx global_ctx; - --static int nss_nlcapwap_ops_create_tun(struct sk_buff *skb, struct genl_info *info); --static int nss_nlcapwap_ops_destroy_tun(struct sk_buff *skb, struct genl_info *info); --static int nss_nlcapwap_ops_update_mtu(struct sk_buff *skb, struct genl_info *info); --static int nss_nlcapwap_ops_dtls(struct sk_buff *skb, struct genl_info *info); --static int nss_nlcapwap_ops_perf(struct sk_buff *skb, struct genl_info *info); --static int nss_nlcapwap_ops_tx_packets(struct sk_buff *skb, struct genl_info *info); --static int nss_nlcapwap_ops_meta_header(struct sk_buff *skb, struct genl_info *info); --static int nss_nlcapwap_ops_ip_flow(struct sk_buff *skb, struct genl_info *info); --static int nss_nlcapwap_ops_keepalive(struct sk_buff *skb, struct genl_info *info); --static int nss_nlcapwap_ops_get_stats(struct sk_buff *skb, struct genl_info *info); +@@ -35,7 +36,8 @@ + #define nss_nl_warn(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) + #define nss_nl_info(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) + #define nss_nl_trace(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) - ++#define nss_nl_hex_dump_bytes(prefix_str, prefix_type, buf, len) \ ++ dynamic_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true) + #else /* - * nss_nlcapwap_family_mcgrp - * Multicast group for sending message status & events -@@ -182,30 +167,11 @@ static const struct genl_multicast_group - }; + * Statically compile messages at different levels +@@ -55,6 +57,11 @@ + pr_notice("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__); \ + } \ + } ++#define nss_nl_hex_dump_bytes(prefix_str, prefix_type, buf, len) { \ ++ if (NSS_NL_DEBUG_LEVEL > NSS_NL_DEBUG_LVL_INFO) { \ ++ print_hex_dump_bytes(prefix_str, prefix_type, buf, len); \ ++ } \ ++} + #define nss_nl_trace(s, ...) { \ + if (NSS_NL_DEBUG_LEVEL > NSS_NL_DEBUG_LVL_TRACE) { \ + pr_info("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__); \ +--- a/netlink/nss_nlc2c_rx.c ++++ b/netlink/nss_nlc2c_rx.c +@@ -46,20 +46,6 @@ static int nss_nlc2c_rx_ops_get_stats(st + static int nss_nlc2c_rx_process_notify(struct notifier_block *nb, unsigned long val, void *data); /* -- * nss_nlcapwap_cmd_ops -- * Operation table called by the generic netlink layer based on the command +- * c2c_rx family definition - */ --struct genl_ops nss_nlcapwap_cmd_ops[] = { -- {.cmd = NSS_NLCAPWAP_CMD_TYPE_CREATE_TUN, .doit = nss_nlcapwap_ops_create_tun,}, -- {.cmd = NSS_NLCAPWAP_CMD_TYPE_DESTROY_TUN, .doit = nss_nlcapwap_ops_destroy_tun,}, -- {.cmd = NSS_NLCAPWAP_CMD_TYPE_UPDATE_MTU, .doit = nss_nlcapwap_ops_update_mtu,}, -- {.cmd = NSS_NLCAPWAP_CMD_TYPE_DTLS, .doit = nss_nlcapwap_ops_dtls,}, -- {.cmd = NSS_NLCAPWAP_CMD_TYPE_PERF, .doit = nss_nlcapwap_ops_perf,}, -- {.cmd = NSS_NLCAPWAP_CMD_TYPE_TX_PACKETS, .doit = nss_nlcapwap_ops_tx_packets,}, -- {.cmd = NSS_NLCAPWAP_CMD_TYPE_META_HEADER, .doit = nss_nlcapwap_ops_meta_header,}, -- {.cmd = NSS_NLCAPWAP_CMD_TYPE_IP_FLOW, .doit = nss_nlcapwap_ops_ip_flow,}, -- {.cmd = NSS_NLCAPWAP_CMD_TYPE_KEEPALIVE, .doit = nss_nlcapwap_ops_keepalive,}, -- {.cmd = NSS_STATS_EVENT_NOTIFY, .doit = nss_nlcapwap_ops_get_stats,}, +-static struct genl_family nss_nlc2c_rx_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLC2C_RX_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_c2c_rx_stats_notification), /* NSS NETLINK c2c_rx stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLC2C_RX version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, -}; - -/* - * nss_nlcapwap_family - * Capwap family definition + * multicast group for sending message status & events */ - struct genl_family nss_nlcapwap_family = { --#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) - .id = GENL_ID_GENERATE, /* Auto generate ID */ --#endif - .name = NSS_NLCAPWAP_FAMILY, /* family name string */ - .hdrsize = sizeof(struct nss_nlcapwap_rule), /* NSS NETLINK capwap rule */ - .version = NSS_NL_VER, /* Set it to NSS_NL_VER version */ -@@ -213,10 +179,6 @@ struct genl_family nss_nlcapwap_family = - .netnsok = true, - .pre_doit = NULL, - .post_doit = NULL, -- .ops = nss_nlcapwap_cmd_ops, -- .n_ops = ARRAY_SIZE(nss_nlcapwap_cmd_ops), -- .mcgrps = nss_nlcapwap_family_mcgrp, -- .n_mcgrps = ARRAY_SIZE(nss_nlcapwap_family_mcgrp) + static const struct genl_multicast_group nss_nlc2c_rx_mcgrp[] = { +@@ -74,6 +60,26 @@ static struct genl_ops nss_nlc2c_rx_ops[ }; /* -@@ -601,7 +563,6 @@ static void nss_nlcapwap_create_tun_ipv4 - } - - capwap_rule->enabled_features = features; -- capwap_rule->outer_sgt_value = nl_rule->msg.create.rule.outer_sgt_value; - - /* - * Configure IPv4 rule -@@ -1471,6 +1432,23 @@ static const struct file_operations nss_ - }; - - /* -+ * nss_nlcapwap_cmd_ops -+ * Operation table called by the generic netlink layer based on the command ++ * c2c_rx family definition + */ -+struct genl_ops nss_nlcapwap_cmd_ops[] = { -+ {.cmd = NSS_NLCAPWAP_CMD_TYPE_CREATE_TUN, .doit = nss_nlcapwap_ops_create_tun,}, -+ {.cmd = NSS_NLCAPWAP_CMD_TYPE_DESTROY_TUN, .doit = nss_nlcapwap_ops_destroy_tun,}, -+ {.cmd = NSS_NLCAPWAP_CMD_TYPE_UPDATE_MTU, .doit = nss_nlcapwap_ops_update_mtu,}, -+ {.cmd = NSS_NLCAPWAP_CMD_TYPE_DTLS, .doit = nss_nlcapwap_ops_dtls,}, -+ {.cmd = NSS_NLCAPWAP_CMD_TYPE_PERF, .doit = nss_nlcapwap_ops_perf,}, -+ {.cmd = NSS_NLCAPWAP_CMD_TYPE_TX_PACKETS, .doit = nss_nlcapwap_ops_tx_packets,}, -+ {.cmd = NSS_NLCAPWAP_CMD_TYPE_META_HEADER, .doit = nss_nlcapwap_ops_meta_header,}, -+ {.cmd = NSS_NLCAPWAP_CMD_TYPE_IP_FLOW, .doit = nss_nlcapwap_ops_ip_flow,}, -+ {.cmd = NSS_NLCAPWAP_CMD_TYPE_KEEPALIVE, .doit = nss_nlcapwap_ops_keepalive,}, -+ {.cmd = NSS_STATS_EVENT_NOTIFY, .doit = nss_nlcapwap_ops_get_stats,}, ++static struct genl_family nss_nlc2c_rx_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLC2C_RX_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_c2c_rx_stats_notification), /* NSS NETLINK c2c_rx stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLC2C_RX version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nlc2c_rx_ops, ++ .n_ops = ARRAY_SIZE(nss_nlc2c_rx_ops), ++ .mcgrps = nss_nlc2c_rx_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlc2c_rx_mcgrp) +}; + +/* - * nss_nlcapwap_get_ifnum() - * Get the interface number corresponding to netdev + * stats call back handler for c2c_rx from NSS */ + static struct notifier_block nss_c2c_rx_stats_notifier_nb = { +@@ -125,7 +131,7 @@ bool nss_nlc2c_rx_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nlc2c_rx_family, nss_nlc2c_rx_ops, nss_nlc2c_rx_mcgrp); ++ error = genl_register_family(&nss_nlc2c_rx_family); + if (error) { + nss_nl_info_always("Error: unable to register c2c_rx family\n"); + return false; +--- a/netlink/nss_nlc2c_tx.c ++++ b/netlink/nss_nlc2c_tx.c +@@ -46,20 +46,6 @@ static int nss_nlc2c_tx_ops_get_stats(st + static int nss_nlc2c_tx_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * c2c_tx family definition +- */ +-static struct genl_family nss_nlc2c_tx_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLC2C_TX_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_c2c_tx_stats_notification), /* NSS NETLINK c2c_tx stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLC2C_TX version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nlc2c_tx_mcgrp[] = { +@@ -74,6 +60,26 @@ static struct genl_ops nss_nlc2c_tx_ops[ + }; + + /* ++ * c2c_tx family definition ++ */ ++static struct genl_family nss_nlc2c_tx_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLC2C_TX_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_c2c_tx_stats_notification), /* NSS NETLINK c2c_tx stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLC2C_TX version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nlc2c_tx_ops, ++ .n_ops = ARRAY_SIZE(nss_nlc2c_tx_ops), ++ .mcgrps = nss_nlc2c_tx_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlc2c_tx_mcgrp) ++}; ++ ++/* + * stats call back handler for c2c_tx from NSS + */ + static struct notifier_block nss_c2c_tx_stats_notifier_nb = { +@@ -125,7 +131,7 @@ bool nss_nlc2c_tx_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nlc2c_tx_family, nss_nlc2c_tx_ops, nss_nlc2c_tx_mcgrp); ++ error = genl_register_family(&nss_nlc2c_tx_family); + if (error) { + nss_nl_info_always("Error: unable to register c2c_tx family\n"); + return false; --- a/netlink/nss_nldtls.c +++ b/netlink/nss_nldtls.c -@@ -1,12 +1,9 @@ +@@ -15,6 +15,7 @@ + */ + + #include ++#include + #include + #include + #include +@@ -34,6 +35,14 @@ + #include "nss_nldtls_if.h" + /* - ************************************************************************** -- * Copyright (c) 2015-2016,2018-2021 The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2015-2016,2018-2020 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 -@@ -449,7 +446,7 @@ static void nss_nldtls_data_callback(voi ++ * prototypes ++ */ ++static int nss_nldtls_ops_create_tun(struct sk_buff *skb, struct genl_info *info); ++static int nss_nldtls_ops_destroy_tun(struct sk_buff *skb, struct genl_info *info); ++static int nss_nldtls_ops_update_config(struct sk_buff *skb, struct genl_info *info); ++static int nss_nldtls_ops_tx_pkts(struct sk_buff *skb, struct genl_info *info); ++ ++/* + * Initializing the global variables + */ + static struct nss_nldtls_gbl_ctx gbl_ctx = { +@@ -52,11 +61,24 @@ static const struct genl_multicast_group + }; + + /* ++ * nss_nldtls_ops ++ * Operation table called by the generic netlink layer based on the command ++ */ ++static struct genl_ops nss_nldtls_ops[] = { ++ {.cmd = NSS_NLDTLS_CMD_TYPE_CREATE_TUN, .doit = nss_nldtls_ops_create_tun,}, ++ {.cmd = NSS_NLDTLS_CMD_TYPE_DESTROY_TUN, .doit = nss_nldtls_ops_destroy_tun,}, ++ {.cmd = NSS_NLDTLS_CMD_TYPE_UPDATE_CONFIG, .doit = nss_nldtls_ops_update_config,}, ++ {.cmd = NSS_NLDTLS_CMD_TYPE_TX_PKTS, .doit = nss_nldtls_ops_tx_pkts,}, ++}; ++ ++/* + * nss_nldtls_family + * Dtls family definition + */ + struct genl_family nss_nldtls_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) + .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif + .name = NSS_NLDTLS_FAMILY, /* family name string */ + .hdrsize = sizeof(struct nss_nldtls_rule), /* NSS NETLINK dtls rule */ + .version = NSS_NL_VER, /* Set it to NSS_NLDTLS version */ +@@ -64,13 +86,17 @@ struct genl_family nss_nldtls_family = { + .netnsok = true, + .pre_doit = NULL, + .post_doit = NULL, ++ .ops = nss_nldtls_ops, ++ .n_ops = ARRAY_SIZE(nss_nldtls_ops), ++ .mcgrps = nss_nldtls_family_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nldtls_family_mcgrp) + }; + + /* +- * nss_nldtls_find_dtls_tun_gbl_ctx() ++ * nss_nldtls_find_tun_ctx() + * Returns the global context object of a tunnel + */ +-static struct nss_nldtls_tun_ctx *nss_nldtls_find_dtls_tun_gbl_ctx(struct net_device *dev) ++static struct nss_nldtls_tun_ctx *nss_nldtls_find_tun_ctx(struct net_device *dev) + { + struct nss_nldtls_tun_ctx *entry; + +@@ -87,47 +113,6 @@ static struct nss_nldtls_tun_ctx *nss_nl + } + + /* +- * nss_nldtls_data_cb() +- * Data callback function for dtls +- */ +-static void __maybe_unused nss_nldtls_data_cb(void *app_data __maybe_unused, struct sk_buff *skb __maybe_unused) +-{ +- static bool first_pkt; +- unsigned long long duration; +- ktime_t delta; +- +- if (unlikely(!first_pkt)) { +- gbl_ctx.first_rx_pkt_time = ktime_get(); +- first_pkt = true; +- } +- +- /* +- * Remove meta header +- */ +- skb_pull(skb, sizeof(struct nss_dtlsmgr_metadata)); +- gbl_ctx.last_rx_pkt_time = ktime_get(); +- +- if (unlikely(gbl_ctx.log_en)) { +- struct net_device *dev; +- +- delta = ktime_sub(gbl_ctx.last_rx_pkt_time, gbl_ctx.first_rx_pkt_time); +- duration = (unsigned long long) ktime_to_ns(delta) >> 10; +- print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, skb->data, 32); +- dev = dev_get_by_index(&init_net, skb->skb_iif); +- if (dev) { +- nss_nl_error("In dev = %s, out_dev = %s\n", dev->name, skb->dev->name); +- dev_put(dev); +- } +- +- nss_nl_info("%px: DTLS RX (%s) pkt len = %d udp_csum = %s rx_time: %llu\n", skb, +- skb->dev->name, skb->len, udp_lib_checksum_complete(skb) ? +- "invalid" : "valid", duration); +- } +- +- dev_kfree_skb_any(skb); +-} +- +-/* + * nss_nldtls_dev_rx_handler() + * Common rx handler for all dtls dev + */ +@@ -416,6 +401,48 @@ static int nss_nldtls_create_ipv6_rule(s + } + + /* ++ * nss_nldtls_data_callback() ++ * Data callback function for dtls ++ */ ++static void nss_nldtls_data_callback(void *app_data, struct sk_buff *skb) ++{ ++ struct nss_dtlsmgr_metadata *ndm; ++ struct nss_nldtls_tun_ctx *tun; ++ struct nss_nldtls_stats *stats; ++ struct net_device *dev; ++ ++ dev = dev_get_by_index(&init_net, skb->skb_iif); ++ if (!dev) { ++ nss_nl_error("Unable to get net dev for skb_iif %d\n", skb->skb_iif); ++ dev_kfree_skb_any(skb); ++ return; ++ } ++ ++ ndm = (struct nss_dtlsmgr_metadata *)skb->data; ++ tun = nss_nldtls_find_tun_ctx(dev); ++ if (!tun) { ++ nss_nl_error("Unable find tunnel ctx for %s\n", dev->name); ++ dev_put(dev); ++ dev_kfree_skb_any(skb); ++ return; ++ } ++ ++ stats = &tun->stats[NSS_NLDTLS_CTYPE_TO_IDX(ndm->ctype)]; ++ spin_lock(&gbl_ctx.lock); ++ stats->rx_pkts++; ++ stats->rx_bytes += skb->len - sizeof(*ndm); ++ spin_unlock(&gbl_ctx.lock); ++ ++ if (unlikely(gbl_ctx.log_en)) { ++ nss_nl_hex_dump_bytes("", DUMP_PREFIX_OFFSET, skb->data, (skb->len > 64) ? 64 : skb->len); ++ } ++ ++ nss_nl_trace("%px Received DTLS packet\n", skb); ++ dev_put(dev); ++ dev_kfree_skb_any(skb); ++} ++ ++/* * nss_nldtls_create_session() * Create a DTLS session through dtlsmgr driver API. */ --static struct net_device *nss_nldtls_create_session(struct nss_nldtls_rule *nl_rule) -+static struct net_device *nss_nldtls_create_session(struct nss_nldtls_rule *nl_rule, uint32_t flags) - { - struct nss_nldtls_tun_ctx *dtls_tun_data; +@@ -425,6 +452,7 @@ static struct net_device *nss_nldtls_cre struct nss_dtlsmgr_config dcfg; -@@ -466,7 +463,7 @@ static struct net_device *nss_nldtls_cre + struct nss_dtlsmgr_ctx *ctx; + struct net_device *ndev; ++ uint16_t key_len; + uint8_t algo; + int err; + +@@ -434,24 +462,66 @@ static struct net_device *nss_nldtls_cre + } memset(&dcfg, 0, sizeof(struct nss_dtlsmgr_config)); - algo = nl_rule->msg.create.encap.cfg.crypto.algo; -- dcfg.flags = nl_rule->msg.create.flags | NSS_DTLSMGR_ENCAP_METADATA; +- algo = nl_rule->msg.create.encap.crypto.algo; +- dcfg.flags = flags; ++ algo = nl_rule->msg.create.encap.cfg.crypto.algo; + dcfg.flags = flags | (NSS_DTLSMGR_ENCAP_METADATA | NSS_DTLSMGR_HDR_CAPWAP); if (algo == NSS_DTLSMGR_ALGO_AES_GCM) dcfg.flags |= NSS_DTLSMGR_CIPHER_MODE_GCM; -@@ -608,11 +605,7 @@ static int nss_nldtls_create_ipv4_rule_e - ipv4.dest_port = nl_rule->msg.create.encap.cfg.sport; - ipv4.dest_port_xlate = nl_rule->msg.create.encap.cfg.sport; + dcfg.app_data = NULL; + dcfg.notify = NULL; +- dcfg.data = NULL; ++ dcfg.data = nss_nldtls_data_callback; -- if (nl_rule->msg.create.flags & NSS_DTLSMGR_HDR_UDPLITE) -- ipv4.protocol = IPPROTO_UDPLITE; -- else -- ipv4.protocol = IPPROTO_UDP; -- -+ ipv4.protocol = IPPROTO_UDP; - ipv4.in_vlan_tag[0] = NSS_NLDTLS_VLAN_INVALID; - ipv4.out_vlan_tag[0] = NSS_NLDTLS_VLAN_INVALID; - ipv4.in_vlan_tag[1] = NSS_NLDTLS_VLAN_INVALID; -@@ -620,8 +613,6 @@ static int nss_nldtls_create_ipv4_rule_e - - memcpy(&ipv4.src_mac[0], &nl_rule->msg.create.gmac_ifmac[0], sizeof(ipv4.src_mac)); - -- dev_put(ndev); -- /* - * Create an ipv4 rule entry + * Encap configuration */ -@@ -663,11 +654,7 @@ static int nss_nldtls_create_ipv6_rule_e +- memcpy((void *)&dcfg.encap, (void *)&nl_rule->msg.create.encap, sizeof(struct nss_dtlsmgr_encap_config)); ++ key_len = nl_rule->msg.create.encap.cfg.crypto.cipher_key.len; ++ if (key_len > NSS_NLDTLS_CIPHER_KEY_MAX) { ++ nss_nl_error("Invalid cipher length: %u\n", key_len); ++ return NULL; ++ } ++ ++ key_len = nl_rule->msg.create.encap.cfg.crypto.auth_key.len; ++ if (key_len > NSS_NLDTLS_AUTH_KEY_MAX) { ++ nss_nl_error("Invalid authentication length: %u\n", key_len); ++ return NULL; ++ } ++ ++ key_len = nl_rule->msg.create.encap.cfg.crypto.nonce.len; ++ if (key_len > NSS_NLDTLS_NONCE_SIZE_MAX) { ++ nss_nl_error("Invalid nonce length: %u\n", key_len); ++ return NULL; ++ } ++ ++ nl_rule->msg.create.encap.cfg.crypto.cipher_key.data = nl_rule->msg.create.encap.keys.cipher; ++ nl_rule->msg.create.encap.cfg.crypto.auth_key.data = nl_rule->msg.create.encap.keys.auth; ++ nl_rule->msg.create.encap.cfg.crypto.nonce.data = nl_rule->msg.create.encap.keys.nonce; ++ memcpy((void *)&dcfg.encap, (void *)&nl_rule->msg.create.encap.cfg, sizeof(struct nss_dtlsmgr_encap_config)); + + /* + * Decap configuration */ - memcpy(ipv6.src_ip, nl_rule->msg.create.encap.cfg.dip, sizeof(ipv6.src_ip)); - memcpy(ipv6.dest_ip, nl_rule->msg.create.encap.cfg.sip, sizeof(ipv6.dest_ip)); +- memcpy((void *)&dcfg.decap, (void *)&nl_rule->msg.create.decap, sizeof(struct nss_dtlsmgr_decap_config)); ++ key_len = nl_rule->msg.create.decap.cfg.crypto.cipher_key.len; ++ if (key_len > NSS_NLDTLS_CIPHER_KEY_MAX) { ++ nss_nl_error("Invalid cipher length: %u\n", key_len); ++ return NULL; ++ } ++ ++ key_len = nl_rule->msg.create.decap.cfg.crypto.auth_key.len; ++ if (key_len > NSS_NLDTLS_AUTH_KEY_MAX) { ++ nss_nl_error("Invalid authentication length: %u\n", key_len); ++ return NULL; ++ } ++ ++ key_len = nl_rule->msg.create.decap.cfg.crypto.nonce.len; ++ if (key_len > NSS_NLDTLS_NONCE_SIZE_MAX) { ++ nss_nl_error("Invalid nonce length: %u\n", key_len); ++ return NULL; ++ } ++ ++ nl_rule->msg.create.decap.cfg.crypto.cipher_key.data = nl_rule->msg.create.decap.keys.cipher; ++ nl_rule->msg.create.decap.cfg.crypto.auth_key.data = nl_rule->msg.create.decap.keys.auth; ++ nl_rule->msg.create.decap.cfg.crypto.nonce.data = nl_rule->msg.create.decap.keys.nonce; ++ memcpy((void *)&dcfg.decap, (void *)&nl_rule->msg.create.decap.cfg, sizeof(struct nss_dtlsmgr_decap_config)); + dcfg.decap.nexthop_ifnum = NSS_N2H_INTERFACE; + + /* +@@ -484,6 +554,7 @@ static struct net_device *nss_nldtls_cre + dtls_tun_data = (struct nss_nldtls_tun_ctx *)kmalloc(sizeof(*dtls_tun_data), GFP_KERNEL); + dtls_tun_data->nl_rule = nl_rule; + memcpy(dtls_tun_data->dev_name, ndev->name, IFNAMSIZ); ++ memset(&dtls_tun_data->stats, 0, sizeof(dtls_tun_data->stats)); + + /* + * Adding tunnel to global list of tunnels +@@ -524,15 +595,15 @@ static int nss_nldtls_create_ipv4_rule_e + ipv4.src_interface_num = if_num; + ipv4.dest_interface_num = nss_dtlsmgr_get_interface(dtls_dev, NSS_DTLSMGR_INTERFACE_TYPE_OUTER); + +- ipv4.src_port = nl_rule->msg.create.encap.dport; +- ipv4.src_port_xlate = nl_rule->msg.create.encap.dport; +- ipv4.src_ip = nl_rule->msg.create.encap.dip[0]; +- ipv4.src_ip_xlate = nl_rule->msg.create.encap.dip[0]; - -- if (nl_rule->msg.create.flags & NSS_DTLSMGR_HDR_UDPLITE) -- ipv6.protocol = IPPROTO_UDPLITE; -- else -- ipv6.protocol = IPPROTO_UDP; -+ ipv6.protocol = IPPROTO_UDP; +- ipv4.dest_ip = nl_rule->msg.create.encap.sip[0]; +- ipv4.dest_ip_xlate = nl_rule->msg.create.encap.sip[0]; +- ipv4.dest_port = nl_rule->msg.create.encap.sport; +- ipv4.dest_port_xlate = nl_rule->msg.create.encap.sport; ++ ipv4.src_port = nl_rule->msg.create.encap.cfg.dport; ++ ipv4.src_port_xlate = nl_rule->msg.create.encap.cfg.dport; ++ ipv4.src_ip = nl_rule->msg.create.encap.cfg.dip[0]; ++ ipv4.src_ip_xlate = nl_rule->msg.create.encap.cfg.dip[0]; ++ ++ ipv4.dest_ip = nl_rule->msg.create.encap.cfg.sip[0]; ++ ipv4.dest_ip_xlate = nl_rule->msg.create.encap.cfg.sip[0]; ++ ipv4.dest_port = nl_rule->msg.create.encap.cfg.sport; ++ ipv4.dest_port_xlate = nl_rule->msg.create.encap.cfg.sport; + + ipv4.protocol = IPPROTO_UDP; + ipv4.in_vlan_tag[0] = NSS_NLDTLS_VLAN_INVALID; +@@ -575,14 +646,14 @@ static int nss_nldtls_create_ipv6_rule_e + if_num = nss_cmn_get_interface_number_by_dev(ndev); + ipv6.src_interface_num = if_num; + ipv6.dest_interface_num = nss_dtlsmgr_get_interface(dtls_dev, NSS_DTLSMGR_INTERFACE_TYPE_OUTER); +- ipv6.src_port = nl_rule->msg.create.encap.dport; +- ipv6.dest_port = nl_rule->msg.create.encap.sport; ++ ipv6.src_port = nl_rule->msg.create.encap.cfg.dport; ++ ipv6.dest_port = nl_rule->msg.create.encap.cfg.sport; + + /* + * Configure IPv6 rule + */ +- memcpy(ipv6.src_ip, nl_rule->msg.create.encap.dip, sizeof(ipv6.src_ip)); +- memcpy(ipv6.dest_ip, nl_rule->msg.create.encap.sip, sizeof(ipv6.dest_ip)); ++ memcpy(ipv6.src_ip, nl_rule->msg.create.encap.cfg.dip, sizeof(ipv6.src_ip)); ++ memcpy(ipv6.dest_ip, nl_rule->msg.create.encap.cfg.sip, sizeof(ipv6.dest_ip)); + ipv6.protocol = IPPROTO_UDP; ipv6.in_vlan_tag[0] = NSS_NLDTLS_VLAN_INVALID; - ipv6.in_vlan_tag[1] = NSS_NLDTLS_VLAN_INVALID; -@@ -676,8 +663,6 @@ static int nss_nldtls_create_ipv6_rule_e +@@ -602,29 +673,27 @@ static int nss_nldtls_create_ipv6_rule_e + * nss_nldtls_destroy_tun() + * Common handler for tunnel destroy + */ +-static int nss_nldtls_destroy_tun(struct net_device *dtls_ndev) ++static int nss_nldtls_destroy_tun(struct net_device *dev) + { +- struct nss_nldtls_tun_ctx *dtls_tun_data; ++ struct nss_nldtls_tun_ctx *tun; - memcpy(&ipv6.src_mac[0], &nl_rule->msg.create.gmac_ifmac[0], sizeof(ipv6.src_mac)); +- dtls_tun_data = nss_nldtls_find_dtls_tun_gbl_ctx(dtls_ndev); +- if (!dtls_tun_data) { +- nss_nl_error("Unable to find context of the tunnel: %s\n", dtls_ndev->name); +- dev_put(dtls_ndev); ++ tun = nss_nldtls_find_tun_ctx(dev); ++ if (!tun) { ++ nss_nl_error("Unable to find context of the tunnel: %s\n", dev->name); + return -EAGAIN; + } -- dev_put(ndev); -- /* - * Create an ipv6 rule entry + * Delete tunnel node from the list */ -@@ -744,7 +729,7 @@ static int nss_nldtls_ops_create_tun(str - * Create tunnel based on ip version +- list_del_init(&dtls_tun_data->list); +- kfree(dtls_tun_data); +- dev_put(dtls_ndev); ++ list_del_init(&tun->list); ++ kfree(tun); + + /* + * Destroy the dtls session */ - if (nl_rule->msg.create.ip_version == NSS_NLDTLS_IP_VERS_4) { -- dtls_dev = nss_nldtls_create_session(nl_rule); -+ dtls_dev = nss_nldtls_create_session(nl_rule, NSS_NLDTLS_IPV4_SESSION); - if (!dtls_dev) { - nss_nl_error("%px: Unable to create dtls session for v4\n", skb); +- if (nss_dtlsmgr_session_destroy(dtls_ndev)) { +- nss_nl_error("Unable to destroy the tunnel: %s\n", dtls_ndev->name); ++ if (nss_dtlsmgr_session_destroy(dev)) { ++ nss_nl_error("Unable to destroy the tunnel: %s\n", dev->name); + return -EAGAIN; + } + +@@ -709,8 +778,8 @@ static int nss_nldtls_ops_create_tun(str + static int nss_nldtls_ops_destroy_tun(struct sk_buff *skb, struct genl_info *info) + { + struct nss_nldtls_rule *nl_rule; +- struct net_device *dtls_ndev; + struct nss_nlcmn *nl_cm; ++ struct net_device *dev; + int ret; + + /* +@@ -727,18 +796,20 @@ static int nss_nldtls_ops_destroy_tun(st + */ + nl_rule = container_of(nl_cm, struct nss_nldtls_rule, cm); + +- dtls_ndev = dev_get_by_name(&init_net, nl_rule->msg.destroy.dev_name); +- if (!dtls_ndev) { +- nss_nl_error("%px: Unable to find dev: %s\n", skb, nl_rule->msg.destroy.dev_name); ++ dev = dev_get_by_name(&init_net, nl_rule->msg.destroy.dev_name); ++ if (!dev) { ++ nss_nl_error("%px Unable to find dev: %s\n", skb, nl_rule->msg.destroy.dev_name); + return -EINVAL; + } + ++ dev_put(dev); ++ + /* + * Common dtls handler for tunnel destroy + */ +- ret = nss_nldtls_destroy_tun(dtls_ndev); ++ ret = nss_nldtls_destroy_tun(dev); + if (ret < 0) { +- nss_nl_error("%px: Unable to destroy tunnel: %s\n", skb, dtls_ndev->name); ++ nss_nl_error("%px Unable to destroy tunnel: %s\n", skb, dev->name); + return -EAGAIN; + } + +@@ -753,13 +824,14 @@ static int nss_nldtls_ops_destroy_tun(st + */ + static int nss_nldtls_ops_update_config(struct sk_buff *skb, struct genl_info *info) + { +- struct nss_nldtls_tun_ctx *dtls_tun_data; + struct nss_dtlsmgr_config_update dcfg; + struct nss_nldtls_rule *nl_rule; +- struct net_device *dtls_ndev; ++ struct nss_nldtls_tun_ctx *tun; + struct nss_dtlsmgr_ctx *ctx; + nss_dtlsmgr_status_t status; + struct nss_nlcmn *nl_cm; ++ struct net_device *dev; ++ uint16_t key_len; + + /* + * extract the message payload +@@ -775,17 +847,17 @@ static int nss_nldtls_ops_update_config( + */ + nl_rule = container_of(nl_cm, struct nss_nldtls_rule, cm); + +- dtls_ndev = dev_get_by_name(&init_net, nl_rule->msg.update_config.dev_name); +- if (!dtls_ndev) { +- nss_nl_error("%px: Unable to find dev: %s\n", skb, nl_rule->msg.update_config.dev_name); ++ dev = dev_get_by_name(&init_net, nl_rule->msg.update_config.dev_name); ++ if (!dev) { ++ nss_nl_error("%px Unable to find dev: %s\n", skb, nl_rule->msg.update_config.dev_name); + return -EINVAL; + } + +- ctx = netdev_priv(dtls_ndev); +- dtls_tun_data = nss_nldtls_find_dtls_tun_gbl_ctx(dtls_ndev); +- if (!dtls_tun_data) { +- nss_nl_error("%px: Unable to find context of the tunnel: %s\n", ctx, dtls_ndev->name); +- dev_put(dtls_ndev); ++ ctx = netdev_priv(dev); ++ tun = nss_nldtls_find_tun_ctx(dev); ++ if (!tun) { ++ nss_nl_error("%px Unable to find context of the tunnel: %s\n", ctx, dev->name); ++ dev_put(dev); + return -EAGAIN; + } + +@@ -793,28 +865,46 @@ static int nss_nldtls_ops_update_config( + * Configure the dtls configuration + */ + dcfg.crypto.algo = nl_rule->msg.update_config.config_update.crypto.algo; +- dcfg.crypto.cipher_key.data = nl_rule->msg.update_config.config_update.crypto.cipher_key.data; +- dcfg.crypto.cipher_key.len = nl_rule->msg.update_config.config_update.crypto.cipher_key.len; +- dcfg.crypto.auth_key.data = nl_rule->msg.update_config.config_update.crypto.auth_key.data; +- dcfg.crypto.auth_key.len = nl_rule->msg.update_config.config_update.crypto.auth_key.len; +- dcfg.crypto.nonce.data = nl_rule->msg.update_config.config_update.crypto.nonce.data; +- dcfg.crypto.nonce.len = nl_rule->msg.update_config.config_update.crypto.nonce.len; ++ dcfg.crypto.cipher_key.data = nl_rule->msg.update_config.keys.cipher; ++ dcfg.crypto.auth_key.data = nl_rule->msg.update_config.keys.auth; ++ dcfg.crypto.nonce.data = nl_rule->msg.update_config.keys.nonce; ++ key_len = nl_rule->msg.update_config.config_update.crypto.cipher_key.len; ++ if (key_len > NSS_NLDTLS_CIPHER_KEY_MAX) { ++ nss_nl_error("Invalid cipher length: %u\n", key_len); ++ return -EINVAL; ++ } ++ ++ dcfg.crypto.cipher_key.len = key_len; ++ key_len = nl_rule->msg.update_config.config_update.crypto.auth_key.len; ++ if (key_len > NSS_NLDTLS_AUTH_KEY_MAX) { ++ nss_nl_error("Invalid authentication length: %u\n", key_len); ++ return -EINVAL; ++ } ++ ++ dcfg.crypto.auth_key.len = key_len; ++ key_len = nl_rule->msg.update_config.config_update.crypto.nonce.len; ++ if (key_len > NSS_NLDTLS_NONCE_SIZE_MAX) { ++ nss_nl_error("Invalid nonce length: %u\n", key_len); ++ return -EINVAL; ++ } ++ ++ dcfg.crypto.nonce.len = key_len; + dcfg.epoch = nl_rule->msg.update_config.config_update.epoch; + dcfg.window_size = nl_rule->msg.update_config.config_update.window_size; + if (!nl_rule->msg.update_config.dir) { +- status = nss_dtlsmgr_session_update_encap(dtls_ndev, &dcfg); ++ status = nss_dtlsmgr_session_update_encap(dev, &dcfg); + if (status != NSS_DTLSMGR_OK) { +- nss_nl_error("%px: Unable to update encap configuration\n", ctx); +- dev_put(dtls_ndev); ++ nss_nl_error("%px Unable to update encap configuration\n", ctx); ++ dev_put(dev); return -EINVAL; -@@ -763,7 +748,7 @@ static int nss_nldtls_ops_create_tun(str - atomic_inc(&gbl_ctx.num_tun); - nss_nl_info("%px: Successfully created ipv4 dtls tunnel\n", skb); + } + + nss_nl_info("%px: Successfully update the encap configuration\n", ctx); } else { -- dtls_dev = nss_nldtls_create_session(nl_rule); -+ dtls_dev = nss_nldtls_create_session(nl_rule, NSS_DTLSMGR_HDR_IPV6); - if (!dtls_dev) { - nss_nl_error("%px: Unable to create dtls session for v6\n", skb); +- status = nss_dtlsmgr_session_update_decap(dtls_ndev, &dcfg); ++ status = nss_dtlsmgr_session_update_decap(dev, &dcfg); + if (status != NSS_DTLSMGR_OK) { +- nss_nl_error("%px: Unable to update decap configuration\n", ctx); +- dev_put(dtls_ndev); ++ nss_nl_error("%px Unable to update decap configuration\n", ctx); ++ dev_put(dev); return -EINVAL; -@@ -886,7 +871,6 @@ static int nss_nldtls_ops_update_config( - key_len = nl_rule->msg.update_config.config_update.crypto.cipher_key.len; - if (key_len > NSS_NLDTLS_CIPHER_KEY_MAX) { - nss_nl_error("Invalid cipher length: %u\n", key_len); -- dev_put(dev); + } + +@@ -824,213 +914,65 @@ static int nss_nldtls_ops_update_config( + /* + * Update the tun data configuration + */ +- dtls_tun_data->nl_rule = nl_rule; ++ tun->nl_rule = nl_rule; ++ dev_put(dev); + return 0; + } + + /* +- * nss_nldtls_construct_ipv4_udp_header() +- * Creates an ipv4 + udp packet +- */ +-static struct sk_buff *nss_nldtls_construct_ipv4_udp_header(struct net_device *dev, struct nss_nldtls_rule *nl_rule) +-{ +- struct nss_nldtls_tun_ctx *tun_data; +- struct nss_nldtls_rule *dtls_rule; +- uint16_t hroom, troom; +- struct sk_buff *skb; +- struct udphdr *uh; +- struct iphdr *iph; +- +- /* +- * Get the tun data +- */ +- tun_data = nss_nldtls_find_dtls_tun_gbl_ctx(dev); +- dtls_rule = tun_data->nl_rule; +- hroom = dev->needed_headroom; +- troom = dev->needed_tailroom; +- skb = dev_alloc_skb(nl_rule->msg.tx_pkts.pkt_sz + hroom + troom); +- if (!skb) { +- nss_nl_info("Failed to allocate skb\n"); +- return NULL; +- } +- +- skb_reserve(skb, sizeof(struct udphdr) + sizeof(struct iphdr)); +- skb_put(skb, nl_rule->msg.tx_pkts.pkt_sz); +- +- /* +- * Fill the packet with dummy data +- */ +- memset(skb->data, NSS_NLDTLS_DUMMY_DATA, skb->len); +- +- /* +- * Fill udp header fields +- */ +- skb_push(skb, sizeof(struct udphdr)); +- uh = (struct udphdr *)skb->data; +- uh->source = htons(dtls_rule->msg.create.encap.sport); +- uh->dest = htons(dtls_rule->msg.create.encap.dport); +- uh->len = htons(skb->len); +- uh->check = 0; +- +- /* +- * Fill IP header fields +- */ +- skb_push(skb, sizeof(struct iphdr)); +- iph = (struct iphdr *)skb->data; +- iph->ihl = 5; +- iph->version = 4; +- iph->tot_len = (nl_rule->msg.tx_pkts.pkt_sz + sizeof(struct udphdr) + sizeof(struct iphdr)); +- iph->ttl = dtls_rule->msg.create.encap.ip_ttl; +- iph->protocol = IPPROTO_UDP; +- iph->saddr = dtls_rule->msg.create.encap.sip[0]; +- iph->daddr = dtls_rule->msg.create.encap.dip[0]; +- +- /* +- * UDP checksum +- */ +- uh->check = udp_csum(skb); +- uh->check = csum_tcpudp_magic(iph->saddr, iph->daddr, skb->len, +- IPPROTO_UDP, uh->check); +- +- if (nl_rule->msg.tx_pkts.log_en) { +- nss_nl_info("%px: DTLS TX pkt len:%d udp_csum:0x%x\n", skb, skb->len, uh->check); +- } +- +- return skb; +-} +- +-/* +- * nss_nldtls_construct_ipv6_udp_header() +- * Creates an ipv6 + udp packet ++ * nss_nldtls_alloc_pkt() ++ * Handler for forming ctype packet + */ +-static struct sk_buff *nss_nldtls_construct_ipv6_udp_header(struct net_device *dev, struct nss_nldtls_rule *nl_rule) ++static struct sk_buff *nss_nldtls_alloc_pkt(struct nss_nldtls_rule *nl_rule, ++ struct net_device *dev, uint32_t pkt_sz, uint8_t ctype) + { +- struct nss_nldtls_tun_ctx *tun_data; +- struct nss_nldtls_rule *dtls_rule; +- uint16_t hroom, troom; ++ struct nss_dtlsmgr_metadata *ndm; ++ uint16_t hdr_len, payload_len; + struct sk_buff *skb; +- struct udphdr *uh; +- struct ipv6hdr *ip6h; + +- /* +- * Get the tun data +- */ +- tun_data = nss_nldtls_find_dtls_tun_gbl_ctx(dev); +- dtls_rule = tun_data->nl_rule; +- hroom = dev->needed_headroom; +- troom = dev->needed_tailroom; +- skb = dev_alloc_skb(nl_rule->msg.tx_pkts.pkt_sz + hroom + troom); ++ hdr_len = dev->needed_headroom + sizeof(*ndm); ++ payload_len = hdr_len + dev->needed_tailroom + pkt_sz; ++ skb = netdev_alloc_skb(dev, payload_len); + if (!skb) { +- nss_nl_info("Failed to allocate skb\n"); + return NULL; + } + +- skb_reserve(skb, sizeof(struct udphdr) + sizeof(struct iphdr)); +- skb_put(skb, nl_rule->msg.tx_pkts.pkt_sz); ++ skb_reserve(skb, hdr_len); + + /* + * Fill the packet with dummy data + */ +- memset(skb->data, NSS_NLDTLS_DUMMY_DATA, skb->len); +- +- /* +- * Fill udp header fields +- */ +- skb_push(skb, sizeof(struct udphdr)); +- uh = (struct udphdr *)skb->data; +- uh->source = htons(dtls_rule->msg.create.encap.sport); +- uh->dest = htons(dtls_rule->msg.create.encap.dport); +- uh->len = htons(skb->len); +- uh->check = 0; ++ memset(skb_put(skb, pkt_sz), NSS_NLDTLS_DUMMY_DATA, skb->len); + +- /* +- * Fill IP header fields +- */ +- skb_push(skb, sizeof(struct ipv6hdr)); +- ip6h = (struct ipv6hdr *)skb->data; +- ip6h->version = 6; +- ip6h->payload_len = htons(nl_rule->msg.tx_pkts.pkt_sz + sizeof(struct udphdr)); +- ip6h->hop_limit = 64; +- ip6h->nexthdr = IPPROTO_UDP; +- ip6h->saddr.in6_u.u6_addr32[0] = htonl(dtls_rule->msg.create.encap.sip[0]); +- ip6h->saddr.in6_u.u6_addr32[1] = htonl(dtls_rule->msg.create.encap.sip[1]); +- ip6h->saddr.in6_u.u6_addr32[2] = htonl(dtls_rule->msg.create.encap.sip[2]); +- ip6h->saddr.in6_u.u6_addr32[3] = htonl(dtls_rule->msg.create.encap.sip[3]); ++ ndm = nss_dtlsmgr_metadata_init(skb); ++ nss_dtlsmgr_metadata_set_seq(ndm, nl_rule->msg.tx_pkts.seq_num); ++ nss_dtlsmgr_metadata_set_ctype(ndm, ctype); + +- ip6h->saddr.in6_u.u6_addr32[0] = htonl(dtls_rule->msg.create.encap.dip[0]); +- ip6h->saddr.in6_u.u6_addr32[1] = htonl(dtls_rule->msg.create.encap.dip[1]); +- ip6h->saddr.in6_u.u6_addr32[2] = htonl(dtls_rule->msg.create.encap.dip[2]); +- ip6h->saddr.in6_u.u6_addr32[3] = htonl(dtls_rule->msg.create.encap.dip[3]); +- +- skb_set_transport_header(skb, sizeof(struct ipv6hdr)); +- /* +- * UDP checksum +- */ +- udp6_set_csum(false, skb, &ip6h->saddr, &ip6h->daddr, nl_rule->msg.tx_pkts.pkt_sz + sizeof(struct udphdr)); +- +- if (nl_rule->msg.tx_pkts.log_en) { +- nss_nl_info("%px: DTLS TX pkt len:%d udp_csum:0x%x\n", skb, skb->len, uh->check); ++ if (unlikely(nl_rule->msg.tx_pkts.log_en)) { ++ nss_nl_info("%px DTLS TX pkt len:%u\n", skb, skb->len); + } + + return skb; + } + + /* +- * nss_nldtls_tx_ipv4_pkts_host_to_host() +- * Handler for sending ipv4 traffic from one host to other +- */ +-static bool nss_nldtls_tx_ipv4_pkts_host_to_host(struct nss_nldtls_rule *nl_rule, struct net_device *dtls_dev) +-{ +- int i; +- for (i = 0; i < nl_rule->msg.tx_pkts.num_pkts; i++) { +- struct sk_buff *skb; +- +- skb = nss_nldtls_construct_ipv4_udp_header(dtls_dev, nl_rule); +- if (!skb) { +- nss_nl_error("%px: Unable to create ipv4 + udp packet\n", dtls_dev); +- return false; +- } +- +- dtls_dev->netdev_ops->ndo_start_xmit(skb, dtls_dev); +- } +- +- return true; +-} +- +-/* +- * nss_nldtls_tx_ipv6_pkts_host_to_host() +- * Handler for sending ipv6 traffic from one host to other +- */ +-static bool nss_nldtls_tx_ipv6_pkts_host_to_host(struct nss_nldtls_rule *nl_rule, struct net_device *dtls_dev) +-{ +- int i; +- for (i = 0; i < nl_rule->msg.tx_pkts.num_pkts; i++) { +- struct sk_buff *skb; +- +- skb = nss_nldtls_construct_ipv6_udp_header(dtls_dev, nl_rule); +- if (!skb) { +- nss_nl_error("%px: Unable to create ipv4 + udp packet\n", dtls_dev); +- return false; +- } +- +- dtls_dev->netdev_ops->ndo_start_xmit(skb, dtls_dev); +- } +- +- return true; +-} +- +-/* + * nss_nldtls_ops_tx_pkts() + * Handler for sending traffic + */ + static int nss_nldtls_ops_tx_pkts(struct sk_buff *skb, struct genl_info *info) + { +- struct nss_nldtls_tun_ctx *dtls_tun_data; + struct nss_nldtls_rule *nl_rule; +- struct net_device *dtls_ndev; ++ struct nss_nldtls_tun_ctx *tun; ++ struct nss_nldtls_stats *stats; + unsigned long long duration; + struct nss_nlcmn *nl_cm; ++ struct net_device *dev; ++ struct sk_buff *tx_skb; ++ uint32_t num_pkts; ++ uint32_t pkt_sz; ++ uint32_t count; + ktime_t delta; ++ uint8_t ctype; + + /* + * extract the message payload +@@ -1046,56 +988,149 @@ static int nss_nldtls_ops_tx_pkts(struct + */ + nl_rule = container_of(nl_cm, struct nss_nldtls_rule, cm); + +- dtls_ndev = dev_get_by_name(&init_net, nl_rule->msg.tx_pkts.dev_name); +- if (!dtls_ndev) { +- nss_nl_error("%px: Unable to find dev: %s\n", skb, nl_rule->msg.tx_pkts.dev_name); ++ ctype = nl_rule->msg.tx_pkts.ctype; ++ num_pkts = nl_rule->msg.tx_pkts.num_pkts; ++ ++ switch (ctype) { ++ case NSS_DTLSMGR_METADATA_CTYPE_CCS: ++ pkt_sz = NSS_NLDTLS_CCS_PKT_SZ; ++ break; ++ ++ case NSS_DTLSMGR_METADATA_CTYPE_ALERT: ++ pkt_sz = NSS_NLDTLS_ALERT_PKT_SZ; ++ break; ++ ++ case NSS_DTLSMGR_METADATA_CTYPE_HANDSHAKE: ++ pkt_sz = NSS_NLDTLS_HANDSHAKE_PKT_SZ; ++ break; ++ ++ case NSS_DTLSMGR_METADATA_CTYPE_APP: ++ pkt_sz = nl_rule->msg.tx_pkts.pkt_sz; ++ break; ++ ++ default: return -EINVAL; } -@@ -894,7 +878,6 @@ static int nss_nldtls_ops_update_config( - key_len = nl_rule->msg.update_config.config_update.crypto.auth_key.len; - if (key_len > NSS_NLDTLS_AUTH_KEY_MAX) { - nss_nl_error("Invalid authentication length: %u\n", key_len); -- dev_put(dev); - return -EINVAL; +- dtls_tun_data = nss_nldtls_find_dtls_tun_gbl_ctx(dtls_ndev); +- if (!dtls_tun_data) { +- nss_nl_error("%px: Unable to find context of the tunnel: %s\n", skb, dtls_ndev->name); +- dev_put(dtls_ndev); +- return -EAGAIN; ++ dev = dev_get_by_name(&init_net, nl_rule->msg.tx_pkts.dev_name); ++ if (!dev) { ++ nss_nl_error("%px Unable to find dev: %s\n", skb, nl_rule->msg.tx_pkts.dev_name); ++ return -EINVAL; ++ } ++ ++ tun = nss_nldtls_find_tun_ctx(dev); ++ if (!tun) { ++ nss_nl_error("%px Unable to find context of the tunnel: %s\n", skb, dev->name); ++ dev_put(dev); ++ return -EINVAL; } -@@ -902,7 +885,6 @@ static int nss_nldtls_ops_update_config( - key_len = nl_rule->msg.update_config.config_update.crypto.nonce.len; - if (key_len > NSS_NLDTLS_NONCE_SIZE_MAX) { - nss_nl_error("Invalid nonce length: %u\n", key_len); -- dev_put(dev); - return -EINVAL; + spin_lock(&gbl_ctx.lock); + gbl_ctx.log_en = nl_rule->msg.tx_pkts.log_en; + spin_unlock(&gbl_ctx.lock); + +- /* +- * Send traffic from host to host +- */ + gbl_ctx.first_tx_pkt_time = ktime_get(); +- if (nl_rule->msg.tx_pkts.ip_version == NSS_NLDTLS_IP_VERS_4) { +- if (!nss_nldtls_tx_ipv4_pkts_host_to_host(nl_rule, dtls_ndev)) { +- nss_nl_error("%px: Error in transmission\n", skb); +- return -EAGAIN; +- } +- } else { +- if (!nss_nldtls_tx_ipv6_pkts_host_to_host(nl_rule, dtls_ndev)) { +- nss_nl_error("%px: Error in transmission\n", skb); +- return -EAGAIN; ++ ++ for (count = 0; count < num_pkts; count++) { ++ tx_skb = nss_nldtls_alloc_pkt(nl_rule, dev, pkt_sz, ctype); ++ if (!tx_skb) { ++ nss_nl_error("%px Failed to allocate skb\n", dev); ++ break; + } ++ ++ dev->netdev_ops->ndo_start_xmit(tx_skb, dev); ++ } ++ ++ stats = &tun->stats[NSS_NLDTLS_CTYPE_TO_IDX(ctype)]; ++ spin_lock(&gbl_ctx.lock); ++ stats->tx_pkts += count; ++ stats->tx_bytes += (count * pkt_sz); ++ spin_unlock(&gbl_ctx.lock); ++ dev_put(dev); ++ ++ if (count != num_pkts) { ++ nss_nl_error("%px Error in transmission\n", skb); ++ return -EAGAIN; } + gbl_ctx.last_tx_pkt_time = ktime_get(); + delta = ktime_sub(gbl_ctx.last_tx_pkt_time, gbl_ctx.first_tx_pkt_time); + duration = (unsigned long long) ktime_to_ns(delta) >> 10; +- nss_nl_info("%px: Packets sent in %llu usecs", dtls_ndev, duration); +- nss_nl_info("%px: Traffic transmission successful\n", skb); ++ nss_nl_info("%px Packets sent in %llu usecs", dev, duration); ++ nss_nl_info("%px Traffic transmission successful\n", skb); + return 0; + } + + /* +- * nss_nldtls_cmd_ops +- * Operation table called by the generic netlink layer based on the command ++ * nss_nldtls_tunnel_stats_read() ++ * reads the per tunnel tx and rx packets stats for every ctypes + */ +-struct genl_ops nss_nldtls_cmd_ops[] = { +- {.cmd = NSS_NLDTLS_CMD_TYPE_CREATE_TUN, .doit = nss_nldtls_ops_create_tun,}, +- {.cmd = NSS_NLDTLS_CMD_TYPE_DESTROY_TUN, .doit = nss_nldtls_ops_destroy_tun,}, +- {.cmd = NSS_NLDTLS_CMD_TYPE_UPDATE_CONFIG, .doit = nss_nldtls_ops_update_config,}, +- {.cmd = NSS_NLDTLS_CMD_TYPE_TX_PKTS, .doit = nss_nldtls_ops_tx_pkts,}, ++static ssize_t nss_nldtls_tunnel_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *f_ppos) ++{ ++ struct nss_nldtls_stats stats[NSS_NLDTLS_CTYPE_MAX]; ++ struct nss_nldtls_tun_ctx *entry; ++ uint32_t max_output_lines; ++ char dev_name[IFNAMSIZ]; ++ ssize_t bytes_read = 0; ++ ssize_t size_wr = 0; ++ ssize_t size_al; ++ char *lbuf; ++ ++ max_output_lines = 2 + (NSS_NLDTLS_MAX_TUNNELS * NSS_NLDTLS_STATS_MAX_ROW); ++ size_al = NSS_NLDTLS_STATS_MAX_STR_LEN * max_output_lines; ++ ++ lbuf = vzalloc(size_al); ++ ++ if (!lbuf) { ++ nss_nl_error("%px Could not allocate buffer for debug entry\n", f_ppos); ++ return 0; ++ } ++ ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nDTLS netlink ctype stats:\n"); ++ list_for_each_entry(entry, &gbl_ctx.dtls_list_head, list) { ++ spin_lock_bh(&gbl_ctx.lock); ++ memcpy(&stats, &entry->stats, sizeof(stats)); ++ strlcpy(dev_name, entry->dev_name, IFNAMSIZ); ++ spin_unlock_bh(&gbl_ctx.lock); ++ ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n--------------------------------"); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n%s:\t %s", "dev", dev_name); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n change_cipher_spec"); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "tx_pkts", stats[0].tx_pkts); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "tx_bytes", stats[0].tx_bytes); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "rx_pkts", stats[0].rx_pkts); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "rx_bytes", stats[0].rx_bytes); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n alert"); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "tx_pkts", stats[1].tx_pkts); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "tx_bytes", stats[1].tx_bytes); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "rx_pkts", stats[1].rx_pkts); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "rx_bytes", stats[1].rx_bytes); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n handshake"); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "tx_pkts", stats[2].tx_pkts); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "tx_bytes", stats[2].tx_bytes); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "rx_pkts", stats[2].rx_pkts); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "rx_bytes", stats[2].rx_bytes); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n app_data"); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "tx_pkts", stats[3].tx_pkts); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "tx_bytes", stats[3].tx_bytes); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "rx_pkts", stats[3].rx_pkts); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n\t%s:\t %llu", "rx_bytes", stats[3].rx_bytes); ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n--------------------------------\n"); ++ } ++ ++ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nDTLS netlink ctype stats end\n\n"); ++ bytes_read = simple_read_from_buffer(ubuf, sz, f_ppos, lbuf, size_wr); ++ ++ vfree(lbuf); ++ return bytes_read; ++} ++ ++/* ++ * nss_nldtls_stats_ops() ++ * file operation handler for dentry ++ */ ++static const struct file_operations nss_nldtls_stats_ops = { ++ .read = nss_nldtls_tunnel_stats_read, + }; + + /* +@@ -1111,14 +1146,35 @@ bool nss_nldtls_init(void) + /* + * register NETLINK ops with the family + */ +- err = genl_register_family_with_ops_groups(&nss_nldtls_family, nss_nldtls_cmd_ops, nss_nldtls_family_mcgrp); ++ err = genl_register_family(&nss_nldtls_family); + if (err) { + nss_nl_info_always("Error: %d unable to register gre_redir family\n", err); + genl_unregister_family(&nss_nldtls_family); + return false; + } + ++ /* ++ * Create a debugfs entry for netlink dtls ++ */ ++ gbl_ctx.dentry = debugfs_create_dir("nldtls", NULL); ++ if (!gbl_ctx.dentry) { ++ nss_nl_info_always("Cannot create nldtls directory\n"); ++ goto free_family; ++ } ++ ++ if (!debugfs_create_file("stats", 0400, gbl_ctx.dentry, NULL, &nss_nldtls_stats_ops)) { ++ nss_nl_info_always("Cannot create nldtls dentry file\n"); ++ goto free_debugfs; ++ } ++ + return true; ++ ++free_debugfs: ++ debugfs_remove_recursive(gbl_ctx.dentry); ++free_family: ++ genl_unregister_family(&nss_nldtls_family); ++ ++ return false; + } + + /* +@@ -1128,7 +1184,7 @@ bool nss_nldtls_init(void) + bool nss_nldtls_exit(void) + { + struct nss_nldtls_tun_ctx *entry, *tmp; +- struct net_device *dtls_ndev; ++ struct net_device *dev; + int err; + + nss_nl_info_always("Exit NSS netlink dtls handler\n"); +@@ -1137,9 +1193,10 @@ bool nss_nldtls_exit(void) + * Destroy all active tunnel before exiting + */ + list_for_each_entry_safe(entry, tmp, &gbl_ctx.dtls_list_head, list) { +- dtls_ndev = dev_get_by_name(&init_net, entry->dev_name); +- if (dtls_ndev) { +- nss_nldtls_destroy_tun(dtls_ndev); ++ dev = dev_get_by_name(&init_net, entry->dev_name); ++ if (dev) { ++ dev_put(dev); ++ nss_nldtls_destroy_tun(dev); + } + } + +--- a/netlink/nss_nldtls.h ++++ b/netlink/nss_nldtls.h +@@ -27,6 +27,27 @@ + #define NSS_NLDTLS_VLAN_INVALID 0xFFF + #define NSS_NLDTLS_IP_VERS_4 4 + #define NSS_NLDTLS_DUMMY_DATA 0xcc ++#define NSS_NLDTLS_STATS_MAX_ROW 23 ++#define NSS_NLDTLS_STATS_MAX_STR_LEN 35 ++ ++#define NSS_NLDTLS_CTYPE_MAX 4 ++#define NSS_NLDTLS_CTYPE_BASE NSS_DTLSMGR_METADATA_CTYPE_CCS ++#define NSS_NLDTLS_CTYPE_TO_IDX(ctype) ((ctype) - NSS_NLDTLS_CTYPE_BASE) ++ ++#define NSS_NLDTLS_CCS_PKT_SZ 1 ++#define NSS_NLDTLS_ALERT_PKT_SZ 2 ++#define NSS_NLDTLS_HANDSHAKE_PKT_SZ 56 ++ ++/* ++ * nss_dtls_stats ++ * netlink DTLS TX and RX statistics ++ */ ++struct nss_nldtls_stats { ++ uint64_t rx_pkts; ++ uint64_t rx_bytes; ++ uint64_t tx_pkts; ++ uint64_t tx_bytes; ++}; + + /* + * nss_nldtls_tun_ctx +@@ -36,6 +57,8 @@ struct nss_nldtls_tun_ctx { + struct list_head list; /**< List for holding different tunnel info */ + struct nss_nldtls_rule *nl_rule; /**< Dtls rule structure */ + char dev_name[IFNAMSIZ]; /**< Dtls session netdev */ ++ struct nss_nldtls_stats stats[NSS_NLDTLS_CTYPE_MAX]; ++ /**< Dtls stats */ + }; + + /* +@@ -51,6 +74,7 @@ struct nss_nldtls_gbl_ctx { + ktime_t first_tx_pkt_time; + ktime_t last_rx_pkt_time; + ktime_t last_tx_pkt_time; ++ struct dentry *dentry; + }; + + #if (CONFIG_NSS_NLDTLS == 1) +--- a/netlink/nss_nldynamic_interface.c ++++ b/netlink/nss_nldynamic_interface.c +@@ -46,20 +46,6 @@ static int nss_nldynamic_interface_ops_g + static int nss_nldynamic_interface_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * dynamic interface family definition +- */ +-static struct genl_family nss_nldynamic_interface_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLDYNAMIC_INTERFACE_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_dynamic_interface_notification), /* NSS NETLINK dynamic interface information */ +- .version = NSS_NL_VER, /* Set it to NSS_NLDYNAMIC_INTERFACE version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nldynamic_interface_mcgrp[] = { +@@ -74,6 +60,26 @@ static struct genl_ops nss_nldynamic_int + }; + + /* ++ * dynamic interface family definition ++ */ ++static struct genl_family nss_nldynamic_interface_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLDYNAMIC_INTERFACE_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_dynamic_interface_notification), /* NSS NETLINK dynamic interface information */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLDYNAMIC_INTERFACE version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nldynamic_interface_ops, ++ .n_ops = ARRAY_SIZE(nss_nldynamic_interface_ops), ++ .mcgrps = nss_nldynamic_interface_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nldynamic_interface_mcgrp) ++}; ++ ++/* + * destroy interface call back handler for dynamic interface from NSS + */ + static struct notifier_block nss_dynamic_interface_stats_notifier_nb = { +@@ -125,7 +131,7 @@ bool nss_nldynamic_interface_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nldynamic_interface_family, nss_nldynamic_interface_ops, nss_nldynamic_interface_mcgrp); ++ error = genl_register_family(&nss_nldynamic_interface_family); + if (error) { + nss_nl_info_always("Error: unable to register dynamic_interface family\n"); + return false; +--- a/netlink/nss_nledma.c ++++ b/netlink/nss_nledma.c +@@ -45,20 +45,6 @@ static int nss_nledma_ops_get_stats(stru + static int nss_nledma_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * Edma family definition +- */ +-static struct genl_family nss_nledma_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLEDMA_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_nledma_stats), /* NSS NETLINK Edma stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLEDMA version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nledma_mcgrp[] = { +@@ -73,6 +59,26 @@ static struct genl_ops nss_nledma_ops[] + }; + + /* ++ * Edma family definition ++ */ ++static struct genl_family nss_nledma_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLEDMA_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_nledma_stats), /* NSS NETLINK Edma stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLEDMA version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nledma_ops, ++ .n_ops = ARRAY_SIZE(nss_nledma_ops), ++ .mcgrps = nss_nledma_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nledma_mcgrp) ++}; ++ ++/* + * statistics call back handler for edma from NSS + */ + static struct notifier_block nss_edma_stats_notifier_nb = { +@@ -130,7 +136,7 @@ bool nss_nledma_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nledma_family, nss_nledma_ops, nss_nledma_mcgrp); ++ error = genl_register_family(&nss_nledma_family); + if (error) { + nss_nl_info_always("Error: unable to register Edma family\n"); + return false; +--- a/netlink/nss_nlethrx.c ++++ b/netlink/nss_nlethrx.c +@@ -46,20 +46,6 @@ static int nss_nlethrx_ops_get_stats(str + static int nss_nlethrx_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * eth_rx family definition +- */ +-static struct genl_family nss_nlethrx_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLETHRX_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_eth_rx_stats_notification), /* NSS NETLINK eth_rx rule */ +- .version = NSS_NL_VER, /* Set it to NSS_NLETHRX version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nlethrx_mcgrp[] = { +@@ -74,6 +60,26 @@ static struct genl_ops nss_nlethrx_ops[] + }; + + /* ++ * eth_rx family definition ++ */ ++static struct genl_family nss_nlethrx_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLETHRX_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_eth_rx_stats_notification), /* NSS NETLINK eth_rx rule */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLETHRX version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nlethrx_ops, ++ .n_ops = ARRAY_SIZE(nss_nlethrx_ops), ++ .mcgrps = nss_nlethrx_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlethrx_mcgrp) ++}; ++ ++/* + * statistics call back handler for eth_rx from NSS + */ + static struct notifier_block nss_eth_rx_stats_notifier_nb = { +@@ -125,7 +131,7 @@ bool nss_nlethrx_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nlethrx_family, nss_nlethrx_ops, nss_nlethrx_mcgrp); ++ error = genl_register_family(&nss_nlethrx_family); + if (error) { + nss_nl_info_always("Error: unable to register eth_rx family\n"); + return false; +--- a/netlink/nss_nlgre_redir_cmd.c ++++ b/netlink/nss_nlgre_redir_cmd.c +@@ -43,11 +43,46 @@ static DEFINE_SPINLOCK(lock); + static enum nss_nlgre_redir_cmd_deploy_mode deploy_mode; + + /* ++ * prototypes ++ */ ++static int nss_nlgre_redir_cmd_ops_tun_create(struct sk_buff *skb, struct genl_info *info); ++static int nss_nlgre_redir_cmd_ops_tun_destroy(struct sk_buff *skb, struct genl_info *info); ++static int nss_nlgre_redir_cmd_ops_map(struct sk_buff *skb, struct genl_info *info); ++static int nss_nlgre_redir_cmd_ops_unmap(struct sk_buff *skb, struct genl_info *info); ++static int nss_nlgre_redir_cmd_ops_set_next(struct sk_buff *skb, struct genl_info *info); ++static int nss_nlgre_redir_cmd_ops_add_hash(struct sk_buff *skb, struct genl_info *info); ++static int nss_nlgre_redir_cmd_ops_del_hash(struct sk_buff *skb, struct genl_info *info); ++ ++/* ++ * nss_nlgre_redir_cmd_mcgrp ++ * Multicast group for sending message status & events ++ */ ++static const struct genl_multicast_group nss_nlgre_redir_family_mcgrp[] = { ++ {.name = NSS_NLGRE_REDIR_MCAST_GRP}, ++}; ++ ++/* ++ * nss_nlgre_redir_ops ++ * Operation table called by the generic netlink layer based on the command ++ */ ++static struct genl_ops nss_nlgre_redir_ops[] = { ++ {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_CREATE_TUN, .doit = nss_nlgre_redir_cmd_ops_tun_create,}, ++ {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_DESTROY_TUN, .doit = nss_nlgre_redir_cmd_ops_tun_destroy,}, ++ {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_MAP, .doit = nss_nlgre_redir_cmd_ops_map,}, ++ {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_UNMAP, .doit = nss_nlgre_redir_cmd_ops_unmap,}, ++ {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_SET_NEXT_HOP, .doit = nss_nlgre_redir_cmd_ops_set_next,}, ++ {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_ADD_HASH, .doit = nss_nlgre_redir_cmd_ops_add_hash,}, ++ {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_DEL_HASH, .doit = nss_nlgre_redir_cmd_ops_del_hash,}, ++}; ++ ++/* + * nss_nlgre_redir_cmd_family + * Gre_redir family definition + */ + struct genl_family nss_nlgre_redir_cmd_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) + .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif + .name = NSS_NLGRE_REDIR_FAMILY, /* family name string */ + .hdrsize = sizeof(struct nss_nlgre_redir_rule), /* NSS NETLINK gre_redir rule */ + .version = NSS_NL_VER, /* Set it to NSS_NLGRE_REDIR version */ +@@ -55,6 +90,10 @@ struct genl_family nss_nlgre_redir_cmd_f + .netnsok = true, + .pre_doit = NULL, + .post_doit = NULL, ++ .ops = nss_nlgre_redir_ops, ++ .n_ops = ARRAY_SIZE(nss_nlgre_redir_ops), ++ .mcgrps = nss_nlgre_redir_family_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlgre_redir_family_mcgrp) + }; + + /* +@@ -134,7 +173,7 @@ done: + } + + /* +- * nss_nlgre_redir_cmd_ops_destroy_tun() ++ * nss_nlgre_redir_cmd_ops_tun_destroy() + * Handler to destroy tunnel + */ + static int nss_nlgre_redir_cmd_ops_tun_destroy(struct sk_buff *skb, struct genl_info *info) +@@ -287,7 +326,7 @@ static int nss_nlgre_redir_cmd_ops_unmap + } + + /* +- * nss_nlgre_redir_cmd_set_next() ++ * nss_nlgre_redir_cmd_ops_set_next() + * Handler for set_next command + */ + static int nss_nlgre_redir_cmd_ops_set_next(struct sk_buff *skb, struct genl_info *info) +@@ -340,7 +379,7 @@ done: + } + + /* +- * nss_nlgre_redir_cmd_add_hash() ++ * nss_nlgre_redir_cmd_ops_add_hash() + * Handler for adding hash a value + */ + static int nss_nlgre_redir_cmd_ops_add_hash(struct sk_buff *skb, struct genl_info *info) +@@ -373,7 +412,7 @@ static int nss_nlgre_redir_cmd_ops_add_h + } + + /* +- * nss_nlgre_redir_cmd_del_hash() ++ * nss_nlgre_redir_cmd_ops_del_hash() + * Handler for deleting a hash value + */ + static int nss_nlgre_redir_cmd_ops_del_hash(struct sk_buff *skb, struct genl_info *info) +@@ -410,20 +449,6 @@ static int nss_nlgre_redir_cmd_ops_del_h + } + + /* +- * nss_nlgre_redir_cmd_ops +- * Operation table called by the generic netlink layer based on the command +- */ +-struct genl_ops nss_nlgre_redir_cmd_ops[] = { +- {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_CREATE_TUN, .doit = nss_nlgre_redir_cmd_ops_tun_create,}, +- {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_DESTROY_TUN, .doit = nss_nlgre_redir_cmd_ops_tun_destroy,}, +- {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_MAP, .doit = nss_nlgre_redir_cmd_ops_map,}, +- {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_UNMAP, .doit = nss_nlgre_redir_cmd_ops_unmap,}, +- {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_SET_NEXT_HOP, .doit = nss_nlgre_redir_cmd_ops_set_next,}, +- {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_ADD_HASH, .doit = nss_nlgre_redir_cmd_ops_add_hash,}, +- {.cmd = NSS_NLGRE_REDIR_CMD_TYPE_DEL_HASH, .doit = nss_nlgre_redir_cmd_ops_del_hash,}, +-}; +- +-/* + * nss_nlgre_redir_cmd_get_ifnum() + * Get the interface number corresponding to netdev + */ +--- a/netlink/nss_nlgre_redir_cmd.h ++++ b/netlink/nss_nlgre_redir_cmd.h +@@ -38,11 +38,6 @@ enum nss_nlgre_redir_cmd_deploy_mode { + extern struct genl_family nss_nlgre_redir_cmd_family; + + /* +- * Gre_redir generic netlink operations +- */ +-extern struct genl_ops nss_nlgre_redir_cmd_ops[NSS_NLGRE_REDIR_CMD_MAX]; +- +-/* + * nss_nlgre_redir_cmd_get_ifnum() + * Get the interface number corresponding to netdev + */ --- a/netlink/nss_nlgre_redir_cmn.c +++ b/netlink/nss_nlgre_redir_cmn.c +@@ -354,6 +354,24 @@ static struct rtnl_link_stats64 *nss_nlg + } + + /* ++ * nss_nlgre_redir_cmn_dev_stats64 ++ * Report packet statistics to linux ++ */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) ++static struct rtnl_link_stats64 *nss_nlgre_redir_cmn_dev_stats64(struct net_device *dev, ++ struct rtnl_link_stats64 *stats) ++{ ++ return nss_nlgre_redir_cmn_get_stats64(dev, stats); ++} ++#else ++static void nss_nlgre_redir_cmn_dev_stats64(struct net_device *dev, ++ struct rtnl_link_stats64 *stats) ++{ ++ nss_nlgre_redir_cmn_get_stats64(dev, stats); ++} ++#endif ++ ++/* + * nss_nlgre_redir_cmn_set_mac_address() + * Sets the mac address of netdev + */ +@@ -389,7 +407,11 @@ static void nss_nlgre_redir_cmn_dev_setu + ether_setup(dev); + dev->needed_headroom = NSS_NLGRE_REDIR_CMN_NEEDED_HEADROOM; + dev->netdev_ops = &gre_redir_netdev_ops; ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) + dev->destructor = nss_nlgre_redir_cmn_netdev_destructor; ++#else ++ dev->priv_destructor = nss_nlgre_redir_cmn_netdev_destructor; ++#endif + eth_hw_addr_random(dev); + } + +@@ -401,7 +423,7 @@ static const struct net_device_ops gre_r + .ndo_open = nss_nlgre_redir_cmn_open_interface, + .ndo_stop = nss_nlgre_redir_cmn_close_interface, + .ndo_start_xmit = nss_nlgre_redir_cmn_xmit_data, +- .ndo_get_stats64 = nss_nlgre_redir_cmn_get_stats64, ++ .ndo_get_stats64 = nss_nlgre_redir_cmn_dev_stats64, + .ndo_set_mac_address = nss_nlgre_redir_cmn_set_mac_address, + }; + +--- a/netlink/nss_nlgre_redir_family.c ++++ b/netlink/nss_nlgre_redir_family.c @@ -1,6 +1,6 @@ /* - *************************************************************************** -- * Copyright (c) 2015-2016, 2018-2021, The Linux Foundation. All rights reserved. + ************************************************************************** +- * Copyright (c) 2015-2016,2018-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2016,2018-2020, 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. -@@ -325,7 +325,7 @@ static struct rtnl_link_stats64 *nss_nlg - int i; +@@ -28,14 +28,6 @@ + #include "nss_nlgre_redir_cmd.h" - for (i = 0; i < NSS_GRE_REDIR_MAX_INTERFACES; i++) { -- if (!nss_gre_redir_stats_get(i, &get_stats)) { -+ if (!nss_gre_redir_get_stats(i, &get_stats)) { - continue; - } - -@@ -340,15 +340,15 @@ static struct rtnl_link_stats64 *nss_nlg - if (found == false) - return NULL; - -- stats->tx_bytes = get_stats.tstats.tx_bytes; -- stats->tx_packets = get_stats.tstats.tx_packets; -- stats->rx_bytes = get_stats.tstats.rx_bytes; -- stats->rx_packets = get_stats.tstats.rx_packets; -- for (i = 0;i < ARRAY_SIZE(get_stats.tstats.rx_dropped); i++) { -- stats->rx_dropped += get_stats.tstats.rx_dropped[i]; -+ stats->tx_bytes = get_stats.node_stats.tx_bytes; -+ stats->tx_packets = get_stats.node_stats.tx_packets; -+ stats->rx_bytes = get_stats.node_stats.rx_bytes; -+ stats->rx_packets = get_stats.node_stats.rx_packets; -+ for (i = 0;i < ARRAY_SIZE(get_stats.node_stats.rx_dropped); i++) { -+ stats->rx_dropped += get_stats.node_stats.rx_dropped[i]; - } - -- stats->tx_dropped = get_stats.tstats.tx_dropped; -+ stats->tx_dropped = get_stats.tx_dropped; - - return stats; - } + /* +- * nss_nlgre_redir_cmd_mcgrp +- * Multicast group for sending message status & events +- */ +-static const struct genl_multicast_group nss_nlgre_redir_family_mcgrp[] = { +- {.name = NSS_NLGRE_REDIR_MCAST_GRP}, +-}; +- +-/* + * nss_nlgre_redir_family_init() + * handler init + */ +@@ -47,7 +39,7 @@ bool nss_nlgre_redir_family_init(void) + /* + * register NETLINK ops with the family + */ +- err = genl_register_family_with_ops_groups(&nss_nlgre_redir_cmd_family, nss_nlgre_redir_cmd_ops, nss_nlgre_redir_family_mcgrp); ++ err = genl_register_family(&nss_nlgre_redir_cmd_family); + if (err) { + nss_nl_info_always("Error: %d unable to register gre_redir family\n", err); + return false; --- a/netlink/nss_nlipsec.c +++ b/netlink/nss_nlipsec.c -@@ -1,12 +1,9 @@ - /* - ************************************************************************** -- * Copyright (c) 2015-2016,2018-2021 The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2015-2016,2018-2020 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 -@@ -52,8 +49,8 @@ static int nss_nlipsec_op_create_tunnel( - static int nss_nlipsec_op_destroy_tunnel(struct sk_buff *skb, struct genl_info *info); - static int nss_nlipsec_op_add_sa(struct sk_buff *skb, struct genl_info *info); - static int nss_nlipsec_op_delete_sa(struct sk_buff *skb, struct genl_info *info); --static int nss_nlipsec_op_add_flow(struct sk_buff *skb, struct genl_info *info); --static int nss_nlipsec_op_delete_flow(struct sk_buff *skb, struct genl_info *info); -+// static int nss_nlipsec_op_add_flow(struct sk_buff *skb, struct genl_info *info); -+// static int nss_nlipsec_op_delete_flow(struct sk_buff *skb, struct genl_info *info); +@@ -43,6 +43,16 @@ + #include "nss_nlipv4_if.h" /* ++ * Function prototypes ++ */ ++static int nss_nlipsec_op_create_tunnel(struct sk_buff *skb, struct genl_info *info); ++static int nss_nlipsec_op_destroy_tunnel(struct sk_buff *skb, struct genl_info *info); ++static int nss_nlipsec_op_add_sa(struct sk_buff *skb, struct genl_info *info); ++static int nss_nlipsec_op_delete_sa(struct sk_buff *skb, struct genl_info *info); ++// static int nss_nlipsec_op_add_flow(struct sk_buff *skb, struct genl_info *info); ++// static int nss_nlipsec_op_delete_flow(struct sk_buff *skb, struct genl_info *info); ++ ++/* * Hold netdevice references -@@ -111,14 +108,14 @@ static struct genl_ops nss_nlipsec_ops[] - .cmd = NSS_NLIPSEC_CMD_DEL_SA, - .doit = nss_nlipsec_op_delete_sa, - }, -- { /* Add flow */ -- .cmd = NSS_NLIPSEC_CMD_ADD_FLOW, -- .doit = nss_nlipsec_op_add_flow, -- }, -- { /* Delete flow */ -- .cmd = NSS_NLIPSEC_CMD_DEL_FLOW, -- .doit = nss_nlipsec_op_delete_flow, -- }, + */ + struct nss_nlipsec_ref { +@@ -72,10 +82,49 @@ struct nss_nlipsec_ctx { + static struct nss_nlipsec_ctx gbl_ctx; + + /* ++ * Multicast group for sending message status & events ++ */ ++static const struct genl_multicast_group nss_nlipsec_mcgrp[] = { ++ {.name = NSS_NLIPSEC_MCAST_GRP}, ++}; ++ ++/* ++ * Operation table called by the generic netlink layer based on the command ++ */ ++static struct genl_ops nss_nlipsec_ops[] = { ++ { /* Create tunnel */ ++ .cmd = NSS_NLIPSEC_CMD_ADD_TUNNEL, ++ .doit = nss_nlipsec_op_create_tunnel, ++ }, ++ { /* Destroy tunnel */ ++ .cmd = NSS_NLIPSEC_CMD_DEL_TUNNEL, ++ .doit = nss_nlipsec_op_destroy_tunnel, ++ }, ++ { /* Add Security Association */ ++ .cmd = NSS_NLIPSEC_CMD_ADD_SA, ++ .doit = nss_nlipsec_op_add_sa, ++ }, ++ { /* Delete Security Association */ ++ .cmd = NSS_NLIPSEC_CMD_DEL_SA, ++ .doit = nss_nlipsec_op_delete_sa, ++ }, + // { /* Add flow */ + // .cmd = NSS_NLIPSEC_CMD_ADD_FLOW, + // .doit = nss_nlipsec_op_add_flow, @@ -5419,28 +2152,37 @@ + // .cmd = NSS_NLIPSEC_CMD_DEL_FLOW, + // .doit = nss_nlipsec_op_delete_flow, + // }, ++}; ++ ++/* + * IPsec family definition + */ + static struct genl_family nss_nlipsec_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) + .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif + .name = NSS_NLIPSEC_FAMILY, /* Family name string */ + .hdrsize = sizeof(struct nss_nlipsec_rule),/* NSS NETLINK IPsec rule */ + .version = NSS_NL_VER, /* Set it to NSS_NL version */ +@@ -83,13 +132,10 @@ static struct genl_family nss_nlipsec_fa + .netnsok = true, + .pre_doit = NULL, + .post_doit = NULL, +-}; +- +-/* +- * Multicast group for sending message status & events +- */ +-static const struct genl_multicast_group nss_nlipsec_mcgrp[] = { +- {.name = NSS_NLIPSEC_MCAST_GRP}, ++ .ops = nss_nlipsec_ops, ++ .n_ops = ARRAY_SIZE(nss_nlipsec_ops), ++ .mcgrps = nss_nlipsec_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlipsec_mcgrp) }; /* -@@ -329,7 +326,7 @@ int nss_nlipsec_get_mtu(struct net_devic - static int nss_nlipsec_op_create_tunnel(struct sk_buff *skb, struct genl_info *info) - { - struct nss_nlipsec_rule *nl_rule; -- struct nss_ipsecmgr_callback cb = {0}; -+ struct nss_ipsecmgr_callback cb; - struct nss_nlcmn *nl_cm; - struct net_device *dev; - struct sk_buff *resp; -@@ -511,8 +508,6 @@ static struct nss_nlipsec_rule *nss_nlip - dev_put(*dev); - return NULL; - } -- -- dev_put(*dev); - return nl_rule; - } - -@@ -552,7 +547,7 @@ static int nss_nlipsec_op_add_sa(struct +@@ -501,7 +547,7 @@ static int nss_nlipsec_op_add_sa(struct sa_data->cmn.keys.auth_key = sa_rule->auth_key; sa_data->cmn.keys.nonce = sa_rule->nonce; @@ -5449,7 +2191,7 @@ if (error) { nss_nl_error("%d: Failed to add SA for net device(%s), error:%d\n", pid, nl_rule->ifname, error); goto free_dev; -@@ -630,72 +625,73 @@ static int nss_nlipsec_op_delete_sa(stru +@@ -579,102 +625,73 @@ static int nss_nlipsec_op_delete_sa(stru * nss_nlipsec_op_add_flow() * Add a flow */ @@ -5552,6 +2294,36 @@ - dev_put(dev); - return error; -} +- +-/* +- * Operation table called by the generic netlink layer based on the command +- */ +-static struct genl_ops nss_nlipsec_ops[] = { +- { /* Create tunnel */ +- .cmd = NSS_NLIPSEC_CMD_ADD_TUNNEL, +- .doit = nss_nlipsec_op_create_tunnel, +- }, +- { /* Destroy tunnel */ +- .cmd = NSS_NLIPSEC_CMD_DEL_TUNNEL, +- .doit = nss_nlipsec_op_destroy_tunnel, +- }, +- { /* Add Security Association */ +- .cmd = NSS_NLIPSEC_CMD_ADD_SA, +- .doit = nss_nlipsec_op_add_sa, +- }, +- { /* Delete Security Association */ +- .cmd = NSS_NLIPSEC_CMD_DEL_SA, +- .doit = nss_nlipsec_op_delete_sa, +- }, +- { /* Add flow */ +- .cmd = NSS_NLIPSEC_CMD_ADD_FLOW, +- .doit = nss_nlipsec_op_add_flow, +- }, +- { /* Delete flow */ +- .cmd = NSS_NLIPSEC_CMD_DEL_FLOW, +- .doit = nss_nlipsec_op_delete_flow, +- }, +-}; +// static int nss_nlipsec_op_delete_flow(struct sk_buff *skb, struct genl_info *info) +// { +// struct nss_ipsecmgr_flow_tuple *flow_tuple; @@ -5584,9 +2356,66 @@ /* * nss_nlipsec_init() +@@ -700,7 +717,7 @@ bool nss_nlipsec_init(void) + /* + * Register with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nlipsec_family, nss_nlipsec_ops, nss_nlipsec_mcgrp); ++ error = genl_register_family(&nss_nlipsec_family); + if (error != 0) { + nss_nl_info_always("Error: unable to register IPsec family\n"); + return false; --- a/netlink/nss_nlipv4.c +++ b/netlink/nss_nlipv4.c -@@ -336,20 +336,6 @@ static int nss_nlipv4_verify_conn_rule(s +@@ -71,20 +71,6 @@ static int nss_nlipv4_ops_destroy_rule(s + static int nss_nlipv4_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * IPv4 family definition +- */ +-static struct genl_family nss_nlipv4_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLIPV4_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_nlipv4_rule), /* NSS NETLINK IPv4 rule */ +- .version = NSS_NL_VER, /* Set it to NSS_NLIPv4 version */ +- .maxattr = NSS_IPV4_MAX_MSG_TYPES, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nlipv4_mcgrp[] = { +@@ -100,6 +86,26 @@ static struct genl_ops nss_nlipv4_ops[] + }; + + /* ++ * IPv4 family definition ++ */ ++static struct genl_family nss_nlipv4_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLIPV4_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_nlipv4_rule), /* NSS NETLINK IPv4 rule */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLIPv4 version */ ++ .maxattr = NSS_IPV4_MAX_MSG_TYPES, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nlipv4_ops, ++ .n_ops = ARRAY_SIZE(nss_nlipv4_ops), ++ .mcgrps = nss_nlipv4_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlipv4_mcgrp) ++}; ++ ++/* + * statistics call back handler for ipv4 from NSS + */ + static struct notifier_block nss_ipv4_stats_notifier_nb = { +@@ -330,20 +336,6 @@ static int nss_nlipv4_verify_conn_rule(s tuple->return_ident, tuple->flow_ident); break; @@ -5607,7 +2436,7 @@ case NSS_NL_IFTYPE_VLAN: conn->flow_interface_num = nss_cmn_get_interface_number_by_dev(vlan_dev_real_dev(flow_dev)); if (conn->flow_interface_num < 0 ) { -@@ -396,17 +382,6 @@ static int nss_nlipv4_verify_conn_rule(s +@@ -390,17 +382,6 @@ static int nss_nlipv4_verify_conn_rule(s tuple->return_ident, tuple->flow_ident); break; @@ -5625,75 +2454,137 @@ case NSS_NL_IFTYPE_VLAN: conn->return_interface_num = nss_cmn_get_interface_number_by_dev(vlan_dev_real_dev(return_dev)); if (conn->return_interface_num < 0 ) { -@@ -623,27 +598,6 @@ static int nss_nlipv4_verify_vlan_rule(s - } +@@ -915,7 +896,7 @@ bool nss_nlipv4_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nlipv4_family, nss_nlipv4_ops, nss_nlipv4_mcgrp); ++ error = genl_register_family(&nss_nlipv4_family); + if (error != 0) { + nss_nl_info_always("Error: unable to register IPv4 family\n"); + return false; +--- a/netlink/nss_nlipv4_reasm.c ++++ b/netlink/nss_nlipv4_reasm.c +@@ -46,20 +46,6 @@ static int nss_nlipv4_reasm_ops_get_stat + static int nss_nlipv4_reasm_process_notify(struct notifier_block *nb, unsigned long val, void *data); /* -- * nss_nlipv4_verify_identifier() -- * verify and override identifier rule entries +- * ipv4_reasm family definition - */ --static int nss_nlipv4_verify_identifier(struct nss_ipv4_rule_create_msg *msg) --{ -- struct nss_ipv4_identifier_rule *identifier = &msg->identifier; -- const size_t rule_sz = sizeof(struct nss_ipv4_identifier_rule); -- uint16_t valid; -- -- /* -- * if identifier is not valid, set identifier rule to 0 -- */ -- valid = msg->valid_flags & NSS_IPV4_RULE_CREATE_IDENTIFIER_VALID; -- if (!valid) { -- memset(identifier, 0, rule_sz); -- } -- -- return 0; --} +-static struct genl_family nss_nlipv4_reasm_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLIPV4_REASM_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_ipv4_reasm_stats_notification), /* NSS NETLINK ipv4_reasm stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLIPV4_REASM version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; - -/* - * nss_nlipv4_process_notify() - * process notification messages from NSS + * multicast group for sending message status & events */ -@@ -823,15 +777,6 @@ static int nss_nlipv4_ops_create_rule(st - } + static const struct genl_multicast_group nss_nlipv4_reasm_mcgrp[] = { +@@ -74,6 +60,26 @@ static struct genl_ops nss_nlipv4_reasm_ + }; + /* ++ * ipv4_reasm family definition ++ */ ++static struct genl_family nss_nlipv4_reasm_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLIPV4_REASM_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_ipv4_reasm_stats_notification), /* NSS NETLINK ipv4_reasm stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLIPV4_REASM version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nlipv4_reasm_ops, ++ .n_ops = ARRAY_SIZE(nss_nlipv4_reasm_ops), ++ .mcgrps = nss_nlipv4_reasm_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlipv4_reasm_mcgrp) ++}; ++ ++/* + * stats call back handler for ipv4_reasm from NSS + */ + static struct notifier_block nss_ipv4_reasm_stats_notifier_nb = { +@@ -125,7 +131,7 @@ bool nss_nlipv4_reasm_init(void) /* -- * check identifier -- */ -- error = nss_nlipv4_verify_identifier(&nim->msg.rule_create); -- if (error < 0) { -- nss_nl_error("%d:invalid identifier rule information passed\n", pid); -- goto done; -- } -- -- /* - * copy the NL message for response + * register NETLINK ops with the family */ - resp = nss_nl_copy_msg(skb); -@@ -855,10 +800,6 @@ static int nss_nlipv4_ops_create_rule(st - * Push Rule to NSS - */ - tx_status = nss_ipv4_tx_sync(gbl_ctx.nss, nim); -- -- /* TODO: Handle the case where firmware has received the response -- * and there is a failure in firmware. -- */ - if (tx_status != NSS_TX_SUCCESS) { - nss_nl_error("%d:unable to send IPv4 rule create, status(%d)\n", pid, tx_status); - error = -EBUSY; -@@ -933,10 +874,6 @@ static int nss_nlipv4_ops_destroy_rule(s - * Push rule to NSS - */ - tx_status = nss_ipv4_tx_sync(gbl_ctx.nss, nim); -- -- /* TODO: Handle the case where firmware has received the response -- * and there is a failure in firmware. -- */ - if (tx_status != NSS_TX_SUCCESS) { - nss_nl_error("%d:unable to send IPv4 rule delete, status(%d)\n", pid, tx_status); - return -EBUSY; +- error = genl_register_family_with_ops_groups(&nss_nlipv4_reasm_family, nss_nlipv4_reasm_ops, nss_nlipv4_reasm_mcgrp); ++ error = genl_register_family(&nss_nlipv4_reasm_family); + if (error) { + nss_nl_info_always("Error: unable to register ipv4_reasm family\n"); + return false; --- a/netlink/nss_nlipv6.c +++ b/netlink/nss_nlipv6.c -@@ -353,17 +353,6 @@ static int nss_nlipv6_verify_conn_rule(s +@@ -79,20 +79,6 @@ static int nss_nlipv6_ops_destroy_rule(s + static int nss_nlipv6_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * IPV6 family definition +- */ +-static struct genl_family nss_nlipv6_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLIPV6_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_nlipv6_rule), /* NSS NETLINK IPV6 rule */ +- .version = NSS_NL_VER, /* Set it to NSS_NLIPV6 version */ +- .maxattr = NSS_IPV6_MAX_MSG_TYPES, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static struct genl_multicast_group nss_nlipv6_mcgrp[] = { +@@ -108,6 +94,26 @@ static struct genl_ops nss_nlipv6_ops[] + }; + + /* ++ * IPV6 family definition ++ */ ++static struct genl_family nss_nlipv6_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLIPV6_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_nlipv6_rule), /* NSS NETLINK IPV6 rule */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLIPV6 version */ ++ .maxattr = NSS_IPV6_MAX_MSG_TYPES, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nlipv6_ops, ++ .n_ops = ARRAY_SIZE(nss_nlipv6_ops), ++ .mcgrps = nss_nlipv6_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlipv6_mcgrp) ++}; ++ ++/* + * statistics call back handler for ipv6 from NSS + */ + static struct notifier_block nss_ipv6_stats_notifier_nb = { +@@ -131,7 +137,11 @@ static struct neighbour *nss_nlipv6_get_ + + IPV6_ADDR_TO_IN6_ADDR(daddr, dst_addr); + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0)) + rt = rt6_lookup(&init_net, &daddr, NULL, 0, 0); ++#else ++ rt = rt6_lookup(&init_net, &daddr, NULL, 0, NULL, 0); ++#endif + if (!rt) { + return NULL; + } +@@ -343,17 +353,6 @@ static int nss_nlipv6_verify_conn_rule(s tuple->return_ident, tuple->flow_ident); break; @@ -5711,7 +2602,7 @@ case NSS_NL_IFTYPE_VLAN: conn->flow_interface_num = nss_cmn_get_interface_number_by_dev(vlan_dev_real_dev(flow_dev)); if (conn->flow_interface_num < 0 ) { -@@ -411,17 +400,6 @@ static int nss_nlipv6_verify_conn_rule(s +@@ -401,17 +400,6 @@ static int nss_nlipv6_verify_conn_rule(s tuple->return_ident, tuple->flow_ident); break; @@ -5729,708 +2620,1333 @@ case NSS_NL_IFTYPE_VLAN: conn->return_interface_num = nss_cmn_get_interface_number_by_dev(vlan_dev_real_dev(return_dev)); if (conn->return_interface_num < 0 ) { -@@ -624,27 +602,6 @@ static int nss_nlipv6_verify_vlan_rule(s - } +@@ -916,7 +904,7 @@ bool nss_nlipv6_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nlipv6_family, nss_nlipv6_ops, nss_nlipv6_mcgrp); ++ error = genl_register_family(&nss_nlipv6_family); + if (error != 0) { + nss_nl_info_always("Error: unable to register IPV6 family\n"); + return false; +--- a/netlink/nss_nlipv6_reasm.c ++++ b/netlink/nss_nlipv6_reasm.c +@@ -46,20 +46,6 @@ static int nss_nlipv6_reasm_ops_get_stat + static int nss_nlipv6_reasm_process_notify(struct notifier_block *nb, unsigned long val, void *data); /* -- * nss_nlipv6_verify_identifier() -- * verify and override identifier rule entries +- * ipv6_reasm family definition - */ --static int nss_nlipv6_verify_identifier(struct nss_ipv6_rule_create_msg *msg) --{ -- struct nss_ipv6_identifier_rule *identifier = &msg->identifier; -- const size_t rule_sz = sizeof(struct nss_ipv6_identifier_rule); -- uint16_t valid; -- -- /* -- * if identifier is not valid, set identifier rule to 0 -- */ -- valid = msg->valid_flags & NSS_IPV6_RULE_CREATE_IDENTIFIER_VALID; -- if (!valid) { -- memset(identifier, 0, rule_sz); -- } -- -- return 0; --} +-static struct genl_family nss_nlipv6_reasm_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLIPV6_REASM_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_ipv6_reasm_stats_notification), /* NSS NETLINK ipv6_reasm stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLIPV6_REASM version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; - -/* - * nss_nlipv6_process_notify() - * process notification messages from NSS + * multicast group for sending message status & events */ -@@ -817,15 +774,6 @@ static int nss_nlipv6_ops_create_rule(st - } + static const struct genl_multicast_group nss_nlipv6_reasm_mcgrp[] = { +@@ -74,6 +60,26 @@ static struct genl_ops nss_nlipv6_reasm_ + }; + /* ++ * ipv6_reasm family definition ++ */ ++static struct genl_family nss_nlipv6_reasm_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLIPV6_REASM_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_ipv6_reasm_stats_notification), /* NSS NETLINK ipv6_reasm stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLIPV6_REASM version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nlipv6_reasm_ops, ++ .n_ops = ARRAY_SIZE(nss_nlipv6_reasm_ops), ++ .mcgrps = nss_nlipv6_reasm_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlipv6_reasm_mcgrp) ++}; ++ ++/* + * stats call back handler for ipv6_reasm from NSS + */ + static struct notifier_block nss_ipv6_reasm_stats_notifier_nb = { +@@ -125,7 +131,7 @@ bool nss_nlipv6_reasm_init(void) /* -- * check identifier -- */ -- error = nss_nlipv6_verify_identifier(&nim->msg.rule_create); -- if (error < 0) { -- nss_nl_error("%d:invalid identifier rule information passed\n", pid); -- goto done; -- } -- -- /* - * copy the NL message for response + * register NETLINK ops with the family */ - resp = nss_nl_copy_msg(skb); -@@ -855,10 +803,6 @@ static int nss_nlipv6_ops_create_rule(st - * Push Rule to NSS - */ - tx_status = nss_ipv6_tx_sync(gbl_ctx.nss, nim); +- error = genl_register_family_with_ops_groups(&nss_nlipv6_reasm_family, nss_nlipv6_reasm_ops, nss_nlipv6_reasm_mcgrp); ++ error = genl_register_family(&nss_nlipv6_reasm_family); + if (error) { + nss_nl_info_always("Error: unable to register ipv6_reasm family\n"); + return false; +--- a/netlink/nss_nll2tpv2.c ++++ b/netlink/nss_nll2tpv2.c +@@ -47,20 +47,6 @@ static int nss_nll2tpv2_ops_get_stats(st + static int nss_nll2tpv2_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * l2tpv2 family definition +- */ +-static struct genl_family nss_nll2tpv2_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLL2TPV2_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_l2tpv2_stats_notification), /* NSS NETLINK l2tpv2 stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLL2TPV2 version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; - -- /* TODO: Handle the case where firmware has received the response -- * and there is a failure in firmware. -- */ - if (tx_status != NSS_TX_SUCCESS) { - nss_nl_error("%d:unable to send IPV6 rule create, status(%d)\n", pid, tx_status); - error = -EBUSY; -@@ -938,10 +882,6 @@ static int nss_nlipv6_ops_destroy_rule(s - * Push rule to NSS - */ - tx_status = nss_ipv6_tx_sync(gbl_ctx.nss, nim); -- -- /* TODO: Handle the case where firmware has received the response -- * and there is a failure in firmware. -- */ - if (tx_status != NSS_TX_SUCCESS) { - nss_nl_error("%d:unable to send IPV6 rule delete, status(%d)\n", pid, tx_status); - return -EBUSY; ---- /dev/null -+++ b/nss_connmgr_tunipip6.c -@@ -0,0 +1,503 @@ -+/* -+ ************************************************************************** -+ * Copyright (c) 2014, 2017-2018, 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. -+ ************************************************************************** +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nll2tpv2_mcgrp[] = { +@@ -75,6 +61,26 @@ static struct genl_ops nss_nll2tpv2_ops[ + }; + + /* ++ * l2tpv2 family definition + */ -+ -+/* -+ * nss_tunipip6.c -+ * -+ * This file is the NSS DS-lit and IPP6 tunnel module -+ * ------------------------REVISION HISTORY----------------------------- -+ * Qualcomm Atheros 15/sep/2013 Created -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3,9,0)) -+#include -+#else -+#include ++static struct genl_family nss_nll2tpv2_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ +#endif -+#include -+#include -+#include -+ -+/* -+ * NSS tunipip6 debug macros -+ */ -+#if (NSS_TUNIPIP6_DEBUG_LEVEL < 1) -+#define nss_tunipip6_assert(fmt, args...) -+#else -+#define nss_tunipip6_assert(c) if (!(c)) { BUG_ON(!(c)); } -+#endif -+ -+#if defined(CONFIG_DYNAMIC_DEBUG) -+ -+/* -+ * Compile messages for dynamic enable/disable -+ */ -+#define nss_tunipip6_warning(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) -+#define nss_tunipip6_info(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) -+#define nss_tunipip6_trace(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) -+#else -+ -+/* -+ * Statically compile messages at different levels -+ */ -+#if (NSS_TUNIPIP6_DEBUG_LEVEL < 2) -+#define nss_tunipip6_warning(s, ...) -+#else -+#define nss_tunipip6_warning(s, ...) pr_warn("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) -+#endif -+ -+#if (NSS_TUNIPIP6_DEBUG_LEVEL < 3) -+#define nss_tunipip6_info(s, ...) -+#else -+#define nss_tunipip6_info(s, ...) pr_notice("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) -+#endif -+ -+#if (NSS_TUNIPIP6_DEBUG_LEVEL < 4) -+#define nss_tunipip6_trace(s, ...) -+#else -+#define nss_tunipip6_trace(s, ...) pr_info("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) -+#endif -+#endif -+ -+/* -+ * tunipip6 stats structure -+ */ -+struct nss_tunipip6_stats { -+ uint32_t rx_packets; /* Number of received packets */ -+ uint32_t rx_bytes; /* Number of received bytes */ -+ uint32_t tx_packets; /* Number of transmitted packets */ -+ uint32_t tx_bytes; /* Number of transmitted bytes */ ++ .name = NSS_NLL2TPV2_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_l2tpv2_stats_notification), /* NSS NETLINK l2tpv2 stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLL2TPV2 version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nll2tpv2_ops, ++ .n_ops = ARRAY_SIZE(nss_nll2tpv2_ops), ++ .mcgrps = nss_nll2tpv2_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nll2tpv2_mcgrp) +}; + +/* -+ * nss_tunipip6_encap_exception() -+ * Exception handler registered to NSS driver. -+ * -+ * This function is called when no rule is found for successful encapsulation. + * device call back handler for l2tpv2 from NSS + */ + static struct notifier_block nss_l2tpv2_stats_notifier_nb = { +@@ -126,7 +132,7 @@ bool nss_nll2tpv2_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nll2tpv2_family, nss_nll2tpv2_ops, nss_nll2tpv2_mcgrp); ++ error = genl_register_family(&nss_nll2tpv2_family); + if (error) { + nss_nl_info_always("Error: unable to register l2tpv2 family\n"); + return false; +--- a/netlink/nss_nllso_rx.c ++++ b/netlink/nss_nllso_rx.c +@@ -47,20 +47,6 @@ static int nss_nllso_rx_ops_get_stats(st + static int nss_nllso_rx_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * lso_rx family definition +- */ +-static struct genl_family nss_nllso_rx_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLLSO_RX_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_lso_rx_stats_notification), /* NSS NETLINK lso_rx stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLLSO_RX version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nllso_rx_mcgrp[] = { +@@ -75,6 +61,26 @@ static struct genl_ops nss_nllso_rx_ops[ + }; + + /* ++ * lso_rx family definition + */ -+static void nss_tunipip6_encap_exception(struct net_device *dev, struct sk_buff *skb, __attribute__((unused)) struct napi_struct *napi) -+{ -+ skb->dev = dev; -+ nss_tunipip6_info("received - %d bytes name %s ver %x\n", -+ skb->len, dev->name, (skb->data[0] >> 4)); -+ -+ skb->protocol = htons(ETH_P_IP); -+ skb_reset_network_header(skb); -+ skb->pkt_type = PACKET_HOST; -+ skb->skb_iif = dev->ifindex; -+ skb->ip_summed = CHECKSUM_NONE; -+ netif_receive_skb(skb); -+} -+ -+/* -+ * nss_tunipip6_decap_exception() -+ * Exception handler registered to NSS driver. -+ * -+ * This function is called when no rule is found for successful decapsulation. -+ */ -+static void nss_tunipip6_decap_exception(struct net_device *dev, struct sk_buff *skb, __attribute__((unused)) struct napi_struct *napi) -+{ -+ skb->dev = dev; -+ nss_tunipip6_info("received - %d bytes name %s ver %x\n", -+ skb->len, dev->name, (skb->data[0] >> 4)); -+ -+ skb->protocol = htons(ETH_P_IPV6); -+ skb_reset_network_header(skb); -+ skb->pkt_type = PACKET_HOST; -+ skb->skb_iif = dev->ifindex; -+ skb->ip_summed = CHECKSUM_NONE; -+ netif_receive_skb(skb); -+} -+ -+/* -+ * nss_tunipip6_update_dev_stats -+ * Update the Dev stats received from NetAp -+ */ -+static void nss_tunipip6_update_dev_stats(struct net_device *dev, -+ struct nss_tunipip6_stats_sync_msg *sync_stats) -+{ -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) -+ struct pcpu_sw_netstats stats; -+ -+ u64_stats_init(&stats.syncp); -+ u64_stats_update_begin(&stats.syncp); -+ stats.rx_packets = sync_stats->node_stats.rx_packets; -+ stats.rx_bytes = sync_stats->node_stats.rx_bytes; -+ stats.tx_packets = sync_stats->node_stats.tx_packets; -+ stats.tx_bytes = sync_stats->node_stats.tx_bytes; -+ u64_stats_update_end(&stats.syncp); -+#else -+ struct nss_tunipip6_stats stats; -+ -+ stats.rx_packets = sync_stats->node_stats.rx_packets; -+ stats.rx_bytes = sync_stats->node_stats.rx_bytes; -+ stats.tx_packets = sync_stats->node_stats.tx_packets; -+ stats.tx_bytes = sync_stats->node_stats.tx_bytes; ++static struct genl_family nss_nllso_rx_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ +#endif -+ -+ dev->stats.rx_dropped += nss_cmn_rx_dropped_sum(&sync_stats->node_stats); -+ ip6_update_offload_stats(dev, (void *)&stats); -+ -+} -+ -+/* -+ * nss_tunipip6_event_receive() -+ * Event Callback to receive events from NSS. -+ */ -+void nss_tunipip6_event_receive(void *if_ctx, struct nss_tunipip6_msg *tnlmsg) -+{ -+ struct net_device *netdev = NULL; -+ netdev = (struct net_device *)if_ctx; -+ -+ switch (tnlmsg->cm.type) { -+ case NSS_TUNIPIP6_RX_STATS_SYNC: -+ nss_tunipip6_update_dev_stats(netdev, (struct nss_tunipip6_stats_sync_msg *)&tnlmsg->msg.stats_sync); -+ break; -+ -+ default: -+ nss_tunipip6_info("%s: Unknown Event from NSS", __func__); -+ break; -+ } -+} -+ -+/* -+ * nss_tunipip6_dev_up() -+ * IPIP6 Tunnel device i/f up handler -+ */ -+int nss_tunipip6_dev_up(struct net_device *netdev) -+{ -+ struct ip6_tnl *tunnel; -+ struct nss_tunipip6_msg tnlmsg; -+ struct nss_tunipip6_create_msg *tnlcfg; -+ struct flowi6 *fl6; -+ uint32_t fmr_number = 0; -+ int inner_ifnum, outer_ifnum; -+ uint32_t features = 0; -+ nss_tx_status_t status; -+ struct nss_ctx_instance *nss_ctx; -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) -+ struct __ip6_tnl_fmr *fmr; -+#endif -+ -+ /* -+ * Validate netdev for ipv6-in-ipv4 Tunnel -+ */ -+ if (netdev->type != ARPHRD_TUNNEL6 ) { -+ return NOTIFY_DONE; -+ } -+ -+ tunnel = (struct ip6_tnl *)netdev_priv(netdev); -+ -+ /* -+ * Find the Tunnel device flow information -+ */ -+ fl6 = &tunnel->fl.u.ip6; -+ -+ nss_tunipip6_trace("%p: Tunnel Param srcaddr %x:%x:%x:%x daddr %x:%x:%x:%x\n", netdev, -+ fl6->saddr.s6_addr32[0], fl6->saddr.s6_addr32[1], -+ fl6->saddr.s6_addr32[2], fl6->saddr.s6_addr32[3], -+ fl6->daddr.s6_addr32[0], fl6->daddr.s6_addr32[1], -+ fl6->daddr.s6_addr32[2], fl6->daddr.s6_addr32[3] ); -+ nss_tunipip6_trace("%p: Hop limit %d\n", netdev, tunnel->parms.hop_limit); -+ nss_tunipip6_trace("%p: Tunnel param flag %x fl6.flowlabel %x\n", netdev, tunnel->parms.flags, fl6->flowlabel); -+ -+ inner_ifnum = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_INNER); -+ if (inner_ifnum < 0) { -+ nss_tunipip6_warning("%p: Request interface number failed\n", netdev); -+ goto inner_alloc_fail; -+ } -+ -+ outer_ifnum = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER); -+ if (outer_ifnum < 0) { -+ nss_tunipip6_warning("%p: Request interface number failed\n", netdev); -+ goto outer_alloc_fail; -+ } -+ -+ /* -+ * Register ipip6 tunnel with NSS -+ */ -+ nss_ctx = nss_register_tunipip6_if(inner_ifnum, -+ NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_INNER, -+ nss_tunipip6_encap_exception, -+ nss_tunipip6_event_receive, -+ netdev, -+ features); -+ if (!nss_ctx) { -+ nss_tunipip6_warning("%p: nss_register_tunipip6_if Failed\n", netdev); -+ goto inner_reg_fail; -+ } -+ -+ nss_ctx = nss_register_tunipip6_if(outer_ifnum, -+ NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER, -+ nss_tunipip6_decap_exception, -+ nss_tunipip6_event_receive, -+ netdev, -+ features); -+ if (!nss_ctx) { -+ nss_tunipip6_warning("%p: nss_register_tunipip6_if Failed\n", netdev); -+ goto outer_reg_fail; -+ } -+ -+ nss_tunipip6_trace("%p: nss_register_tunipip6_if Success\n", netdev); -+ -+ /* -+ * Prepare The Tunnel configuration parameter to send to nss -+ */ -+ memset(&tnlmsg, 0, sizeof(struct nss_tunipip6_msg)); -+ tnlcfg = &tnlmsg.msg.tunipip6_create; -+ -+ tnlcfg->saddr[0] = ntohl(fl6->saddr.s6_addr32[0]); -+ tnlcfg->saddr[1] = ntohl(fl6->saddr.s6_addr32[1]); -+ tnlcfg->saddr[2] = ntohl(fl6->saddr.s6_addr32[2]); -+ tnlcfg->saddr[3] = ntohl(fl6->saddr.s6_addr32[3]); -+ tnlcfg->daddr[0] = ntohl(fl6->daddr.s6_addr32[0]); -+ tnlcfg->daddr[1] = ntohl(fl6->daddr.s6_addr32[1]); -+ tnlcfg->daddr[2] = ntohl(fl6->daddr.s6_addr32[2]); -+ tnlcfg->daddr[3] = ntohl(fl6->daddr.s6_addr32[3]); -+ tnlcfg->hop_limit = tunnel->parms.hop_limit; -+ tnlcfg->flags = ntohl(tunnel->parms.flags); -+ -+ /* -+ * Flow Label In kernel is stored in big endian format. -+ */ -+ tnlcfg->flowlabel = fl6->flowlabel; -+ tnlcfg->draft03 = tunnel->parms.draft03; -+ -+ /* -+ * Configure FMR table up to MAX_FMR_NUMBER, the rest will be forwarded to BR -+ */ -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) -+ for (fmr = tunnel->parms.fmrs; fmr && fmr_number < NSS_TUNIPIP6_MAX_FMR_NUMBER; fmr = fmr->next, fmr_number++) { -+ tnlcfg->fmr[fmr_number].ip6_prefix[0] = ntohl(fmr->ip6_prefix.s6_addr32[0]); -+ tnlcfg->fmr[fmr_number].ip6_prefix[1] = ntohl(fmr->ip6_prefix.s6_addr32[1]); -+ tnlcfg->fmr[fmr_number].ip6_prefix[2] = ntohl(fmr->ip6_prefix.s6_addr32[2]); -+ tnlcfg->fmr[fmr_number].ip6_prefix[3] = ntohl(fmr->ip6_prefix.s6_addr32[3]); -+ tnlcfg->fmr[fmr_number].ip4_prefix = ntohl(fmr->ip4_prefix.s_addr); -+ tnlcfg->fmr[fmr_number].ip6_prefix_len = fmr->ip6_prefix_len; -+ tnlcfg->fmr[fmr_number].ip4_prefix_len = fmr->ip4_prefix_len; -+ tnlcfg->fmr[fmr_number].ea_len = fmr->ea_len; -+ tnlcfg->fmr[fmr_number].offset = fmr->offset; -+ } -+#endif -+ tnlcfg->fmr_number = fmr_number; -+ -+ /* -+ * Updating sibling_if_num for encap interface. -+ */ -+ tnlcfg->sibling_if_num = outer_ifnum; -+ -+ nss_tunipip6_trace("%p: Tunnel Param srcaddr %x:%x:%x:%x daddr %x:%x:%x:%x\n", netdev, -+ tnlcfg->saddr[0], tnlcfg->saddr[1], -+ tnlcfg->saddr[2], tnlcfg->saddr[3], -+ tnlcfg->daddr[0], tnlcfg->daddr[1], -+ tnlcfg->daddr[2], tnlcfg->daddr[3] ); -+ -+ /* -+ * Send configure message to encap interface. -+ */ -+ nss_tunipip6_msg_init(&tnlmsg, inner_ifnum, NSS_TUNIPIP6_TX_ENCAP_IF_CREATE, -+ sizeof(struct nss_tunipip6_create_msg), NULL, NULL); -+ -+ nss_tunipip6_trace("%p: Sending IPIP6 tunnel i/f up command to NSS %p\n", netdev, nss_ctx); -+ status = nss_tunipip6_tx(nss_ctx, &tnlmsg); -+ if (status != NSS_TX_SUCCESS) { -+ nss_tunipip6_warning("%p: Tunnel up command error %d\n", netdev, status); -+ goto config_fail; -+ } -+ -+ /* -+ * Updating sibling_if_num for decap interface. -+ */ -+ tnlcfg->sibling_if_num = inner_ifnum; -+ -+ /* -+ * Send configure message to decap interface. -+ */ -+ nss_tunipip6_msg_init(&tnlmsg, outer_ifnum, NSS_TUNIPIP6_TX_DECAP_IF_CREATE, -+ sizeof(struct nss_tunipip6_create_msg), NULL, NULL); -+ -+ nss_tunipip6_trace("%p: Sending IPIP6 tunnel i/f up command to NSS %p\n", netdev, nss_ctx); -+ status = nss_tunipip6_tx(nss_ctx, &tnlmsg); -+ if (status != NSS_TX_SUCCESS) { -+ nss_tunipip6_warning("%p: Tunnel up command error %d\n", netdev, status); -+ goto config_fail; -+ } -+ return NOTIFY_DONE; -+ -+config_fail: -+ nss_unregister_tunipip6_if(outer_ifnum); -+outer_reg_fail: -+ nss_unregister_tunipip6_if(inner_ifnum); -+inner_reg_fail: -+ status = nss_dynamic_interface_dealloc_node(outer_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER); -+ if (status != NSS_TX_SUCCESS) { -+ nss_tunipip6_warning("%p: Unable to dealloc the node[%d] in the NSS fw!\n", netdev, outer_ifnum); -+ } -+outer_alloc_fail: -+ status = nss_dynamic_interface_dealloc_node(inner_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_INNER); -+ if (status != NSS_TX_SUCCESS) { -+ nss_tunipip6_warning("%p: Unable to dealloc the node[%d] in the NSS fw!\n", netdev, inner_ifnum); -+ } -+inner_alloc_fail: -+ return NOTIFY_DONE; -+} -+ -+/* -+ * nss_tunipip6_dev_down() -+ * IPP6 Tunnel device i/f down handler -+ */ -+int nss_tunipip6_dev_down(struct net_device *netdev) -+{ -+ int inner_ifnum, outer_ifnum; -+ nss_tx_status_t status; -+ -+ /* -+ * Validate netdev for ipv6-in-ipv4 Tunnel -+ */ -+ if (netdev->type != ARPHRD_TUNNEL6) { -+ return NOTIFY_DONE; -+ } -+ -+ /* -+ * Check if tunnel ipip6 is registered ? -+ */ -+ inner_ifnum = nss_cmn_get_interface_number_by_dev_and_type(netdev, NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_INNER); -+ if (inner_ifnum < 0) { -+ nss_tunipip6_warning("%p: Net device is not registered with nss\n", netdev); -+ return NOTIFY_DONE; -+ } -+ -+ outer_ifnum = nss_cmn_get_interface_number_by_dev_and_type(netdev, NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER); -+ if (outer_ifnum < 0) { -+ nss_tunipip6_warning("%p: Net device is not registered with nss\n", netdev); -+ return NOTIFY_DONE; -+ } -+ -+ /* -+ * Un-Register IPIP6 tunnel with NSS -+ */ -+ nss_unregister_tunipip6_if(inner_ifnum); -+ nss_unregister_tunipip6_if(outer_ifnum); -+ -+ status = nss_dynamic_interface_dealloc_node(inner_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_INNER); -+ if (status != NSS_TX_SUCCESS) { -+ nss_tunipip6_warning("%p: Dealloc node failure\n", netdev); -+ return NOTIFY_DONE; -+ } -+ -+ status = nss_dynamic_interface_dealloc_node(outer_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER); -+ if (status != NSS_TX_SUCCESS) { -+ nss_tunipip6_warning("%p: Dealloc node failure\n", netdev); -+ return NOTIFY_DONE; -+ } -+ -+ return NOTIFY_DONE; -+} -+ -+/* -+ * nss_tunipip6_dev_event() -+ * Net device notifier for ipip6 module -+ */ -+static int nss_tunipip6_dev_event(struct notifier_block *nb, -+ unsigned long event, void *dev) -+{ -+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 10, 0)) -+ struct net_device *netdev = (struct net_device *)dev; -+#else -+ struct net_device *netdev = netdev_notifier_info_to_dev(dev); -+#endif -+ -+ switch (event) { -+ case NETDEV_UP: -+ nss_tunipip6_trace("%p: NETDEV_UP :event %lu name %s\n", netdev, event, netdev->name); -+ return nss_tunipip6_dev_up(netdev); -+ -+ case NETDEV_DOWN: -+ nss_tunipip6_trace("%p: NETDEV_DOWN :event %lu name %s\n", netdev, event, netdev->name); -+ return nss_tunipip6_dev_down(netdev); -+ -+ default: -+ nss_tunipip6_trace("%p: Unhandled notifier dev %s event %x\n", netdev, netdev->name, (int)event); -+ break; -+ } -+ -+ return NOTIFY_DONE; -+} -+ -+/* -+ * Linux Net device Notifier -+ */ -+struct notifier_block nss_tunipip6_notifier = { -+ .notifier_call = nss_tunipip6_dev_event, ++ .name = NSS_NLLSO_RX_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_lso_rx_stats_notification), /* NSS NETLINK lso_rx stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLLSO_RX version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nllso_rx_ops, ++ .n_ops = ARRAY_SIZE(nss_nllso_rx_ops), ++ .mcgrps = nss_nllso_rx_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nllso_rx_mcgrp) +}; + +/* -+ * nss_tunipip6_init_module() -+ * Tunnel ipip6 module init function + * device call back handler for lso_rx from NSS + */ + static struct notifier_block nss_lso_rx_stats_notifier_nb = { +@@ -126,7 +132,7 @@ bool nss_nllso_rx_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nllso_rx_family, nss_nllso_rx_ops, nss_nllso_rx_mcgrp); ++ error = genl_register_family(&nss_nllso_rx_family); + if (error) { + nss_nl_info_always("Error: unable to register lso_rx family\n"); + return false; +--- a/netlink/nss_nlmap_t.c ++++ b/netlink/nss_nlmap_t.c +@@ -47,20 +47,6 @@ static int nss_nlmap_t_ops_get_stats(str + static int nss_nlmap_t_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * map_t family definition +- */ +-static struct genl_family nss_nlmap_t_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLMAP_T_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_map_t_stats_notification), /* NSS NETLINK map_t stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLMAP_T version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nlmap_t_mcgrp[] = { +@@ -75,6 +61,26 @@ static struct genl_ops nss_nlmap_t_ops[] + }; + + /* ++ * map_t family definition + */ -+int __init nss_tunipip6_init_module(void) -+{ -+#ifdef CONFIG_OF -+ /* -+ * If the node is not compatible, don't do anything. -+ */ -+ if (!of_find_node_by_name(NULL, "nss-common")) { -+ return 0; -+ } ++static struct genl_family nss_nlmap_t_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ +#endif -+ nss_tunipip6_info("module (platform - IPQ806x , %s) loaded\n", -+ NSS_CLIENT_BUILD_ID); -+ -+ register_netdevice_notifier(&nss_tunipip6_notifier); -+ nss_tunipip6_trace("Netdev Notifier registerd\n"); -+ -+ -+ return 0; -+} ++ .name = NSS_NLMAP_T_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_map_t_stats_notification), /* NSS NETLINK map_t stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLMAP_T version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nlmap_t_ops, ++ .n_ops = ARRAY_SIZE(nss_nlmap_t_ops), ++ .mcgrps = nss_nlmap_t_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlmap_t_mcgrp) ++}; + +/* -+ * nss_tunipip6_exit_module() -+ * Tunnel ipip6 module exit function + * device call back handler for map_t from NSS + */ + static struct notifier_block nss_map_t_stats_notifier_nb = { +@@ -126,7 +132,7 @@ bool nss_nlmap_t_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nlmap_t_family, nss_nlmap_t_ops, nss_nlmap_t_mcgrp); ++ error = genl_register_family(&nss_nlmap_t_family); + if (error) { + nss_nl_info_always("Error: unable to register map_t family\n"); + return false; +--- a/netlink/nss_nln2h.c ++++ b/netlink/nss_nln2h.c +@@ -46,20 +46,6 @@ static int nss_nln2h_ops_get_stats(struc + static int nss_nln2h_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * n2h family definition +- */ +-static struct genl_family nss_nln2h_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLN2H_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_n2h_stats_notification), /* NSS NETLINK n2h stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLN2H version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nln2h_mcgrp[] = { +@@ -74,6 +60,26 @@ static struct genl_ops nss_nln2h_ops[] = + }; + + /* ++ * n2h family definition + */ -+void __exit nss_tunipip6_exit_module(void) -+{ -+#ifdef CONFIG_OF -+ -+ /* -+ * If the node is not compatible, don't do anything. -+ */ -+ if (!of_find_node_by_name(NULL, "nss-common")) { -+ return; -+ } ++static struct genl_family nss_nln2h_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ +#endif ++ .name = NSS_NLN2H_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_n2h_stats_notification), /* NSS NETLINK n2h stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLN2H version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nln2h_ops, ++ .n_ops = ARRAY_SIZE(nss_nln2h_ops), ++ .mcgrps = nss_nln2h_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nln2h_mcgrp) ++}; + -+ unregister_netdevice_notifier(&nss_tunipip6_notifier); -+ nss_tunipip6_info("module unloaded\n"); -+} ++/* + * stats call back handler for n2h from NSS + */ + static struct notifier_block nss_n2h_stats_notifier_nb = { +@@ -125,7 +131,7 @@ bool nss_nln2h_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nln2h_family, nss_nln2h_ops, nss_nln2h_mcgrp); ++ error = genl_register_family(&nss_nln2h_family); + if (error) { + nss_nl_info_always("Error: unable to register n2h family\n"); + return false; +--- a/netlink/nss_nloam.c ++++ b/netlink/nss_nloam.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016,2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016,2018, 2020, 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. +@@ -82,11 +82,25 @@ struct nss_nloam_msg_map global_nloam_ms + }, + }; + ++static struct genl_multicast_group nss_nloam_mcgrp[] = { ++ {.name = NSS_NLOAM_MCAST_GRP}, ++}; + -+module_init(nss_tunipip6_init_module); -+module_exit(nss_tunipip6_exit_module); ++/* ++ * operation table called by the generic netlink layer based on the command ++ */ ++static struct genl_ops nss_nloam_ops[] = { ++ {.cmd = NSS_NLOAM_CMD_NONE, .doit = nss_nloam_op_none,}, ++ {.cmd = NSS_NLOAM_CMD_GET_REQ, .doit = nss_nloam_op_get_req,}, ++}; + -+MODULE_LICENSE("Dual BSD/GPL"); -+MODULE_DESCRIPTION("NSS tunipip6 offload manager"); + /* + * OAM family definition + */ + static struct genl_family nss_nloam_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) + .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif + .name = NSS_NLOAM_FAMILY, /* family name string */ + .hdrsize = sizeof(struct nss_nloam_rule), /* NLOAM msg size */ + .version = NSS_NL_VER, /* nss netlink version */ +@@ -94,18 +108,10 @@ static struct genl_family nss_nloam_fami + .netnsok = false, + .pre_doit = NULL, + .post_doit = NULL, +-}; +- +-static struct genl_multicast_group nss_nloam_mcgrp[] = { +- {.name = NSS_NLOAM_MCAST_GRP}, +-}; +- +-/* +- * operation table called by the generic netlink layer based on the command +- */ +-static struct genl_ops nss_nloam_ops[] = { +- {.cmd = NSS_NLOAM_CMD_NONE, .doit = nss_nloam_op_none,}, +- {.cmd = NSS_NLOAM_CMD_GET_REQ, .doit = nss_nloam_op_get_req,}, ++ .ops = nss_nloam_ops, ++ .n_ops = ARRAY_SIZE(nss_nloam_ops), ++ .mcgrps = nss_nloam_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nloam_mcgrp) + }; + + #define NSS_NLOAM_OPS_SZ ARRAY_SIZE(nss_nloam_ops) +@@ -340,7 +346,7 @@ bool nss_nloam_init(void) + /* + * register with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nloam_family, nss_nloam_ops, nss_nloam_mcgrp); ++ error = genl_register_family(&nss_nloam_family); + if (error != 0) { + nss_nl_info_always("unable to register OAM family\n"); + return false; +--- a/netlink/nss_nlpppoe.c ++++ b/netlink/nss_nlpppoe.c +@@ -47,20 +47,6 @@ static int nss_nlpppoe_ops_get_stats(str + static int nss_nlpppoe_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * pppoe family definition +- */ +-static struct genl_family nss_nlpppoe_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLPPPOE_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_pppoe_stats_notification), /* NSS NETLINK pppoe stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLPPPOE version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nlpppoe_mcgrp[] = { +@@ -75,6 +61,26 @@ static struct genl_ops nss_nlpppoe_ops[] + }; + + /* ++ * pppoe family definition ++ */ ++static struct genl_family nss_nlpppoe_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLPPPOE_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_pppoe_stats_notification), /* NSS NETLINK pppoe stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLPPPOE version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nlpppoe_ops, ++ .n_ops = ARRAY_SIZE(nss_nlpppoe_ops), ++ .mcgrps = nss_nlpppoe_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlpppoe_mcgrp) ++}; ++ ++/* + * device call back handler for pppoe from NSS + */ + static struct notifier_block nss_pppoe_stats_notifier_nb = { +@@ -126,7 +132,7 @@ bool nss_nlpppoe_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nlpppoe_family, nss_nlpppoe_ops, nss_nlpppoe_mcgrp); ++ error = genl_register_family(&nss_nlpppoe_family); + if (error) { + nss_nl_info_always("Error: unable to register pppoe family\n"); + return false; +--- a/netlink/nss_nlpptp.c ++++ b/netlink/nss_nlpptp.c +@@ -47,20 +47,6 @@ static int nss_nlpptp_ops_get_stats(stru + static int nss_nlpptp_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * pptp family definition +- */ +-static struct genl_family nss_nlpptp_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLPPTP_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_pptp_stats_notification), /* NSS NETLINK pptp stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLPPTP version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nlpptp_mcgrp[] = { +@@ -75,6 +61,26 @@ static struct genl_ops nss_nlpptp_ops[] + }; + + /* ++ * pptp family definition ++ */ ++static struct genl_family nss_nlpptp_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLPPTP_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_pptp_stats_notification), /* NSS NETLINK pptp stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLPPTP version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nlpptp_ops, ++ .n_ops = ARRAY_SIZE(nss_nlpptp_ops), ++ .mcgrps = nss_nlpptp_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlpptp_mcgrp) ++}; ++ ++/* + * device call back handler for pptp from NSS + */ + static struct notifier_block nss_pptp_stats_notifier_nb = { +@@ -126,7 +132,7 @@ bool nss_nlpptp_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nlpptp_family, nss_nlpptp_ops, nss_nlpptp_mcgrp); ++ error = genl_register_family(&nss_nlpptp_family); + if (error) { + nss_nl_info_always("Error: unable to register pptp family\n"); + return false; +--- a/netlink/nss_nlwifili.c ++++ b/netlink/nss_nlwifili.c +@@ -47,20 +47,6 @@ static int nss_nlwifili_ops_get_stats(st + static int nss_nlwifili_process_notify(struct notifier_block *nb, unsigned long val, void *data); + + /* +- * wifili family definition +- */ +-static struct genl_family nss_nlwifili_family = { +- .id = GENL_ID_GENERATE, /* Auto generate ID */ +- .name = NSS_NLWIFILI_FAMILY, /* family name string */ +- .hdrsize = sizeof(struct nss_wifili_stats_notification), /* NSS NETLINK wifili stats */ +- .version = NSS_NL_VER, /* Set it to NSS_NLWIFILI version */ +- .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ +- .netnsok = true, +- .pre_doit = NULL, +- .post_doit = NULL, +-}; +- +-/* + * multicast group for sending message status & events + */ + static const struct genl_multicast_group nss_nlwifili_mcgrp[] = { +@@ -75,6 +61,26 @@ static struct genl_ops nss_nlwifili_ops[ + }; + + /* ++ * wifili family definition ++ */ ++static struct genl_family nss_nlwifili_family = { ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0)) ++ .id = GENL_ID_GENERATE, /* Auto generate ID */ ++#endif ++ .name = NSS_NLWIFILI_FAMILY, /* family name string */ ++ .hdrsize = sizeof(struct nss_wifili_stats_notification), /* NSS NETLINK wifili stats */ ++ .version = NSS_NL_VER, /* Set it to NSS_NLWIFILI version */ ++ .maxattr = NSS_STATS_EVENT_MAX, /* maximum commands supported */ ++ .netnsok = true, ++ .pre_doit = NULL, ++ .post_doit = NULL, ++ .ops = nss_nlwifili_ops, ++ .n_ops = ARRAY_SIZE(nss_nlwifili_ops), ++ .mcgrps = nss_nlwifili_mcgrp, ++ .n_mcgrps = ARRAY_SIZE(nss_nlwifili_mcgrp) ++}; ++ ++/* + * device call back handler for wifili from NSS + */ + static struct notifier_block nss_wifili_stats_notifier_nb = { +@@ -126,7 +132,7 @@ bool nss_nlwifili_init(void) + /* + * register NETLINK ops with the family + */ +- error = genl_register_family_with_ops_groups(&nss_nlwifili_family, nss_nlwifili_ops, nss_nlwifili_mcgrp); ++ error = genl_register_family(&nss_nlwifili_family); + if (error) { + nss_nl_info_always("Error: unable to register wifili family\n"); + return false; +--- a/netlink/nss_nlcapwap.c ++++ b/netlink/nss_nlcapwap.c +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include "nss_crypto_defines.h" + #include "nss_nl.h" + #include "nss_nlcapwap_if.h" + #include "nss_nlcapwap.h" +@@ -1510,7 +1509,7 @@ bool nss_nlcapwap_init(void) + /* + * register NETLINK ops with the family + */ +- err = genl_register_family_with_ops_groups(&nss_nlcapwap_family, nss_nlcapwap_cmd_ops, nss_nlcapwap_family_mcgrp); ++ err = genl_register_family(&nss_nlcapwap_family); + if (err) { + nss_nl_info_always("Error: %d unable to register capwap family\n", err); + goto free; +--- a/netlink/Makefile ++++ b/netlink/Makefile +@@ -1,5 +1,6 @@ ++GRE_ENABLED := $(strip $(if $(filter $(gre), y), 1 , 0)) + CAPWAP_ENABLED := $(strip $(if $(filter $(capwapmgr), y), 1 , 0)) +-IPSEC_ENABLED := $(strip $(if $(filter $(ipsecmgr), y), 1 , 0)) ++IPSEC_ENABLED := 0 + DTLS_ENABLED := $(strip $(if $(filter $(dtlsmgr), y), 1 , 0)) + + ccflags-y := -Werror +@@ -10,44 +11,39 @@ ccflags-y += -DNSS_CLIENT_BUILD_ID="$(BU + + ccflags-y += -DCONFIG_NSS_NLIPV4=1 + ccflags-y += -DCONFIG_NSS_NLIPV6=1 +-ccflags-y += -DCONFIG_NSS_NLOAM=1 +-ccflags-y += -DCONFIG_NSS_NLGRE_REDIR_FAMILY=1 ++ccflags-y += -DCONFIG_NSS_NLOAM=0 ++ccflags-y += -DCONFIG_NSS_NLGRE_REDIR_FAMILY=${GRE_ENABLED} + ccflags-y += -DCONFIG_NSS_NLETHRX=1 + ccflags-y += -DCONFIG_NSS_NLDYNAMIC_INTERFACE=1 + ccflags-y += -DCONFIG_NSS_NLN2H=1 +-ccflags-y += -DCONFIG_NSS_NLIPV4_REASM=1 +-ccflags-y += -DCONFIG_NSS_NLIPV6_REASM=1 ++ccflags-y += -DCONFIG_NSS_NLIPV4_REASM=0 ++ccflags-y += -DCONFIG_NSS_NLIPV6_REASM=0 + ccflags-y += -DCONFIG_NSS_NLWIFILI=1 + ccflags-y += -DCONFIG_NSS_NLLSO_RX=1 +-ccflags-y += -DCONFIG_NSS_NLMAP_T=1 +-ccflags-y += -DCONFIG_NSS_NLPPPOE=1 +-ccflags-y += -DCONFIG_NSS_NLL2TPV2=1 +-ccflags-y += -DCONFIG_NSS_NLPPTP=1 ++ccflags-y += -DCONFIG_NSS_NLMAP_T=0 ++ccflags-y += -DCONFIG_NSS_NLPPPOE=0 ++ccflags-y += -DCONFIG_NSS_NLL2TPV2=0 ++ccflags-y += -DCONFIG_NSS_NLPPTP=0 + ccflags-y += -DCONFIG_NSS_NLCAPWAP=${CAPWAP_ENABLED} + ccflags-y += -DCONFIG_NSS_NLIPSEC=${IPSEC_ENABLED} + ccflags-y += -DCONFIG_NSS_NLDTLS=${DTLS_ENABLED} + + qca-nss-netlink-objs := nss_nl.o +-qca-nss-netlink-objs += nss_nlgre_redir_family.o +-qca-nss-netlink-objs += nss_nlgre_redir_cmd.o +-qca-nss-netlink-objs += nss_nlgre_redir_cmn.o +-qca-nss-netlink-objs += nss_nlgre_redir.o +-qca-nss-netlink-objs += nss_nlgre_redir_lag.o + qca-nss-netlink-objs += nss_nlipv4.o + qca-nss-netlink-objs += nss_nlipv6.o +-qca-nss-netlink-objs += nss_nloam.o ++# qca-nss-netlink-objs += nss_nloam.o + qca-nss-netlink-objs += nss_nlethrx.o + qca-nss-netlink-objs += nss_nldynamic_interface.o + qca-nss-netlink-objs += nss_nln2h.o +-qca-nss-netlink-objs += nss_nlipv4_reasm.o +-qca-nss-netlink-objs += nss_nlipv6_reasm.o ++# qca-nss-netlink-objs += nss_nlipv4_reasm.o ++# qca-nss-netlink-objs += nss_nlipv6_reasm.o + qca-nss-netlink-objs += nss_nlwifili.o + qca-nss-netlink-objs += nss_nllso_rx.o +-qca-nss-netlink-objs += nss_nlmap_t.o +-qca-nss-netlink-objs += nss_nlpppoe.o +-qca-nss-netlink-objs += nss_nll2tpv2.o +-qca-nss-netlink-objs += nss_nlpptp.o +- ++# qca-nss-netlink-objs += nss_nlmap_t.o ++# qca-nss-netlink-objs += nss_nlpppoe.o ++# qca-nss-netlink-objs += nss_nll2tpv2.o ++# qca-nss-netlink-objs += nss_nlpptp.o ++# + ifneq (,$(filter $(capwapmgr), y)) + qca-nss-netlink-objs += nss_nlcapwap.o + endif +@@ -56,8 +52,12 @@ ifneq (,$(filter $(dtlsmgr), y)) + qca-nss-netlink-objs += nss_nldtls.o + endif + +-ifneq (,$(filter $(ipsecmgr), y)) +-qca-nss-netlink-objs += nss_nlipsec.o ++ifneq (,$(filter $(gre), y)) ++qca-nss-netlink-objs += nss_nlgre_redir_family.o ++qca-nss-netlink-objs += nss_nlgre_redir_cmd.o ++qca-nss-netlink-objs += nss_nlgre_redir_cmn.o ++qca-nss-netlink-objs += nss_nlgre_redir.o ++qca-nss-netlink-objs += nss_nlgre_redir_lag.o + endif + + ifeq ($(SoC),$(filter $(SoC),ipq807x ipq807x_64)) +--- a/netlink/nss_nl.c ++++ b/netlink/nss_nl.c +@@ -35,8 +35,6 @@ + #include "nss_nlcmn_if.h" + #include "nss_nldtls.h" + #include "nss_nldtls_if.h" +-#include "nss_nlgre_redir_if.h" +-#include "nss_nlgre_redir_family.h" + #include "nss_nlipsec.h" + #include "nss_nlipsec_if.h" + #include "nss_nlipv4.h" +@@ -59,10 +57,6 @@ + #include "nss_nlc2c_tx_if.h" + #include "nss_nlc2c_rx.h" + #include "nss_nlc2c_rx_if.h" +-#include "nss_nlipv4_reasm.h" +-#include "nss_nlipv4_reasm_if.h" +-#include "nss_nlipv6_reasm.h" +-#include "nss_nlipv6_reasm_if.h" + #include "nss_nlwifili.h" + #include "nss_nlwifili_if.h" + #include "nss_nllso_rx.h" +@@ -106,24 +100,6 @@ static struct nss_nl_family family_handl + }, + { + /* +- * NSS_NLIPSEC +- */ +- .name = NSS_NLIPSEC_FAMILY, /* ipsec */ +- .entry = NSS_NLIPSEC_INIT, /* init */ +- .exit = NSS_NLIPSEC_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLIPSEC /* 1 or 0 */ +- }, +- { +- /* +- * NSS_NLOAM +- */ +- .name = NSS_NLOAM_FAMILY, /* oam */ +- .entry = NSS_NLOAM_INIT, /* init */ +- .exit = NSS_NLOAM_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLOAM /* 1 or 0 */ +- }, +- { +- /* + * NSS_NLIPV6 + */ + .name = NSS_NLIPV6_FAMILY, /* ipv6 */ +@@ -133,24 +109,6 @@ static struct nss_nl_family family_handl + }, + { + /* +- * NSS_NLGRE_REDIR +- */ +- .name = NSS_NLGRE_REDIR_FAMILY, /* gre_redir */ +- .entry = NSS_NLGRE_REDIR_FAMILY_INIT, /* init */ +- .exit = NSS_NLGRE_REDIR_FAMILY_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLGRE_REDIR_FAMILY /* 1 or 0 */ +- }, +- { +- /* +- * NSS_NLCAPWAP +- */ +- .name = NSS_NLCAPWAP_FAMILY, /* capwap */ +- .entry = NSS_NLCAPWAP_INIT, /* init */ +- .exit = NSS_NLCAPWAP_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLCAPWAP /* 1 or 0 */ +- }, +- { +- /* + * NSS_NLDTLS + */ + .name = NSS_NLDTLS_FAMILY, /* dtls */ +@@ -169,15 +127,6 @@ static struct nss_nl_family family_handl + }, + { + /* +- * NSS_NLEDMA +- */ +- .name = NSS_NLEDMA_FAMILY, /* edma */ +- .entry = NSS_NLEDMA_INIT, /* init */ +- .exit = NSS_NLEDMA_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLEDMA /* 1 or 0 */ +- }, +- { +- /* + * NSS_NLDYNAMIC_INTERFACE + */ + .name = NSS_NLDYNAMIC_INTERFACE_FAMILY, /* dynamic interface */ +@@ -196,42 +145,6 @@ static struct nss_nl_family family_handl + }, + { + /* +- * NSS_NLC2C_TX +- */ +- .name = NSS_NLC2C_TX_FAMILY, /* c2c_tx */ +- .entry = NSS_NLC2C_TX_INIT, /* init */ +- .exit = NSS_NLC2C_TX_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLC2C_TX /* 1 or 0 */ +- }, +- { +- /* +- * NSS_NLC2C_RX +- */ +- .name = NSS_NLC2C_RX_FAMILY, /* c2c_rx */ +- .entry = NSS_NLC2C_RX_INIT, /* init */ +- .exit = NSS_NLC2C_RX_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLC2C_RX /* 1 or 0 */ +- }, +- { +- /* +- * NSS_NLIPV4_REASM +- */ +- .name = NSS_NLIPV4_REASM_FAMILY, /* ipv4_reasm */ +- .entry = NSS_NLIPV4_REASM_INIT, /* init */ +- .exit = NSS_NLIPV4_REASM_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLIPV4_REASM /* 1 or 0 */ +- }, +- { +- /* +- * NSS_NLIPV6_REASM +- */ +- .name = NSS_NLIPV6_REASM_FAMILY, /* ipv6_reasm */ +- .entry = NSS_NLIPV6_REASM_INIT, /* init */ +- .exit = NSS_NLIPV6_REASM_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLIPV6_REASM /* 1 or 0 */ +- }, +- { +- /* + * NSS_NLWIFILI + */ + .name = NSS_NLWIFILI_FAMILY, /* wifili */ +@@ -248,42 +161,6 @@ static struct nss_nl_family family_handl + .exit = NSS_NLLSO_RX_EXIT, /* exit */ + .valid = CONFIG_NSS_NLLSO_RX /* 1 or 0 */ + }, +- { +- /* +- * NSS_NLMAP_T +- */ +- .name = NSS_NLMAP_T_FAMILY, /* map_t */ +- .entry = NSS_NLMAP_T_INIT, /* init */ +- .exit = NSS_NLMAP_T_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLMAP_T /* 1 or 0 */ +- }, +- { +- /* +- * NSS_NLPPPOE +- */ +- .name = NSS_NLPPPOE_FAMILY, /* pppoe */ +- .entry = NSS_NLPPPOE_INIT, /* init */ +- .exit = NSS_NLPPPOE_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLPPPOE /* 1 or 0 */ +- }, +- { +- /* +- * NSS_NLL2TPV2 +- */ +- .name = NSS_NLL2TPV2_FAMILY, /* l2tpv2 */ +- .entry = NSS_NLL2TPV2_INIT, /* init */ +- .exit = NSS_NLL2TPV2_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLL2TPV2 /* 1 or 0 */ +- }, +- { +- /* +- * NSS_NLPPTP +- */ +- .name = NSS_NLPPTP_FAMILY, /* pptp */ +- .entry = NSS_NLPPTP_INIT, /* init */ +- .exit = NSS_NLPPTP_EXIT, /* exit */ +- .valid = CONFIG_NSS_NLPPTP /* 1 or 0 */ +- }, + }; + + #define NSS_NL_FAMILY_HANDLER_SZ ARRAY_SIZE(family_handlers) --- a/nss_qdisc/Makefile +++ b/nss_qdisc/Makefile -@@ -9,18 +9,16 @@ endif - ccflags-y += -Wall -Werror +@@ -6,7 +6,7 @@ ifeq ($(SoC),$(filter $(SoC),ipq807x ipq + ccflags-y += -DNSS_QDISC_PPE_SUPPORT -DNSS_QDISC_BRIDGE_SUPPORT + endif + +-ccflags-y += -Werror ++ccflags-y += -Wall -Werror obj-m += qca-nss-qdisc.o --qca-nss-qdisc-objs := nss_bf.o \ -- nss_blackhole.o \ -- nss_codel.o \ -+qca-nss-qdisc-objs := nss_qdisc.o \ - nss_fifo.o \ -- nss_htb.o \ -- nss_prio.o \ -- nss_qdisc.o \ -- nss_qdisc_htable.o \ -- nss_qdisc_stats.o \ -+ nss_codel.o \ - nss_tbl.o \ -- nss_wred.o \ -- nss_wrr.o -+ nss_prio.o \ -+ nss_bf.o \ -+ nss_wrr.o \ -+ nss_htb.o \ -+ nss_blackhole.o \ -+ nss_wred.o - - ifeq ($(SoC),$(filter $(SoC),ipq807x ipq807x_64 ipq60xx ipq60xx_64)) - qca-nss-qdisc-objs += nss_ppe.o \ + qca-nss-qdisc-objs := nss_qdisc.o \ --- a/nss_qdisc/igs/Makefile +++ b/nss_qdisc/igs/Makefile -@@ -1,7 +1,6 @@ +@@ -1,8 +1,7 @@ # Makefile for IGS (Ingress Shaping) ccflags-y += $(NSS_CCFLAGS) -I$(obj)/../../exports -ccflags-y += -DNSS_IGS_DEBUG_LEVEL=2 - ccflags-y += -Wall -Werror +-ccflags-y += -Werror ++ccflags-y += -Wall -Werror obj-m += act_nssmirred.o + act_nssmirred-objs := \ --- a/nss_qdisc/igs/nss_mirred.c +++ b/nss_qdisc/igs/nss_mirred.c -@@ -82,20 +82,24 @@ static const struct nla_policy nss_mirre - * nss_mirred_init() +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019 The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020 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. +@@ -24,12 +24,20 @@ + + static LIST_HEAD(nss_mirred_list); /* List for all nss mirred actions */ + static DEFINE_SPINLOCK(nss_mirred_list_lock); /* Lock for the nss mirred list */ ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) ++static unsigned int nss_mirred_net_id; /* NSS mirror net ID */ ++static struct tc_action_ops nss_mirred_act_ops; /* NSS action mirror ops */ ++#endif + + /* + * nss_mirred_release() + * Cleanup the resources for nss mirred action. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + static void nss_mirred_release(struct tc_action *tc_act, int bind) ++#else ++static void nss_mirred_release(struct tc_action *tc_act) ++#endif + { + struct nss_mirred_tcf *act = nss_mirred_get(tc_act); + struct net_device *dev = rcu_dereference_protected(act->tcfm_dev, 1); +@@ -75,9 +83,23 @@ static const struct nla_policy nss_mirre * Initialize the nss mirred action. */ --#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) static int nss_mirred_init(struct net *net, struct nlattr *nla, - struct nlattr *est, struct tc_action *tc_act, int ovr, - int bind) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + struct nlattr *est, struct tc_action *tc_act, int ovr, + int bind) -+{ + { +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) + struct nlattr *est, struct tc_action **tc_act, int ovr, + int bind, bool rtnl_held, struct tcf_proto *tp, + u32 flags, struct netlink_ext_ack *extack) - { - #else --static int nss_mirred_init(struct net *net, struct nlattr *nla, -- struct nlattr *est, struct tc_action **tc_act, int ovr, -- int bind, bool rtnl_held, struct tcf_proto *tp, -- struct netlink_ext_ack *extack) ++{ ++#else + struct nlattr *est, struct tc_action **tc_act, + struct tcf_proto *tp, u32 flags, struct netlink_ext_ack *extack) - { ++{ + bool bind = flags & TCA_ACT_FLAGS_BIND; +#endif - struct tc_action_net *tn = net_generic(net, nss_mirred_net_id); - u32 index; --#endif ++ struct tc_action_net *tn = net_generic(net, nss_mirred_net_id); ++ u32 index; struct nlattr *arr[TC_NSS_MIRRED_MAX + 1]; struct tc_nss_mirred *parm; struct nss_mirred_tcf *act; -@@ -239,8 +243,13 @@ static int nss_mirred_init(struct net *n +@@ -92,7 +114,11 @@ static int nss_mirred_init(struct net *n + /* + * Parse and validate the user configurations. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0)) + ret = nla_parse_nested(arr, TC_NSS_MIRRED_MAX, nla, nss_mirred_policy); ++#else ++ ret = nla_parse_nested_deprecated(arr, TC_NSS_MIRRED_MAX, nla, nss_mirred_policy, extack); ++#endif + if (ret < 0) { + return ret; + } +@@ -193,6 +219,7 @@ static int nss_mirred_init(struct net *n + /* + * Return error if nss mirred action index is present in the hash. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + if (tcf_hash_check(parm->index, tc_act, bind)) { + return -EEXIST; + } +@@ -204,7 +231,33 @@ static int nss_mirred_init(struct net *n } - if (!ret) { + act = nss_mirred_get(tc_act); ++#else ++ index = parm->index; ++ ret = tcf_idr_check_alloc(tn, &index, tc_act, bind); ++ if (ret < 0) { ++ return ret; ++ } ++ ++ if (ret && bind) { ++ return 0; ++ } ++ ++ if (!ret) { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)) - ret = tcf_idr_create(tn, index, est, tc_act, &nss_mirred_act_ops, - bind, true); ++ ret = tcf_idr_create(tn, index, est, tc_act, &nss_mirred_act_ops, ++ bind, true); +#else + ret = tcf_idr_create(tn, index, est, tc_act, &nss_mirred_act_ops, + bind, true, 0); +#endif - if (ret) { - tcf_idr_cleanup(tn, index); - return ret; ---- a/nss_qdisc/nss_bf.c -+++ b/nss_qdisc/nss_bf.c -@@ -1,13 +1,9 @@ ++ if (ret) { ++ tcf_idr_cleanup(tn, index); ++ return ret; ++ } ++ } + ++ act = nss_mirred_get(*tc_act); ++#endif + /* + * Fill up the nss mirred tc parameters to + * its local action structure. +@@ -222,7 +275,9 @@ static int nss_mirred_init(struct net *n + spin_lock_bh(&nss_mirred_list_lock); + list_add(&act->tcfm_list, &nss_mirred_list); + spin_unlock_bh(&nss_mirred_list_lock); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + tcf_hash_insert(tc_act); ++#endif + + return ACT_P_CREATED; + } +@@ -234,10 +289,15 @@ static int nss_mirred_init(struct net *n + static int nss_mirred_act(struct sk_buff *skb, const struct tc_action *tc_act, + struct tcf_result *res) + { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + struct nss_mirred_tcf *act = tc_act->priv; ++#else ++ struct nss_mirred_tcf *act = nss_mirred_get(tc_act); ++#endif + struct net_device *dev; + struct sk_buff *skb_new; + int retval, err; ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + u32 skb_tc_at = G_TC_AT(skb->tc_verd); + + /* +@@ -247,6 +307,12 @@ static int nss_mirred_act(struct sk_buff + return TC_ACT_UNSPEC; + } + ++#else ++ if (!skb_at_tc_ingress(skb)) { ++ return TC_ACT_UNSPEC; ++ } ++#endif ++ + /* + * Update the last use of action. + */ +@@ -276,9 +342,14 @@ static int nss_mirred_act(struct sk_buff + + skb_new->skb_iif = skb->dev->ifindex; + skb_new->dev = dev; ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + skb_new->tc_verd = SET_TC_FROM(skb_new->tc_verd, skb_tc_at); + skb_push_rcsum(skb_new, skb->mac_len); + skb_sender_cpu_clear(skb_new); ++#else ++ skb_set_redirected(skb_new, skb_new->tc_at_ingress); ++ skb_push_rcsum(skb_new, skb->mac_len); ++#endif + + err = dev_queue_xmit(skb_new); + if (!err) { +@@ -300,12 +371,21 @@ static int nss_mirred_dump(struct sk_buf + { + struct tcf_t filter; + unsigned char *tail = skb_tail_pointer(skb); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + struct nss_mirred_tcf *act = tc_act->priv; ++#else ++ struct nss_mirred_tcf *act = nss_mirred_get(tc_act); ++#endif + struct tc_nss_mirred opt = { + .index = act->tcf_index, + .action = act->tcf_action, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + .refcnt = act->tcf_refcnt - ref, + .bindcnt = act->tcf_bindcnt - bind, ++#else ++ .refcnt = refcount_read(&act->tcf_refcnt) - ref, ++ .bindcnt = atomic_read(&act->tcf_bindcnt) - bind, ++#endif + .from_ifindex = act->tcfm_from_ifindex, + .to_ifindex = act->tcfm_to_ifindex, + }; +@@ -470,6 +550,64 @@ static int nss_mirred_device_event(struc + return NOTIFY_DONE; + } + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) ++/* ++ * nss_mirred_walker ++ * nssmirred tcf_action walker ++ */ ++static int nss_mirred_walker(struct net *net, struct sk_buff *skb, ++ struct netlink_callback *cb, int type, ++ const struct tc_action_ops *ops, ++ struct netlink_ext_ack *extack) ++{ ++ struct tc_action_net *tn = net_generic(net, nss_mirred_net_id); ++ ++ return tcf_generic_walker(tn, skb, cb, type, ops, extack); ++} ++ ++/* ++ * nss_mirred_search ++ * nssmirred search idr function. ++ */ ++static int nss_mirred_search(struct net *net, struct tc_action **a, u32 index) ++{ ++ struct tc_action_net *tn = net_generic(net, nss_mirred_net_id); ++ ++ return tcf_idr_search(tn, a, index); ++} ++ ++/* ++ * nss_mirred_dev_put ++ * Release igs dev ++ */ ++static void nss_mirred_dev_put(void *priv) ++{ ++ struct net_device *dev = priv; ++ ++ dev_put(dev); ++} ++ ++/* ++ * nss_mirred_device ++ * Get the igs dev. ++ */ ++static struct net_device *nss_mirred_device(const struct tc_action *a, tc_action_priv_destructor *destructor) ++{ ++ struct nss_mirred_tcf *m = nss_mirred_get(a); ++ struct net_device *dev; ++ ++ rcu_read_lock(); ++ dev = rcu_dereference(m->tcfm_dev); ++ if (dev) { ++ dev_hold(dev); ++ *destructor = nss_mirred_dev_put; ++ } ++ rcu_read_unlock(); ++ ++ return dev; ++} ++#endif ++ + /* + * nss_mirred_device_notifier + * nss mirred device notifier structure. +@@ -482,14 +620,22 @@ static struct notifier_block nss_mirred_ + * nss_mirred_act_ops + * Registration structure for nss mirred action. + */ +-struct tc_action_ops nss_mirred_act_ops = { ++static struct tc_action_ops nss_mirred_act_ops = { + .kind = "nssmirred", +- .type = TCA_ACT_MIRRED_NSS, + .owner = THIS_MODULE, + .act = nss_mirred_act, + .dump = nss_mirred_dump, + .cleanup = nss_mirred_release, + .init = nss_mirred_init, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) ++ .type = TCA_ACT_MIRRED_NSS, ++#else ++ .id = TCA_ID_MIRRED_NSS, ++ .walk = nss_mirred_walker, ++ .lookup = nss_mirred_search, ++ .size = sizeof(struct nss_mirred_tcf), ++ .get_dev = nss_mirred_device ++#endif + }; + + /* +@@ -514,6 +660,52 @@ struct nf_hook_ops nss_mirred_igs_nf_ops + }, + }; + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) ++/* ++ * nss_mirred_init_net ++ * nssmirred net init function. ++ */ ++static __net_init int nss_mirred_init_net(struct net *net) ++{ ++ struct tc_action_net *tn = net_generic(net, nss_mirred_net_id); ++ nf_register_net_hooks(net, nss_mirred_igs_nf_ops, ++ ARRAY_SIZE(nss_mirred_igs_nf_ops)); ++ ++ return tc_action_net_init(net, tn, &nss_mirred_act_ops); ++} ++ ++/* ++ * nss_mirred_exit_net ++ * nssmirred net exit function. ++ */ ++static void __net_exit nss_mirred_exit_net(struct net *net) ++{ ++ nf_unregister_net_hooks(net, nss_mirred_igs_nf_ops, ++ ARRAY_SIZE(nss_mirred_igs_nf_ops)); ++} ++ ++/* ++ * nss_mirred_exit_batch_net ++ * nssmirred exit_batch_net function. ++ */ ++static void __net_exit nss_mirred_exit_batch_net(struct list_head *net_list) ++{ ++ tc_action_net_exit(net_list, nss_mirred_net_id); ++} ++ ++/* ++ * nss_mirred_net_ops ++ * Per netdevice ops. ++ */ ++static struct pernet_operations nss_mirred_net_ops = { ++ .init = nss_mirred_init_net, ++ .exit = nss_mirred_exit_net, ++ .exit_batch = nss_mirred_exit_batch_net, ++ .id = &nss_mirred_net_id, ++ .size = sizeof(struct tc_action_net), ++}; ++#endif ++ + /* + * nss_mirred_init_module() + * nssmirred init function. +@@ -525,6 +717,7 @@ static int __init nss_mirred_init_module + return err; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + err = tcf_register_action(&nss_mirred_act_ops, NSS_MIRRED_TAB_MASK); + if (err) { + unregister_netdevice_notifier(&nss_mirred_device_notifier); +@@ -538,6 +731,13 @@ static int __init nss_mirred_init_module + unregister_netdevice_notifier(&nss_mirred_device_notifier); + return err; + } ++#else ++ err = tcf_register_action(&nss_mirred_act_ops, &nss_mirred_net_ops); ++ if (err) { ++ unregister_netdevice_notifier(&nss_mirred_device_notifier); ++ return err; ++ } ++#endif + + /* + * Set the IGS module reference variable. +@@ -559,12 +759,16 @@ static void __exit nss_mirred_cleanup_mo + */ + nss_igs_module_save(&nss_mirred_act_ops, NULL); + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + nf_unregister_hooks(nss_mirred_igs_nf_ops, ARRAY_SIZE(nss_mirred_igs_nf_ops)); + + /* + * Un-register nss mirred action. + */ + tcf_unregister_action(&nss_mirred_act_ops); ++#else ++ tcf_unregister_action(&nss_mirred_act_ops, &nss_mirred_net_ops); ++#endif + unregister_netdevice_notifier(&nss_mirred_device_notifier); + } + +--- a/nss_qdisc/igs/nss_mirred.h ++++ b/nss_qdisc/igs/nss_mirred.h +@@ -1,6 +1,6 @@ /* ************************************************************************** -- * Copyright (c) 2014-2017, 2019-2021, The Linux Foundation. All rights reserved. -- * -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2014-2017, 2019-2020, The Linux Foundation. All rights reserved. +- * Copyright (c) 2019 The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020 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 -@@ -178,6 +174,11 @@ static int nss_bf_change_class(struct Qd - */ - qdisc_class_hash_grow(sch, &q->clhash); +@@ -14,6 +14,7 @@ + ************************************************************************** + */ -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(&cl->nq); ++#include + #include + + #define NSS_MIRRED_TAB_MASK 7 +@@ -23,7 +24,11 @@ + * nss mirred internal structure. + */ + struct nss_mirred_tcf { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + struct tcf_common common; /* Common filter structure */ ++#else ++ struct tc_action common; /* Common filter structure */ ++#endif + __u32 tcfm_to_ifindex; /* Index number of device to which + * traffic will be redirected. + */ +@@ -40,5 +45,10 @@ struct nss_mirred_tcf { + * To get the pointer of nss mirred action structure from the common + * tc_action structure pointer. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + #define nss_mirred_get(a) \ + container_of(a->priv, struct nss_mirred_tcf, common) ++#else ++#define nss_mirred_get(a) ((struct nss_mirred_tcf *)a) ++#endif + - nss_qdisc_info("Class %u successfully allocated\n", classid); +--- a/nss_qdisc/nss_bf.c ++++ b/nss_qdisc/nss_bf.c +@@ -68,12 +68,20 @@ static inline struct nss_bf_class_data * + * nss_bf_change_class() + * Configures a new class. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_bf_change_class(struct Qdisc *sch, u32 classid, u32 parentid, + struct nlattr **tca, unsigned long *arg) + { ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_bf_change_class(struct Qdisc *sch, u32 classid, u32 parentid, ++ struct nlattr **tca, unsigned long *arg, struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_bf_sched_data *q = qdisc_priv(sch); + struct nss_bf_class_data *cl = (struct nss_bf_class_data *)*arg; + struct nlattr *opt = tca[TCA_OPTIONS]; ++ struct nlattr *tb[TCA_NSSBF_MAX + 1]; + struct tc_nssbf_class_qopt *qopt; + struct nss_if_msg nim_config; + struct net_device *dev = qdisc_dev(sch); +@@ -84,7 +92,12 @@ static int nss_bf_change_class(struct Qd + return -EINVAL; } -@@ -276,6 +277,11 @@ static void nss_bf_destroy_class(struct - nss_qdisc_put(cl->qdisc); +- qopt = nss_qdisc_qopt_get(opt, nss_bf_policy, TCA_NSSBF_MAX, TCA_NSSBF_CLASS_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_bf_policy, tb, TCA_NSSBF_MAX, TCA_NSSBF_CLASS_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_bf_policy, tb, TCA_NSSBF_MAX, TCA_NSSBF_CLASS_PARMS, extack); ++#endif ++ + if (!qopt) { + return -EINVAL; + } +@@ -111,7 +124,7 @@ static int nss_bf_change_class(struct Qd + * reference count should not be 0. + */ + cl->qdisc = &noop_qdisc; +- atomic_set(&cl->nq.refcnt, 1); ++ nss_qdisc_atomic_set(&cl->nq); + *arg = (unsigned long)cl; + + nss_qdisc_info("Adding classid %u to qdisc %px hash queue %px\n", classid, sch, &q->clhash); +@@ -121,7 +134,8 @@ static int nss_bf_change_class(struct Qd + * that is registered to Linux. Therefore we initialize the NSSBF_GROUP shaper + * here. + */ +- if (nss_qdisc_init(sch, &cl->nq, NSS_SHAPER_NODE_TYPE_BF_GROUP, classid, accel_mode) < 0) { ++ if (nss_qdisc_init(sch, &cl->nq, NSS_SHAPER_NODE_TYPE_BF_GROUP, classid, accel_mode, extack) < 0) ++ { + nss_qdisc_error("Nss init for class %u failed\n", classid); + kfree(cl); + return -EINVAL; +@@ -260,7 +274,7 @@ static void nss_bf_destroy_class(struct + /* + * And now we destroy the child. + */ +- qdisc_destroy(cl->qdisc); ++ nss_qdisc_put(cl->qdisc); /* -+ * Stop the stats polling timer and free class -+ */ -+ nss_qdisc_stop_basic_stats_polling(&cl->nq); -+ -+ /* - * Destroy the shaper in NSS - */ - nss_qdisc_destroy(&cl->nq); -@@ -290,7 +296,11 @@ static void nss_bf_destroy_class(struct + * Stop the stats polling timer and free class +@@ -282,7 +296,11 @@ static void nss_bf_destroy_class(struct * nss_bf_delete_class() * Detaches a class from operation, but does not destroy it. */ @@ -6442,228 +3958,832 @@ { struct nss_bf_sched_data *q = qdisc_priv(sch); struct nss_bf_class_data *cl = (struct nss_bf_class_data *)arg; -@@ -299,14 +309,11 @@ static int nss_bf_delete_class(struct Qd - struct nss_qdisc *nq_child = (struct nss_qdisc *)qdisc_priv(cl->qdisc); - - /* -- * If the class is the root class or has qdiscs attached, we do not -- * support deleting it. -+ * Since all classes are leaf nodes in our case, we dont have to make -+ * that check. - */ -- if ((cl == &q->root) || (cl->qdisc != &noop_qdisc)) { -- nss_qdisc_warning("Cannot delete bf class %x as it is the root " -- "class or has child qdisc attached\n", cl->nq.qos_tag); -+ if (cl == &q->root) - return -EBUSY; -- } - - /* - * The message to NSS should be sent to the parent of this class -@@ -320,22 +327,14 @@ static int nss_bf_delete_class(struct Qd - } - +@@ -311,7 +329,7 @@ static int nss_bf_delete_class(struct Qd sch_tree_lock(sch); -+ qdisc_reset(cl->qdisc); + qdisc_reset(cl->qdisc); qdisc_class_hash_remove(&q->clhash, &cl->cl_common); - refcnt = nss_qdisc_atomic_sub_return(&cl->nq); +- refcnt = atomic_sub_return(1, &cl->nq.refcnt); ++ refcnt = nss_qdisc_atomic_sub_return(&cl->nq); sch_tree_unlock(sch); -- -- /* -- * For 5.4 and above kernels, calling nss_htb_destroy_class -- * explicitly as there is no put_class which would have called -- * nss_bf_destroy_class when refcnt becomes zero. -- */ --#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)) -- nss_bf_destroy_class(sch, cl); --#else if (!refcnt) { nss_qdisc_error("Reference count should not be zero for class %px\n", cl); - } --#endif -+ - return 0; +@@ -324,8 +342,13 @@ static int nss_bf_delete_class(struct Qd + * nss_bf_graft_class() + * Replaces the qdisc attached to the provided class. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_bf_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, + struct Qdisc **old) ++#else ++static int nss_bf_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, ++ struct Qdisc **old, struct netlink_ext_ack *extack) ++#endif + { + struct nss_bf_sched_data *q = qdisc_priv(sch); + struct nss_bf_class_data *cl = (struct nss_bf_class_data *)arg; +@@ -415,6 +438,7 @@ static void nss_bf_qlen_notify(struct Qd + */ } -@@ -635,11 +634,6 @@ static int nss_bf_change_qdisc(struct Qd - */ - static void nss_bf_reset_class(struct nss_bf_class_data *cl) - { -- if (cl->qdisc == &noop_qdisc) { -- nss_qdisc_trace("Class %x has no child qdisc to reset\n", cl->nq.qos_tag); -- return; -- } -- - nss_qdisc_reset(cl->qdisc); - nss_qdisc_info("Nssbf class resetted %px\n", cl->qdisc); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + /* + * nss_bf_get_class() + * Fetches the class pointer if provided the classid. +@@ -444,10 +468,24 @@ static void nss_bf_put_class(struct Qdis + * We are safe to destroy the qdisc if the reference count + * goes down to 0. + */ +- if (atomic_sub_return(1, &cl->nq.refcnt) == 0) { ++ if (nss_qdisc_atomic_sub_return(&cl->nq) == 0) { + nss_bf_destroy_class(sch, cl); + } } -@@ -721,6 +715,11 @@ static void nss_bf_destroy_qdisc(struct - qdisc_class_hash_destroy(&q->clhash); ++#else ++/* ++ * nss_bf_search_class() ++ * Fetches the class pointer if provided the classid. ++ */ ++static unsigned long nss_bf_search_class(struct Qdisc *sch, u32 classid) ++{ ++ struct nss_bf_class_data *cl = nss_bf_find_class(classid, sch); ++ ++ nss_qdisc_info("Get bf class %px - class match = %px\n", sch, cl); ++ ++ return (unsigned long)cl; ++} ++#endif + + /* + * nss_bf_dump_class() +@@ -475,7 +513,7 @@ static int nss_bf_dump_class(struct Qdis + tcm->tcm_handle = cl->cl_common.classid; + tcm->tcm_info = cl->qdisc->handle; + +- opts = nla_nest_start(skb, TCA_OPTIONS); ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL || nla_put(skb, TCA_NSSBF_CLASS_PARMS, sizeof(qopt), &qopt)) { + goto nla_put_failure; + } +@@ -495,7 +533,7 @@ static int nss_bf_dump_class_stats(struc + { + struct nss_qdisc *nq = (struct nss_qdisc *)arg; + +- if (nss_qdisc_gnet_stats_copy_basic(d, &nq->bstats) < 0 || ++ if (nss_qdisc_gnet_stats_copy_basic(sch, d, &nq->bstats) < 0 || + nss_qdisc_gnet_stats_copy_queue(d, &nq->qstats) < 0) { + return -1; + } +@@ -538,9 +576,15 @@ static void nss_bf_walk(struct Qdisc *sc + * nss_bf_change_qdisc() + * Can be used to configure a nssbf qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_bf_change_qdisc(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_bf_change_qdisc(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++#endif + { + struct nss_bf_sched_data *q = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSBF_MAX + 1]; + struct tc_nssbf_qopt *qopt; /* -+ * Stop the polling of basic stats -+ */ -+ nss_qdisc_stop_basic_stats_polling(&q->nq); -+ -+ /* - * Now we can go ahead and destroy the qdisc. - * Note: We dont have to detach ourself from our parent because this - * will be taken care of by the graft call. -@@ -799,6 +798,11 @@ static int nss_bf_init_qdisc(struct Qdis +@@ -563,7 +607,11 @@ static int nss_bf_change_qdisc(struct Qd + /* + * If it is not NULL, parse to get qopt. + */ +- qopt = nss_qdisc_qopt_get(opt, nss_bf_policy, TCA_NSSBF_MAX, TCA_NSSBF_QDISC_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_bf_policy, tb, TCA_NSSBF_MAX, TCA_NSSBF_QDISC_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_bf_policy, tb, TCA_NSSBF_MAX, TCA_NSSBF_QDISC_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -643,7 +691,7 @@ static void nss_bf_destroy_qdisc(struct + * Reduce refcnt by 1 before destroying. This is to + * ensure that polling of stat stops properly. + */ +- atomic_sub(1, &cl->nq.refcnt); ++ nss_qdisc_atomic_sub(&cl->nq); + + /* + * Detach class before destroying it. We dont check for noop qdisc here +@@ -684,9 +732,17 @@ static void nss_bf_destroy_qdisc(struct + * nss_bf_init_qdisc() + * Initializes the nssbf qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_bf_init_qdisc(struct Qdisc *sch, struct nlattr *opt) + { ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_bf_init_qdisc(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_bf_sched_data *q = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSBF_MAX + 1]; + struct tc_nssbf_qopt *qopt; + int err; + unsigned int accel_mode; +@@ -710,7 +766,11 @@ static int nss_bf_init_qdisc(struct Qdis + if (!opt) { + accel_mode = TCA_NSS_ACCEL_MODE_NSS_FW; + } else { +- qopt = nss_qdisc_qopt_get(opt, nss_bf_policy, TCA_NSSBF_MAX, TCA_NSSBF_QDISC_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_bf_policy, tb, TCA_NSSBF_MAX, TCA_NSSBF_QDISC_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_bf_policy, tb, TCA_NSSBF_MAX, TCA_NSSBF_QDISC_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -720,7 +780,7 @@ static int nss_bf_init_qdisc(struct Qdis + /* + * Initialize the NSSBF shaper in NSS + */ +- if (nss_qdisc_init(sch, &q->nq, NSS_SHAPER_NODE_TYPE_BF, 0, accel_mode) < 0) { ++ if (nss_qdisc_init(sch, &q->nq, NSS_SHAPER_NODE_TYPE_BF, 0, accel_mode, extack) < 0) { return -EINVAL; } -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(&q->nq); -+ - return 0; +@@ -729,7 +789,11 @@ static int nss_bf_init_qdisc(struct Qdis + /* + * Tune nss_bf parameters. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_bf_change_qdisc(sch, opt) < 0) { ++#else ++ if (nss_bf_change_qdisc(sch, opt, extack) < 0) { ++#endif + nss_qdisc_destroy(&q->nq); + return -EINVAL; + } +@@ -756,7 +820,7 @@ static int nss_bf_dump_qdisc(struct Qdis + qopt.defcls = q->defcls; + qopt.accel_mode = nss_qdisc_accel_mode_get(&q->nq); + +- opts = nla_nest_start(skb, TCA_OPTIONS); ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); + if (!opts || nla_put(skb, TCA_NSSBF_QDISC_PARMS, sizeof(qopt), &qopt)) { + goto nla_put_failure; + } +@@ -772,9 +836,18 @@ nla_put_failure: + * nss_bf_enqueue() + * Enqueues a skb to nssbf qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static int nss_bf_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++#else ++static int nss_bf_enqueue(struct sk_buff *skb, struct Qdisc *sch, ++ struct sk_buff **to_free) ++#endif + { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + return nss_qdisc_enqueue(skb, sch); ++#else ++ return nss_qdisc_enqueue(skb, sch, to_free); ++#endif } + /* +@@ -786,6 +859,7 @@ static struct sk_buff *nss_bf_dequeue(st + return nss_qdisc_dequeue(sch); + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + /* + * nss_bf_drop() + * Drops a single skb from linux queue, if not empty. +@@ -797,6 +871,7 @@ static unsigned int nss_bf_drop(struct Q + printk("In bf drop\n"); + return nss_qdisc_drop(sch); + } ++#endif + + /* + * Registration structure for nssbf class +@@ -807,9 +882,17 @@ const struct Qdisc_class_ops nss_bf_clas + .graft = nss_bf_graft_class, + .leaf = nss_bf_leaf_class, + .qlen_notify = nss_bf_qlen_notify, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + .get = nss_bf_get_class, + .put = nss_bf_put_class, ++#else ++ .find = nss_bf_search_class, ++#endif ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + .tcf_chain = nss_qdisc_tcf_chain, ++#else ++ .tcf_block = nss_qdisc_tcf_block, ++#endif + .bind_tcf = nss_qdisc_tcf_bind, + .unbind_tcf = nss_qdisc_tcf_unbind, + .dump = nss_bf_dump_class, +@@ -830,7 +913,9 @@ struct Qdisc_ops nss_bf_qdisc_ops __read + .enqueue = nss_bf_enqueue, + .dequeue = nss_bf_dequeue, + .peek = qdisc_peek_dequeued, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_bf_drop, ++#endif + .cl_ops = &nss_bf_class_ops, + .priv_size = sizeof(struct nss_bf_sched_data), + .owner = THIS_MODULE --- a/nss_qdisc/nss_blackhole.c +++ b/nss_qdisc/nss_blackhole.c @@ -1,6 +1,6 @@ /* ************************************************************************** -- * Copyright (c) 2014, 2016-2017, 2020-2021, The Linux Foundation. All rights reserved. +- * Copyright (c) 2014, 2016-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2014, 2016-2017, 2020, 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. -@@ -90,6 +90,11 @@ static void nss_blackhole_destroy(struct +@@ -35,9 +35,18 @@ static struct nla_policy nss_blackhole_p + * nss_blackhole_enqueue() + * Enqueue API for nss blackhole qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static int nss_blackhole_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++#else ++static int nss_blackhole_enqueue(struct sk_buff *skb, struct Qdisc *sch, ++ struct sk_buff **to_free) ++#endif { - struct nss_qdisc *nq = (struct nss_qdisc *)qdisc_priv(sch); - -+ /* -+ * Stop the polling of basic stats -+ */ -+ nss_qdisc_stop_basic_stats_polling(nq); -+ - nss_qdisc_info("destroying qdisc %x\n", sch->handle); - nss_qdisc_destroy(nq); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + return nss_qdisc_enqueue(skb, sch); ++#else ++ return nss_qdisc_enqueue(skb, sch, to_free); ++#endif } -@@ -219,6 +224,11 @@ static int nss_blackhole_init(struct Qdi + + /* +@@ -49,6 +58,7 @@ static struct sk_buff *nss_blackhole_deq + return nss_qdisc_dequeue(sch); + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + /* + * nss_blackhole_drop() + * The following function drops a packet from HLOS queue. +@@ -60,6 +70,7 @@ static unsigned int nss_blackhole_drop(s + nss_qdisc_info("qdisc %x dropping\n", sch->handle); + return nss_qdisc_drop(sch); + } ++#endif + + /* + * nss_blackhole_reset() +@@ -92,9 +103,15 @@ static void nss_blackhole_destroy(struct + * nss_blackhole_change() + * Function call used to configure the parameters of the nss blackhole qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_blackhole_change(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_blackhole_change(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++#endif + { + struct nss_blackhole_sched_data *q; ++ struct nlattr *tb[TCA_NSSBLACKHOLE_MAX + 1]; + struct tc_nssblackhole_qopt *qopt; + struct nss_if_msg nim; + +@@ -102,7 +119,11 @@ static int nss_blackhole_change(struct Q + return 0; + } + +- qopt = nss_qdisc_qopt_get(opt, nss_blackhole_policy, TCA_NSSBLACKHOLE_MAX, TCA_NSSBLACKHOLE_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_blackhole_policy, tb, TCA_NSSBLACKHOLE_MAX, TCA_NSSBLACKHOLE_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_blackhole_policy, tb, TCA_NSSBLACKHOLE_MAX, TCA_NSSBLACKHOLE_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -154,9 +175,17 @@ static int nss_blackhole_change(struct Q + * nss_blackhole_init() + * Initializes a nss blackhole qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_blackhole_init(struct Qdisc *sch, struct nlattr *opt) + { ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_blackhole_init(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_qdisc *nq = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSBLACKHOLE_MAX + 1]; + struct tc_nssblackhole_qopt *qopt; + unsigned int accel_mode; + +@@ -166,7 +195,11 @@ static int nss_blackhole_init(struct Qdi + if (!opt) { + accel_mode = TCA_NSS_ACCEL_MODE_PPE; + } else { +- qopt = nss_qdisc_qopt_get(opt, nss_blackhole_policy, TCA_NSSBLACKHOLE_MAX, TCA_NSSBLACKHOLE_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_blackhole_policy, tb, TCA_NSSBLACKHOLE_MAX, TCA_NSSBLACKHOLE_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_blackhole_policy, tb, TCA_NSSBLACKHOLE_MAX, TCA_NSSBLACKHOLE_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -176,12 +209,17 @@ static int nss_blackhole_init(struct Qdi + nss_qdisc_info("qdisc %x initializing\n", sch->handle); + nss_blackhole_reset(sch); + +- if (nss_qdisc_init(sch, nq, NSS_SHAPER_NODE_TYPE_FIFO, 0, accel_mode) < 0) { ++ if (nss_qdisc_init(sch, nq, NSS_SHAPER_NODE_TYPE_FIFO, 0, accel_mode, extack) < 0) ++ { return -EINVAL; } -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(nq); -+ - return 0; - } + nss_qdisc_info("qdisc %x initialized with parent %x\n", sch->handle, sch->parent); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_blackhole_change(sch, opt) < 0) { ++#else ++ if (nss_blackhole_change(sch, opt, extack) < 0) { ++#endif + nss_qdisc_destroy(nq); + return -EINVAL; + } +@@ -214,7 +252,7 @@ static int nss_blackhole_dump(struct Qdi + opt.set_default = q->set_default; + opt.accel_mode = nss_qdisc_accel_mode_get(&q->nq); +- opts = nla_nest_start(skb, TCA_OPTIONS); ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL) { + goto nla_put_failure; + } +@@ -251,7 +289,9 @@ struct Qdisc_ops nss_blackhole_qdisc_ops + .enqueue = nss_blackhole_enqueue, + .dequeue = nss_blackhole_dequeue, + .peek = nss_blackhole_peek, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_blackhole_drop, ++#endif + .init = nss_blackhole_init, + .reset = nss_blackhole_reset, + .destroy = nss_blackhole_destroy, --- a/nss_qdisc/nss_codel.c +++ b/nss_qdisc/nss_codel.c @@ -1,6 +1,6 @@ /* ************************************************************************** -- * Copyright (c) 2014, 2016-2018, 2020-2021, The Linux Foundation. All rights reserved. +- * Copyright (c) 2014, 2016-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2014, 2016-2018, 2020, 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. -@@ -155,6 +155,10 @@ static void nss_codel_destroy(struct Qdi +@@ -76,9 +76,18 @@ static struct nla_policy nss_codel_polic + * nss_codel_enqueue() + * Enqueue a packet into nss_codel queue in NSS firmware (bounce). + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static int nss_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++#else ++static int nss_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch, ++ struct sk_buff **to_free) ++#endif + { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + return nss_qdisc_enqueue(skb, sch); ++#else ++ return nss_qdisc_enqueue(skb, sch, to_free); ++#endif + } + + /* +@@ -90,6 +99,7 @@ static struct sk_buff *nss_codel_dequeue + return nss_qdisc_dequeue(sch); + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + /* + * nss_codel_drop() + * Drops a packet from the bounce complete queue. +@@ -100,6 +110,7 @@ static unsigned int nss_codel_drop(struc + { + return nss_qdisc_drop(sch); + } ++#endif + + /* + * nss_codel_reset() +@@ -234,9 +245,15 @@ static int nss_codel_mem_sz_get(struct Q + * nss_codel_change() + * Used to configure the nss_codel queue in NSS firmware. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_codel_change(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_codel_change(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++#endif { struct nss_codel_sched_data *q = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSCODEL_MAX + 1]; + struct tc_nsscodel_qopt *qopt; + struct nss_if_msg nim; + struct net_device *dev = qdisc_dev(sch); +@@ -245,7 +262,11 @@ static int nss_codel_change(struct Qdisc + struct nss_shaper_node_config *config; + bool free_flow_queue = true; -+ /* -+ * Stop the polling of basic stats -+ */ -+ nss_qdisc_stop_basic_stats_polling(&q->nq); - nss_qdisc_destroy(&q->nq); - nss_codel_flow_queues_free(q); - nss_qdisc_info("nss_codel destroyed"); -@@ -451,6 +455,11 @@ static int nss_codel_init(struct Qdisc * +- qopt = nss_qdisc_qopt_get(opt, nss_codel_policy, TCA_NSSCODEL_MAX, TCA_NSSCODEL_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_codel_policy, tb, TCA_NSSCODEL_MAX, TCA_NSSCODEL_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_codel_policy, tb, TCA_NSSCODEL_MAX, TCA_NSSCODEL_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -381,16 +402,28 @@ fail: + * nss_codel_init() + * Initializes the nss_codel qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_codel_init(struct Qdisc *sch, struct nlattr *opt) + { ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_codel_init(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_qdisc *nq = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSCODEL_MAX + 1]; + struct tc_nsscodel_qopt *qopt; + + if (!opt) { return -EINVAL; } -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(nq); -+ - return 0; - } +- qopt = nss_qdisc_qopt_get(opt, nss_codel_policy, TCA_NSSCODEL_MAX, TCA_NSSCODEL_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_codel_policy, tb, TCA_NSSCODEL_MAX, TCA_NSSCODEL_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_codel_policy, tb, TCA_NSSCODEL_MAX, TCA_NSSCODEL_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -404,7 +437,8 @@ static int nss_codel_init(struct Qdisc * + nss_qdisc_register_configure_callback(nq, nss_codel_configure_callback); + nss_qdisc_register_stats_callback(nq, nss_codel_stats_callback); +- if (nss_qdisc_init(sch, nq, NSS_SHAPER_NODE_TYPE_CODEL, 0, qopt->accel_mode) < 0) { ++ if (nss_qdisc_init(sch, nq, NSS_SHAPER_NODE_TYPE_CODEL, 0, qopt->accel_mode, extack) < 0) ++ { + return -EINVAL; + } + +@@ -412,7 +446,11 @@ static int nss_codel_init(struct Qdisc * + return -EINVAL; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_codel_change(sch, opt) < 0) { ++#else ++ if (nss_codel_change(sch, opt, extack) < 0) { ++#endif + nss_qdisc_destroy(nq); + return -EINVAL; + } +@@ -451,7 +489,7 @@ static int nss_codel_dump(struct Qdisc * + opt.flows = q->flows; + opt.ecn = q->ecn; + +- opts = nla_nest_start(skb, TCA_OPTIONS); ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL) { + goto nla_put_failure; + } +@@ -511,7 +549,9 @@ struct Qdisc_ops nss_codel_qdisc_ops __r + .enqueue = nss_codel_enqueue, + .dequeue = nss_codel_dequeue, + .peek = nss_codel_peek, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_codel_drop, ++#endif + .init = nss_codel_init, + .reset = nss_codel_reset, + .destroy = nss_codel_destroy, +@@ -530,7 +570,9 @@ struct Qdisc_ops nss_fq_codel_qdisc_ops + .enqueue = nss_codel_enqueue, + .dequeue = nss_codel_dequeue, + .peek = nss_codel_peek, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_codel_drop, ++#endif + .init = nss_codel_init, + .reset = nss_codel_reset, + .destroy = nss_codel_destroy, --- a/nss_qdisc/nss_fifo.c +++ b/nss_qdisc/nss_fifo.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014, 2016-2017, 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014, 2016-2017, 2020, 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. -@@ -66,6 +66,11 @@ static void nss_fifo_destroy(struct Qdis - { - struct nss_qdisc *nq = (struct nss_qdisc *)qdisc_priv(sch); +@@ -29,9 +29,18 @@ static struct nla_policy nss_fifo_policy + [TCA_NSSFIFO_PARMS] = { .len = sizeof(struct tc_nssfifo_qopt) }, + }; -+ /* -+ * Stop the polling of basic stats -+ */ -+ nss_qdisc_stop_basic_stats_polling(nq); -+ - nss_qdisc_destroy(nq); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static int nss_fifo_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++#else ++static int nss_fifo_enqueue(struct sk_buff *skb, struct Qdisc *sch, ++ struct sk_buff **to_free) ++#endif + { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + return nss_qdisc_enqueue(skb, sch); ++#else ++ return nss_qdisc_enqueue(skb, sch, to_free); ++#endif + } + + static struct sk_buff *nss_fifo_dequeue(struct Qdisc *sch) +@@ -39,11 +48,13 @@ static struct sk_buff *nss_fifo_dequeue( + return nss_qdisc_dequeue(sch); + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static unsigned int nss_fifo_drop(struct Qdisc *sch) + { + nss_qdisc_info("nss_fifo dropping"); + return nss_qdisc_drop(sch); + } ++#endif + + static void nss_fifo_reset(struct Qdisc *sch) + { +@@ -64,8 +75,14 @@ static void nss_fifo_destroy(struct Qdis nss_qdisc_info("nss_fifo destroyed"); } -@@ -291,6 +296,11 @@ static int nss_fifo_init(struct Qdisc *s + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_fifo_params_validate_and_save(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_fifo_params_validate_and_save(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++#endif + { ++ struct nlattr *tb[TCA_NSSFIFO_MAX + 1]; + struct tc_nssfifo_qopt *qopt; + struct nss_fifo_sched_data *q = qdisc_priv(sch); + bool is_bfifo = (sch->ops == &nss_bfifo_qdisc_ops); +@@ -74,7 +91,11 @@ static int nss_fifo_params_validate_and_ return -EINVAL; } -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(nq); -+ +- qopt = nss_qdisc_qopt_get(opt, nss_fifo_policy, TCA_NSSFIFO_MAX, TCA_NSSFIFO_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_fifo_policy, tb, TCA_NSSFIFO_MAX, TCA_NSSFIFO_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_fifo_policy, tb, TCA_NSSFIFO_MAX, TCA_NSSFIFO_PARMS, extack); ++#endif + if (!qopt) { + nss_qdisc_warning("Invalid input to fifo %x", sch->handle); + return -EINVAL; +@@ -101,7 +122,11 @@ static int nss_fifo_params_validate_and_ + } + + #if defined(NSS_QDISC_PPE_SUPPORT) ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_fifo_ppe_change(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_fifo_ppe_change(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) ++#endif + { + struct nss_fifo_sched_data *q = qdisc_priv(sch); + struct nss_qdisc *nq = &q->nq; +@@ -150,28 +175,45 @@ fail: + /* + * Fallback to nss qdisc if PPE Qdisc configuration failed at init time. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_ppe_fallback_to_nss(&q->nq, opt) < 0) { +- nss_qdisc_warning("nss_fifo %x fallback to nss failed\n", sch->handle); ++#else ++ if (nss_ppe_fallback_to_nss(&q->nq, opt, extack) < 0) { ++#endif ++ nss_qdisc_warning("nss_fifo %x fallback to nss failed\n", sch->handle); + return -EINVAL; + } + return 0; + } + #endif + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_fifo_change(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_fifo_change(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++#endif + { + struct nss_fifo_sched_data *q = qdisc_priv(sch); + struct nss_qdisc *nq = &q->nq; + struct nss_if_msg nim; + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_fifo_params_validate_and_save(sch, opt) < 0) { ++#else ++ if (nss_fifo_params_validate_and_save(sch, opt, extack) < 0) { ++#endif + nss_qdisc_warning("nss_fifo %px params validate and save failed\n", sch); + return -EINVAL; + } + + #if defined(NSS_QDISC_PPE_SUPPORT) + if (nq->mode == NSS_QDISC_MODE_PPE) { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_fifo_ppe_change(sch, opt) < 0) { ++#else ++ if (nss_fifo_ppe_change(sch, opt, extack) < 0) { ++#endif + nss_qdisc_warning("nss_fifo %px params validate and save failed\n", sch); + return -EINVAL; + } +@@ -208,9 +250,17 @@ static int nss_fifo_change(struct Qdisc return 0; } ---- a/nss_qdisc/nss_htb.c -+++ b/nss_qdisc/nss_htb.c -@@ -1,13 +1,9 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2017, 2019-2021, The Linux Foundation. All rights reserved. -- * -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2014-2017, 2019-2020, 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 -@@ -413,6 +409,11 @@ static int nss_htb_change_class(struct Q - */ - qdisc_class_hash_grow(sch, &q->clhash); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_fifo_init(struct Qdisc *sch, struct nlattr *opt) + { ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_fifo_init(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_qdisc *nq = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSFIFO_MAX + 1]; + struct tc_nssfifo_qopt *qopt; -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(&cl->nq); -+ - nss_qdisc_trace("class %x successfully allocated and initialized\n", classid); + if (!opt) { +@@ -220,19 +270,28 @@ static int nss_fifo_init(struct Qdisc *s + nss_qdisc_info("Initializing Fifo - type %d\n", NSS_SHAPER_NODE_TYPE_FIFO); + nss_fifo_reset(sch); + +- qopt = nss_qdisc_qopt_get(opt, nss_fifo_policy, TCA_NSSFIFO_MAX, TCA_NSSFIFO_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_fifo_policy, tb, TCA_NSSFIFO_MAX, TCA_NSSFIFO_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_fifo_policy, tb, TCA_NSSFIFO_MAX, TCA_NSSFIFO_PARMS, extack); ++#endif + if (!qopt) { + nss_qdisc_warning("Invalid input to fifo %x", sch->handle); + return -EINVAL; } -@@ -502,6 +503,11 @@ static void nss_htb_destroy_class(struct - nss_qdisc_put(cl->qdisc); +- if (nss_qdisc_init(sch, nq, NSS_SHAPER_NODE_TYPE_FIFO, 0, qopt->accel_mode) < 0) { ++ if (nss_qdisc_init(sch, nq, NSS_SHAPER_NODE_TYPE_FIFO, 0, qopt->accel_mode, extack) < 0) ++ { + nss_qdisc_warning("Fifo %x init failed", sch->handle); + return -EINVAL; + } + + nss_qdisc_info("NSS fifo initialized - handle %x parent %x\n", sch->handle, sch->parent); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_fifo_change(sch, opt) < 0) { ++#else ++ if (nss_fifo_change(sch, opt, extack) < 0) { ++#endif + nss_qdisc_destroy(nq); + return -EINVAL; + } +@@ -262,7 +321,8 @@ static int nss_fifo_dump(struct Qdisc *s + opt.set_default = q->set_default; + opt.accel_mode = nss_qdisc_accel_mode_get(&q->nq); + +- opts = nla_nest_start(skb, TCA_OPTIONS); ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); ++ + if (opts == NULL) { + goto nla_put_failure; + } +@@ -290,7 +350,9 @@ struct Qdisc_ops nss_pfifo_qdisc_ops __r + .enqueue = nss_fifo_enqueue, + .dequeue = nss_fifo_dequeue, + .peek = nss_fifo_peek, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_fifo_drop, ++#endif + .init = nss_fifo_init, + .reset = nss_fifo_reset, + .destroy = nss_fifo_destroy, +@@ -305,7 +367,9 @@ struct Qdisc_ops nss_bfifo_qdisc_ops __r + .enqueue = nss_fifo_enqueue, + .dequeue = nss_fifo_dequeue, + .peek = nss_fifo_peek, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_fifo_drop, ++#endif + .init = nss_fifo_init, + .reset = nss_fifo_reset, + .destroy = nss_fifo_destroy, +--- a/nss_qdisc/nss_htb.c ++++ b/nss_qdisc/nss_htb.c +@@ -83,10 +83,16 @@ static inline struct nss_htb_class_data + * nss_htb_class_params_validate_and_save() + * Validates and saves the qdisc configuration parameters. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_htb_class_params_validate_and_save(struct Qdisc *sch, struct nlattr **tca, + struct nss_htb_param *param) ++#else ++static int nss_htb_class_params_validate_and_save(struct Qdisc *sch, struct nlattr **tca, ++ struct nss_htb_param *param, struct netlink_ext_ack *extack) ++#endif + { + struct nlattr *opt = tca[TCA_OPTIONS]; ++ struct nlattr *tb[TCA_NSSHTB_MAX + 1]; + struct tc_nsshtb_class_qopt *qopt; + struct nss_htb_sched_data *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); +@@ -99,7 +105,11 @@ static int nss_htb_class_params_validate + return -EINVAL; + } + +- qopt = nss_qdisc_qopt_get(opt, nss_htb_policy, TCA_NSSHTB_MAX, TCA_NSSHTB_CLASS_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_htb_policy, tb, TCA_NSSHTB_MAX, TCA_NSSHTB_CLASS_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_htb_policy, tb, TCA_NSSHTB_MAX, TCA_NSSHTB_CLASS_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -219,7 +229,7 @@ static struct nss_htb_class_data *nss_ht + * reference count should not be 0. + */ + cl->qdisc = &noop_qdisc; +- atomic_set(&cl->nq.refcnt, 1); ++ nss_qdisc_atomic_set(&cl->nq); + + return cl; + } +@@ -266,9 +276,16 @@ static int nss_htb_ppe_change_class(stru + * nss_htb_change_class() + * Configures a new class. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_htb_change_class(struct Qdisc *sch, u32 classid, u32 parentid, + struct nlattr **tca, unsigned long *arg) + { ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_htb_change_class(struct Qdisc *sch, u32 classid, u32 parentid, ++ struct nlattr **tca, unsigned long *arg, struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_htb_sched_data *q = qdisc_priv(sch); + struct nss_htb_class_data *cl = (struct nss_htb_class_data *)*arg; + struct nss_htb_class_data *parent; +@@ -282,7 +299,11 @@ static int nss_htb_change_class(struct Q + + nss_qdisc_trace("configuring htb class %x of qdisc %x\n", classid, sch->handle); + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_htb_class_params_validate_and_save(sch, tca, ¶m) < 0) { ++#else ++ if (nss_htb_class_params_validate_and_save(sch, tca, ¶m, extack) < 0) { ++#endif + nss_qdisc_warning("validation of configuration parameters for htb class %x failed\n", + sch->handle); + return -EINVAL; +@@ -332,7 +353,8 @@ static int nss_htb_change_class(struct Q + * here. + */ + cl->nq.parent = nq_parent; +- if (nss_qdisc_init(sch, &cl->nq, NSS_SHAPER_NODE_TYPE_HTB_GROUP, classid, accel_mode) < 0) { ++ if (nss_qdisc_init(sch, &cl->nq, NSS_SHAPER_NODE_TYPE_HTB_GROUP, classid, accel_mode, extack) < 0) ++ { + nss_qdisc_error("nss_init for htb class %x failed\n", classid); + goto failure; + } +@@ -478,7 +500,7 @@ static void nss_htb_destroy_class(struct + /* + * And now we destroy the child. + */ +- qdisc_destroy(cl->qdisc); ++ nss_qdisc_put(cl->qdisc); /* -+ * Stop the stats polling timer and free class -+ */ -+ nss_qdisc_stop_basic_stats_polling(&cl->nq); -+ -+ /* - * Destroy the shaper in NSS - */ - nss_qdisc_destroy(&cl->nq); -@@ -516,7 +522,11 @@ static void nss_htb_destroy_class(struct + * Stop the stats polling timer and free class +@@ -500,7 +522,11 @@ static void nss_htb_destroy_class(struct * nss_htb_delete_class() * Detaches a class from operation, but does not destroy it. */ @@ -6675,349 +4795,815 @@ { struct nss_htb_sched_data *q = qdisc_priv(sch); struct nss_htb_class_data *cl = (struct nss_htb_class_data *)arg; -@@ -524,12 +534,10 @@ static int nss_htb_delete_class(struct Q - int refcnt; - - /* -- * If the class still has child nodes or qdiscs, then we do not -+ * If the class still has child nodes, then we do not - * support deleting it. - */ -- if ((cl->children) || (cl->qdisc != &noop_qdisc)) { -- nss_qdisc_warning("Cannot delete htb class %x with child nodes " -- "or qdisc attached\n", cl->nq.qos_tag); -+ if (cl->children) { - return -EBUSY; - } - -@@ -560,21 +568,16 @@ static int nss_htb_delete_class(struct Q - } - - sch_tree_lock(sch); -+ qdisc_reset(cl->qdisc); - qdisc_class_hash_remove(&q->clhash, &cl->sch_common); - - /* - * If we are root class, we dont have to update our parent. +@@ -550,7 +576,7 @@ static int nss_htb_delete_class(struct Q * We simply deduct refcnt and return. -- * For 5.4 and above kernels, calling nss_htb_destroy_class -- * explicitly as there is no put_class which would have called -- * nss_htb_destroy_class when refcnt becomes zero. */ if (!cl->parent) { - refcnt = nss_qdisc_atomic_sub_return(&cl->nq); +- refcnt = atomic_sub_return(1, &cl->nq.refcnt); ++ refcnt = nss_qdisc_atomic_sub_return(&cl->nq); sch_tree_unlock(sch); --#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)) -- nss_htb_destroy_class(sch, cl); --#endif + return 0; + } +@@ -567,7 +593,7 @@ static int nss_htb_delete_class(struct Q + /* + * Decrement refcnt and return + */ +- refcnt = atomic_sub_return(1, &cl->nq.refcnt); ++ refcnt = nss_qdisc_atomic_sub_return(&cl->nq); + sch_tree_unlock(sch); + + return 0; +@@ -577,7 +603,12 @@ static int nss_htb_delete_class(struct Q + * nss_htb_graft_class() + * Replaces the qdisc attached to the provided class. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_htb_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, struct Qdisc **old) ++#else ++static int nss_htb_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, struct Qdisc **old, ++ struct netlink_ext_ack *extack) ++#endif + { + struct nss_htb_class_data *cl = (struct nss_htb_class_data *)arg; + struct nss_if_msg nim_detach; +@@ -664,6 +695,7 @@ static void nss_htb_qlen_notify(struct Q + */ + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + /* + * nss_htb_get_class() + * Fetches the class pointer if provided the classid. +@@ -695,10 +727,22 @@ static void nss_htb_put_class(struct Qdi + * We are safe to destroy the qdisc if the reference count + * goes down to 0. + */ +- if (atomic_sub_return(1, &cl->nq.refcnt) == 0) { ++ if (nss_qdisc_atomic_sub_return(&cl->nq) == 0) { + nss_htb_destroy_class(sch, cl); + } + } ++#else ++/* ++ * nss_htb_search_class() ++ * Fetches the class pointer if provided the classid. ++ */ ++static unsigned long nss_htb_search_class(struct Qdisc *sch, u32 classid) ++{ ++ struct nss_htb_class_data *cl = nss_htb_find_class(classid, sch); ++ ++ return (unsigned long)cl; ++} ++#endif + + /* + * nss_htb_dump_class() +@@ -728,8 +772,7 @@ static int nss_htb_dump_class(struct Qdi + tcm->tcm_handle = cl->sch_common.classid; + tcm->tcm_info = cl->qdisc->handle; + +- opts = nla_nest_start(skb, TCA_OPTIONS); +- ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL || nla_put(skb, TCA_NSSHTB_CLASS_PARMS, sizeof(qopt), &qopt)) { + goto nla_put_failure; + } +@@ -750,7 +793,7 @@ static int nss_htb_dump_class_stats(stru + { + struct nss_qdisc *nq = (struct nss_qdisc *)arg; + +- if (nss_qdisc_gnet_stats_copy_basic(d, &nq->bstats) < 0 || ++ if (nss_qdisc_gnet_stats_copy_basic(sch, d, &nq->bstats) < 0 || + nss_qdisc_gnet_stats_copy_queue(d, &nq->qstats) < 0) { + nss_qdisc_error("htb class %x stats dump failed\n", nq->qos_tag); + return -1; +@@ -795,9 +838,15 @@ static void nss_htb_walk(struct Qdisc *s + * nss_htb_change_qdisc() + * Can be used to configure a htb qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_htb_change_qdisc(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_htb_change_qdisc(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++#endif + { + struct nss_htb_sched_data *q = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSHTB_MAX + 1]; + struct tc_nsshtb_qopt *qopt; + + /* +@@ -820,7 +869,11 @@ static int nss_htb_change_qdisc(struct Q + /* + * If it is not NULL, parse to get qopt. + */ +- qopt = nss_qdisc_qopt_get(opt, nss_htb_policy, TCA_NSSHTB_MAX, TCA_NSSHTB_QDISC_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_htb_policy, tb, TCA_NSSHTB_MAX, TCA_NSSHTB_QDISC_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_htb_policy, tb, TCA_NSSHTB_MAX, TCA_NSSHTB_QDISC_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -895,7 +948,7 @@ static void nss_htb_destroy_qdisc(struct + * Reduce refcnt by 1 before destroying. This is to + * ensure that polling of stat stops properly. + */ +- atomic_sub(1, &cl->nq.refcnt); ++ nss_qdisc_atomic_sub(&cl->nq); + + /* + * We are not root class. Therefore we reduce the children count +@@ -945,9 +998,17 @@ static void nss_htb_destroy_qdisc(struct + * nss_htb_init_qdisc() + * Initializes the htb qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_htb_init_qdisc(struct Qdisc *sch, struct nlattr *opt) + { ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_htb_init_qdisc(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_htb_sched_data *q = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSHTB_MAX + 1]; + struct tc_nsshtb_qopt *qopt; + int err; + unsigned int accel_mode; +@@ -964,7 +1025,11 @@ static int nss_htb_init_qdisc(struct Qdi + if (!opt) { + accel_mode = TCA_NSS_ACCEL_MODE_PPE; + } else { +- qopt = nss_qdisc_qopt_get(opt, nss_htb_policy, TCA_NSSHTB_MAX, TCA_NSSHTB_QDISC_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_htb_policy, tb, TCA_NSSHTB_MAX, TCA_NSSHTB_QDISC_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_htb_policy, tb, TCA_NSSHTB_MAX, TCA_NSSHTB_QDISC_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -977,7 +1042,7 @@ static int nss_htb_init_qdisc(struct Qdi + /* + * Initialize the NSSHTB shaper in NSS + */ +- if (nss_qdisc_init(sch, &q->nq, NSS_SHAPER_NODE_TYPE_HTB, 0, accel_mode) < 0) { ++ if (nss_qdisc_init(sch, &q->nq, NSS_SHAPER_NODE_TYPE_HTB, 0, accel_mode, extack) < 0) { + nss_qdisc_error("failed to initialize htb qdisc %x in nss", sch->handle); + return -EINVAL; + } +@@ -987,7 +1052,11 @@ static int nss_htb_init_qdisc(struct Qdi + /* + * Tune HTB parameters + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_htb_change_qdisc(sch, opt) < 0) { ++#else ++ if (nss_htb_change_qdisc(sch, opt, extack) < 0) { ++#endif + nss_qdisc_destroy(&q->nq); + return -EINVAL; + } +@@ -1016,7 +1085,8 @@ static int nss_htb_dump_qdisc(struct Qdi + qopt.accel_mode = nss_qdisc_accel_mode_get(&q->nq); + + nss_qdisc_info("r2q = %u accel_mode = %u", qopt.r2q, qopt.accel_mode); +- opts = nla_nest_start(skb, TCA_OPTIONS); ++ ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); + if (!opts || nla_put(skb, TCA_NSSHTB_QDISC_PARMS, sizeof(qopt), &qopt)) { + goto nla_put_failure; + } +@@ -1032,9 +1102,18 @@ static int nss_htb_dump_qdisc(struct Qdi + * nss_htb_enqueue() + * Enqueues a skb to htb qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static int nss_htb_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++#else ++static int nss_htb_enqueue(struct sk_buff *skb, struct Qdisc *sch, ++ struct sk_buff **to_free) ++#endif + { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + return nss_qdisc_enqueue(skb, sch); ++#else ++ return nss_qdisc_enqueue(skb, sch, to_free); ++#endif + } + + /* +@@ -1046,6 +1125,7 @@ static struct sk_buff *nss_htb_dequeue(s + return nss_qdisc_dequeue(sch); + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + /* + * nss_htb_drop() + * Drops a single skb from linux queue, if not empty. +@@ -1057,6 +1137,7 @@ static unsigned int nss_htb_drop(struct + nss_qdisc_trace("drop called on htb qdisc %x\n", sch->handle); + return nss_qdisc_drop(sch); + } ++#endif + + /* + * Registration structure for htb class +@@ -1067,9 +1148,17 @@ const struct Qdisc_class_ops nss_htb_cla + .graft = nss_htb_graft_class, + .leaf = nss_htb_leaf_class, + .qlen_notify = nss_htb_qlen_notify, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + .get = nss_htb_get_class, + .put = nss_htb_put_class, ++#else ++ .find = nss_htb_search_class, ++#endif ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + .tcf_chain = nss_qdisc_tcf_chain, ++#else ++ .tcf_block = nss_qdisc_tcf_block, ++#endif + .bind_tcf = nss_qdisc_tcf_bind, + .unbind_tcf = nss_qdisc_tcf_unbind, + .dump = nss_htb_dump_class, +@@ -1090,7 +1179,9 @@ struct Qdisc_ops nss_htb_qdisc_ops __rea + .enqueue = nss_htb_enqueue, + .dequeue = nss_htb_dequeue, + .peek = qdisc_peek_dequeued, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_htb_drop, ++#endif + .cl_ops = &nss_htb_class_ops, + .priv_size = sizeof(struct nss_htb_sched_data), + .owner = THIS_MODULE +--- a/nss_qdisc/nss_ppe.c ++++ b/nss_qdisc/nss_ppe.c +@@ -1773,7 +1773,7 @@ int nss_ppe_set_parent(struct Qdisc *sch + struct net_device *dev = qdisc_dev(sch); + struct nss_qdisc *parent_nq = NULL; + struct Qdisc *parent_qdisc = NULL; +- unsigned long parent_class; ++ unsigned long parent_class = 0; + + /* + * PPE Qdisc cannot be attached to NSS Qdisc. +@@ -1812,8 +1812,11 @@ int nss_ppe_set_parent(struct Qdisc *sch + return NSS_PPE_QDISC_PARENT_NOT_EXISTING; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + parent_class = parent_qdisc->ops->cl_ops->get(parent_qdisc, parent); +- ++#else ++ parent_class = parent_qdisc->ops->cl_ops->find(parent_qdisc, parent); ++#endif + if (!parent_class) { + nq->parent = NULL; + nss_qdisc_info("HW qdisc/class %px cannot be attached to non-existing class %x\n", nq->qdisc, parent); +@@ -1822,7 +1825,9 @@ int nss_ppe_set_parent(struct Qdisc *sch + } + + nq->parent = (struct nss_qdisc *)parent_class; ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + parent_qdisc->ops->cl_ops->put(parent_qdisc, parent_class); ++#endif + } + } + +@@ -2200,14 +2205,22 @@ fail: + * nss_ppe_fallback_to_nss() + * Calls the initialization of NSS Qdisc when PPE initialization fails. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + int nss_ppe_fallback_to_nss(struct nss_qdisc *nq, struct nlattr *opt) ++#else ++int nss_ppe_fallback_to_nss(struct nss_qdisc *nq, struct nlattr *opt, struct netlink_ext_ack *extack) ++#endif + { + nss_qdisc_destroy(nq); + + memset(&nq->npq, 0, sizeof(struct nss_ppe_qdisc)); + nq->ppe_init_failed = true; + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nq->qdisc->ops->init(nq->qdisc, opt) < 0) { ++#else ++ if (nq->qdisc->ops->init(nq->qdisc, opt, extack) < 0) { ++#endif + nss_qdisc_warning("Fallback to NSS Qdisc failed.\n"); + return -EINVAL; + } +--- a/nss_qdisc/nss_ppe.h ++++ b/nss_qdisc/nss_ppe.h +@@ -269,7 +269,11 @@ extern int nss_ppe_configure(struct nss_ + * nss_ppe_fallback_to_nss() + * Calls the initialization of NSS Qdisc when PPE initialization fails. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + extern int nss_ppe_fallback_to_nss(struct nss_qdisc *nq, struct nlattr *opt); ++#else ++extern int nss_ppe_fallback_to_nss(struct nss_qdisc *nq, struct nlattr *opt, struct netlink_ext_ack *extack); ++#endif + + /* + * nss_ppe_destroy() +--- a/nss_qdisc/nss_prio.c ++++ b/nss_qdisc/nss_prio.c +@@ -37,9 +37,18 @@ static struct nla_policy nss_prio_policy + * nss_prio_enqueue() + * Enqueues a skb to nssprio qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static int nss_prio_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++#else ++static int nss_prio_enqueue(struct sk_buff *skb, struct Qdisc *sch, ++ struct sk_buff **to_free) ++#endif + { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + return nss_qdisc_enqueue(skb, sch); ++#else ++ return nss_qdisc_enqueue(skb, sch, to_free); ++#endif + } + + /* +@@ -51,6 +60,7 @@ static struct sk_buff *nss_prio_dequeue( + return nss_qdisc_dequeue(sch); + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + /* + * nss_prio_drop() + * Drops a single skb from linux queue, if not empty. +@@ -61,6 +71,7 @@ static unsigned int nss_prio_drop(struct + { + return nss_qdisc_drop(sch); + } ++#endif + + /* + * nss_prio_peek() +@@ -117,7 +128,11 @@ static void nss_prio_destroy(struct Qdis + /* + * We can now destroy it + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)) + qdisc_destroy(q->queues[i]); ++#else ++ qdisc_put(q->queues[i]); ++#endif + } + + /* +@@ -157,8 +172,14 @@ static int nss_prio_get_max_bands(struct + * nss_prio_change() + * Function call to configure the nssprio parameters + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_prio_change(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_prio_change(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++#endif + { ++ struct nlattr *tb[TCA_NSSPRIO_MAX + 1]; + struct nss_prio_sched_data *q; + struct tc_nssprio_qopt *qopt; + +@@ -180,7 +201,11 @@ static int nss_prio_change(struct Qdisc return 0; } -@@ -593,14 +596,6 @@ static int nss_htb_delete_class(struct Q - refcnt = nss_qdisc_atomic_sub_return(&cl->nq); - sch_tree_unlock(sch); - -- /* -- * For 5.4 and above kernels, calling nss_htb_destroy_class -- * explicitly as there is no put_class which would have called -- * nss_htb_destroy_class when refcnt becomes zero. -- */ --#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)) -- nss_htb_destroy_class(sch, cl); --#endif - return 0; - } - -@@ -903,11 +898,6 @@ static int nss_htb_change_qdisc(struct Q +- qopt = nss_qdisc_qopt_get(opt, nss_prio_policy, TCA_NSSPRIO_MAX, TCA_NSSPRIO_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_prio_policy, tb, TCA_NSSPRIO_MAX, TCA_NSSPRIO_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_prio_policy, tb, TCA_NSSPRIO_MAX, TCA_NSSPRIO_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -209,9 +234,17 @@ static int nss_prio_change(struct Qdisc + * nss_prio_init() + * Initializes the nssprio qdisc */ - static void nss_htb_reset_class(struct nss_htb_class_data *cl) ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_prio_init(struct Qdisc *sch, struct nlattr *opt) { -- if (cl->qdisc == &noop_qdisc) { -- nss_qdisc_trace("Class %x has no child qdisc to reset\n", cl->nq.qos_tag); -- return; -- } -- - nss_qdisc_reset(cl->qdisc); - nss_qdisc_trace("htb class %x reset\n", cl->nq.qos_tag); - } -@@ -991,6 +981,11 @@ static void nss_htb_destroy_qdisc(struct - qdisc_class_hash_destroy(&q->clhash); ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_prio_init(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_prio_sched_data *q = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSPRIO_MAX + 1]; + struct tc_nssprio_qopt *qopt; + int i; + unsigned int accel_mode; +@@ -223,21 +256,30 @@ static int nss_prio_init(struct Qdisc *s + if (!opt) { + accel_mode = TCA_NSS_ACCEL_MODE_PPE; + } else { +- qopt = nss_qdisc_qopt_get(opt, nss_prio_policy, TCA_NSSPRIO_MAX, TCA_NSSPRIO_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_prio_policy, tb, TCA_NSSPRIO_MAX, TCA_NSSPRIO_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_prio_policy, tb, TCA_NSSPRIO_MAX, TCA_NSSPRIO_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } + accel_mode = qopt->accel_mode; + } - /* -+ * Stop the polling of basic stats -+ */ -+ nss_qdisc_stop_basic_stats_polling(&q->nq); -+ -+ /* - * Now we can go ahead and destroy the qdisc. - * Note: We dont have to detach ourself from our parent because this - * will be taken care of by the graft call. -@@ -1066,6 +1061,11 @@ static int nss_htb_init_qdisc(struct Qdi +- if (nss_qdisc_init(sch, &q->nq, NSS_SHAPER_NODE_TYPE_PRIO, 0, accel_mode) < 0) { ++ if (nss_qdisc_init(sch, &q->nq, NSS_SHAPER_NODE_TYPE_PRIO, 0, accel_mode, extack) < 0) ++ { return -EINVAL; } -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(&q->nq); -+ - return 0; + nss_qdisc_info("Nssprio initialized - handle %x parent %x\n", + sch->handle, sch->parent); + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_prio_change(sch, opt) < 0) { ++#else ++ if (nss_prio_change(sch, opt, extack) < 0) { ++#endif + nss_qdisc_destroy(&q->nq); + return -EINVAL; + } +@@ -263,7 +305,7 @@ static int nss_prio_dump(struct Qdisc *s + qopt.bands = q->bands; + qopt.accel_mode = nss_qdisc_accel_mode_get(&q->nq); + +- opts = nla_nest_start(skb, TCA_OPTIONS); ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL || nla_put(skb, TCA_NSSPRIO_PARMS, sizeof(qopt), &qopt)) { + goto nla_put_failure; + } +@@ -279,8 +321,14 @@ nla_put_failure: + * nss_prio_graft() + * Replaces existing child qdisc with the new qdisc that is passed. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_prio_graft(struct Qdisc *sch, unsigned long arg, + struct Qdisc *new, struct Qdisc **old) ++#else ++static int nss_prio_graft(struct Qdisc *sch, unsigned long arg, ++ struct Qdisc *new, struct Qdisc **old, ++ struct netlink_ext_ack *extack) ++#endif + { + struct nss_prio_sched_data *q = qdisc_priv(sch); + struct nss_qdisc *nq_new = qdisc_priv(new); +@@ -365,6 +413,7 @@ static struct Qdisc *nss_prio_leaf(struc + return q->queues[band]; } ---- a/nss_qdisc/nss_ppe.c -+++ b/nss_qdisc/nss_ppe.c -@@ -1,8 +1,6 @@ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) /* - ************************************************************************** - * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. -- * -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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. -@@ -128,7 +126,7 @@ static struct nss_ppe_res *nss_ppe_res_e + * nss_prio_get() + * Returns the band if provided the classid. +@@ -390,6 +439,24 @@ static void nss_prio_put(struct Qdisc *s + { + nss_qdisc_info("Inside prio put\n"); + } ++#else ++/* ++ * nss_prio_search() ++ * Returns the band if provided the classid. ++ */ ++static unsigned long nss_prio_search(struct Qdisc *sch, u32 classid) ++{ ++ struct nss_prio_sched_data *q = qdisc_priv(sch); ++ unsigned long band = TC_H_MIN(classid); ++ ++ nss_qdisc_info("Inside get. Handle - %x Classid - %x Band %lu Available band %u\n", sch->handle, classid, band, q->bands); ++ ++ if (band > q->bands) ++ return 0; ++ ++ return band; ++} ++#endif - spin_lock_bh(&ppe_port->lock); - for (i = max; i > 0; i--) { -- res = kzalloc(sizeof(struct nss_ppe_res), GFP_ATOMIC); -+ res = kzalloc(sizeof(struct nss_ppe_res), GFP_KERNEL); - if (!res) { - nss_qdisc_error("Free queue list allocation failed for port %u\n", port); - goto fail; ---- a/nss_qdisc/nss_prio.c -+++ b/nss_qdisc/nss_prio.c + /* + * nss_prio_walk() +@@ -446,7 +513,7 @@ static int nss_prio_dump_class_stats(str + cl_q = q->queues[cl - 1]; + cl_q->qstats.qlen = cl_q->q.qlen; + +- if (nss_qdisc_gnet_stats_copy_basic(d, &cl_q->bstats) < 0 || ++ if (nss_qdisc_gnet_stats_copy_basic(sch, d, &cl_q->bstats) < 0 || + nss_qdisc_gnet_stats_copy_queue(d, &cl_q->qstats) < 0) + return -1; + +@@ -460,9 +527,17 @@ static int nss_prio_dump_class_stats(str + const struct Qdisc_class_ops nss_prio_class_ops = { + .graft = nss_prio_graft, + .leaf = nss_prio_leaf, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + .get = nss_prio_get, + .put = nss_prio_put, ++#else ++ .find = nss_prio_search, ++#endif ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + .tcf_chain = nss_qdisc_tcf_chain, ++#else ++ .tcf_block = nss_qdisc_tcf_block, ++#endif + .bind_tcf = nss_qdisc_tcf_bind, + .unbind_tcf = nss_qdisc_tcf_unbind, + .walk = nss_prio_walk, +@@ -481,7 +556,9 @@ struct Qdisc_ops nss_prio_qdisc_ops __re + .enqueue = nss_prio_enqueue, + .dequeue = nss_prio_dequeue, + .peek = nss_prio_peek, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_prio_drop, ++#endif + .init = nss_prio_init, + .reset = nss_prio_reset, + .destroy = nss_prio_destroy, +--- a/nss_qdisc/nss_qdisc.c ++++ b/nss_qdisc/nss_qdisc.c @@ -1,6 +1,6 @@ /* ************************************************************************** -- * Copyright (c) 2014-2017, 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2017, 2019-2020, The Linux Foundation. All rights reserved. +- * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014-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. -@@ -136,6 +136,11 @@ static void nss_prio_destroy(struct Qdis - } - - /* -+ * Stop the polling of basic stats -+ */ -+ nss_qdisc_stop_basic_stats_polling(&q->nq); -+ -+ /* - * Destroy the qdisc in NSS +@@ -927,7 +927,11 @@ static inline void nss_qdisc_add_to_tail + * We do not use the qdisc_enqueue_tail() API here in order + * to prevent stats from getting updated by the API. */ - nss_qdisc_destroy(&q->nq); -@@ -279,6 +284,10 @@ static int nss_prio_init(struct Qdisc *s - return -EINVAL; ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + __skb_queue_tail(&sch->q, skb); ++#else ++ __qdisc_enqueue_tail(skb, &sch->q); ++#endif + + spin_unlock_bh(&nq->bounce_protection_lock); + }; +@@ -942,7 +946,11 @@ static inline void nss_qdisc_add_to_tail + * We do not use the qdisc_enqueue_tail() API here in order + * to prevent stats from getting updated by the API. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + __skb_queue_tail(&sch->q, skb); ++#else ++ __qdisc_enqueue_tail(skb, &sch->q); ++#endif + }; + + /* +@@ -964,10 +972,12 @@ static inline struct sk_buff *nss_qdisc_ + * We use __skb_dequeue() to ensure that + * stats don't get updated twice. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) + skb = __skb_dequeue(&sch->q); +- ++#else ++ skb = __qdisc_dequeue_head(&sch->q); ++#endif + spin_unlock_bh(&nq->bounce_protection_lock); +- + return skb; + }; + +@@ -981,7 +991,11 @@ static inline struct sk_buff *nss_qdisc_ + * We use __skb_dequeue() to ensure that + * stats don't get updated twice. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) + return __skb_dequeue(&sch->q); ++#else ++ return __qdisc_dequeue_head(&sch->q); ++#endif + }; + + /* +@@ -1059,24 +1073,33 @@ struct Qdisc *nss_qdisc_replace(struct Q + * nss_qdisc_qopt_get() + * Extracts qopt from opt. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++void *nss_qdisc_qopt_get(struct nlattr *opt, struct nla_policy *policy, ++ struct nlattr *tb[], uint32_t tca_max, uint32_t tca_params) ++#else + void *nss_qdisc_qopt_get(struct nlattr *opt, struct nla_policy *policy, +- uint32_t tca_max, uint32_t tca_params) ++ struct nlattr *tb[], uint32_t tca_max, uint32_t tca_params, struct netlink_ext_ack *extack) ++#endif + { +- struct nlattr *na[tca_max + 1]; + int err; + + if (!opt) { + return NULL; } -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(&q->nq); - return 0; +- err = nla_parse_nested(na, tca_max, opt, policy); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ err = nla_parse_nested(tb, tca_max, opt, policy); ++#else ++ err = nla_parse_nested_deprecated(tb, tca_max, opt, policy, extack); ++#endif ++ + if (err < 0) + return NULL; + +- if (na[tca_params] == NULL) ++ if (tb[tca_params] == NULL) + return NULL; + +- return nla_data(na[tca_params]); ++ return nla_data(tb[tca_params]); } ---- a/nss_qdisc/nss_qdisc.c -+++ b/nss_qdisc/nss_qdisc.c -@@ -29,6 +29,9 @@ - - void *nss_qdisc_ctx; /* Shaping context for nss_qdisc */ - -+#define NSS_QDISC_COMMAND_TIMEOUT (10*HZ) /* We set 10sec to be the command */ -+ /* timeout value for messages */ -+ /* - * Defines related to root hash maintenance - */ -@@ -36,53 +39,6 @@ void *nss_qdisc_ctx; /* Shaping contex - #define NSS_QDISC_ROOT_HASH_MASK (NSS_QDISC_ROOT_HASH_SIZE - 1) +@@ -1102,16 +1125,17 @@ struct sk_buff *nss_qdisc_peek(struct Qd + struct sk_buff *skb; - /* -- * nss_qdisc_get_interface_msg() -- * Returns the correct message that needs to be sent down to the NSS interface. -- */ --int nss_qdisc_get_interface_msg(bool is_bridge, uint32_t msg_type) --{ -- /* -- * We re-assign the message based on whether this is for the I shaper -- * or the B shaper. The is_bridge flag tells if we are on a bridge interface. -- */ -- if (is_bridge) { -- switch (msg_type) { -- case NSS_QDISC_IF_SHAPER_ASSIGN: -- return NSS_IF_BSHAPER_ASSIGN; -- case NSS_QDISC_IF_SHAPER_UNASSIGN: -- return NSS_IF_BSHAPER_UNASSIGN; -- case NSS_QDISC_IF_SHAPER_CONFIG: -- return NSS_IF_BSHAPER_CONFIG; -- default: -- nss_qdisc_info("Unknown message type for a bridge - type %d", msg_type); -- return -1; -- } -- } else { -- switch (msg_type) { -- case NSS_QDISC_IF_SHAPER_ASSIGN: -- return NSS_IF_ISHAPER_ASSIGN; -- case NSS_QDISC_IF_SHAPER_UNASSIGN: -- return NSS_IF_ISHAPER_UNASSIGN; -- case NSS_QDISC_IF_SHAPER_CONFIG: -- return NSS_IF_ISHAPER_CONFIG; -- default: -- nss_qdisc_info("Unknown message type for an interface - type %d", msg_type); -- return -1; -- } -- } --} -- --/* -- * nss_qdisc_msg_init() -- * Initialize the qdisc specific message -- */ --void nss_qdisc_msg_init(struct nss_if_msg *nim, uint16_t if_num, uint32_t msg_type, uint32_t len, -- nss_if_msg_callback_t cb, void *app_data) --{ -- nss_cmn_msg_init(&nim->cm, if_num, msg_type, len, (void *)cb, app_data); --} -- --/* - * nss_qdisc_interface_is_virtual() - * Return true if it is redirect or bridge interface. - */ -@@ -165,6 +121,53 @@ static int nss_qdisc_ppe_init(struct Qdi - #endif + if (!nq->is_virtual) { +- skb = skb_peek(&sch->q); ++ skb = qdisc_peek_head(sch); + } else { + spin_lock_bh(&nq->bounce_protection_lock); +- skb = skb_peek(&sch->q); ++ skb = qdisc_peek_head(sch); + spin_unlock_bh(&nq->bounce_protection_lock); + } - /* -+ * nss_qdisc_msg_init() -+ * Initialize the qdisc specific message -+ */ -+static void nss_qdisc_msg_init(struct nss_if_msg *nim, uint16_t if_num, uint32_t msg_type, uint32_t len, -+ nss_if_msg_callback_t cb, void *app_data) -+{ -+ nss_cmn_msg_init(&nim->cm, if_num, msg_type, len, (void*)cb, app_data); -+} -+ -+/* -+ * nss_qdisc_get_interface_msg() -+ * Returns the correct message that needs to be sent down to the NSS interface. -+ */ -+static inline int nss_qdisc_get_interface_msg(bool is_bridge, uint32_t msg_type) -+{ -+ /* -+ * We re-assign the message based on whether this is for the I shaper -+ * or the B shaper. The is_bridge flag tells if we are on a bridge interface. -+ */ -+ if (is_bridge) { -+ switch(msg_type) { -+ case NSS_QDISC_IF_SHAPER_ASSIGN: -+ return NSS_IF_BSHAPER_ASSIGN; -+ case NSS_QDISC_IF_SHAPER_UNASSIGN: -+ return NSS_IF_BSHAPER_UNASSIGN; -+ case NSS_QDISC_IF_SHAPER_CONFIG: -+ return NSS_IF_BSHAPER_CONFIG; -+ default: -+ nss_qdisc_info("Unknown message type for a bridge - type %d", msg_type); -+ return -1; -+ } -+ } else { -+ switch(msg_type) { -+ case NSS_QDISC_IF_SHAPER_ASSIGN: -+ return NSS_IF_ISHAPER_ASSIGN; -+ case NSS_QDISC_IF_SHAPER_UNASSIGN: -+ return NSS_IF_ISHAPER_UNASSIGN; -+ case NSS_QDISC_IF_SHAPER_CONFIG: -+ return NSS_IF_ISHAPER_CONFIG; -+ default: -+ nss_qdisc_info("Unknown message type for an interface - type %d", msg_type); -+ return -1; -+ } -+ } -+} -+ -+/* - * nss_qdisc_attach_bshaper_callback() - * Call back funtion for bridge shaper attach to an interface. - */ -@@ -609,6 +612,7 @@ static void nss_qdisc_root_cleanup_free_ - nss_qdisc_info("Root qdisc %px (type %d) free SUCCESS - response " - "type: %d\n", nq->qdisc, nq->type, - nim->msg.shaper_configure.config.response_type); -+ - nss_qdisc_root_cleanup_shaper_unassign(nq); + return skb; } -@@ -1162,15 +1166,8 @@ unsigned int nss_qdisc_drop(struct Qdisc - */ - void nss_qdisc_reset(struct Qdisc *sch) - { -- struct nss_qdisc *nq; -- -- if(!(sch->flags & TCQ_F_NSS)) { -- qdisc_reset_queue(sch); -- nss_qdisc_info("Qdisc %px resetting non NSS qdisc\n", sch); -- return; -- } -+ struct nss_qdisc *nq = qdisc_priv(sch); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + /* + * nss_qdisc_drop() + * Called to drop the packet at the head of queue +@@ -1134,6 +1158,7 @@ unsigned int nss_qdisc_drop(struct Qdisc -- nq = qdisc_priv(sch); - nss_qdisc_info("Qdisc %px (type %d) resetting\n", - sch, nq->type); + return ret; + } ++#endif -@@ -1209,10 +1206,10 @@ static bool nss_qdisc_iterate_fl(struct + /* + * nss_qdisc_reset() +@@ -1181,7 +1206,11 @@ static bool nss_qdisc_iterate_fl(struct return 0; } --#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) - status = tc_classify(skb, tcf, &res, false); --#else +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) - status = tcf_classify(skb, tcf, &res, false); ++ status = tcf_classify(skb, tcf, &res, false); +#else + status = tcf_classify(skb, NULL, tcf, &res, false); - #endif ++#endif if ((status == TC_ACT_STOLEN) || (status == TC_ACT_QUEUED)) { return 1; -@@ -1892,7 +1889,6 @@ int nss_qdisc_configure(struct nss_qdisc - return 0; + } +@@ -1203,7 +1232,11 @@ static bool nss_qdisc_iterate_fl(struct + * nss_qdisc_enqueue() + * Generic enqueue call for enqueuing packets into NSS for shaping + */ +-int nss_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) ++extern int nss_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++#else ++extern int nss_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free) ++#endif + { + struct nss_qdisc *nq = qdisc_priv(sch); + nss_tx_status_t status; +@@ -1263,11 +1296,18 @@ int nss_qdisc_enqueue(struct sk_buff *sk + /* + * Skip the shaping of already shaped packets. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + if (skb->tc_verd & TC_NCLS_NSS) { + skb->tc_verd = CLR_TC_NCLS_NSS(skb->tc_verd); + nss_qdisc_mark_and_schedule(nq->qdisc, skb); + return NET_XMIT_SUCCESS; + } ++#else ++ if (skb_skip_tc_classify_offload(skb)) { ++ nss_qdisc_mark_and_schedule(nq->qdisc, skb); ++ return NET_XMIT_SUCCESS; ++ } ++#endif + + if (!nq->is_virtual) { + /* +@@ -1316,12 +1356,15 @@ enqueue_drop: + * We were unable to transmit the packet for bridge shaping. + * We therefore drop it. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + kfree_skb(skb); + + spin_lock_bh(&nq->lock); + sch->qstats.drops++; + spin_unlock_bh(&nq->lock); +- ++#else ++ qdisc_drop(skb, sch, to_free); ++#endif + return NET_XMIT_DROP; + } + +@@ -1882,7 +1925,12 @@ void nss_qdisc_destroy(struct nss_qdisc + /* + * Destroy any attached filter over qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + tcf_destroy_chain(&nq->filter_list); ++#else ++ tcf_block_put(nq->block); ++#endif ++ + #if defined(NSS_QDISC_PPE_SUPPORT) + if (nq->mode == NSS_QDISC_MODE_PPE) { + nss_ppe_destroy(nq); +@@ -1960,12 +2008,19 @@ void nss_qdisc_destroy(struct nss_qdisc } -- /* - * nss_qdisc_register_configure_callback() - * Register shaper configure callback, which gets invoked on receiving a response. -@@ -1949,11 +1945,6 @@ void nss_qdisc_destroy(struct nss_qdisc - } +- * nss_qdisc_init() ++ * __nss_qdisc_init() + * Initializes a shaper in NSS, based on the position of this qdisc (child or root) + * and if its a normal interface or a bridge interface. + */ +-int nss_qdisc_init(struct Qdisc *sch, struct nss_qdisc *nq, nss_shaper_node_type_t type, uint32_t classid, uint32_t accel_mode) ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) ++int __nss_qdisc_init(struct Qdisc *sch, struct nss_qdisc *nq, nss_shaper_node_type_t type, uint32_t classid, uint32_t accel_mode) ++{ ++#else ++int __nss_qdisc_init(struct Qdisc *sch, struct nss_qdisc *nq, nss_shaper_node_type_t type, uint32_t classid, uint32_t accel_mode, ++ struct netlink_ext_ack *extack) + { ++ int err; ++#endif + struct Qdisc *root; + u32 parent; + nss_tx_status_t rc; +@@ -1978,7 +2033,6 @@ int nss_qdisc_init(struct Qdisc *sch, st + bool mode_ppe = false; + #endif + bool igs_put = false; +- + if (accel_mode >= TCA_NSS_ACCEL_MODE_MAX) { + nss_qdisc_warning("Qdisc %px (type %d) accel_mode:%u should be < %u\n", + sch, nq->type, accel_mode, TCA_NSS_ACCEL_MODE_MAX); +@@ -2037,8 +2091,9 @@ int nss_qdisc_init(struct Qdisc *sch, st + /* + * Initialize filter list. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + RCU_INIT_POINTER(nq->filter_list, NULL); +- ++#endif + /* + * If we are a class, then classid is used as the qos tag. + * Else the qdisc handle will be used as the qos tag. +@@ -2073,6 +2128,25 @@ int nss_qdisc_init(struct Qdisc *sch, st + * or on a net device that is represented by a virtual NSS interface (e.g. WIFI) + */ + dev = qdisc_dev(sch); ++ ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) ++ /* ++ * Currently filter addition is only supported over IFB interfaces. ++ * Therefore, perform tcf block allocation (which is used for storing ++ * filter list) only if the input net device is an IFB device. ++ */ ++ if (netif_is_ifb_dev(dev)) { ++ err = tcf_block_get(&nq->block, &nq->filter_list, sch, extack); ++ if (err) { ++ nss_qdisc_error("%px: Unable to initialize tcf_block\n", &nq->block); ++ return -1; ++ } ++ } else { ++ RCU_INIT_POINTER(nq->filter_list, NULL); ++ nq->block = NULL; ++ } ++#endif ++ + nss_qdisc_info("Qdisc %px (type %d) init dev: %px\n", nq->qdisc, nq->type, dev); /* -- * Delete node from stats list -- */ -- nss_qdisc_stats_qdisc_detach(nq); -- -- /* - * How we begin to tidy up depends on whether we are root or child - */ - nq->pending_final_state = NSS_QDISC_STATE_IDLE; -@@ -1972,11 +1963,6 @@ void nss_qdisc_destroy(struct nss_qdisc - } - - /* -- * Stop stats polling -- */ -- nss_qdisc_stats_stop_polling(nq); -- -- /* - * Begin by freeing the root shaper node - */ - nss_qdisc_root_cleanup_free_node(nq); -@@ -2129,8 +2115,6 @@ int __nss_qdisc_init(struct Qdisc *sch, - */ - if ((sch->parent == TC_H_ROOT) && (!nq->is_class)) { - nss_qdisc_info("Qdisc %px (type %d) is root\n", nq->qdisc, nq->type); -- nss_qdisc_info("Qdisc %px dev-name %s qdisc_dev(sch)->qdisc %px, qdisc_dev(sch)->qdisc->handle %x\n", qdisc_dev(sch), qdisc_dev(sch)->name, qdisc_dev(sch)->qdisc, qdisc_dev(sch)->qdisc->handle); -- nss_qdisc_info("Qdisc %px (sch %px) is root, sch->handle %x\n", nq->qdisc, sch, sch->handle); - nq->is_root = true; - root = sch; - } else { -@@ -2188,6 +2172,8 @@ int __nss_qdisc_init(struct Qdisc *sch, +@@ -2098,6 +2172,8 @@ int nss_qdisc_init(struct Qdisc *sch, st * This is to prevent mixing NSS and PPE qdisc with linux qdisc. */ if ((parent != TC_H_ROOT) && (root->ops->owner != THIS_MODULE)) { @@ -7026,35 +5612,7 @@ nss_qdisc_warning("NSS qdisc %px (type %d) used along with non-nss qdiscs," " or the interface is currently down", nq->qdisc, nq->type); } -@@ -2288,11 +2274,6 @@ int __nss_qdisc_init(struct Qdisc *sch, - * If state is positive, return success - */ - if (state > 0) { -- -- /* -- * Qdisc successfully initialized, add it to stats list if its not a class -- */ -- nss_qdisc_stats_qdisc_attach(nq); - return 0; - } - -@@ -2460,15 +2441,6 @@ int __nss_qdisc_init(struct Qdisc *sch, - goto init_fail; - } - #endif -- /* -- * Initialize the stats management only for root node -- */ -- if (!nss_qdisc_stats_sync_many_init(nq)) { -- nss_qdisc_error("Qdisc %px (type %d) stats sync init failed", nq->qdisc, nq->type); -- nss_shaper_unregister_shaping(nq->nss_shaping_ctx); -- atomic_set(&nq->state, NSS_QDISC_STATE_INIT_FAILED); -- goto init_fail; -- } - - /* - * Create and send the shaper assign message to the NSS interface -@@ -2498,7 +2470,7 @@ int __nss_qdisc_init(struct Qdisc *sch, +@@ -2394,7 +2470,7 @@ int nss_qdisc_init(struct Qdisc *sch, st if (igs_put) { nss_igs_module_put(); } @@ -7063,491 +5621,853 @@ return -1; } -@@ -2509,16 +2481,6 @@ int __nss_qdisc_init(struct Qdisc *sch, - if (state > 0) { - - /* -- * Qdisc successfully initialized add it to stats list if its not a class -- */ -- nss_qdisc_stats_qdisc_attach(nq); -- -- /* -- * Root node is successfully configured, start stats polling -- */ -- nss_qdisc_stats_start_polling(nq); -- -- /* - * Return if this is not a root qdisc on a bridge interface. - */ - if (!nq->is_root || !nq->is_bridge) { -@@ -2559,14 +2521,6 @@ init_fail: - } - #endif - -- -- /* -- * Clean up stats sync objects if initialized. -- */ -- if (nq->stats_wq) { -- nss_qdisc_stats_sync_many_exit(nq); -- } -- - /* - * Destroy any virtual interfaces created by us before returning a failure. - */ -@@ -2601,6 +2555,210 @@ int nss_qdisc_init(struct Qdisc *sch, st +@@ -2465,6 +2541,20 @@ init_fail: } /* -+ * nss_qdisc_basic_stats_callback() -+ * Invoked after getting basic stats ++ * nss_qdisc_init() ++ * Initialize nss qdisc based on position of the qdisc + */ -+static void nss_qdisc_basic_stats_callback(void *app_data, -+ struct nss_if_msg *nim) ++int nss_qdisc_init(struct Qdisc *sch, struct nss_qdisc *nq, nss_shaper_node_type_t type, uint32_t classid, ++ uint32_t accel_mode, void *extack) +{ -+ struct nss_qdisc *nq = (struct nss_qdisc *)app_data; -+ struct Qdisc *qdisc = nq->qdisc; -+ struct gnet_stats_basic_packed *bstats; -+ struct gnet_stats_queue *qstats; -+ struct nss_shaper_node_stats_response *response; -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)) -+ atomic_t *refcnt; ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) ++ return __nss_qdisc_init(sch, nq, type, classid, accel_mode); +#else -+ refcount_t *refcnt; ++ return __nss_qdisc_init(sch, nq, type, classid, accel_mode, extack); +#endif -+ -+ if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { -+ nss_qdisc_warning("Qdisc %px (type %d): Receive stats FAILED - " -+ "response: type: %d\n", qdisc, nq->type, -+ nim->msg.shaper_configure.config.response_type); -+ atomic_sub(1, &nq->pending_stat_requests); -+ wake_up(&nq->wait_queue); -+ return; -+ } -+ -+ response = &nim->msg.shaper_configure.config.msg.shaper_node_stats_get.response; -+ -+ /* -+ * Get the right stats pointers based on whether it is a class -+ * or a qdisc. -+ */ -+ if (nq->is_class) { -+ bstats = &nq->bstats; -+ qstats = &nq->qstats; -+ refcnt = &nq->refcnt; -+ } else { -+ bstats = &qdisc->bstats; -+ qstats = &qdisc->qstats; -+ refcnt = &qdisc->refcnt; -+ qdisc->q.qlen = response->sn_stats.qlen_packets; -+ } -+ -+ /* -+ * Update qdisc->bstats -+ */ -+ spin_lock_bh(&nq->lock); -+ bstats->bytes += (__u64)response->sn_stats.delta.dequeued_bytes; -+ bstats->packets += response->sn_stats.delta.dequeued_packets; -+ -+ /* -+ * Update qdisc->qstats -+ */ -+ qstats->backlog = response->sn_stats.qlen_bytes; -+ -+ qstats->drops += (response->sn_stats.delta.enqueued_packets_dropped + -+ response->sn_stats.delta.dequeued_packets_dropped); -+ -+ /* -+ * Update qdisc->qstats -+ */ -+ qstats->qlen = response->sn_stats.qlen_packets; -+ qstats->requeues = 0; -+ qstats->overlimits += response->sn_stats.delta.queue_overrun; -+ spin_unlock_bh(&nq->lock); -+ -+ /* -+ * Shapers that maintain additional unique statistics will process them -+ * via a registered callback. So invoke if its been registered. -+ */ -+ if (nq->stats_cb) { -+ nq->stats_cb(nq, response); -+ } -+ -+ /* -+ * All access to nq fields below do not need lock protection. They -+ * do not get manipulated on different thread contexts. -+ */ -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)) -+ if (atomic_read(refcnt) == 0) { -+#else -+ if (refcount_read(refcnt) == 0) { -+#endif -+ atomic_sub(1, &nq->pending_stat_requests); -+ wake_up(&nq->wait_queue); -+ return; -+ } -+ -+ /* -+ * Requests for stats again, after 1 sec. -+ */ -+ nq->stats_get_timer.expires += HZ; -+ if (nq->stats_get_timer.expires <= jiffies) { -+ nss_qdisc_info("losing time %lu, jiffies = %lu\n", -+ nq->stats_get_timer.expires, jiffies); -+ nq->stats_get_timer.expires = jiffies + HZ; -+ } -+ add_timer(&nq->stats_get_timer); +} + +/* -+ * nss_qdisc_get_stats_timer_callback() -+ * Invoked periodically to get updated stats -+ */ + * nss_qdisc_basic_stats_callback() + * Invoked after getting basic stats + */ +@@ -2476,7 +2566,11 @@ static void nss_qdisc_basic_stats_callba + struct gnet_stats_basic_packed *bstats; + struct gnet_stats_queue *qstats; + struct nss_shaper_node_stats_response *response; ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)) + atomic_t *refcnt; ++#else ++ refcount_t *refcnt; ++#endif + + if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { + nss_qdisc_warning("Qdisc %px (type %d): Receive stats FAILED - " +@@ -2539,7 +2633,11 @@ static void nss_qdisc_basic_stats_callba + * All access to nq fields below do not need lock protection. They + * do not get manipulated on different thread contexts. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)) + if (atomic_read(refcnt) == 0) { ++#else ++ if (refcount_read(refcnt) == 0) { ++#endif + atomic_sub(1, &nq->pending_stat_requests); + wake_up(&nq->wait_queue); + return; +@@ -2561,9 +2659,18 @@ static void nss_qdisc_basic_stats_callba + * nss_qdisc_get_stats_timer_callback() + * Invoked periodically to get updated stats + */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)) -+static void nss_qdisc_get_stats_timer_callback(unsigned long int data) + static void nss_qdisc_get_stats_timer_callback(unsigned long int data) +#else +static void nss_qdisc_get_stats_timer_callback(struct timer_list *tm) +#endif -+{ + { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)) -+ struct nss_qdisc *nq = (struct nss_qdisc *)data; + struct nss_qdisc *nq = (struct nss_qdisc *)data; +#else + struct nss_qdisc *nq = from_timer(nq, tm, stats_get_timer); +#endif + -+ nss_tx_status_t rc; -+ struct nss_if_msg nim; -+ int msg_type; -+ -+ /* -+ * Create and send the shaper configure message to the NSS interface -+ */ -+ msg_type = nss_qdisc_get_interface_msg(nq->is_bridge, NSS_QDISC_IF_SHAPER_CONFIG); -+ nss_qdisc_msg_init(&nim, nq->nss_interface_number, msg_type, sizeof(struct nss_if_shaper_configure), -+ nss_qdisc_basic_stats_callback, -+ nq); -+ nim.msg.shaper_configure.config.request_type = NSS_SHAPER_CONFIG_TYPE_SHAPER_NODE_BASIC_STATS_GET; -+ nim.msg.shaper_configure.config.msg.shaper_node_stats_get.qos_tag = nq->qos_tag; -+ rc = nss_if_tx_msg(nq->nss_shaping_ctx, &nim); -+ -+ /* -+ * Check if we failed to send the stats request to NSS. -+ */ -+ if (rc != NSS_TX_SUCCESS) { -+ nss_qdisc_info("%px: stats fetch request dropped, causing " -+ "delay in stats fetch\n", nq->qdisc); -+ -+ /* -+ * Schedule the timer once again for re-trying. Since this is a -+ * re-try we schedule it 100ms from now, instead of a whole second. -+ */ -+ nq->stats_get_timer.expires = jiffies + HZ/10; -+ add_timer(&nq->stats_get_timer); -+ } -+} -+ -+/* -+ * nss_qdisc_start_basic_stats_polling() -+ * Call to initiate the stats polling timer -+ */ -+void nss_qdisc_start_basic_stats_polling(struct nss_qdisc *nq) -+{ -+ /* -+ * In case the stats polling timer is already -+ * initiated, return. This can happen only when -+ * there is a fallback from PPE to NSS qdisc. -+ */ -+ if (atomic_read(&nq->pending_stat_requests)) { -+ return; -+ } -+ + nss_tx_status_t rc; + struct nss_if_msg nim; + int msg_type; +@@ -2610,9 +2717,14 @@ void nss_qdisc_start_basic_stats_polling + return; + } + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)) -+ init_timer(&nq->stats_get_timer); -+ nq->stats_get_timer.function = nss_qdisc_get_stats_timer_callback; -+ nq->stats_get_timer.data = (unsigned long)nq; + init_timer(&nq->stats_get_timer); + nq->stats_get_timer.function = nss_qdisc_get_stats_timer_callback; + nq->stats_get_timer.data = (unsigned long)nq; +#else + timer_setup(&nq->stats_get_timer, nss_qdisc_get_stats_timer_callback, 0); +#endif + -+ nq->stats_get_timer.expires = jiffies + HZ; -+ atomic_set(&nq->pending_stat_requests, 1); -+ add_timer(&nq->stats_get_timer); -+} -+ -+/* -+ * nss_qdisc_stop_basic_stats_polling() -+ * Call to stop polling of basic stats -+ */ -+void nss_qdisc_stop_basic_stats_polling(struct nss_qdisc *nq) -+{ -+ /* -+ * If the timer was active, then delete timer and return. -+ */ -+ if (del_timer(&nq->stats_get_timer) > 0) { -+ /* -+ * The timer was still active (counting down) when it was deleted. -+ * Therefore we are sure that there are no pending stats request -+ * for which we need to wait for. We can therefore return. -+ */ -+ return; -+ } -+ -+ /* -+ * The timer has already fired, which means we have a pending stat response. -+ * We will have to wait until we have received the pending response. -+ */ -+ if (!wait_event_timeout(nq->wait_queue, atomic_read(&nq->pending_stat_requests) == 0, -+ NSS_QDISC_COMMAND_TIMEOUT)) { -+ nss_qdisc_error("Stats request command for %x timedout!\n", nq->qos_tag); -+ } -+} -+ -+/* + nq->stats_get_timer.expires = jiffies + HZ; + atomic_set(&nq->pending_stat_requests, 1); + add_timer(&nq->stats_get_timer); +@@ -2650,13 +2762,15 @@ void nss_qdisc_stop_basic_stats_polling( * nss_qdisc_gnet_stats_copy_basic() * Wrapper around gnet_stats_copy_basic() */ -@@ -2876,10 +3034,6 @@ static int __init nss_qdisc_module_init( - return ret; - nss_qdisc_info("nss qdisc device notifiers registered\n"); - -- if (!nss_qdisc_stats_work_queue_init()) { -- nss_qdisc_error("Failed to initialized stats workqueue thread\n"); -- } -- - #if defined(NSS_QDISC_PPE_SUPPORT) - nss_ppe_port_res_alloc(); - nss_qdisc_info("nss ppe qdsic configured"); -@@ -2899,8 +3053,6 @@ static void __exit nss_qdisc_module_exit - } +-int nss_qdisc_gnet_stats_copy_basic(struct gnet_dump *d, ++int nss_qdisc_gnet_stats_copy_basic(struct Qdisc *sch, struct gnet_dump *d, + struct gnet_stats_basic_packed *b) + { + #if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 18, 0)) + return gnet_stats_copy_basic(d, b); +-#else ++#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + return gnet_stats_copy_basic(d, NULL, b); ++#else ++ return gnet_stats_copy_basic(qdisc_root_sleeping_running(sch), d, NULL, b); #endif + } -- nss_qdisc_stats_work_queue_exit(); -- - unregister_qdisc(&nss_pfifo_qdisc_ops); - nss_qdisc_info("nsspfifo unregistered\n"); +@@ -2695,10 +2809,8 @@ static int nss_qdisc_if_event_cb(struct + switch (event) { + case NETDEV_BR_JOIN: +- nss_qdisc_info("Reveived NETDEV_BR_JOIN on interface %s\n", +- dev->name); + case NETDEV_BR_LEAVE: +- nss_qdisc_info("Reveived NETDEV_BR_LEAVE on interface %s\n", ++ nss_qdisc_info("Received NETDEV_BR_JOIN/NETDEV_BR_LEAVE on interface %s\n", + dev->name); + br = nss_qdisc_get_dev_master(dev); + if_num = nss_cmn_get_interface_number(nss_qdisc_ctx, dev); +@@ -2754,6 +2866,7 @@ static int nss_qdisc_if_event_cb(struct + return NOTIFY_DONE; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + /* + * nss_qdisc_tcf_chain() + * Return the filter list of qdisc. +@@ -2778,8 +2891,29 @@ struct tcf_proto __rcu **nss_qdisc_tcf_c + if (nq->is_root) { + return &(nq->filter_list); + } ++ ++ return NULL; ++} ++#else ++/* ++ * nss_qdisc_tcf_block() ++ * Return the block containing chain of qdisc. ++ */ ++struct tcf_block *nss_qdisc_tcf_block(struct Qdisc *sch, unsigned long cl, struct netlink_ext_ack *extack) ++{ ++ struct nss_qdisc *nq = qdisc_priv(sch); ++ ++ /* ++ * Currently, support is available only for tc filter iterations ++ * at root qdisc. ++ */ ++ if (nq->is_root) { ++ return nq->block; ++ } ++ + return NULL; + } ++#endif + + /* + * nss_qdisc_tcf_bind() --- a/nss_qdisc/nss_qdisc.h +++ b/nss_qdisc/nss_qdisc.h @@ -1,6 +1,6 @@ /* ************************************************************************** -- * Copyright (c) 2014-2018, 2020-2021 The Linux Foundation. All rights reserved. +- * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2018, 2020 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. -@@ -35,17 +35,12 @@ +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -27,6 +28,9 @@ + #include + #include + #include ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) ++#include ++#endif + #if defined(NSS_QDISC_PPE_SUPPORT) #include "nss_ppe.h" - #endif --#include "nss_qdisc_stats.h" --#include "nss_qdisc_htable.h" - - #define NSS_QDISC_DEBUG_LEVEL_ERROR 1 - #define NSS_QDISC_DEBUG_LEVEL_WARN 2 - #define NSS_QDISC_DEBUG_LEVEL_INFO 3 - #define NSS_QDISC_DEBUG_LEVEL_TRACE 4 - --#define NSS_QDISC_COMMAND_TIMEOUT (10*HZ) /* We set 10sec to be the command */ -- /* timeout value for messages */ -- - /* - * Debug message for module init and exit - */ -@@ -92,9 +87,6 @@ - #endif - #endif - --#define NSS_QDISC_STATS_SYNC_MANY_PERIOD msecs_to_jiffies(1000) --#define NSS_QDISC_STATS_SYNC_MANY_UDELAY 5000 /* Delay for 5 ms */ -- - /* - * State values - */ -@@ -144,27 +136,6 @@ struct nss_qdisc; - typedef void (*nss_qdisc_stats_callback_t)(struct nss_qdisc *nq, struct nss_shaper_node_stats_response *response); - typedef void (*nss_qdisc_configure_callback_t)(struct nss_qdisc *nq, struct nss_shaper_configure *response); - -- --/* -- * Qdisc stats sync info object -- */ --struct nss_qdisc_stats_wq { -- struct nss_qdisc *nq; /* Pointer to root nss_qdisc */ -- struct list_head stats_list; /* List head stats sync management work */ -- struct nss_if_msg stats_sync_req_msg; /* FW sync message */ -- struct timer_list stats_get_timer; /* Timer used to start fresh iter */ -- unsigned long int next_req_time; /* Time at which next sync iteration starts */ -- unsigned long int stats_request_success; /* Number of success stats request */ -- unsigned long int stats_request_fail; /* Number of failed stats request */ -- unsigned long int stats_request_nack; /* Number of NACK'd stats request */ -- atomic_t pending_stat_work; /* Pending work queue status */ -- atomic_t pending_stat_resp; /* Pending statistics response from FW */ -- bool stats_polling_stopped; /* True when polling is stopped due to qdisc delete */ -- wait_queue_head_t stats_work_waitqueue; /* Wait queue to wait on work queue processing */ -- wait_queue_head_t stats_resp_waitqueue; /* Wait queue used to wait on response from the NSS */ -- struct nss_qdisc_htable nqt; /* Struct to manage hash table of Qdiscs for stats */ --}; -- - struct nss_qdisc { - struct Qdisc *qdisc; /* Handy pointer back to containing qdisc */ - struct nss_qdisc *parent; /* Pointer to parent nss qdisc */ -@@ -226,8 +197,6 @@ struct nss_qdisc { - #endif +@@ -186,7 +190,11 @@ struct nss_qdisc { + */ + struct gnet_stats_basic_packed bstats; /* Basic class statistics */ + struct gnet_stats_queue qstats; /* Qstats for use by classes */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)) + atomic_t refcnt; /* Reference count for class use */ ++#else ++ refcount_t refcnt; /* Reference count for class use */ ++#endif struct timer_list stats_get_timer; /* Timer used to poll for stats */ atomic_t pending_stat_requests; /* Number of pending stats responses */ -- struct nss_qdisc_stats_wq *stats_wq; /* Stats info and state work object */ -- struct hlist_node hlist; /* Hlist node for managing stats hash list */ wait_queue_head_t wait_queue; /* Wait queue used to wait on responses from the NSS */ - spinlock_t lock; /* Lock to protect the nss qdisc structure */ - uint16_t mode; /* Mode of Qdisc/class */ -@@ -460,6 +429,18 @@ extern int nss_qdisc_init(struct Qdisc * - void *extack); +@@ -201,6 +209,9 @@ struct nss_qdisc { + */ + #endif + struct tcf_proto __rcu *filter_list; /* Filter list */ ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) ++ struct tcf_block *block; ++#endif + }; /* -+ * nss_qdisc_start_basic_stats_polling() -+ * Call to initiate the stats polling timer +@@ -238,11 +249,81 @@ enum nss_qdisc_hybrid_mode { + }; + + /* ++ * nss_qdisc_nla_nest_start() ++ * Returns the container attribute + */ -+extern void nss_qdisc_start_basic_stats_polling(struct nss_qdisc *nq); ++static inline struct nlattr * nss_qdisc_nla_nest_start(struct sk_buff *skb, int attrtype) ++{ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) ++ return nla_nest_start(skb, TCA_OPTIONS); ++#else ++ return nla_nest_start_noflag(skb, TCA_OPTIONS); ++#endif ++} + +/* -+ * nss_qdisc_stop_basic_stats_polling() -+ * Call to stop polling of basic stats ++ * nss_qdisc_atomic_sub() ++ * Atomically decrements the ref count by 1 + */ -+extern void nss_qdisc_stop_basic_stats_polling(struct nss_qdisc *nq); ++static inline void nss_qdisc_atomic_sub(struct nss_qdisc *nq) ++{ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)) ++ atomic_sub(1, &nq->refcnt); ++#else ++ atomic_sub(1, &nq->refcnt.refs); ++#endif ++} + +/* ++ * nss_qdisc_atomic_sub_return() ++ * Atomically decrements the ref count by 1 and return ref count ++ */ ++static inline int nss_qdisc_atomic_sub_return(struct nss_qdisc *nq) ++{ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)) ++ return atomic_sub_return(1, &nq->refcnt); ++#else ++ return atomic_sub_return(1, &nq->refcnt.refs); ++#endif ++} ++ ++/* ++ * nss_qdisc_atomic_set() ++ * Atomically sets the ref count by 1 ++ */ ++static inline void nss_qdisc_atomic_set(struct nss_qdisc *nq) ++{ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)) ++ atomic_set(&nq->refcnt, 1); ++#else ++ refcount_set(&nq->refcnt, 1); ++#endif ++} ++ ++/* ++ * nss_qdisc_put() ++ * Destroy the qdisc ++ */ ++static inline void nss_qdisc_put(struct Qdisc *sch) ++{ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)) ++ qdisc_destroy(sch); ++#else ++ qdisc_put(sch); ++#endif ++} ++ ++/* + * nss_qdisc_qopt_get() + * Extracts qopt from opt. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + extern void *nss_qdisc_qopt_get(struct nlattr *opt, struct nla_policy *policy, +- uint32_t tca_max, uint32_t tca_params); ++ struct nlattr *tb[], uint32_t tca_max, uint32_t tca_params); ++#else ++extern void *nss_qdisc_qopt_get(struct nlattr *opt, struct nla_policy *policy, ++ struct nlattr *tb[], uint32_t tca_max, uint32_t tca_params, struct netlink_ext_ack *extack); ++#endif + + /* + * nss_qdisc_mode_get() +@@ -256,11 +337,13 @@ extern uint8_t nss_qdisc_accel_mode_get( + */ + extern struct sk_buff *nss_qdisc_peek(struct Qdisc *sch); + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + /* + * nss_qdisc_drop() + * Called to drop the packet at the head of queue + */ + extern unsigned int nss_qdisc_drop(struct Qdisc *sch); ++#endif + + /* + * nss_qdisc_reset() +@@ -272,7 +355,11 @@ extern void nss_qdisc_reset(struct Qdisc + * nss_qdisc_enqueue() + * Generic enqueue call for enqueuing packets into NSS for shaping + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + extern int nss_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch); ++#else ++extern int nss_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free); ++#endif + + /* + * nss_qdisc_dequeue() +@@ -338,7 +425,8 @@ extern void nss_qdisc_destroy(struct nss + * Initializes a shaper in NSS, based on the position of this qdisc (child or root) + * and if its a normal interface or a bridge interface. + */ +-extern int nss_qdisc_init(struct Qdisc *sch, struct nss_qdisc *nq, nss_shaper_node_type_t type, uint32_t classid, uint32_t accel_mode); ++extern int nss_qdisc_init(struct Qdisc *sch, struct nss_qdisc *nq, nss_shaper_node_type_t type, uint32_t classid, uint32_t accel_mode, ++ void *extack); + + /* + * nss_qdisc_start_basic_stats_polling() +@@ -356,8 +444,8 @@ extern void nss_qdisc_stop_basic_stats_p * nss_qdisc_gnet_stats_copy_basic() * Wrapper around gnet_stats_copy_basic() */ -@@ -505,15 +486,3 @@ extern unsigned long nss_qdisc_tcf_bind( - * Unbind the filter from the qdisc. +-extern int nss_qdisc_gnet_stats_copy_basic(struct gnet_dump *d, +- struct gnet_stats_basic_packed *b); ++extern int nss_qdisc_gnet_stats_copy_basic(struct Qdisc *sch, ++ struct gnet_dump *d, struct gnet_stats_basic_packed *b); + + /* + * nss_qdisc_gnet_stats_copy_queue() +@@ -373,11 +461,19 @@ extern int nss_qdisc_gnet_stats_copy_que + extern struct Qdisc *nss_qdisc_replace(struct Qdisc *sch, struct Qdisc *new, + struct Qdisc **pold); + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + /* + * nss_qdisc_tcf_chain() + * Return the filter list of qdisc. */ - extern void nss_qdisc_tcf_unbind(struct Qdisc *sch, unsigned long arg); -- --/* -- * nss_qdisc_get_interface_msg() -- * Returns the correct message that needs to be sent down to the NSS interface. -- */ --extern int nss_qdisc_get_interface_msg(bool is_bridge, uint32_t msg_type); -- --/* -- * nss_qdisc_msg_init() -- * Initialize the qdisc specific message -- */ --extern void nss_qdisc_msg_init(struct nss_if_msg *nim, uint16_t if_num, uint32_t msg_type, uint32_t len, nss_if_msg_callback_t cb, void *app_data); + extern struct tcf_proto __rcu **nss_qdisc_tcf_chain(struct Qdisc *sch, unsigned long arg); ++#else ++/* ++ * nss_qdisc_tcf_block() ++ * Return the block containing chain of qdisc. ++ */ ++extern struct tcf_block *nss_qdisc_tcf_block(struct Qdisc *sch, unsigned long cl, struct netlink_ext_ack *extack); ++#endif + + /* + * nss_qdisc_tcf_bind() --- a/nss_qdisc/nss_tbl.c +++ b/nss_qdisc/nss_tbl.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2017, 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2017, 2019-2020, 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. -@@ -88,7 +88,12 @@ static void nss_tbl_destroy(struct Qdisc +@@ -29,9 +29,18 @@ static struct nla_policy nss_tbl_policy[ + [TCA_NSSTBL_PARMS] = { .len = sizeof(struct tc_nsstbl_qopt) }, + }; + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static int nss_tbl_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++#else ++static int nss_tbl_enqueue(struct sk_buff *skb, struct Qdisc *sch, ++ struct sk_buff **to_free) ++#endif + { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + return nss_qdisc_enqueue(skb, sch); ++#else ++ return nss_qdisc_enqueue(skb, sch, to_free); ++#endif + } + + static struct sk_buff *nss_tbl_dequeue(struct Qdisc *sch) +@@ -39,10 +48,12 @@ static struct sk_buff *nss_tbl_dequeue(s + return nss_qdisc_dequeue(sch); + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static unsigned int nss_tbl_drop(struct Qdisc *sch) + { + return nss_qdisc_drop(sch); + } ++#endif + + static struct sk_buff *nss_tbl_peek(struct Qdisc *sch) + { +@@ -77,7 +88,7 @@ static void nss_tbl_destroy(struct Qdisc /* * Now we can destroy our child qdisc */ -- nss_qdisc_put(q->qdisc); +- qdisc_destroy(q->qdisc); + nss_qdisc_put(q->qdisc); -+ -+ /* -+ * Stop the polling of basic stats and destroy qdisc. -+ */ -+ nss_qdisc_stop_basic_stats_polling(&q->nq); - nss_qdisc_destroy(&q->nq); - } - -@@ -287,6 +292,11 @@ static int nss_tbl_init(struct Qdisc *sc - return -EINVAL; - } - -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(&q->nq); -+ - return 0; - } - ---- a/nss_qdisc/nss_wred.c -+++ b/nss_qdisc/nss_wred.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2017, 2020-2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2017, 2020 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. -@@ -108,6 +108,11 @@ static void nss_wred_destroy(struct Qdis - { - struct nss_qdisc *nq = (struct nss_qdisc *)qdisc_priv(sch); - -+ /* -+ * Stop the polling of basic stats -+ */ -+ nss_qdisc_stop_basic_stats_polling(nq); -+ - nss_qdisc_destroy(nq); - nss_qdisc_info("nsswred destroyed"); - } -@@ -370,6 +375,11 @@ static int nss_wred_init(struct Qdisc *s - return -EINVAL; - } - -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(nq); -+ - return 0; - } - ---- a/nss_qdisc/nss_wrr.c -+++ b/nss_qdisc/nss_wrr.c -@@ -1,13 +1,9 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2017, 2019-2021, The Linux Foundation. All rights reserved. -- * -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2014-2017, 2019-2020, 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 -@@ -91,6 +87,11 @@ static void nss_wrr_destroy_class(struct - nss_qdisc_put(cl->qdisc); /* -+ * Stop the stats polling timer and free class -+ */ -+ nss_qdisc_stop_basic_stats_polling(&cl->nq); -+ -+ /* - * Destroy the shaper in NSS - */ - nss_qdisc_destroy(&cl->nq); -@@ -351,6 +352,11 @@ static int nss_wrr_change_class(struct Q - */ - qdisc_class_hash_grow(sch, &q->clhash); + * Stop the polling of basic stats and destroy qdisc. +@@ -87,7 +98,11 @@ static void nss_tbl_destroy(struct Qdisc + } -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(&cl->nq); -+ - nss_qdisc_info("Class %u successfully allocated\n", classid); + #if defined(NSS_QDISC_PPE_SUPPORT) ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_tbl_ppe_change(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_tbl_ppe_change(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) ++#endif + { + struct nss_tbl_sched_data *q = qdisc_priv(sch); + struct nss_qdisc *nq = &q->nq; +@@ -123,8 +138,12 @@ fail: + /* + * PPE qdisc config failed, try to initialize in NSS. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_ppe_fallback_to_nss(nq, opt)) { +- nss_qdisc_warning("nss_tbl %x fallback to nss failed\n", sch->handle); ++#else ++ if (nss_ppe_fallback_to_nss(nq, opt, extack)) { ++#endif ++ nss_qdisc_warning("nss_tbl %x fallback to nss failed\n", sch->handle); + return -EINVAL; } -@@ -400,7 +406,11 @@ failure: +@@ -132,9 +151,15 @@ fail: + } + #endif + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_tbl_change(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_tbl_change(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++#endif + { + struct nss_tbl_sched_data *q = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSTBL_MAX + 1]; + struct tc_nsstbl_qopt *qopt; + struct nss_if_msg nim; + struct net_device *dev = qdisc_dev(sch); +@@ -143,7 +168,11 @@ static int nss_tbl_change(struct Qdisc * + return -EINVAL; + } + +- qopt = nss_qdisc_qopt_get(opt, nss_tbl_policy, TCA_NSSTBL_MAX, TCA_NSSTBL_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_tbl_policy, tb, TCA_NSSTBL_MAX, TCA_NSSTBL_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_tbl_policy, tb, TCA_NSSTBL_MAX, TCA_NSSTBL_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -178,7 +207,11 @@ static int nss_tbl_change(struct Qdisc * + + #if defined(NSS_QDISC_PPE_SUPPORT) + if (q->nq.mode == NSS_QDISC_MODE_PPE) { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_tbl_ppe_change(sch, opt) < 0) { ++#else ++ if (nss_tbl_ppe_change(sch, opt, extack) < 0) { ++#endif + nss_qdisc_warning("nss_tbl %x SSDK scheduler config failed\n", sch->handle); + return -EINVAL; + } +@@ -216,9 +249,17 @@ static int nss_tbl_change(struct Qdisc * + return 0; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_tbl_init(struct Qdisc *sch, struct nlattr *opt) + { ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_tbl_init(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_tbl_sched_data *q = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSTBL_MAX + 1]; + struct tc_nsstbl_qopt *qopt; + + if (!opt) { +@@ -227,15 +268,25 @@ static int nss_tbl_init(struct Qdisc *sc + + q->qdisc = &noop_qdisc; + +- qopt = nss_qdisc_qopt_get(opt, nss_tbl_policy, TCA_NSSTBL_MAX, TCA_NSSTBL_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_tbl_policy, tb, TCA_NSSTBL_MAX, TCA_NSSTBL_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_tbl_policy, tb, TCA_NSSTBL_MAX, TCA_NSSTBL_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } + +- if (nss_qdisc_init(sch, &q->nq, NSS_SHAPER_NODE_TYPE_TBL, 0, qopt->accel_mode) < 0) ++ if (nss_qdisc_init(sch, &q->nq, NSS_SHAPER_NODE_TYPE_TBL, 0, qopt->accel_mode, extack) < 0) ++ { + return -EINVAL; ++ } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_tbl_change(sch, opt) < 0) { ++#else ++ if (nss_tbl_change(sch, opt, extack) < 0) { ++#endif + nss_qdisc_info("Failed to configure tbl\n"); + nss_qdisc_destroy(&q->nq); + return -EINVAL; +@@ -262,7 +313,8 @@ static int nss_tbl_dump(struct Qdisc *sc + opt.accel_mode = nss_qdisc_accel_mode_get(&q->nq); + + nss_qdisc_info("Nsstbl dumping"); +- opts = nla_nest_start(skb, TCA_OPTIONS); ++ ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL || nla_put(skb, TCA_NSSTBL_PARMS, sizeof(opt), &opt)) { + goto nla_put_failure; + } +@@ -286,8 +338,13 @@ static int nss_tbl_dump_class(struct Qdi + return 0; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_tbl_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, + struct Qdisc **old) ++#else ++static int nss_tbl_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, ++ struct Qdisc **old, struct netlink_ext_ack *extack) ++#endif + { + struct nss_tbl_sched_data *q = qdisc_priv(sch); + struct nss_qdisc *nq_new = (struct nss_qdisc *)qdisc_priv(new); +@@ -339,6 +396,7 @@ static struct Qdisc *nss_tbl_leaf(struct + return q->qdisc; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + static unsigned long nss_tbl_get(struct Qdisc *sch, u32 classid) + { + return 1; +@@ -347,6 +405,12 @@ static unsigned long nss_tbl_get(struct + static void nss_tbl_put(struct Qdisc *sch, unsigned long arg) + { + } ++#else ++static unsigned long nss_tbl_search(struct Qdisc *sch, u32 classid) ++{ ++ return 1; ++} ++#endif + + static void nss_tbl_walk(struct Qdisc *sch, struct qdisc_walker *walker) + { +@@ -364,9 +428,17 @@ static void nss_tbl_walk(struct Qdisc *s + const struct Qdisc_class_ops nss_tbl_class_ops = { + .graft = nss_tbl_graft, + .leaf = nss_tbl_leaf, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + .get = nss_tbl_get, + .put = nss_tbl_put, ++#else ++ .find = nss_tbl_search, ++#endif ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + .tcf_chain = nss_qdisc_tcf_chain, ++#else ++ .tcf_block = nss_qdisc_tcf_block, ++#endif + .bind_tcf = nss_qdisc_tcf_bind, + .unbind_tcf = nss_qdisc_tcf_unbind, + .walk = nss_tbl_walk, +@@ -381,7 +453,9 @@ struct Qdisc_ops nss_tbl_qdisc_ops __rea + .enqueue = nss_tbl_enqueue, + .dequeue = nss_tbl_dequeue, + .peek = nss_tbl_peek, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_tbl_drop, ++#endif + .init = nss_tbl_init, + .reset = nss_tbl_reset, + .destroy = nss_tbl_destroy, +--- a/nss_qdisc/nss_wred.c ++++ b/nss_qdisc/nss_wred.c +@@ -55,9 +55,18 @@ static struct nla_policy nss_wred_policy + * nss_wred_enqueue() + * Enqueue API for nsswred qdisc + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static int nss_wred_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++#else ++static int nss_wred_enqueue(struct sk_buff *skb, struct Qdisc *sch, ++ struct sk_buff **to_free) ++#endif + { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + return nss_qdisc_enqueue(skb, sch); ++#else ++ return nss_qdisc_enqueue(skb, sch, to_free); ++#endif + } + + /* +@@ -69,6 +78,7 @@ static struct sk_buff *nss_wred_dequeue( + return nss_qdisc_dequeue(sch); + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + /* + * nss_wred_drop() + * Drops a packet from HLOS queue. +@@ -78,6 +88,7 @@ static unsigned int nss_wred_drop(struct + nss_qdisc_info("nsswred dropping"); + return nss_qdisc_drop(sch); + } ++#endif + + /* + * nss_wred_reset() +@@ -111,7 +122,11 @@ static void nss_wred_destroy(struct Qdis + * nss_wred_ppe_change() + * Function call to configure the nssred parameters for ppe qdisc. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_wred_ppe_change(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_wred_ppe_change(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) ++#endif + { + struct nss_wred_sched_data *q = qdisc_priv(sch); + struct nss_qdisc *nq = &q->nq; +@@ -159,8 +174,12 @@ fail: + /* + * Fallback to nss qdisc if PPE Qdisc configuration failed at init time. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_ppe_fallback_to_nss(&q->nq, opt) < 0) { +- nss_qdisc_warning("nss_wred %x fallback to nss failed\n", sch->handle); ++#else ++ if (nss_ppe_fallback_to_nss(&q->nq, opt, extack) < 0) { ++#endif ++ nss_qdisc_warning("nss_wred %x fallback to nss failed\n", sch->handle); + return -EINVAL; + } + return 0; +@@ -171,9 +190,15 @@ fail: + * nss_wred_change() + * Function call to configure the nsswred parameters + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_wred_change(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_wred_change(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++#endif + { + struct nss_wred_sched_data *q = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSWRED_MAX + 1]; + struct tc_nsswred_qopt *qopt; + struct nss_if_msg nim; + +@@ -181,7 +206,11 @@ static int nss_wred_change(struct Qdisc + return -EINVAL; + } + +- qopt = nss_qdisc_qopt_get(opt, nss_wred_policy, TCA_NSSWRED_MAX, TCA_NSSWRED_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_wred_policy, tb, TCA_NSSWRED_MAX, TCA_NSSWRED_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_wred_policy, tb, TCA_NSSWRED_MAX, TCA_NSSWRED_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -253,7 +282,11 @@ static int nss_wred_change(struct Qdisc + + #if defined(NSS_QDISC_PPE_SUPPORT) + if (q->nq.mode == NSS_QDISC_MODE_PPE) { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_wred_ppe_change(sch, opt) < 0) { ++#else ++ if (nss_wred_ppe_change(sch, opt, extack) < 0) { ++#endif + nss_qdisc_warning("nss_wred %px params validate and save failed\n", sch); + return -EINVAL; + } +@@ -298,16 +331,28 @@ static int nss_wred_change(struct Qdisc + * nss_wred_init() + * Init the nsswred qdisc + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_wred_init(struct Qdisc *sch, struct nlattr *opt) + { ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_wred_init(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_qdisc *nq = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSWRED_MAX + 1]; + struct tc_nsswred_qopt *qopt; + + if (opt == NULL) { + return -EINVAL; + } + +- qopt = nss_qdisc_qopt_get(opt, nss_wred_policy, TCA_NSSWRED_MAX, TCA_NSSWRED_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_wred_policy, tb, TCA_NSSWRED_MAX, TCA_NSSWRED_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_wred_policy, tb, TCA_NSSWRED_MAX, TCA_NSSWRED_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -315,11 +360,17 @@ static int nss_wred_init(struct Qdisc *s + nss_qdisc_info("Initializing Wred - type %d\n", NSS_SHAPER_NODE_TYPE_WRED); + nss_wred_reset(sch); + +- if (nss_qdisc_init(sch, nq, NSS_SHAPER_NODE_TYPE_WRED, 0, qopt->accel_mode) < 0) ++ if (nss_qdisc_init(sch, nq, NSS_SHAPER_NODE_TYPE_WRED, 0, qopt->accel_mode, extack) < 0) ++ { + return -EINVAL; ++ } + + nss_qdisc_info("NSS wred initialized - handle %x parent %x\n", sch->handle, sch->parent); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_wred_change(sch, opt) < 0) { ++#else ++ if (nss_wred_change(sch, opt, extack) < 0) { ++#endif + nss_qdisc_destroy(nq); + return -EINVAL; + } +@@ -374,7 +425,7 @@ static int nss_wred_dump(struct Qdisc *s + opt.set_default = q->set_default; + opt.accel_mode = nss_qdisc_accel_mode_get(&q->nq); + +- opts = nla_nest_start(skb, TCA_OPTIONS); ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL || nla_put(skb, TCA_NSSWRED_PARMS, sizeof(opt), &opt)) { + goto nla_put_failure; + } +@@ -405,7 +456,9 @@ struct Qdisc_ops nss_red_qdisc_ops __rea + .enqueue = nss_wred_enqueue, + .dequeue = nss_wred_dequeue, + .peek = nss_wred_peek, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_wred_drop, ++#endif + .init = nss_wred_init, + .reset = nss_wred_reset, + .destroy = nss_wred_destroy, +@@ -423,7 +476,9 @@ struct Qdisc_ops nss_wred_qdisc_ops __re + .enqueue = nss_wred_enqueue, + .dequeue = nss_wred_dequeue, + .peek = nss_wred_peek, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_wred_drop, ++#endif + .init = nss_wred_init, + .reset = nss_wred_reset, + .destroy = nss_wred_destroy, +--- a/nss_qdisc/nss_wrr.c ++++ b/nss_qdisc/nss_wrr.c +@@ -84,7 +84,7 @@ static void nss_wrr_destroy_class(struct + /* + * And now we destroy the child. + */ +- qdisc_destroy(cl->qdisc); ++ nss_qdisc_put(cl->qdisc); + + /* + * Stop the stats polling timer and free class +@@ -106,9 +106,15 @@ static void nss_wrr_destroy_class(struct + * nss_wrr_class_params_validate_and_save() + * Validates and saves the class configuration parameters. + */ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_wrr_class_params_validate_and_save(struct Qdisc *sch, struct nlattr **tca, + uint32_t *quantum) ++#else ++static int nss_wrr_class_params_validate_and_save(struct Qdisc *sch, struct nlattr **tca, ++ uint32_t *quantum, struct netlink_ext_ack *extack) ++#endif + { ++ struct nlattr *tb[TCA_NSSWRR_MAX + 1]; + struct nlattr *opt = tca[TCA_OPTIONS]; + struct tc_nsswrr_class_qopt *qopt; + struct net_device *dev = qdisc_dev(sch); +@@ -123,7 +129,11 @@ static int nss_wrr_class_params_validate + return -EINVAL; + } + +- qopt = nss_qdisc_qopt_get(opt, nss_wrr_policy, TCA_NSSWRR_MAX, TCA_NSSWRR_CLASS_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_wrr_policy, tb, TCA_NSSWRR_MAX, TCA_NSSWRR_CLASS_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_wrr_policy, tb, TCA_NSSWRR_MAX, TCA_NSSWRR_CLASS_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -218,9 +228,16 @@ static int nss_wrr_ppe_change_class(stru + } + #endif + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_wrr_change_class(struct Qdisc *sch, u32 classid, u32 parentid, + struct nlattr **tca, unsigned long *arg) + { ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_wrr_change_class(struct Qdisc *sch, u32 classid, u32 parentid, ++ struct nlattr **tca, unsigned long *arg, struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_wrr_sched_data *q = qdisc_priv(sch); + struct nss_wrr_class_data *cl = (struct nss_wrr_class_data *)*arg; + struct nss_if_msg nim_config; +@@ -230,7 +247,11 @@ static int nss_wrr_change_class(struct Q + + nss_qdisc_info("Changing nss_wrr class %u\n", classid); + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + if (nss_wrr_class_params_validate_and_save(sch, tca, &quantum) < 0) { ++#else ++ if (nss_wrr_class_params_validate_and_save(sch, tca, &quantum, extack) < 0) { ++#endif + nss_qdisc_warning("validation of configuration parameters for wrr class %x failed\n", + sch->handle); + return -EINVAL; +@@ -275,7 +296,7 @@ static int nss_wrr_change_class(struct Q + * reference count should not be 0. + */ + cl->qdisc = &noop_qdisc; +- atomic_set(&cl->nq.refcnt, 1); ++ nss_qdisc_atomic_set(&cl->nq); + *arg = (unsigned long)cl; + + nss_qdisc_info("Adding classid %u to qdisc %px hash queue %px\n", classid, sch, &q->clhash); +@@ -286,7 +307,8 @@ static int nss_wrr_change_class(struct Q + * here. + */ + cl->nq.parent = &q->nq; +- if (nss_qdisc_init(sch, &cl->nq, NSS_SHAPER_NODE_TYPE_WRR_GROUP, classid, accel_mode) < 0) { ++ if (nss_qdisc_init(sch, &cl->nq, NSS_SHAPER_NODE_TYPE_WRR_GROUP, classid, accel_mode, extack) < 0) ++ { + nss_qdisc_error("Nss init for class %u failed\n", classid); + return -EINVAL; + } +@@ -384,7 +406,11 @@ failure: return -EINVAL; } @@ -7559,3740 +6479,1453 @@ { struct nss_wrr_sched_data *q = qdisc_priv(sch); struct nss_wrr_class_data *cl = (struct nss_wrr_class_data *)arg; -@@ -408,14 +418,11 @@ static int nss_wrr_delete_class(struct Q - int refcnt; - - /* -- * If the class is a root class or has a child qdisc attached -- * we do not support deleting it. -+ * Since all classes are leaf nodes in our case, we dont have to make -+ * that check. - */ -- if ((cl == &q->root) || (cl->qdisc != &noop_qdisc)) { -- nss_qdisc_warning("Cannot delete wrr class %x as it is the " -- "root class or has a child qdisc attached\n", cl->nq.qos_tag); -+ if (cl == &q->root) - return -EBUSY; -- } - - /* - * The message to NSS should be sent to the parent of this class -@@ -429,24 +436,16 @@ static int nss_wrr_delete_class(struct Q - } - +@@ -412,7 +438,9 @@ static int nss_wrr_delete_class(struct Q sch_tree_lock(sch); -+ qdisc_reset(cl->qdisc); + qdisc_reset(cl->qdisc); qdisc_class_hash_remove(&q->clhash, &cl->cl_common); - - refcnt = nss_qdisc_atomic_sub_return(&cl->nq); - +- refcnt = atomic_sub_return(1, &cl->nq.refcnt); ++ ++ refcnt = nss_qdisc_atomic_sub_return(&cl->nq); ++ sch_tree_unlock(sch); -- -- /* -- * For 5.4 and above kernels, calling nss_htb_destroy_class -- * explicitly as there is no put_class which would have called -- * nss_wrr_destroy_class when refcnt becomes zero. -- */ --#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)) -- nss_wrr_destroy_class(sch, cl); --#else if (!refcnt) { nss_qdisc_error("Reference count should not be zero for class %px\n", cl); - } --#endif -+ +@@ -421,8 +449,13 @@ static int nss_wrr_delete_class(struct Q return 0; } -@@ -722,6 +721,11 @@ static int nss_wrr_init_qdisc(struct Qdi - - nss_qdisc_info("Nsswrr initialized - handle %x parent %x\n", sch->handle, sch->parent); - -+ /* -+ * Start the stats polling timer -+ */ -+ nss_qdisc_start_basic_stats_polling(&q->nq); -+ - return 0; - } - -@@ -760,11 +764,6 @@ static int nss_wrr_change_qdisc(struct Q - - static void nss_wrr_reset_class(struct nss_wrr_class_data *cl) - { -- if (cl->qdisc == &noop_qdisc) { -- nss_qdisc_trace("Class %x has no child qdisc to reset\n", cl->nq.qos_tag); -- return; -- } -- - nss_qdisc_reset(cl->qdisc); - nss_qdisc_info("Nsswrr class resetted %px\n", cl->qdisc); - } -@@ -837,6 +836,11 @@ static void nss_wrr_destroy_qdisc(struct - qdisc_class_hash_destroy(&q->clhash); - - /* -+ * Stop the polling of basic stats -+ */ -+ nss_qdisc_stop_basic_stats_polling(&q->nq); -+ -+ /* - * Now we can go ahead and destroy the qdisc. - * Note: We dont have to detach ourself from our parent because this - * will be taken care of by the graft call. ---- a/openvpn/plugins/Makefile -+++ b/openvpn/plugins/Makefile -@@ -1,12 +1,11 @@ - - # Makefile for the ovpn plugins - --ccflags-y := $(NSS_CCFLAGS) -I$(obj) -I$(obj)/../../exports -I$(obj)/include -I$(obj)/../src -I$(STAGING_DIR)/usr/include/qca-nss-ecm -- -+ccflags-y := $(NSS_CCFLAGS) -I$(obj) -I$(obj)/../../exports -I$(obj)/include -I$(obj)/../src - ccflags-y += -DNSS_CLIENT_BUILD_ID="$(BUILD_ID)" - ccflags-y += -DNSS_OVPNMGR_DEBUG_LEVEL=0 - ccflags-y += -DNSS_OVPN_LINK_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - - obj-m += qca-nss-ovpn-link.o - qca-nss-ovpn-link-objs := nss_ovpn_link.o ---- a/openvpn/plugins/nss_ovpn_sk.c -+++ b/openvpn/plugins/nss_ovpn_sk.c -@@ -19,7 +19,6 @@ - * Socket implementation for OVPN. - */ - --#include - #include - #include - #include -@@ -264,12 +263,7 @@ static int nss_ovpn_sk_update_ipv6_tuple - struct rt6_info *rt6; - int addr_type; - --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) - rt6 = rt6_lookup(dev_net(pinfo->dev), (struct in6_addr *)tun_data->tun_hdr.dst_ip, NULL, 0, 0); --#else -- rt6 = rt6_lookup(dev_net(pinfo->dev), (struct in6_addr *)tun_data->tun_hdr.dst_ip, NULL, 0, 0, 0); --#endif -- - if (!rt6) { - nss_ovpn_sk_warn("%px: Failed to find IPv6 route.\n", pinfo); - return -EINVAL; -@@ -411,11 +405,7 @@ static int nss_ovpn_sk_tun_add(struct so - * Bring up tunnel device. - */ - rtnl_lock(); --#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) - err = dev_open(tun_dev); --#else -- err = dev_open(tun_dev, NULL); --#endif - rtnl_unlock(); - - if (err) { -@@ -642,11 +632,11 @@ static int nss_ovpn_sk_sendmsg(struct so - */ - static int nss_ovpn_sk_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, int flags) - { -- struct nss_ovpn_sk_pkt_info *pkt_info_data, pkt_data; -+ struct nss_ovpn_sk_pkt_info *pkt_info_data; - struct nss_ovpnmgr_metadata pkt_info; - int copied, ret; - struct sk_buff *skb; -- struct cmsghdr *cmsg, k_cmsg; -+ struct cmsghdr *cmsg; - struct sock *sk = sock->sk; - - if (flags & ~(MSG_PEEK | MSG_DONTWAIT | MSG_TRUNC | MSG_CMSG_COMPAT)) { -@@ -666,13 +656,6 @@ static int nss_ovpn_sk_recvmsg(struct so - return -EINVAL; - } - -- if (copy_from_user(&k_cmsg, cmsg, sizeof(struct cmsghdr))) { -- nss_ovpn_sk_warn("Copy from user failed\n"); -- return -EINVAL; -- } -- -- cmsg = &k_cmsg; -- - if (!CMSG_OK(msg, cmsg)) { - nss_ovpn_sk_warn("%px: Incorrect message format\n", sock); - return -EINVAL; -@@ -700,15 +683,8 @@ static int nss_ovpn_sk_recvmsg(struct so - * Send control information to application. - */ - memcpy(&pkt_info, skb->cb, sizeof(pkt_info)); -- -- pkt_data.tunnel_id = pkt_info.tunnel_id; -- pkt_data.flags = pkt_info.flags; -- -- if (copy_to_user(pkt_info_data, &pkt_data, sizeof(pkt_data))) { -- nss_ovpn_sk_warn("Copy from user failed\n"); -- return -EINVAL; -- } -- -+ pkt_info_data->tunnel_id = pkt_info.tunnel_id; -+ pkt_info_data->flags = pkt_info.flags; - put_cmsg(msg, SOL_IP, IP_PKTINFO, sizeof(*pkt_info_data), pkt_info_data); - - copied = skb->len; -@@ -864,12 +840,7 @@ int nss_ovpn_sk_send(struct sk_buff *skb - * for indefinite time. - */ - skb_orphan(skb); -- --#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) - nf_reset(skb); --#else -- nf_reset_ct(skb); --#endif - - /* Enqueue packet */ - if (sock_queue_rcv_skb(sk, skb) < 0) { ---- a/openvpn/src/Makefile -+++ b/openvpn/src/Makefile -@@ -3,7 +3,7 @@ - ccflags-y := $(NSS_CCFLAGS) -I$(obj) -I$(obj)/../../exports -I$(obj)/include -I$(obj)/../plugins - ccflags-y += -DNSS_CLIENT_BUILD_ID="$(BUILD_ID)" - ccflags-y += -DNSS_OVPNMGR_DEBUG_LEVEL=0 -DNSS_OVPNMGR_DEBUG_ENABLE_PKT_DUMP=0 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - - obj-m += qca-nss-ovpn-mgr.o - qca-nss-ovpn-mgr-objs := nss_ovpnmgr.o nss_ovpnmgr_app.o nss_ovpnmgr_tun.o nss_ovpnmgr_crypto.o \ ---- a/openvpn/src/nss_ovpnmgr.c -+++ b/openvpn/src/nss_ovpnmgr.c -@@ -99,12 +99,7 @@ static int nss_ovpnmgr_netdevice_event(s - */ - read_unlock_bh(&ovpnmgr_ctx.lock); - if (event == NETDEV_UP) { --#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) - dev_open(nss_dev); --#else -- dev_open(nss_dev, NULL); --#endif -- - } else { - dev_close(nss_dev); - } ---- a/openvpn/src/nss_ovpnmgr_app.c -+++ b/openvpn/src/nss_ovpnmgr_app.c -@@ -62,12 +62,7 @@ static struct net_device *nss_ovpnmgr_ap - return dev; - } - --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) - rt6 = rt6_lookup(&init_net, (const struct in6_addr *)rt->ip_addr, NULL, 0, 0); --#else -- rt6 = rt6_lookup(&init_net, (const struct in6_addr *)rt->ip_addr, NULL, 0, 0, 0); --#endif -- - if (!rt6) { - return NULL; - } ---- a/openvpn/src/nss_ovpnmgr_route.c -+++ b/openvpn/src/nss_ovpnmgr_route.c -@@ -80,7 +80,7 @@ int nss_ovpnmgr_route_set_active(struct - /* - * This API should be called under lock. - */ -- lockdep_assert_held(&ovpnmgr_ctx.lock); -+ BUG_ON(write_can_lock(&ovpnmgr_ctx.lock)); - - /* - * Search for route entry with from_addr. ---- a/openvpn/src/nss_ovpnmgr_tun.c -+++ b/openvpn/src/nss_ovpnmgr_tun.c -@@ -130,11 +130,7 @@ static void nss_ovpnmgr_tun_ipv6_forward - skb->protocol = htons(ETH_P_IPV6); - ip6h = ipv6_hdr(skb); - --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) - rt6 = rt6_lookup(dev_net(app->dev), &ip6h->daddr, &ip6h->saddr, 0, 0); --#else -- rt6 = rt6_lookup(dev_net(app->dev), &ip6h->daddr, &ip6h->saddr, 0, 0, 0); --#endif - if (!rt6) { - nss_ovpnmgr_warn("%px: Failed to find IPv6 route.\n", skb); - tun->outer.stats.host_pkt_drop++; -@@ -488,11 +484,7 @@ static void nss_ovpnmgr_tun_dev_setup(st - dev->header_ops = NULL; - dev->netdev_ops = &ovpnmgr_dev_ops; - dev->ethtool_ops = NULL; --#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 11, 8)) - dev->destructor = nss_ovpnmgr_tun_free; --#else -- dev->priv_destructor = nss_ovpnmgr_tun_free; --#endif - } - - /* ---- a/portifmgr/Makefile -+++ b/portifmgr/Makefile -@@ -11,4 +11,4 @@ obj-m += qca-nss-portifmgr.o - qca-nss-portifmgr-objs := nss_portifmgr.o - - ccflags-y += -DNSS_PORTIFMGR_DEBUG_LEVEL=2 #-DNSS_PORTIFMGR_REF_AP148 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror -\ No newline at end of file ---- a/portifmgr/nss_portifmgr.c -+++ b/portifmgr/nss_portifmgr.c -@@ -187,16 +187,20 @@ drop: - } - - /* -- * nss_portifmgr_get_stats() -+ * nss_portifmgr_get_stats64() - * Netdev get stats function to get port stats - */ --static struct rtnl_link_stats64 *nss_portifmgr_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) -+/* -+ * nss_nlgre_redir_cmn_dev_stats64 -+ * Report packet statistics to linux -+ */ -+static void nss_portifmgr_get_stats64(struct net_device *dev, -+ struct rtnl_link_stats64 *stats) - { - struct nss_portifmgr_priv *priv = (struct nss_portifmgr_priv *)netdev_priv(dev); - BUG_ON(priv == NULL); - - nss_portid_get_stats(priv->if_num, stats); -- return stats; - } - - /* -@@ -225,7 +229,7 @@ static const struct net_device_ops nss_p - .ndo_start_xmit = nss_portifmgr_start_xmit, - .ndo_set_mac_address = eth_mac_addr, - .ndo_change_mtu = nss_portifmgr_change_mtu, -- .ndo_get_stats64 = nss_portifmgr_get_stats, -+ .ndo_get_stats64 = nss_portifmgr_get_stats64, - }; - - /* ---- a/pppoe/Makefile -+++ b/pppoe/Makefile -@@ -1,10 +1,12 @@ - # Makefile for pppoe client - ccflags-y += -I$(obj)/../exports -I$(obj)/.. -I$(obj)/nss_hal/include - ccflags-y += -DNSS_PPPOE_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - obj-m += qca-nss-pppoe.o - qca-nss-pppoe-objs := nss_connmgr_pppoe.o - - ifneq (,$(filter $(CONFIG_BONDING),y m)) -+ifneq ($(findstring 4.4, $(KERNELVERSION)),) - ccflags-y += -DBONDING_SUPPORT - endif -+endif ---- a/pppoe/nss_connmgr_pppoe.c -+++ b/pppoe/nss_connmgr_pppoe.c -@@ -69,11 +69,7 @@ static int nss_connmgr_pppoe_get_session - return -1; - } - -- if (pppoe_channel_addressing_get(channel[0], addressing)) { -- nss_connmgr_pppoe_warn("%px: failed to get addressing information\n", dev); -- ppp_release_channels(channel, 1); -- return -1; -- } -+ pppoe_channel_addressing_get(channel[0], addressing); - - dev_put(addressing->dev); - ppp_release_channels(channel, 1); ---- a/pptp/Makefile -+++ b/pptp/Makefile -@@ -1,6 +1,6 @@ - # Makefile for pptp client - ccflags-y += -I$(obj)/../exports -I$(obj)/.. -I$(obj)/nss_hal/include - ccflags-y += -DNSS_PPTP_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - obj-m += qca-nss-pptp.o - qca-nss-pptp-objs := nss_connmgr_pptp.o ---- a/pptp/nss_connmgr_pptp.c -+++ b/pptp/nss_connmgr_pptp.c -@@ -156,11 +156,6 @@ static int nss_connmgr_pptp_get_session( - return -1; - } - -- if (ppp_is_cp_enabled(dev)) { -- nss_connmgr_pptp_warning("%px: rx or tx compression is enabled for PPP\n", dev); -- return -1; -- } -- - ppp_ch_count = ppp_hold_channels(dev, channel, 1); - nss_connmgr_pptp_info("%px: PPP hold channel ret %d\n", dev, ppp_ch_count); - if (ppp_ch_count != 1) { ---- a/profiler/Makefile -+++ b/profiler/Makefile -@@ -1,5 +1,5 @@ - ccflags-y := -I$(obj) -I$(obj)/.. -I$(obj)/../exports -DNSS_DEBUG_LEVEL=0 #-DPROFILE_DEBUG --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - - obj-m += qca-nss-profile-drv.o - qca-nss-profile-drv-objs := profile.o ---- a/profiler/profile.c -+++ b/profiler/profile.c -@@ -31,6 +31,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -937,12 +938,26 @@ static ssize_t debug_if(struct file *fil - return count; - } - -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) -+#define HAVE_PROC_OPS -+#endif -+ -+#ifdef HAVE_PROC_OPS -+static const struct proc_ops profile_fops = { -+ .proc_open = profile_open, -+ .proc_read = profile_read, -+ .proc_lseek = seq_lseek, -+ .proc_release = profile_release, -+ .proc_write = debug_if, -+}; ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_wrr_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, + struct Qdisc **old) +#else - static const struct file_operations profile_fops = { - .open = profile_open, - .read = profile_read, - .release = profile_release, - .write = debug_if, - }; ++static int nss_wrr_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, ++ struct Qdisc **old, struct netlink_ext_ack *extack) +#endif - - /* - * showing sample status on Linux console -@@ -971,6 +986,15 @@ static ssize_t profile_rate_write(struct - return 0; - } - -+#ifdef HAVE_PROC_OPS -+static const struct proc_ops profile_rate_fops = { -+ .proc_open = profile_rate_open, -+ .proc_read = seq_read, -+ .proc_lseek = seq_lseek, -+ .proc_release = single_release, -+ .proc_write = profile_rate_write, -+}; -+#else - static const struct file_operations profile_rate_fops = { - .open = profile_rate_open, - .read = seq_read, -@@ -978,6 +1002,7 @@ static const struct file_operations prof - .release = single_release, - .write = profile_rate_write, - }; -+#endif - - /* - * hexdump -@@ -1269,25 +1294,15 @@ void netap_profile_release_resource(void - remove_proc_entry("rate", pdir); - remove_proc_entry("data", pdir); - remove_proc_entry("data1", pdir); -- proc_remove(pdir); -- pdir = NULL; -- } -- -- if (node[0]->ctx) { -- nss_profile_dma_deregister_cb(node[0]->ctx, 0); -- if (node[1] && node[1]->ctx) { -- nss_profile_dma_deregister_cb(node[1]->ctx, 0); -- nss_profiler_release_dma(node[1]->ctx); -- /* -- * node[1] memory is part of node[0] allocation; same as the ccl. -- */ -- node[1] = NULL; -- } -- nss_profiler_release_dma(node[0]->ctx); - } -+ nss_profile_dma_deregister_cb(node[0]->ctx, 0); -+ nss_profile_dma_deregister_cb(node[1]->ctx, 0); -+ nss_profiler_release_dma(node[1]->ctx); -+ nss_profiler_release_dma(node[0]->ctx); - kfree(node[0]->ccl); - kfree(node[0]); - node[0] = NULL; -+ - } - - /* ---- a/tls/Makefile -+++ b/tls/Makefile -@@ -4,7 +4,7 @@ ccflags-y += $(NSS_CCFLAGS) -I$(obj)/../ - #ccflags-y += -DNSS_TLSMGR_DEBUG_DUMP - ccflags-y += -DNSS_TLSMGR_DEBUG_LEVEL=3 - ccflags-y += -DNSS_TLSMGR_BUILD_ID=\"'Build_ID - $(shell date +'%m/%d/%y, %H:%M:%S') SoC=$(SoC)'\" --ccflags-y += -Wall -Werror -+ccflags-y += -Werror - - obj-m += qca-nss-tlsmgr.o - qca-nss-tlsmgr-objs += nss_tlsmgr.o ---- a/tls/nss_tlsmgr_buf.c -+++ b/tls/nss_tlsmgr_buf.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -52,15 +52,6 @@ - #define NSS_TLSMGR_REC_MAX_SIZE (sizeof(struct nss_tlsmgr_rec) * NSS_TLSMGR_MDATA_REC_MAX) - - /* -- * nss_tlsmgr_buf_get_rec_start() -- * Get record start -- */ --struct nss_tlsmgr_rec *nss_tlsmgr_buf_get_rec_start(struct nss_tlsmgr_buf *buf) --{ -- return (struct nss_tlsmgr_rec *)((uint8_t *)buf + sizeof(*buf)); --} -- --/* - * nss_tlsmgr_buf_set_rec() - * Reserve space for a record in a buffer. - */ -@@ -181,7 +172,7 @@ EXPORT_SYMBOL(nss_tlsmgr_buf_encap); - */ - nss_tlsmgr_status_t nss_tlsmgr_buf_decap(struct nss_tlsmgr_buf *buf, nss_tlsmgr_data_callback_t cb, void *app_data) { -- struct nss_tlsmgr_tun *tun = buf->tun; -+ struct nss_tlsmgr_tun *tun; - struct nss_tlsmgr_ctx *ctx; - struct sk_buff *skb; - struct nss_tlsmgr_rec *rec; -@@ -216,6 +207,7 @@ nss_tlsmgr_status_t nss_tlsmgr_buf_decap - skb = buf->skb; - skb_pull(skb, mdata_start - skb->data); + struct nss_wrr_sched_data *q = qdisc_priv(sch); + struct nss_wrr_class_data *cl = (struct nss_wrr_class_data *)arg; +@@ -504,6 +537,7 @@ static void nss_wrr_qlen_notify(struct Q + */ + } -+ tun = buf->tun; - ctx = &tun->ctx_dec; - - return nss_tlsmgr_ctx_tx(ctx, skb, rec); ---- a/tls/nss_tlsmgr_buf.h -+++ b/tls/nss_tlsmgr_buf.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -41,6 +41,13 @@ struct nss_tlsmgr_buf { - - void nss_tlsmgr_buf_rx(struct nss_tlsmgr_buf *buf, nss_tlsmgr_status_t status); - --struct nss_tlsmgr_rec *nss_tlsmgr_buf_get_rec_start(struct nss_tlsmgr_buf *buf); -+/* -+ * nss_tlsmgr_buf_get_rec_start() -+ * Get record start -+ */ -+static struct nss_tlsmgr_rec *nss_tlsmgr_buf_get_rec_start(struct nss_tlsmgr_buf *buf) ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + static unsigned long nss_wrr_get_class(struct Qdisc *sch, u32 classid) + { + struct nss_wrr_class_data *cl = nss_wrr_find_class(classid, sch); +@@ -526,10 +560,24 @@ static void nss_wrr_put_class(struct Qdi + * We are safe to destroy the qdisc if the reference count + * goes down to 0. + */ +- if (atomic_sub_return(1, &cl->nq.refcnt) == 0) { ++ if (nss_qdisc_atomic_sub_return(&cl->nq) == 0) { + nss_wrr_destroy_class(sch, cl); + } + } ++#else ++static unsigned long nss_wrr_search_class(struct Qdisc *sch, u32 classid) +{ -+ return (struct nss_tlsmgr_rec *)((uint8_t *)buf + sizeof(*buf)); ++ struct nss_wrr_class_data *cl = nss_wrr_find_class(classid, sch); ++ ++ nss_qdisc_info("Get nss_wrr class %px - class match = %px\n", sch, cl); ++ ++ if (cl != NULL) { ++ atomic_add(1, &cl->nq.refcnt.refs); ++ } ++ ++ return (unsigned long)cl; +} ++#endif - #endif /* !__NSS_TLSMGR_BUF_H_ */ ---- a/tls/nss_tlsmgr_tun.c -+++ b/tls/nss_tlsmgr_tun.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -102,7 +102,7 @@ static int nss_tlsmgr_tun_open(struct ne - * nss_tlsmgr_tun_stats64() - * TLS manager tunnel device - */ --static struct rtnl_link_stats64 *nss_tlsmgr_get_tun_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) -+void nss_tlsmgr_tun_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) + static int nss_wrr_dump_class(struct Qdisc *sch, unsigned long arg, struct sk_buff *skb, + struct tcmsg *tcm) +@@ -550,7 +598,7 @@ static int nss_wrr_dump_class(struct Qdi + tcm->tcm_handle = cl->cl_common.classid; + tcm->tcm_info = cl->qdisc->handle; + +- opts = nla_nest_start(skb, TCA_OPTIONS); ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL || nla_put(skb, TCA_NSSWRR_CLASS_PARMS, sizeof(qopt), &qopt)) { + goto nla_put_failure; + } +@@ -565,7 +613,7 @@ static int nss_wrr_dump_class_stats(stru { - struct nss_tlsmgr_tun *tun = netdev_priv(dev); + struct nss_qdisc *nq = (struct nss_qdisc *)arg; -@@ -113,29 +113,8 @@ static struct rtnl_link_stats64 *nss_tls - nss_tlsmgr_ctx_stats_copy(&tun->ctx_dec, stats); - read_unlock_bh(&tun->lock); - -- return stats; +- if (nss_qdisc_gnet_stats_copy_basic(d, &nq->bstats) < 0 || ++ if (nss_qdisc_gnet_stats_copy_basic(sch, d, &nq->bstats) < 0 || + nss_qdisc_gnet_stats_copy_queue(d, &nq->qstats) < 0) { + return -1; + } +@@ -600,9 +648,17 @@ static void nss_wrr_walk(struct Qdisc *s + } } --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) --/* -- * nss_tlsmgr_tun_stats64() -- * Netdev ops function to retrieve stats for kernel version < 4.6 -- */ --static struct rtnl_link_stats64 *nss_tlsmgr_tun_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) --{ -- return nss_tlsmgr_get_tun_stats64(dev, stats); --} --#else --/* -- * nss_tlsmgr_tun_stats64() -- * Netdev ops function to retrieve stats for kernel version >= 4.6 -- */ --static void nss_tlsmgr_tun_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) --{ -- nss_tlsmgr_get_tun_stats64(dev, stats); --} --#endif -- - /* - * nss_tlsmgr_tun_change_mtu() - * Change MTU size of TLS context device. -@@ -211,22 +190,13 @@ static void nss_tlsmgr_tun_free_work(str - read_unlock_bh(&tun->lock); - } - -- - /* - * nss_tlsmgr_notify_event() - * TLS manager notification timer handler - */ --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)) - static void nss_tlsmgr_notify_event(unsigned long data) --#else --static void nss_tlsmgr_notify_event(struct timer_list *tm) --#endif ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_wrr_init_qdisc(struct Qdisc *sch, struct nlattr *opt) { --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)) - struct nss_tlsmgr_tun *tun = (struct nss_tlsmgr_tun *)data; --#else -- struct nss_tlsmgr_tun *tun = from_timer(tun, tm, notify.timer); --#endif - nss_tlsmgr_notify_callback_t cb; - struct nss_tlsmgr_stats stats; - void *app_data; -@@ -248,17 +218,9 @@ static void nss_tlsmgr_notify_event(stru - * nss_tlsmgr_notify_decongestion() - * TLS manager decongestion notification - */ --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)) - static void nss_tlsmgr_notify_decongestion(unsigned long data) --#else --static void nss_tlsmgr_notify_decongestion(struct timer_list *tm) --#endif - { --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)) - struct nss_tlsmgr_tun *tun = (struct nss_tlsmgr_tun *)data; --#else -- struct nss_tlsmgr_tun *tun = from_timer(tun, tm, notify.timer); --#endif - nss_tlsmgr_decongest_callback_t cb; - void *app_data; ++ struct netlink_ext_ack *extack = NULL; ++#else ++static int nss_wrr_init_qdisc(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++#endif + struct nss_wrr_sched_data *q = qdisc_priv(sch); ++ struct nlattr *tb[TCA_NSSWRR_MAX + 1]; + int err; + struct nss_if_msg nim; + struct tc_nsswrr_qopt *qopt; +@@ -620,7 +676,11 @@ static int nss_wrr_init_qdisc(struct Qdi + qdisc_class_hash_insert(&q->clhash, &q->root.cl_common); + qdisc_class_hash_grow(sch, &q->clhash); -@@ -393,7 +355,6 @@ struct net_device *nss_tlsmgr_tun_add(ns +- qopt = nss_qdisc_qopt_get(opt, nss_wrr_policy, TCA_NSSWRR_MAX, TCA_NSSWRR_QDISC_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_wrr_policy, tb, TCA_NSSWRR_MAX, TCA_NSSWRR_QDISC_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_wrr_policy, tb, TCA_NSSWRR_MAX, TCA_NSSWRR_QDISC_PARMS, extack); ++#endif + if (!qopt) { + nss_qdisc_warning("Failed to parse input"); + return -EINVAL; +@@ -629,7 +689,7 @@ static int nss_wrr_init_qdisc(struct Qdi /* - * Initialize Event notification and Decongestion timer + * Initialize the NSSWRR shaper in NSS */ --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)) - init_timer(&tun->notify.timer); - tun->notify.timer.function = nss_tlsmgr_notify_event; - tun->notify.timer.data = (unsigned long)tun; -@@ -401,10 +362,6 @@ struct net_device *nss_tlsmgr_tun_add(ns - init_timer(&tun->decongest.timer); - tun->decongest.timer.function = nss_tlsmgr_notify_decongestion; - tun->decongest.timer.data = (unsigned long)tun; --#else -- timer_setup(&tun->notify.timer, nss_tlsmgr_notify_event, 0); -- timer_setup(&tun->decongest.timer, nss_tlsmgr_notify_decongestion, 0); --#endif +- if (nss_qdisc_init(sch, &q->nq, NSS_SHAPER_NODE_TYPE_WRR, 0, qopt->accel_mode) < 0) { ++ if (nss_qdisc_init(sch, &q->nq, NSS_SHAPER_NODE_TYPE_WRR, 0, qopt->accel_mode, extack) < 0) { + nss_qdisc_warning("Failed init nss_wrr qdisc"); + return -EINVAL; + } +@@ -669,8 +729,14 @@ static int nss_wrr_init_qdisc(struct Qdi + return 0; + } - INIT_LIST_HEAD(&tun->free_list); - INIT_WORK(&tun->free_work, nss_tlsmgr_tun_free_work); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) + static int nss_wrr_change_qdisc(struct Qdisc *sch, struct nlattr *opt) ++#else ++static int nss_wrr_change_qdisc(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++#endif + { ++ struct nlattr *tb[TCA_NSSWRR_MAX + 1]; + struct nss_wrr_sched_data *q; + struct tc_nsswrr_qopt *qopt; + +@@ -680,7 +746,11 @@ static int nss_wrr_change_qdisc(struct Q + return -EINVAL; + } + +- qopt = nss_qdisc_qopt_get(opt, nss_wrr_policy, TCA_NSSWRR_MAX, TCA_NSSWRR_QDISC_PARMS); ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)) ++ qopt = nss_qdisc_qopt_get(opt, nss_wrr_policy, tb, TCA_NSSWRR_MAX, TCA_NSSWRR_QDISC_PARMS); ++#else ++ qopt = nss_qdisc_qopt_get(opt, nss_wrr_policy, tb, TCA_NSSWRR_MAX, TCA_NSSWRR_QDISC_PARMS, extack); ++#endif + if (!qopt) { + return -EINVAL; + } +@@ -743,7 +813,7 @@ static void nss_wrr_destroy_qdisc(struct + * Reduce refcnt by 1 before destroying. This is to + * ensure that polling of stat stops properly. + */ +- atomic_sub(1, &cl->nq.refcnt); ++ nss_qdisc_atomic_sub(&cl->nq); + + /* + * Detach class before destroying it. We dont check for noop qdisc here +@@ -794,7 +864,7 @@ static int nss_wrr_dump_qdisc(struct Qdi + + opt.accel_mode = nss_qdisc_accel_mode_get(&q->nq); + +- opts = nla_nest_start(skb, TCA_OPTIONS); ++ opts = nss_qdisc_nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL) { + goto nla_put_failure; + } +@@ -809,9 +879,18 @@ nla_put_failure: + return -EMSGSIZE; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static int nss_wrr_enqueue(struct sk_buff *skb, struct Qdisc *sch) ++#else ++static int nss_wrr_enqueue(struct sk_buff *skb, struct Qdisc *sch, ++ struct sk_buff **to_free) ++#endif + { ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + return nss_qdisc_enqueue(skb, sch); ++#else ++ return nss_qdisc_enqueue(skb, sch, to_free); ++#endif + } + + static struct sk_buff *nss_wrr_dequeue(struct Qdisc *sch) +@@ -819,11 +898,13 @@ static struct sk_buff *nss_wrr_dequeue(s + return nss_qdisc_dequeue(sch); + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + static unsigned int nss_wrr_drop(struct Qdisc *sch) + { + nss_qdisc_info("Nsswrr drop\n"); + return nss_qdisc_drop(sch); + } ++#endif + + const struct Qdisc_class_ops nss_wrr_class_ops = { + .change = nss_wrr_change_class, +@@ -831,9 +912,17 @@ const struct Qdisc_class_ops nss_wrr_cla + .graft = nss_wrr_graft_class, + .leaf = nss_wrr_leaf_class, + .qlen_notify = nss_wrr_qlen_notify, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + .get = nss_wrr_get_class, + .put = nss_wrr_put_class, ++#else ++ .find = nss_wrr_search_class, ++#endif ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + .tcf_chain = nss_qdisc_tcf_chain, ++#else ++ .tcf_block = nss_qdisc_tcf_block, ++#endif + .bind_tcf = nss_qdisc_tcf_bind, + .unbind_tcf = nss_qdisc_tcf_unbind, + .dump = nss_wrr_dump_class, +@@ -851,7 +940,9 @@ struct Qdisc_ops nss_wrr_qdisc_ops __rea + .enqueue = nss_wrr_enqueue, + .dequeue = nss_wrr_dequeue, + .peek = qdisc_peek_dequeued, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_wrr_drop, ++#endif + .cl_ops = &nss_wrr_class_ops, + .priv_size = sizeof(struct nss_wrr_sched_data), + .owner = THIS_MODULE +@@ -863,9 +954,17 @@ const struct Qdisc_class_ops nss_wfq_cla + .graft = nss_wrr_graft_class, + .leaf = nss_wrr_leaf_class, + .qlen_notify = nss_wrr_qlen_notify, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)) + .get = nss_wrr_get_class, + .put = nss_wrr_put_class, ++#else ++ .find = nss_wrr_search_class, ++#endif ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) + .tcf_chain = nss_qdisc_tcf_chain, ++#else ++ .tcf_block = nss_qdisc_tcf_block, ++#endif + .bind_tcf = nss_qdisc_tcf_bind, + .unbind_tcf = nss_qdisc_tcf_unbind, + .dump = nss_wrr_dump_class, +@@ -883,7 +982,9 @@ struct Qdisc_ops nss_wfq_qdisc_ops __rea + .enqueue = nss_wrr_enqueue, + .dequeue = nss_wrr_dequeue, + .peek = qdisc_peek_dequeued, ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) + .drop = nss_wrr_drop, ++#endif + .cl_ops = &nss_wrr_class_ops, + .priv_size = sizeof(struct nss_wrr_sched_data), + .owner = THIS_MODULE +--- a/exports/nss_connmgr_tunipip6.h ++++ b/exports/nss_connmgr_tunipip6.h +@@ -28,12 +28,13 @@ enum nss_connmgr_tunipip6_err_codes { + NSS_CONNMGR_TUNIPIP6_TUN_DESTROY_FAILURE, /**< Tunnel destroy failure. */ + NSS_CONNMGR_TUNIPIP6_TUN_NONE, /**< Invalid tunnel type */ + NSS_CONNMGR_TUNIPIP6_NETDEV_TYPE_FAILURE, /**< Netdevice is not of type ipv6-in-ipv4. */ +- NSS_CONNMGR_TUNIPIP6_MAPRULE_ADD_FAILURE, /**< BMR/FMR addition failure. */ +- NSS_CONNMGR_TUNIPIP6_MAPRULE_DEL_FAILURE, /**< BMR/FMR deletion failure. */ +- NSS_CONNMGR_TUNIPIP6_FMR_RULE_FLUSH_FAILURE, /**< FMR flush failure. */ ++ NSS_CONNMGR_TUNIPIP6_MAPRULE_ADD_FAILURE, /**< BMR/FMR addition failure. */ ++ NSS_CONNMGR_TUNIPIP6_MAPRULE_DEL_FAILURE, /**< BMR/FMR deletion failure. */ ++ NSS_CONNMGR_TUNIPIP6_FMR_RULE_FLUSH_FAILURE, /**< FMR flush failure. */ + NSS_CONNMGR_TUNIPIP6_NO_DEV, /**< No NSS node found. */ + NSS_CONNMGR_TUNIPIP6_INVALID_PARAM, /**< Invalid tunnel parameters. */ + NSS_CONNMGR_TUNIPIP6_INVALID_RULE_TYPE, /**< Invalid maprule type. */ ++ NSS_CONNMGR_TUNIPIP6_CONTEXT_FAILURE, /**< Tunnel host context not found. */ + }; + + /* --- a/tunipip6/Makefile +++ b/tunipip6/Makefile -@@ -2,7 +2,6 @@ +@@ -2,9 +2,8 @@ ccflags-y += -I$(obj)/../exports -I$(obj)/.. ccflags-y += -DNSS_CLIENT_BUILD_ID="$(BUILD_ID)" ccflags-y += -DNSS_TUNIPIP6_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror +-ccflags-y += -Werror obj-m += qca-nss-tunipip6.o - qca-nss-tunipip6-objs := nss_connmgr_tunipip6.o nss_connmgr_tunipip6_sysctl.o nss_connmgr_tunipip6_stats.o +-qca-nss-tunipip6-objs := nss_connmgr_tunipip6.o nss_connmgr_tunipip6_sysctl.o ++qca-nss-tunipip6-objs := nss_connmgr_tunipip6.o nss_connmgr_tunipip6_sysctl.o nss_connmgr_tunipip6_stats.o ifneq ($(findstring 4.4, $(KERNELVERSION)),) + ccflags-y += -DDRAFT03_SUPPORT + endif --- a/tunipip6/nss_connmgr_tunipip6.c +++ b/tunipip6/nss_connmgr_tunipip6.c -@@ -194,7 +194,6 @@ static void nss_tunipip6_encap_exception - skb->pkt_type = PACKET_HOST; - skb->skb_iif = dev->ifindex; - skb->ip_summed = CHECKSUM_NONE; -- ip_rt_put(rt); - netif_receive_skb(skb); - return; - } -@@ -348,7 +347,7 @@ static void nss_tunipip6_update_dev_stat +@@ -20,7 +20,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -29,71 +28,123 @@ + #include + #include + #include +-#include + #include + #include "nss_connmgr_tunipip6.h" + #include "nss_connmgr_tunipip6_sysctl.h" ++#include "nss_connmgr_tunipip6_priv.h" ++ ++#define NSS_TUNIPIP6_MAX_FMR 255 /* Maximum number of forward mapping rule (FMR). */ + + /* +- * NSS tunipip6 debug macros ++ * Frag Id update is disabled by default + */ +-#if (NSS_TUNIPIP6_DEBUG_LEVEL < 1) +-#define nss_tunipip6_assert(fmt, args...) +-#else +-#define nss_tunipip6_assert(c) if (!(c)) { BUG_ON(!(c)); } +-#endif +- +-#if defined(CONFIG_DYNAMIC_DEBUG) ++bool frag_id_update = false; ++/* ++ * Creating custom ipip6 interface is disabled by default. ++ */ ++static bool enable_custom; ++module_param(enable_custom, bool, 0); + + /* +- * Compile messages for dynamic enable/disable ++ * tunipip6 global context. + */ +-#define nss_tunipip6_warning(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) +-#define nss_tunipip6_info(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) +-#define nss_tunipip6_trace(s, ...) pr_debug("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) +-#else ++struct nss_tunipip6_context tunipip6_ctx; + + /* +- * Statically compile messages at different levels ++ * nss_tunipip6_alloc_instance() ++ * Allocate tunipip6 interface instance. + */ +-#if (NSS_TUNIPIP6_DEBUG_LEVEL < 2) +-#define nss_tunipip6_warning(s, ...) +-#else +-#define nss_tunipip6_warning(s, ...) pr_warn("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) +-#endif ++static struct nss_tunipip6_instance *nss_tunipip6_alloc_instance(struct net_device *dev, ++ int inner_ifnum, ++ int outer_ifnum) ++{ ++ struct nss_tunipip6_instance*ntii; + +-#if (NSS_TUNIPIP6_DEBUG_LEVEL < 3) +-#define nss_tunipip6_info(s, ...) +-#else +-#define nss_tunipip6_info(s, ...) pr_notice("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) +-#endif ++ ntii = vzalloc(sizeof(*ntii)); ++ if (!ntii) { ++ nss_tunipip6_warning("%px: Not able to allocate tunipip6 instance\n", dev); ++ return NULL; ++ } + +-#if (NSS_TUNIPIP6_DEBUG_LEVEL < 4) +-#define nss_tunipip6_trace(s, ...) +-#else +-#define nss_tunipip6_trace(s, ...) pr_info("%s[%d]:" s, __func__, __LINE__, ##__VA_ARGS__) +-#endif +-#endif ++ ntii->dev = dev; ++ ++ /* ++ * Create statistics dentry. ++ */ ++ if (!nss_tunipip6_stats_dentry_create(ntii)) { ++ vfree(ntii); ++ nss_tunipip6_warning("%px: Not able to create tunipip6 statistics dentry\n", dev); ++ return NULL; ++ } ++ ++ INIT_LIST_HEAD(&ntii->list); ++ ntii->inner_ifnum = inner_ifnum; ++ ntii->outer_ifnum = outer_ifnum; ++ dev_hold(dev); ++ return ntii; ++} + + /* +- * Frag Id update is disabled by default ++ * nss_tunipip6_free_instance() ++ * Delete the tunipip6 interface instance from the list and free it. ++ * ++ * Note: tunnel list lock is expected to be held by the caller. + */ +-bool frag_id_update = false; ++static void nss_tunipip6_free_instance(struct nss_tunipip6_instance *ntii) ++{ ++ if (!list_empty(&ntii->list)) { ++ list_del(&ntii->list); ++ } ++ ++ vfree(ntii); ++} ++ + /* +- * Creating custom ipip6 interface is disabled by default. ++ * nss_tunipip6_find_instance() ++ * Find tunipip6 interface instance from list. ++ * ++ * Note: tunnel list lock is expected to be held by the caller. + */ +-static bool enable_custom; +-module_param(enable_custom, bool, 0); ++struct nss_tunipip6_instance *nss_tunipip6_find_instance(struct net_device *dev) ++{ ++ struct nss_tunipip6_instance *ntii; ++ ++ /* ++ * Check if dev instance is in the list ++ */ ++ list_for_each_entry(ntii, &tunipip6_ctx.dev_list, list) { ++ if (ntii->dev == dev) { ++ return ntii; ++ } ++ } ++ ++ return NULL; ++} + + /* +- * tunipip6 stats structure ++ * nss_tunipip6_find_and_free_instance() ++ * Find and free the tunipip6 instance. + */ +-struct nss_tunipip6_stats { +- uint32_t rx_packets; /* Number of received packets */ +- uint32_t rx_bytes; /* Number of received bytes */ +- uint32_t tx_packets; /* Number of transmitted packets */ +- uint32_t tx_bytes; /* Number of transmitted bytes */ +-}; ++static enum nss_connmgr_tunipip6_err_codes nss_tunipip6_find_and_free_instance(struct net_device *netdev) ++{ ++ struct dentry *dentry; ++ struct nss_tunipip6_instance *ntii; ++ ++ spin_lock_bh(&tunipip6_ctx.lock); ++ ntii = nss_tunipip6_find_instance(netdev); ++ if (!ntii) { ++ spin_unlock_bh(&tunipip6_ctx.lock); ++ nss_tunipip6_warning("%px: Not able to find tunipip6 instance for dev:%s\n", netdev, netdev->name); ++ return NSS_CONNMGR_TUNIPIP6_CONTEXT_FAILURE; ++ } ++ ++ dentry = ntii->dentry; ++ nss_tunipip6_free_instance(ntii); ++ spin_unlock_bh(&tunipip6_ctx.lock); ++ debugfs_remove(dentry); ++ dev_put(netdev); ++ return NSS_CONNMGR_TUNIPIP6_SUCCESS; ++} + + /* + * nss_tunipip6_encap_exception() +@@ -206,7 +257,7 @@ static void nss_tunipip6_decap_exception + struct iphdr *iph; + struct rtable *rt; + int cpu; +- int8_t ver = skb->data[0] >> 4; ++ __attribute__((unused)) int8_t ver = skb->data[0] >> 4; + + nss_tunipip6_trace("%px: received - %d bytes name %s ver %x\n", + dev, skb->len, dev->name, ver); +@@ -289,20 +340,29 @@ static void nss_tunipip6_decap_exception + + /* + * nss_tunipip6_update_dev_stats +- * Update the Dev stats received from NetAp ++ * Update the Dev stats received from NSS + */ + static void nss_tunipip6_update_dev_stats(struct net_device *dev, +- struct nss_tunipip6_stats_sync_msg *sync_stats) ++ struct nss_tunipip6_msg *tnlmsg) { struct pcpu_sw_netstats stats; - enum nss_dynamic_interface_type interface_type; -- struct nss_tunipip6_stats_sync_msg *sync_stats = (struct nss_tunipip6_stats_sync_msg *)&tnlmsg->msg.stats; ++ enum nss_dynamic_interface_type interface_type; + struct nss_tunipip6_stats_sync_msg *sync_stats = (struct nss_tunipip6_stats_sync_msg *)&tnlmsg->msg.stats_sync; ++ ++ interface_type = nss_dynamic_interface_get_type(nss_tunipip6_get_context(), tnlmsg->cm.interface); ++ ++ memset(&stats, 0, sizeof(stats)); ++ if (interface_type == NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_INNER) { ++ stats.tx_packets = sync_stats->node_stats.tx_packets; ++ stats.tx_bytes = sync_stats->node_stats.tx_bytes; ++ } else if (interface_type == NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER) { ++ stats.rx_packets = sync_stats->node_stats.rx_packets; ++ stats.rx_bytes = sync_stats->node_stats.rx_bytes; ++ } else { ++ nss_tunipip6_warning("%px: Invalid interface type received from NSS\n", dev); ++ return; ++ } - interface_type = nss_dynamic_interface_get_type(nss_tunipip6_get_context(), tnlmsg->cm.interface); +- u64_stats_init(&stats.syncp); +- u64_stats_update_begin(&stats.syncp); +- stats.rx_packets = sync_stats->node_stats.rx_packets; +- stats.rx_bytes = sync_stats->node_stats.rx_bytes; +- stats.tx_packets = sync_stats->node_stats.tx_packets; +- stats.tx_bytes = sync_stats->node_stats.tx_bytes; +- u64_stats_update_end(&stats.syncp); + dev->stats.rx_dropped += nss_cmn_rx_dropped_sum(&sync_stats->node_stats); -@@ -381,7 +380,7 @@ void nss_tunipip6_event_receive(void *if + /* TODO: Update rx_dropped stats in ip6_update_offload_stats() */ +@@ -316,11 +376,20 @@ static void nss_tunipip6_update_dev_stat + void nss_tunipip6_event_receive(void *if_ctx, struct nss_tunipip6_msg *tnlmsg) + { + struct net_device *netdev = NULL; ++ netdev = (struct net_device *)if_ctx; switch (tnlmsg->cm.type) { -- case NSS_TUNIPIP6_STATS_SYNC: -+ case NSS_TUNIPIP6_RX_STATS_SYNC: - /* - * Update netdevice statistics. - */ -@@ -627,7 +626,6 @@ configure_tunnel: - tnlcreate->ttl_inherit = tnlcfg->ttl_inherit; - tnlcreate->tos_inherit = tnlcfg->tos_inherit; - tnlcreate->frag_id_update = tnlcfg->frag_id_update; -- tnlcreate->fmr_max = tnlcfg->fmr_max; - - /* - * Set "draft03" based on "tunnel_type". draft03 should be ---- a/tunipip6/nss_connmgr_tunipip6_stats.c -+++ b/tunipip6/nss_connmgr_tunipip6_stats.c -@@ -132,7 +132,7 @@ static void nss_tunipip6_stats_update(ui - void nss_tunipip6_stats_sync(struct net_device *dev, struct nss_tunipip6_msg *ntm) - { - uint32_t ifnum = ntm->cm.interface; -- struct nss_tunipip6_stats_sync_msg *stats = &ntm->msg.stats; -+ struct nss_tunipip6_stats_sync_msg *stats = &ntm->msg.stats_sync; - struct nss_tunipip6_instance *ntii; - struct nss_tunipip6_stats *s; - -@@ -147,7 +147,6 @@ void nss_tunipip6_stats_sync(struct net_ - s = &ntii->stats; - if (ntii->inner_ifnum == ifnum) { - nss_tunipip6_stats_update(s->inner_stats, stats); -- s->inner_stats[NSS_TUNIPIP6_STATS_CONFIG_ENCAP_TOTAL_FMR] = stats->tun_stats.encap.cfg.total_fmr; - } else if (ntii->outer_ifnum == ifnum) { - nss_tunipip6_stats_update(s->outer_stats, stats); - } else { ---- a/vlan/Makefile -+++ b/vlan/Makefile -@@ -8,8 +8,8 @@ ifeq ($(SoC),$(filter $(SoC),ipq807x ipq - ccflags-y += -DNSS_VLAN_MGR_PPE_SUPPORT - endif - --ccflags-y += -DNSS_VLAN_MGR_DEBUG_LEVEL=0 --ccflags-y += -Wall -Werror -+ccflags-y += -DNSS_VLAN_MGR_DEBUG_LEVEL=4 -+ccflags-y += -Werror - - ifneq (,$(filter $(CONFIG_BONDING),y m)) - ccflags-y += -DBONDING_SUPPORT ---- a/vlan/nss_vlan_mgr.c -+++ b/vlan/nss_vlan_mgr.c -@@ -1,12 +1,9 @@ - /* - ************************************************************************** - * Copyright (c) 2017-2018, 2020 The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 -@@ -368,16 +365,22 @@ static void nss_vlan_mgr_port_role_event - * nss_vlan_mgr_bond_configure_ppe() - * Configure PPE for bond device - */ --static int nss_vlan_mgr_bond_configure_ppe(struct nss_vlan_pvt *v, struct net_device *bond_dev, uint32_t vsi) -+static int nss_vlan_mgr_bond_configure_ppe(struct nss_vlan_pvt *v, struct net_device *bond_dev) - { -+ uint32_t vsi; - int ret = 0; - struct net_device *slave; - int32_t port; - int vlan_mgr_bond_port_role = -1; - -+ if (ppe_vsi_alloc(NSS_VLAN_MGR_SWITCH_ID, &vsi)) { -+ nss_vlan_mgr_warn("%s: failed to allocate VSI for bond vlan device", bond_dev->name); -+ return -1; -+ } + case NSS_TUNIPIP6_RX_STATS_SYNC: +- nss_tunipip6_update_dev_stats(netdev, (struct nss_tunipip6_stats_sync_msg *)&tnlmsg->msg.stats_sync); ++ /* ++ * Update netdevice statistics. ++ */ ++ nss_tunipip6_update_dev_stats(netdev, tnlmsg); + - if (nss_vlan_tx_vsi_attach_msg(v->nss_if, vsi) != NSS_TX_SUCCESS) { - nss_vlan_mgr_warn("%s: failed to attach VSI to bond vlan interface\n", bond_dev->name); -- return -1; -+ goto free_vsi; - } ++ /* ++ * Update NSS statistics for tunipip6. ++ */ ++ nss_tunipip6_stats_sync(netdev, tnlmsg); + break; + default: +@@ -415,7 +484,7 @@ static void nss_tunipip6_dev_parse_param + tnlcfg->ttl_inherit = false; + tnlcfg->tos_inherit = true; + tnlcfg->frag_id_update = frag_id_update; +- ++ tnlcfg->fmr_max = NSS_TUNIPIP6_MAX_FMR; /* -@@ -390,7 +393,7 @@ static int nss_vlan_mgr_bond_configure_p - if (!NSS_VLAN_PHY_PORT_CHK(port)) { - rcu_read_unlock(); - nss_vlan_mgr_warn("%s: %d is not valid physical port\n", slave->name, port); -- return -1; -+ goto free_vsi; - } - - /* -@@ -406,7 +409,7 @@ static int nss_vlan_mgr_bond_configure_p - * In case the bond interface has no slaves, we do not want to proceed further + * Flow Label In kernel is stored in big endian format. */ - if (vlan_mgr_bond_port_role == -1) { -- return -1; -+ goto free_vsi; +@@ -454,9 +523,9 @@ static void nss_connmgr_tunipip6_configu + tunnel = (struct ip6_tnl *)netdev_priv(netdev); + + /* +- * Configure FMR table up to NSS_TUNIPIP6_MAX_FMR_NUMBER, the rest will be forwarded to BR ++ * Configure FMR table up to NSS_TUNIPIP6_MAX_FMR, the rest will be forwarded to BR + */ +- for (fmr = tunnel->parms.fmrs; fmr && fmr_number < NSS_TUNIPIP6_MAX_FMR_NUMBER; fmr = fmr->next, fmr_number++) { ++ for (fmr = tunnel->parms.fmrs; fmr && fmr_number < NSS_TUNIPIP6_MAX_FMR; fmr = fmr->next, fmr_number++) { + /* + * Prepare "rulecfg" + */ +@@ -497,6 +566,7 @@ enum nss_connmgr_tunipip6_err_codes nss_ + int inner_ifnum, outer_ifnum; + uint32_t features = 0; + nss_tx_status_t status; ++ struct nss_tunipip6_instance *ntii; + + #if IS_ENABLED(CONFIG_MAP_E_SUPPORT) + #ifndef DRAFT03_SUPPORT +@@ -626,7 +696,7 @@ configure_tunnel: + status = nss_tunipip6_tx_sync(nss_ctx, &tnlmsg); + if (status != NSS_TX_SUCCESS) { + nss_tunipip6_warning("%px: Tunnel up command error %d\n", netdev, status); +- goto config_fail; ++ goto context_alloc_fail; } /* -@@ -510,6 +513,7 @@ static int nss_vlan_mgr_bond_configure_p - ret = NSS_VLAN_PORT_ROLE_CHANGED; +@@ -644,12 +714,28 @@ configure_tunnel: + status = nss_tunipip6_tx_sync(nss_ctx, &tnlmsg); + if (status != NSS_TX_SUCCESS) { + nss_tunipip6_warning("%px: Tunnel up command error %d\n", netdev, status); +- goto config_fail; ++ goto context_alloc_fail; } -+ v->ppe_vsi = vsi; - return ret; - - delete_egress_rule: -@@ -541,19 +545,30 @@ detach_vsi: - nss_vlan_mgr_warn("%px: Failed to detach vsi %d\n", v, vsi); - } - -+free_vsi: -+ if (ppe_vsi_free(NSS_VLAN_MGR_SWITCH_ID, vsi)) { -+ nss_vlan_mgr_warn("%px: Failed to free VLAN VSI\n", v); ++ /* ++ * Initialize tunipip6 instance. ++ */ ++ ntii = nss_tunipip6_alloc_instance(netdev, inner_ifnum, outer_ifnum); ++ if (!ntii) { ++ nss_tunipip6_warning("%px: Not able to create tunipip6 instance\n", netdev); ++ goto context_alloc_fail; + } + - return -1; - } - /* - * nss_vlan_mgr_configure_ppe() - * Configure PPE for physical devices - */ --static int nss_vlan_mgr_configure_ppe(struct nss_vlan_pvt *v, struct net_device *dev, uint32_t vsi) -+static int nss_vlan_mgr_configure_ppe(struct nss_vlan_pvt *v, struct net_device *dev) - { -+ uint32_t vsi; - int ret = 0; ++ /* ++ * Add the new tunipip6 instance to the global list. ++ */ ++ spin_lock_bh(&tunipip6_ctx.lock); ++ list_add(&ntii->list, &tunipip6_ctx.dev_list); ++ spin_unlock_bh(&tunipip6_ctx.lock); ++ + return NSS_CONNMGR_TUNIPIP6_SUCCESS; -+ if (ppe_vsi_alloc(NSS_VLAN_MGR_SWITCH_ID, &vsi)) { -+ nss_vlan_mgr_warn("%s: failed to allocate VSI for vlan device", dev->name); +-config_fail: ++context_alloc_fail: + nss_unregister_tunipip6_if(outer_ifnum); + outer_reg_fail: + nss_unregister_tunipip6_if(inner_ifnum); +@@ -675,6 +761,8 @@ EXPORT_SYMBOL(nss_connmgr_tunipip6_creat + */ + enum nss_connmgr_tunipip6_err_codes nss_connmgr_tunipip6_destroy_interface(struct net_device *netdev) + { ++ enum nss_connmgr_tunipip6_err_codes ret; ++ + /* + * Validate netdev for ipv6-in-ipv4 Tunnel + */ +@@ -682,7 +770,20 @@ enum nss_connmgr_tunipip6_err_codes nss_ + return NSS_CONNMGR_TUNIPIP6_NETDEV_TYPE_FAILURE; + } + +- return _nss_tunipip6_dyn_interface_destroy(netdev); ++ /* ++ * Destroy tunipip6 NSS context. ++ */ ++ ret = _nss_tunipip6_dyn_interface_destroy(netdev); ++ if (ret != NSS_CONNMGR_TUNIPIP6_SUCCESS) { ++ nss_tunipip6_warning("%px: Not able to destroy NSS context. Err: %d\n", netdev, ret); ++ return ret; ++ } ++ ++ /* ++ * Find and free the tunipip6 instance. ++ */ ++ ret = nss_tunipip6_find_and_free_instance(netdev); ++ return ret; + } + EXPORT_SYMBOL(nss_connmgr_tunipip6_destroy_interface); + +@@ -941,6 +1042,39 @@ static int nss_tunipip6_dev_event(struct + } + + /* ++ * nss_tunipip6_destroy_interface_all() ++ * Destroy NSS interfaces and free instance for all tunipip6 interfaces. ++ */ ++static void nss_tunipip6_destroy_interface_all(void) ++{ ++ struct net_device *netdev; ++ struct dentry *dentry; ++ struct nss_tunipip6_instance *ntii; ++ ++ spin_lock_bh(&tunipip6_ctx.lock); ++ ntii = list_first_entry_or_null(&tunipip6_ctx.dev_list, struct nss_tunipip6_instance, list); ++ do { ++ if (!ntii) { ++ spin_unlock_bh(&tunipip6_ctx.lock); ++ return; ++ } ++ ++ netdev = ntii->dev; ++ dentry = ntii->dentry; ++ nss_tunipip6_free_instance(ntii); ++ spin_unlock_bh(&tunipip6_ctx.lock); ++ ++ dev_put(netdev); ++ debugfs_remove(dentry); ++ _nss_tunipip6_dyn_interface_destroy(netdev); ++ ++ spin_lock_bh(&tunipip6_ctx.lock); ++ ntii = list_first_entry_or_null(&tunipip6_ctx.dev_list, struct nss_tunipip6_instance, list); ++ } while (ntii); ++ spin_unlock_bh(&tunipip6_ctx.lock); ++} ++ ++/* + * Linux Net device Notifier + */ + struct notifier_block nss_tunipip6_notifier = { +@@ -965,6 +1099,20 @@ int __init nss_tunipip6_init_module(void + NSS_CLIENT_BUILD_ID); + + /* ++ * Initialize lock and dev list. ++ */ ++ INIT_LIST_HEAD(&tunipip6_ctx.dev_list); ++ spin_lock_init(&tunipip6_ctx.lock); ++ ++ /* ++ * Create the debugfs directory for statistics. ++ */ ++ if (!nss_tunipip6_stats_dentry_init()) { ++ nss_tunipip6_trace("Failed to initialize debugfs\n"); + return -1; + } + - if (nss_vlan_tx_vsi_attach_msg(v->nss_if, vsi) != NSS_TX_SUCCESS) { - nss_vlan_mgr_warn("%s: failed to attach VSI to vlan interface\n", dev->name); -- return -1; -+ goto free_vsi; - } ++ /* + * Do not register net device notification for + * custom tunnel. Net device notification is used only + * for standard tunnel. +@@ -1000,6 +1148,16 @@ void __exit nss_tunipip6_exit_module(voi + #endif /* -@@ -637,6 +652,7 @@ static int nss_vlan_mgr_configure_ppe(st - ret = NSS_VLAN_PORT_ROLE_CHANGED; - } - -+ v->ppe_vsi = vsi; - return ret; - - delete_egress_rule: -@@ -658,6 +674,11 @@ detach_vsi: - nss_vlan_mgr_warn("%px: Failed to detach vsi %d\n", v, vsi); - } - -+free_vsi: -+ if (ppe_vsi_free(NSS_VLAN_MGR_SWITCH_ID, vsi)) { -+ nss_vlan_mgr_warn("%px: Failed to free VLAN VSI\n", v); -+ } ++ * Free Host and NSS tunipip6 instances. ++ */ ++ nss_tunipip6_destroy_interface_all(); + - return -1; - } - #endif -@@ -800,8 +821,10 @@ static struct nss_vlan_pvt *nss_vlan_mgr - */ - static void nss_vlan_mgr_instance_free(struct nss_vlan_pvt *v) - { -+#ifdef NSS_VLAN_MGR_PPE_SUPPORT - int32_t i; - int ret = 0; -+#endif - - spin_lock(&vlan_mgr_ctx.lock); - BUG_ON(--v->refs); -@@ -847,8 +870,7 @@ static void nss_vlan_mgr_instance_free(s - } - - /* -- * We will always have a VSI since this is allocated in beginning -- * of the code. -+ * Free PPE VSI - */ - if (ppe_vsi_free(NSS_VLAN_MGR_SWITCH_ID, v->ppe_vsi)) { - nss_vlan_mgr_warn("%px: Failed to free VLAN VSI\n", v); -@@ -957,12 +979,14 @@ static int nss_vlan_mgr_register_event(s - struct nss_vlan_pvt *v; - int if_num; - #ifdef NSS_VLAN_MGR_PPE_SUPPORT -- uint32_t vsi; - int ret; - #endif - uint32_t vlan_tag; -+#ifdef NSS_VLAN_MGR_PPE_SUPPORT - struct net_device *slave; -- int32_t port, port_if; -+ int32_t port; -+#endif -+ int32_t port_if; - struct vlan_dev_priv *vlan; - struct net_device *real_dev; - bool is_bond_master = false; -@@ -971,25 +995,19 @@ static int nss_vlan_mgr_register_event(s - if (!v) - return NOTIFY_DONE; - -- /* -- * Allocate the VSI here. -- */ --#ifdef NSS_VLAN_MGR_PPE_SUPPORT -- if (ppe_vsi_alloc(NSS_VLAN_MGR_SWITCH_ID, &vsi)) { -- nss_vlan_mgr_warn("%s: failed to allocate VSI for vlan device", dev->name); -- return NOTIFY_DONE; -- } --#endif -- - if_num = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_VLAN); - if (if_num < 0) { - nss_vlan_mgr_warn("%s: failed to alloc NSS dynamic interface\n", dev->name); -- goto vsi_alloc_free; -+ nss_vlan_mgr_instance_free(v); -+ return NOTIFY_DONE; - } - - if (!nss_register_vlan_if(if_num, NULL, dev, 0, v)) { - nss_vlan_mgr_warn("%s: failed to register NSS dynamic interface", dev->name); -- goto free_dynamic_interface; -+ if (nss_dynamic_interface_dealloc_node(if_num, NSS_DYNAMIC_INTERFACE_TYPE_VLAN) != NSS_TX_SUCCESS) -+ nss_vlan_mgr_warn("%px: Failed to dealloc vlan dynamic interface\n", v); -+ nss_vlan_mgr_instance_free(v); -+ return NOTIFY_DONE; - } - v->nss_if = if_num; - -@@ -1003,25 +1021,26 @@ static int nss_vlan_mgr_register_event(s - - #ifdef NSS_VLAN_MGR_PPE_SUPPORT - if (!is_bond_master) -- ret = nss_vlan_mgr_configure_ppe(v, dev, vsi); -+ ret = nss_vlan_mgr_configure_ppe(v, dev); - else -- ret = nss_vlan_mgr_bond_configure_ppe(v, real_dev, vsi); -+ ret = nss_vlan_mgr_bond_configure_ppe(v, real_dev); - - if (ret < 0) { -- goto vlan_instance_free; -+ nss_vlan_mgr_instance_free(v); -+ return NOTIFY_DONE; - } -- -- v->ppe_vsi = vsi; - #endif - - if (nss_vlan_tx_set_mac_addr_msg(v->nss_if, v->dev_addr) != NSS_TX_SUCCESS) { - nss_vlan_mgr_warn("%s: failed to set mac_addr msg\n", dev->name); -- goto vlan_instance_free; -+ nss_vlan_mgr_instance_free(v); -+ return NOTIFY_DONE; - } - - if (nss_vlan_tx_set_mtu_msg(v->nss_if, v->mtu) != NSS_TX_SUCCESS) { - nss_vlan_mgr_warn("%s: failed to set mtu msg\n", dev->name); -- goto vlan_instance_free; -+ nss_vlan_mgr_instance_free(v); -+ return NOTIFY_DONE; - } - - vlan_tag = (v->tpid << NSS_VLAN_TPID_SHIFT | v->vid); -@@ -1030,7 +1049,8 @@ static int nss_vlan_mgr_register_event(s - (v->parent ? v->parent->nss_if : port_if), - port_if) != NSS_TX_SUCCESS) { - nss_vlan_mgr_warn("%s: failed to add vlan in nss\n", dev->name); -- goto vlan_instance_free; -+ nss_vlan_mgr_instance_free(v); -+ return NOTIFY_DONE; - } - - spin_lock(&vlan_mgr_ctx.lock); -@@ -1058,21 +1078,6 @@ static int nss_vlan_mgr_register_event(s - } - #endif - return NOTIFY_DONE; -- --free_dynamic_interface: -- if (nss_dynamic_interface_dealloc_node(if_num, NSS_DYNAMIC_INTERFACE_TYPE_VLAN) != NSS_TX_SUCCESS) -- nss_vlan_mgr_warn("%px: Failed to dealloc vlan dynamic interface\n", v); -- --vsi_alloc_free: --#ifdef NSS_VLAN_MGR_PPE_SUPPORT -- if (ppe_vsi_free(NSS_VLAN_MGR_SWITCH_ID, v->ppe_vsi)) { -- nss_vlan_mgr_warn("%px: Failed to free VLAN VSI\n", v); -- } --#endif -- --vlan_instance_free: -- nss_vlan_mgr_instance_free(v); -- return NOTIFY_DONE; - } - - /* -@@ -1355,8 +1360,10 @@ return_with_error: - int nss_vlan_mgr_join_bridge(struct net_device *dev, uint32_t bridge_vsi) - { - struct nss_vlan_pvt *v = nss_vlan_mgr_instance_find_and_ref(dev); -+#ifdef NSS_VLAN_MGR_PPE_SUPPORT - struct net_device *real_dev; - int ret; -+#endif - - if (!v) - return 0; -@@ -1416,8 +1423,10 @@ EXPORT_SYMBOL(nss_vlan_mgr_join_bridge); - int nss_vlan_mgr_leave_bridge(struct net_device *dev, uint32_t bridge_vsi) - { - struct nss_vlan_pvt *v = nss_vlan_mgr_instance_find_and_ref(dev); -+#ifdef NSS_VLAN_MGR_PPE_SUPPORT - struct net_device *real_dev; - int ret; -+#endif - - if (!v) - return 0; ---- a/vxlanmgr/nss_vxlanmgr.c -+++ b/vxlanmgr/nss_vxlanmgr.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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. -@@ -22,18 +22,15 @@ - #include - #include - #include --#include - #include - #include - #include "nss_vxlanmgr.h" --#include "nss_vxlanmgr_priv.h" - #include "nss_vxlanmgr_tun_stats.h" - - /* - * VxLAN context - */ - struct nss_vxlanmgr_ctx vxlan_ctx; --static struct nss_vxlanmgr_get_ipsec_if_num __rcu ipsecmgr_cb; - - /* - * nss_vxlanmgr_netdev_event() -@@ -77,77 +74,6 @@ static struct notifier_block nss_vxlanmg - }; - - /* -- * nss_vxlanmgr_bind_ipsec_by_ip() -- * Bind VxLAN tunnel with IPsec based on IP Address -- */ --int32_t nss_vxlanmgr_bind_ipsec_by_ip(union vxlan_addr *src_ip, union vxlan_addr *dest_ip) --{ -- int32_t ipsec_if_num; -- nss_vxlanmgr_get_ipsec_if_num_by_ip_callback_t ipsec_cb; -- struct nss_ctx_instance *nss_ctx = nss_vxlan_get_ctx(); -- -- /* -- * Check if the VxLAN interface is applied over an IPsec interface by querying the IPsec. -- */ -- rcu_read_lock(); -- ipsec_cb = rcu_dereference(ipsecmgr_cb.get_ifnum_by_ip); -- if (!ipsec_cb) { -- rcu_read_unlock(); -- nss_vxlanmgr_info("%px: IPsec get_ifnum_by_ip callback is not registered\n", nss_ctx); -- return -1; -- } -- -- if (dest_ip->sa.sa_family == AF_INET) { -- ipsec_if_num = ipsec_cb(IPVERSION, &src_ip->sin.sin_addr.s_addr, &dest_ip->sin.sin_addr.s_addr); -- } else { -- ipsec_if_num = ipsec_cb(6, src_ip->sin6.sin6_addr.in6_u.u6_addr32, dest_ip->sin6.sin6_addr.in6_u.u6_addr32); -- } -- -- rcu_read_unlock(); -- nss_vxlanmgr_info("%px: VxLAN interface is bound to IPsec interface with if_num(0x%x)\n", nss_ctx, ipsec_if_num); -- -- return ipsec_if_num; --} -- --/* -- * nss_vxlanmgr_unregister_ipsecmgr_callback_by_ip -- * Unregister callback. -- */ --void nss_vxlanmgr_unregister_ipsecmgr_callback_by_ip(void) --{ -- rcu_assign_pointer(ipsecmgr_cb.get_ifnum_by_ip, NULL); -- synchronize_rcu(); --} --EXPORT_SYMBOL(nss_vxlanmgr_unregister_ipsecmgr_callback_by_ip); -- --/* -- * nss_vxlanmgr_register_ipsecmgr_callback_by_ip() -- * Register IPSecmgr callback. -- */ --void nss_vxlanmgr_register_ipsecmgr_callback_by_ip(struct nss_vxlanmgr_get_ipsec_if_num *cb) --{ -- nss_vxlanmgr_get_ipsec_if_num_by_ip_callback_t ipsec_get_ifnum_by_ip; -- -- rcu_read_lock(); -- ipsec_get_ifnum_by_ip = rcu_dereference(ipsecmgr_cb.get_ifnum_by_ip); -- if (ipsec_get_ifnum_by_ip) { -- rcu_read_unlock(); -- nss_vxlanmgr_info("%px: IPSecmgr Callback get_ifnum_by_ip is already registered\n", cb); -- return; -- } -- rcu_read_unlock(); -- -- if (cb->get_ifnum_by_ip == NULL) { -- nss_vxlanmgr_warn("%px: IPSecmgr Callback get_ifnum_by_ip is NULL\n", cb); -- return; -- } -- -- rcu_assign_pointer(ipsecmgr_cb.get_ifnum_by_ip, cb->get_ifnum_by_ip); -- synchronize_rcu(); --} --EXPORT_SYMBOL(nss_vxlanmgr_register_ipsecmgr_callback_by_ip); -- --/* - * nss_vxlanmgr_exit_module() - * Tunnel vxlan module exit function - */ -@@ -194,12 +120,6 @@ int __init nss_vxlanmgr_init_module(void - return -1; - } - -- /* -- * Initialize ipsecmgr callback. -- */ -- rcu_assign_pointer(ipsecmgr_cb.get_ifnum_by_ip, NULL); -- synchronize_rcu(); -- - INIT_LIST_HEAD(&vxlan_ctx.list); - vxlan_ctx.nss_ctx = nss_vxlan_get_ctx(); - spin_lock_init(&vxlan_ctx.tun_lock); ++ /* ++ * De-initialize debugfs. ++ */ ++ nss_tunipip6_stats_dentry_deinit(); ++ ++ /* + * Unregister net device notification for standard tunnel. + */ + if (!enable_custom) { --- /dev/null -+++ b/vxlanmgr/nss_vxlanmgr.h -@@ -0,0 +1,85 @@ ++++ b/tunipip6/nss_connmgr_tunipip6_priv.h +@@ -0,0 +1,94 @@ +/* + ************************************************************************** -+ * Copyright (c) 2019, 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. ++ * Copyright (c) 2020, 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. ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + ************************************************************************** + */ + ++#ifndef __NSS_CONNMGR_TUNIPIP6_PRIV_H_ ++#define __NSS_CONNMGR_TUNIPIP6_PRIV_H_ ++ ++#include "nss_connmgr_tunipip6_stats.h" ++#include ++ +/* -+ * nss_vxlanmgr.h -+ * VxLAN manager header ++ * tunipip6 context + */ -+#ifndef __NSS_VXLANMGR_H -+#define __NSS_VXLANMGR_H ++extern struct nss_tunipip6_context tunipip6_ctx; ++ ++/* ++ * NSS tunipip6 debug macros ++ */ ++#if (NSS_TUNIPIP6_DEBUG_LEVEL < 1) ++#define nss_tunipip6_assert(fmt, args...) ++#else ++#define nss_tunipip6_assert(c) if (!(c)) { BUG_ON(!(c)); } ++#endif + +/* + * Compile messages for dynamic enable/disable + */ +#if defined(CONFIG_DYNAMIC_DEBUG) -+#define nss_vxlanmgr_warn(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) -+#define nss_vxlanmgr_info(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) -+#define nss_vxlanmgr_trace(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) ++#define nss_tunipip6_warning(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) ++#define nss_tunipip6_info(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) ++#define nss_tunipip6_trace(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) +#else /* CONFIG_DYNAMIC_DEBUG */ +/* + * Statically compile messages at different levels + */ -+#if (NSS_VXLANMGR_DEBUG_LEVEL < 2) -+#define nss_vxlanmgr_warn(s, ...) ++#if (NSS_TUNIPIP6_DEBUG_LEVEL < 2) ++#define nss_tunipip6_warning(s, ...) +#else -+#define nss_vxlanmgr_warn(s, ...) pr_warn("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) ++#define nss_tunipip6_warning(s, ...) pr_warn("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) +#endif + -+#if (NSS_VXLANMGR_DEBUG_LEVEL < 3) -+#define nss_vxlanmgr_info(s, ...) ++#if (NSS_TUNIPIP6_DEBUG_LEVEL < 3) ++#define nss_tunipip6_info(s, ...) +#else -+#define nss_vxlanmgr_info(s, ...) pr_notice("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) ++#define nss_tunipip6_info(s, ...) pr_notice("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) +#endif + -+#if (NSS_VXLANMGR_DEBUG_LEVEL < 4) -+#define nss_vxlanmgr_trace(s, ...) ++#if (NSS_TUNIPIP6_DEBUG_LEVEL < 4) ++#define nss_tunipip6_trace(s, ...) +#else -+#define nss_vxlanmgr_trace(s, ...) pr_info("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) ++#define nss_tunipip6_trace(s, ...) pr_info("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) +#endif +#endif /* CONFIG_DYNAMIC_DEBUG */ + -+struct nss_vxlanmgr_ctx { -+ struct list_head list; /* vxlanmgr context list head */ -+ struct dentry *dentry; /* debugfs entry for qca-nss-vxlanmgr */ -+ struct nss_ctx_instance *nss_ctx; /* nss context for vxlan tunnel */ -+ uint32_t tun_count; /* active vxlan tunnel count */ -+ spinlock_t tun_lock; /* spinlock */ ++extern struct nss_tunipip6_context tunipip6_ctx; ++ ++/* ++ * tunipip6 global context structure. ++ */ ++struct nss_tunipip6_context { ++ struct list_head dev_list; /* List of tunipip6 interface instances */ ++ struct dentry *tunipip6_dentry_dir; /* tunipip6 debugfs directory entry */ ++ spinlock_t lock; /* Lock to protect list. */ +}; + -+struct nss_vxlanmgr_tun_ctx { -+ struct list_head head; /* tunnel context list entry */ -+ struct net_device *dev; /* tunnel netdevice pointer */ -+ struct dentry *dentry; /* per tunnel debugfs entry */ -+ struct nss_vxlanmgr_ctx *vxlan_ctx; /* pointer to vxlanmgr context */ -+ struct nss_vxlanmgr_tun_stats *stats; /* tunnel statistics structure */ -+ uint32_t inner_ifnum; /* inner node interface number */ -+ uint32_t outer_ifnum; /* outer node interface number */ -+ uint32_t vni; /* vnet identifier */ -+ uint16_t tunnel_flags; /* vxlan tunnel flags */ -+ uint16_t flow_label; /* flowlabel */ -+ uint16_t src_port_min; /* minimum source port */ -+ uint16_t src_port_max; /* maximum source port*/ -+ uint16_t dest_port; /* destination port */ -+ uint8_t tos; /* tos value */ -+ uint8_t ttl; /* time to live */ ++/* ++ * tunipip6 interface instance structure. ++ */ ++struct nss_tunipip6_instance { ++ struct list_head list; /* List of tunipip6 interface instance */ ++ struct net_device *dev; /* tunipip6 netdevice */ ++ struct dentry *dentry; /* debugfs entry for this tunnel device */ ++ struct nss_tunipip6_stats stats; /* tunipip6 statistics */ ++ uint32_t inner_ifnum; /* tunipip6 inner dynamic interface */ ++ uint32_t outer_ifnum; /* tunipip6 outer dynamic interface */ +}; + -+extern int nss_vxlanmgr_tunnel_create(struct net_device *dev); -+extern int nss_vxlanmgr_tunnel_destroy(struct net_device *dev); -+extern int nss_vxlanmgr_tunnel_config(struct net_device *dev); -+extern int nss_vxlanmgr_tunnel_deconfig(struct net_device *dev); ++struct nss_tunipip6_instance *nss_tunipip6_find_instance(struct net_device *dev); + -+#endif /* __NSS_VXLANMGR_H */ ---- a/vxlanmgr/nss_vxlanmgr_tun_stats.c -+++ b/vxlanmgr/nss_vxlanmgr_tun_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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. -@@ -18,7 +18,7 @@ - #include - #include - #include --#include "nss_vxlanmgr_priv.h" -+#include "nss_vxlanmgr.h" - #include "nss_vxlanmgr_tun_stats.h" - - /* -@@ -47,8 +47,6 @@ static int8_t *nss_vxlanmgr_tun_stats_st - "Except VNI Look-up failed", - "Dropped packet malformed", - "Dropped next node queue is full", -- "Except Inner hash calculation failed", -- "Decap IPSec source interface invalid" - }; - - /* -@@ -90,7 +88,7 @@ static int nss_vxlanmgr_tun_stats_show(s - seq_printf(m, "\t\tflow_label = %u\n", tun_ctx->flow_label); - seq_printf(m, "\t\tsrc_port_min = %u\n", tun_ctx->src_port_min); - seq_printf(m, "\t\tsrc_port_max = %u\n", tun_ctx->src_port_max); -- seq_printf(m, "\t\tdest_port = %u\n", tun_ctx->dest_port); -+ seq_printf(m, "\t\tdest_port = %u\n", ntohs(tun_ctx->dest_port)); - seq_printf(m, "\t\ttos = %u\n", tun_ctx->tos); - seq_printf(m, "\t\tttl = %u\n", tun_ctx->ttl); - -@@ -167,16 +165,11 @@ void nss_vxlanmgr_tun_stats_update(uint6 - stats_msg->dropped_malformed; - stats[NSS_VXLANMGR_TUN_STATS_TYPE_DROP_NEXT_NODE_QUEUE_FULL] += - stats_msg->dropped_next_node_queue_full; -- stats[NSS_VXLANMGR_TUN_STATS_TYPE_EXCEPT_INNER_HASH] += -- stats_msg->except_inner_hash; -- stats[NSS_VXLANMGR_TUN_STATS_TYPE_DECAP_IPSEC_SRC_INVALID] += -- stats_msg->decap_ipsec_src_err; - } - - /* - * nss_vxlanmgr_tun_macdb_stats_sync() - * Sync function for vxlan fdb entries -- * Note: Reference on the netdevice is expected to be held by the caller at the time this function is called. - */ - void nss_vxlanmgr_tun_macdb_stats_sync(struct nss_vxlanmgr_tun_ctx *tun_ctx, struct nss_vxlan_msg *nvm) - { -@@ -187,8 +180,11 @@ void nss_vxlanmgr_tun_macdb_stats_sync(s - db_stats = &nvm->msg.db_stats; - nentries = db_stats->cnt; - -+ dev_hold(tun_ctx->dev); ++#endif /* __NSS_CONNMGR_TUNIPIP6_PRIV_H_ */ +--- /dev/null ++++ b/tunipip6/nss_connmgr_tunipip6_stats.c +@@ -0,0 +1,225 @@ ++/* ++ ************************************************************************** ++ * Copyright (c) 2020, 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. ++ ************************************************************************** ++ */ + - if (nentries > NSS_VXLAN_MACDB_ENTRIES_PER_MSG) { - nss_vxlanmgr_warn("%px: No more than 20 entries allowed per message.\n", tun_ctx->dev); -+ dev_put(tun_ctx->dev); - return; - } - -@@ -204,6 +200,7 @@ void nss_vxlanmgr_tun_macdb_stats_sync(s - } - } - } -+ dev_put(tun_ctx->dev); - } - - /* ---- a/vxlanmgr/nss_vxlanmgr_tun_stats.h -+++ b/vxlanmgr/nss_vxlanmgr_tun_stats.h -@@ -1,6 +1,6 @@ - /* - ****************************************************************************** -- * Copyright (c) 2019, 2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019, 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. -@@ -37,8 +37,6 @@ enum nss_vxlanmgr_tun_stats_type { - NSS_VXLANMGR_TUN_STATS_TYPE_EXCEPT_VNI_LOOKUP_FAILED, - NSS_VXLANMGR_TUN_STATS_TYPE_DROP_MALFORMED, - NSS_VXLANMGR_TUN_STATS_TYPE_DROP_NEXT_NODE_QUEUE_FULL, -- NSS_VXLANMGR_TUN_STATS_TYPE_EXCEPT_INNER_HASH, -- NSS_VXLANMGR_TUN_STATS_TYPE_DECAP_IPSEC_SRC_INVALID, - NSS_VXLANMGR_TUN_STATS_TYPE_MAX, - }; - ---- a/vxlanmgr/nss_vxlanmgr_tunnel.c -+++ b/vxlanmgr/nss_vxlanmgr_tunnel.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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. -@@ -27,7 +27,7 @@ - #include - #include - #include --#include "nss_vxlanmgr_priv.h" -+#include "nss_vxlanmgr.h" - #include "nss_vxlanmgr_tun_stats.h" - - /* -@@ -91,23 +91,18 @@ static uint16_t nss_vxlanmgr_tunnel_flag - uint16_t flags = 0; - uint32_t priv_flags = priv->flags; - -- if (priv_flags & VXLAN_F_RSC) -- return flags; - if (priv_flags & VXLAN_F_GBP) - flags |= NSS_VXLAN_RULE_FLAG_GBP_ENABLED; -- -- if (priv_flags & VXLAN_F_IPV6) { -+ if (priv_flags & VXLAN_F_IPV6) - flags |= NSS_VXLAN_RULE_FLAG_IPV6; -- if (!(priv_flags & VXLAN_F_UDP_ZERO_CSUM6_TX)) -- flags |= NSS_VXLAN_RULE_FLAG_ENCAP_L4_CSUM_REQUIRED; -- } else { -+ else if (!(priv_flags & VXLAN_F_IPV6)) - flags |= NSS_VXLAN_RULE_FLAG_IPV4; -- if (priv_flags & VXLAN_F_UDP_CSUM) -- flags |= NSS_VXLAN_RULE_FLAG_ENCAP_L4_CSUM_REQUIRED; -- } -- - if (priv->cfg.tos == 1) - flags |= NSS_VXLAN_RULE_FLAG_INHERIT_TOS; -+ if (priv_flags & VXLAN_F_UDP_CSUM) -+ flags |= NSS_VXLAN_RULE_FLAG_ENCAP_L4_CSUM_REQUIRED; -+ else if (!(priv_flags & VXLAN_F_UDP_ZERO_CSUM6_TX)) -+ flags |= NSS_VXLAN_RULE_FLAG_ENCAP_L4_CSUM_REQUIRED; - - return (flags | NSS_VXLAN_RULE_FLAG_UDP); - } -@@ -118,25 +113,18 @@ static uint16_t nss_vxlanmgr_tunnel_flag - struct vxlan_config *cfg = &priv->cfg; - uint32_t priv_flags = cfg->flags; - -- if (priv_flags & VXLAN_F_RSC) -- return flags; -- if (priv_flags & VXLAN_F_GPE) -- return flags; - if (priv_flags & VXLAN_F_GBP) - flags |= NSS_VXLAN_RULE_FLAG_GBP_ENABLED; -- -- if (priv_flags & VXLAN_F_IPV6) { -+ if (priv_flags & VXLAN_F_IPV6) - flags |= NSS_VXLAN_RULE_FLAG_IPV6; -- if (!(priv_flags & VXLAN_F_UDP_ZERO_CSUM6_TX)) -- flags |= NSS_VXLAN_RULE_FLAG_ENCAP_L4_CSUM_REQUIRED; -- } else { -+ else if (!(priv_flags & VXLAN_F_IPV6)) - flags |= NSS_VXLAN_RULE_FLAG_IPV4; -- if (!(priv_flags & VXLAN_F_UDP_ZERO_CSUM_TX)) -- flags |= NSS_VXLAN_RULE_FLAG_ENCAP_L4_CSUM_REQUIRED; -- } -- - if (cfg->tos == 1) - flags |= NSS_VXLAN_RULE_FLAG_INHERIT_TOS; -+ if (priv_flags & VXLAN_F_UDP_ZERO_CSUM_TX) -+ flags |= NSS_VXLAN_RULE_FLAG_ENCAP_L4_CSUM_REQUIRED; -+ else if (!(priv_flags & VXLAN_F_UDP_ZERO_CSUM6_TX)) -+ flags |= NSS_VXLAN_RULE_FLAG_ENCAP_L4_CSUM_REQUIRED; - - return (flags | NSS_VXLAN_RULE_FLAG_UDP); - } -@@ -323,7 +311,6 @@ static nss_tx_status_t nss_vxlanmgr_tunn - union vxlan_addr *remote_ip, *src_ip; - uint32_t i, inner_ifnum; - uint32_t new_src_ip[4] = {0}; -- int32_t ipsec_if_num; - nss_tx_status_t status = NSS_TX_FAILURE; - - dev = vfe->dev; -@@ -380,17 +367,6 @@ static nss_tx_status_t nss_vxlanmgr_tunn - } - - /* -- * Check if this is a VxLAN over IPsec use case. If so, we need to bind the IPsec interface to the VxLAN. -- * When the IPsec interface is deleted in NSS, user is expected to bring the vxlan interface down as well, thereby flushing the MAC entries in NSS. -- */ -- ipsec_if_num = nss_vxlanmgr_bind_ipsec_by_ip(src_ip, remote_ip); -- if (ipsec_if_num > 0) { -- mac_add_msg->ipsec_if_num = (uint32_t)ipsec_if_num; -- mac_add_msg->flags = mac_add_msg->flags | NSS_VXLAN_MAC_ENABLE_IPSEC_BIND; -- nss_vxlanmgr_trace("%px: VxLAN interface is bound to IPsec interface with if_num(0x%x)\n", dev, ipsec_if_num); -- } -- -- /* - * Send MAC add message asynchronously as it is called by chain - * notifier in atomic context from the vxlan driver. - */ -@@ -460,8 +436,7 @@ static struct notifier_block nss_vxlanmg - - /* - * nss_vxlanmgr_tunnel_inner_stats() -- * Update vxlan netdev stats with inner node stats. -- * Note: Reference on the netdevice is expected to be held by the caller at the time this function is called. -+ * Update vxlan netdev stats with inner node stats - */ - static void nss_vxlanmgr_tunnel_inner_stats(struct nss_vxlanmgr_tun_ctx *tun_ctx, struct nss_vxlan_msg *nvm) - { -@@ -475,6 +450,7 @@ static void nss_vxlanmgr_tunnel_inner_st - stats = &nvm->msg.stats; - dev = tun_ctx->dev; - -+ dev_hold(dev); - netdev_stats = (struct net_device_stats *)&dev->stats; - - /* -@@ -493,6 +469,7 @@ static void nss_vxlanmgr_tunnel_inner_st - tstats->tx_bytes += stats->node_stats.tx_bytes; - u64_stats_update_end(&tstats->syncp); - netdev_stats->tx_dropped += dropped; -+ dev_put(dev); - } - - /* -@@ -537,7 +514,7 @@ static void nss_vxlanmgr_tunnel_outer_st - * nss_vxlanmgr_tunnel_fdb_update() - * Update vxlan fdb entries - */ --static void nss_vxlanmgr_tunnel_fdb_update(struct net_device *dev, uint32_t vni, struct nss_vxlan_msg *nvm) -+static void nss_vxlanmgr_tunnel_fdb_update(struct nss_vxlanmgr_tun_ctx *tun_ctx, struct nss_vxlan_msg *nvm) - { - uint8_t *mac; - uint16_t i, nentries; -@@ -546,10 +523,13 @@ static void nss_vxlanmgr_tunnel_fdb_upda - - db_stats = &nvm->msg.db_stats; - nentries = db_stats->cnt; -- priv = netdev_priv(dev); -+ priv = netdev_priv(tun_ctx->dev); ++#include ++#include "nss_connmgr_tunipip6_priv.h" + -+ dev_hold(tun_ctx->dev); - - if (nentries > NSS_VXLAN_MACDB_ENTRIES_PER_MSG) { -- nss_vxlanmgr_warn("%px: No more than 20 entries allowed per message.\n", dev); -+ nss_vxlanmgr_warn("%px: No more than 20 entries allowed per message.\n", tun_ctx->dev); -+ dev_put(tun_ctx->dev); - return; - } - -@@ -559,10 +539,11 @@ static void nss_vxlanmgr_tunnel_fdb_upda - #if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 5, 7)) - vxlan_fdb_update_mac(priv, mac); - #else -- vxlan_fdb_update_mac(priv, mac, vni); -+ vxlan_fdb_update_mac(priv, mac, tun_ctx->vni); - #endif - } - } -+ dev_put(tun_ctx->dev); - } - - /* -@@ -574,29 +555,20 @@ static void nss_vxlanmgr_tunnel_inner_no - struct net_device *dev = (struct net_device *)app_data; - struct nss_vxlanmgr_tun_ctx *tun_ctx; - struct nss_vxlan_msg *nvm; -- uint32_t vni; - - if (!ncm) { - nss_vxlanmgr_info("%px: NULL msg received.\n", dev); - return; - } - -- if (!dev) { -- nss_vxlanmgr_info("%px: NULL device received.\n", dev); -- return; -- } -- - spin_lock_bh(&vxlan_ctx.tun_lock); -- dev_hold(dev); - tun_ctx = nss_vxlanmgr_tunnel_ctx_dev_get(dev); - if (!tun_ctx) { - spin_unlock_bh(&vxlan_ctx.tun_lock); - nss_vxlanmgr_warn("%px: Invalid tunnel context\n", dev); -- dev_put(dev); - return; - } - -- vni = tun_ctx->vni; - nvm = (struct nss_vxlan_msg *)ncm; - switch (nvm->cm.type) { - case NSS_VXLAN_MSG_TYPE_STATS_SYNC: -@@ -604,24 +576,14 @@ static void nss_vxlanmgr_tunnel_inner_no - nss_vxlanmgr_tun_stats_sync(tun_ctx, nvm); - break; - case NSS_VXLAN_MSG_TYPE_MACDB_STATS: -+ nss_vxlanmgr_tunnel_fdb_update(tun_ctx, nvm); - nss_vxlanmgr_tun_macdb_stats_sync(tun_ctx, nvm); -- -- /* -- * Release the lock before updating the Linux FDB entry. -- * This will ensure there is no deadlock when a potential -- * MAC add event occurs at same time, which needs to hold -- * the kernel's hash lock followed by the tunnel ctx lock. -- */ -- spin_unlock_bh(&vxlan_ctx.tun_lock); -- -- nss_vxlanmgr_tunnel_fdb_update(dev, vni, nvm); -- dev_put(dev); -- return; -+ break; - default: -+ spin_unlock_bh(&vxlan_ctx.tun_lock); - nss_vxlanmgr_info("%px: Unknown Event from NSS", dev); ++/* ++ * nss_tunipip6_stats_str ++ * tunipip6 statistics strings for NSS tunnel stats ++ */ ++static int8_t *nss_tunipip6_stats_str[NSS_TUNIPIP6_STATS_MAX] = { ++ "rx pkts", ++ "rx bytes", ++ "tx pkts", ++ "tx bytes", ++ "rx queue 0 dropped", ++ "rx queue 1 dropped", ++ "rx queue 2 dropped", ++ "rx queue 3 dropped", ++ "encap low headroom", ++ "encap unhandled_protocol", ++ "encap enqueue fail", ++ "encap tunnel exist", ++ "encap total fmr_count", ++ "encap fmr add count", ++ "encap fmr del count", ++ "encap fmr flush count", ++ "encap fmr update_count", ++ "encap fmr add_fail count", ++ "encap fmr del_fail count", ++ "encap error no fmr", ++ "encap bmr add count", ++ "encap bmr del count", ++ "encap error bmr exist", ++ "encap error no bmr", ++ "decap enqueue fail", ++}; ++ ++/* ++ * nss_tunipip6_stats_show() ++ * Read tunipip6 tunnel statistics ++ */ ++static int nss_tunipip6_stats_show(struct seq_file *m, void __attribute__((unused))*p) ++{ ++ int i; ++ struct nss_tunipip6_instance *tun_inst; ++ struct nss_tunipip6_stats *tunipip6_tunnel_stats; ++ ++ tun_inst = vzalloc(sizeof(struct nss_tunipip6_instance)); ++ if (!tun_inst) { ++ nss_tunipip6_warning("Failed to allocate memory for tun_inst\n"); ++ return -ENOMEM; ++ } ++ ++ tunipip6_tunnel_stats = vzalloc(sizeof(struct nss_tunipip6_stats)); ++ if (!tunipip6_tunnel_stats) { ++ nss_tunipip6_warning("Failed to allocate memory for tunipip6_tunnel_stats\n"); ++ vfree(tun_inst); ++ return -ENOMEM; ++ } ++ ++ /* ++ * Copy the tunnel and stats information from the tunnel instance. ++ */ ++ spin_lock_bh(&tunipip6_ctx.lock); ++ memcpy(tun_inst, m->private, sizeof(struct nss_tunipip6_instance)); ++ memcpy(tunipip6_tunnel_stats, &tun_inst->stats, sizeof(struct nss_tunipip6_stats)); ++ spin_unlock_bh(&tunipip6_ctx.lock); ++ ++ seq_printf(m, "\n\tInner ifnum %u stats:\n", tun_inst->inner_ifnum); ++ for (i = 0; i < NSS_TUNIPIP6_STATS_MAX; i++) { ++ seq_printf(m, "\t\t%s = %llu\n", ++ nss_tunipip6_stats_str[i], ++ tunipip6_tunnel_stats->inner_stats[i]); ++ } ++ ++ seq_printf(m, "\n\tOuter ifnum %u stats:\n", tun_inst->outer_ifnum); ++ for (i = 0; i < NSS_TUNIPIP6_STATS_MAX; i++) { ++ seq_printf(m, "\t\t%s = %llu\n", ++ nss_tunipip6_stats_str[i], ++ tunipip6_tunnel_stats->outer_stats[i]); ++ } ++ ++ seq_printf(m, "\n%s tunnel stats end\n\n", tun_inst->dev->name); ++ vfree(tun_inst); ++ vfree(tunipip6_tunnel_stats); ++ return 0; ++} ++ ++/* ++ * nss_tunipip6_stats_open() ++ */ ++static int nss_tunipip6_stats_open(struct inode *inode, struct file *file) ++{ ++ return single_open(file, nss_tunipip6_stats_show, inode->i_private); ++} ++ ++/* ++ * nss_tunipip6_stats_update() ++ * Update inner or outer node statistics ++ */ ++static void nss_tunipip6_stats_update(uint64_t *stats, struct nss_tunipip6_stats_sync_msg *stats_msg) ++{ ++ uint32_t i, *src; ++ uint64_t *dest = stats; ++ ++ src = &stats_msg->node_stats.rx_packets; ++ for (i = NSS_TUNIPIP6_STATS_RX_PKTS; i < NSS_TUNIPIP6_STATS_MAX; i++, src++, dest++) { ++ *dest += *src; ++ } ++} ++ ++/* ++ * nss_tunipip6_stats_sync() ++ * Sync function for tunipip6 statistics ++ */ ++void nss_tunipip6_stats_sync(struct net_device *dev, struct nss_tunipip6_msg *ntm) ++{ ++ uint32_t ifnum = ntm->cm.interface; ++ struct nss_tunipip6_stats_sync_msg *stats = &ntm->msg.stats_sync; ++ struct nss_tunipip6_instance *ntii; ++ struct nss_tunipip6_stats *s; ++ ++ spin_lock_bh(&tunipip6_ctx.lock); ++ ntii = nss_tunipip6_find_instance(dev); ++ if (!ntii) { ++ spin_unlock_bh(&tunipip6_ctx.lock); ++ nss_tunipip6_warning("%px: Not able to find context for device: %s\n", dev, dev->name); + return; ++ } ++ ++ s = &ntii->stats; ++ if (ntii->inner_ifnum == ifnum) { ++ nss_tunipip6_stats_update(s->inner_stats, stats); ++ } else if (ntii->outer_ifnum == ifnum) { ++ nss_tunipip6_stats_update(s->outer_stats, stats); ++ } else { ++ nss_tunipip6_warning("%px: Netdev=%s invalid interface number. Interface No: %u\n", dev, dev->name, ifnum); ++ } ++ ++ spin_unlock_bh(&tunipip6_ctx.lock); ++} ++ ++/* ++ * nss_tunipip6_stats_ops ++ * File operations for tunipip6 tunnel stats ++ */ ++static const struct file_operations nss_tunipip6_stats_ops = { \ ++ .open = nss_tunipip6_stats_open, ++ .read = seq_read, ++ .llseek = seq_lseek, ++ .release = seq_release ++}; ++ ++/* ++ * nss_tunipip6_stats_dentry_destroy() ++ * Remove debufs file for given tunnel. ++ */ ++void nss_tunipip6_stats_dentry_destroy(struct nss_tunipip6_instance *tun_inst) ++{ ++ debugfs_remove(tun_inst->dentry); ++} ++ ++/* ++ * nss_tunipip6_stats_dentry_create() ++ * Create dentry for a given tunnel. ++ */ ++bool nss_tunipip6_stats_dentry_create(struct nss_tunipip6_instance *tun_inst) ++{ ++ char dentry_name[IFNAMSIZ]; ++ ++ scnprintf(dentry_name, sizeof(dentry_name), "%s", tun_inst->dev->name); ++ tun_inst->dentry = debugfs_create_file(dentry_name, S_IRUGO, ++ tunipip6_ctx.tunipip6_dentry_dir, tun_inst, &nss_tunipip6_stats_ops); ++ if (!tun_inst->dentry) { ++ nss_tunipip6_warning("Debugfs file creation failed for tun %s\n", tun_inst->dev->name); ++ return false; ++ } ++ ++ return true; ++} ++ ++/* ++ * nss_tunipip6_stats_dentry_deinit() ++ * Cleanup the debugfs tree. ++ */ ++void nss_tunipip6_stats_dentry_deinit(void) ++{ ++ if (tunipip6_ctx.tunipip6_dentry_dir) { ++ debugfs_remove_recursive(tunipip6_ctx.tunipip6_dentry_dir); ++ } ++} ++ ++/* ++ * nss_tunipip6_stats_dentry_init() ++ * Create tunipip6 tunnel statistics debugfs entry. ++ */ ++bool nss_tunipip6_stats_dentry_init(void) ++{ ++ /* ++ * Initialize debugfs directory. ++ */ ++ tunipip6_ctx.tunipip6_dentry_dir = debugfs_create_dir("qca-nss-tunipip6", NULL); ++ if (!tunipip6_ctx.tunipip6_dentry_dir) { ++ nss_tunipip6_warning("Failed to create debug entry for subsystem: qca-nss-tunipip6\n"); ++ return false; ++ } ++ ++ return true; ++} +--- /dev/null ++++ b/tunipip6/nss_connmgr_tunipip6_stats.h +@@ -0,0 +1,73 @@ ++/* ++ ****************************************************************************** ++ * Copyright (c) 2020, 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. ++ * **************************************************************************** ++ */ ++ ++#ifndef _NSS_CONNMGR_TUNIPIP6_STATS_H_ ++#define _NSS_CONNMGR_TUNIPIP6_STATS_H_ ++ ++struct nss_tunipip6_instance; ++ ++/* ++ * tunipip6 statistic counters ++ */ ++enum nss_tunipip6_stats_type { ++ NSS_TUNIPIP6_STATS_RX_PKTS, ++ NSS_TUNIPIP6_STATS_RX_BYTES, ++ NSS_TUNIPIP6_STATS_TX_PKTS, ++ NSS_TUNIPIP6_STATS_TX_BYTES, ++ NSS_TUNIPIP6_STATS_RX_QUEUE_0_DROPPED, ++ NSS_TUNIPIP6_STATS_RX_QUEUE_1_DROPPED, ++ NSS_TUNIPIP6_STATS_RX_QUEUE_2_DROPPED, ++ NSS_TUNIPIP6_STATS_RX_QUEUE_3_DROPPED, ++ NSS_TUNIPIP6_STATS_EXCEP_ENCAP_LOW_HEADROOM, ++ NSS_TUNIPIP6_STATS_EXCEP_ENCAP_UNHANDLED_PROTOCOL, ++ NSS_TUNIPIP6_STATS_DROP_ENCAP_ENQUEUE_FAIL, ++ NSS_TUNIPIP6_STATS_CONFIG_ERR_TUNNEL, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_TOTAL_FMR, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_FMR_ADD, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_FMR_DEL, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_FMR_FLUSH, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_FMR_UPDATE, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_FMR_ADD_FAIL, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_FMR_DEL_FAIL, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_ERR_NO_FMR, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_BMR_ADD, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_BMR_DEL, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_ERR_BMR_EXIST, ++ NSS_TUNIPIP6_STATS_CONFIG_ENCAP_ERR_NO_BMR, ++ NSS_TUNIPIP6_STATS_DROP_DECAP_ENQUEUE_FAIL, ++ NSS_TUNIPIP6_STATS_MAX, ++}; ++ ++/* ++ * tunipip6 statistics ++ */ ++struct nss_tunipip6_stats { ++ uint64_t inner_stats[NSS_TUNIPIP6_STATS_MAX]; ++ uint64_t outer_stats[NSS_TUNIPIP6_STATS_MAX]; ++}; ++ ++/* ++ * tunipip6 statistics API ++ */ ++extern void nss_tunipip6_stats_sync(struct net_device *dev, struct nss_tunipip6_msg *ntm); ++extern void nss_tunipip6_stats_dentry_deinit(void); ++extern bool nss_tunipip6_stats_dentry_init(void); ++extern void nss_tunipip6_stats_dentry_destroy(struct nss_tunipip6_instance *tun_inst); ++extern bool nss_tunipip6_stats_dentry_create(struct nss_tunipip6_instance *tun_inst); ++ ++#endif /* _NSS_CONNMGR_TUNIPIP6_STATS_H_ */ +--- a/tunipip6/nss_connmgr_tunipip6_sysctl.c ++++ b/tunipip6/nss_connmgr_tunipip6_sysctl.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2020, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2020-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 +@@ -61,7 +61,7 @@ static int nss_tunipip6_data_parser(stru + bool ipv4_prefix_valid = false, ipv4_prefix_len_valid = false, ipv6_suffix_len_valid = false; + bool rule_type_valid = false, ea_len_valid = false, psid_offset_valid = false, netdev_valid = false; + struct nss_connmgr_tunipip6_maprule_cfg mrcfg = {0}; +- char *buf = kzalloc(MAX_PROC_SIZE, GFP_KERNEL); ++ char *buf; + enum nss_connmgr_tunipip6_err_codes status; + struct net_device *dev = NULL; + char *pfree; +@@ -69,7 +69,11 @@ static int nss_tunipip6_data_parser(stru + int ret; + int count; + ++ if (!write) { ++ return -EINVAL; ++ } + ++ buf = kzalloc(MAX_PROC_SIZE, GFP_KERNEL); + if (!buf) { + return -ENOMEM; } -- -- dev_put(dev); - spin_unlock_bh(&vxlan_ctx.tun_lock); +@@ -122,6 +126,7 @@ static int nss_tunipip6_data_parser(stru + + if ((rule_type !=NSS_CONNMGR_TUNIPIP6_RULE_BMR) && + (rule_type != NSS_CONNMGR_TUNIPIP6_RULE_FMR)) { ++ kfree(pfree); + goto fail; + } + rule_type_valid = true; +@@ -135,6 +140,7 @@ static int nss_tunipip6_data_parser(stru + } + + if (frag_id != 0 && frag_id != 1) { ++ kfree(pfree); + goto fail; + } + continue; +@@ -396,9 +402,9 @@ static int nss_tunipip6_cmd_procfs_read_ + b. To delete maprule(BMR):\n\ + echo dev= rule_type=<1> > remove_map_rule\n\ + 3. To flush FMR entries:\n\ +- echo dev= > flush_fmr_rule\n\ +- 4. To enable/disable frag id:\n\ +- echo frag_id_update=<0/1> > frag_id\n\ ++ echo dev= > flush_fmr_rule\n"); ++ pr_info("\t\t\t4. To enable/disable frag id: \n\ ++ echo frag_id_update=<0/1> > frag_id \n\ + =====end of help=====\n"); + *lenp = 0; + return ret; +--- a/capwapmgr/nss_capwapmgr.c ++++ b/capwapmgr/nss_capwapmgr.c +@@ -348,6 +348,40 @@ static struct rtnl_link_stats64 *nss_cap + return stats; } -@@ -867,7 +829,7 @@ done: ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) ++/* ++ * nss_capwapmgr_dev_tunnel_stats() ++ * Netdev ops function to retrieve stats for kernel version < 4.6 ++ */ ++static struct rtnl_link_stats64 *nss_capwapmgr_dev_tunnel_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) ++{ ++ return nss_capwapmgr_get_tunnel_stats(dev, stats); ++} ++#else ++/* ++ * nss_capwapmgr_dev_tunnel_stats() ++ * Netdev ops function to retrieve stats for kernel version > 4.6 ++ */ ++static void nss_capwapmgr_dev_tunnel_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) ++{ ++ nss_capwapmgr_get_tunnel_stats(dev, stats); ++} ++#endif ++ ++/** ++ * nss_capwapmgr_change_mtu - set new MTU size ++ * @dev: network device ++ * @new_mtu: new Maximum Transfer Unit ++ * ++ * Allow changing MTU size. Needs to be overridden for devices ++ * supporting jumbo frames. ++ */ ++int nss_capwapmgr_change_mtu(struct net_device *dev, int new_mtu) ++{ ++ dev->mtu = new_mtu; ++ return 0; ++} ++ + /* + * nss_capwapmgr_netdev_ops + * Netdev operations. +@@ -357,8 +391,8 @@ static const struct net_device_ops nss_c + .ndo_stop = nss_capwapmgr_close, + .ndo_start_xmit = nss_capwapmgr_start_xmit, + .ndo_set_mac_address = eth_mac_addr, +- .ndo_change_mtu = eth_change_mtu, +- .ndo_get_stats64 = nss_capwapmgr_get_tunnel_stats, ++ .ndo_change_mtu = nss_capwapmgr_change_mtu, ++ .ndo_get_stats64 = nss_capwapmgr_dev_tunnel_stats, + }; + + /* +@@ -375,7 +409,12 @@ static void nss_capwapmgr_dummpy_netdev_ + dev->ethtool_ops = NULL; + dev->header_ops = NULL; + dev->netdev_ops = &nss_capwapmgr_netdev_ops; ++ ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 11, 8)) + dev->destructor = NULL; ++#else ++ dev->priv_destructor = NULL; ++#endif + memcpy(dev->dev_addr, "\x00\x00\x00\x00\x00\x00", dev->addr_len); + memset(dev->broadcast, 0xff, dev->addr_len); + memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); +@@ -514,6 +553,8 @@ static nss_capwapmgr_status_t nss_capwap + /* + * nss_capwapmgr_verify_tunnel_param() + * Common function to verify tunnel_id and returns pointer to tunnel. ++ * ++ * The caller of the function should hold reference to the net device before calling. */ - int nss_vxlanmgr_tunnel_destroy(struct net_device *dev) + static struct nss_capwapmgr_tunnel *nss_capwapmgr_verify_tunnel_param(struct net_device *dev, uint8_t tunnel_id) { -- uint32_t inner_ifnum, outer_ifnum, tun_count; -+ uint32_t inner_ifnum, outer_ifnum; - struct nss_vxlanmgr_tun_ctx *tun_ctx; - struct nss_vxlan_msg vxlanmsg; - nss_tx_status_t ret; -@@ -904,21 +866,16 @@ int nss_vxlanmgr_tunnel_destroy(struct n +@@ -1050,6 +1091,7 @@ static nss_tx_status_t nss_capwapmgr_cre + nircm->rule_flags |= rule_flags; + nircm->valid_flags |= valid_flags; - nss_vxlanmgr_tun_stats_deinit(tun_ctx); - nss_vxlanmgr_tun_stats_dentry_remove(tun_ctx); -- dev_put(tun_ctx->dev); - kfree(tun_ctx); ++ down(&ip_response.sem); + status = nss_ipv6_tx(nss_ctx, &nim); + if (status != NSS_TX_SUCCESS) { + up(&ip_response.sem); +--- a/match/nss_match_l2.c ++++ b/match/nss_match_l2.c +@@ -1,6 +1,7 @@ + /* + ******************************************************************************* + * Copyright (c) 2020, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 +@@ -133,7 +134,7 @@ static int nss_match_l2_cmd_parse(char * + struct nss_ctx_instance *nss_ctx = nss_match_get_context(); + int ret = 0; + uint32_t mask_val[4] = {0}; +- uint32_t actions = 0, if_num = 0, setprio = 0, nexthop = 0; ++ uint32_t actions = 0, if_num = 0, setprio = NSS_MAX_NUM_PRI, nexthop = 0; + uint16_t smac[3] = {0}, dmac[3] = {0}, mask_id = 0, ethertype = 0; + uint8_t mac_addr_tmp[6]; + char tmp[4]; +@@ -340,22 +341,22 @@ static int nss_match_l2_cmd_parse(char * -- /* -- * Unregister fdb notifier chain if -- * all vxlan tunnels are destroyed. -- */ -- spin_lock_bh(&vxlan_ctx.tun_lock); -- tun_count = vxlan_ctx.tun_count; -- spin_unlock_bh(&vxlan_ctx.tun_lock); -- if (!tun_count) { -+ if (!vxlan_ctx.tun_count) { -+ /* -+ * Unregister fdb notifier chain if -+ * all vxlan tunnels are destroyed. -+ */ - vxlan_fdb_unregister_notify(&nss_vxlanmgr_tunnel_fdb_notifier); + switch(actions) { + case NSS_MATCH_ACTION_SETPRIO: +- if (nexthop || !setprio || setprio >= NSS_MAX_NUM_PRI) { ++ if (nexthop || setprio >= NSS_MAX_NUM_PRI) { + goto fail; + } + break; + case NSS_MATCH_ACTION_FORWARD: +- if (setprio || !nexthop) { ++ if (!(setprio == NSS_MAX_NUM_PRI) || !nexthop) { + goto fail; + } + break; + case NSS_MATCH_ACTION_SETPRIO | NSS_MATCH_ACTION_FORWARD: +- if (!setprio || !nexthop || setprio >= NSS_MAX_NUM_PRI) { ++ if (!nexthop || setprio >= NSS_MAX_NUM_PRI) { + goto fail; + } + break; + case NSS_MATCH_ACTION_DROP: +- if (setprio || nexthop) { ++ if (!(setprio == NSS_MAX_NUM_PRI) || nexthop) { + goto fail; + } + break; +--- a/match/nss_match_vow.c ++++ b/match/nss_match_vow.c +@@ -1,6 +1,6 @@ + /* + ******************************************************************************* +- * Copyright (c) 2020, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2020-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 +@@ -122,7 +122,7 @@ static int nss_match_vow_cmd_parse(char + char *token, *param, *value; + struct nss_ctx_instance *nss_ctx = nss_match_get_context(); + int ret = 0; +- uint32_t actions = 0, if_num = 0, dscp = 0, outer_prio = 0, inner_prio = 0, setprio = 0, nexthop = 0; ++ uint32_t actions = 0, if_num = 0, dscp = 0, outer_prio = 0, inner_prio = 0, setprio = NSS_MAX_NUM_PRI, nexthop = 0; + uint16_t mask_id = 0; + uint32_t mask_val = 0; + +@@ -301,22 +301,22 @@ static int nss_match_vow_cmd_parse(char + + switch(actions) { + case NSS_MATCH_ACTION_SETPRIO: +- if (nexthop || !setprio || setprio >= NSS_MAX_NUM_PRI) { ++ if (nexthop || setprio >= NSS_MAX_NUM_PRI) { + goto fail; + } + break; + case NSS_MATCH_ACTION_FORWARD: +- if (setprio || !nexthop) { ++ if (!(setprio == NSS_MAX_NUM_PRI) || !nexthop) { + goto fail; + } + break; + case NSS_MATCH_ACTION_SETPRIO | NSS_MATCH_ACTION_FORWARD: +- if (!setprio || !nexthop || setprio >= NSS_MAX_NUM_PRI) { ++ if (!nexthop || setprio >= NSS_MAX_NUM_PRI) { + goto fail; + } + break; + case NSS_MATCH_ACTION_DROP: +- if (setprio || nexthop) { ++ if (!(setprio == NSS_MAX_NUM_PRI) || nexthop) { + goto fail; + } + break; +--- a/pvxlanmgr/nss_pvxlanmgr.c ++++ b/pvxlanmgr/nss_pvxlanmgr.c +@@ -186,6 +186,26 @@ static struct rtnl_link_stats64 *nss_pvx + return stats; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) ++/* ++ * nss_pvxlanmgr_dev_tunnel_stats() ++ * Netdev ops function to retrieve stats for kernel version < 4.6 ++ */ ++static struct rtnl_link_stats64 *nss_pvxlanmgr_dev_tunnel_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) ++{ ++ return nss_pvxlanmgr_get_tunnel_stats(dev, stats); ++} ++#else ++/* ++ * nss_pvxlanmgr_dev_tunnel_stats() ++ * Netdev ops function to retrieve stats for kernel version > 4.6 ++ */ ++static void nss_pvxlanmgr_dev_tunnel_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) ++{ ++ nss_pvxlanmgr_get_tunnel_stats(dev, stats); ++} ++#endif ++ + /* + * nss_pvxlanmgr_unregister_with_nss() + * Internal function to unregister with NSS FW +@@ -262,7 +282,7 @@ static const struct net_device_ops nss_p + .ndo_stop = nss_pvxlanmgr_close, + .ndo_start_xmit = nss_pvxlanmgr_start_xmit, + .ndo_set_mac_address = eth_mac_addr, +- .ndo_get_stats64 = nss_pvxlanmgr_get_tunnel_stats, ++ .ndo_get_stats64 = nss_pvxlanmgr_dev_tunnel_stats, + }; + + /* +@@ -278,7 +298,13 @@ static void nss_pvxlanmgr_dummy_netdev_s + dev->ethtool_ops = NULL; + dev->header_ops = NULL; + dev->netdev_ops = &nss_pvxlanmgr_netdev_ops; ++ ++#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 11, 8)) + dev->destructor = NULL; ++#else ++ dev->priv_destructor = NULL; ++#endif ++ + memcpy(dev->dev_addr, "\x00\x00\x00\x00\x00\x00", dev->addr_len); + memset(dev->broadcast, 0xff, dev->addr_len); + memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); +@@ -600,13 +626,14 @@ EXPORT_SYMBOL(nss_pvxlanmgr_netdev_creat + void __exit nss_pvxlanmgr_exit_module(void) + { + int ret; +- ++#ifdef CONFIG_OF + /* + * If the node is not compatible, don't do anything. + */ + if (!of_find_node_by_name(NULL, "nss-common")) { + return; } -- -- nss_vxlanmgr_info("%px: VxLAN interface count is #%d\n", dev, tun_count); -+ nss_vxlanmgr_info("%px: VxLAN interface count is #%d\n", dev, vxlan_ctx.tun_count); ++#endif - memset(&vxlanmsg, 0, sizeof(struct nss_vxlan_msg)); - ret = nss_vxlanmgr_tunnel_tx_msg_sync(vxlan_ctx.nss_ctx, -@@ -972,7 +929,6 @@ int nss_vxlanmgr_tunnel_create(struct ne - struct nss_vxlan_rule_msg *vxlan_cfg; - struct nss_ctx_instance *nss_ctx; - uint32_t inner_ifnum, outer_ifnum; -- uint16_t parse_flags; - nss_tx_status_t ret; - - spin_lock_bh(&vxlan_ctx.tun_lock); -@@ -983,20 +939,7 @@ int nss_vxlanmgr_tunnel_create(struct ne + ret = unregister_netdevice_notifier(&nss_pvxlanmgr_netdev_notifier); + if (!ret) { +@@ -623,12 +650,14 @@ void __exit nss_pvxlanmgr_exit_module(vo + int __init nss_pvxlanmgr_init_module(void) + { + int ret; ++#ifdef CONFIG_OF + /* + * If the node is not compatible, don't do anything. + */ + if (!of_find_node_by_name(NULL, "nss-common")) { + return 0; } - spin_unlock_bh(&vxlan_ctx.tun_lock); ++#endif -- /* -- * The reference to the dev will be released in nss_vxlanmgr_tunnel_destroy() -- */ - dev_hold(dev); -- priv = netdev_priv(dev); -- parse_flags = nss_vxlanmgr_tunnel_flags_parse(priv); -- -- /* -- * Check if the tunnel is supported. -- */ -- if (!parse_flags) { -- nss_vxlanmgr_warn("%px: Tunnel offload not supported\n", dev); -- goto ctx_alloc_fail; -- } - - tun_ctx = kzalloc(sizeof(struct nss_vxlanmgr_tun_ctx), GFP_ATOMIC); - if (!tun_ctx) { -@@ -1045,11 +988,12 @@ int nss_vxlanmgr_tunnel_create(struct ne - memset(&vxlanmsg, 0, sizeof(struct nss_vxlan_msg)); - vxlan_cfg = &vxlanmsg.msg.vxlan_create; - -+ priv = netdev_priv(dev); - vxlan_cfg->vni = vxlan_get_vni(priv); -- vxlan_cfg->tunnel_flags = parse_flags; -+ vxlan_cfg->tunnel_flags = nss_vxlanmgr_tunnel_flags_parse(priv); - vxlan_cfg->src_port_min = priv->cfg.port_min; - vxlan_cfg->src_port_max = priv->cfg.port_max; -- vxlan_cfg->dest_port = ntohs(priv->cfg.dst_port); -+ vxlan_cfg->dest_port = priv->cfg.dst_port; - vxlan_cfg->tos = priv->cfg.tos; - vxlan_cfg->ttl = (priv->cfg.ttl ? priv->cfg.ttl : IPDEFTTL); - -@@ -1115,6 +1059,7 @@ int nss_vxlanmgr_tunnel_create(struct ne - spin_unlock_bh(&vxlan_ctx.tun_lock); - nss_vxlanmgr_info("%px: VxLAN interface count is #%d\n", dev, vxlan_ctx.tun_count); - -+ dev_put(dev); - return NOTIFY_DONE; - - config_fail: ---- a/wifi_meshmgr/Makefile -+++ /dev/null -@@ -1,7 +0,0 @@ --ccflags-y += -I$(obj)/../exports -I$(obj)/.. -I$(obj)/nss_hal/include --ccflags-y += -DNSS_CLIENT_BUILD_ID="$(BUILD_ID)" --ccflags-y += -DNSS_WIFI_MESHMGR_DEBUG_LEVEL=4 --ccflags-y += -Wall -Werror -- --obj-m += qca-nss-wifi-meshmgr.o --qca-nss-wifi-meshmgr-objs := nss_wifi_meshmgr.o ---- a/wifi_meshmgr/nss_wifi_mesh_priv.h -+++ /dev/null -@@ -1,83 +0,0 @@ --/* -- ************************************************************************** -- * 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. -- ************************************************************************** -- */ -- --/* -- * nss_wifi_mesh_priv.h -- * Mesh manager header -- */ --#ifndef __NSS_WIFI_MESH_PRIV_H_ --#define __NSS_WIFI_MESH_PRIV_H_ -- --#define NSS_WIFI_MESH_MAX 16 -- --/* -- * Compile messages for dynamic enable/disable -- */ --#if defined(CONFIG_DYNAMIC_DEBUG) --#define nss_wifi_meshmgr_warn(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) --#define nss_wifi_meshmgr_info(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) --#define nss_wifi_meshmgr_trace(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) --#else /* CONFIG_DYNAMIC_DEBUG */ --/* -- * Statically compile messages at different levels -- */ --#if (NSS_WIFI_MESHMGR_DEBUG_LEVEL < 2) --#define nss_wifi_meshmgr_warn(s, ...) --#else --#define nss_wifi_meshmgr_warn(s, ...) pr_warn("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) --#endif -- --#if (NSS_WIFI_MESHMGR_DEBUG_LEVEL < 3) --#define nss_wifi_meshmgr_info(s, ...) --#else --#define nss_wifi_meshmgr_info(s, ...) pr_notice("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) --#endif -- --#if (NSS_WIFI_MESHMGR_DEBUG_LEVEL < 4) --#define nss_wifi_meshmgr_trace(s, ...) --#else --#define nss_wifi_meshmgr_trace(s, ...) pr_info("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__) --#endif --#endif /* CONFIG_DYNAMIC_DEBUG */ -- --/* -- * nss_wifi_meshmgr_mesh_ctx -- * Mesh context per interface. -- */ --struct nss_wifi_meshmgr_mesh_ctx { -- struct net_device *dev; /* Netdevice pointer */ -- atomic_t ref; /* Atomic reference count */ -- int32_t encap_ifnum; /* Encap interface number */ -- int32_t decap_ifnum; /* Decap interface number */ -- struct semaphore sem; /* Semaphore for message synchronization */ -- struct completion complete; /* Per context complete */ -- nss_tx_status_t response; /* Response type */ --}; -- --/* -- * nss_wifi_meshmgr_ctx -- * Global mesh context. -- */ --struct nss_wifi_meshmgr_ctx { -- struct nss_ctx_instance *nss_ctx; /* Nss context for mesh */ -- uint32_t mesh_count; /* Active mesh count */ -- spinlock_t ref_lock; /* Spinlock */ -- struct nss_wifi_meshmgr_mesh_ctx *mesh_ctx[NSS_WIFI_MESH_MAX]; -- /* Mesh handle table */ --}; --#endif /* __NSS_WIFI_MESH_PRIV_H_ */ ---- a/wifi_meshmgr/nss_wifi_meshmgr.c -+++ /dev/null -@@ -1,2005 +0,0 @@ --/* -- ************************************************************************** -- * 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. -- ************************************************************************** -- */ -- --/* -- * nss_wifi_meshmgr.c -- * NSS to HLOS WiFi-Mesh manager -- */ -- --#include --#include --#include --#include --#include --#include "nss_wifi_mesh_priv.h" -- --/* -- * WiFi-Mesh context -- */ --static struct nss_wifi_meshmgr_ctx wmgr_ctx; -- --/* -- * nss_wifi_meshmgr_verify_if_num() -- * Verify interface number. -- */ --static bool nss_wifi_meshmgr_verify_if_num(int32_t if_num, enum nss_dynamic_interface_type di_type) --{ -- return (nss_is_dynamic_interface(if_num) && -- (nss_dynamic_interface_get_type(wmgr_ctx.nss_ctx, if_num) == di_type)); --} -- --/* -- * nss_wifi_meshmgr_tx_msg() -- * WiFi-Mesh message send API -- */ --static nss_wifi_meshmgr_status_t nss_wifi_meshmgr_tx_msg(struct nss_wifi_mesh_msg *msg) --{ -- return nss_wifi_mesh_tx_msg(wmgr_ctx.nss_ctx, msg); --} -- --/* -- * nss_wifi_meshmgr_ctx_insert() -- * Insert the mesh context into global table -- */ --static int32_t nss_wifi_meshmgr_ctx_insert(struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx) --{ -- int32_t i, idx = -1; -- struct net_device *dev; -- -- assert_spin_locked(&wmgr_ctx.ref_lock); -- -- /* -- * Check if the context already exist for the same netdev. -- */ -- for (i = 0; i < NSS_WIFI_MESH_MAX; i++) { -- if (!wmgr_ctx.mesh_ctx[i]) { -- idx = i; -- continue; -- } -- -- dev = (wmgr_ctx.mesh_ctx[i])->dev; -- if (dev == wmesh_ctx->dev) { -- nss_wifi_meshmgr_warn("%px: The mesh context already exist for dev:%s", -- &wmgr_ctx, wmesh_ctx->dev->name); -- return -1; -- } -- } -- -- if (idx == -1) { -- return idx; -- } -- -- wmgr_ctx.mesh_ctx[idx] = wmesh_ctx; -- return idx; --} -- --/* -- * nss_wifi_meshmgr_ctx_remove() -- * Remove the mesh context from global table -- */ --static void nss_wifi_meshmgr_ctx_remove(struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx) --{ -- int32_t i; -- -- assert_spin_locked(&wmgr_ctx.ref_lock); -- -- for (i = 0; i < NSS_WIFI_MESH_MAX; i++) { -- if (wmgr_ctx.mesh_ctx[i] != wmesh_ctx) { -- continue; -- } -- -- wmgr_ctx.mesh_ctx[i] = NULL; -- return; -- } --} -- --/* -- * nss_wifi_meshmgr_cleanup() -- * Clean up the mesh context. -- */ --static void nss_wifi_meshmgr_cleanup(struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx) --{ -- int32_t encap_ifnum, decap_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- nss_wifi_meshmgr_trace("%px: Mesh handle cleanup called for: %s\n", &wmgr_ctx, wmesh_ctx->dev->name); -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- decap_ifnum = wmesh_ctx->decap_ifnum; -- -- /* -- * Unregister and dealloc decap DI. -- */ -- nss_unregister_wifi_mesh_if(decap_ifnum); -- nss_status = nss_dynamic_interface_dealloc_node(decap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Failed to dealloc decap: %d\n", &wmgr_ctx, nss_status); -- } -- -- /* -- * Unregister and dealloc encap DI. -- */ -- nss_unregister_wifi_mesh_if(encap_ifnum); -- nss_status = nss_dynamic_interface_dealloc_node(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Failed to dealloc encap: %d\n", &wmgr_ctx, nss_status); -- } -- -- dev_put(wmesh_ctx->dev); -- kfree(wmesh_ctx); --} -- --/* -- * nss_wifi_meshmgr_ref_dec() -- * Find and decrement the reference counter. -- */ --static void nss_wifi_meshmgr_ref_dec(struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx) --{ -- if (atomic_dec_and_test(&wmesh_ctx->ref)) { -- nss_wifi_meshmgr_cleanup(wmesh_ctx); -- } --} -- --/* -- * nss_wifi_meshmgr_find_and_ref_inc() -- * Find and inreae the reference counter. -- */ --static struct nss_wifi_meshmgr_mesh_ctx *nss_wifi_meshmgr_find_and_ref_inc(nss_wifi_mesh_handle_t mesh_handle) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- -- if ((mesh_handle < 0) || (mesh_handle >= NSS_WIFI_MESH_MAX)) { -- nss_wifi_meshmgr_warn("%px: Invalid mesh handle: %d\n", &wmgr_ctx, mesh_handle); -- return NULL; -- } -- -- spin_lock_bh(&wmgr_ctx.ref_lock); -- wmesh_ctx = wmgr_ctx.mesh_ctx[mesh_handle]; -- if (wmesh_ctx && atomic_inc_and_test(&wmesh_ctx->ref)) { -- BUG_ON(1); -- } -- spin_unlock_bh(&wmgr_ctx.ref_lock); -- return wmesh_ctx; --} -- --/* -- * nss_wifi_meshmgr_remap_error() -- * Remap the error code. -- */ --static nss_wifi_meshmgr_status_t nss_wifi_meshmgr_remap_error(enum nss_wifi_mesh_error_types error) --{ -- switch (error) { -- case NSS_WIFI_MESH_ERROR_UNKNOWN_MSG: -- return NSS_WIFI_MESHMGR_FAILURE_UNKNOWN_MSG; -- case NSS_WIFI_MESH_ERROR_TTL_CONFIG: -- return NSS_WIFI_MESHMGR_FAILURE_TTL_CONFIG; -- case NSS_WIFI_MESH_ERROR_REFRESH_TIME_CONFIG: -- return NSS_WIFI_MESHMGR_FAILURE_REFRESH_TIME_CONFIG; -- case NSS_WIFI_MESH_ERROR_MPP_LEARNING_MODE_CONFIG: -- return NSS_WIFI_MESHMGR_FAILURE_MPP_LEARNING_MODE_CONFIG; -- case NSS_WIFI_MESH_ERROR_PATH_ADD_MAX_RADIO_CNT: -- return NSS_WIFI_MESHMGR_FAILURE_PATH_ADD_MAX_RADIO_CNT; -- case NSS_WIFI_MESH_ERROR_PATH_ADD_INVALID_INTERFACE_NUM: -- return NSS_WIFI_MESHMGR_FAILURE_PATH_ADD_INVALID_INTERFACE_NUM; -- case NSS_WIFI_MESH_ERROR_PATH_ADD_INTERFACE_NUM_NOT_FOUND: -- return NSS_WIFI_MESHMGR_FAILURE_PATH_ADD_INTERFACE_NUM_NOT_FOUND; -- case NSS_WIFI_MESH_ERROR_PATH_TABLE_FULL: -- return NSS_WIFI_MESHMGR_FAILURE_PATH_TABLE_FULL; -- case NSS_WIFI_MESH_ERROR_PATH_ALLOC_FAIL: -- return NSS_WIFI_MESHMGR_FAILURE_PATH_ALLOC_FAIL; -- case NSS_WIFI_MESH_ERROR_PATH_INSERT_FAIL: -- return NSS_WIFI_MESHMGR_FAILURE_PATH_INSERT_FAIL; -- case NSS_WIFI_MESH_ERROR_PATH_NOT_FOUND: -- return NSS_WIFI_MESHMGR_FAILURE_PATH_NOT_FOUND; -- case NSS_WIFI_MESH_ERROR_PATH_UNHASHED: -- return NSS_WIFI_MESHMGR_FAILURE_PATH_UNHASHED; -- case NSS_WIFI_MESH_ERROR_PATH_DELETE_FAIL: -- return NSS_WIFI_MESHMGR_FAILURE_PATH_DELETE_FAIL; -- case NSS_WIFI_MESH_ERROR_PROXY_PATH_NOT_FOUND: -- return NSS_WIFI_MESHMGR_FAILURE_PROXY_PATH_NOT_FOUND; -- case NSS_WIFI_MESH_ERROR_PROXY_PATH_UNHASHED: -- return NSS_WIFI_MESHMGR_FAILURE_PROXY_PATH_UNHASHED; -- case NSS_WIFI_MESH_ERROR_PROXY_PATH_DELETE_FAIL: -- return NSS_WIFI_MESHMGR_FAILURE_PROXY_PATH_DELETE_FAIL; -- case NSS_WIFI_MESH_ERROR_PROXY_PATH_EXISTS: -- return NSS_WIFI_MESHMGR_FAILURE_PROXY_PATH_EXISTS; -- case NSS_WIFI_MESH_ERROR_PROXY_PATH_ALLOC_FAIL: -- return NSS_WIFI_MESHMGR_FAILURE_PROXY_PATH_ALLOC_FAIL; -- case NSS_WIFI_MESH_ERROR_PROXY_PATH_INSERT_FAIL: -- return NSS_WIFI_MESHMGR_FAILURE_PROXY_PATH_INSERT_FAIL; -- case NSS_WIFI_MESH_ERROR_PROXY_PATH_TABLE_FULL: -- return NSS_WIFI_MESHMGR_FAILURE_PROXY_PATH_TABLE_FULL; -- case NSS_WIFI_MESH_ERROR_PB_ALLOC_FAIL: -- return NSS_WIFI_MESHMGR_FAILURE_PB_ALLOC_FAIL; -- case NSS_WIFI_MESH_ERROR_ENQUEUE_TO_HOST_FAIL: -- return NSS_WIFI_MESHMGR_FAILURE_ENQUEUE_TO_HOST_FAIL; -- case NSS_WIFI_MESH_ERROR_ENABLE_INTERFACE_FAIL: -- return NSS_WIFI_MESHMGR_FAILURE_ENABLE_INTERFACE_FAIL; -- case NSS_WIFI_MESH_ERROR_DISABLE_INTERFACE_FAIL: -- return NSS_WIFI_MESHMGR_FAILURE_DISABLE_INTERFACE_FAIL; -- case NSS_WIFI_MESH_ERROR_INVALID_EXCEPTION_NUM: -- return NSS_WIFI_MESHMGR_FAILURE_INVALID_EXCEPTION_NUM; -- case NSS_WIFI_MESH_ERROR_ONESHOT_ALREADY_ATTACHED: -- return NSS_WIFI_MESHMGR_FAILURE_ONESHOT_ALREADY_ATTACHED; -- case NSS_WIFI_MESH_ERROR_DUMMY_PATH_ADD_FAILED: -- return NSS_WIFI_MESHMGR_FAILURE_DUMMY_PATH_ADD; -- case NSS_WIFI_MESH_ERROR_DUMMY_PROXY_PATH_ADD_FAILED: -- return NSS_WIFI_MESHMGR_FAILURE_DUMMY_PROXY_PATH_ADD; -- default: -- return NSS_WIFI_MESHMGR_FAILURE; -- }; --} -- --/* -- * nss_wifi_meshmgr_tx_msg_cb() -- * Callback to handle the completion of NSS->HLOS messages. -- */ --static void nss_wifi_meshmgr_tx_msg_cb(void *app_data, struct nss_cmn_msg *ncm) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx = (struct nss_wifi_meshmgr_mesh_ctx *)app_data; -- uint32_t error_code = ncm->error; -- -- /* -- * FIXME: The wmesh_ctx can be invalid if the memory goes away with the caller being timedout. -- */ -- wmesh_ctx->response = NSS_WIFI_MESHMGR_SUCCESS; -- if (ncm->response != NSS_CMN_RESPONSE_ACK) { -- nss_wifi_meshmgr_warn("%px: WiFi-Mesh error response %d error_code: %u\n", &wmgr_ctx, ncm->response, error_code); -- wmesh_ctx->response = nss_wifi_meshmgr_remap_error(error_code); -- } -- -- complete(&wmesh_ctx->complete); --} -- -- /* -- * nss_wifi_meshmgr_tx_msg_sync() -- * Transmit a WiFi mesh message to NSS firmware synchronously. -- */ --static nss_wifi_meshmgr_status_t nss_wifi_meshmgr_tx_msg_sync(struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx, struct nss_wifi_mesh_msg *wmesh_msg) --{ -- nss_wifi_meshmgr_status_t status; -- int ret; -- -- down(&wmesh_ctx->sem); -- status = nss_wifi_meshmgr_tx_msg(wmesh_msg); -- if (status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh tx sync msg failed: %d\n", &wmgr_ctx, status); -- up(&wmesh_ctx->sem); -- return status; -- } -- -- /* -- * Wait for the acknowledgement. -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- return status; --} -- --/* -- * nss_wifi_meshmgr_tx_buf() -- * Send packets to mesh I/F -- */ --nss_wifi_meshmgr_status_t nss_wifi_meshmgr_tx_buf(nss_wifi_mesh_handle_t mesh_handle, struct sk_buff *os_buf) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- int32_t encap_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- nss_status = nss_wifi_mesh_tx_buf(wmgr_ctx.nss_ctx, os_buf, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_tx_buf); -- --/* -- * nss_wifi_meshmgr_if_down() -- * Make the NSS interface down synchronously. -- */ --nss_wifi_meshmgr_status_t nss_wifi_meshmgr_if_down(nss_wifi_mesh_handle_t mesh_handle) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- nss_wifi_meshmgr_status_t nss_status; -- int32_t encap_ifnum, decap_ifnum; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- decap_ifnum = wmesh_ctx->decap_ifnum; -- -- /* -- * Verify the I/F encap and decap number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER) || -- nss_wifi_meshmgr_verify_if_num(decap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER))) { -- nss_wifi_meshmgr_warn("%px: Interface verification failed\n", &wmgr_ctx); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the encap I/F down message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_IF_CLOSE, -- sizeof(struct nss_if_close), nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- -- /* -- * Send the I/F down message to the encap I/F. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg_sync(wmesh_ctx, &wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh link encap I/F down failed: %d.\n", &wmgr_ctx, nss_status); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Initialize the decap I/F down message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nss_wifi_mesh_msg_init(&wmesh_msg, decap_ifnum, NSS_IF_CLOSE, -- sizeof(struct nss_if_close), nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- -- /* -- * Send the I/F down message to the decap I/F. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg_sync(wmesh_ctx, &wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh link decap I/F down failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_if_down); -- --/* -- * nss_wifi_meshmgr_if_up() -- * Make the NSS interface up synchronously. -- */ --nss_wifi_meshmgr_status_t nss_wifi_meshmgr_if_up(nss_wifi_mesh_handle_t mesh_handle) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- nss_wifi_meshmgr_status_t nss_status; -- int32_t encap_ifnum, decap_ifnum; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- decap_ifnum = wmesh_ctx->decap_ifnum; -- -- /* -- * Verify the I/F encap and decap number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER) || -- nss_wifi_meshmgr_verify_if_num(decap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER))) { -- nss_wifi_meshmgr_warn("%px: Interface verification failed\n", &wmgr_ctx); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the encap I/F up message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_IF_OPEN, -- sizeof(struct nss_if_open), nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- -- /* -- * Send the I/F up message to the encap I/F. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg_sync(wmesh_ctx, &wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh link encap I/F up failed: %d.\n", &wmgr_ctx, nss_status); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Initialize the I/F decap up message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nss_wifi_mesh_msg_init(&wmesh_msg, decap_ifnum, NSS_IF_OPEN, -- sizeof(struct nss_if_open), nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- -- /* -- * Send the I/F up message to the decap interface. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg_sync(wmesh_ctx, &wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh link decap I/F up failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_if_up); -- --/* -- * nss_wifi_meshmgr_dump_mesh_path() -- * Dump mesh path table request asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_dump_mesh_path(nss_wifi_mesh_handle_t mesh_handle, nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- nss_wifi_meshmgr_status_t nss_status; -- int32_t encap_ifnum; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the path dump request message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_WIFI_MESH_MSG_PATH_TABLE_DUMP, -- sizeof(struct nss_wifi_mesh_path_table_dump), msg_cb, app_data); -- -- /* -- * Send the path dump request mesage to the NSS asynchronously. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh dump mesh path failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_dump_mesh_path); -- --/* -- * nss_wifi_meshmgr_dump_mesh_path_sync() -- * Dump mesh path table request synchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_dump_mesh_path_sync(nss_wifi_mesh_handle_t mesh_handle) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- nss_wifi_meshmgr_status_t nss_status; -- int32_t ret; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the path dump request mesage to the NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_dump_mesh_path(mesh_handle, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh path dump msg failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_dump_mesh_path_sync); -- --/* -- * nss_wifi_meshmgr_dump_mesh_proxy_path() -- * Dump mesh proxy path table request asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_dump_mesh_proxy_path(nss_wifi_mesh_handle_t mesh_handle, nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- nss_wifi_meshmgr_status_t nss_status; -- int32_t encap_ifnum; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the proxy path table message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_WIFI_MESH_MSG_PROXY_PATH_TABLE_DUMP, -- sizeof(struct nss_wifi_mesh_proxy_path_table_dump), msg_cb, app_data); -- -- /* -- * Send the proxy path dump message to NSS asynchronously. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh link vap proxy path dump failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_dump_mesh_proxy_path); -- --/* -- * nss_wifi_meshmgr_dump_mesh_path_sync() -- * Dump mesh proxy path table request synchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_dump_mesh_proxy_path_sync(nss_wifi_mesh_handle_t mesh_handle) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- nss_wifi_meshmgr_status_t nss_status; -- int32_t ret; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the path dump request to the NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_dump_mesh_proxy_path(mesh_handle, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh proxy path dump msg failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_dump_mesh_proxy_path_sync); -- --/* -- * nss_wifi_meshmgr_assoc_link_vap() -- * Associate the link interface to the mesh I/F asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_assoc_link_vap(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_assoc_link_vap *wmalv, -- nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_vdev_msg *wifivdevmsg; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- struct nss_wifi_vdev_set_next_hop_msg *next_hop_msg = NULL; -- int32_t decap_ifnum, link_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- wifivdevmsg = kzalloc(sizeof(*wifivdevmsg), GFP_ATOMIC); -- if (!wifivdevmsg) { -- nss_wifi_meshmgr_warn("%px: Failed to allocate message memmory", &wmgr_ctx); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- decap_ifnum = wmesh_ctx->decap_ifnum; -- -- /* -- * Verify the decap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(decap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, decap_ifnum); -- kfree(wifivdevmsg); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- -- link_ifnum = wmalv->link_vap_id; -- -- /* -- * Verify the link VAP I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(link_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_VAP))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, link_ifnum); -- kfree(wifivdevmsg); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- -- next_hop_msg = &wifivdevmsg->msg.next_hop; -- next_hop_msg->ifnumber = decap_ifnum; -- nss_cmn_msg_init(&wifivdevmsg->cm, link_ifnum, NSS_WIFI_VDEV_SET_NEXT_HOP, sizeof(*next_hop_msg), -- msg_cb, app_data); -- -- /* -- * Send the link vap mesage to the NSS synchronously. -- */ -- nss_status = nss_wifi_vdev_tx_msg(wmgr_ctx.nss_ctx, wifivdevmsg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh link vap association failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- kfree(wifivdevmsg); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_assoc_link_vap); -- --/* -- * nss_wifi_meshmgr_assoc_link_vap_sync() -- * Associate the link VAP to the mesh I/F synchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_assoc_link_vap_sync(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_assoc_link_vap *wmalv) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- nss_wifi_meshmgr_status_t nss_status; -- int32_t ret; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the link vap mesage to the NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_assoc_link_vap(mesh_handle, wmalv, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh link vap association failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_assoc_link_vap_sync); -- --/* -- * nss_wifi_meshmgr_mesh_config_update() -- * Update mesh configuration message asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_config_update(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_config_msg *wmcum, -- nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- struct nss_wifi_mesh_config_msg *nwmcum; -- int32_t encap_ifnum, decap_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- decap_ifnum = wmesh_ctx->decap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Verify the decap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(decap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER))) { -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, decap_ifnum); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the mesh configuration messsage. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nwmcum = &wmesh_msg.msg.mesh_config; -- memcpy(nwmcum, wmcum, sizeof(*nwmcum)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_WIFI_MESH_MSG_INTERFACE_CONFIGURE, -- sizeof(*nwmcum), msg_cb, app_data); -- -- /* -- * Send the configuration message to encap I/F. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh configuration message failed: %d.\n", &wmgr_ctx, nss_status); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Initialize the mesh configuration messsage. -- */ -- nss_wifi_mesh_msg_init(&wmesh_msg, decap_ifnum, NSS_WIFI_MESH_MSG_INTERFACE_CONFIGURE, -- sizeof(*nwmcum), msg_cb, app_data); -- -- /* -- * Send the configuration message decap I/F. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh configuration message failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_config_update); -- --/* -- * nss_wifi_meshmgr_mesh_config_update_sync() -- * Update mesh configuration message synchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_config_update_sync(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_config_msg *wmcum) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- nss_wifi_meshmgr_status_t nss_status; -- int32_t ret; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the message to NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_mesh_config_update(mesh_handle, wmcum, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh proxy path update failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_config_update_sync); -- --/* -- * nss_wifi_meshmgr_mesh_proxy_path_delete() -- * Delete the mesh proxy path asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_proxy_path_delete(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_proxy_path_del_msg *wmppdm, -- nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- struct nss_wifi_mesh_proxy_path_del_msg *nwmppdm; -- int32_t encap_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nwmppdm = &wmesh_msg.msg.proxy_del_msg; -- memcpy(nwmppdm, wmppdm, sizeof(*nwmppdm)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_WIFI_MESH_MSG_PROXY_PATH_DELETE, -- sizeof(*nwmppdm), msg_cb, app_data); -- -- /* -- * Send the message to NSS asynchronously. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh proxy path delete failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_proxy_path_delete); -- --/* -- * nss_wifi_meshmgr_mesh_proxy_path_delete_sync() -- * Delete the mesh proxy path synchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_proxy_path_delete_sync(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_proxy_path_del_msg *wmppdm) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- nss_wifi_meshmgr_status_t nss_status; -- int32_t ret; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the message to NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_mesh_proxy_path_delete(mesh_handle, wmppdm, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh proxy path delete failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_proxy_path_delete_sync); -- --/* -- * nss_wifi_meshmgr_mesh_proxy_path_update() -- * Mesh prpxy path update message asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_proxy_path_update(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_proxy_path_update_msg *wmppum, -- nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- struct nss_wifi_mesh_proxy_path_update_msg *nwmppum; -- int32_t encap_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nwmppum = &wmesh_msg.msg.proxy_update_msg; -- memcpy(nwmppum, wmppum, sizeof(*nwmppum)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_WIFI_MESH_MSG_PROXY_PATH_UPDATE, -- sizeof(*nwmppum), msg_cb, app_data); -- -- /* -- * Send the message to NSS asynchronously -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh proxy path update failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_proxy_path_update); -- --/* -- * nss_wifi_meshmgr_mesh_proxy_path_update_sync() -- * Send proxy update message synchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_proxy_path_update_sync(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_proxy_path_update_msg *wmppum) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- nss_wifi_meshmgr_status_t nss_status; -- int32_t ret; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the message to NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_mesh_proxy_path_update(mesh_handle, wmppum, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh proxy path update failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_proxy_path_update_sync); -- --/* -- * nss_wifi_meshmgr_mesh_proxy_path_add() -- * Send mesh proxy add message asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_proxy_path_add(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_proxy_path_add_msg *wmppam, -- nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- struct nss_wifi_mesh_proxy_path_add_msg *nwmppam; -- int32_t encap_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the message -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nwmppam = &wmesh_msg.msg.proxy_add_msg; -- memcpy(nwmppam, wmppam, sizeof(*nwmppam)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_WIFI_MESH_MSG_PROXY_PATH_ADD, -- sizeof(*nwmppam), msg_cb, app_data); -- -- /* -- * Send the message to NSS asynchronously. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh proxy path add failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_proxy_path_add); -- --/* -- * nss_wifi_meshmgr_mesh_proxy_path_add_sync() -- * Send mesh proxy add message synchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_proxy_path_add_sync(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_proxy_path_add_msg *wmppam) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- int32_t ret; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the message to NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_mesh_proxy_path_add(mesh_handle, wmppam, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh proxy path add failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_proxy_path_add_sync); -- --/* -- * nss_wifi_meshmgr_mesh_path_delete() -- * Send the mesh path delete message asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_path_delete(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_mpath_del_msg *wmpdm, -- nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- struct nss_wifi_mesh_mpath_del_msg *nwmpdm; -- int32_t encap_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nwmpdm = &wmesh_msg.msg.mpath_del; -- memcpy(nwmpdm, wmpdm, sizeof(*nwmpdm)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_WIFI_MESH_MSG_MPATH_DELETE, -- sizeof(*nwmpdm), msg_cb, app_data); -- -- /* -- * Send the message to NSS asynchronously. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh path delete failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_path_delete); -- --/* -- * nss_wifi_meshmgr_mesh_path_delete_sync() -- * Send the mesh path delete message synchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_path_delete_sync(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_mpath_del_msg *wmpdm) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- int32_t ret; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the message to NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_mesh_path_delete(mesh_handle, wmpdm, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh path delete failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_path_delete_sync); -- --/* -- * nss_wifi_meshmgr_mesh_path_add() -- * Mesh path add message asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_path_add(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_mpath_add_msg *wmpam, -- nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_mesh_mpath_add_msg *nwmpam; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- int32_t encap_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nwmpam = &wmesh_msg.msg.mpath_add; -- memcpy(nwmpam, wmpam, sizeof(*nwmpam)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_WIFI_MESH_MSG_MPATH_ADD, -- sizeof(*nwmpam), msg_cb, app_data); -- -- /* -- * Send the message to NSS asynchronously. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh path addition failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_path_add); -- --/* -- * nss_wifi_meshmgr_mesh_path_add_sync() -- * Mesh path add message synchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_path_add_sync(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_mpath_add_msg *wmpam) --{ -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- int32_t ret; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the message to NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_mesh_path_add(mesh_handle, wmpam, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh path addition failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_path_add_sync); -- --/* -- * nss_wifi_meshmgr_mpath_update() -- * Send mesh path update message asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_path_update(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_mpath_update_msg *wmpum, -- nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_mesh_mpath_update_msg *nwmpum; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- int32_t encap_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the mesh path update message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nwmpum = &wmesh_msg.msg.mpath_update; -- memcpy(nwmpum, wmpum, sizeof(*nwmpum)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_WIFI_MESH_MSG_MPATH_UPDATE, -- sizeof(*nwmpum), msg_cb, app_data); -- -- /* -- * Send the message to NSS asynchronously. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh MPath update failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_path_update); -- --/* -- * nss_wifi_meshmgr_mpath_update_sync() -- * Send mesh path update message sychronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_path_update_sync(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_mpath_update_msg *wmpum) --{ -- nss_wifi_meshmgr_status_t nss_status; -- int32_t ret; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the message to NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_mesh_path_update(mesh_handle, wmpum, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh MPath update failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_path_update_sync); -- --/* -- * nss_wifi_meshmgr_mesh_path_exception() -- * Mesh path exception msg asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_path_exception(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_exception_flag_msg *wmefm, -- nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_mesh_exception_flag_msg *nwmefm; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- int32_t encap_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Initialize the message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nwmefm = &wmesh_msg.msg.exception_msg; -- memcpy(nwmefm, wmefm, sizeof(*nwmefm)); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_WIFI_MESH_MSG_EXCEPTION_FLAG, -- sizeof(*nwmefm), msg_cb, app_data); -- -- /* -- * Send the message to NSS asynchronously. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh path exception message failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_path_exception); -- --/* -- * nss_wifi_meshmgr_mesh_path_exception_sync() -- * Send mesh path exception message sychronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_mesh_path_exception_sync(nss_wifi_mesh_handle_t mesh_handle,struct nss_wifi_mesh_exception_flag_msg *wmefm) --{ -- nss_wifi_meshmgr_status_t nss_status; -- int32_t ret; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the message to NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_mesh_path_exception(mesh_handle, wmefm, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh path exception message failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_mesh_path_exception_sync); -- --/* -- * nss_wifi_meshmgr_config_mesh_exception() -- * Configure mesh exception asynchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_config_mesh_exception(nss_wifi_mesh_handle_t mesh_handle, struct nss_wifi_mesh_rate_limit_config *wmrlc, -- nss_wifi_mesh_msg_callback_t msg_cb, void *app_data) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_mesh_rate_limit_config *nwmrlc; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- int32_t encap_ifnum, decap_ifnum, ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- decap_ifnum = wmesh_ctx->decap_ifnum; -- -- /* -- * Verify the decap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(decap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, decap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- switch(wmrlc->exception_num) { -- case NSS_WIFI_MESH_DS_MESH_PATH_NOT_FOUND: -- ifnum = encap_ifnum; -- break; -- -- case NSS_WIFI_MESH_US_MESH_PROXY_NOT_FOUND: -- ifnum = decap_ifnum; -- break; -- -- case NSS_WIFI_MESH_US_MESH_PATH_NOT_FOUND: -- ifnum = decap_ifnum; -- break; -- } -- -- /* -- * Initialize the message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nwmrlc = &wmesh_msg.msg.exc_cfg; -- memcpy(nwmrlc, wmrlc, sizeof(*nwmrlc)); -- nss_wifi_mesh_msg_init(&wmesh_msg, ifnum, NSS_WIFI_MESH_CONFIG_EXCEPTION, -- sizeof(*nwmrlc), msg_cb, app_data); -- -- /* -- * Send the message to NSS asynchronously. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg(&wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh config exception message failed: %d.\n", &wmgr_ctx, nss_status); -- } -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_config_mesh_exception); -- --/* -- * nss_wifi_meshmgr_config_mesh_exception_sync() -- * Configure mesh exception synchronously. -- */ --nss_wifi_meshmgr_status_t --nss_wifi_meshmgr_config_mesh_exception_sync(nss_wifi_mesh_handle_t mesh_handle,struct nss_wifi_mesh_rate_limit_config *wmrlc) --{ -- nss_wifi_meshmgr_status_t nss_status; -- int32_t ret; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_NULL_MESH_CTX; -- } -- -- /* -- * Send the message to NSS synchronously. -- */ -- down(&wmesh_ctx->sem); -- nss_status = nss_wifi_meshmgr_config_mesh_exception(mesh_handle, wmrlc, nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Mesh config exception message failed: %d.\n", &wmgr_ctx, nss_status); -- up(&wmesh_ctx->sem); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wmesh_ctx->complete, msecs_to_jiffies(NSS_WIFI_MESH_TX_TIMEOUT)); -- if (!ret) { -- nss_wifi_meshmgr_warn("%px: WiFi mesh msg tx failed due to timeout\n", &wmgr_ctx); -- wmesh_ctx->response = NSS_WIFI_MESHMGR_FAILURE_SYNC_TIMEOUT; -- } -- -- nss_status = wmesh_ctx->response; -- up(&wmesh_ctx->sem); -- -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_config_mesh_exception_sync); -- --/* -- * nss_wifi_meshmgr_if_destroy_sync() -- * Function to unregister and destroy dynamic interfaces synchronously. -- */ --nss_wifi_meshmgr_status_t nss_wifi_meshmgr_if_destroy_sync(nss_wifi_mesh_handle_t mesh_handle) --{ -- int32_t encap_ifnum, decap_ifnum; -- nss_wifi_meshmgr_status_t nss_status; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- -- wmesh_ctx = nss_wifi_meshmgr_find_and_ref_inc(mesh_handle); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Mesh context is null\n", &wmgr_ctx); -- return NSS_WIFI_MESHMGR_FAILURE_BAD_PARAM; -- } -- -- encap_ifnum = wmesh_ctx->encap_ifnum; -- decap_ifnum = wmesh_ctx->decap_ifnum; -- -- /* -- * Verify the encap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, encap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Verify the decap I/F number against it types. -- */ -- if (!(nss_wifi_meshmgr_verify_if_num(decap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER))) { -- nss_wifi_meshmgr_warn("%px: I/F num: 0x%x verification failed\n", &wmgr_ctx, decap_ifnum); -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return NSS_WIFI_MESHMGR_FAILURE; -- } -- -- /* -- * Send the I/F down message to NSS. -- */ -- nss_status = nss_wifi_meshmgr_if_down(mesh_handle); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Sending mesh I/F down to NSS failed: %d\n", &wmgr_ctx, nss_status); -- } -- -- /* -- * Remove mesh context from the table. -- */ -- spin_lock_bh(&wmgr_ctx.ref_lock); -- nss_wifi_meshmgr_ctx_remove(wmesh_ctx); -- wmgr_ctx.mesh_count--; -- spin_unlock_bh(&wmgr_ctx.ref_lock); -- -- /* -- * Release the reference taken during alloc. -- */ -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- -- /* -- * Release the reference for the find taken at the beginning of the function. -- */ -- nss_wifi_meshmgr_ref_dec(wmesh_ctx); -- return nss_status; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_if_destroy_sync); -- --/* -- * nss_wifi_meshmgr_if_create_sync() -- * Create and register dynamic interface synchronously. -- * -- * Note: Synchronous create message, callbacks are used for driver registration not message handling. -- */ --nss_wifi_mesh_handle_t nss_wifi_meshmgr_if_create_sync(struct net_device *dev, struct nss_wifi_mesh_config_msg *wmcm, -- nss_wifi_mesh_data_callback_t data_cb, -- nss_wifi_mesh_ext_data_callback_t ext_data_cb, -- nss_wifi_mesh_msg_callback_t event_cb) --{ -- struct nss_wifi_mesh_msg wmesh_msg; -- struct nss_wifi_mesh_config_msg *nwmcm; -- int32_t encap_ifnum, decap_ifnum; -- uint32_t features = 0; -- nss_wifi_mesh_handle_t mesh_handle; -- nss_wifi_meshmgr_status_t nss_status; -- struct nss_wifi_meshmgr_mesh_ctx *wmesh_ctx; -- -- spin_lock_bh(&wmgr_ctx.ref_lock); -- if (wmgr_ctx.mesh_count == NSS_WIFI_MESH_MAX) { -- nss_wifi_meshmgr_warn("%px: Reached maxed number of mesh interface\n", dev); -- spin_unlock_bh(&wmgr_ctx.ref_lock); -- return -1; -- } -- -- wmgr_ctx.mesh_count++; -- spin_unlock_bh(&wmgr_ctx.ref_lock); -- -- dev_hold(dev); -- wmesh_ctx = kzalloc(sizeof(*wmesh_ctx), GFP_ATOMIC); -- if (!wmesh_ctx) { -- nss_wifi_meshmgr_warn("%px: Failed to allocate memory for mesh context\n", dev); -- goto ctx_alloc_fail; -- } -- -- wmesh_ctx->dev = dev; -- sema_init(&wmesh_ctx->sem, 1); -- init_completion(&wmesh_ctx->complete); -- -- /* -- * Alloc the encap dynamic interface node. -- */ -- encap_ifnum = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER); -- if (encap_ifnum < 0) { -- nss_wifi_meshmgr_warn("%px: Encap allocation failed.\n", dev); -- goto encap_alloc_fail; -- } -- -- if (nss_register_wifi_mesh_if(encap_ifnum, data_cb, ext_data_cb, event_cb, -- NSS_WIFI_MESH_DP_INNER, dev, features) != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Encap registration failed.\n", dev); -- goto encap_reg_fail; -- } -- -- /* -- * Allocate and register decap interface. -- */ -- decap_ifnum = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER); -- if (decap_ifnum < 0) { -- nss_wifi_meshmgr_warn("%px: Decap allocation failed.\n", dev); -- goto decap_alloc_fail; -- } -- -- -- if (nss_register_wifi_mesh_if(decap_ifnum, data_cb, ext_data_cb, event_cb, -- NSS_WIFI_MESH_DP_OUTER, dev, features) != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Decap registration failed.\n", dev); -- goto decap_reg_fail; -- } -- -- wmesh_ctx->encap_ifnum = encap_ifnum; -- wmesh_ctx->decap_ifnum = decap_ifnum; -- -- nss_wifi_meshmgr_trace("%px: Successfully registered encap and decap iface for Mesh\n", dev); -- -- /* -- * Initialize the encap configuration message. -- */ -- memset(&wmesh_msg, 0, sizeof(struct nss_wifi_mesh_msg)); -- nwmcm = &wmesh_msg.msg.mesh_config; -- nwmcm->ttl = wmcm->ttl; -- nwmcm->mesh_path_refresh_time = wmcm->mesh_path_refresh_time; -- nwmcm->mpp_learning_mode = wmcm->mpp_learning_mode; -- nwmcm->config_flags = wmcm->config_flags | NSS_WIFI_MESH_CONFIG_FLAG_SIBLING_IF_NUM_VALID; -- nwmcm->sibling_ifnum = decap_ifnum; -- -- ether_addr_copy(nwmcm->local_mac_addr, wmcm->local_mac_addr); -- nss_wifi_mesh_msg_init(&wmesh_msg, encap_ifnum, NSS_WIFI_MESH_MSG_INTERFACE_CONFIGURE, -- sizeof(*nwmcm), nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- -- /* -- * Send the encap configuration message. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg_sync(wmesh_ctx, &wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Encap configuration message failed: %d.\n", dev, nss_status); -- goto config_failed; -- } -- -- /* -- * Initialize the decap configuration message. -- */ -- nwmcm->sibling_ifnum = encap_ifnum; -- nwmcm->block_mesh_forwarding = wmcm->block_mesh_forwarding; -- nss_wifi_mesh_msg_init(&wmesh_msg, decap_ifnum, NSS_WIFI_MESH_MSG_INTERFACE_CONFIGURE, -- sizeof(*nwmcm), nss_wifi_meshmgr_tx_msg_cb, wmesh_ctx); -- -- /* -- * Send the decap configuration message. -- */ -- nss_status = nss_wifi_meshmgr_tx_msg_sync(wmesh_ctx, &wmesh_msg); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Decap configuration message failed: %d.\n", dev, nss_status); -- goto config_failed; -- } -- -- /* -- * Take the self reference on the mesh context. -- */ -- atomic_set(&wmesh_ctx->ref, 1); -- -- /* -- * Add the Mesh context to the mesh manager's list. -- */ -- spin_lock_bh(&wmgr_ctx.ref_lock); -- mesh_handle = nss_wifi_meshmgr_ctx_insert(wmesh_ctx); -- if (mesh_handle < 0) { -- spin_unlock_bh(&wmgr_ctx.ref_lock); -- nss_wifi_meshmgr_warn("%px: Insertion for mesh context failed", &wmgr_ctx); -- goto config_failed; -- } -- -- spin_unlock_bh(&wmgr_ctx.ref_lock); -- -- nss_wifi_meshmgr_trace("%px: WiFi Mesh interface count:%d.\n", dev, wmgr_ctx.mesh_count); -- return mesh_handle; -- --config_failed: -- nss_unregister_wifi_mesh_if(decap_ifnum); --decap_reg_fail: -- nss_dynamic_interface_dealloc_node(decap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Decap interface dealloc failed: %d\n", dev, nss_status); -- } --decap_alloc_fail: -- nss_unregister_wifi_mesh_if(encap_ifnum); --encap_reg_fail: -- nss_dynamic_interface_dealloc_node(encap_ifnum, NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER); -- if (nss_status != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px: Encap interface dealloc failed: %d\n", dev, nss_status); -- } --encap_alloc_fail: -- kfree(wmesh_ctx); --ctx_alloc_fail: -- spin_lock_bh(&wmgr_ctx.ref_lock); -- wmgr_ctx.mesh_count--; -- spin_unlock_bh(&wmgr_ctx.ref_lock); -- dev_put(dev); -- return -1; --} --EXPORT_SYMBOL(nss_wifi_meshmgr_if_create_sync); -- --/* -- * nss_wifi_meshmgr_exit_module() -- * WiFi-Mesh module exit function -- */ --static void __exit nss_wifi_meshmgr_exit_module(void) --{ -- int32_t i; -- -- /* -- * Check if there are any mesh I/F. Delete all the mesh I/F from NSS FW and free. -- */ -- for (i = 0; i < NSS_WIFI_MESH_MAX; i++) { -- if (nss_wifi_meshmgr_if_destroy_sync(i) != NSS_WIFI_MESHMGR_SUCCESS) { -- nss_wifi_meshmgr_warn("%px Destroy failed or context does not exist", &wmgr_ctx); -- } -- } -- nss_wifi_meshmgr_info("Module %s unloaded\n", NSS_CLIENT_BUILD_ID); --} -- --/* -- * nss_wifi_meshmgr_init_module() -- * Wi-Fi mesh manager module init function -- */ --static int __init nss_wifi_meshmgr_init_module(void) --{ -- struct nss_ctx_instance *nss_ctx; -- int32_t idx; -- --#ifdef CONFIG_OF -- /* -- * If the node is not compatible, don't do anything. -- */ -- if (!of_find_node_by_name(NULL, "nss-common")) { -- nss_wifi_meshmgr_warn("NSS common not found.\n"); -- return -1; -- } --#endif -- -- nss_ctx = nss_wifi_mesh_get_context(); -- if (!nss_ctx) { -- nss_wifi_meshmgr_warn("NSS SoC context is NULL.\n"); -- return -1; -- } -- -- wmgr_ctx.nss_ctx = nss_ctx; -- for (idx = 0; idx < NSS_WIFI_MESH_MAX; idx++) { -- wmgr_ctx.mesh_ctx[idx] = NULL; -- } -- -- wmgr_ctx.mesh_count = 0; -- spin_lock_init(&wmgr_ctx.ref_lock); -- -- nss_wifi_meshmgr_info("Module %s loaded\n", NSS_CLIENT_BUILD_ID); -- return 0; --} -- --module_init(nss_wifi_meshmgr_init_module); --module_exit(nss_wifi_meshmgr_exit_module); -- --MODULE_LICENSE("Dual BSD/GPL"); --MODULE_DESCRIPTION("NSS WiFi-Mesh manager"); + nss_pvxlanmgr_info("module %s loaded\n", + NSS_CLIENT_BUILD_ID); +--- a/pvxlanmgr/nss_pvxlanmgr_priv.h ++++ b/pvxlanmgr/nss_pvxlanmgr_priv.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -19,8 +19,10 @@ + * Pvxlan manager private defines + */ + #include ++#include + #include + #include ++#include + #include + #include + #include diff --git a/package/qca-nss/qca-nss-drv/Makefile b/package/qca-nss/qca-nss-drv/Makefile index 7f4b6d71e0..458e038e98 100644 --- a/package/qca-nss/qca-nss-drv/Makefile +++ b/package/qca-nss/qca-nss-drv/Makefile @@ -1,4 +1,4 @@ -# NHSS.QSDK.12.2 +# NHSS.QSDK 11.2 - 12.2 # by SqTER include $(TOPDIR)/rules.mk @@ -9,9 +9,9 @@ PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/nss-drv.git PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2023-06-01 -PKG_SOURCE_VERSION:=fe0bc6b077b842d13a06053271115bb9b3dcc505 -PKG_MIRROR_HASH:=1011fb113ba40d7919c0718d055ae6be8600fc8e02c1472f7425b7da47372a8a +PKG_SOURCE_DATE:=2020-03-20 +PKG_SOURCE_VERSION:=3cfb9f43 +PKG_MIRROR_HASH:=37d268b4712db049df3780ce298abe0456f6478a9ec2504eb303a6f10e03c818 PKG_BUILD_PARALLEL:=1 PKG_CONFIG_DEPENDS:= \ @@ -260,12 +260,9 @@ define Build/Configure endef define Build/Compile - +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" $(strip $(DRV_MAKE_OPTS)) \ - CROSS_COMPILE="$(TARGET_CROSS)" \ - ARCH="$(LINUX_KARCH)" \ + $(KERNEL_MAKE) $(strip $(DRV_MAKE_OPTS)) \ M="$(PKG_BUILD_DIR)" \ - EXTRA_CFLAGS="$(EXTRA_CFLAGS)" SoC=$(SOC) \ - $(KERNEL_MAKE_FLAGS) \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" SoC="$(subtarget)" \ modules endef diff --git a/package/qca-nss/qca-nss-drv/patches/100-kernel-5.15-support.patch b/package/qca-nss/qca-nss-drv/patches/100-kernel-5.15-support.patch index 3d37211773..48e5ccbd7f 100644 --- a/package/qca-nss/qca-nss-drv/patches/100-kernel-5.15-support.patch +++ b/package/qca-nss/qca-nss-drv/patches/100-kernel-5.15-support.patch @@ -1,56 +1,114 @@ +--- a/nss_data_plane/nss_data_plane_gmac.c ++++ b/nss_data_plane/nss_data_plane_gmac.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014-2020, 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. +@@ -20,7 +20,7 @@ + #include "nss_tx_rx_common.h" + #include + +-#define NSS_DP_GMAC_SUPPORTED_FEATURES (NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_FRAGLIST | (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)) ++#define NSS_DP_GMAC_SUPPORTED_FEATURES (NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_FRAGLIST | (NETIF_F_TSO | NETIF_F_TSO6)) + #define NSS_DATA_PLANE_GMAC_MAX_INTERFACES 4 + + static DEFINE_SPINLOCK(nss_data_plane_gmac_stats_lock); +@@ -250,9 +250,9 @@ static void __nss_data_plane_register(st + + for (i = 0; i < NSS_DATA_PLANE_GMAC_MAX_INTERFACES; i++) { + if (!nss_data_plane_register_to_nss_gmac(nss_ctx, i)) { +- nss_warning("%p: Register data plane failed for gmac:%d\n", nss_ctx, i); ++ nss_warning("%px: Register data plane failed for gmac:%d\n", nss_ctx, i); + } else { +- nss_info("%p: Register data plan to gmac:%d success\n", nss_ctx, i); ++ nss_info("%px: Register data plan to gmac:%d success\n", nss_ctx, i); + } + } + } --- a/Makefile +++ b/Makefile -@@ -5,9 +5,6 @@ - obj-m += qca-nss-drv.o - - # --# Regular NSS path --# --# +@@ -8,8 +8,6 @@ obj-m += qca-nss-drv.o # List the files that belong to the driver in alphabetical order. # qca-nss-drv-objs := \ -@@ -19,61 +16,86 @@ qca-nss-drv-objs := \ +- nss_bridge.o \ +- nss_bridge_log.o \ + nss_cmn.o \ + nss_core.o \ + nss_coredump.o \ +@@ -18,40 +16,22 @@ qca-nss-drv-objs := \ nss_dynamic_interface.o \ nss_dynamic_interface_log.o \ nss_dynamic_interface_stats.o \ -+ nss_eth_rx.o \ -+ nss_eth_rx_stats.o \ -+ nss_eth_rx_strings.o \ -+ nss_gmac_stats.o \ -+ nss_if.o \ +- nss_edma.o \ +- nss_edma_stats.o \ +- nss_edma_strings.o \ + nss_eth_rx.o \ + nss_eth_rx_stats.o \ + nss_eth_rx_strings.o \ + nss_gmac_stats.o \ + nss_if.o \ + nss_if_log.o \ nss_init.o \ -+ nss_ipv4.o \ -+ nss_ipv4_stats.o \ -+ nss_ipv4_strings.o \ -+ nss_ipv4_log.o \ + nss_ipv4.o \ + nss_ipv4_stats.o \ + nss_ipv4_strings.o \ + nss_ipv4_log.o \ +- nss_ipv4_reasm.o \ +- nss_ipv4_reasm_stats.o \ +- nss_ipv4_reasm_strings.o \ +- nss_ipv6.o \ +- nss_ipv6_stats.o \ +- nss_ipv6_strings.o \ +- nss_ipv6_log.o \ +- nss_ipv6_reasm.o \ +- nss_ipv6_reasm_stats.o \ +- nss_ipv6_reasm_strings.o \ nss_log.o \ -+ nss_lso_rx.o \ -+ nss_lso_rx_stats.o \ -+ nss_lso_rx_strings.o \ + nss_lso_rx.o \ + nss_lso_rx_stats.o \ + nss_lso_rx_strings.o \ +- nss_match.o \ +- nss_match_log.o \ +- nss_match_stats.o \ nss_meminfo.o \ +- nss_mirror.o \ +- nss_mirror_log.o \ +- nss_mirror_stats.o \ nss_n2h.o \ nss_n2h_stats.o \ nss_n2h_strings.o \ -+ nss_phys_if.o \ +@@ -59,28 +39,44 @@ qca-nss-drv-objs := \ nss_pm.o \ nss_profiler.o \ nss_project.o \ +- nss_ppe.o \ +- nss_ppe_log.o \ +- nss_ppe_stats.o \ +- nss_ppe_vp.o \ +- nss_ppe_vp_log.o \ +- nss_ppe_vp_stats.o \ +- nss_pppoe.o \ +- nss_pppoe_log.o \ +- nss_pppoe_stats.o \ +- nss_pppoe_strings.o \ nss_rps.o \ nss_stats.o \ nss_strings.o \ -+ nss_tx_msg_sync.o \ + nss_tx_msg_sync.o \ nss_unaligned.o \ nss_unaligned_log.o \ - nss_unaligned_stats.o - --# Base NSS HAL support +- nss_unaligned_stats.o \ ++ nss_unaligned_stats.o ++ +# Base NSS data plane/HAL support +qca-nss-drv-objs += nss_data_plane/nss_data_plane_common.o - qca-nss-drv-objs += nss_hal/nss_hal.o - --ifneq "$(NSS_DRV_POINT_OFFLOAD)" "y" ++qca-nss-drv-objs += nss_hal/nss_hal.o ++ +ifneq "$(NSS_DRV_PPPOE_ENABLE)" "n" +ccflags-y += -DNSS_DRV_PPPOE_ENABLE +qca-nss-drv-objs += \ @@ -62,236 +120,145 @@ + +ifneq "$(NSS_DRV_VIRT_IF_ENABLE)" "n" +ccflags-y += -DNSS_DRV_VIRT_IF_ENABLE - qca-nss-drv-objs += \ -- nss_gmac_stats.o \ -- nss_if.o \ -- nss_if_log.o \ -- nss_phys_if.o \ -- nss_tx_msg_sync.o \ ++qca-nss-drv-objs += \ nss_virt_if.o \ - nss_virt_if_stats.o -- --# Base NSS data plane support --qca-nss-drv-objs += nss_data_plane/nss_data_plane_common.o - endif - --ifneq "$(NSS_DRV_BRIDGE_ENABLE)" "n" --ccflags-y += -DNSS_DRV_BRIDGE_ENABLE +- nss_virt_if_stats.o \ ++ nss_virt_if_stats.o ++endif ++ +ifneq "$(NSS_DRV_VLAN_ENABLE)" "n" +ccflags-y += -DNSS_DRV_VLAN_ENABLE - qca-nss-drv-objs += \ -- nss_bridge.o \ -- nss_bridge_log.o -+ nss_vlan.o \ ++qca-nss-drv-objs += \ + nss_vlan.o \ +- nss_vlan_log.o \ +- nss_wifi.o \ + nss_vlan_log.o - endif - --ifneq "$(NSS_DRV_WIFI_EXT_VDEV_ENABLE)" "n" --ccflags-y += -DNSS_DRV_WIFI_EXT_VDEV_ENABLE --qca-nss-drv-objs += \ -- nss_wifi_ext_vdev.o \ -- nss_wifi_ext_vdev_stats.o \ -- nss_wifi_ext_vdev_log.o ++endif ++ +ifneq "$(NSS_DRV_WIFI_ENABLE)" "n" +ccflags-y += -DNSS_DRV_WIFI_ENABLE +qca-nss-drv-objs += nss_wifi.o \ -+ nss_wifi_log.o \ -+ nss_wifi_stats.o \ -+ nss_wifi_vdev.o \ -+ nss_wifi_if.o \ -+ nss_wifi_if_stats.o \ -+ nss_wifili.o \ -+ nss_wifili_log.o \ -+ nss_wifili_stats.o \ + nss_wifi_log.o \ + nss_wifi_stats.o \ + nss_wifi_vdev.o \ +@@ -89,13 +85,26 @@ qca-nss-drv-objs := \ + nss_wifili.o \ + nss_wifili_log.o \ + nss_wifili_stats.o \ +- nss_wifili_strings.o \ +- nss_wifi_mac_db.o + nss_wifili_strings.o +ifeq ($(shell test $(TARGET_NSS_MINOR_VERSION) -gt 0; echo $$?),0) +qca-nss-drv-objs += nss_wifi_mac_db.o +endif - endif ++endif --ifneq "$(NSS_DRV_WIFI_MESH_ENABLE)" "n" --ccflags-y += -DNSS_DRV_WIFI_MESH_ENABLE +-# Base NSS data plane/HAL support +-qca-nss-drv-objs += nss_data_plane/nss_data_plane.o +-qca-nss-drv-objs += nss_hal/nss_hal.o +ifneq "$(NSS_DRV_BRIDGE_ENABLE)" "n" +ccflags-y += -DNSS_DRV_BRIDGE_ENABLE - qca-nss-drv-objs += \ -- nss_wifi_mesh.o \ -- nss_wifi_mesh_log.o \ -- nss_wifi_mesh_stats.o \ -- nss_wifi_mesh_strings.o ++qca-nss-drv-objs += \ + nss_bridge.o \ + nss_bridge_log.o ++endif + ++ifneq "$(NSS_DRV_IPV4_REASM_ENABLE)" "n" ++ccflags-y += -DNSS_DRV_IPV4_REASM_ENABLE ++qca-nss-drv-objs += \ ++ nss_ipv4_reasm.o \ ++ nss_ipv4_reasm_stats.o \ ++ nss_ipv4_reasm_strings.o ++endif + + ifneq "$(NSS_DRV_L2TP_ENABLE)" "n" + ccflags-y += -DNSS_DRV_L2TP_ENABLE +@@ -121,6 +130,22 @@ qca-nss-drv-objs += \ + nss_pvxlan_stats.o endif - ifneq "$(NSS_DRV_IPV4_REASM_ENABLE)" "n" -@@ -136,8 +158,7 @@ ccflags-y += -DNSS_DRV_GRE_ENABLE ++ifneq "$(NSS_DRV_IPV6_ENABLE)" "n" ++ccflags-y += -DNSS_DRV_IPV6_ENABLE ++qca-nss-drv-objs += \ ++ nss_ipv6.o \ ++ nss_ipv6_stats.o \ ++ nss_ipv6_strings.o \ ++ nss_ipv6_log.o ++ifneq "$(NSS_DRV_IPV6_REASM_ENABLE)" "n" ++ccflags-y += -DNSS_DRV_IPV6_REASM_ENABLE ++qca-nss-drv-objs += \ ++ nss_ipv6_reasm.o \ ++ nss_ipv6_reasm_stats.o \ ++ nss_ipv6_reasm_strings.o ++endif ++endif ++ + ifneq "$(NSS_DRV_TSTAMP_ENABLE)" "n" + ccflags-y += -DNSS_DRV_TSTAMP_ENABLE qca-nss-drv-objs += \ - nss_gre.o \ - nss_gre_log.o \ -- nss_gre_stats.o \ -- nss_gre_strings.o -+ nss_gre_stats.o +@@ -269,17 +294,6 @@ qca-nss-drv-objs += \ + nss_clmap_stats.o endif - ifneq "$(NSS_DRV_GRE_REDIR_ENABLE)" "n" -@@ -148,17 +169,13 @@ qca-nss-drv-objs += \ - nss_gre_redir_lag_ds.o \ - nss_gre_redir_lag_ds_log.o \ - nss_gre_redir_lag_ds_stats.o \ -- nss_gre_redir_lag_ds_strings.o \ - nss_gre_redir_lag_us.o \ - nss_gre_redir_lag_us_log.o \ - nss_gre_redir_lag_us_stats.o \ -- nss_gre_redir_lag_us_strings.o \ - nss_gre_redir_stats.o \ -- nss_gre_redir_strings.o \ - nss_gre_redir_mark.o \ - nss_gre_redir_mark_log.o \ -- nss_gre_redir_mark_stats.o \ -- nss_gre_redir_mark_strings.o -+ nss_gre_redir_mark_stats.o - endif - - ifneq "$(NSS_DRV_GRE_TUNNEL_ENABLE)" "n" -@@ -166,8 +183,7 @@ ccflags-y += -DNSS_DRV_GRE_TUNNEL_ENABLE - qca-nss-drv-objs += \ - nss_gre_tunnel.o \ - nss_gre_tunnel_log.o \ -- nss_gre_tunnel_stats.o \ -- nss_gre_tunnel_strings.o -+ nss_gre_tunnel_stats.o - endif - - ifneq "$(NSS_DRV_CAPWAP_ENABLE)" "n" -@@ -226,20 +242,11 @@ qca-nss-drv-objs += \ - nss_trustsec_tx_stats.o - endif - --ifneq "$(NSS_DRV_TRUSTSEC_RX_ENABLE)" "n" --ccflags-y += -DNSS_DRV_TRUSTSEC_RX_ENABLE +-ifneq "$(NSS_DRV_C2C_ENABLE)" "n" +-ccflags-y += -DNSS_DRV_C2C_ENABLE -qca-nss-drv-objs += \ -- nss_trustsec_rx.o \ -- nss_trustsec_rx_log.o \ -- nss_trustsec_rx_stats.o +- nss_c2c_tx.o \ +- nss_c2c_tx_log.o \ +- nss_c2c_tx_stats.o \ +- nss_c2c_tx_strings.o \ +- nss_c2c_rx.o \ +- nss_c2c_rx_stats.o \ +- nss_c2c_rx_strings.o -endif -- - ifneq "$(NSS_DRV_TUNIPIP6_ENABLE)" "n" - ccflags-y += -DNSS_DRV_TUNIPIP6_ENABLE - qca-nss-drv-objs += \ - nss_tunipip6.o \ -- nss_tunipip6_log.o \ -- nss_tunipip6_stats.o -+ nss_tunipip6_log.o + + ifneq "$(NSS_DRV_VXLAN_ENABLE)" "n" + ccflags-y += -DNSS_DRV_VXLAN_ENABLE +@@ -289,9 +303,37 @@ qca-nss-drv-objs += \ + nss_vxlan_stats.o endif - ifneq "$(NSS_DRV_QRFS_ENABLE)" "n" -@@ -284,8 +291,7 @@ ccflags-y += -DNSS_DRV_CLMAP_ENABLE - qca-nss-drv-objs += \ - nss_clmap.o \ - nss_clmap_log.o \ -- nss_clmap_stats.o \ -- nss_clmap_strings.o -+ nss_clmap_stats.o - endif - - -@@ -302,8 +308,7 @@ ccflags-y += -DNSS_DRV_MATCH_ENABLE - qca-nss-drv-objs += \ - nss_match.o \ - nss_match_log.o \ -- nss_match_stats.o \ -- nss_match_strings.o +-ifeq ($(SoC),$(filter $(SoC),ipq806x ipq40xx)) ++ifneq "$(NSS_DRV_MATCH_ENABLE)" "n" ++ccflags-y += -DNSS_DRV_MATCH_ENABLE ++qca-nss-drv-objs += \ ++ nss_match.o \ ++ nss_match_log.o \ + nss_match_stats.o - endif - - ifneq "$(NSS_DRV_MIRROR_ENABLE)" "n" -@@ -311,72 +316,7 @@ ccflags-y += -DNSS_DRV_MIRROR_ENABLE - qca-nss-drv-objs += \ - nss_mirror.o \ - nss_mirror_log.o \ -- nss_mirror_stats.o \ -- nss_mirror_strings.o --endif -- --ifneq "$(NSS_DRV_UDP_ST_ENABLE)" "n" --ccflags-y += -DNSS_DRV_UDP_ST_ENABLE --qca-nss-drv-objs += \ -- nss_udp_st.o \ -- nss_udp_st_log.o \ -- nss_udp_st_stats.o \ -- nss_udp_st_strings.o --endif -- --ifneq "$(NSS_DRV_IPV4_ENABLE)" "n" --ccflags-y += -DNSS_DRV_IPV4_ENABLE --qca-nss-drv-objs += \ -- nss_ipv4.o \ -- nss_ipv4_stats.o \ -- nss_ipv4_strings.o \ -- nss_ipv4_log.o --endif -- --ifneq "$(NSS_DRV_ETH_RX_ENABLE)" "n" --ccflags-y += -DNSS_DRV_ETH_RX_ENABLE --qca-nss-drv-objs += \ -- nss_eth_rx.o \ -- nss_eth_rx_stats.o \ -- nss_eth_rx_strings.o --endif -- --ifneq "$(NSS_DRV_PPPOE_ENABLE)" "n" --ccflags-y += -DNSS_DRV_PPPOE_ENABLE --qca-nss-drv-objs += \ -- nss_pppoe.o \ -- nss_pppoe_log.o \ -- nss_pppoe_stats.o \ -- nss_pppoe_strings.o --endif -- --ifneq "$(NSS_DRV_WIFIOFFLOAD_ENABLE)" "n" --ccflags-y += -DNSS_DRV_WIFIOFFLOAD_ENABLE --qca-nss-drv-objs += \ -- nss_wifi.o \ -- nss_wifi_log.o \ -- nss_wifi_stats.o \ -- nss_wifi_vdev.o \ -- nss_wifili.o \ -- nss_wifili_log.o \ -- nss_wifili_stats.o \ -- nss_wifili_strings.o \ -- nss_wifi_mac_db.o --endif -- --ifneq "$(NSS_DRV_VLAN_ENABLE)" "n" --ccflags-y += -DNSS_DRV_VLAN_ENABLE --qca-nss-drv-objs += \ -- nss_vlan.o \ -- nss_vlan_log.o --endif -- --ifneq "$(NSS_DRV_LSO_RX_ENABLE)" "n" --ccflags-y += -DNSS_DRV_LSO_RX_ENABLE --qca-nss-drv-objs += \ -- nss_lso_rx.o \ -- nss_lso_rx_stats.o \ -- nss_lso_rx_strings.o ++endif ++ ++ifneq "$(NSS_DRV_MIRROR_ENABLE)" "n" ++ccflags-y += -DNSS_DRV_MIRROR_ENABLE ++qca-nss-drv-objs += \ ++ nss_mirror.o \ ++ nss_mirror_log.o \ + nss_mirror_stats.o ++endif ++ ++ifeq ($(SoC),$(filter $(SoC),ipq806x)) + qca-nss-drv-objs += nss_data_plane/nss_data_plane_gmac.o \ + nss_hal/ipq806x/nss_hal_pvt.o ++ ++ifneq "$(NSS_DRV_C2C_ENABLE)" "n" ++ccflags-y += -DNSS_DRV_C2C_ENABLE ++qca-nss-drv-objs += \ ++ nss_c2c_tx.o \ ++ nss_c2c_tx_log.o \ ++ nss_c2c_tx_stats.o \ ++ nss_c2c_tx_strings.o \ ++ nss_c2c_rx.o \ ++ nss_c2c_rx_stats.o \ ++ nss_c2c_rx_strings.o ++endif + ifneq "$(NSS_DRV_IPSEC_ENABLE)" "n" + ccflags-y += -DNSS_DRV_IPSEC_ENABLE + qca-nss-drv-objs += \ +@@ -317,7 +359,19 @@ ccflags-y += -I$(obj)/nss_hal/ipq806x -D endif - ifeq ($(SoC),$(filter $(SoC),ipq806x)) -@@ -420,16 +360,15 @@ endif - ifeq ($(SoC),$(filter $(SoC),ipq60xx ipq60xx_64 ipq807x ipq807x_64)) - qca-nss-drv-objs += nss_data_plane/nss_data_plane.o \ -- nss_edma.o \ -- nss_edma_stats.o \ -- nss_edma_strings.o \ -- nss_ppe.o \ -- nss_ppe_log.o \ -- nss_ppe_stats.o \ -- nss_ppe_strings.o \ -- nss_ppe_vp.o \ -- nss_ppe_vp_log.o \ -- nss_ppe_vp_stats.o +-qca-nss-drv-objs += nss_data_plane/nss_data_plane_edma.o ++qca-nss-drv-objs += nss_data_plane/nss_data_plane.o \ + nss_edma.o \ + nss_edma_stats.o \ + nss_edma_strings.o \ @@ -301,143 +268,94 @@ + nss_ppe_vp.o \ + nss_ppe_vp_log.o \ + nss_ppe_vp_stats.o ++ ++ccflags-y += -DNSS_DRV_PPE_ENABLE ++ccflags-y += -DNSS_DRV_EDMA_ENABLE - ccflags-y += -DNSS_DRV_PPE_ENABLE - ccflags-y += -DNSS_DRV_EDMA_ENABLE -@@ -438,9 +377,7 @@ ifneq "$(NSS_DRV_IPSEC_ENABLE)" "n" + ifneq "$(NSS_DRV_IPSEC_ENABLE)" "n" ccflags-y += -DNSS_DRV_IPSEC_ENABLE - qca-nss-drv-objs += \ - nss_ipsec_cmn_log.o \ -- nss_ipsec_cmn.o \ -- nss_ipsec_cmn_stats.o \ -- nss_ipsec_cmn_strings.o -+ nss_ipsec_cmn.o - endif +@@ -328,9 +382,15 @@ endif ifneq "$(NSS_DRV_CRYPTO_ENABLE)" "n" -@@ -450,8 +387,6 @@ ccflags-y += -DNSS_DRV_DMA_ENABLE + ccflags-y += -DNSS_DRV_CRYPTO_ENABLE ++ccflags-y += -DNSS_DRV_DMA_ENABLE ++ qca-nss-drv-objs += \ nss_crypto_cmn.o \ - nss_crypto_cmn_log.o \ -- nss_crypto_cmn_stats.o \ -- nss_crypto_cmn_strings.o \ - nss_dma.o \ - nss_dma_log.o \ - nss_dma_stats.o \ -@@ -462,9 +397,7 @@ ifneq "$(NSS_DRV_DTLS_ENABLE)" "n" - ccflags-y += -DNSS_DRV_DTLS_ENABLE - qca-nss-drv-objs += \ - nss_dtls_cmn.o \ -- nss_dtls_cmn_log.o \ -- nss_dtls_cmn_stats.o \ -- nss_dtls_cmn_strings.o -+ nss_dtls_cmn_log.o +- nss_crypto_cmn_log.o ++ nss_crypto_cmn_log.o \ ++ nss_dma.o \ ++ nss_dma_log.o \ ++ nss_dma_stats.o \ ++ nss_dma_strings.o endif + ifneq "$(NSS_DRV_DTLS_ENABLE)" "n" +@@ -343,9 +403,9 @@ endif ifneq "$(NSS_DRV_QVPN_ENABLE)" "n" -@@ -472,62 +405,14 @@ ccflags-y += -DNSS_DRV_QVPN_ENABLE + ccflags-y += -DNSS_DRV_QVPN_ENABLE qca-nss-drv-objs += \ - nss_qvpn.o \ - nss_qvpn_log.o \ -- nss_qvpn_stats.o \ -- nss_qvpn_strings.o +- nss_qvpn.o \ +- nss_qvpn_stats.o \ +- nss_qvpn_log.o ++ nss_qvpn.o \ ++ nss_qvpn_log.o \ + nss_qvpn_stats.o endif ifneq "$(NSS_DRV_TLS_ENABLE)" "n" ccflags-y += -DNSS_DRV_TLS_ENABLE - qca-nss-drv-objs += \ - nss_tls.o \ -- nss_tls_log.o \ -- nss_tls_stats.o \ -- nss_tls_strings.o --endif --endif -- --ifeq ($(SoC),$(filter $(SoC),ipq95xx)) --qca-nss-drv-objs += nss_hal/ipq95xx/nss_hal_pvt.o --qca-nss-drv-objs += nss_data_plane/nss_data_plane_lite.o --qca-nss-drv-objs += nss_edma_lite.o \ -- nss_edma_lite_stats.o \ -- nss_edma_lite_strings.o -- --ccflags-y += -DNSS_DATA_PLANE_LITE_SUPPORT --ccflags-y += -DNSS_DRV_EDMA_LITE_ENABLE --ccflags-y += -DNSS_DRV_POINT_OFFLOAD -- --ifneq "$(NSS_DRV_CRYPTO_ENABLE)" "n" --ccflags-y += -DNSS_DRV_CRYPTO_ENABLE --ccflags-y += -DNSS_DRV_DMA_ENABLE -- --qca-nss-drv-objs += \ -- nss_crypto.o \ -- nss_crypto_log.o \ -- nss_crypto_cmn.o \ -- nss_crypto_cmn_log.o \ -- nss_crypto_cmn_stats.o \ -- nss_crypto_cmn_strings.o \ -- nss_dma.o \ -- nss_dma_log.o \ -- nss_dma_stats.o \ -- nss_dma_strings.o --endif -- --ifneq "$(NSS_DRV_DTLS_ENABLE)" "n" --ccflags-y += -DNSS_DRV_DTLS_ENABLE --qca-nss-drv-objs += \ -- nss_dtls.o \ -- nss_dtls_log.o \ -- nss_dtls_stats.o \ -- nss_dtls_cmn.o \ -- nss_dtls_cmn_log.o \ -- nss_dtls_cmn_stats.o \ -- nss_dtls_cmn_strings.o -+ nss_tls_log.o - endif -- --ccflags-y += -I$(obj)/nss_hal/ipq95xx -DNSS_HAL_IPQ95XX_SUPPORT -DNSS_MULTI_H2N_DATA_RING_SUPPORT --else --ccflags-y += -DNSS_DATA_PLANE_GENERIC_SUPPORT +@@ -356,18 +416,32 @@ endif endif ifeq ($(SoC),$(filter $(SoC),ipq807x ipq807x_64)) -@@ -562,33 +447,26 @@ ifneq "$(NSS_DRV_IPSEC_ENABLE)" "n" +-qca-nss-drv-objs += nss_hal/ipq807x/nss_hal_pvt.o ++qca-nss-drv-objs += nss_hal/ipq807x/nss_hal_pvt.o \ ++ nss_data_plane/hal/nss_ipq807x.o ++ifneq "$(NSS_DRV_C2C_ENABLE)" "n" ++ccflags-y += -DNSS_DRV_C2C_ENABLE ++qca-nss-drv-objs += \ ++ nss_c2c_tx.o \ ++ nss_c2c_tx_log.o \ ++ nss_c2c_tx_stats.o \ ++ nss_c2c_tx_strings.o \ ++ nss_c2c_rx.o \ ++ nss_c2c_rx_stats.o \ ++ nss_c2c_rx_strings.o ++endif + ccflags-y += -I$(obj)/nss_hal/ipq807x -DNSS_HAL_IPQ807x_SUPPORT -DNSS_MULTI_H2N_DATA_RING_SUPPORT + endif + + ifeq ($(SoC),$(filter $(SoC),ipq60xx ipq60xx_64)) +-qca-nss-drv-objs += nss_hal/ipq60xx/nss_hal_pvt.o ++qca-nss-drv-objs += nss_hal/ipq60xx/nss_hal_pvt.o \ ++ nss_data_plane/hal/nss_ipq60xx.o + ccflags-y += -I$(obj)/nss_hal/ipq60xx -DNSS_HAL_IPQ60XX_SUPPORT -DNSS_MULTI_H2N_DATA_RING_SUPPORT + endif + + ifeq ($(SoC),$(filter $(SoC),ipq50xx ipq50xx_64)) +-qca-nss-drv-objs += nss_data_plane/nss_data_plane_edma.o \ +- nss_hal/ipq50xx/nss_hal_pvt.o ++qca-nss-drv-objs += nss_data_plane/nss_data_plane.o \ ++ nss_hal/ipq50xx/nss_hal_pvt.o \ ++ nss_data_plane/hal/nss_ipq50xx.o + + ifneq "$(NSS_DRV_IPSEC_ENABLE)" "n" ccflags-y += -DNSS_DRV_IPSEC_ENABLE - qca-nss-drv-objs += \ - nss_ipsec_cmn_log.o \ -- nss_ipsec_cmn.o \ -- nss_ipsec_cmn_stats.o \ -- nss_ipsec_cmn_strings.o -+ nss_ipsec_cmn.o - endif - - ifneq "$(NSS_DRV_CRYPTO_ENABLE)" "n" - ccflags-y += -DNSS_DRV_CRYPTO_ENABLE - qca-nss-drv-objs += \ - nss_crypto_cmn.o \ -- nss_crypto_cmn_log.o \ -- nss_crypto_cmn_stats.o \ -- nss_crypto_cmn_strings.o -+ nss_crypto_cmn_log.o - endif - - ifneq "$(NSS_DRV_DTLS_ENABLE)" "n" - ccflags-y += -DNSS_DRV_DTLS_ENABLE - qca-nss-drv-objs += \ - nss_dtls_cmn.o \ -- nss_dtls_cmn_log.o \ -- nss_dtls_cmn_stats.o \ -- nss_dtls_cmn_strings.o -+ nss_dtls_cmn_log.o - endif - ccflags-y += -I$(obj)/nss_hal/ipq50xx -DNSS_HAL_IPQ50XX_SUPPORT -DNSS_MULTI_H2N_DATA_RING_SUPPORT +@@ -393,9 +467,11 @@ ccflags-y += -I$(obj)/nss_hal/ipq50xx -D endif ccflags-y += -I$(obj)/nss_hal/include -I$(obj)/nss_data_plane/include -I$(obj)/exports -DNSS_DEBUG_LEVEL=0 -DNSS_PKT_STATS_ENABLED=1 - - ccflags-y += -I$(obj)/nss_data_plane/hal/include ++ccflags-y += -I$(obj)/nss_data_plane/hal/include ccflags-y += -DNSS_PM_DEBUG_LEVEL=0 -DNSS_SKB_REUSE_SUPPORT=1 - ccflags-y += -Wall -Werror -@@ -603,14 +481,7 @@ NSS_CCFLAGS = -DNSS_DT_SUPPORT=1 -DNSS_F +-ccflags-y += -Werror ++ccflags-y += -Wall -Werror ++ ++KERNELVERSION := $(word 1, $(subst ., ,$(KERNELVERSION))).$(word 2, $(subst ., ,$(KERNELVERSION))) + + ifneq ($(findstring 3.4, $(KERNELVERSION)),) + NSS_CCFLAGS = -DNSS_DT_SUPPORT=0 -DNSS_FW_DBG_SUPPORT=1 -DNSS_PM_SUPPORT=1 +@@ -405,14 +481,7 @@ NSS_CCFLAGS = -DNSS_DT_SUPPORT=1 -DNSS_F ccflags-y += -I$(obj) endif @@ -452,7282 +370,9 @@ # Disable Frequency scaling ifeq "$(NSS_FREQ_SCALE_DISABLE)" "y" ---- a/exports/nss_api_if.h -+++ b/exports/nss_api_if.h -@@ -1,12 +1,9 @@ - /* - ************************************************************************** -- * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2013-2020, 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 -@@ -68,17 +65,16 @@ - #include "nss_wifi_vdev.h" - #include "nss_n2h.h" - #include "nss_rps.h" -+#include "nss_wifi_if.h" - #include "nss_portid.h" - #include "nss_oam.h" - #include "nss_dtls.h" - #include "nss_dtls_cmn.h" - #include "nss_tls.h" - #include "nss_edma.h" --#include "nss_edma_lite.h" - #include "nss_bridge.h" - #include "nss_ppe.h" - #include "nss_trustsec_tx.h" --#include "nss_trustsec_rx.h" - #include "nss_vlan.h" - #include "nss_igs.h" - #include "nss_mirror.h" -@@ -103,12 +99,6 @@ - #include "nss_ipv4_reasm.h" - #include "nss_lso_rx.h" - #include "nss_wifi_mac_db_if.h" --#include "nss_wifi_ext_vdev_if.h" --#include "nss_wifili_if.h" --#include "nss_ppe_vp.h" --#include "nss_wifi_mesh.h" --#include "nss_udp_st.h" --#include "nss_qrfs.h" - #endif - - #endif /*__KERNEL__ */ -@@ -129,7 +119,11 @@ - #define NSS_MAX_PHYSICAL_INTERFACES 8 /**< Maximum number of physical interfaces. */ - #define NSS_MAX_VIRTUAL_INTERFACES 16 /**< Maximum number of virtual interfaces. */ - #define NSS_MAX_TUNNEL_INTERFACES 4 /**< Maximum number of tunnel interfaces. */ --#define NSS_MAX_SPECIAL_INTERFACES 72 /**< Maximum number of special interfaces. */ -+#if (NSS_FW_VERSION_CODE < NSS_FW_VERSION(11,1)) -+#define NSS_MAX_SPECIAL_INTERFACES 55 /**< Maximum number of special interfaces. */ -+#else -+#define NSS_MAX_SPECIAL_INTERFACES 67 /**< Maximum number of special interfaces. */ -+#endif - #define NSS_MAX_WIFI_RADIO_INTERFACES 3 /**< Maximum number of radio interfaces. */ - - /* -@@ -263,6 +257,10 @@ - /**< Special interface number for timestamp receive. */ - #define NSS_GRE_REDIR_MARK_INTERFACE (NSS_SPECIAL_IF_START + 56) - /**< Special interface number for GRE redirect mark. */ -+#if (NSS_FW_VERSION_CODE < NSS_FW_VERSION(11,1)) -+#define NSS_RMNET_RX_INTERFACE (NSS_SPECIAL_IF_START + 57) -+ /**< Special interface number for RMNET receive handler. */ -+#else - #define NSS_VXLAN_INTERFACE (NSS_SPECIAL_IF_START + 57) - /**< Special interface number for VxLAN handler. */ - #define NSS_RMNET_RX_INTERFACE (NSS_SPECIAL_IF_START + 58) -@@ -279,19 +277,510 @@ - /**< Special interface number for the Wi-Fi MAC database. */ - #define NSS_DMA_INTERFACE (NSS_SPECIAL_IF_START + 66) - /**< Special interface number for the DMA interface. */ --#define NSS_WIFI_EXT_VDEV_INTERFACE (NSS_SPECIAL_IF_START + 67) -- /**< Special interface number for the Wi-Fi extended virtual interface. */ --#define NSS_UDP_ST_INTERFACE (NSS_SPECIAL_IF_START + 68) -- /**< Special interface number for the UDP speed test interface. */ --#define NSS_EDMA_LITE_INTERFACE (NSS_SPECIAL_IF_START + 69) -- /**< Special interface number for the EDMA lite interface. */ --#define NSS_PPE_VP_IF_MAP_INTERFACE (NSS_SPECIAL_IF_START + 70) -- /**< Special interface number for the virtual port map interface. */ --#define NSS_TRUSTSEC_RX_INTERFACE (NSS_SPECIAL_IF_START + 71) -- /**< Special interface number for the TrustSec RX. */ -+#endif - - #ifdef __KERNEL__ /* only kernel will use. */ - -+/** -+ * Wireless Multimedia Extention Access Category to TID. @hideinitializer -+ */ -+#define NSS_WIFILI_WME_AC_TO_TID(_ac) ( \ -+ ((_ac) == NSS_WIFILI_WME_AC_VO) ? 6 : \ -+ (((_ac) == NSS_WIFILI_WME_AC_VI) ? 5 : \ -+ (((_ac) == NSS_WIFILI_WME_AC_BK) ? 1 : \ -+ 0))) -+ -+/** -+ * Wireless TID to Wireless Extension Multimedia Access Category. @hideinitializer -+ */ -+#define NSS_WIFILI_TID_TO_WME_AC(_tid) ( \ -+ (((_tid) == 0) || ((_tid) == 3)) ? NSS_WIFILI_WME_AC_BE : \ -+ ((((_tid) == 1) || ((_tid) == 2)) ? NSS_WIFILI_WME_AC_BK : \ -+ ((((_tid) == 4) || ((_tid) == 5)) ? NSS_WIFILI_WME_AC_VI : \ -+ NSS_WIFILI_WME_AC_VO))) -+ -+/** -+ * Converts the format of an IPv6 address from Linux to NSS. @hideinitializer -+ */ -+#define IN6_ADDR_TO_IPV6_ADDR(ipv6, in6) \ -+ { \ -+ ((uint32_t *)ipv6)[0] = in6.in6_u.u6_addr32[0]; \ -+ ((uint32_t *)ipv6)[1] = in6.in6_u.u6_addr32[1]; \ -+ ((uint32_t *)ipv6)[2] = in6.in6_u.u6_addr32[2]; \ -+ ((uint32_t *)ipv6)[3] = in6.in6_u.u6_addr32[3]; \ -+ } -+ -+/** -+ * Converts the format of an IPv6 address from NSS to Linux. @hideinitializer -+ */ -+#define IPV6_ADDR_TO_IN6_ADDR(in6, ipv6) \ -+ { \ -+ in6.in6_u.u6_addr32[0] = ((uint32_t *)ipv6)[0]; \ -+ in6.in6_u.u6_addr32[1] = ((uint32_t *)ipv6)[1]; \ -+ in6.in6_u.u6_addr32[2] = ((uint32_t *)ipv6)[2]; \ -+ in6.in6_u.u6_addr32[3] = ((uint32_t *)ipv6)[3]; \ -+ } -+ -+/** -+ * Format of an IPv6 address (16 * 8 bits). -+ */ -+#define IPV6_ADDR_OCTAL_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x" -+ -+/** -+ * Prints an IPv6 address (16 * 8 bits). -+ */ -+#define IPV6_ADDR_TO_OCTAL(ipv6) ((uint16_t *)ipv6)[0], ((uint16_t *)ipv6)[1], ((uint16_t *)ipv6)[2], ((uint16_t *)ipv6)[3], ((uint16_t *)ipv6)[4], ((uint16_t *)ipv6)[5], ((uint16_t *)ipv6)[6], ((uint16_t *)ipv6)[7] -+ -+/* -+ * IPv4 rule sync reasons. -+ */ -+#define NSS_IPV4_SYNC_REASON_STATS 0 /**< Rule for synchronizing statistics. */ -+#define NSS_IPV4_SYNC_REASON_FLUSH 1 /**< Rule for flushing a cache entry. */ -+#define NSS_IPV4_SYNC_REASON_EVICT 2 /**< Rule for evicting a cache entry. */ -+#define NSS_IPV4_SYNC_REASON_DESTROY 3 -+ /**< Rule for destroying a cache entry (requested by the host OS). */ -+#define NSS_IPV4_SYNC_REASON_PPPOE_DESTROY 4 -+ /**< Rule for destroying a cache entry that belongs to a PPPoE session. */ -+ -+/** -+ * nss_ipv4_create -+ * Information for an IPv4 flow or connection create rule. -+ * -+ * All fields must be passed in host-endian order. -+ */ -+struct nss_ipv4_create { -+ int32_t src_interface_num; -+ /**< Source interface number (virtual or physical). */ -+ int32_t dest_interface_num; -+ /**< Destination interface number (virtual or physical). */ -+ int32_t protocol; /**< L4 protocol (e.g., TCP or UDP). */ -+ uint32_t flags; /**< Flags (if any) associated with this rule. */ -+ uint32_t from_mtu; /**< MTU of the incoming interface. */ -+ uint32_t to_mtu; /**< MTU of the outgoing interface. */ -+ uint32_t src_ip; /**< Source IP address. */ -+ int32_t src_port; /**< Source L4 port (e.g., TCP or UDP port). */ -+ uint32_t src_ip_xlate; /**< Translated source IP address (used with SNAT). */ -+ int32_t src_port_xlate; /**< Translated source L4 port (used with SNAT). */ -+ uint32_t dest_ip; /**< Destination IP address. */ -+ int32_t dest_port; /**< Destination L4 port (e.g., TCP or UDP port). */ -+ uint32_t dest_ip_xlate; -+ /**< Translated destination IP address (used with DNAT). */ -+ int32_t dest_port_xlate; -+ /**< Translated destination L4 port (used with DNAT). */ -+ uint8_t src_mac[ETH_ALEN]; -+ /**< Source MAC address. */ -+ uint8_t dest_mac[ETH_ALEN]; -+ /**< Destination MAC address. */ -+ uint8_t src_mac_xlate[ETH_ALEN]; -+ /**< Translated source MAC address (post-routing). */ -+ uint8_t dest_mac_xlate[ETH_ALEN]; -+ /**< Translated destination MAC address (post-routing). */ -+ uint8_t flow_window_scale; /**< Window scaling factor (TCP). */ -+ uint32_t flow_max_window; /**< Maximum window size (TCP). */ -+ uint32_t flow_end; /**< TCP window end. */ -+ uint32_t flow_max_end; /**< TCP window maximum end. */ -+ uint32_t flow_pppoe_if_exist; -+ /**< Flow direction: PPPoE interface exist flag. */ -+ int32_t flow_pppoe_if_num; -+ /**< Flow direction: PPPoE interface number. */ -+ uint16_t ingress_vlan_tag; /**< Ingress VLAN tag expected for this flow. */ -+ uint8_t return_window_scale; -+ /**< Window scaling factor of the return direction (TCP). */ -+ uint32_t return_max_window; -+ /**< Maximum window size of the return direction. */ -+ uint32_t return_end; -+ /**< Flow end for the return direction. */ -+ uint32_t return_max_end; -+ /**< Flow maximum end for the return direction. */ -+ uint32_t return_pppoe_if_exist; -+ /**< Return direction: PPPoE interface existence flag. */ -+ int32_t return_pppoe_if_num; -+ /**< Return direction: PPPoE interface number. */ -+ uint16_t egress_vlan_tag; /**< Egress VLAN tag expected for this flow. */ -+ uint8_t spo_needed; /**< Indicates whether SPO is required. */ -+ uint32_t param_a0; /**< Custom parameter 0. */ -+ uint32_t param_a1; /**< Custom parameter 1. */ -+ uint32_t param_a2; /**< Custom parameter 2. */ -+ uint32_t param_a3; /**< Custom parameter 3. */ -+ uint32_t param_a4; /**< Custom parameter 4. */ -+ uint32_t qos_tag; /**< Deprecated, will be removed soon. */ -+ uint32_t flow_qos_tag; /**< QoS tag value for the flow direction. */ -+ uint32_t return_qos_tag; /**< QoS tag value for the return direction. */ -+ uint8_t dscp_itag; /**< DSCP marking tag. */ -+ uint8_t dscp_imask; /**< DSCP marking input mask. */ -+ uint8_t dscp_omask; /**< DSCP marking output mask. */ -+ uint8_t dscp_oval; /**< DSCP marking output value. */ -+ uint16_t vlan_itag; /**< VLAN marking tag. */ -+ uint16_t vlan_imask; /**< VLAN marking input mask. */ -+ uint16_t vlan_omask; /**< VLAN marking output mask. */ -+ uint16_t vlan_oval; /**< VLAN marking output value. */ -+ uint32_t in_vlan_tag[MAX_VLAN_DEPTH]; -+ /**< Ingress VLAN tag expected for this flow. */ -+ uint32_t out_vlan_tag[MAX_VLAN_DEPTH]; -+ /**< Egress VLAN tag expected for this flow. */ -+ uint8_t flow_dscp; /**< IP DSCP value for the flow direction. */ -+ uint8_t return_dscp; /**< IP DSCP value for the return direction. */ -+}; -+ -+/* -+ * IPv4 connection flags (to be used with nss_ipv4_create::flags). -+ */ -+#define NSS_IPV4_CREATE_FLAG_NO_SEQ_CHECK 0x01 -+ /**< Rule for not checking sequence numbers. */ -+#define NSS_IPV4_CREATE_FLAG_BRIDGE_FLOW 0x02 -+ /**< Rule that indicates pure bridge flow (no routing is involved). */ -+#define NSS_IPV4_CREATE_FLAG_ROUTED 0x04 /**< Rule for a routed connection. */ -+ -+#define NSS_IPV4_CREATE_FLAG_DSCP_MARKING 0x08 /**< Rule for DSCP marking. */ -+#define NSS_IPV4_CREATE_FLAG_VLAN_MARKING 0x10 /**< Rule for VLAN marking. */ -+#define NSS_IPV4_CREATE_FLAG_QOS_VALID 0x20 /**< Rule for QoS is valid. */ -+ -+/** -+ * nss_ipv4_destroy -+ * Information for an IPv4 flow or connection destroy rule. -+ */ -+struct nss_ipv4_destroy { -+ int32_t protocol; /**< L4 protocol ID. */ -+ uint32_t src_ip; /**< Source IP address. */ -+ int32_t src_port; /**< Source L4 port (e.g., TCP or UDP port). */ -+ uint32_t dest_ip; /**< Destination IP address. */ -+ int32_t dest_port; /**< Destination L4 port (e.g., TCP or UDP port). */ -+}; -+ -+/* -+ * IPv6 rule sync reasons. -+ */ -+#define NSS_IPV6_SYNC_REASON_STATS 0 /**< Rule for synchronizing statistics. */ -+#define NSS_IPV6_SYNC_REASON_FLUSH 1 /**< Rule for flushing a cache entry. */ -+#define NSS_IPV6_SYNC_REASON_EVICT 2 /**< Rule for evicting a cache entry. */ -+#define NSS_IPV6_SYNC_REASON_DESTROY 3 -+ /**< Rule for destroying a cache entry (requested by the host OS). */ -+#define NSS_IPV6_SYNC_REASON_PPPOE_DESTROY 4 -+ /**< Rule for destroying a cache entry that belongs to a PPPoE session. */ -+ -+/** -+ * nss_ipv6_create -+ * Information for an IPv6 flow or connection create rule. -+ * -+ * All fields must be passed in host-endian order. -+ */ -+struct nss_ipv6_create { -+ int32_t src_interface_num; -+ /**< Source interface number (virtual or physical). */ -+ int32_t dest_interface_num; -+ /**< Destination interface number (virtual or physical). */ -+ int32_t protocol; /**< L4 protocol (e.g., TCP or UDP). */ -+ uint32_t flags; /**< Flags (if any) associated with this rule. */ -+ uint32_t from_mtu; /**< MTU of the incoming interface. */ -+ uint32_t to_mtu; /**< MTU of the outgoing interface. */ -+ uint32_t src_ip[4]; /**< Source IP address. */ -+ int32_t src_port; /**< Source L4 port (e.g., TCP or UDP port). */ -+ uint32_t dest_ip[4]; /**< Destination IP address. */ -+ int32_t dest_port; /**< Destination L4 port (e.g., TCP or UDP port). */ -+ uint8_t src_mac[ETH_ALEN]; /**< Source MAC address. */ -+ uint8_t dest_mac[ETH_ALEN]; /**< Destination MAC address. */ -+ uint8_t flow_window_scale; /**< Window scaling factor (TCP). */ -+ uint32_t flow_max_window; /**< Maximum window size (TCP). */ -+ uint32_t flow_end; /**< TCP window end. */ -+ uint32_t flow_max_end; /**< TCP window maximum end. */ -+ uint32_t flow_pppoe_if_exist; -+ /**< Flow direction: PPPoE interface existence flag. */ -+ int32_t flow_pppoe_if_num; -+ /**< Flow direction: PPPoE interface number. */ -+ uint16_t ingress_vlan_tag; -+ /**< Ingress VLAN tag expected for this flow. */ -+ uint8_t return_window_scale; -+ /**< Window scaling factor (TCP) for the return direction. */ -+ uint32_t return_max_window; -+ /**< Maximum window size (TCP) for the return direction. */ -+ uint32_t return_end; -+ /**< End for the return direction. */ -+ uint32_t return_max_end; -+ /**< Maximum end for the return direction. */ -+ uint32_t return_pppoe_if_exist; -+ /**< Return direction: PPPoE interface exist flag. */ -+ int32_t return_pppoe_if_num; -+ /**< Return direction: PPPoE interface number. */ -+ uint16_t egress_vlan_tag; /**< Egress VLAN tag expected for this flow. */ -+ uint32_t qos_tag; /**< Deprecated; will be removed soon. */ -+ uint32_t flow_qos_tag; /**< QoS tag value for flow direction. */ -+ uint32_t return_qos_tag; /**< QoS tag value for the return direction. */ -+ uint8_t dscp_itag; /**< DSCP marking tag. */ -+ uint8_t dscp_imask; /**< DSCP marking input mask. */ -+ uint8_t dscp_omask; /**< DSCP marking output mask. */ -+ uint8_t dscp_oval; /**< DSCP marking output value. */ -+ uint16_t vlan_itag; /**< VLAN marking tag. */ -+ uint16_t vlan_imask; /**< VLAN marking input mask. */ -+ uint16_t vlan_omask; /**< VLAN marking output mask. */ -+ uint16_t vlan_oval; /**< VLAN marking output value. */ -+ uint32_t in_vlan_tag[MAX_VLAN_DEPTH]; -+ /**< Ingress VLAN tag expected for this flow. */ -+ uint32_t out_vlan_tag[MAX_VLAN_DEPTH]; -+ /**< Egress VLAN tag expected for this flow. */ -+ uint8_t flow_dscp; /**< IP DSCP value for flow direction. */ -+ uint8_t return_dscp; /**< IP DSCP value for the return direction. */ -+}; -+ -+/* -+ * IPv6 connection flags (to be used with nss_ipv6_create::flags. -+ */ -+#define NSS_IPV6_CREATE_FLAG_NO_SEQ_CHECK 0x1 -+ /**< Indicates that sequence numbers are not to be checked. */ -+#define NSS_IPV6_CREATE_FLAG_BRIDGE_FLOW 0x02 -+ /**< Indicates that this is a pure bridge flow (no routing is involved). */ -+#define NSS_IPV6_CREATE_FLAG_ROUTED 0x04 /**< Rule is for a routed connection. */ -+#define NSS_IPV6_CREATE_FLAG_DSCP_MARKING 0x08 /**< Rule for DSCP marking. */ -+#define NSS_IPV6_CREATE_FLAG_VLAN_MARKING 0x10 /**< Rule for VLAN marking. */ -+#define NSS_IPV6_CREATE_FLAG_QOS_VALID 0x20 /**< Rule for Valid QoS. */ -+ -+/** -+ * nss_ipv6_destroy -+ * Information for an IPv6 flow or connection destroy rule. -+ */ -+struct nss_ipv6_destroy { -+ int32_t protocol; /**< L4 protocol (e.g., TCP or UDP). */ -+ uint32_t src_ip[4]; /**< Source IP address. */ -+ int32_t src_port; /**< Source L4 port (e.g., TCP or UDP port). */ -+ uint32_t dest_ip[4]; /**< Destination IP address. */ -+ int32_t dest_port; /**< Destination L4 port (e.g., TCP or UDP port). */ -+}; -+ -+/** -+ * nss_ipv4_sync -+ * Defines packet statistics for IPv4 and also keeps the connection entry alive. -+ * -+ * Statistics are bytes and packets seen over a connection. -+ * -+ * The addresses are NON-NAT addresses (i.e., true endpoint -+ * addressing). -+ * -+ * The source (src) creates the connection. -+ */ -+struct nss_ipv4_sync { -+ uint32_t index; /**< Slot ID for cache statistics to host OS. */ -+ /*TODO: use an opaque information as host and NSS -+ may be using a different mechanism to store rules. */ -+ int32_t protocol; /**< L4 protocol (e.g., TCP or UDP). */ -+ uint32_t src_ip; /**< Source IP address. */ -+ int32_t src_port; /**< Source L4 port (e.g., TCP or UDP port). */ -+ uint32_t src_ip_xlate; /**< Translated source IP address (used with SNAT). */ -+ int32_t src_port_xlate; /**< Translated source L4 port (used with SNAT). */ -+ uint32_t dest_ip; /**< Destination IP address. */ -+ int32_t dest_port; /**< Destination L4 port (e.g., TCP or UDP port). */ -+ uint32_t dest_ip_xlate; -+ /**< Translated destination IP address (used with DNAT). */ -+ int32_t dest_port_xlate; -+ /**< Translated destination L4 port (used with DNAT). */ -+ uint32_t flow_max_window; /**< Maximum window size (TCP). */ -+ uint32_t flow_end; /**< TCP window end. */ -+ uint32_t flow_max_end; /**< TCP window maximum end. */ -+ uint32_t flow_rx_packet_count; /**< Rx packet count for the flow interface. */ -+ uint32_t flow_rx_byte_count; /**< Rx byte count for the flow interface. */ -+ uint32_t flow_tx_packet_count; /**< Tx packet count for the flow interface. */ -+ uint32_t flow_tx_byte_count; /**< Tx byte count for the flow interface. */ -+ uint32_t return_max_window; -+ /**< Maximum window size (TCP) for the return direction. */ -+ uint32_t return_end; -+ /**< End for the return direction. */ -+ uint32_t return_max_end; -+ /**< Maximum end for the return direction. */ -+ uint32_t return_rx_packet_count; -+ /**< Rx packet count for the return direction. */ -+ uint32_t return_rx_byte_count; -+ /**< Rx byte count for the return direction. */ -+ uint32_t return_tx_packet_count; -+ /**< Tx packet count for the return direction. */ -+ uint32_t return_tx_byte_count; -+ /**< Tx byte count for the return direction. */ -+ -+ /** -+ * Time in Linux jiffies to be added to the current timeout to keep the -+ * connection alive. -+ */ -+ unsigned long int delta_jiffies; -+ -+ uint8_t reason; /**< Reason for synchronization. */ -+ uint32_t param_a0; /**< Custom parameter 0. */ -+ uint32_t param_a1; /**< Custom parameter 1. */ -+ uint32_t param_a2; /**< Custom parameter 2. */ -+ uint32_t param_a3; /**< Custom parameter 3. */ -+ uint32_t param_a4; /**< Custom parameter 4. */ -+ -+ uint8_t flags; /**< Flags indicating the status of the flow. */ -+ uint32_t qos_tag; /**< QoS value of the flow. */ -+}; -+ -+/** -+ * nss_ipv4_establish -+ * Defines connection-established message parameters for IPv4. -+ */ -+struct nss_ipv4_establish { -+ uint32_t index; /**< Slot ID for cache statistics to host OS. */ -+ /*TODO: use an opaque information as host and NSS -+ may be using a different mechanism to store rules. */ -+ uint8_t protocol; /**< Protocol number. */ -+ uint8_t reserved[3]; /**< Padding for word alignment. */ -+ int32_t flow_interface; /**< Flow interface number. */ -+ uint32_t flow_mtu; /**< MTU for the flow interface. */ -+ uint32_t flow_ip; /**< Flow IP address. */ -+ uint32_t flow_ip_xlate; /**< Translated flow IP address. */ -+ uint32_t flow_ident; /**< Flow identifier (e.g., port). */ -+ uint32_t flow_ident_xlate; /**< Translated flow identifier (e.g., port). */ -+ uint16_t flow_mac[3]; /**< Source MAC address for the flow direction. */ -+ uint32_t flow_pppoe_if_exist; /**< Flow direction: PPPoE interface existence flag. */ -+ int32_t flow_pppoe_if_num; /**< Flow direction: PPPoE interface number. */ -+ uint16_t ingress_vlan_tag; /**< Ingress VLAN tag. */ -+ int32_t return_interface; /**< Return interface number. */ -+ uint32_t return_mtu; /**< MTU for the return interface. */ -+ uint32_t return_ip; /**< Return IP address. */ -+ uint32_t return_ip_xlate; /**< Translated return IP address. */ -+ uint32_t return_ident; /**< Return identier (e.g., port). */ -+ uint32_t return_ident_xlate; /**< Translated return identifier (e.g., port). */ -+ uint16_t return_mac[3]; /**< Source MAC address for the return direction. */ -+ uint32_t return_pppoe_if_exist; /**< Return direction: PPPoE interface existence flag. */ -+ int32_t return_pppoe_if_num; /**< Return direction: PPPoE interface number. */ -+ uint16_t egress_vlan_tag; /**< Egress VLAN tag. */ -+ uint8_t flags; /**< Flags indicating the status of the flow. */ -+ uint32_t qos_tag; /**< QoS value of the flow. */ -+}; -+ -+/** -+ * nss_ipv4_cb_reason -+ * Reasons for an IPv4 callback. -+ */ -+enum nss_ipv4_cb_reason { -+ NSS_IPV4_CB_REASON_ESTABLISH = 0, -+ NSS_IPV4_CB_REASON_SYNC, -+ NSS_IPV4_CB_REASON_ESTABLISH_FAIL, -+}; -+ -+/** -+ * nss_ipv4_cb_params -+ * Message parameters for an IPv4 callback. -+ */ -+struct nss_ipv4_cb_params { -+ enum nss_ipv4_cb_reason reason; /**< Reason for the callback. */ -+ -+ /** -+ * Message parameters for an IPv4 callback. -+ */ -+ union { -+ struct nss_ipv4_sync sync; -+ /**< Parameters for synchronization. */ -+ struct nss_ipv4_establish establish; -+ /**< Parameters for establishing a connection. */ -+ } params; /**< Payload of parameters. */ -+}; -+ -+/** -+ * nss_ipv6_sync -+ * Update packet statistics (bytes and packets seen over a connection) and also keep the connection entry alive. -+ * -+ * The addresses are NON-NAT addresses (i.e., true endpoint addressing). -+ * -+ * The source (src) creates the connection. -+ */ -+struct nss_ipv6_sync { -+ uint32_t index; /**< Slot ID for cache statistics to the host OS. */ -+ int32_t protocol; /**< L4 protocol (e.g., TCP or UDP). */ -+ uint32_t src_ip[4]; /**< Source IP address. */ -+ int32_t src_port; /**< Source L4 port (e.g., TCP or UDP port). */ -+ uint32_t dest_ip[4]; /**< Destination IP address. */ -+ int32_t dest_port; /**< Destination L4 port (e.g., TCP or UDP port). */ -+ uint32_t flow_max_window; /**< Maximum window size (TCP). */ -+ uint32_t flow_end; /**< TCP window end. */ -+ uint32_t flow_max_end; /**< TCP window maximum end. */ -+ uint32_t flow_rx_packet_count; /**< Rx packet count for the flow interface. */ -+ uint32_t flow_rx_byte_count; /**< Rx byte count for the flow interface. */ -+ uint32_t flow_tx_packet_count; /**< Tx packet count for the flow interface. */ -+ uint32_t flow_tx_byte_count; /**< Tx byte count for the flow interface. */ -+ uint32_t return_max_window; -+ /**< Maximum window size (TCP) for the return direction. */ -+ uint32_t return_end; -+ /**< End for the return direction. */ -+ uint32_t return_max_end; -+ /**< Maximum end for the return direction. */ -+ uint32_t return_rx_packet_count; -+ /**< Rx packet count for the return direction. */ -+ uint32_t return_rx_byte_count; -+ /**< Rx byte count for the return direction. */ -+ uint32_t return_tx_packet_count; -+ /**< Tx packet count for the return direction. */ -+ uint32_t return_tx_byte_count; -+ /**< Tx byte count for the return direction. */ -+ -+ /** -+ * Time in Linux jiffies to be added to the current timeout to keep the -+ * connection alive. -+ */ -+ unsigned long int delta_jiffies; -+ -+ /** -+ * Non-zero when the NA has ceased to accelerate the given connection. -+ */ -+ uint8_t final_sync; -+ -+ uint8_t evicted; /**< Non-zero if the connection is evicted. */ -+ -+ uint8_t flags; /**< Flags indicating the status of the flow. */ -+ uint32_t qos_tag; /**< QoS value of the flow. */ -+}; -+ -+/** -+ * nss_ipv6_establish -+ * Defines connection-established message parameters for IPv6. -+ */ -+struct nss_ipv6_establish { -+ uint32_t index; /**< Slot ID for cache statistics to the host OS. */ -+ uint8_t protocol; /**< Protocol number. */ -+ int32_t flow_interface; /**< Flow interface number. */ -+ uint32_t flow_mtu; /**< MTU for the flow interface. */ -+ uint32_t flow_ip[4]; /**< Flow IP address. */ -+ uint32_t flow_ident; /**< Flow identifier (e.g., port). */ -+ uint16_t flow_mac[3]; /**< Source MAC address for the flow direction. */ -+ uint32_t flow_pppoe_if_exist; /**< Flow direction: PPPoE interface existence flag. */ -+ int32_t flow_pppoe_if_num; /**< Flow direction: PPPoE interface number. */ -+ uint16_t ingress_vlan_tag; /**< Ingress VLAN tag. */ -+ int32_t return_interface; /**< Return interface number. */ -+ uint32_t return_mtu; /**< MTU for the return interface. */ -+ uint32_t return_ip[4]; /**< Return IP address. */ -+ uint32_t return_ident; /**< Return identier (e.g., port). */ -+ uint16_t return_mac[3]; /**< Source MAC address for the return direction. */ -+ uint32_t return_pppoe_if_exist; /**< Return direction: PPPoE interface existence flag. */ -+ int32_t return_pppoe_if_num; /**< Return direction: PPPoE interface number. */ -+ uint16_t egress_vlan_tag; /**< VLAN tag to be inserted for egress direction. */ -+ uint8_t flags; /**< Flags indicating the status of the flow. */ -+ uint32_t qos_tag; /**< QoS value of the flow. */ -+}; -+ -+/** -+ * nss_ipv6_cb_reason -+ * Reasons for an IPv6 callback. -+ */ -+enum nss_ipv6_cb_reason { -+ NSS_IPV6_CB_REASON_ESTABLISH = 0, -+ NSS_IPV6_CB_REASON_SYNC, -+ NSS_IPV6_CB_REASON_ESTABLISH_FAIL, -+}; -+ -+/** -+ * nss_ipv6_cb_params -+ * Message parameters for an IPv6 callback. -+ */ -+struct nss_ipv6_cb_params { -+ enum nss_ipv6_cb_reason reason; /**< Reason for the callback. */ -+ -+ /** -+ * Message parameters for an IPv6 callback. -+ */ -+ union { -+ struct nss_ipv6_sync sync; -+ /**< Parameters for synchronization. */ -+ struct nss_ipv6_establish establish; -+ /**< Parameters for establishing a connection. */ -+ } params; /**< Callback parameters. */ -+}; -+ - /* - * General utilities - */ -@@ -308,6 +797,16 @@ - typedef void (*nss_if_rx_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - - /** -+ * Callback function for IPv4 connection synchronization messages. -+ * -+ * @datatypes -+ * nss_ipv4_cb_params -+ * -+ * @param[in] nicb Pointer to the parameter structure for an NSS IPv4 callback. -+ */ -+typedef void (*nss_ipv4_callback_t)(struct nss_ipv4_cb_params *nicb); -+ -+/** - * nss_get_state - * Gets the NSS state. - * ---- a/exports/nss_c2c_rx.h -+++ b/exports/nss_c2c_rx.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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. -@@ -36,7 +36,7 @@ enum nss_c2c_rx_stats_types { - /**< Number of received simple pbufs. */ - NSS_C2C_RX_STATS_PBUF_SG, /**< Number of scatter-gather pbufs received. */ - NSS_C2C_RX_STATS_PBUF_RETURNING, /**< Number of returning scatter-gather pbufs. */ -- NSS_C2C_RX_STATS_INVAL_DEST, /**< Number of pbuf enqueue failures because destination is invalid. */ -+ NSS_C2C_RX_STATS_INVAL_DEST, /**< Number of pbuf enqueue failures because of destination is invalid. */ - NSS_C2C_RX_STATS_MAX, /**< Maximum message type. */ - }; - ---- a/exports/nss_c2c_tx.h -+++ b/exports/nss_c2c_tx.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2018-2020, 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. -@@ -72,9 +72,9 @@ enum nss_c2c_tx_test_type { - */ - enum nss_c2c_tx_stats_types { - NSS_C2C_TX_STATS_PBUF_SIMPLE = NSS_STATS_NODE_MAX, -- /**< Number of received simple pbufs. */ -- NSS_C2C_TX_STATS_PBUF_SG, /**< Number of scatter-gather pbufs received. */ -- NSS_C2C_TX_STATS_PBUF_RETURNING, /**< Number of returning scatter-gather pbufs. */ -+ /**< Number of received simple pbuf. */ -+ NSS_C2C_TX_STATS_PBUF_SG, /**< Number of scatter-gather pbuf received. */ -+ NSS_C2C_TX_STATS_PBUF_RETURNING, /**< Number of returning scatter-gather pbuf. */ - NSS_C2C_TX_STATS_MAX, /**< Maximum message type. */ - }; - ---- a/exports/nss_capwap.h -+++ b/exports/nss_capwap.h -@@ -1,12 +1,9 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2014-2020, 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 -@@ -94,7 +91,6 @@ typedef enum nss_capwap_msg_type { - NSS_CAPWAP_MSG_TYPE_DTLS, - NSS_CAPWAP_MSG_TYPE_FLOW_RULE_ADD, - NSS_CAPWAP_MSG_TYPE_FLOW_RULE_DEL, -- NSS_CAPWAP_MSG_TYPE_UPDATE_VP_NUM, - NSS_CAPWAP_MSG_TYPE_MAX, - } nss_capwap_msg_type_t; - -@@ -119,10 +115,6 @@ typedef enum nss_capwap_msg_response { - NSS_CAPWAP_ERROR_MSG_FLOW_TABLE_FULL, - NSS_CAPWAP_ERROR_MSG_FLOW_EXIST, - NSS_CAPWAP_ERROR_MSG_FLOW_NOT_EXIST, -- NSS_CAPWAP_ERROR_MSG_INVALID_INTERFACE, -- NSS_CAPWAP_ERROR_MSG_UPDATE_VP_NUM_FAILED, -- NSS_CAPWAP_ERROR_MSG_DELETE_VP_NUM_FAILED, -- NSS_CAPWAP_ERROR_MSG_INVALID_NEXT_NODE, - NSS_CAPWAP_ERROR_MSG_MAX, - } nss_capwap_msg_response_t; - -@@ -147,8 +139,8 @@ struct nss_capwap_stats_msg { - - uint32_t rx_frag_timeout_drops; - /**< Packets dropped because of a reassembly timeout. */ -- uint32_t rx_n2h_drops; -- /**< Packets dropped because of error in packet processing. */ -+ uint32_t rx_queue_full_drops; -+ /**< Packets dropped because the queue is full. */ - uint32_t rx_n2h_queue_full_drops; - /**< Packets dropped because the NSS-to-host queue is full. */ - uint32_t rx_csum_drops; -@@ -306,22 +298,6 @@ struct nss_capwap_flow_rule_msg { - }; - - /** -- * nss_capwap_enable_tunnel_msg -- * Structure to update sibling interface number. -- */ --struct nss_capwap_enable_tunnel_msg { -- uint32_t sibling_if_num; /**< Sibling interface number. */ --}; -- --/** -- * nss_capwap_update_vp_num_msg -- * Structure to update the VP number associated with the tunnel. -- */ --struct nss_capwap_update_vp_num_msg { -- int16_t vp_num; /**< VP number associated with the tunnel. */ --}; -- --/** - * nss_capwap_msg - * Data for sending and receiving CAPWAP messages. - */ -@@ -346,10 +322,6 @@ struct nss_capwap_msg { - /**< Flow rule add message. */ - struct nss_capwap_flow_rule_msg flow_rule_del; - /**< Flow rule delete message. */ -- struct nss_capwap_enable_tunnel_msg enable_tunnel; -- /**< Enable tunnel message. */ -- struct nss_capwap_update_vp_num_msg update_vp_num; -- /**< Update VP number message. */ - } msg; /**< Message payload. */ - }; - -@@ -386,8 +358,8 @@ struct nss_capwap_tunnel_stats { - - uint64_t rx_frag_timeout_drops; - /**< Packets dropped because of a reassembly timeout. */ -- uint64_t rx_n2h_drops; -- /**< Packets dropped because of error in processing the packet. */ -+ uint64_t rx_queue_full_drops; -+ /**< Packets dropped because the queue is full. */ - uint64_t rx_n2h_queue_full_drops; - /**< Packets dropped because the NSS-to-host queue is full. */ - uint64_t rx_csum_drops; -@@ -402,7 +374,6 @@ struct nss_capwap_tunnel_stats { - /* - * Tx/encap stats - */ -- uint64_t tx_dropped_inner; /** NSS_FW_VERSION(11,0)) - NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_MATCH, -+#endif - NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H, - NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_H2N, -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_EXTERNAL0, - NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_EXTERNAL1, - NSS_DYNAMIC_INTERFACE_TYPE_TLS_INNER, - NSS_DYNAMIC_INTERFACE_TYPE_TLS_OUTER, - NSS_DYNAMIC_INTERFACE_TYPE_MIRROR, -- NSS_DYNAMIC_INTERFACE_TYPE_WIFI_EXT_VDEV_WDS, -- NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_HOST_INNER, -- NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_OUTER, -- NSS_DYNAMIC_INTERFACE_TYPE_WIFI_EXT_VDEV_VLAN, -- NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER, -- NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER, -+#endif - NSS_DYNAMIC_INTERFACE_TYPE_MAX - }; - ---- a/exports/nss_edma.h -+++ b/exports/nss_edma.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2020, 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. -@@ -84,7 +84,6 @@ enum nss_edma_stats_rx_t { - NSS_EDMA_STATS_RX_DESC, - NSS_EDMA_STATS_RX_QOS_ERR, - NSS_EDMA_STATS_RX_SRC_PORT_INVALID, -- NSS_EDMA_STATS_RX_SRC_IF_INVALID, - NSS_EDMA_STATS_RX_MAX - }; - -@@ -144,7 +143,6 @@ struct nss_edma_rx_ring_stats { - uint32_t desc_cnt; /**< Number of descriptors processed. */ - uint32_t qos_err; /**< Number of QoS errors. */ - uint32_t rx_src_port_invalid; /**< Number of source port invalid errors. */ -- uint32_t rx_src_if_invalid; /**< Number of source interface invalid errors. */ - }; - - /** -@@ -330,7 +328,7 @@ extern void nss_edma_notify_unregister(v - * nss_edma_get_stats - * Sends EDMA statistics to NSS clients. - * -- * @param[in] stats EDMA statistics to be sent to netlink. -+ * @param[in] stats EDMA statistics to be sent to Netlink. - * @param[in] port_id EDMA port ID. - * - * @return ---- /dev/null -+++ b/exports/nss_fw_version.h -@@ -0,0 +1,11 @@ -+#ifndef __NSS_FW_VERSION_H -+#define __NSS_FW_VERSION_H -+ -+#define NSS_FW_VERSION_MAJOR 11 -+#define NSS_FW_VERSION_MINOR 0 -+ -+#define NSS_FW_VERSION(a,b) (((a) << 8) + (b)) -+ -+#define NSS_FW_VERSION_CODE NSS_FW_VERSION(NSS_FW_VERSION_MAJOR, NSS_FW_VERSION_MINOR) -+ -+#endif /* __NSS_FW_VERSION_H */ ---- a/exports/nss_gre.h -+++ b/exports/nss_gre.h -@@ -1,9 +1,6 @@ - /* -- **************************************************************************** -- * Copyright (c) 2017-2019, 2021, The Linux Foundation. All rights reserved. -- * -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ ************************************************************************** -+ * Copyright (c) 2017-2019, 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. -@@ -14,7 +11,7 @@ - * 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. -- **************************************************************************** -+ ************************************************************************** - */ - - /** -@@ -104,16 +101,16 @@ enum nss_gre_msg_types { - }; - - /** -- * GRE mode types. -+ * GRE Mode Types - */ - enum nss_gre_mode { -- NSS_GRE_MODE_TUN, /**< GRE tunnel interface. */ -- NSS_GRE_MODE_TAP, /**< GRE TAP interface. */ -+ NSS_GRE_MODE_TUN, /**< GRE Tunnel interface. */ -+ NSS_GRE_MODE_TAP, /**< GRE Tap interface. */ - NSS_GRE_MODE_MAX /**< Maxmum GRE mode. */ - }; - - /** -- * GRE IP types. -+ * GRE IP Types - */ - enum nss_gre_ip_types { - NSS_GRE_IP_IPV4, /**< Outer Tunnel is IPV4. */ -@@ -122,60 +119,58 @@ enum nss_gre_ip_types { - }; - - /** -- * nss_gre_base_types -- * GRE base debug statistics. -+ * GRE Base debug statistics - */ --enum nss_gre_base_types { -- NSS_GRE_BASE_RX_PACKETS, /**< Receive packet count. */ -- NSS_GRE_BASE_RX_DROPPED, /**< Number of packet dropped at receive. */ -- NSS_GRE_BASE_EXP_ETH_HDR_MISSING, /**< Ethernet header missing. */ -- NSS_GRE_BASE_EXP_ETH_TYPE_NON_IP, /**< Packet is not IPV4 or IPV6. */ -- NSS_GRE_BASE_EXP_IP_UNKNOWN_PROTOCOL, /**< Packet protocol is unknown. */ -- NSS_GRE_BASE_EXP_IP_HEADER_INCOMPLETE, /**< Bad IP header. */ -- NSS_GRE_BASE_EXP_IP_BAD_TOTAL_LENGTH, /**< IP total length is invalid. */ -- NSS_GRE_BASE_EXP_IP_BAD_CHECKSUM, /**< IP checksum is bad. */ -- NSS_GRE_BASE_EXP_IP_DATAGRAM_INCOMPLETE,/**< Bad packet. */ -- NSS_GRE_BASE_EXP_IP_FRAGMENT, /**< IP packet is a fragment. */ -- NSS_GRE_BASE_EXP_IP_OPTIONS_INCOMPLETE, /**< IP option is invalid. */ -- NSS_GRE_BASE_EXP_IP_WITH_OPTIONS, /**< IP packet with options. */ -- NSS_GRE_BASE_EXP_IPV6_UNKNOWN_PROTOCOL, /**< Protocol is unknown. */ -- NSS_GRE_BASE_EXP_IPV6_HEADER_INCOMPLETE,/**< Incomplete ipv6 header. */ -- NSS_GRE_BASE_EXP_GRE_UNKNOWN_SESSION, /**< Unknown GRE session. */ -- NSS_GRE_BASE_EXP_GRE_NODE_INACTIVE, /**< GRE node is inactive. */ -- NSS_GRE_BASE_DEBUG_MAX, /**< GRE base debug maximum. */ -+enum nss_gre_base_debug_types { -+ GRE_BASE_RX_PACKETS, /**< Rx packet count. */ -+ GRE_BASE_RX_DROPPED, /**< Number of packet dropped at Rx. */ -+ GRE_BASE_EXP_ETH_HDR_MISSING, /**< Ethernet header missing. */ -+ GRE_BASE_EXP_ETH_TYPE_NON_IP, /**< Packet is not IPV4 or IPV6. */ -+ GRE_BASE_EXP_IP_UNKNOWN_PROTOCOL, /**< Packet protocol is unknown. */ -+ GRE_BASE_EXP_IP_HEADER_INCOMPLETE, /**< Bad IP header. */ -+ GRE_BASE_EXP_IP_BAD_TOTAL_LENGTH, /**< IP total lenghth is invalid. */ -+ GRE_BASE_EXP_IP_BAD_CHECKSUM, /**< IP checksum is bad. */ -+ GRE_BASE_EXP_IP_DATAGRAM_INCOMPLETE, /**< Bad packet. */ -+ GRE_BASE_EXP_IP_FRAGMENT, /**< IP packet is a fragment. */ -+ GRE_BASE_EXP_IP_OPTIONS_INCOMPLETE, /**< IP option is invalid. */ -+ GRE_BASE_EXP_IP_WITH_OPTIONS, /**< IP packet with options. */ -+ GRE_BASE_EXP_IPV6_UNKNOWN_PROTOCOL, /**< Protocol is unknown. */ -+ GRE_BASE_EXP_IPV6_HEADER_INCOMPLETE, /**< Incomplete ipv6 header. */ -+ GRE_BASE_EXP_GRE_UNKNOWN_SESSION, /**< Unknown GRE session. */ -+ GRE_BASE_EXP_GRE_NODE_INACTIVE, /**< GRE node is inactive. */ -+ GRE_BASE_DEBUG_MAX, /**< GRE base debug max. */ - }; - --/** -- * nss_gre_session_types -- * GRE session packet drop and exception events. -- */ --enum nss_gre_session_types { -- NSS_GRE_SESSION_PBUF_ALLOC_FAIL, /**< Pbuf allocation failure. */ -- NSS_GRE_SESSION_DECAP_FORWARD_ENQUEUE_FAIL, /**< Receive forward enqueue failure. */ -- NSS_GRE_SESSION_ENCAP_FORWARD_ENQUEUE_FAIL, /**< Transmit forward enqueue failure. */ -- NSS_GRE_SESSION_DECAP_TX_FORWARDED, /**< Number of packets forwarded after decapsulation. */ -- NSS_GRE_SESSION_ENCAP_RX_RECEIVED, /**< Number of packets received for encapsulation. */ -- NSS_GRE_SESSION_ENCAP_RX_DROPPED, /**< Packets dropped while enqueuing for encapsulation. */ -- NSS_GRE_SESSION_ENCAP_RX_LINEAR_FAIL, /**< Packets dropped during encapsulation linearization. */ -- NSS_GRE_SESSION_EXP_RX_KEY_ERROR, /**< Receive key error. */ -- NSS_GRE_SESSION_EXP_RX_SEQ_ERROR, /**< Receive Sequence number error. */ -- NSS_GRE_SESSION_EXP_RX_CS_ERROR, /**< Receive checksum error */ -- NSS_GRE_SESSION_EXP_RX_FLAG_MISMATCH, /**< Receive flag mismatch. */ -- NSS_GRE_SESSION_EXP_RX_MALFORMED, /**< Receive packet is malformed. */ -- NSS_GRE_SESSION_EXP_RX_INVALID_PROTOCOL, /**< Receive packet protocol is invalid. */ -- NSS_GRE_SESSION_EXP_RX_NO_HEADROOM, /**< Packet does not have enough headroom. */ -- NSS_GRE_SESSION_DEBUG_MAX, /**< Session debug maximum. */ -+/* -+ * GRE session Packet drop and exception events. -+ */ -+enum gre_session_debug_types { -+ GRE_SESSION_PBUF_ALLOC_FAIL, /**< Pbuf allocation failure. */ -+ GRE_SESSION_DECAP_FORWARD_ENQUEUE_FAIL, /**< Rx forward enqueue failure. */ -+ GRE_SESSION_ENCAP_FORWARD_ENQUEUE_FAIL, /**< Tx forward enqueue failure. */ -+ GRE_SESSION_DECAP_TX_FORWARDED, /**< Number of packets forwarded after decap. */ -+ GRE_SESSION_ENCAP_RX_RECEIVED, /**< Number of packets received for encap. */ -+ GRE_SESSION_ENCAP_RX_DROPPED, /**< Packets dropped while enqueuing for encap. */ -+ GRE_SESSION_ENCAP_RX_LINEAR_FAIL, /**< Packets dropped during encap linearization. */ -+ GRE_SESSION_EXP_RX_KEY_ERROR, /**< Rx KEY error. */ -+ GRE_SESSION_EXP_RX_SEQ_ERROR, /**< Rx Sequence number error. */ -+ GRE_SESSION_EXP_RX_CS_ERROR, /**< Rx checksum error */ -+ GRE_SESSION_EXP_RX_FLAG_MISMATCH, /**< Rx flag mismatch. */ -+ GRE_SESSION_EXP_RX_MALFORMED, /**< Rx packet is malformed. */ -+ GRE_SESSION_EXP_RX_INVALID_PROTOCOL, /**< Rx packet protocol is invalid. */ -+ GRE_SESSION_EXP_RX_NO_HEADROOM, /**< Packet does not have enough headroom. */ -+ GRE_SESSION_DEBUG_MAX, /**< Session debug max. */ - }; - - /** - * GRE create message structure. - */ - struct nss_gre_config_msg { -- uint32_t src_ip[4]; /**< Source IPv4 or IPv6 address. */ -- uint32_t dest_ip[4]; /**< Destination IPv4 or IPv6 address. */ -+ uint32_t src_ip[4]; /**< Source IPv4 or IPv6 Adddress. */ -+ uint32_t dest_ip[4]; /**< Destination IPv4 or IPv6 Adddress. */ - uint32_t flags; /**< GRE Flags. */ -- uint32_t ikey; /**< GRE Rx key.*/ -- uint32_t okey; /**< GRE Tx key. */ -+ uint32_t ikey; /**< GRE rx KEY.*/ -+ uint32_t okey; /**< GRE tx KEY. */ - uint32_t mode; /**< GRE TUN or TAP. */ - uint32_t ip_type; /**< IPv4 or IPv6 type. */ - uint32_t next_node_if_num; /**< To whom to forward packets. */ -@@ -188,7 +183,7 @@ struct nss_gre_config_msg { - }; - - /** -- * GRE link up message structure. -+ * GRE link up message structure - */ - struct nss_gre_linkup_msg { - int if_number; /**< Interface number. */ -@@ -205,49 +200,30 @@ struct nss_gre_linkdown_msg { - * GRE deconfig message structure - */ - struct nss_gre_deconfig_msg { -- int if_number; /**< Interface number. */ -+ int if_number; /**< Interface number */ - }; - - /** -- * GRE session statistics message. -+ * GRE session statistics message - */ - struct nss_gre_session_stats_msg { -- struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ -- uint32_t stats[NSS_GRE_SESSION_DEBUG_MAX]; /**< Session debug statistics. */ -+ struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ -+ uint32_t stats[GRE_SESSION_DEBUG_MAX]; /**< Session debug statistics. */ - }; - - /** -- * GRE base statistics message. -+ * GRE base statistics message - */ - struct nss_gre_base_stats_msg { -- uint32_t stats[NSS_GRE_BASE_DEBUG_MAX]; /**< Base debug statistics. */ --}; -- --/** -- * nss_gre_base_stats_notification -- * GRE transmission statistics structure. -- */ --struct nss_gre_base_stats_notification { -- uint64_t stats_base_ctx[NSS_GRE_BASE_DEBUG_MAX]; /**< Base debug transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ --}; -- --/** -- * nss_gre_session_stats_notification -- * GRE transmission statistics structure. -- */ --struct nss_gre_session_stats_notification { -- uint64_t stats_session_ctx[NSS_GRE_SESSION_DEBUG_MAX]; /**< Session debug transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ -- uint32_t if_num; /**< Interface number. */ -+ uint32_t stats[GRE_BASE_DEBUG_MAX]; /**< Base debug statistics. */ - }; - - /** - * nss_gre_msg -- * Message structure to send/receive GRE messages. -+ * Message structure to send/receive GRE messages - */ - struct nss_gre_msg { -- struct nss_cmn_msg cm; /**< Common message header. */ -+ struct nss_cmn_msg cm; /**< Common message header */ - - /** - * Payload of a GRE message. -@@ -307,7 +283,7 @@ extern nss_tx_status_t nss_gre_tx_msg_sy - - /** - * nss_gre_tx_buf -- * Sends a packet to the NSS. -+ * Sends packet to the NSS - * - * @datatypes - * nss_ctx_instance \n -@@ -448,17 +424,7 @@ typedef void (*nss_gre_pkt_callback_t)(s - * @return - * None. - */ --#ifdef NSS_DRV_GRE_ENABLE - extern void nss_gre_register_pkt_callback(nss_gre_pkt_callback_t cb); --#else --static inline void nss_gre_register_pkt_callback(nss_gre_pkt_callback_t cb) --{ -- /* -- * Dummy registration function for external modules when GRE -- * is disabled -- */ --} --#endif - - /** - * nss_gre_unregister_pkt_callback -@@ -470,45 +436,7 @@ static inline void nss_gre_register_pkt_ - * @return - * None. - */ --#ifdef NSS_DRV_GRE_ENABLE - extern void nss_gre_unregister_pkt_callback(void); --#else --static inline void nss_gre_unregister_pkt_callback(void) --{ -- /* -- * Dummy registration function for external modules when GRE -- * is disabled -- */ --} --#endif -- --/** -- * nss_gre_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_stats_unregister_notifier(struct notifier_block *nb); -- --/** -- * nss_gre_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_stats_register_notifier(struct notifier_block *nb); - - /** - * @} ---- a/exports/nss_gre_redir.h -+++ b/exports/nss_gre_redir.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2015, 2017-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2015, 2017-2020, 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. -@@ -93,60 +93,6 @@ enum nss_gre_redir_tunnel_types { - }; - - /** -- * nss_gre_redir_stats_types -- * GRE redirect statistics types. -- */ --enum nss_gre_redir_stats_types { -- NSS_GRE_REDIR_STATS_TX_DROPS = NSS_STATS_NODE_MAX, -- /**< Dropped transmit packets. */ -- NSS_GRE_REDIR_STATS_SJACK_RX_PKTS, /**< SJACK receive packet counter. */ -- NSS_GRE_REDIR_STATS_SJACK_TX_PKTS, /**< SJACK transmit packet counter. */ -- NSS_GRE_REDIR_STATS_OFFLOAD_RX_PKTS_0, /**< Offload receive packet counter 0. */ -- NSS_GRE_REDIR_STATS_OFFLOAD_RX_PKTS_1, /**< Offload receive packet counter 1. */ -- NSS_GRE_REDIR_STATS_OFFLOAD_RX_PKTS_2, /**< Offload receive packet counter 2. */ -- NSS_GRE_REDIR_STATS_OFFLOAD_RX_PKTS_3, /**< Offload receive packet counter 3. */ -- NSS_GRE_REDIR_STATS_OFFLOAD_RX_PKTS_4, /**< Offload receive packet counter 4. */ -- NSS_GRE_REDIR_STATS_OFFLOAD_TX_PKTS_0, /**< Offload transmit packet counter 0. */ -- NSS_GRE_REDIR_STATS_OFFLOAD_TX_PKTS_1, /**< Offload transmit packet counter 1. */ -- NSS_GRE_REDIR_STATS_OFFLOAD_TX_PKTS_2, /**< Offload transmit packet counter 2. */ -- NSS_GRE_REDIR_STATS_OFFLOAD_TX_PKTS_3, /**< Offload transmit packet counter 3. */ -- NSS_GRE_REDIR_STATS_OFFLOAD_TX_PKTS_4, /**< Offload transmit packet counter 4. */ -- NSS_GRE_REDIR_STATS_EXCEPTION_US_RX_PKTS, -- /**< Upstream exception receive packet counter. */ -- NSS_GRE_REDIR_STATS_EXCEPTION_US_TX_PKTS, -- /**< Upstream exception transmit packet counter. */ -- NSS_GRE_REDIR_STATS_EXCEPTION_DS_RX_PKTS, -- /**< Downstream exception receive packet counter. */ -- NSS_GRE_REDIR_STATS_EXCEPTION_DS_TX_PKTS, -- /**< Downstream exception transmit packet counter. */ -- NSS_GRE_REDIR_STATS_ENCAP_SG_ALLOC_DROP, -- /**< Encapsulation drop counters due to scatter gather buffer allocation failure. */ -- NSS_GRE_REDIR_STATS_DECAP_FAIL_DROP, -- /**< Decapsulation drop counters due to invalid IP header. */ -- NSS_GRE_REDIR_STATS_DECAP_SPLIT_DROP, -- /**< Decapsulation drop counters due to split flow processing. */ -- NSS_GRE_REDIR_STATS_SPLIT_SG_ALLOC_FAIL, -- /**< Split processing fail counter due to scatter gather buffer allocation failure. */ -- NSS_GRE_REDIR_STATS_SPLIT_LINEAR_COPY_FAIL, -- /**< Split processing fail counter due to linear copy fail. */ -- NSS_GRE_REDIR_STATS_SPLIT_NOT_ENOUGH_TAILROOM, -- /**< Split processing fail counter due to insufficient tailroom. */ -- NSS_GRE_REDIR_STATS_EXCEPTION_DS_INVALID_DST_DROP, -- /**< Downstream exception handling fail counter due to invalid destination. */ -- NSS_GRE_REDIR_STATS_DECAP_EAPOL_FRAMES, -- /**< Decapsulation EAPoL frame counters. */ -- NSS_GRE_REDIR_STATS_EXCEPTION_DS_INV_APPID, -- /**< Invalid application ID for the transmit completion packets on exception downstream node. */ -- NSS_GRE_REDIR_STATS_HEADROOM_UNAVAILABLE, -- /**< Packet headroom unavailable to write metadata. */ -- NSS_GRE_REDIR_STATS_TX_COMPLETION_SUCCESS, -- /**< Host enqueue success count for the transmit completion packets. */ -- NSS_GRE_REDIR_STATS_TX_COMPLETION_DROP, -- /**< Host enqueue drop count for the transmit completion packets. */ -- NSS_GRE_REDIR_STATS_MAX /**< Maximum statistics type. */ --}; -- --/** - * nss_gre_redir_inner_configure_msg - * Message information for configuring GRE inner node. - */ -@@ -301,63 +247,34 @@ struct nss_gre_redir_stats_sync_msg { - }; - - /** -- * nss_gre_redir_tun_stats -- * GRE redirect statistics to accumulate all stats values. -- */ --struct nss_gre_redir_tun_stats { -- uint64_t rx_packets; /**< Number of packets received. */ -- uint64_t rx_bytes; /**< Number of bytes received. */ -- uint64_t tx_packets; /**< Number of packets transmitted. */ -- uint64_t tx_bytes; /**< Number of bytes transmitted. */ -- uint64_t rx_dropped[NSS_MAX_NUM_PRI]; -- /**< Packets dropped on receive due to queue full. */ -- uint64_t tx_dropped; /**< Dropped transmit packets. */ -- uint64_t sjack_rx_packets; /**< SJACK receive packet counter. */ -- uint64_t sjack_tx_packets; /**< SJACK transmit packet counter. */ -- uint64_t offl_rx_pkts[NSS_GRE_REDIR_MAX_RADIO]; /**< Offload receive packet counter per radio. */ -- uint64_t offl_tx_pkts[NSS_GRE_REDIR_MAX_RADIO]; /**< Offload transmit packet counter per radio. */ -- uint64_t exception_us_rx; /**< Upstream exception receive packet counter. */ -- uint64_t exception_us_tx; /**< Upstream exception transmit packet counter. */ -- uint64_t exception_ds_rx; /**< Downstream exception receive packet counter. */ -- uint64_t exception_ds_tx; /**< Downstream exception transmit packet counter. */ -- uint64_t encap_sg_alloc_drop; -- /**< Encapsulation drop counters due to scatter gather buffer allocation failure. */ -- uint64_t decap_fail_drop; /**< Decapsulation drop counters due to invalid IP header. */ -- uint64_t decap_split_drop; /**< Decapsulation drop counters due to split flow processing. */ -- uint64_t split_sg_alloc_fail; -- /**< Split processing fail counter due to scatter gather buffer allocation failure. */ -- uint64_t split_linear_copy_fail; -- /**< Split processing fail counter due to linear copy fail. */ -- uint64_t split_not_enough_tailroom; -- /**< Split processing fail counter due to insufficient tailroom. */ -- uint64_t exception_ds_invalid_dst_drop; -- /**< Downstream exception handling fail counter due to invalid destination. */ -- uint64_t decap_eapol_frames; /**< Decapsulation EAPoL frame counters. */ -- uint64_t exception_ds_inv_appid; -- /**< Invalid application ID for the transmit completion packets on exception downstream node. */ -- uint64_t headroom_unavail; /**< Packet headroom unavailable to write metadata. */ -- uint64_t tx_completion_success; /**< Host enqueue success count for the transmit completion packets. */ -- uint64_t tx_completion_drop; /**< Host enqueue drop count for the transmit completion packets. */ --}; -- --/** - * nss_gre_redir_tunnel_stats - * GRE redirect statistics as seen by the HLOS. - */ - struct nss_gre_redir_tunnel_stats { -- struct net_device *dev; /**< Net device. */ -- struct nss_gre_redir_tun_stats tstats; /**< Structure to accumulate all the statistics. */ -- uint32_t ref_count; /**< Reference count for statistics. */ --}; -- --/** -- * nss_gre_redir_stats_notification -- * GRE redirect transmission statistics structure. -- */ --struct nss_gre_redir_stats_notification { -- struct nss_gre_redir_tunnel_stats stats_ctx; /**< Context transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ -- uint32_t if_num; /**< Interface number. */ -+ struct net_device *dev; /**< Net device. */ -+ struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ -+ uint64_t tx_dropped; /**< Dropped Tx packets. */ -+ uint64_t sjack_rx_packets; /**< SJACK Rx packet counter. */ -+ uint64_t sjack_tx_packets; /**< SJACK Tx packet counter. */ -+ uint64_t offl_rx_pkts[NSS_GRE_REDIR_MAX_RADIO]; /**< Offload Rx packet counter per radio. */ -+ uint64_t offl_tx_pkts[NSS_GRE_REDIR_MAX_RADIO]; /**< Offload Tx packet counter per radio. */ -+ uint64_t exception_us_rx; /**< Upstream exception Rx packet counter. */ -+ uint64_t exception_us_tx; /**< Upstream exception Tx packet counter. */ -+ uint64_t exception_ds_rx; /**< Downstream exception Rx packet counter. */ -+ uint64_t exception_ds_tx; /**< Downstream exception Tx packet counter. */ -+ uint64_t encap_sg_alloc_drop; /**< Encapsulation drop counters due to scatter gather buffer allocation failure. */ -+ uint64_t decap_fail_drop; /**< Decapsulation drop counters due to invalid IP header. */ -+ uint64_t decap_split_drop; /**< Decapsulation drop counters due to split flow processing. */ -+ uint64_t split_sg_alloc_fail; /**< Split processing fail counter due to scatter gather buffer allocation failure. */ -+ uint64_t split_linear_copy_fail; /**< Split processing fail counter due to linear copy fail. */ -+ uint64_t split_not_enough_tailroom; /**< Split processing fail counter due to insufficient tailroom. */ -+ uint64_t exception_ds_invalid_dst_drop; /**< Downstream exception handling fail counter due to invalid destination. */ -+ uint64_t decap_eapol_frames; /**< Decapsulation EAPoL frame counters. */ -+ uint64_t exception_ds_inv_appid; /**< Invalid application ID for the Tx completion packets on exception downstream node. */ -+ uint64_t headroom_unavail; /**< Packet headroom unavailable to write metadata. */ -+ uint64_t tx_completion_success; /**< Host enqueue success count for the Tx completion packets. */ -+ uint64_t tx_completion_drop; /**< Host enqueue drop count for the Tx completion packets. */ -+ uint32_t ref_count; /**< Reference count for statistics. */ - }; - - /** -@@ -549,7 +466,7 @@ extern nss_tx_status_t nss_gre_redir_tx_ - uint32_t if_num); - - /** -- * nss_gre_redir_stats_get -+ * nss_gre_redir_get_stats - * Gets GRE redirect tunnel statistics. - * - * @datatypes -@@ -561,7 +478,7 @@ extern nss_tx_status_t nss_gre_redir_tx_ - * @return - * TRUE or FALSE. - */ --extern bool nss_gre_redir_stats_get(int index, struct nss_gre_redir_tunnel_stats *stats); -+extern bool nss_gre_redir_get_stats(int index, struct nss_gre_redir_tunnel_stats *stats); - - /** - * nss_gre_redir_alloc_and_register_node -@@ -678,34 +595,6 @@ extern struct dentry *nss_gre_redir_get_ - extern struct device *nss_gre_redir_get_device(void); - - /** -- * nss_gre_redir_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_redir_stats_unregister_notifier(struct notifier_block *nb); -- --/** -- * nss_gre_redir_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_redir_stats_register_notifier(struct notifier_block *nb); -- --/** - * @} - */ - ---- a/exports/nss_gre_redir_lag.h -+++ b/exports/nss_gre_redir_lag.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2018, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2018, 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. -@@ -73,39 +73,6 @@ enum nss_gre_redir_lag_ds_message_types - }; - - /** -- * nss_gre_redir_lag_ds_stats_types -- * GRE redirect LAG downstream statistics. -- */ --enum nss_gre_redir_lag_ds_stats_types { -- NSS_GRE_REDIR_LAG_DS_STATS_DST_INVALID = NSS_STATS_NODE_MAX, -- /**< Packets that do not have a valid destination. */ -- NSS_GRE_REDIR_LAG_DS_STATS_EXCEPTION_PKT, /**< Packets that are exceptioned to host. */ -- NSS_GRE_REDIR_LAG_DS_STATS_MAX, /**< Maximum statistics type. */ --}; -- --/** -- * nss_gre_redir_lag_us_stats_types -- * GRE redirect LAG upstream statistics. -- */ --enum nss_gre_redir_lag_us_stats_types { -- NSS_GRE_REDIR_LAG_US_STATS_AMSDU_PKTS = NSS_STATS_NODE_MAX, -- /**< Number of AMSDU packets seen. */ -- NSS_GRE_REDIR_LAG_US_STATS_AMSDU_PKTS_ENQUEUED, /**< Number of AMSDU packets enqueued. */ -- NSS_GRE_REDIR_LAG_US_STATS_AMSDU_PKTS_EXCEPTIONED, -- /**< Number of AMSDU packets exceptioned. */ -- NSS_GRE_REDIR_LAG_US_STATS_EXCEPTIONED, /**< Number of exceptioned packets. */ -- NSS_GRE_REDIR_LAG_US_STATS_FREED, /**< Freed packets when equeue to NSS to host fails. */ -- NSS_GRE_REDIR_LAG_US_STATS_ADD_ATTEMPT, /**< Add hash attempts. */ -- NSS_GRE_REDIR_LAG_US_STATS_ADD_SUCCESS, /**< Add hash success. */ -- NSS_GRE_REDIR_LAG_US_STATS_ADD_FAIL_TABLE_FULL, /**< Add hash failed due to full table. */ -- NSS_GRE_REDIR_LAG_US_STATS_ADD_FAIL_EXISTS, /**< Add hash failed as entry already exists. */ -- NSS_GRE_REDIR_LAG_US_STATS_DEL_ATTEMPT, /**< Delete hash attempts. */ -- NSS_GRE_REDIR_LAG_US_STATS_DEL_SUCCESS, /**< Delete hash success. */ -- NSS_GRE_REDIR_LAG_US_STATS_DEL_FAIL_NOT_FOUND, /**< Delete hash failed as entry not found in hash table. */ -- NSS_GRE_REDIR_LAG_US_STATS_MAX, /**< Maximum statistics type. */ --}; -- --/** - * nss_gre_redir_lag_us_hash_mode - * GRE redirect LAG upstream hash modes. - */ -@@ -287,16 +254,6 @@ struct nss_gre_redir_lag_us_tunnel_stats - }; - - /** -- * nss_gre_redir_lag_us_stats_notification -- * GRE redirect LAG upstream transmission statistics structure. -- */ --struct nss_gre_redir_lag_us_stats_notification { -- struct nss_gre_redir_lag_us_tunnel_stats stats_ctx; /**< Context transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ -- uint32_t if_num; /**< Interface number. */ --}; -- --/** - * nss_gre_redir_lag_ds_add_sta_msg - * Message to add station in LAG deployment. - */ -@@ -363,26 +320,15 @@ struct nss_gre_redir_lag_ds_msg { - * Downstream statistics. - */ - struct nss_gre_redir_lag_ds_tun_stats { -- uint64_t rx_packets; /**< Received packets. */ -- uint64_t rx_bytes; /**< Received bytes. */ -- uint64_t tx_packets; /**< Transmit packets. */ -- uint64_t tx_bytes; /**< Transmit bytes. */ -- uint64_t rx_dropped[NSS_MAX_NUM_PRI]; -- /**< Packets dropped on receive due to queue full. */ -- uint64_t dst_invalid; /**< Packets that do not have a valid destination. */ -- uint64_t exception_cnt; /**< Packets that are exceptioned to host. */ -- uint32_t ifnum; /**< NSS interface number. */ -- bool valid; /**< Valid flag. */ --}; -- --/** -- * nss_gre_redir_lag_ds_stats_notification -- * GRE redirect LAG downstream transmission statistics structure. -- */ --struct nss_gre_redir_lag_ds_stats_notification { -- struct nss_gre_redir_lag_ds_tun_stats stats_ctx; /**< Context transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ -- uint32_t if_num; /**< Interface number. */ -+ uint64_t rx_packets; /**< Received packets. */ -+ uint64_t rx_bytes; /**< Received bytes. */ -+ uint64_t tx_packets; /**< Transmit packets. */ -+ uint64_t tx_bytes; /**< Transmit bytes. */ -+ uint64_t rx_dropped[NSS_MAX_NUM_PRI]; /**< Packets dropped on receive due to queue full. */ -+ uint64_t dst_invalid; /**< Packets that do not have a valid destination. */ -+ uint64_t exception_cnt; /**< Packets that are exceptioned to host. */ -+ uint32_t ifnum; /**< NSS interface number. */ -+ bool valid; /**< Valid flag. */ - }; - - /** -@@ -622,7 +568,7 @@ extern nss_tx_status_t nss_gre_redir_lag - extern nss_tx_status_t nss_gre_redir_lag_ds_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_ds_msg *ngrm); - - /** -- * nss_gre_redir_lag_us_stats_get -+ * nss_gre_redir_lag_us_get_cmn_stats - * Fetches common node statistics for upstream GRE Redir LAG. - * - * @datatypes -@@ -634,10 +580,10 @@ extern nss_tx_status_t nss_gre_redir_lag - * @return - * True if successful, else false. - */ --extern bool nss_gre_redir_lag_us_stats_get(struct nss_gre_redir_lag_us_tunnel_stats *cmn_stats, uint32_t index); -+extern bool nss_gre_redir_lag_us_get_cmn_stats(struct nss_gre_redir_lag_us_tunnel_stats *cmn_stats, uint32_t index); - - /** -- * nss_gre_redir_lag_ds_stats_get -+ * nss_gre_redir_lag_ds_get_stats - * Fetches common node statistics for downstream GRE Redir LAG. - * - * @datatypes -@@ -649,7 +595,7 @@ extern bool nss_gre_redir_lag_us_stats_g - * @return - * True if successful, else false. - */ --extern bool nss_gre_redir_lag_ds_stats_get(struct nss_gre_redir_lag_ds_tun_stats *cmn_stats, uint32_t index); -+extern bool nss_gre_redir_lag_ds_get_cmn_stats(struct nss_gre_redir_lag_ds_tun_stats *cmn_stats, uint32_t index); - - /** - * nss_gre_redir_lag_us_get_context -@@ -670,62 +616,6 @@ extern struct nss_ctx_instance *nss_gre_ - extern struct nss_ctx_instance *nss_gre_redir_lag_ds_get_context(void); - - /** -- * nss_gre_redir_lag_ds_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_redir_lag_ds_stats_unregister_notifier(struct notifier_block *nb); -- --/** -- * nss_gre_redir_lag_ds_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_redir_lag_ds_stats_register_notifier(struct notifier_block *nb); -- --/** -- * nss_gre_redir_lag_us_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_redir_lag_us_stats_unregister_notifier(struct notifier_block *nb); -- --/** -- * nss_gre_redir_lag_us_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_redir_lag_us_stats_register_notifier(struct notifier_block *nb); -- --/** - * @} - */ - ---- a/exports/nss_gre_redir_mark.h -+++ b/exports/nss_gre_redir_mark.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019, 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. -@@ -25,8 +25,6 @@ - #define NSS_GRE_REDIR_MARK_HLOS_MAGIC 0xaade /**< Metadata magic set by HLOS. */ - #define NSS_GRE_REDIR_MARK_NSS_MAGIC 0xaadf /**< Metadata magic set by NSS. */ - --extern struct nss_gre_redir_mark_stats gre_mark_stats; -- - /** - * nss_gre_redir_mark messages - * Message types for GRE redirect mark requests and responses. -@@ -49,23 +47,6 @@ enum nss_gre_redir_mark_error_types { - }; - - /** -- * nss_gre_redir_mark_stats_types -- * GRE redirect mark statistics types. -- */ --enum nss_gre_redir_mark_stats_types { -- NSS_GRE_REDIR_MARK_STATS_HLOS_MAGIC_FAILED = NSS_STATS_NODE_MAX, -- /**< HLOS magic fail count. */ -- NSS_GRE_REDIR_MARK_STATS_INV_DST_IF_DROPS, /**< Invalid transmit interface drop count. */ -- NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE, /**< Next egress interface enqueue success count. */ -- NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE_DROPS, /**< Next egress interface enqueue drop count. */ -- NSS_GRE_REDIR_MARK_STATS_INV_APPID, /**< Invalid application ID for the transmit completion packets. */ -- NSS_GRE_REDIR_MARK_STATS_HEADROOM_UNAVAILABLE, /**< Packet headroom unavailable to write metadata. */ -- NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_SUCCESS, /**< Transmit completion host enqueue success count. */ -- NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_DROPS, /**< Transmit completion host enqueue drop count. */ -- NSS_GRE_REDIR_MARK_STATS_MAX /**< Maximum statistics type. */ --}; -- --/** - * nss_gre_redir_mark_metadata - * HLOS to NSS per packet downstream metadata. - */ -@@ -74,7 +55,7 @@ struct nss_gre_redir_mark_metadata { - uint8_t wifi_tid; /**< TID value. */ - uint8_t app_id; /**< Application ID. */ - uint16_t hw_hash_idx; /**< Hardware AST hash index value. */ -- uint32_t tx_status; /**< Transmit status. */ -+ uint32_t tx_status; /**< Tx status. */ - uint16_t offset; /**< Buffer offset from the metadata. */ - uint16_t magic; /**< Metadata magic. */ - }; -@@ -86,31 +67,21 @@ struct nss_gre_redir_mark_metadata { - struct nss_gre_redir_mark_stats_sync_msg { - struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - uint32_t hlos_magic_fail; /**< HLOS magic fail count. */ -- uint32_t invalid_dst_drop; /**< Invalid transmit interface drop count. */ -+ uint32_t invalid_dst_drop; /**< Invalid Tx interface drop count. */ - uint32_t dst_enqueue_success; /**< Next egress interface enqueue success count. */ - uint32_t dst_enqueue_drop; /**< Next egress interface enqueue drop count. */ -- uint32_t inv_appid; /**< Invalid application ID for the transmit completion packets. */ -+ uint32_t inv_appid; /**< Invalid application ID for the Tx completion packets. */ - uint32_t headroom_unavail; /**< Packet headroom unavailable to write metadata. */ -- uint32_t tx_completion_success; /**< Transmit completion host enqueue success count. */ -- uint32_t tx_completion_drop; /**< Transmit completion host enqueue drop count. */ -+ uint32_t tx_completion_success; /**< Tx completion host enqueue success count. */ -+ uint32_t tx_completion_drop; /**< Tx completion host enqueue drop count. */ - }; - - /** - * nss_gre_redir_mark_register_cb_msg -- * Transmit completion function register configuration message. -+ * Tx completion function register configuration message. - */ - struct nss_gre_redir_mark_register_cb_msg { -- uint32_t nss_if_num; /**< NSS transmit interface number on which callback needs to be registered. */ --}; -- --/** -- * nss_gre_redir_mark_stats_notification -- * GRE redirect mark transmission statistics structure. -- */ --struct nss_gre_redir_mark_stats_notification { -- uint64_t stats_ctx[NSS_GRE_REDIR_MARK_STATS_MAX]; /**< Context transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ -- uint32_t if_num; /**< Interface number. */ -+ uint32_t nss_if_num; /**< NSS Tx interface number on which callback needs to be registered. */ - }; - - /** -@@ -240,7 +211,7 @@ extern nss_tx_status_t nss_gre_redir_mar - extern nss_tx_status_t nss_gre_redir_mark_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_mark_msg *ngrm); - - /** -- * nss_gre_redir_mark_stats_get -+ * nss_gre_redir_mark_get_stats - * Gets GRE redirect mark statistics. - * - * @datatypes -@@ -252,7 +223,7 @@ extern nss_tx_status_t nss_gre_redir_mar - * @return - * TRUE or FALSE. - */ --extern bool nss_gre_redir_mark_stats_get(struct nss_gre_redir_mark_stats *stats); -+extern bool nss_gre_redir_mark_get_stats(void *stats); - - /** - * nss_gre_redir_alloc_and_register_node -@@ -304,34 +275,6 @@ extern struct dentry *nss_gre_redir_mark - extern struct device *nss_gre_redir_mark_get_device(void); - - /** -- * nss_gre_redir_mark_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_redir_mark_stats_unregister_notifier(struct notifier_block *nb); -- --/** -- * nss_gre_redir_mark_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_redir_mark_stats_register_notifier(struct notifier_block *nb); -- --/** - * @} - */ - ---- a/exports/nss_gre_tunnel.h -+++ b/exports/nss_gre_tunnel.h -@@ -1,6 +1,6 @@ - /* -- **************************************************************************** -- * Copyright (c) 2016-2018, 2020-2021, The Linux Foundation. All rights reserved. -+ ************************************************************************** -+ * Copyright (c) 2016-2018,2020, 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. -@@ -11,7 +11,7 @@ - * 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. -- **************************************************************************** -+ ************************************************************************** - */ - - /** -@@ -98,41 +98,6 @@ enum nss_gre_tunnel_error_types { - }; - - /** -- * nss_gre_tunnel_stats_type -- * GRE tunnel session debug statistic counters. -- */ --enum nss_gre_tunnel_stats_type { -- NSS_GRE_TUNNEL_STATS_SESSION_RX_PKTS, /**< Number of packets received. */ -- NSS_GRE_TUNNEL_STATS_SESSION_TX_PKTS, /**< Number of packets transmitted. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_QUEUE_0_DROPPED, /**< Dropped receive packets 0. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_QUEUE_1_DROPPED, /**< Dropped receive packets 1. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_QUEUE_2_DROPPED, /**< Dropped receive packets 2. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_QUEUE_3_DROPPED, /**< Dropped receive packets 3. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_MALFORMED, /**< Malformed packet was received. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_INVALID_PROT, /**< Invalid protocol was received. */ -- NSS_GRE_TUNNEL_STATS_SESSION_DECAP_QUEUE_FULL, /**< Decapsulation queue is full. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_SINGLE_REC_DGRAM, /**< Single fragment was received. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_INVALID_REC_DGRAM, /**< Invalid fragment was received. */ -- NSS_GRE_TUNNEL_STATS_SESSION_BUFFER_ALLOC_FAIL, /**< Buffer memory allocation failed. */ -- NSS_GRE_TUNNEL_STATS_SESSION_BUFFER_COPY_FAIL, /**< Buffer memory copy failed. */ -- NSS_GRE_TUNNEL_STATS_SESSION_OUTFLOW_QUEUE_FULL, /**< Outflow queue is full. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_DROPPED_HROOM, /**< Packets dropped because of insufficent headroom. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_CBUFFER_ALLOC_FAIL, /**< Receive crypto buffer allocation failed. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_CENQUEUE_FAIL, /**< Receive enqueue-to-crypto failed. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_DECRYPT_DONE, /**< Receive decryption is complete. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_FORWARD_ENQUEUE_FAIL, /**< Receive forward enqueue failed. */ -- NSS_GRE_TUNNEL_STATS_SESSION_TX_CBUFFER_ALLOC_FAIL, /**< Receive crypto buffer allocation failed. */ -- NSS_GRE_TUNNEL_STATS_SESSION_TX_CENQUEUE_FAIL, /**< Transmit enqueue-to-crypto failed. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_DROPPED_TROOM, /**< Packets dropped because of insufficent tailroom. */ -- NSS_GRE_TUNNEL_STATS_SESSION_TX_FORWARD_ENQUEUE_FAIL, /**< Transmit forward enqueue failed. */ -- NSS_GRE_TUNNEL_STATS_SESSION_TX_CIPHER_DONE, /**< Transmit cipher is complete. */ -- NSS_GRE_TUNNEL_STATS_SESSION_CRYPTO_NOSUPP, /**< Error count for non-supported crypto packets. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_DROPPED_MH_VERSION, /**< Receive drop: bad meta header. */ -- NSS_GRE_TUNNEL_STATS_SESSION_RX_UNALIGNED_PKT, /**< Counter for unaligned packets. */ -- NSS_GRE_TUNNEL_STATS_SESSION_MAX, /**< Maximum statistics type. */ --}; -- --/** - * nss_gre_tunnel_di_to_wlan_id - * Dynamic interface to WLAN ID message structure. - */ -@@ -186,20 +151,20 @@ struct nss_gre_tunnel_stats { - uint32_t rx_dropped_hroom; - /**< Packets dropped because of insufficent headroom. */ - uint32_t rx_cbuf_alloc_fail; -- /**< Receive crypto buffer allocation failed. */ -- uint32_t rx_cenqueue_fail; /**< Receive enqueue-to-crypto failed. */ -- uint32_t rx_decrypt_done; /**< Receive decryption is complete. */ -- uint32_t rx_forward_enqueue_fail; /**< Receive forward enqueue failed. */ -+ /**< Rx crypto buffer allocation failed. */ -+ uint32_t rx_cenqueue_fail; /**< Rx enqueue-to-crypto failed. */ -+ uint32_t rx_decrypt_done; /**< Rx decryption is complete. */ -+ uint32_t rx_forward_enqueue_fail; /**< Rx forward enqueue failed. */ - uint32_t tx_cbuf_alloc_fail; -- /**< Receive crypto buffer allocation failed. */ -- uint32_t tx_cenqueue_fail; /**< Transmit enqueue-to-crypto failed. */ -+ /**< Rx crypto buffer allocation failed. */ -+ uint32_t tx_cenqueue_fail; /**< Tx enqueue-to-crypto failed. */ - uint32_t rx_dropped_troom; - /**< Packets dropped because of insufficent tailroom. */ -- uint32_t tx_forward_enqueue_fail; /**< Transmit forward enqueue failed. */ -- uint32_t tx_cipher_done; /**< Transmit cipher is complete. */ -+ uint32_t tx_forward_enqueue_fail; /**< Tx forward enqueue failed. */ -+ uint32_t tx_cipher_done; /**< Tx cipher is complete. */ - uint32_t crypto_nosupp; - /**< Error count for non-supported crypto packets. */ -- uint32_t rx_dropped_mh_ver; /**< Receive drop: bad meta header. */ -+ uint32_t rx_dropped_mh_ver; /**< Rx drop: bad meta header. */ - uint32_t rx_unaligned_pkt; /**< Counter for unaligned packets. */ - #if defined(NSS_HAL_IPQ807x_SUPPORT) - uint32_t crypto_resp_error[NSS_CRYPTO_CMN_RESP_ERROR_MAX]; -@@ -208,17 +173,6 @@ struct nss_gre_tunnel_stats { - }; - - /** -- * nss_gre_tunnel_stats_notification -- * GRE tunnel transmission statistics structure. -- */ --struct nss_gre_tunnel_stats_notification { -- uint64_t stats_ctx[NSS_GRE_TUNNEL_STATS_SESSION_MAX + NSS_CRYPTO_CMN_RESP_ERROR_MAX]; -- /**< Context transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ -- uint32_t if_num; /**< Interface number. */ --}; -- --/** - * nss_gre_tunnel_msg - * Data for sending and receiving GRE tunnel messages. - */ -@@ -394,34 +348,6 @@ extern nss_tx_status_t nss_gre_tunnel_in - nss_gre_tunnel_msg_callback_t cb, void *app_data); - - /** -- * nss_gre_tunnel_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_tunnel_stats_unregister_notifier(struct notifier_block *nb); -- --/** -- * nss_gre_tunnel_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_gre_tunnel_stats_register_notifier(struct notifier_block *nb); -- --/** - * @} - */ - ---- a/exports/nss_if.h -+++ b/exports/nss_if.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2020, 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. -@@ -53,8 +53,6 @@ enum nss_if_message_types { - NSS_IF_SET_IGS_NODE, - NSS_IF_CLEAR_IGS_NODE, - NSS_IF_RESET_NEXTHOP, -- NSS_IF_PPE_PORT_CREATE, -- NSS_IF_PPE_PORT_DESTROY, - NSS_IF_MAX_MSG_TYPES = 9999, - }; - -@@ -200,14 +198,6 @@ struct nss_if_igs_config { - }; - - /** -- * nss_if_ppe_port_create -- * Message to create PPE port. -- */ --struct nss_if_ppe_port_create { -- int32_t ppe_port_num; /**< PPE port number returned by NSS. */ --}; -- --/** - * nss_if_msgs - * Information for physical NSS interface command messages. - */ -@@ -240,8 +230,6 @@ union nss_if_msgs { - /**< Set nexthop of interface. */ - struct nss_if_igs_config config_igs; - /**< Configure an ingress shaper interface. */ -- struct nss_if_ppe_port_create ppe_port_create; -- /**< Create a PPE port. */ - }; - - /** -@@ -321,23 +309,6 @@ extern struct nss_ctx_instance *nss_if_r - extern nss_tx_status_t nss_if_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num); - - /** -- * nss_if_tx_msg_with_size -- * Sends a message to the NSS interface. -- * -- * @datatypes -- * nss_ctx_instance \n -- * nss_if_msg -- * -- * @param[in,out] nss_ctx Pointer to the NSS context. -- * @param[in] nim Pointer to the NSS interface message. -- * @param[in] size Total message buffer size. -- * -- * @return -- * Status of the Tx operation. -- */ --nss_tx_status_t nss_if_tx_msg_with_size(struct nss_ctx_instance *nss_ctx, struct nss_if_msg *nim, uint32_t size); -- --/** - * nss_if_tx_msg - * Sends a message to the NSS interface. - * -@@ -355,7 +326,7 @@ nss_tx_status_t nss_if_tx_msg(struct nss - - /** - * nss_if_msg_sync -- * Sends a message to the NSS interface and waits for the response. -+ * Sends a message to the NSS interface and wait for the response. - * - * @datatypes - * nss_ctx_instance \n -@@ -401,70 +372,6 @@ nss_tx_status_t nss_if_set_nexthop(struc - nss_tx_status_t nss_if_reset_nexthop(struct nss_ctx_instance *nss_ctx, uint32_t if_num); - - /** -- * nss_if_change_mtu -- * Changes the MTU of the interface. -- * -- * @datatypes -- * nss_ctx_instance -- * -- * @param[in] nss_ctx Pointer to the NSS context. -- * @param[in] if_num NSS interface number. -- * @param[in] mtu New MTU. -- * -- * @return -- * Status of the transmit operation. -- */ --nss_tx_status_t nss_if_change_mtu(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num, uint16_t mtu); -- --/** -- * nss_if_change_mac_addr -- * Changes the MAC address of the interface. -- * -- * @datatypes -- * nss_ctx_instance -- * -- * @param[in] nss_ctx Pointer to the NSS context. -- * @param[in] if_num NSS interface number. -- * @param[in] mac_addr New MAC address. -- * -- * @return -- * Status of the transmit operation. -- */ --nss_tx_status_t nss_if_change_mac_addr(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num, uint8_t *mac_addr); -- --/** -- * nss_if_vsi_unassign -- * Detaches the VSI ID from the given interface. -- * -- * @datatypes -- * nss_ctx_instance -- * -- * @param[in] nss_ctx Pointer to the NSS context. -- * @param[in] if_num NSS interface number. -- * @param[in] vsi VSI ID. -- * -- * @return -- * Status of the transmit operation. -- */ --nss_tx_status_t nss_if_vsi_unassign(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num, uint32_t vsi); -- --/** -- * nss_if_vsi_assign -- * Attaches the VSI ID to the given interface. -- * -- * @datatypes -- * nss_ctx_instance -- * -- * @param[in] nss_ctx Pointer to the NSS context. -- * @param[in] if_num NSS interface number. -- * @param[in] vsi VSI ID. -- * -- * @return -- * Status of the transmit operation. -- */ --nss_tx_status_t nss_if_vsi_assign(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num, uint32_t vsi); -- --/** - * @} - */ - ---- a/exports/nss_ipsec_cmn.h -+++ b/exports/nss_ipsec_cmn.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2018-2020, 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. -@@ -107,37 +107,6 @@ enum nss_ipsec_cmn_ctx_type { - }; - - /** -- * nss_ipsec_cmn_stats_types -- * IPsec common statistics types. -- */ --enum nss_ipsec_cmn_stats_types { -- NSS_IPSEC_CMN_STATS_FAIL_HEADROOM = NSS_STATS_NODE_MAX, -- /**< Failure in headroom check. */ -- NSS_IPSEC_CMN_STATS_FAIL_TAILROOM, /**< Failure in tailroom check. */ -- NSS_IPSEC_CMN_STATS_FAIL_REPLAY, /**< Failure in anti-replay check. */ -- NSS_IPSEC_CMN_STATS_FAIL_REPLAY_DUP, /**< Failure in anti-replay; duplicate records. */ -- NSS_IPSEC_CMN_STATS_FAIL_REPLAY_WIN, /**< Failure in anti-replay; packet outside the window. */ -- NSS_IPSEC_CMN_STATS_FAIL_PBUF_CRYPTO, /**< Failure in crypto pbuf allocation. */ -- NSS_IPSEC_CMN_STATS_FAIL_QUEUE, /**< Failure due to queue full in IPsec. */ -- NSS_IPSEC_CMN_STATS_FAIL_QUEUE_CRYPTO, /**< Failure due to queue full in crypto. */ -- NSS_IPSEC_CMN_STATS_FAIL_QUEUE_NEXTHOP, /**< Failure due to queue full in next hop. */ -- NSS_IPSEC_CMN_STATS_FAIL_PBUF_ALLOC, /**< Failure in pbuf allocation. */ -- NSS_IPSEC_CMN_STATS_FAIL_PBUF_LINEAR, /**< Failure in pbuf linearization. */ -- NSS_IPSEC_CMN_STATS_FAIL_PBUF_STATS, /**< Failure in pbuf allocation for statistics. */ -- NSS_IPSEC_CMN_STATS_FAIL_PBUF_ALIGN, /**< Failure in pbuf access due to non-word alignmnt */ -- NSS_IPSEC_CMN_STATS_FAIL_CIPHER, /**< Failure in decrypting the data. */ -- NSS_IPSEC_CMN_STATS_FAIL_AUTH, /**< Failure in authenticating the data. */ -- NSS_IPSEC_CMN_STATS_FAIL_SEQ_OVF, /**< Failure due to sequence number rollover. */ -- NSS_IPSEC_CMN_STATS_FAIL_BLK_LEN, /**< Failure in decapsulation due to bad cipher block length. */ -- NSS_IPSEC_CMN_STATS_FAIL_HASH_LEN, /**< Failure in decapsulation due to bad hash block length. */ -- NSS_IPSEC_CMN_STATS_FAIL_TRANSFORM, /**< Failure in transformation; general error. */ -- NSS_IPSEC_CMN_STATS_FAIL_CRYPTO, /**< Failure in crypto transformation. */ -- NSS_IPSEC_CMN_STATS_FAIL_CLE, /**< Failure in classification; general failure. */ -- NSS_IPSEC_CMN_STATS_IS_STOPPED, /**< Indicates if SA is stopped; for example: sequence overflow. */ -- NSS_IPSEC_CMN_STATS_MAX, /**< Maximum statistics type. */ --}; -- --/** - * nss_ipsec_cmn_flow_tuple - * IPsec tuple for creating flow entries. - * -@@ -227,7 +196,6 @@ struct nss_ipsec_cmn_sa { - struct nss_ipsec_cmn_ctx { - enum nss_ipsec_cmn_ctx_type type; /**< Node type. */ - uint32_t except_ifnum; /**< Exception interface for egress. */ -- uint32_t sibling_ifnum; /**< Sibling interface. */ - }; - - /** -@@ -269,7 +237,7 @@ struct nss_ipsec_cmn_sa_stats { - uint32_t fail_pbuf_alloc; /**< Failure in pbuf allocation. */ - uint32_t fail_pbuf_linear; /**< Failure in pbuf linearization. */ - uint32_t fail_pbuf_stats; /**< Failure in pbuf allocation for statistics. */ -- uint32_t fail_pbuf_align; /**< Failure in pbuf access due to non-word alignment. */ -+ uint32_t fail_pbuf_align; /**< Failure in pbuf access due non-word alignment. */ - uint32_t fail_cipher; /**< Failure in decrypting the data. */ - uint32_t fail_auth; /**< Failure in authenticating the data. */ - uint32_t fail_seq_ovf; /**< Failure due to sequence number rollover. */ -@@ -278,7 +246,6 @@ struct nss_ipsec_cmn_sa_stats { - uint32_t fail_transform; /**< Failure in transformation; general error. */ - uint32_t fail_crypto; /**< Failure in crypto transformation. */ - uint32_t fail_cle; /**< Failure in classification; general failure. */ -- uint32_t is_stopped; /**< Indicates if SA is stopped; for example, sequence overflow. */ - }; - - /** -@@ -301,7 +268,6 @@ struct nss_ipsec_cmn_ctx_stats { - uint32_t exceptioned; /**< Exceptioned to host. */ - uint32_t linearized; /**< Linearized packets. */ - uint32_t redirected; /**< Redirected from inline. */ -- uint32_t dropped; /**< Total dropped packets. */ - uint32_t fail_sa; /**< Failed to find SA. */ - uint32_t fail_flow; /**< Failed to find flow. */ - uint32_t fail_stats; /**< Failed to send statistics. */ -@@ -309,9 +275,6 @@ struct nss_ipsec_cmn_ctx_stats { - uint32_t fail_transform; /**< Failed to produce output. */ - uint32_t fail_linearized; /**< Failed to linearize. */ - uint32_t fail_mdata_ver; /**< Invalid metadata version. */ -- uint32_t fail_ctx_active; /**< Failed to queue as context is not active. */ -- uint32_t fail_pbuf_crypto; /**< Failed to allocate pbuf for crypto operation. */ -- uint32_t fail_queue_crypto; /**< Failed to queue pbuf to crypto pnode. */ - }; - - /** -@@ -368,16 +331,6 @@ struct nss_ipsec_cmn_mdata { - }; - - /** -- * nss_ipsec_cmn_stats_notification -- * IPsec common transmission statistics structure. -- */ --struct nss_ipsec_cmn_stats_notification { -- uint64_t stats_ctx[NSS_IPSEC_CMN_STATS_MAX]; /**< Context transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ -- uint32_t if_num; /**< Interface number. */ --}; -- --/** - * nss_ipsec_cmn_msg - * Message structure for NSS IPsec messages. - */ -@@ -466,23 +419,6 @@ extern struct nss_ctx_instance *nss_ipse - extern uint32_t nss_ipsec_cmn_get_ifnum_with_coreid(int32_t ifnum); - - /** -- * nss_ipsec_cmn_unregister_if -- * Deregisters an IPSEC tunnel interface from the NSS. -- * -- * @param[in] if_num NSS interface number. -- * -- * @return -- * None. -- * -- * @dependencies -- * The tunnel interface must have been previously registered. -- * -- * @return -- * True if successful, else false. -- */ --extern bool nss_ipsec_cmn_unregister_if(uint32_t if_num); -- --/** - * nss_ipsec_cmn_register_if - * Registers the IPsec interface with the NSS for sending and - * receiving messages. -@@ -510,26 +446,25 @@ extern struct nss_ctx_instance *nss_ipse - uint32_t features, enum nss_dynamic_interface_type type, void *app_data); - - /** -- * nss_ipsec_cmn_notify_unregister -- * Deregisters the message notifier from the HLOS driver. -- * -- * @datatypes -- * nss_ctx_instance -- * -- * @param[in,out] ctx Pointer to the context of the HLOS driver. -- * @param[in] if_num NSS interface number. -+ * nss_ipsec_cmn_unregister_if -+ * Deregisters a IPSEC tunnel interface from the NSS. - * -+ * @param[in] if_num NSS interface number. -+. * - * @return - * None. - * - * @dependencies -- * The message notifier must have been previously registered. -+ * The tunnel interface must have been previously registered. -+ * -+ * @return -+ * True if successful, else false. - */ --extern void nss_ipsec_cmn_notify_unregister(struct nss_ctx_instance *ctx, uint32_t if_num); -+extern bool nss_ipsec_cmn_unregister_if(uint32_t if_num); - - /** - * nss_ipsec_cmn_notify_register -- * Registers an event callback to handle notifications from the IPsec firmware package. -+ * Register an event callback to handle notification from IPsec firmware package. - * - * @datatypes - * nss_ipsec_cmn_msg_callback_t \n -@@ -539,11 +474,29 @@ extern void nss_ipsec_cmn_notify_unregis - * @param[in] app_data Pointer to the application context. - * - * @return -- * Pointer to the NSS core context. -+ * Pointer to NSS core context. - */ - extern struct nss_ctx_instance *nss_ipsec_cmn_notify_register(uint32_t ifnum, nss_ipsec_cmn_msg_callback_t cb, void *app_data); - - /** -+ * nss_ipsec_cmn_notify_unregister -+ * Deregisters the message notifier from the HLOS driver. -+ * -+ * @datatypes -+ * nss_ctx_instance -+ * -+ * @param[in,out] ctx Pointer to the context of the HLOS driver. -+ * @param[in] if_num NSS interface number. -+ * -+ * @return -+ * None. -+ * -+ * @dependencies -+ * The message notifier must have been previously registered. -+ */ -+extern void nss_ipsec_cmn_notify_unregister(struct nss_ctx_instance *ctx, uint32_t if_num); -+ -+/** - * nss_ipsec_cmn_msg_init - * Initializes an IPsec message. - * -@@ -657,34 +610,6 @@ extern bool nss_ipsec_cmn_ppe_port_confi - bool nss_ipsec_cmn_ppe_mtu_update(struct nss_ctx_instance *ctx, uint32_t if_num, uint16_t mtu, uint16_t mru); - - /** -- * nss_ipsec_cmn_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_ipsec_cmn_stats_unregister_notifier(struct notifier_block *nb); -- --/** -- * nss_ipsec_cmn_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_ipsec_cmn_stats_register_notifier(struct notifier_block *nb); -- --/** - * @} - */ - ---- a/exports/nss_ipv4.h -+++ b/exports/nss_ipv4.h -@@ -1,12 +1,9 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2014-2020, 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 -@@ -29,116 +26,13 @@ - #include "nss_stats_public.h" - #endif - -+#include "nss_fw_version.h" -+ - /** - * @addtogroup nss_ipv4_subsystem - * @{ - */ - --/* -- * IPv4 connection flags (to be used with nss_ipv4_create::flags). -- */ --#define NSS_IPV4_CREATE_FLAG_NO_SEQ_CHECK 0x01 -- /**< Rule for not checking sequence numbers. */ --#define NSS_IPV4_CREATE_FLAG_BRIDGE_FLOW 0x02 -- /**< Rule that indicates pure bridge flow (no routing is involved). */ --#define NSS_IPV4_CREATE_FLAG_ROUTED 0x04 /**< Rule for a routed connection. */ -- --#define NSS_IPV4_CREATE_FLAG_DSCP_MARKING 0x08 /**< Rule for DSCP marking. */ --#define NSS_IPV4_CREATE_FLAG_VLAN_MARKING 0x10 /**< Rule for VLAN marking. */ --#define NSS_IPV4_CREATE_FLAG_QOS_VALID 0x20 /**< Rule for QoS is valid. */ -- --/** -- * nss_ipv4_create -- * Information for an IPv4 flow or connection create rule. -- * -- * All fields must be passed in host-endian order. -- */ --struct nss_ipv4_create { -- int32_t src_interface_num; -- /**< Source interface number (virtual or physical). */ -- int32_t dest_interface_num; -- /**< Destination interface number (virtual or physical). */ -- int32_t protocol; /**< L4 protocol, e.g., TCP or UDP. */ -- uint32_t flags; /**< Flags associated with this rule. */ -- uint32_t from_mtu; /**< MTU of the incoming interface. */ -- uint32_t to_mtu; /**< MTU of the outgoing interface. */ -- uint32_t src_ip; /**< Source IP address. */ -- int32_t src_port; /**< Source L4 port, e.g., TCP or UDP port. */ -- uint32_t src_ip_xlate; /**< Translated source IP address (used with SNAT). */ -- int32_t src_port_xlate; /**< Translated source L4 port (used with SNAT). */ -- uint32_t dest_ip; /**< Destination IP address. */ -- int32_t dest_port; /**< Destination L4 port, e.g., TCP or UDP port. */ -- uint32_t dest_ip_xlate; -- /**< Translated destination IP address (used with DNAT). */ -- int32_t dest_port_xlate; -- /**< Translated destination L4 port (used with DNAT). */ -- uint8_t src_mac[ETH_ALEN]; -- /**< Source MAC address. */ -- uint8_t dest_mac[ETH_ALEN]; -- /**< Destination MAC address. */ -- uint8_t src_mac_xlate[ETH_ALEN]; -- /**< Translated source MAC address (post-routing). */ -- uint8_t dest_mac_xlate[ETH_ALEN]; -- /**< Translated destination MAC address (post-routing). */ -- uint8_t flow_window_scale; /**< Window scaling factor (TCP). */ -- uint32_t flow_max_window; /**< Maximum window size (TCP). */ -- uint32_t flow_end; /**< TCP window end. */ -- uint32_t flow_max_end; /**< TCP window maximum end. */ -- uint32_t flow_pppoe_if_exist; -- /**< Flow direction: PPPoE interface existence flag. */ -- int32_t flow_pppoe_if_num; -- /**< Flow direction: PPPoE interface number. */ -- uint16_t ingress_vlan_tag; /**< Ingress VLAN tag expected for this flow. */ -- uint8_t return_window_scale; -- /**< Window scaling factor of the return direction (TCP). */ -- uint32_t return_max_window; -- /**< Maximum window size of the return direction. */ -- uint32_t return_end; -- /**< Flow end for the return direction. */ -- uint32_t return_max_end; -- /**< Flow maximum end for the return direction. */ -- uint32_t return_pppoe_if_exist; -- /**< Return direction: PPPoE interface existence flag. */ -- int32_t return_pppoe_if_num; -- /**< Return direction: PPPoE interface number. */ -- uint16_t egress_vlan_tag; /**< Egress VLAN tag expected for this flow. */ -- uint8_t spo_needed; /**< Indicates whether SPO is required. */ -- struct net_device *top_ndev; /**< Netdevice associated with the top interface. */ -- uint32_t param_a1; /**< Custom parameter 1. */ -- uint32_t param_a2; /**< Custom parameter 2. */ -- uint32_t param_a3; /**< Custom parameter 3. */ -- uint32_t param_a4; /**< Custom parameter 4. */ -- uint32_t qos_tag; /**< Deprecated, will be removed soon. */ -- uint32_t flow_qos_tag; /**< QoS tag value for the flow direction. */ -- uint32_t return_qos_tag; /**< QoS tag value for the return direction. */ -- uint8_t dscp_itag; /**< DSCP marking tag. */ -- uint8_t dscp_imask; /**< DSCP marking input mask. */ -- uint8_t dscp_omask; /**< DSCP marking output mask. */ -- uint8_t dscp_oval; /**< DSCP marking output value. */ -- uint16_t vlan_itag; /**< VLAN marking tag. */ -- uint16_t vlan_imask; /**< VLAN marking input mask. */ -- uint16_t vlan_omask; /**< VLAN marking output mask. */ -- uint16_t vlan_oval; /**< VLAN marking output value. */ -- uint32_t in_vlan_tag[MAX_VLAN_DEPTH]; -- /**< Ingress VLAN tag expected for this flow. */ -- uint32_t out_vlan_tag[MAX_VLAN_DEPTH]; -- /**< Egress VLAN tag expected for this flow. */ -- uint8_t flow_dscp; /**< IP DSCP value for the flow direction. */ -- uint8_t return_dscp; /**< IP DSCP value for the return direction. */ --}; -- --/** -- * nss_ipv4_destroy -- * Information for an IPv4 flow or connection destroy rule. -- */ --struct nss_ipv4_destroy { -- int32_t protocol; /**< L4 protocol ID. */ -- uint32_t src_ip; /**< Source IP address. */ -- int32_t src_port; /**< Source L4 port, e.g., TCP or UDP port. */ -- uint32_t dest_ip; /**< Destination IP address. */ -- int32_t dest_port; /**< Destination L4 port, e.g., TCP or UDP port. */ --}; -- - /** - * nss_ipv4_message_types - * IPv4 bridge and routing rule message types. -@@ -219,12 +113,6 @@ enum nss_ipv4_stats_types { - /**< Number of IPv4 multicast connection destroy requests that missed the cache. */ - NSS_IPV4_STATS_MC_CONNECTION_FLUSHES, - /**< Number of IPv4 multicast connection flushes. */ -- NSS_IPV4_STATS_CONNECTION_CREATE_INVALID_MIRROR_IFNUM, -- /**< Number of IPv4 mirror connection requests with an invalid interface number. */ -- NSS_IPV4_STATS_CONNECTION_CREATE_INVALID_MIRROR_IFTYPE, -- /**< Number of IPv4 mirror connection requests with an invalid interface type. */ -- NSS_IPV4_STATS_MIRROR_FAILURES, -- /**< Number of IPv4 mirror failures. */ - NSS_IPV4_STATS_MAX, - /**< Maximum message type. */ - }; -@@ -252,18 +140,17 @@ enum nss_ipv4_stats_types { - * carries an IPv4 payload within it. - */ - #define NSS_IPV4_RULE_CREATE_FLAG_L2_ENCAP 0x80 -+ - #define NSS_IPV4_RULE_CREATE_FLAG_DROP 0x100 - /**< Rule to drop packets. */ - #define NSS_IPV4_RULE_CREATE_FLAG_EXCEPTION 0x200 - /**< Rule to except packets. */ -+ - #define NSS_IPV4_RULE_CREATE_FLAG_SRC_INTERFACE_CHECK 0x400 - /**< Check the source interface for the rule. */ -+ - #define NSS_IPV4_RULE_CREATE_FLAG_NO_SRC_IDENT 0x800 - /**< Zero out the source identifier for the rule. */ --#define NSS_IPV4_RULE_CREATE_FLAG_NO_MAC 0x1000 -- /**< Flag to bypass writing MAC addresses. */ --#define NSS_IPV4_RULE_CREATE_FLAG_EMESH_SP 0x2000 -- /**< Mark rule as E-MESH Service Prioritization valid. */ - - /* - * Validity flags for rule creation. -@@ -287,16 +174,11 @@ enum nss_ipv4_stats_types { - /**< Destination MAC address fields are valid. */ - #define NSS_IPV4_RULE_CREATE_IGS_VALID 0x800 - /**< Ingress shaping fields are valid. */ --#define NSS_IPV4_RULE_CREATE_IDENTIFIER_VALID 0x1000 -- /**< Identifier is valid. */ --#define NSS_IPV4_RULE_CREATE_MIRROR_VALID 0x2000 /**< Mirror fields are valid. */ - - /* - * Multicast command rule flags - */ - #define NSS_IPV4_MC_RULE_CREATE_FLAG_MC_UPDATE 0x01 /**< Multicast rule update. */ --#define NSS_IPV4_MC_RULE_CREATE_FLAG_MC_EMESH_SP 0x02 -- /**< Mark multicast rule as E-MESH Service Prioritization valid. */ - - /* - * Multicast command validity flags -@@ -344,23 +226,6 @@ enum nss_ipv4_stats_types { - #define NSS_IPV4_SRC_MAC_RETURN_VALID 0x02 - /**< MAC address for the return interface is valid. */ - --/* -- * Identifier valid flags (to be used with identifier_valid_flags field of nss_ipv4_identifier_rule structure) -- */ --#define NSS_IPV4_FLOW_IDENTIFIER_VALID 0x01 -- /**< Identifier for flow direction is valid. */ --#define NSS_IPV4_RETURN_IDENTIFIER_VALID 0x02 -- /**< Identifier for return direction is valid. */ -- --/* -- * Mirror valid flags (to be used with the valid field of nss_ipv4_mirror_rule structure) -- */ --#define NSS_IPV4_MIRROR_FLOW_VALID 0x01 -- /**< Mirror interface number for the flow direction is valid. */ --#define NSS_IPV4_MIRROR_RETURN_VALID 0x02 -- /**< Mirror interface number for the return direction is valid. */ -- -- - /** - * nss_ipv4_5tuple - * Common 5-tuple information. -@@ -522,29 +387,6 @@ struct nss_ipv4_rps_rule { - }; - - /** -- * nss_ipv4_identifier_rule -- * Identifier rule structure. -- */ --struct nss_ipv4_identifier_rule { -- uint32_t identifier_valid_flags; -- /**< Identifier validity flags. */ -- uint32_t flow_identifier; -- /**< Identifier for flow direction. */ -- uint32_t return_identifier; -- /**< Identifier for return direction. */ --}; -- --/** -- * nss_ipv4_mirror_rule -- * Mirror rule structure. -- */ --struct nss_ipv4_mirror_rule { -- uint32_t valid; /**< Mirror validity flags. */ -- nss_if_num_t flow_ifnum; /**< Flow mirror interface number. */ -- nss_if_num_t return_ifnum; /**< Return mirror interface number. */ --}; -- --/** - * nss_ipv4_error_response_types - * Error types for IPv4 messages. - */ -@@ -569,8 +411,6 @@ enum nss_ipv4_error_response_types { - NSS_IPV4_CR_HASH_BITMAP_INVALID, - NSS_IPV4_DR_HW_DECEL_FAIL_ERROR, - NSS_IPV4_CR_RETURN_EXIST_ERROR, -- NSS_IPV4_CR_INVALID_IDENTIFIER, -- NSS_IPV4_CR_EMESH_SP_CONFIG_INVALID, - NSS_IPV4_LAST - }; - -@@ -610,10 +450,6 @@ struct nss_ipv4_rule_create_msg { - /**< RPS parameter. */ - struct nss_ipv4_igs_rule igs_rule; - /**< Ingress shaping related accleration parameters. */ -- struct nss_ipv4_identifier_rule identifier; -- /**< Rule for adding identifier. */ -- struct nss_ipv4_mirror_rule mirror_rule; -- /**< Mirror rule parameter. */ - }; - - /** -@@ -900,10 +736,10 @@ enum nss_ipv4_exception_events { - NSS_IPV4_EXCEPTION_EVENT_MC_PBUF_ALLOC_FAILURE, - NSS_IPV4_EXCEPTION_EVENT_PPPOE_BRIDGE_NO_ICME, - NSS_IPV4_EXCEPTION_EVENT_PPPOE_NO_SESSION, -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - NSS_IPV4_EXCEPTION_EVENT_ICMP_IPV4_GRE_HEADER_INCOMPLETE, - NSS_IPV4_EXCEPTION_EVENT_ICMP_IPV4_ESP_HEADER_INCOMPLETE, -- NSS_IPV4_EXCEPTION_EVENT_EMESH_PRIO_MISMATCH, -- NSS_IPV4_EXCEPTION_EVENT_MC_UCAST_DMAC, -+#endif - NSS_IPV4_EXCEPTION_EVENT_MAX - }; - -@@ -958,16 +794,6 @@ struct nss_ipv4_node_sync { - - uint32_t ipv4_mc_connection_flushes; - /**< Number of multicast connection flushes. */ -- -- uint32_t ipv4_connection_create_invalid_mirror_ifnum; -- /**< Number of failed create requests with an invalid mirror interface number. */ -- -- uint32_t ipv4_connection_create_invalid_mirror_iftype; -- /**< Number of failed create requests with an invalid mirror interface type. */ -- -- uint32_t ipv4_mirror_failures; -- /**< Mirror packet failed. */ -- - uint32_t exception_events[NSS_IPV4_EXCEPTION_EVENT_MAX]; - /**< Number of exception events. */ - }; ---- a/exports/nss_ipv6.h -+++ b/exports/nss_ipv6.h -@@ -1,12 +1,9 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2014-2020, 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 -@@ -31,126 +28,6 @@ - */ - - /** -- * Converts the format of an IPv6 address from Linux to NSS. @hideinitializer -- */ --#define IN6_ADDR_TO_IPV6_ADDR(ipv6, in6) \ -- { \ -- ((uint32_t *)ipv6)[0] = in6.in6_u.u6_addr32[0]; \ -- ((uint32_t *)ipv6)[1] = in6.in6_u.u6_addr32[1]; \ -- ((uint32_t *)ipv6)[2] = in6.in6_u.u6_addr32[2]; \ -- ((uint32_t *)ipv6)[3] = in6.in6_u.u6_addr32[3]; \ -- } -- --/** -- * Converts the format of an IPv6 address from NSS to Linux. @hideinitializer -- */ --#define IPV6_ADDR_TO_IN6_ADDR(in6, ipv6) \ -- { \ -- in6.in6_u.u6_addr32[0] = ((uint32_t *)ipv6)[0]; \ -- in6.in6_u.u6_addr32[1] = ((uint32_t *)ipv6)[1]; \ -- in6.in6_u.u6_addr32[2] = ((uint32_t *)ipv6)[2]; \ -- in6.in6_u.u6_addr32[3] = ((uint32_t *)ipv6)[3]; \ -- } -- --/** -- * Format of an IPv6 address (16 * 8 bits). -- */ --#define IPV6_ADDR_OCTAL_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x" -- --/** -- * Prints an IPv6 address (16 * 8 bits). -- */ --#define IPV6_ADDR_TO_OCTAL(ipv6) ((uint16_t *)ipv6)[0], ((uint16_t *)ipv6)[1], ((uint16_t *)ipv6)[2], ((uint16_t *)ipv6)[3], ((uint16_t *)ipv6)[4], ((uint16_t *)ipv6)[5], ((uint16_t *)ipv6)[6], ((uint16_t *)ipv6)[7] -- --/* -- * IPv6 connection flags (to be used with nss_ipv6_create::flags. -- */ --#define NSS_IPV6_CREATE_FLAG_NO_SEQ_CHECK 0x1 -- /**< Indicates that sequence numbers are not to be checked. */ --#define NSS_IPV6_CREATE_FLAG_BRIDGE_FLOW 0x02 -- /**< Indicates that this is a pure bridge flow (no routing is involved). */ --#define NSS_IPV6_CREATE_FLAG_ROUTED 0x04 /**< Rule is for a routed connection. */ --#define NSS_IPV6_CREATE_FLAG_DSCP_MARKING 0x08 /**< Rule for DSCP marking. */ --#define NSS_IPV6_CREATE_FLAG_VLAN_MARKING 0x10 /**< Rule for VLAN marking. */ --#define NSS_IPV6_CREATE_FLAG_QOS_VALID 0x20 /**< Rule for Valid QoS. */ -- --/** -- * nss_ipv6_create -- * Information for an IPv6 flow or connection create rule. -- * -- * All fields must be passed in host-endian order. -- */ --struct nss_ipv6_create { -- int32_t src_interface_num; -- /**< Source interface number (virtual or physical). */ -- int32_t dest_interface_num; -- /**< Destination interface number (virtual or physical). */ -- int32_t protocol; /**< L4 protocol, e.g., TCP or UDP,. */ -- uint32_t flags; /**< Flags associated with this rule. */ -- uint32_t from_mtu; /**< MTU of the incoming interface. */ -- uint32_t to_mtu; /**< MTU of the outgoing interface. */ -- uint32_t src_ip[4]; /**< Source IP address. */ -- int32_t src_port; /**< Source L4 port, e.g., TCP or UDP port. */ -- uint32_t dest_ip[4]; /**< Destination IP address. */ -- int32_t dest_port; /**< Destination L4 port, e.g., TCP or UDP port. */ -- uint8_t src_mac[ETH_ALEN]; /**< Source MAC address. */ -- uint8_t dest_mac[ETH_ALEN]; /**< Destination MAC address. */ -- uint8_t flow_window_scale; /**< Window scaling factor (TCP). */ -- uint32_t flow_max_window; /**< Maximum window size (TCP). */ -- uint32_t flow_end; /**< TCP window end. */ -- uint32_t flow_max_end; /**< TCP window maximum end. */ -- uint32_t flow_pppoe_if_exist; -- /**< Flow direction: PPPoE interface existence flag. */ -- int32_t flow_pppoe_if_num; -- /**< Flow direction: PPPoE interface number. */ -- uint16_t ingress_vlan_tag; -- /**< Ingress VLAN tag expected for this flow. */ -- uint8_t return_window_scale; -- /**< Window scaling factor (TCP) for the return direction. */ -- uint32_t return_max_window; -- /**< Maximum window size (TCP) for the return direction. */ -- uint32_t return_end; -- /**< End for the return direction. */ -- uint32_t return_max_end; -- /**< Maximum end for the return direction. */ -- uint32_t return_pppoe_if_exist; -- /**< Return direction: PPPoE interface existence flag. */ -- int32_t return_pppoe_if_num; -- /**< Return direction: PPPoE interface number. */ -- uint16_t egress_vlan_tag; /**< Egress VLAN tag expected for this flow. */ -- uint32_t qos_tag; /**< Deprecated; will be removed soon. */ -- uint32_t flow_qos_tag; /**< QoS tag value for flow direction. */ -- uint32_t return_qos_tag; /**< QoS tag value for the return direction. */ -- uint8_t dscp_itag; /**< DSCP marking tag. */ -- uint8_t dscp_imask; /**< DSCP marking input mask. */ -- uint8_t dscp_omask; /**< DSCP marking output mask. */ -- uint8_t dscp_oval; /**< DSCP marking output value. */ -- uint16_t vlan_itag; /**< VLAN marking tag. */ -- uint16_t vlan_imask; /**< VLAN marking input mask. */ -- uint16_t vlan_omask; /**< VLAN marking output mask. */ -- uint16_t vlan_oval; /**< VLAN marking output value. */ -- uint32_t in_vlan_tag[MAX_VLAN_DEPTH]; -- /**< Ingress VLAN tag expected for this flow. */ -- uint32_t out_vlan_tag[MAX_VLAN_DEPTH]; -- /**< Egress VLAN tag expected for this flow. */ -- uint8_t flow_dscp; /**< IP DSCP value for flow direction. */ -- uint8_t return_dscp; /**< IP DSCP value for the return direction. */ -- struct net_device *top_ndev; /**< Netdevice associated with the top interface. */ --}; -- --/** -- * nss_ipv6_destroy -- * Information for an IPv6 flow or connection destroy rule. -- */ --struct nss_ipv6_destroy { -- int32_t protocol; /**< L4 protocol, e.g., TCP or UDP. */ -- uint32_t src_ip[4]; /**< Source IP address. */ -- int32_t src_port; /**< Source L4 port, e.g., TCP or UDP port. */ -- uint32_t dest_ip[4]; /**< Destination IP address. */ -- int32_t dest_port; /**< Destination L4 port, e.g., TCP or UDP port. */ --}; -- --/** - * nss_ipv6_stats_types - * IPv6 node statistics. - */ -@@ -199,14 +76,6 @@ enum nss_ipv6_stats_types { - /**< Number of IPv6 multicast connection destroy requests that missed the cache. */ - NSS_IPV6_STATS_MC_CONNECTION_FLUSHES, - /**< Number of IPv6 multicast connection flushes. */ -- NSS_IPV6_STATS_CONNECTION_CREATE_INVALID_MIRROR_IFNUM, -- /**< Number of IPv6 mirror connection requests with an invalid interface number. */ -- NSS_IPV6_STATS_CONNECTION_CREATE_INVALID_MIRROR_IFTYPE, -- /**< Number of IPv6 mirror connection requests with an invalid interface type. */ -- -- NSS_IPV6_STATS_MIRROR_FAILURES, -- /**< Number of IPv6 mirror failures. */ -- - NSS_IPV6_STATS_MAX, - /**< Maximum message type. */ - }; -@@ -270,14 +139,11 @@ enum nss_ipv6_dscp_map_actions { - /**< Drop packets. */ - #define NSS_IPV6_RULE_CREATE_FLAG_EXCEPTION 0x200 - /**< Rule to except packets. */ -+ - #define NSS_IPV6_RULE_CREATE_FLAG_SRC_INTERFACE_CHECK 0x400 - /**< Check the source interface for the rule. */ - #define NSS_IPV6_RULE_CREATE_FLAG_NO_SRC_IDENT 0x800 - /**< Flag to indicate NSS to ignore src_ident and use value 0 for it during rule addition. */ --#define NSS_IPV6_RULE_CREATE_FLAG_NO_MAC 0x1000 -- /**< Flag to bypass writing MAC addresses. */ --#define NSS_IPV6_RULE_CREATE_FLAG_EMESH_SP 0x2000 -- /**< Mark rule as E-MESH Service Prioritization valid. */ - - /* - * IPv6 rule creation validity flags. -@@ -299,15 +165,12 @@ enum nss_ipv6_dscp_map_actions { - #define NSS_IPV6_RULE_CREATE_DEST_MAC_VALID 0x400 - /**< Destination MAC address fields are valid. */ - #define NSS_IPV6_RULE_CREATE_IGS_VALID 0x800 /**< Ingress shaping fields are valid. */ --#define NSS_IPV6_RULE_CREATE_IDENTIFIER_VALID 0x1000 /**< Identifier is valid. */ --#define NSS_IPV6_RULE_CREATE_MIRROR_VALID 0x2000 /**< Mirror fields are valid. */ -+ - - /* - * Multicast command rule flags - */ - #define NSS_IPV6_MC_RULE_CREATE_FLAG_MC_UPDATE 0x01 /**< Multicast rule update. */ --#define NSS_IPV6_MC_RULE_CREATE_FLAG_MC_EMESH_SP 0x02 -- /**< Mark multicast rule as E-MESH Service Prioritization valid. */ - - /* - * Multicast command validity flags -@@ -353,22 +216,6 @@ enum nss_ipv6_dscp_map_actions { - #define NSS_IPV6_SRC_MAC_RETURN_VALID 0x02 - /**< MAC address for the return interface is valid. */ - --/* -- * Identifier valid flags (to be used with identifier_valid_flags field of nss_ipv6_identifier_rule structure) -- */ --#define NSS_IPV6_FLOW_IDENTIFIER_VALID 0x01 -- /**< Identifier for flow direction is valid. */ --#define NSS_IPV6_RETURN_IDENTIFIER_VALID 0x02 -- /**< Identifier for return direction is valid. */ -- --/* -- * Mirror valid flags (to be used with the valid field of nss_ipv6_mirror_rule structure) -- */ --#define NSS_IPV6_MIRROR_FLOW_VALID 0x01 -- /**< Mirror interface number for the flow direction is valid. */ --#define NSS_IPV6_MIRROR_RETURN_VALID 0x02 -- /**< Mirror interface number for the return direction is valid. */ -- - /** - * nss_ipv6_exception_events - * Exception events from an IPv6 bridge or route handler. -@@ -429,12 +276,14 @@ enum nss_ipv6_exception_events { - NSS_IPV6_EXCEPTION_EVENT_TUNIPIP6_NEEDS_FRAGMENTATION, - NSS_IPV6_EXCEPTION_EVENT_PPPOE_BRIDGE_NO_ICME, - NSS_IPV6_EXCEPTION_EVENT_DONT_FRAG_SET, -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - NSS_IPV6_EXCEPTION_EVENT_REASSEMBLY_NOT_SUPPORTED, -+#endif - NSS_IPV6_EXCEPTION_EVENT_PPPOE_NO_SESSION, -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - NSS_IPV6_EXCEPTION_EVENT_ICMP_IPV6_GRE_HEADER_INCOMPLETE, - NSS_IPV6_EXCEPTION_EVENT_ICMP_IPV6_ESP_HEADER_INCOMPLETE, -- NSS_IPV6_EXCEPTION_EVENT_EMESH_PRIO_MISMATCH, -- NSS_IPV6_EXCEPTION_EVENT_MC_UCAST_DMAC, -+#endif - NSS_IPV6_EXCEPTION_EVENT_MAX - }; - -@@ -589,29 +438,6 @@ struct nss_ipv6_rps_rule { - }; - - /** -- * nss_ipv6_identifier_rule -- * Identifier rule structure. -- */ --struct nss_ipv6_identifier_rule { -- uint32_t identifier_valid_flags; -- /**< Identifier validity flags. */ -- uint32_t flow_identifier; -- /**< Identifier for flow direction. */ -- uint32_t return_identifier; -- /**< Identifier for return direction. */ --}; -- --/** -- * nss_ipv6_mirror_rule -- * Mirror rule structure. -- */ --struct nss_ipv6_mirror_rule { -- uint32_t valid; /**< Mirror validity flags. */ -- nss_if_num_t flow_ifnum; /**< Flow mirror interface number. */ -- nss_if_num_t return_ifnum; /**< Return mirror interface number. */ --}; -- --/** - * nss_ipv6_error_response_types - * Error types for IPv6 messages. - */ -@@ -647,24 +473,24 @@ enum nss_ipv6_error_response_types { - /**< Invalid interface for updating multicast. */ - NSS_IPV6_CR_ACCEL_MODE_CONFIG_INVALID, - /**< Invalid config value for acceleration mode. */ -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - NSS_IPV6_CR_INVALID_MSG_ERROR, - /**< Invalid message size error. */ - NSS_IPV6_CR_DSCP2PRI_PRI_INVALID, - /**< Priority value out of range error. */ - NSS_IPV6_CR_DSCP2PRI_CONFIG_INVALID, - /**< Invalid DSCP value. */ -+#endif - NSS_IPV6_CR_INVALID_RPS, - /**< Invalid RPS Value. */ - NSS_IPV6_HASH_BITMAP_INVALID, - /**< Invalid hash bitmap. */ -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - NSS_IPV6_DR_HW_DECEL_FAIL_ERROR, - /**< Hardware deceleration fail error. */ - NSS_IPV6_CR_RETURN_EXIST_ERROR, - /**< Rule creation failed because a 5-tuple return already exists. */ -- NSS_IPV6_CR_INVALID_IDENTIFIER, -- /**< Invalid identifier value. */ -- NSS_IPV6_CR_EMESH_SP_CONFIG_INVALID, -- /**< Rule creation failed because Qos tag was not set for a Emesh SP rule. */ -+#endif - NSS_IPV6_LAST - /**< Maximum number of error responses. */ - }; -@@ -705,10 +531,6 @@ struct nss_ipv6_rule_create_msg { - /**< RPS parameter. */ - struct nss_ipv6_igs_rule igs_rule; - /**< Ingress shaping related accleration parameters. */ -- struct nss_ipv6_identifier_rule identifier; -- /**< Rule for adding identifier. */ -- struct nss_ipv6_mirror_rule mirror_rule; -- /**< Mirror rule parameter. */ - }; - - /** -@@ -954,16 +776,6 @@ struct nss_ipv6_node_sync { - - uint32_t ipv6_mc_connection_flushes; - /**< Number of multicast connection flushes. */ -- -- uint32_t ipv6_connection_create_invalid_mirror_ifnum; -- /**< Number of failed create requests with an invalid mirror interface number. */ -- -- uint32_t ipv6_connection_create_invalid_mirror_iftype; -- /**< Number of failed create requests with an invalid mirror interface type. */ -- -- uint32_t ipv6_mirror_failures; -- /**< Mirror packet failed. */ -- - uint32_t exception_events[NSS_IPV6_EXCEPTION_EVENT_MAX]; - /**< Number of exception events. */ - }; ---- a/exports/nss_lso_rx.h -+++ b/exports/nss_lso_rx.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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 -@@ -17,7 +17,7 @@ - */ - - /* -- * @file nss_lso_rx.h -+ * nss_lso_rx.h - * NSS driver LSO (Large Send Offload) Rx header file. - */ - ---- a/exports/nss_map_t.h -+++ b/exports/nss_map_t.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2020, 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. -@@ -37,20 +37,6 @@ - #define NSS_MAX_MAP_T_DYNAMIC_INTERFACES 4 - - /** -- * MAP-T metadata flag. -- */ --#define NSS_MAPT_MDATA_FLAG_DF_BIT (1 << 0) -- --/** -- * nss_map_t_mdata -- * MAP-T metadata -- */ --struct nss_map_t_mdata { -- uint16_t flags; /**< Metadata flags. */ -- uint16_t res[6]; /**< Reserved for future use. */ --}; -- --/** - * nss_map_t_msg_types - * Message types for MAP-T requests and responses. - */ ---- a/exports/nss_mirror.h -+++ b/exports/nss_mirror.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -79,20 +79,6 @@ enum nss_mirror_error_type { - }; - - /** -- * nss_mirror_stats -- * Mirror interface debug statistics. -- */ --enum nss_mirror_stats { -- NSS_MIRROR_STATS_PKTS, /**< Number of packets exceptioned to host. */ -- NSS_MIRROR_STATS_BYTES, /**< Number of bytes exceptioned to host. */ -- NSS_MIRROR_STATS_TX_SEND_FAIL, /**< Transmit send failures. */ -- NSS_MIRROR_STATS_DEST_LOOKUP_FAIL, /**< Destination lookup failures. */ -- NSS_MIRROR_STATS_MEM_ALLOC_FAIL, /**< Memory allocation failures. */ -- NSS_MIRROR_STATS_COPY_FAIL, /**< Copy failures. */ -- NSS_MIRROR_STATS_MAX /**< Maximum statistics count. */ --}; -- --/** - * nss_mirror_configure_msg - * Mirror interface configuration information. - */ -@@ -134,16 +120,6 @@ struct nss_mirror_stats_sync_msg { - }; - - /** -- * nss_mirror_stats_notification -- * Mirror transmission statistics structure. -- */ --struct nss_mirror_stats_notification { -- uint64_t stats_ctx[NSS_MIRROR_STATS_MAX]; /**< Context transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ -- uint32_t if_num; /**< Interface number. */ --}; -- --/** - * nss_mirror_msg - * Data for sending and receiving mirror interface messages. - */ -@@ -230,17 +206,6 @@ extern nss_tx_status_t nss_mirror_tx_msg - extern nss_tx_status_t nss_mirror_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_mirror_msg *msg); - - /** -- * nss_mirror_unregister_if -- * Deregisters a mirror interface from the NSS. -- * -- * @param[in] if_num NSS interface number. -- * -- * @return -- * None. -- */ --extern void nss_mirror_unregister_if(uint32_t if_num); -- --/** - * nss_mirror_register_if - * Registers a mirror interface with the NSS for sending and receiving messages. - * -@@ -264,6 +229,17 @@ extern struct nss_ctx_instance *nss_mirr - struct net_device *netdev, uint32_t features); - - /** -+ * nss_mirror_unregister_if -+ * Deregisters a mirror interface from the NSS. -+ * -+ * @param[in] if_num NSS interface number. -+ * -+ * @return -+ * None. -+ */ -+extern void nss_mirror_unregister_if(uint32_t if_num); -+ -+/** - * nss_mirror_verify_if_num - * Verify whether the interface is an mirror interface or not. - * -@@ -284,34 +260,6 @@ extern bool nss_mirror_verify_if_num(uin - extern void nss_mirror_register_handler(void); - - /** -- * nss_mirror_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_mirror_stats_unregister_notifier(struct notifier_block *nb); -- --/** -- * nss_mirror_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_mirror_stats_register_notifier(struct notifier_block *nb); -- --/** - * @} - */ - #endif ---- a/exports/nss_n2h.h -+++ b/exports/nss_n2h.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2020, 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. -@@ -62,7 +62,6 @@ struct nss_n2h_cfg_pvt { - struct nss_n2h_payload_info empty_buf_pool_info; /**< Empty buffer pool information. */ - struct nss_n2h_payload_info empty_paged_buf_pool_info; /**< Paged buffer pool information. */ - int wifi_pool; /**< Size of the empty Wi-Fi buffer pool. */ -- int shaper_pool; /**< Size of the empty shaper pool. */ - int response; /**< Response from the firmware. */ - }; - -@@ -74,40 +73,43 @@ struct nss_n2h_cfg_pvt { - */ - enum nss_n2h_stats_types { - NSS_N2H_STATS_QUEUE_DROPPED = NSS_STATS_NODE_MAX, -- /**< Number of packets dropped because the exception queue is too full. */ -- NSS_N2H_STATS_TOTAL_TICKS, /**< Total clock ticks spend inside the N2H. */ -- NSS_N2H_STATS_WORST_CASE_TICKS, /**< Worst case iteration of the exception path in ticks. */ -- NSS_N2H_STATS_ITERATIONS, /**< Number of iterations around the N2H. */ -- NSS_N2H_STATS_PBUF_OCM_TOTAL_COUNT, /**< Number of pbuf OCM total count. */ -- NSS_N2H_STATS_PBUF_OCM_FREE_COUNT, /**< Number of pbuf OCM free count. */ -+ /* Number of packets dropped because the exception queue is too full */ -+ NSS_N2H_STATS_TOTAL_TICKS, /* Total clock ticks spend inside the N2H */ -+ NSS_N2H_STATS_WORST_CASE_TICKS, /* Worst case iteration of the exception path in ticks */ -+ NSS_N2H_STATS_ITERATIONS, /* Number of iterations around the N2H */ -+ - NSS_N2H_STATS_PBUF_OCM_ALLOC_FAILS_WITH_PAYLOAD, -- /**< Number of pbuf OCM allocations that have failed with payload. */ -+ /* Number of pbuf ocm allocations that have failed with payload */ -+ NSS_N2H_STATS_PBUF_OCM_FREE_COUNT, /* Number of pbuf ocm free count */ -+ NSS_N2H_STATS_PBUF_OCM_TOTAL_COUNT, /* Number of pbuf ocm total count */ - NSS_N2H_STATS_PBUF_OCM_ALLOC_FAILS_NO_PAYLOAD, -- /**< Number of pbuf OCM allocations that have failed without payload. */ -- NSS_N2H_STATS_PBUF_DEFAULT_TOTAL_COUNT, /**< Number of pbuf default total count. */ -- NSS_N2H_STATS_PBUF_DEFAULT_FREE_COUNT, /**< Number of pbuf default free count. */ -+ /* Number of pbuf ocm allocations that have failed without payload */ -+ - NSS_N2H_STATS_PBUF_DEFAULT_ALLOC_FAILS_WITH_PAYLOAD, -- /**< Number of pbuf default allocations that have failed with payload. */ -+ /* Number of pbuf default allocations that have failed with payload */ -+ -+ NSS_N2H_STATS_PBUF_DEFAULT_FREE_COUNT, /* Number of pbuf default free count */ -+ NSS_N2H_STATS_PBUF_DEFAULT_TOTAL_COUNT, /* Number of pbuf default total count */ - NSS_N2H_STATS_PBUF_DEFAULT_ALLOC_FAILS_NO_PAYLOAD, -- /**< Number of pbuf default allocations that have failed without payload. */ -+ /* Number of pbuf default allocations that have failed without payload */ - -- NSS_N2H_STATS_PAYLOAD_ALLOC_FAILS, /**< Number of pbuf allocations that have failed because there were no free payloads. */ -- NSS_N2H_STATS_PAYLOAD_FREE_COUNT, /**< Number of free payloads that exist. */ -+ NSS_N2H_STATS_PAYLOAD_ALLOC_FAILS, /* Number of pbuf allocations that have failed because there were no free payloads */ -+ NSS_N2H_STATS_PAYLOAD_FREE_COUNT, /* Number of free payloads that exist */ - -- NSS_N2H_STATS_H2N_CONTROL_PACKETS, /**< Control packets received from HLOS. */ -- NSS_N2H_STATS_H2N_CONTROL_BYTES, /**< Control bytes received from HLOS. */ -- NSS_N2H_STATS_N2H_CONTROL_PACKETS, /**< Control packets sent to HLOS. */ -- NSS_N2H_STATS_N2H_CONTROL_BYTES, /**< Control bytes sent to HLOS. */ -- -- NSS_N2H_STATS_H2N_DATA_PACKETS, /**< Data packets received from HLOS. */ -- NSS_N2H_STATS_H2N_DATA_BYTES, /**< Data bytes received from HLOS. */ -- NSS_N2H_STATS_N2H_DATA_PACKETS, /**< Data packets sent to HLOS. */ -- NSS_N2H_STATS_N2H_DATA_BYTES, /**< Data bytes sent to HLOS. */ -- NSS_N2H_STATS_N2H_TOT_PAYLOADS, /**< Number of payloads in NSS. */ -- NSS_N2H_STATS_N2H_INTERFACE_INVALID, /**< Number of bad interface access. */ -- NSS_N2H_STATS_ENQUEUE_RETRIES, /**< Number of enqueue retries by N2H. */ -+ NSS_N2H_STATS_H2N_CONTROL_PACKETS, /* Control packets received from HLOS */ -+ NSS_N2H_STATS_H2N_CONTROL_BYTES, /* Control bytes received from HLOS */ -+ NSS_N2H_STATS_N2H_CONTROL_PACKETS, /* Control packets sent to HLOS */ -+ NSS_N2H_STATS_N2H_CONTROL_BYTES, /* Control bytes sent to HLOS */ -+ -+ NSS_N2H_STATS_H2N_DATA_PACKETS, /* Data packets received from HLOS */ -+ NSS_N2H_STATS_H2N_DATA_BYTES, /* Data bytes received from HLOS */ -+ NSS_N2H_STATS_N2H_DATA_PACKETS, /* Data packets sent to HLOS */ -+ NSS_N2H_STATS_N2H_DATA_BYTES, /* Data bytes sent to HLOS */ -+ NSS_N2H_STATS_N2H_TOT_PAYLOADS, /* No. of payloads in NSS */ -+ NSS_N2H_STATS_N2H_INTERFACE_INVALID, /* No. of bad interface access */ -+ NSS_N2H_STATS_ENQUEUE_RETRIES, /* No. of enqueue retries by N2H */ - -- NSS_N2H_STATS_MAX, /**< Maximum message type. */ -+ NSS_N2H_STATS_MAX, - }; - - /** -@@ -133,7 +135,6 @@ enum nss_n2h_metadata_types { - NSS_TX_METADATA_TYPE_N2H_QUEUE_LIMIT_CFG, - NSS_TX_METADATA_TYPE_N2H_PAGED_BUFFER_POOL_INIT, - NSS_TX_METADATA_TYPE_N2H_HOST_BACK_PRESSURE_CFG, -- NSS_TX_METADATA_TYPE_N2H_SHAPER_POOL_CFG, - NSS_METADATA_TYPE_N2H_MAX, - }; - -@@ -362,24 +363,6 @@ struct nss_n2h_host_back_pressure { - }; - - /** -- * nss_n2h_shaper_mem_cfg_msg -- * Shaper memory configuration message. -- */ --struct nss_n2h_shaper_mem_cfg_msg { -- uint32_t mem_blk_size; /**< Size of the memory block. */ -- uint32_t num_blks; /**< Number of memory blocks. */ -- -- uint32_t pool_addr[MAX_PAGES_PER_MSG]; -- /**< Buffer addresses. */ -- nss_ptr_t pool_vaddr[MAX_PAGES_PER_MSG]; -- /**< Virtual addresses of the buffers. */ --#ifndef __LP64__ -- uint32_t padding[MAX_PAGES_PER_MSG]; -- /**< Padding that fits up to 64 bits. Do not reuse. */ --#endif --}; -- --/** - * nss_n2h_msg - * Data for sending and receiving N2H messages. - */ -@@ -426,8 +409,6 @@ struct nss_n2h_msg { - /**< Paged buffer pool initialization. */ - struct nss_n2h_host_back_pressure host_bp_cfg; - /**< Host back pressure configuration. */ -- struct nss_n2h_shaper_mem_cfg_msg shaper_mem_cfg; -- /**< Shaper memory configuration. */ - } msg; /**< Message payload. */ - }; - ---- a/exports/nss_phy_if.h -+++ b/exports/nss_phy_if.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -17,7 +17,7 @@ - */ - - /** -- * @file nss_phy_if.h -+ * @file nss_phy_if.h.h - * NSS physical interface definitions. - */ - ---- a/exports/nss_ppe.h -+++ b/exports/nss_ppe.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2018, 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2018, 2020, 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. -@@ -22,8 +22,6 @@ - #ifndef _NSS_PPE_H_ - #define _NSS_PPE_H_ - --typedef int32_t nss_ppe_port_t; -- - /** - * @addtogroup nss_ppe_subsystem - * @{ -@@ -54,38 +52,9 @@ enum nss_ppe_sc_type { - NSS_PPE_SC_PTP, /**< Service code for PTP packets. */ - NSS_PPE_SC_VLAN_FILTER_BYPASS, /**< VLAN filter bypass for bridge flows between 2 different VSIs. */ - NSS_PPE_SC_L3_EXCEPT, /**< Indicate exception post tunnel/TAP operation. */ -- NSS_PPE_SC_SPF_BYPASS, /**< Source port filtering bypass in PPE. */ - NSS_PPE_SC_MAX, /**< Maximum service code. */ - }; - --/** -- * nss_ppe_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_ppe_stats_unregister_notifier(struct notifier_block *nb); -- --/** -- * nss_ppe_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_ppe_stats_register_notifier(struct notifier_block *nb); -- - /** @} */ /* end_addtogroup nss_ppe_subsystem */ - - #endif /* _NSS_PPE_H_ */ ---- a/exports/nss_project.h -+++ b/exports/nss_project.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2018, 2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2018, 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. -@@ -38,12 +38,6 @@ - #define NSS_PROJECT_IRQS_PER_MESSAGE 32 - - /** -- * Maximum possible value of priority after classification -- * at an ingress interface. -- */ --#define NSS_PROJECT_PRI_MQ_MAP_MAX_SIZE 16 -- --/** - * nss_project_message_types - * Project message types. - */ -@@ -52,8 +46,6 @@ enum nss_project_message_types { - /**< Message to enable or disable worker thread statistics. */ - NSS_PROJECT_MSG_WT_STATS_NOTIFY, - /**< NSS to HLOS message containing worker thread statistics. */ -- NSS_PROJECT_MSG_SET_QUEUE_PRI_MAP_CFG, -- /**< Message to configure priority to multi-queue mapping. */ - NSS_PROJECT_MSG_MAX, - }; - -@@ -68,8 +60,6 @@ enum nss_project_error_types { - /**< The firmware does not support worker thread statistics. */ - NSS_PROJECT_ERROR_WT_STATS_REDUNDANT_ENABLE, - /**< The firmware received a redundant request to enable worker thread statistics. */ -- NSS_PROJECT_ERROR_MQ_NUMBER_INVALID, -- /**< The firmware received an invalid multi-queue number. */ - NSS_PROJECT_ERROR_MAX, - }; - -@@ -121,15 +111,6 @@ struct nss_project_msg_wt_stats_notify { - }; - - /** -- * nss_project_msg_pri_mq_map_cfg -- * NSS priority to multi-queue mapping configuration. -- */ --struct nss_project_msg_pri_mq_map_cfg { -- uint8_t pri_mq_map[NSS_PROJECT_PRI_MQ_MAP_MAX_SIZE]; -- /**< Priority to multi-queue mapping array. */ --}; -- --/** - * nss_project_msg - * General message structure for project messages. - */ -@@ -144,8 +125,6 @@ struct nss_project_msg { - /**< Enable or disable worker thread statistics. */ - struct nss_project_msg_wt_stats_notify wt_stats_notify; - /**< One-way worker thread statistics message. */ -- struct nss_project_msg_pri_mq_map_cfg pri_mq_map_cfg; -- /**< Configure priority to multi-queue message. */ - } msg; /**< Message payload. */ - }; - -@@ -191,17 +170,6 @@ void nss_project_unregister_sysctl(void) - void nss_project_register_handler(struct nss_ctx_instance *nss_ctx); - - /** -- * nss_project_pri_mq_map_configure -- * Configures priority to multi-queue mapping. -- * -- * @param[in] nss_ctx Pointer to the NSS context. -- * -- * @return -- * Status of the configuration update operation. -- */ --extern nss_tx_status_t nss_project_pri_mq_map_configure(struct nss_ctx_instance *nss_ctx); -- --/** - * @} - */ - ---- a/exports/nss_qrfs.h -+++ b/exports/nss_qrfs.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2018, 2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2018, 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. -@@ -110,7 +110,6 @@ struct nss_qrfs_msg { - } msg; /**< Message payload. */ - }; - --#ifdef __KERNEL__ - /** - * Callback function for receiving QRFS messages. - * -@@ -177,23 +176,6 @@ void nss_qrfs_notify_unregister(int core - * Status of the Tx operation. - */ - nss_tx_status_t nss_qrfs_set_flow_rule(struct sk_buff *skb, uint32_t cpu, uint32_t action); --/** -- * nss_qrfs_configure_flow_rule -- * Configures and sends a QRFS message to the NSS core to configure(add/remove) the flow rule. -- * -- * @param[in] dst_addr Destination IP address. -- * @param[in] src_addr Source IP address. -- * @param[in] dst_port Destination port. -- * @param[in] src_port Source port. -- * @param[in] version IP version. -- * @param[in] proto Protocol. -- * @param[in] cpu CPU number to be offloaded to. -- * @param[in] type Type of action to perform on the flow table, can be add or delete. -- * -- * @return -- * Status of the Tx operation. -- */ --nss_tx_status_t nss_qrfs_configure_flow_rule(uint32_t *dst_addr, uint32_t *src_addr, uint16_t dst_port, uint16_t src_port, uint32_t version, uint16_t proto, uint16_t cpu, enum nss_qrfs_msg_types type); - - /** - * nss_qrfs_init -@@ -208,5 +190,4 @@ void nss_qrfs_init(void); - * @} - */ - --#endif - #endif /* __NSS_QRFS_H */ ---- a/exports/nss_qvpn.h -+++ b/exports/nss_qvpn.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019, 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. -@@ -27,6 +27,10 @@ - * @{ - */ - -+#define NSS_QVPN_INTERFACE_MAX_LONG BITS_TO_LONGS(NSS_MAX_NET_INTERFACES) /**< QVPN interface mapping bits. */ -+#define NSS_QVPN_STATS_MAX_LINES (NSS_STATS_NODE_MAX + 32) /**< Maxminum number of lines for QVPN statistics dump. */ -+#define NSS_QVPN_STATS_SIZE_PER_IF (NSS_STATS_MAX_STR_LENGTH * NSS_QVPN_STATS_MAX_LINES) /**< Total number of statistics per QVPN interface. */ -+ - #define NSS_QVPN_CMDS_MAX 10 /**< Maximum number of QVPN commands supported. */ - #define NSS_QVPN_VPN_HDR_HEAD_SIZE_MAX 64 /**< Maximum size of QVPN header. */ - #define NSS_QVPN_VPN_HDR_TAIL_SIZE_MAX 32 /**< Maximum size of QVPN tail. */ -@@ -290,16 +294,6 @@ struct nss_qvpn_stats_sync_msg { - }; - - /** -- * nss_qvpn_stats_notification -- * QVPN transmission statistics structure. -- */ --struct nss_qvpn_stats_notification { -- uint64_t stats_ctx[NSS_STATS_NODE_MAX]; /**< Context transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ -- uint32_t if_num; /**< Interface number. */ --}; -- --/** - * nss_qvpn_msg - * QVPN message structure for configuration and statistics. - */ -@@ -426,17 +420,6 @@ typedef void (*nss_qvpn_callback_t)(stru - typedef void (*nss_qvpn_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); - - /** -- * nss_qvpn_unregister_if -- * Deregisters the QVPN interface from the NSS. -- * -- * @param[in] if_num NSS interface number. -- * -- * @return -- * None. -- */ --void nss_qvpn_unregister_if(uint32_t if_num); -- --/** - * nss_qvpn_register_if - * Register to send/receive QVPN messages to NSS. - * -@@ -459,6 +442,17 @@ struct nss_ctx_instance *nss_qvpn_regist - uint32_t features, void *app_ctx); - - /** -+ * nss_qvpn_unregister_if -+ * Deregisters the QVPN interface from the NSS. -+ * -+ * @param[in] if_num NSS interface number. -+ * -+ * @return -+ * None. -+ */ -+void nss_qvpn_unregister_if(uint32_t if_num); -+ -+/** - * nss_qvpn_ifnum_with_core_id - * Gets the QVPN interface number with the core ID. - * -@@ -488,34 +482,6 @@ void nss_qvpn_register_handler(void); - unsigned long *nss_qvpn_ifmap_get(void); - - /** -- * nss_qvpn_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_qvpn_stats_unregister_notifier(struct notifier_block *nb); -- --/** -- * nss_qvpn_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_qvpn_stats_register_notifier(struct notifier_block *nb); -- --/** - * @} - */ - ---- a/exports/nss_rmnet_rx.h -+++ b/exports/nss_rmnet_rx.h -@@ -18,7 +18,7 @@ - - /* - * @file nss_rmnet_rx.h -- * NSS RMNET interface message Structure and APIs -+ * NSS Virtual interface message Structure and APIs - */ - - #ifndef __NSS_RMNET_RX_H -@@ -58,7 +58,7 @@ enum nss_rmnet_rx_msg_types { - - /** - * nss_rmnet_rx_error_types -- * Error types for the RMNET interface. -+ * Error types for the virtual interface. - */ - enum nss_rmnet_rx_error_types { - NSS_RMNET_RX_SUCCESS, /**< No error. */ -@@ -125,19 +125,19 @@ struct nss_rmnet_rx_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** -- * Payload of an RMNET interface message. -+ * Payload of a virtual interface message. - */ - union { - struct nss_rmnet_rx_config_msg if_config; -- /**< Rule for creating an RMNET interface. */ -+ /**< Rule for creating a virtual interface. */ - struct nss_rmnet_rx_stats stats; -- /**< RMNET interface statistics. */ -+ /**< Virtual interface statistics. */ - } msg; /**< Message payload. */ - }; - - /** - * Callback to transmit interface data received from NSS -- * to the transmit path of the RMNET interface. -+ * to the transmit path of the virtual interface. - * - * @datatypes - * net_device \n -@@ -183,8 +183,8 @@ struct nss_rmnet_rx_handle { - int32_t if_num_h2n; /**< Redirect interface number on host-to-NSS path. */ - struct net_device *ndev; /**< Associated network device. */ - struct nss_rmnet_rx_pvt *pvt; /**< Private data structure. */ -- uint64_t *stats_n2h; /**< RMNET interface statistics from NSS-to-host. */ -- uint64_t *stats_h2n; /**< RMNET interface statistics from host-to-NSS. */ -+ uint64_t *stats_n2h; /**< Virtual interface statistics from NSS-to-host. */ -+ uint64_t *stats_h2n; /**< Virtual interface statistics from host-to-NSS. */ - atomic_t refcnt; /**< Reference count. */ - nss_rmnet_rx_msg_callback_t cb; /**< Message callback. */ - void *app_data; /**< Application data to be passed to the callback. */ -@@ -192,12 +192,12 @@ struct nss_rmnet_rx_handle { - - /** - * nss_rmnet_rx_destroy_sync -- * Destroys the RMNET interface synchronously. -+ * Destroys the virtual interface synchronously. - * - * @datatypes - * nss_rmnet_rx_handle - * -- * @param[in,out] handle Pointer to the RMNET interface handle (provided during -+ * @param[in,out] handle Pointer to the virtual interface handle (provided during - * dynamic interface allocation). - * - * @return -@@ -210,7 +210,7 @@ extern nss_tx_status_t nss_rmnet_rx_dest - - /** - * nss_rmnet_rx_create_sync_nexthop -- * Creates an RMNET interface synchronously with specified nexthops. -+ * Creates a virtual interface synchronously with specified nexthops. - * - * @datatypes - * net_device -@@ -220,33 +220,19 @@ extern nss_tx_status_t nss_rmnet_rx_dest - * @param[in] nexthop_h2n Nexthop interface number of host-to-NSS dynamic interface. - * - * @return -- * Pointer to the NSS RMNET interface handle. -+ * Pointer to NSS virtual interface handle. - */ - extern struct nss_rmnet_rx_handle *nss_rmnet_rx_create_sync_nexthop(struct net_device *netdev, uint32_t nexthop_n2h, uint32_t nexthop_h2n); - - /** -- * nss_rmnet_rx_create -- * Creates an RMNET interface synchronously with generic nexthops. -- * -- * @datatypes -- * net_device -- * -- * @param[in] netdev Pointer to the associated network device. -- * -- * @return -- * Pointer to the NSS RMNET interface handle. -- */ --extern struct nss_rmnet_rx_handle *nss_rmnet_rx_create(struct net_device *netdev); -- --/** - * nss_rmnet_rx_tx_buf -- * Forwards RMNET interface packets to the NSS. -+ * Forwards virtual interface packets to the NSS. - * - * @datatypes - * nss_rmnet_rx_handle \n - * sk_buff - * -- * @param[in,out] handle Pointer to the RMNET interface handle (provided during -+ * @param[in,out] handle Pointer to the virtual interface handle (provided during - * registration). - * @param[in] skb Pointer to the data socket buffer. - * -@@ -258,14 +244,14 @@ extern nss_tx_status_t nss_rmnet_rx_tx_b - - /** - * nss_rmnet_rx_tx_msg -- * Sends a message to the RMNET interface. -+ * Sends a message to the virtual interface. - * - * @datatypes - * nss_ctx_instance \n - * nss_rmnet_rx_msg - * - * @param[in] nss_ctx Pointer to the NSS context (provided during registration). -- * @param[in] nvim Pointer to the RMNET interface message. -+ * @param[in] nvim Pointer to the virtual interface message. - * - * @return - * Command Tx status. -@@ -274,12 +260,12 @@ extern nss_tx_status_t nss_rmnet_rx_tx_m - - /** - * nss_rmnet_rx_xmit_callback_unregister -- * Deregisters the transmit callback from the RMNET interface. -+ * Deregisters the transmit callback from the virtual interface. - * - * @datatypes - * nss_rmnet_rx_handle - * -- * @param[in,out] handle Pointer to the RMNET interface handle. -+ * @param[in,out] handle Pointer to the virtual interface handle. - * - * @return - * None. -@@ -288,15 +274,15 @@ extern void nss_rmnet_rx_xmit_callback_u - - /** - * nss_rmnet_rx_xmit_callback_register -- * Registers a transmit callback to an RMNET interface. -+ * Registers a transmit callback to a virtual interface. - * - * @datatypes - * nss_rmnet_rx_handle \n - * nss_rmnet_rx_xmit_callback_t - * -- * @param[in,out] handle Pointer to the RMNET interface handle (provided during -+ * @param[in,out] handle Pointer to the virtual interface handle (provided during - * dynamic interface allocation). -- * @param[in] cb Callback handler for RMNET data packets. -+ * @param[in] cb Callback handler for virtual data packets. - * - * @return - * None. -@@ -306,12 +292,12 @@ extern void nss_rmnet_rx_xmit_callback_r - - /** - * nss_rmnet_rx_unregister -- * Deregisters an RMNET interface from the NSS driver. -+ * Deregisters a virtual interface from the NSS driver. - * - * @datatypes - * nss_rmnet_rx_handle - * -- * @param[in,out] handle Pointer to the RMNET interface handle. -+ * @param[in,out] handle Pointer to the virtual interface handle. - * - * @return - * None. -@@ -320,16 +306,16 @@ extern void nss_rmnet_rx_unregister(stru - - /** - * nss_rmnet_rx_register -- * Registers an RMNET Interface with NSS driver. -+ * Registers a virtual Interface with NSS driver. - * - * @datatypes - * nss_rmnet_rx_handle \n - * nss_rmnet_rx_data_callback_t \n - * net_device - * -- * @param[in,out] handle Pointer to the RMNET interface handle (provided during -+ * @param[in,out] handle Pointer to the virtual interface handle (provided during - * dynamic interface allocation). -- * @param[in] data_callback Callback handler for RMNET data packets. -+ * @param[in] data_callback Callback handler for virtual data packets. - * @param[in] netdev Pointer to the associated network device. - * - * @return -@@ -363,22 +349,22 @@ extern int32_t nss_rmnet_rx_get_ifnum(st - - /** - * nss_rmnet_rx_get_interface_num -- * Returns the RMNET interface number associated with the handle. -+ * Returns the virtual interface number associated with the handle. - * - * @datatypes - * nss_rmnet_rx_handle - * -- * @param[in] handle Pointer to the RMNET interface handle (provided during -+ * @param[in] handle Pointer to the virtual interface handle (provided during - dynamic interface allocation). - * - * @return -- * RMNET interface number. -+ * Virtual interface number. - */ - extern int32_t nss_rmnet_rx_get_interface_num(struct nss_rmnet_rx_handle *handle); - - /** - * nss_rmnet_rx_get_context -- * Gets the RMNET interface context. -+ * Gets the virtual interface context. - * - * @return - * Pointer to the NSS core context. ---- a/exports/nss_shaper.h -+++ b/exports/nss_shaper.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014, 2017-2018, 2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014, 2017-2018 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. -@@ -59,7 +59,7 @@ enum nss_shaper_config_types { - NSS_SHAPER_CONFIG_TYPE_FREE_SHAPER_NODE, - NSS_SHAPER_CONFIG_TYPE_SET_DEFAULT, - NSS_SHAPER_CONFIG_TYPE_SET_ROOT, -- NSS_SHAPER_CONFIG_TYPE_SHAPER_NODE_STATS_SYNC_MANY, -+ NSS_SHAPER_CONFIG_TYPE_SHAPER_NODE_BASIC_STATS_GET, - NSS_SHAPER_CONFIG_TYPE_SHAPER_NODE_ATTACH, - NSS_SHAPER_CONFIG_TYPE_SHAPER_NODE_DETACH, - NSS_SHAPER_CONFIG_TYPE_SHAPER_NODE_CHANGE_PARAM, -@@ -672,7 +672,6 @@ struct nss_shaper_node_stats { - * Statistics response for shaper nodes. - */ - struct nss_shaper_node_stats_response { -- uint32_t qos_tag; /**< QoS tag of the shaper node. */ - struct nss_shaper_node_stats sn_stats; /**< Common shaper node statistics. */ - - /** -@@ -686,27 +685,21 @@ struct nss_shaper_node_stats_response { - }; - - /** -- * nss_shaper_node_stats_sync_many -- * Message structure to request shaper node statistics. -+ * nss_shaper_node_stats_get -+ * Statistics of a shaper node. - */ --struct nss_shaper_node_stats_sync_many { -+struct nss_shaper_node_stats_get { - -- /* -- * Request/Response -- */ -- uint32_t last_qos_tag; /**< Last QoS tag. Zero indicates a fresh iteration. */ -- -- /* -- * Request -- */ -- uint16_t size; /**< Total buffer size indicated by host. */ -- -- /* -- * Response -- */ -- uint16_t count; /**< Number of shaper nodes for which statistics are copied. */ -- struct nss_shaper_node_stats_response stats_sync[]; -- /**< Response to host. */ -+ /* -+ * Request -+ */ -+ uint32_t qos_tag; /**< QoS tag of the shaper node. */ -+ -+ /* -+ * Response -+ */ -+ struct nss_shaper_node_stats_response response; -+ /**< Shaper node statistics response */ - }; - - /** -@@ -733,8 +726,8 @@ struct nss_shaper_configure { - /**< Set a shaper to operate in Hybrid mode. */ - struct nss_shaper_node_config shaper_node_config; - /**< Configuration message for any type of shaper node. */ -- struct nss_shaper_node_stats_sync_many stats_get; -- /**< Statistics of multiple shaper nodes. */ -+ struct nss_shaper_node_stats_get shaper_node_stats_get; -+ /**< Statistics for a shaper node. */ - } msg; /**< Types of configuration messages. */ - }; - ---- a/exports/nss_tls.h -+++ b/exports/nss_tls.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -69,43 +69,6 @@ enum nss_tls_error { - }; - - /** -- * nss_tls_stats_types -- * TLS statistics types. -- */ --enum nss_tls_stats_types { -- NSS_TLS_STATS_SINGLE_REC = NSS_STATS_NODE_MAX, -- /**< Number of transmit single record datagrams. */ -- NSS_TLS_STATS_MULTI_REC, /**< Number of multiple transmit record datagrams. */ -- NSS_TLS_STATS_TX_INVAL_REQS, /**< Number of transmit invalidations successfully requested. */ -- NSS_TLS_STATS_RX_CCS_REC, /**< Number of change cipher specification records received. */ -- NSS_TLS_STATS_FAIL_CCS, /**< Failure to switch to new crypto. */ -- NSS_TLS_STATS_ETH_NODE_DEACTIVE, /**< Ethernet node deactivated because no crypto was available. */ -- NSS_TLS_STATS_CRYPTO_ALLOC_SUCCESS, /**< Number of successful crypto allocations. */ -- NSS_TLS_STATS_CRYPTO_FREE_REQ, /**< Number of crypto-free requests. */ -- NSS_TLS_STATS_CRYPTO_FREE_SUCCESS, /**< Number of crypto-free successes. */ -- NSS_TLS_STATS_FAIL_CRYPTO_ALLOC, /**< Number of failed crypto allocations. */ -- NSS_TLS_STATS_FAIL_CRYPTO_LOOKUP, /**< Failure to find an active crypto session. */ -- NSS_TLS_STATS_FAIL_REQ_ALLOC, /**< Failure to allocate request memory pool. */ -- NSS_TLS_STATS_FAIL_PBUF_STATS, /**< Failure in pbuf allocation for statistics. */ -- NSS_TLS_STATS_FAIL_CTX_ACTIVE, /**< Failure in enqueue due to inactive context. */ -- NSS_TLS_STATS_HW_LEN_ERROR, /**< Length error. */ -- NSS_TLS_STATS_HW_TOKEN_ERROR, /**< Token error; unknown token command or instruction. */ -- NSS_TLS_STATS_HW_BYPASS_ERROR, /**< Token contains too much bypass data. */ -- NSS_TLS_STATS_HW_CRYPTO_ERROR, /**< Cryptographic block size error. */ -- NSS_TLS_STATS_HW_HASH_ERROR, /**< Hash block size error. */ -- NSS_TLS_STATS_HW_CONFIG_ERROR, /**< Invalid command, algorithm, or mode combination. */ -- NSS_TLS_STATS_HW_ALGO_ERROR, /**< Unsupported algorithm. */ -- NSS_TLS_STATS_HW_HASH_OVF_ERROR, /**< Hash input overflow. */ -- NSS_TLS_STATS_HW_AUTH_ERROR, /**< Hash input overflow. */ -- NSS_TLS_STATS_HW_PAD_VERIFY_ERROR, /**< Pad verification error. */ -- NSS_TLS_STATS_HW_TIMEOUT_ERROR, /**< Data timed out. */ -- NSS_TLS_STATS_NO_DESC_IN, /**< Ingress DMA descriptor not available. */ -- NSS_TLS_STATS_NO_DESC_OUT, /**< Egress DMA descriptor not available. */ -- NSS_TLS_STATS_NO_REQS, /**< Not enough requests available for records. */ -- NSS_TLS_STATS_MAX, /**< Maximum statistics type. */ --}; -- --/** - * nss_tls_hw_stats - * TLS HW statistics. - */ -@@ -194,16 +157,6 @@ struct nss_tls_cipher_update { - }; - - /** -- * nss_tls_stats_notification -- * TLS transmission statistics structure. -- */ --struct nss_tls_stats_notification { -- uint64_t stats_ctx[NSS_TLS_STATS_MAX]; /**< Context transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ -- uint32_t if_num; /**< Interface number. */ --}; -- --/** - * nss_tls_msg - * Data for sending and receiving TLS messages. - */ -@@ -292,7 +245,7 @@ extern nss_tx_status_t nss_tls_tx_msg(st - * @param[in] if_num NSS interface number. - * @param[in] type Type of message. - * @param[in] len Size of the payload. -- * @param[in] ntcm Pointer to the NSS IPsec message. -+ * @param[in] nicm Pointer to the NSS IPsec message. - * - * @return - * Status of the Tx operation. -@@ -302,20 +255,6 @@ extern nss_tx_status_t nss_tls_tx_msg_sy - struct nss_tls_msg *ntcm); - - /** -- * nss_tls_unregister_if -- * Deregisters a TLS session interface from the NSS. -- * -- * @param[in] if_num NSS interface number. -- * -- * @return -- * None. -- * -- * @dependencies -- * The TLS session interface must have been previously registered. -- */ --extern void nss_tls_unregister_if(uint32_t if_num); -- --/** - * nss_tls_register_if - * Registers a TLS session interface with the NSS for sending and receiving - * messages. -@@ -345,19 +284,22 @@ extern struct nss_ctx_instance *nss_tls_ - void *app_ctx); - - /** -- * nss_tls_notify_unregister -- * Deregisters an event callback. -+ * nss_tls_unregister_if -+ * Deregisters a TLS session interface from the NSS. - * -- * @param[in] ifnum NSS interface number. -+ * @param[in] if_num NSS interface number. - * - * @return - * None. -+ * -+ * @dependencies -+ * The TLS session interface must have been previously registered. - */ --extern void nss_tls_notify_unregister(uint32_t ifnum); -+extern void nss_tls_unregister_if(uint32_t if_num); - - /** - * nss_tls_notify_register -- * Registers an event callback to handle notification from TLS firmware package. -+ * Register an event callback to handle notification from TLS firmware package. - * - * @datatypes - * nss_tls_msg_callback_t -@@ -372,6 +314,17 @@ extern void nss_tls_notify_unregister(ui - extern struct nss_ctx_instance *nss_tls_notify_register(uint32_t ifnum, nss_tls_msg_callback_t ev_cb, void *app_data); - - /** -+ * nss_tls_notify_unregister -+ * Unregister an event callback. -+ * -+ * @param[in] ifnum NSS interface number. -+ * -+ * @return -+ * None. -+ */ -+extern void nss_tls_notify_unregister(uint32_t ifnum); -+ -+/** - * nss_tls_msg_init - * Initializes a TLS message sent asynchronously. - * -@@ -424,44 +377,6 @@ extern struct nss_ctx_instance *nss_tls_ - * Pointer to the device. - */ - extern struct device *nss_tls_get_dev(struct nss_ctx_instance *nss_ctx); -- --/** -- * nss_tls_ifmap_get -- * Returns active TLS interfaces. -- * -- * @return -- * Pointer to the interface map. -- */ --unsigned long *nss_tls_ifmap_get(void); -- --/** -- * nss_tls_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_tls_stats_unregister_notifier(struct notifier_block *nb); -- --/** -- * nss_tls_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or non-zero on failure. -- */ --extern int nss_tls_stats_register_notifier(struct notifier_block *nb); -- - /** - * @} - */ ---- a/exports/nss_trustsec_tx.h -+++ b/exports/nss_trustsec_tx.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2017, 2020, 2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2017, 2020 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. -@@ -44,7 +44,7 @@ enum nss_trustsec_tx_msg_types { - * Error types for the TrustSec Tx interface. - */ - enum nss_trustsec_tx_error_types { -- NSS_TRUSTSEC_TX_ERR_NONE, /** No error. */ -+ NSS_TRUSTSEC_TX_ERR_NONE, /** No error */ - NSS_TRUSTSEC_TX_ERR_INVAL_SRC_IF, /** Source interface is invalid. */ - NSS_TRUSTSEC_TX_ERR_RECONFIGURE_SRC_IF, /** Source interface is already configured. */ - NSS_TRUSTSEC_TX_ERR_DEST_IF_NOT_FOUND, /** Destination interface is not found. */ ---- a/exports/nss_tunipip6.h -+++ b/exports/nss_tunipip6.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014, 2017-2018, 2020, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014, 2017-2018, 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. -@@ -23,154 +23,81 @@ - #define __NSS_TUNIPIP6_H - - /** -- * Maximum number of supported TUNIPIP6 tunnels. -- */ --#define NSS_TUNIPIP6_TUNNEL_MAX 32 -- --/** - * @addtogroup nss_tunipip6_subsystem - * @{ - */ - -+#define NSS_TUNIPIP6_MAX_FMR_NUMBER 4 /**< Maximum number of forward mapping rule (FMR). */ -+ - /** -- * nss_tunipip6_map_rule -- * Mapping rule (FMR/BMR) for forwarding traffic to the node in the same domain. -+ * nss_tunipip6_fmr -+ * Forward mapping rule (FMR) for direct forwarding traffic to the node in the same domain. - */ --struct nss_tunipip6_map_rule { -+struct nss_tunipip6_fmr { - uint32_t ip6_prefix[4]; /**< An IPv6 prefix assigned by a mapping rule. */ - uint32_t ip4_prefix; /**< An IPv4 prefix assigned by a mapping rule. */ - uint32_t ip6_prefix_len; /**< IPv6 prefix length. */ - uint32_t ip4_prefix_len; /**< IPv4 prefix length. */ -- uint32_t ip6_suffix[4]; /**< IPv6 suffix. */ -- uint32_t ip6_suffix_len; /**< IPv6 suffix length. */ - uint32_t ea_len; /**< Embedded Address (EA) bits. */ -- uint32_t psid_offset; /**< PSID offset default 6. */ --}; -- --/** -- * nss_tunipip6_err_types -- * Error types for response to messages from the host. -- */ --enum nss_tunipip6_err_types { -- NSS_TUNIPIP6_ERR_TYPE_MAX_TUNNELS, /**< Maximum number of tunnel reached. */ -- NSS_TUNIPIP6_ERR_TYPE_TUNNEL_EXIST, /**< Tunnel already exists. */ -- NSS_TUNIPIP6_ERR_TYPE_ENCAP_BAD_PARAM, /**< Bad configuration. */ -- NSS_TUNIPIP6_ERR_TYPE_ENCAP_FMR_EXIST, /**< FMR already exists. */ -- NSS_TUNIPIP6_ERR_TYPE_ENCAP_NO_FMR, /**< No FMR configured.*/ -- NSS_TUNIPIP6_ERR_TYPE_ENCAP_FMR_FULL, /**< FMR table is full. */ -- NSS_TUNIPIP6_ERR_TYPE_ENCAP_INVALID_FMR, /**< Invalid FMR configured.*/ -- NSS_TUNIPIP6_ERR_TYPE_ENCAP_BMR_EXIST, /**< BMR already exists. */ -- NSS_TUNIPIP6_ERR_TYPE_ENCAP_NO_BMR, /**< No BMR configured. */ -- NSS_TUNIPIP6_ERR_TYPE_ENCAP_FMR_MEM_ALLOC_FAILED, /**< Pool allocation for FMR failed. */ -- NSS_TUNIPIP6_ERR_TYPE_UNKNOWN, /**< Unknown message type. */ -- NSS_TUNIPIP6_ERROR_MAX, /**< Maximum number of errors. */ -+ uint32_t offset; /**< PSID offset default 6. */ - }; - - /** - * nss_tunipip6_metadata_types -- * Message types for TUNIPIP6 (IPv4 in IPv6) tunnel requests and responses. -+ * Message types for DS-Lite (IPv4 in IPv6) tunnel requests and responses. - */ - enum nss_tunipip6_metadata_types { - NSS_TUNIPIP6_TX_ENCAP_IF_CREATE, - NSS_TUNIPIP6_TX_DECAP_IF_CREATE, -- NSS_TUNIPIP6_STATS_SYNC, -- NSS_TUNIPIP6_FMR_RULE_ADD, -- NSS_TUNIPIP6_FMR_RULE_DEL, -- NSS_TUNIPIP6_FMR_RULE_FLUSH, -- NSS_TUNIPIP6_BMR_RULE_ADD, -- NSS_TUNIPIP6_BMR_RULE_DEL, -+ NSS_TUNIPIP6_RX_STATS_SYNC, - NSS_TUNIPIP6_MAX, - }; - - /** - * nss_tunipip6_create_msg -- * Payload for configuring the TUNIPIP6 interface. -+ * Payload for configuring the DS-Lite interface. - */ - struct nss_tunipip6_create_msg { -+ struct nss_tunipip6_fmr fmr[NSS_TUNIPIP6_MAX_FMR_NUMBER]; /**< Tunnel FMR array. */ - uint32_t saddr[4]; /**< Tunnel source address. */ - uint32_t daddr[4]; /**< Tunnel destination address. */ - uint32_t flowlabel; /**< Tunnel IPv6 flow label. */ - uint32_t flags; /**< Tunnel additional flags. */ -+ uint32_t fmr_number; /**< Tunnel FMR number. */ - uint32_t sibling_if_num; /**< Sibling interface number. */ -+ uint16_t reserved1; /**< Reserved for alignment. */ - uint8_t hop_limit; /**< Tunnel IPv6 hop limit. */ - uint8_t draft03; /**< Use MAP-E draft03 specification. */ -- uint8_t ttl_inherit; /**< Inherit IPv4 TTL to hoplimit. */ -- uint8_t tos_inherit; /**< Inherit IPv4 ToS. */ -- uint8_t frag_id_update; /**< Enable update of fragment identifier of IPv4. */ -- uint8_t reserved[3]; /**< Reserved bytes. */ -- uint32_t fmr_max; /**< Maximum number of FMRs that can be configured. */ --}; -- --/** -- * nss_tunipip6_debug_stats -- * TUNIPIP6 debug statistics. -- */ --struct nss_tunipip6_debug_stats { -- struct { -- struct { -- uint32_t low_headroom; /**< Low headroom for encapsulation. */ -- uint32_t unhandled_proto; /**< Unhandled protocol for encapsulation. */ -- } exp; -- -- struct { -- uint32_t enqueue_fail; /**< Encapsulation enqueue fail. */ -- } drop; -- -- struct { -- uint32_t err_tunnel_cfg; /**< Tunnel configuration error. */ -- uint32_t total_fmr; /**< Total number of existing FMRs. */ -- uint32_t fmr_add_req; /**< FMR add requests. */ -- uint32_t fmr_del_req; /**< FMR delete requests. */ -- uint32_t fmr_flush_req; /**< FMR flush requests. */ -- uint32_t fmr_update_req; /**< FMR update requests. */ -- uint32_t fmr_add_fail; /**< FMR addition failed. */ -- uint32_t fmr_del_fail; /**< FMR deletion failed. */ -- uint32_t err_no_fmr; /**< No FMR configured. */ -- uint32_t bmr_add_req; /**< BMR add requests. */ -- uint32_t bmr_del_req; /**< BMR delete requests. */ -- uint32_t err_bmr_exist; /**< BMR already configured. */ -- uint32_t err_no_bmr; /**< No BMR configured. */ -- } cfg; -- } encap; -- -- struct { -- struct { -- uint32_t enqueue_fail; /**< Decapsulation enqueue fail. */ -- } drop; -- } decap; - }; - - /** - * nss_tunipip6_stats_sync_msg -- * Message information for TUNIPIP6 synchronization statistics. -+ * Message information for DS-Lite synchronization statistics. - */ - struct nss_tunipip6_stats_sync_msg { -- struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ -- struct nss_tunipip6_debug_stats tun_stats; /**< TUNIPIP6 debug statistics. */ -+ struct nss_cmn_node_stats node_stats; /**< Common node statistics. */ - }; - - /** - * nss_tunipip6_msg -- * Data for sending and receiving TUNIPIP6 messages. -+ * Data for sending and receiving DS-Lite messages. - */ - struct nss_tunipip6_msg { - struct nss_cmn_msg cm; /**< Common message header. */ - - /** -- * Payload of a TUNIPIP6 message. -+ * Payload of a DS-Lite message. - */ - union { - struct nss_tunipip6_create_msg tunipip6_create; -- /**< Create a TUNIPIP6 tunnel. */ -- struct nss_tunipip6_stats_sync_msg stats; -- /**< Synchronized statistics for the TUNIPIP6 interface. */ -- struct nss_tunipip6_map_rule map_rule; -- /**< BMR/FMR rule to add/delete, new or existing rules. */ -- } msg; /**< Message payload for TUNIPIP6 messages exchanged with NSS core. */ -+ /**< Create a DS-Lite tunnel. */ -+ struct nss_tunipip6_stats_sync_msg stats_sync; -+ /**< Synchronized statistics for the DS-Lite interface. */ -+ } msg; /**< Message payload for IPIP6 Tunnel messages exchanged with NSS core. */ - }; - - /** -- * Callback function for receiving TUNIPIP6 messages. -+ * Callback function for receiving DS-Lite messages. - * - * @datatypes - * nss_tunipip6_msg -@@ -182,7 +109,7 @@ typedef void (*nss_tunipip6_msg_callback - - /** - * nss_tunipip6_tx -- * Sends a TUNIPIP6 message to NSS core. -+ * Sends a DS-Lite message to NSS core. - * - * @datatypes - * nss_ctx_instance \n -@@ -197,23 +124,7 @@ typedef void (*nss_tunipip6_msg_callback - extern nss_tx_status_t nss_tunipip6_tx(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *msg); - - /** -- * nss_tunipip6_tx_sync -- * Sends a TUNIPIP6 message to NSS core synchronously. -- * -- * @datatypes -- * nss_ctx_instance \n -- * nss_tunipip6_msg -- * -- * @param[in] nss_ctx Pointer to the NSS context. -- * @param[in] msg Pointer to the message data. -- * -- * @return -- * Status of the Tx operation. -- */ --extern nss_tx_status_t nss_tunipip6_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *msg); -- --/** -- * Callback function for receiving TUNIPIP6 data. -+ * Callback function for receiving DS-Lite data. - * - * @datatypes - * net_device \n -@@ -226,10 +137,10 @@ extern nss_tx_status_t nss_tunipip6_tx_s - */ - typedef void (*nss_tunipip6_callback_t)(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi); - --/** -+/* - * nss_register_tunipip6_if - * Registers the TUNIPIP6 interface with the NSS for sending and receiving -- * TUNIPIP6 messages. -+ * DS-Lite messages. - * - * @datatypes - * nss_tunipip6_callback_t \n -@@ -279,9 +190,9 @@ extern void nss_unregister_tunipip6_if(u - */ - extern void nss_tunipip6_msg_init(struct nss_tunipip6_msg *ntm, uint16_t if_num, uint32_t type, uint32_t len, void *cb, void *app_data); - --/** -+/* - * nss_tunipip6_get_context() -- * Get TUNIPIP6 context. -+ * Get tunipip6 context. - * - * @return - * Pointer to the NSS core context. ---- a/exports/nss_virt_if.h -+++ b/exports/nss_virt_if.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2017, 2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2017, 2019, 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. -@@ -93,8 +93,8 @@ struct nss_virt_if_interface_stats { - * Virtual interface statistics received from the NSS. - */ - struct nss_virt_if_stats { -- struct nss_virt_if_base_node_stats base_stats; /**< Virtual interface statistics of NSS base node. */ -- struct nss_virt_if_interface_stats if_stats; /**< Virtual interface statistics of each pair of interfaces. */ -+ struct nss_virt_if_base_node_stats base_stats; -+ struct nss_virt_if_interface_stats if_stats; - }; - - /** ---- a/exports/nss_vxlan.h -+++ b/exports/nss_vxlan.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019, 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. -@@ -53,11 +53,6 @@ - #define NSS_VXLAN_RULE_FLAG_UDP 0x0100 /**< UDP tunnel. */ - - /** -- * Flag used to set the IPSec interface number in the MAC add message for binding with VxLAN. -- */ --#define NSS_VXLAN_MAC_ENABLE_IPSEC_BIND 0x01 -- --/** - * nss_vxlan_msg_type - * Message types for VxLAN tunnel. - */ -@@ -116,8 +111,6 @@ struct nss_vxlan_stats_msg { - uint32_t except_vni_lookup_failed; /**< Virtual network ID look up failed. */ - uint32_t dropped_malformed; /**< Packet is malformed. */ - uint32_t dropped_next_node_queue_full; /**< Next node dropped the packet. */ -- uint32_t except_inner_hash; /**< Inner hash calculation failed. */ -- uint32_t decap_ipsec_src_err; /* Drops due to incorrect packet buffer source for VxLAN over IPSec flow. */ - }; - - /** -@@ -140,7 +133,7 @@ struct nss_vxlan_rule_msg { - */ - uint16_t flow_label; /**< Flow label. */ - uint8_t tos; /**< Type of service/traffic class. */ -- uint8_t ttl; /**< TTL/hop limit. */ -+ uint8_t ttl; /**< TTL/Hop Limit. */ - - /* - * L4 rules -@@ -168,9 +161,6 @@ struct nss_vxlan_mac_msg { - /**< Tunnel encapsulation header. */ - uint32_t vni; /**< VxLAN network identifier. */ - uint16_t mac_addr[3]; /**< MAC address. */ -- uint8_t reserved; /**< Reserved. */ -- uint8_t flags; /**< First bit set in the LSB indicates if IPSec is enabled. */ -- uint32_t ipsec_if_num; /**< IPSec source interface number. */ - }; - - /** ---- a/exports/nss_wifi.h -+++ b/exports/nss_wifi.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2015-2018, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2015-2018, 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. -@@ -35,8 +35,6 @@ - #define NSS_WIFI_IPV6_ADDR_LEN 16 /**< Size of the IPv6 address. */ - #define NSS_WIFI_MAX_RSSI_CHAINS 4 /**< Maximum number of RSSI chains. */ - #define NSS_WIFI_WME_NUM_AC 4 /**< Number of ACs. */ --#define NSS_WIFI_MIC_KEY_LEN 8 -- - - /** - * Maximum number of Wi-Fi peers per radio as a sum of -@@ -94,8 +92,6 @@ enum nss_wifi_metadata_types { - NSS_WIFI_OL_PEER_TIME_MSG, - NSS_WIFI_PEER_SET_VLAN_ID_MSG, - NSS_WIFI_PEER_ISOLATION_MSG, -- NSS_WIFI_PEER_AUTH_MSG, -- NSS_WIFI_PEER_SECURITY_CFG, - NSS_WIFI_MAX_MSG - }; - -@@ -638,11 +634,6 @@ struct nss_wifi_stats_sync_msg { - * Number of times a deny list was hit during multicast enhancement. - */ - uint32_t mc_enhance_denylist_hit; -- -- /** -- * Total number of data packets dropped for an unauthorized peer. -- */ -- uint32_t peer_unauth_rx_pkt_drop; - }; - - /** -@@ -650,8 +641,8 @@ struct nss_wifi_stats_sync_msg { - * Information for creating a Wi-Fi peer freelist. - */ - struct nss_wifi_peer_freelist_append_msg { -- uint32_t addr; /**< Starting address of the peer freelist pool. */ -- uint32_t length; /**< Size of the peer freelist pool. */ -+ uint32_t addr; /**< Starting address of peer freelist pool. */ -+ uint32_t length; /**< Size of peer freelist pool. */ - uint32_t num_peers; /**< Maximum peer entries supported in the pool. */ - }; - -@@ -718,7 +709,7 @@ struct nss_wifi_peer_ol_stats { - uint32_t tx_mcast; /**< Number of multicast packets sent. */ - uint32_t tx_ucast; /**< Number of unicast packets sent. */ - uint32_t tx_data; /**< Number data packets sent. */ -- uint32_t tx_bytes; /**< Number of bytes transmitted. */ -+ uint32_t tx_bytes; /**< Number of bytes sent. */ - uint32_t tx_fail; /**< Number of failed Tx packets. */ - uint32_t thrup_bytes; /**< Number of throughput bytes. */ - uint32_t tx_bcast_pkts; /**< Number of broadcast packets sent. */ -@@ -731,10 +722,6 @@ struct nss_wifi_peer_ol_stats { - uint32_t ppdu_retries; /**< Number of PPDU retries. */ - uint32_t rssi_chains[NSS_WIFI_MAX_RSSI_CHAINS]; - /**< Acknowledgment RSSI per chain. */ -- uint32_t rx_msdus; /**< Number of MSDUs received. */ -- uint32_t rx_bytes; /**< Number of bytes received. */ -- uint32_t rx_mpdus; /**< Number of MPDUs received. */ -- uint32_t rx_retries; /**< Number of MPDU retries. */ - }; - - /** -@@ -751,7 +738,7 @@ struct nss_wifi_ol_stats_msg { - - /** - * nss_wifi_sta_kickout_msg -- * Station kickout message from NSS firmware. -+ * Station kickout message from NSS Firmware - */ - struct nss_wifi_sta_kickout_msg { - uint32_t peer_id; /**< Peer ID. */ -@@ -766,18 +753,9 @@ struct nss_wifi_peer_isolation_msg { - uint16_t isolation; /**< Isolation enabled/disabled. */ - }; - --/* -- * nss_wifi_peer_auth_msg -- * Peer authentication flag status. -- */ --struct nss_wifi_peer_auth_msg { -- uint16_t peer_id; /**< Peer ID. */ -- uint16_t auth_flag; /**< Peer authentication flag. */ --}; -- - /** - * nss_wifi_wnm_peer_rx_activity_msg -- * Receive active state information for the peer. -+ * Rx active state information for the peer. - */ - struct nss_wifi_wnm_peer_rx_activity_msg { - uint16_t nentries; /**< Number of entries. */ -@@ -789,17 +767,6 @@ struct nss_wifi_wnm_peer_rx_activity_msg - }; - - /** -- * nss_wifi_peer_security_type_msg -- * Wi-fi security type message. -- */ --struct nss_wifi_peer_security_type_msg { -- uint16_t peer_id; /**< Peer ID. */ -- uint8_t pkt_type; /**< Unicast or broadcast packet type. */ -- uint8_t security_type; /**< Security type. */ -- uint8_t mic_key[NSS_WIFI_MIC_KEY_LEN]; /**< MIC key. */ --}; -- --/** - * nss_wifi_append_metaheader - * Append metaheader after pbuf->data for stats_v2. - */ -@@ -946,21 +913,17 @@ struct nss_wifi_msg { - struct nss_wifi_cmd_msg wcmdm; - /**< Pdev command information. */ - struct nss_wifi_enable_ol_statsv2 wesh_msg; -- /**< Enable version 2 transmit/receive statistics. */ -+ /**< Enable version 2 tx/rx stats. */ - struct nss_wifi_ol_peer_time_msg wopt_msg; - /**< Send per peer/TID timestamp statistics to host. */ - struct nss_wifi_peer_isolation_msg isolation_msg; - /**< Enable or disable peer isolation. */ -- struct nss_wifi_peer_auth_msg auth_msg; -- /**< Enable or disable peer authorization. */ -- struct nss_wifi_peer_security_type_msg securitymsg; -- /**< Wifili peer security message. */ - } msg; /**< Message Payload. */ - }; - - /** - * nss_wifi_get_context -- * Gets the Wi-Fi context used in NSS GRE transmit. -+ * Gets the Wi-Fi context used in nss_gre_tx. - * - * @return - * Pointer to the NSS core context. ---- /dev/null -+++ b/exports/nss_wifi_if.h -@@ -0,0 +1,292 @@ -+/* -+ ************************************************************************** -+ * Copyright (c) 2015-2017, 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. -+ ************************************************************************** -+ */ -+ -+/** -+ * @file nss_wifi_if.h -+ * NSS Wi-Fi interface message Structure and APIs. -+ */ -+ -+#ifndef __NSS_WIFI_IF_H -+#define __NSS_WIFI_IF_H -+ -+/** -+ * @addtogroup nss_wifi_subsystem -+ * @{ -+ */ -+ -+/** -+ * nss_wifi_if_msg_types -+ * Message types for Wi-Fi interface requests and responses. -+ */ -+enum nss_wifi_if_msg_types { -+ NSS_WIFI_IF_OPEN = NSS_IF_OPEN, -+ NSS_WIFI_IF_CLOSE = NSS_IF_CLOSE, -+ NSS_WIFI_IF_LINK_STATE_NOTIFY = NSS_IF_LINK_STATE_NOTIFY, -+ NSS_WIFI_IF_MTU_CHANGE = NSS_IF_MTU_CHANGE, -+ NSS_WIFI_IF_MAC_ADDR_SET = NSS_IF_MAC_ADDR_SET, -+ NSS_WIFI_IF_STATS_SYNC = NSS_IF_STATS, -+ NSS_WIFI_IF_ISHAPER_ASSIGN = NSS_IF_ISHAPER_ASSIGN, -+ NSS_WIFI_IF_BSHAPER_ASSIGN = NSS_IF_BSHAPER_ASSIGN, -+ NSS_WIFI_IF_ISHAPER_UNASSIGN = NSS_IF_ISHAPER_UNASSIGN, -+ NSS_WIFI_IF_BSHAPER_UNASSIGN = NSS_IF_BSHAPER_UNASSIGN, -+ NSS_WIFI_IF_ISHAPER_CONFIG = NSS_IF_ISHAPER_CONFIG, -+ NSS_WIFI_IF_BSHAPER_CONFIG = NSS_IF_BSHAPER_CONFIG, -+ NSS_WIFI_IF_VSI_ASSIGN = NSS_IF_VSI_ASSIGN, -+ NSS_WIFI_IF_VSI_UNASSIGN = NSS_IF_VSI_UNASSIGN, -+ NSS_WIFI_IF_TX_CREATE_MSG = NSS_IF_MAX_MSG_TYPES + 1, -+ NSS_WIFI_IF_TX_DESTROY_MSG, -+ NSS_WIFI_IF_STATS_SYNC_MSG, -+ NSS_WIFI_IF_MAX_MSG_TYPES -+}; -+ -+/** -+ * nss_wifi_if_error_types -+ * Error types for the Wi-Fi interface. -+ */ -+enum nss_wifi_if_error_types { -+ NSS_WIFI_IF_SUCCESS, -+ NSS_WIFI_IF_CORE_FAILURE, -+ NSS_WIFI_IF_ALLOC_FAILURE, -+ NSS_WIFI_IF_DYNAMIC_IF_FAILURE, -+ NSS_WIFI_IF_MSG_TX_FAILURE, -+ NSS_WIFI_IF_REG_FAILURE, -+ NSS_WIFI_IF_CORE_NOT_INITIALIZED -+}; -+ -+/** -+ * nss_wifi_if_create_msg -+ * Payload for configuring the Wi-Fi interface. -+ */ -+struct nss_wifi_if_create_msg { -+ uint32_t flags; /**< Interface flags. */ -+ uint8_t mac_addr[ETH_ALEN]; /**< MAC address. */ -+}; -+ -+/** -+ * nss_wifi_if_destroy_msg -+ * Payload for destroying the Wi-Fi interface. -+ */ -+struct nss_wifi_if_destroy_msg { -+ int32_t reserved; /**< Placeholder. */ -+}; -+ -+/** -+ * nss_wifi_if_stats -+ * Wi-Fi interface statistics received from the NSS. -+ */ -+struct nss_wifi_if_stats { -+ struct nss_cmn_node_stats node_stats; -+ /**< Common statistics. */ -+ uint32_t tx_enqueue_failed; -+ /**< Number of packets dropped when queuing to the next node in a network graph. */ -+ uint32_t shaper_enqueue_failed; -+ /**< Number of packets dropped when queuing to the shaper node. */ -+}; -+ -+/** -+ * nss_wifi_if_msg -+ * Data for sending and receiving Wi-Fi interface messages. -+ */ -+struct nss_wifi_if_msg { -+ struct nss_cmn_msg cm; /**< Common message header. */ -+ -+ /** -+ * Payload of a Wi-Fi interface message. -+ */ -+ union { -+ union nss_if_msgs if_msgs; -+ /**< NSS interface messages. */ -+ struct nss_wifi_if_create_msg create; -+ /**< Creates a Wi-Fi interface rule. */ -+ struct nss_wifi_if_destroy_msg destroy; -+ /**< Destroys a Wi-Fi interface rule. */ -+ struct nss_wifi_if_stats stats; -+ /**< Interface statistics. */ -+ } msg; /**< Message payload. */ -+}; -+ -+/** -+ * nss_wifi_if_pvt -+ * Private data information for the Wi-Fi interface. -+ */ -+struct nss_wifi_if_pvt { -+ struct semaphore sem; -+ /**< Semaphore for a specified Wi-Fi interface number. */ -+ struct completion complete; -+ /**< Waits for the NSS to process a message on the specified Wi-Fi interface. */ -+ int response; /**< Response received on a Wi-Fi interface number. */ -+ int sem_init_done; -+ /**< Indicates whether the semaphore is initialized. */ -+}; -+ -+/** -+ * Callback function for receiving Wi-Fi data. -+ * -+ * @datatypes -+ * net_device \n -+ * sk_buff \n -+ * napi_struct -+ * -+ * @param[in] netdev Pointer to the associated network device. -+ * @param[in] skb Pointer to the data socket buffer. -+ * @param[in] napi Pointer to the NAPI structure. -+ */ -+typedef void (*nss_wifi_if_data_callback_t)(struct net_device *netdev, -+ struct sk_buff *skb, struct napi_struct *napi); -+ -+/** -+ * Callback function for receiving Wi-Fi messages. -+ * -+ * @datatypes -+ * nss_cmn_msg -+ * -+ * @param[in] app_data Pointer to the application context of the message. -+ * @param[in] msg Pointer to the message data. -+ */ -+typedef void (*nss_wifi_if_msg_callback_t)(void *app_data, -+ struct nss_cmn_msg *msg); -+ -+/** -+ * nss_wifi_if_handle -+ * Context for WLAN-to-NSS communication. -+ */ -+struct nss_wifi_if_handle { -+ struct nss_ctx_instance *nss_ctx; /**< NSS context. */ -+ int32_t if_num; /**< Interface number. */ -+ struct nss_wifi_if_pvt *pvt; /**< Private data structure. */ -+ struct nss_wifi_if_stats stats; -+ /**< Statistics corresponding to this handle. */ -+ nss_wifi_if_msg_callback_t cb; -+ /**< Callback registered by other modules. */ -+ void *app_data; -+ /**< Application context to be passed to that callback. */ -+}; -+ -+/** -+ * nss_wifi_if_tx_msg -+ * Sends a message to the Wi-Fi interface. -+ * -+ * @datatypes -+ * nss_ctx_instance \n -+ * nss_wifi_if_msg -+ * -+ * @param[in] nss_ctx Pointer to the NSS context (provided during registration). -+ * @param[in] nwim Pointer to the Wi-Fi interface message. -+ * -+ * @return -+ * Status of the Tx operation. -+ */ -+extern nss_tx_status_t nss_wifi_if_tx_msg(struct nss_ctx_instance *nss_ctx, -+ struct nss_wifi_if_msg *nwim); -+ -+/** -+ * nss_wifi_if_register -+ * Registers a Wi-Fi interface with the NSS driver. -+ * -+ * @datatypes -+ * nss_wifi_if_handle \n -+ * nss_wifi_if_data_callback_t \n -+ * net_device -+ * -+ * @param[in] handle Pointer to the Wi-Fi context (provided during Wi-Fi -+ * interface allocation). -+ * @param[in] rx_callback Callback handler for Wi-Fi data packets. -+ * @param[in] netdev Pointer to the associated network device. -+ * -+ * @return -+ * None. -+ */ -+extern void nss_wifi_if_register(struct nss_wifi_if_handle *handle, -+ nss_wifi_if_data_callback_t rx_callback, -+ struct net_device *netdev); -+ -+/** -+ * nss_wifi_if_unregister -+ * Deregisters a Wi-Fi interface from the NSS driver. -+ * -+ * @datatypes -+ * nss_wifi_if_handle -+ * -+ * @param[in] handle Pointer to the Wi-Fi context. -+ * -+ * @return -+ * None. -+ */ -+extern void nss_wifi_if_unregister(struct nss_wifi_if_handle *handle); -+ -+/** -+ * nss_wifi_if_create_sync -+ * Creates a Wi-Fi interface. -+ * -+ * @datatypes -+ * net_device -+ * -+ * @param[in] netdev Pointer to the associated network device. -+ * -+ * @return -+ * Pointer to the Wi-Fi handle. -+ */ -+extern struct nss_wifi_if_handle *nss_wifi_if_create_sync(struct net_device *netdev); -+ -+/** -+ * nss_wifi_if_destroy_sync -+ * Destroys the Wi-Fi interface associated with the interface number. -+ * -+ * @datatypes -+ * nss_wifi_if_handle -+ * -+ * @param[in] handle Pointer to the Wi-Fi handle. -+ * -+ * @return -+ * Status of the Tx operation. -+ */ -+extern nss_tx_status_t nss_wifi_if_destroy_sync(struct nss_wifi_if_handle *handle); -+ -+/** -+ * nss_wifi_if_tx_buf -+ * Sends a data packet or buffer to the NSS. -+ * -+ * @datatypes -+ * nss_wifi_if_handle \n -+ * sk_buff -+ * -+ * @param[in] handle Context associated with the interface. -+ * @param[in] skb Pointer to the data socket buffer. -+ * -+ * @return -+ * Status of the Tx operation. -+ */ -+extern nss_tx_status_t nss_wifi_if_tx_buf(struct nss_wifi_if_handle *handle, -+ struct sk_buff *skb); -+ -+/** -+ * nss_wifi_if_copy_stats -+ * Copies Wi-Fi interface statistics for display. -+ * -+ * @param[in] if_num NSS interface number. -+ * @param[in] index Index in the statistics array. -+ * @param[out] line Pointer to the buffer into which the statistics are copied. -+ * -+ * @return -+ * Number of bytes copied. -+ */ -+int32_t nss_wifi_if_copy_stats(int32_t if_num, int index, char *line); -+ -+/** -+ * @} -+ */ -+ -+#endif /* __NSS_WIFI_IF_H */ ---- a/exports/nss_wifi_mac_db_if.h -+++ b/exports/nss_wifi_mac_db_if.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -25,18 +25,6 @@ - - #define NSS_WIFI_MAC_DB_ENTRY_IF_LOCAL 0x1 - -- /** -- * @addtogroup nss_wifi_mac_db_if_subsystem -- * @{ -- */ -- --/* -- * MAX Wi-Fi MAC database entries sent in group -- * is chosen considering the entry size and -- * maximum entries a smallest buffer could accomodate. -- */ --#define NSS_WIFI_MAC_DB_GROUP_ENTRIES_MAX 48 -- - /** - * nss_wifi_mac_db_msg_types - * Wi-Fi MAC database messages. -@@ -47,9 +35,6 @@ enum nss_wifi_mac_db_msg_types { - NSS_WIFI_MAC_DB_DEL_ENTRY_MSG, /**< Wi-Fi MAC database delete entry message. */ - NSS_WIFI_MAC_DB_UPDATE_ENTRY_MSG, /**< Wi-Fi MAC database update entry message. */ - NSS_WIFI_MAC_DB_DEINIT_MSG, /**< Wi-Fi MAC database deinitialization message. */ -- NSS_WIFI_MAC_DB_GROUP_ENTRIES_ADD_MSG, /**< Wi-Fi MAC database group entries add message. */ -- NSS_WIFI_MAC_DB_ENTRY_ACTIVITY_MSG, /**< Wi-Fi MAC database entry activity message. */ -- NSS_WIFI_MAC_DB_CREATE_ENTRY_MSG, /**< Wi-Fi MAC database entry create message. */ - NSS_WIFI_MAC_DB_MAX_MSG - }; - -@@ -77,84 +62,11 @@ enum nss_wifi_mac_db_if_opmode { - }; - - /** -- * nss_wifi_mac_db_err_types -- * Wi-Fi MAC database errors. -- */ --enum nss_wifi_mac_db_err_types { -- NSS_WIFI_MAC_DB_ERROR_NONE, -- /**< Wi-Fi MAC database error none. */ -- NSS_WIFI_MAC_DB_ERROR_ENTRY_ALLOC_FAIL, -- /**< Error used to report a Wi-Fi MAC database entry pool allocation failure. */ -- NSS_WIFI_MAC_DB_ERROR_MAC_EXISTS, -- /**< Error used to report that a Wi-Fi MAC database entry already exists. */ -- NSS_WIFI_MAC_DB_ERROR_MAC_TABLE_FULL, -- /**< Error used to report that a Wi-Fi MAC table is full. */ -- NSS_WIFI_MAC_DB_ERROR_MAC_ENTRY_ALLOC_FAILED, -- /**< Error used to report a Wi-Fi MAC database entry allocation failure. */ -- NSS_WIFI_MAC_DB_ERROR_ENTRY_NOT_FOUND, -- /**< Error used to report that a Wi-Fi MAC database entry is not present. */ -- NSS_WIFI_MAC_DB_ERROR_MAC_ENTRY_UNHASHED, -- /**< Error used to report that a Wi-Fi MAC database entry is unhashed. */ -- NSS_WIFI_MAC_DB_ERROR_MAC_ENTRY_DELETE_FAILED, -- /**< Error used to report a Wi-Fi MAC database entry delete failure. */ -- NSS_WIFI_MAC_DB_ERROR_INVALID_NUM_ENTRIES_FAIL, -- /**< Error used to report the number of invalid Wi-Fi MAC database entries. */ -- NSS_WIFI_MAC_DB_ERROR_NOT_ALLOCATED_FAIL, -- /**< Error used to report that a Wi-Fi MAC database is not allocated. */ -- NSS_WIFI_MAC_DB_ERROR_INV_IF_RECVD_FAIL, -- /**< Error used to report that a Wi-Fi MAC database entry interface is invalid. */ -- NSS_WIFI_MAC_DB_ERROR_INVALID_EVENT, -- /**< Error used to report that a Wi-Fi MAC database event is invalid. */ -- NSS_WIFI_MAC_DB_ERROR_PN_INVALID, -- /**< Error used to report that a Wi-Fi MAC database entry pnode is invalid. */ -- NSS_WIFI_MAC_DB_ERROR_PHY_PN_INVALID, -- /**< Error used to report that a Wi-Fi MAC database entry radio pnode is invalid. */ -- NSS_WIFI_MAC_DB_ERROR_ENTRY_POOL_INVALID, -- /**< Error used to report that a Wi-Fi MAC database entry pool is invalid. */ -- NSS_WIFI_MAC_DB_ERROR_ENTRY_POOL_ALREADY_ALLOCATED, -- /**< Error used to report that a Wi-Fi MAC database entry pool exists. */ -- NSS_WIFI_MAC_DB_ERROR_GROUP_ENTRY_ADD_FAIL, -- /**< Error used to report that a Wi-Fi MAC database group entry add failure. */ -- NSS_WIFI_MAC_DB_ERROR_MAX, -- /**< Wi-Fi MAC database error maximum. */ --}; -- --/** -- * nss_wifi_mac_db_entry_create_msg -- * Wi-Fi MAC database entry create message. -- */ --struct nss_wifi_mac_db_entry_create_msg { -- uint8_t mac_addr[ETH_ALEN]; /**< MAC address. */ -- uint16_t reserved; /**< Reserved bytes. */ -- int32_t nss_if; /**< NSS interface number. */ --}; -- --/** -- * nss_wifi_mac_db_entry_activity_info -- * Wi-Fi MAC database entry activity information. -- */ --struct nss_wifi_mac_db_entry_activity_info { -- uint8_t mac_addr[ETH_ALEN]; /**< MAC address. */ -- uint16_t reserved; /**< Reserved bytes. */ -- int32_t nss_if; /**< NSS interface number. */ --}; -- --/** -- * nss_wifi_mac_db_entry_activity_info_msg -- * Wi-Fi MAC database entry activity information message. -- */ --struct nss_wifi_mac_db_entry_activity_info_msg { -- uint32_t nentries; /**< Number of entries. */ -- struct nss_wifi_mac_db_entry_activity_info info[1]; -- /**< Wi-Fi MAC database entry activity information. */ --}; -- --/** - * nss_wifi_mac_db_entry_info_msg - * Wi-Fi MAC database entry information. - */ - struct nss_wifi_mac_db_entry_info_msg { -- uint8_t mac_addr[ETH_ALEN]; /**< MAC address. */ -+ uint8_t mac_addr[6]; /**< MAC address. */ - uint16_t flag; /**< Flag information about NSS interface. */ - int32_t nss_if; /**< NSS interface number. */ - uint32_t iftype; /**< NSS interface type. */ -@@ -163,17 +75,6 @@ struct nss_wifi_mac_db_entry_info_msg { - }; - - /** -- * nss_wifi_mac_db_entry_group_info_msg -- * Wi-Fi MAC database group of entries information. -- */ --struct nss_wifi_mac_db_entry_group_info_msg { -- uint32_t num_entries; -- /**< Number of entries in group information message. */ -- struct nss_wifi_mac_db_entry_info_msg entry[NSS_WIFI_MAC_DB_GROUP_ENTRIES_MAX]; -- /**< Wi-Fi MAC database information specific message. */ --}; -- --/** - * nss_wifi_mac_db_msg - * Structure that describes Wi-Fi MAC database messages. - */ -@@ -186,12 +87,6 @@ struct nss_wifi_mac_db_msg { - union { - struct nss_wifi_mac_db_entry_info_msg nmfdbeimsg; - /**< Wi-Fi MAC database information specific message. */ -- struct nss_wifi_mac_db_entry_group_info_msg nmfdbegimsg; -- /**< Wi-Fi MAC database information specific message. */ -- struct nss_wifi_mac_db_entry_activity_info_msg nmfdbeact_imsg; -- /**< Wi-Fi MAC database entry activity information message. */ -- struct nss_wifi_mac_db_entry_create_msg nmfdbecmsg; -- /**< Wi-Fi MAC database entry create message. */ - } msg; /**< Message payload. */ - }; - -@@ -280,9 +175,4 @@ struct nss_ctx_instance *nss_register_wi - */ - void nss_unregister_wifi_mac_db_if(uint32_t if_num); - struct nss_ctx_instance *nss_wifi_mac_db_get_context(void); -- --/** -- * @} -- */ -- - #endif /* __NSS_WIFI_MAC_DB_H */ ---- a/exports/nss_wifi_vdev.h -+++ b/exports/nss_wifi_vdev.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2015-2020, 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. -@@ -16,7 +16,7 @@ - - /** - * @file nss_wifi_vdev.h -- * NSS-to-HLOS Wi-Fi virtual device interface definitions. -+ * NSS TO HLOS Wi-Fi virtual device interface definitions. - */ - - #ifndef __NSS_WIFI_VDEV_H -@@ -31,7 +31,6 @@ - /**< Offset of the metadata in a virtual device message. */ - #define NSS_WIFI_VDEV_DSCP_MAP_LEN 64 /**< Length of the DSCP MAP field. */ - #define NSS_WIFI_VDEV_IPV6_ADDR_LENGTH 16 /**< Size of the IPv6 address field. */ --#define NSS_WIFI_VDEV_IPV6_ADDR_WORDS 4 /**< Size of the IPv6 address field in words. */ - #define NSS_WIFI_MAX_SRCS 4 /**< Maximum number of multicast sources. */ - #define NSS_WIFI_VDEV_MAX_ME_ENTRIES 32 /**< Maximum number of multicast enhancement entries. */ - -@@ -75,8 +74,6 @@ enum nss_wifi_vdev_msg_types { - NSS_WIFI_VDEV_INTERFACE_RECOVERY_RESET_MSG, - NSS_WIFI_VDEV_INTERFACE_RECOVERY_RECONF_MSG, - NSS_WIFI_VDEV_SET_GROUP_KEY, -- NSS_WIFI_VDEV_HMMC_MEMBER_ADD_MSG, -- NSS_WIFI_VDEV_HMMC_MEMBER_DEL_MSG, - NSS_WIFI_VDEV_MAX_MSG - }; - -@@ -131,15 +128,6 @@ enum nss_wifi_vdev_err_types { - NSS_WIFI_VDEV_VLAN_MODE_CONFIG_FAIL, - NSS_WIFI_VDEV_RECOVERY_RESET_FAIL, - NSS_WIFI_VDEV_RECOVERY_RECONF_FAIL, -- NSS_WIFI_VDEV_CONFIG_GROUP_KEY_FAIL, -- NSS_WIFI_VDEV_MULTIPASS_NOT_ENABLED, -- NSS_WIFI_VDEV_ALLOC_VLAN_MAP_FAILED, -- NSS_WIFI_VDEV_MTU_CHANGE_FAIL, -- NSS_WIFI_VDEV_MAC_ADDR_CHANGE_FAIL, -- NSS_WIFI_VDEV_PPE_PORT_CREATE_FAIL, -- NSS_WIFI_VDEV_PPE_PORT_DESTROY_FAIL, -- NSS_WIFI_VDEV_PPE_VSI_ASSIGN_FAIL, -- NSS_WIFI_VDEV_PPE_VSI_UNASSIGN_FAIL, - NSS_WIFI_VDEV_EINV_MAX_CFG - }; - -@@ -162,14 +150,6 @@ enum nss_wifi_vdev_ext_data_pkt_type { - NSS_WIFI_VDEV_EXT_TX_COMPL_PKT_TYPE = 11, /**< Tx completion. */ - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_WDS_LEARN = 12, /**< WDS source port learning command. */ - NSS_WIFI_VDEV_EXT_DATA_PPDU_INFO = 13, /**< PPDU metadata information. */ -- NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_MCBC_RX = 14, /**< Multicast/broadcast packet received. */ -- NSS_WIFI_VDEV_MESH_EXT_DATA_PKT_TYPE_RX_SPL_PACKET = 15, -- /**< Mesh link VAP special packet. */ -- NSS_WIFI_VDEV_MESH_EXT_DATA_PKT_TYPE_RX_MCAST_EXC = 16, -- /**< Mesh link VAP multicast packet. */ -- NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_4ADDR = 17, /**< 4 address exception to host. */ -- NSS_WIFI_VDEV_EXT_DATA_MPDU_INFO = 18, /**< MPDU metadata information. */ -- NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_EAPOL = 19, /**< EAPOL packets. */ - NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_MAX - }; - -@@ -200,13 +180,6 @@ enum nss_wifi_vdev_cmd { - NSS_WIFI_VDEV_CFG_AST_OVERRIDE_CMD, /**< Configuration to set AST (Address Search Table) override on VAP. */ - NSS_WIFI_VDEV_CFG_SON_CAP_CMD, /**< Configuration to set software defined network capability on VAP. */ - NSS_WIFI_VDEV_CFG_MULTIPASS_CMD, /**< Configuration to enable multipass phrase capability on VAP. */ -- NSS_WIFI_VDEV_CFG_HLOS_TID_OVERRIDE_CMD, -- /**< Configuration to enable HLOS TID override on VAP. */ -- NSS_WIFI_VDEV_ENABLE_IGMP_ME_CMD, /**< Configuration to set IGMP multicast enhancement on VAP. */ -- NSS_WIFI_VDEV_CFG_WDS_BACKHAUL_CMD, -- /**< Configuration to set WDS backhaul extension on VAP. */ -- NSS_WIFI_VDEV_CFG_MCBC_EXC_TO_HOST_CMD, /**< Configuration to set multicast/broadcast exception to host on VAP. */ -- NSS_WIFI_VDEV_DROP_3ADDR_MCAST_CMD, /**< Configuration to drop multicast three address frames. */ - NSS_WIFI_VDEV_MAX_CMD - }; - -@@ -242,11 +215,6 @@ enum nss_wifi_vdev_vlan_tagging_mode { - NSS_WIFI_VDEV_VLAN_MAX /**< Wi-Fi maximum VLAN support type. */ - }; - --enum vap_ext_mode { -- WIFI_VDEV_EXT_MODE_MESH_LINK = 1, /* Wi-Fi mesh VAP mode */ -- WIFI_VDEV_EXT_MODE_MAX, /* Wi-Fi maximum VAP mode */ --}; -- - /** - * nss_wifi_vdev_config_msg - * Virtual device configuration. -@@ -272,9 +240,7 @@ struct nss_wifi_vdev_config_msg { - /**< VAP is configured as a smart monitor VAP. */ - uint8_t is_wrap; /**< Specifies whether the VAP is a WRAP-AP. */ - uint8_t is_nss_qwrap_en; /**< VAP is configured for NSS firmware QWRAP logic. */ -- uint8_t tx_per_pkt_vdev_id_check; /**< Transmit per-packet virtual device ID check. */ -- uint8_t align_pad; /**< Reserved field. */ -- uint32_t vap_ext_mode; /**< Different VAP extended modes. */ -+ uint8_t reserved[2]; /**< Reserved for 4-byte alignment padding. */ - }; - - /** -@@ -345,7 +311,7 @@ struct nss_wifi_vdev_me_snptbl_grp_creat - union { - uint32_t grpaddr_ip4; - /**< IPv4 address. */ -- uint32_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_WORDS]; -+ uint8_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; - /**< IPv6 address. */ - } u; /**< IP address of the multicast group. */ - -@@ -366,7 +332,7 @@ struct nss_wifi_vdev_me_snptbl_grp_delet - union { - uint32_t grpaddr_ip4; - /**< IPv4 address. */ -- uint32_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_WORDS]; -+ uint8_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; - /**< IPv6 address. */ - } u; /**< IP address of the multicast group. */ - -@@ -397,7 +363,7 @@ struct nss_wifi_vdev_me_snptbl_grp_mbr_a - union { - uint32_t grpaddr_ip4; - /**< IPv4 address. */ -- uint32_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_WORDS]; -+ uint8_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; - /**< IPv6 address. */ - } u; /**< IP address of the multicast group. */ - -@@ -427,7 +393,7 @@ struct nss_wifi_vdev_me_snptbl_grp_mbr_d - union { - uint32_t grpaddr_ip4; - /**< IPv4 address. */ -- uint32_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_WORDS]; -+ uint8_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; - /**< IPv6 address. */ - }u; /**< IP address of the multicast group. */ - uint8_t grp_addr[ETH_ALEN]; -@@ -449,7 +415,7 @@ struct nss_wifi_vdev_me_snptbl_grp_mbr_u - union { - uint32_t grpaddr_ip4; - /**< IPv4 address. */ -- uint32_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_WORDS]; -+ uint8_t grpaddr_ip6[NSS_WIFI_VDEV_IPV6_ADDR_LENGTH]; - /**< IPv6 address. */ - }u; /**< IP address of the multicast group. */ - -@@ -464,66 +430,6 @@ struct nss_wifi_vdev_me_snptbl_grp_mbr_u - }; - - /** -- * nss_wifi_vdev_me_hmmc_add_msg -- * Information for adding an entry into the host-managed multicast list. -- */ --struct nss_wifi_vdev_me_hmmc_add_msg { -- uint32_t ether_type; /**< IPv4 or IPv6. */ -- union { -- uint32_t ipv4_addr; -- /**< IPv4 multicast group address. */ -- uint32_t ipv6_addr[NSS_WIFI_VDEV_IPV6_ADDR_WORDS]; -- /**< IPv6 multicast group address. */ -- } u; /**< Type of group addresses. */ -- uint32_t netmask; /**< IP subnet netmask. */ --}; -- --/** -- * nss_wifi_vdev_me_hmmc_del_msg -- * Information for deleting an entry from the host-managed multicast list. -- */ --struct nss_wifi_vdev_me_hmmc_del_msg { -- uint32_t ether_type; /**< IPv4 or IPv6. */ -- union { -- uint32_t ipv4_addr; -- /**< IPv4 multicast group address. */ -- uint32_t ipv6_addr[NSS_WIFI_VDEV_IPV6_ADDR_WORDS]; -- /**< IPv6 multicast group address. */ -- } u; /**< Type of group addresses. */ -- uint32_t netmask; /**< IP subnet netmask. */ --}; -- --/** -- * nss_wifi_vdev_me_deny_ip_add_msg -- * Information for adding an entry into the denylist. -- */ --struct nss_wifi_vdev_me_deny_ip_add_msg { -- uint32_t ether_type; /**< IPv4 or IPv6. */ -- union { -- uint32_t ipv4_addr; -- /**< IPv4 multicast group address. */ -- uint32_t ipv6_addr[NSS_WIFI_VDEV_IPV6_ADDR_WORDS]; -- /**< IPv6 multicast group address. */ -- } u; /**< Type of group addresses. */ -- uint32_t netmask; /**< IP subnet netmask. */ --}; -- --/** -- * nss_wifi_vdev_me_deny_ip_del_msg -- * Information for deleting an entry from the denylist. -- */ --struct nss_wifi_vdev_me_deny_ip_del_msg { -- uint32_t ether_type; /**< IPv4 or IPv6. */ -- union { -- uint32_t ipv4_addr; -- /**< IPv4 multicast group address. */ -- uint32_t ipv6_addr[NSS_WIFI_VDEV_IPV6_ADDR_WORDS]; -- /**< IPv6 multicast group address. */ -- } u; /**< Type of group addresses. */ -- uint32_t netmask; /**< IP subnet netmask. */ --}; -- --/** - * nss_wifi_vdev_me_snptbl_deny_grp_add_msg - * Information for adding a snooplist member to a deny list. - */ -@@ -818,49 +724,6 @@ struct nss_wifi_vdev_ppdu_metadata { - }; - - /** -- * nss_wifi_vdev_peer_mpdu_metadata -- * MPDU metadata. -- */ --struct nss_wifi_vdev_peer_mpdu_metadata { -- uint16_t peer_id; /**< Corresponding peer ID. */ -- uint8_t tid; /**< TID of the flow or MPDU queue. */ -- uint8_t msdu_info; /**< First or last MSDU information. */ -- uint32_t ppdu_id; /**< PPDU ID. */ -- uint32_t tsf; /**< Timing synchronization function. */ -- uint8_t transmit_cnt; /**< Transmission count. */ -- uint8_t status; /**< Frame acknowledged/failed. */ -- uint16_t reserved; /**< Reserved. */ --}; -- --/** -- * nss_wifi_vdev_eapol_mdata_dir -- * EAPOL metadata direction. -- */ --enum nss_wifi_vdev_eapol_mdata_dir { -- WIFI_VDEV_EAPOL_MDATA_TX, /**< EAPOL metadata for transmit direction. */ -- WIFI_VDEV_EAPOL_MDATA_RX /**< EAPOL metadata for receive direction. */ --}; -- --/** -- * nss_wifi_vdev_eapol_metadata -- * Metadata per EAPOL packet. -- */ --struct nss_wifi_vdev_eapol_per_packet_metadata { -- enum nss_wifi_vdev_eapol_mdata_dir dir; /**< EAPOL metadata direction. */ -- uint16_t peer_id; /**< Peer ID. */ --}; -- --/** -- * nss_wifi_vdev_addr4_data_metadata -- * Address 4 metadata -- */ --struct nss_wifi_vdev_addr4_data_metadata { -- uint16_t peer_id; /**< Peer ID. */ -- uint8_t sa_valid; /**< Source address is valid. */ -- uint8_t addr4_valid; /**< Address 4 is valid. */ --}; -- --/** - * nss_wifi_vdev_per_packet_metadata - * Wi-Fi per packet metadata content. - */ -@@ -889,12 +752,6 @@ struct nss_wifi_vdev_per_packet_metadata - /**< Per packet Tx metadata structure for wireless distribution system mode. */ - struct nss_wifi_vdev_ppdu_metadata ppdu_metadata; - /**< Per packet PPDU metadata needed for per PPDU copy mode. */ -- struct nss_wifi_vdev_addr4_data_metadata addr4_metadata; -- /**< Create metadata for the WDS extension interface. */ -- struct nss_wifi_vdev_peer_mpdu_metadata mpdu_metadata; -- /**< Per packet Tx metadata structure for Tx capture info per MPDU. */ -- struct nss_wifi_vdev_eapol_per_packet_metadata eapol_metadata; -- /**< Per packet metadata structure for EAPOL. */ - } metadata; - /**< Metadata payload for special data receive message. */ - }; -@@ -904,8 +761,9 @@ struct nss_wifi_vdev_per_packet_metadata - * Metadata payload for Mesh mode receive. - */ - struct nss_wifi_vdev_meshmode_rx_metadata { -- uint16_t rs_ratephy_lo; /**< PHY rate lower order bytes. */ -- uint16_t rs_ratephy_hi; /**< PHY rate higher order bytes. */ -+ uint16_t rs_ratephy; /**< PHY rate. */ -+ uint16_t rs_ratephy_lo; /**< PHY rate lower bytes. */ -+ uint16_t rs_ratephy_hi; /**< PHY rate higher bytes. */ - uint16_t cntr_chan_freq; /** Center channel frequency. */ - uint16_t vdev_id; /**< Virtual device ID. */ - uint16_t peer_id; /**< Peer ID. */ -@@ -1031,22 +889,6 @@ struct nss_wifi_vdev_mcast_enhance_stats - * Number of multicast bytes received for multicast enhancement. - */ - uint32_t mcast_rcvd_bytes; -- -- /** -- * Number of IGMP packets received for conversion to unicast. -- */ -- uint32_t igmp_rcvd; -- -- /** -- * Number of IGMP packets converted to unicast as a part of -- * VoW IGMP improvements. -- */ -- uint32_t igmp_ucast_converted; -- -- /** -- * Number of group members that could not be added due to failed allocation. -- */ -- uint32_t mcast_mbr_alloc_failed; - }; - - /** -@@ -1055,8 +897,8 @@ struct nss_wifi_vdev_mcast_enhance_stats - */ - struct nss_wifi_vdev_stats_sync_msg { - uint32_t dropped; /**< Number of dropped packets. */ -- uint32_t tx_enqueue_cnt; /**< Transmit pnode enqueue count. */ -- uint32_t tx_enqueue_fail_cnt; /**< Transmit pnode enqueue count. */ -+ uint32_t tx_enqueue_cnt; /**< Tx pnode enqueue count. */ -+ uint32_t tx_enqueue_fail_cnt; /**< Tx pnode enqueue count. */ - uint32_t tx_intra_bss_enqueue_cnt; /**< Intra BSS enqueue count. */ - uint32_t tx_intra_bss_enqueue_fail_cnt; - /**< Intra BSS enqueue fail count. */ -@@ -1064,12 +906,12 @@ struct nss_wifi_vdev_stats_sync_msg { - /**< Virual device multicast/broadcast packet count in AP mode. */ - uint32_t tx_intra_bss_mcast_send_fail_cnt; - /**< Virtual device multicast/broadcast packet count in AP mode. */ -- uint32_t tx_enqueue_bytes; /**< Transmit enqueue bytes count. */ -+ uint32_t tx_enqueue_bytes; /**< Tx enqueue bytes count. */ - uint32_t rx_enqueue_cnt; /**< Ethernet node enqueue count. */ - uint32_t rx_enqueue_fail_cnt; /**< Ethernet node enqueue fail count. */ - uint32_t rx_except_enqueue_cnt; /**< N2H (NSS to Host) node enqueue count. */ - uint32_t rx_except_enqueue_fail_cnt; /**< N2H (NSS to Host) node enqueue fail count. */ -- uint32_t rx_enqueue_bytes; /**< Receive enqueue bytes count. */ -+ uint32_t rx_enqueue_bytes; /**< Rx enqueue bytes count. */ - uint32_t rx_wds_learn_send_cnt; /**< Virtual device WDS source port learn count. */ - uint32_t rx_wds_learn_send_fail_cnt; /**< Virtual device WDS source count fail. */ - struct nss_wifi_vdev_mcast_enhance_stats wvmes; -@@ -1089,17 +931,6 @@ struct nss_wifi_vdev_stats_sync_msg { - uint32_t tx_eapol_cnt; /**< Number of EAPoL frames in transmit direction. */ - uint32_t nawds_tx_mcast_cnt; /**< Number of NAWDS packets sent. */ - uint32_t nawds_tx_mcast_bytes; /**< Number of NAWDS bytes sent. */ -- uint32_t per_pkt_vdev_check_fail; /**< Number of packets that failed vdev id check in Tx. */ -- uint32_t rx_mcast_cnt; /**< Receive multicast packet count. */ -- uint32_t rx_mcast_bytes; /**< Receive multicast bytes count. */ -- uint32_t rx_decrypt_err; /**< Receive decryption error */ -- uint32_t rx_mic_err; /**< Receive MIC error */ -- uint32_t mcbc_exc_host_fail_cnt; -- /**< Number of multicast/broadcast packets failed to send to host through exception path. */ -- uint32_t addr4_exc_fail; /**< Number of failed 4 address exceptions. */ -- uint32_t addr4_exc_pass; /**< Number of successful 4 address exceptions. */ -- uint32_t eapol_over_nl_exc_fail_cnt; /**< Number of EAPOL over NL exception packet failures. */ -- uint32_t eapol_over_nl_exc_pass_cnt; /**< Number of EAPOL over NL exception packet successes. */ - }; - - /** -@@ -1130,15 +961,7 @@ struct nss_wifi_vdev_msg { - struct nss_wifi_vdev_me_snptbl_grp_mbr_update_msg vdev_grp_member_update; - /**< Updates a snooplist group member. */ - struct nss_wifi_vdev_me_snptbl_deny_grp_add_msg vdev_deny_member_add; -- /**< Add a snooplist member to the deny list. */ -- struct nss_wifi_vdev_me_hmmc_add_msg vdev_hmmc_member_add; -- /**< Adds a member to the HMMC list. */ -- struct nss_wifi_vdev_me_hmmc_del_msg vdev_hmmc_member_del; -- /**< Deletes a member from the HMMC list. */ -- struct nss_wifi_vdev_me_deny_ip_add_msg vdev_deny_list_member_add; -- /**< Adds a member to the denylist. */ -- struct nss_wifi_vdev_me_deny_ip_del_msg vdev_deny_list_member_del; -- /**< Deletes a member from the denylist. */ -+ /**< Adds a snooplist member to a deny list. */ - struct nss_wifi_vdev_txmsg vdev_txmsgext; - /**< Transmits special data. */ - struct nss_wifi_vdev_vow_dbg_cfg_msg vdev_vow_dbg_cfg; ---- a/exports/nss_wifili_if.h -+++ b/exports/nss_wifili_if.h -@@ -1,19 +1,16 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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. -- * -+ * Copyright (c) 2017-2020, 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. -+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ************************************************************************** - */ - -@@ -65,7 +62,7 @@ - /**< Maximum number of bandwidth supported. */ - #define NSS_WIFILI_REPT_MU_MIMO 1 - #define NSS_WIFILI_REPT_MU_OFDMA_MIMO 3 --#define NSS_WIFILI_MAX_RESERVED_TYPE 2 -+#define NSS_WIFILI_MAX_RESERVED_TYPE 3 - /**< Maximum reserved type. */ - #define NSS_WIFILI_SOC_PER_PACKET_METADATA_SIZE 60 - /**< Metadata area total size. */ -@@ -87,7 +84,7 @@ - /**< Maximum DMA error codes. */ - #define NSS_WIFILI_MAX_TID 8 - /**< Maximum TID values. */ --#define NSS_WIFILI_DELAY_INDEX_MAX 13 -+#define NSS_WIFILI_DELAY_INDEX_MAX 10 - /**< Maximum software enqueue delay buckets. */ - #define NSS_WIFILI_MAX_NUMBER_OF_ADDTNL_SEG 64 - /**< Maximum number of additional pages allocated from host. */ -@@ -97,69 +94,12 @@ - /**< Maximum number of flow queues. */ - #define NSS_WIFILI_WBM_INTERNAL_ERR_MAX 5 - /**< WBM internal maximum errors. */ --#define NSS_WIFILI_MAX_VOW_TID_NUM 4 -- /**< Maximum version 3 TID values. */ -- --/* -- * Peer Size in Bytes -- */ --#define NSS_WIFILI_PEER_SIZE 1600 -- --/* -- * Maximum size of target SoC type string -- */ --#define NSS_WIFILI_SOC_STRING_SIZE_MAX 24 - - /* - * Radio specific flags - */ - #define NSS_WIFILI_PDEV_FLAG_V3_STATS_ENABLED 0x00000008 - /**< Flag to enable version 3 statistics. */ --/** -- * Peer message flags. -- */ --#define NSS_WIFILI_PEER_MSG_DISABLE_4ADDR 0x01 -- --#ifdef __KERNEL__ /* only kernel will use. */ -- --/** -- * Wireless Multimedia Extention Access Category to TID. @hideinitializer -- */ --#define NSS_WIFILI_WME_AC_TO_TID(_ac) ( \ -- ((_ac) == NSS_WIFILI_WME_AC_VO) ? 6 : \ -- (((_ac) == NSS_WIFILI_WME_AC_VI) ? 5 : \ -- (((_ac) == NSS_WIFILI_WME_AC_BK) ? 1 : \ -- 0))) -- --/** -- * Wireless TID to Wireless Extension Multimedia Access Category. @hideinitializer -- */ --#define NSS_WIFILI_TID_TO_WME_AC(_tid) ( \ -- (((_tid) == 0) || ((_tid) == 3)) ? NSS_WIFILI_WME_AC_BE : \ -- ((((_tid) == 1) || ((_tid) == 2)) ? NSS_WIFILI_WME_AC_BK : \ -- ((((_tid) == 4) || ((_tid) == 5)) ? NSS_WIFILI_WME_AC_VI : \ -- NSS_WIFILI_WME_AC_VO))) --#endif /* __KERNEL */ -- --/** -- * nss_wifili_thread_scheme_id -- * List of thread scheme IDs. -- */ --enum nss_wifili_thread_scheme_id { -- NSS_WIFILI_THREAD_SCHEME_ID_0, /**< High priority scheme index. */ -- NSS_WIFILI_THREAD_SCHEME_ID_1, /**< Low priority scheme index. */ -- NSS_WIFILI_THREAD_SCHEME_ID_2, /**< High priority scheme index. */ -- NSS_WIFILI_THREAD_SCHEME_ID_MAX /**< Maximum value of scheme index. */ --}; -- --/* -- * nss_wifili_thread_scheme_priority -- * List of wifili thread scheme priority. -- */ --enum nss_wifili_thread_scheme_priority { -- NSS_WIFILI_LOW_PRIORITY_SCHEME, /**< Low priority scheme. */ -- NSS_WIFILI_HIGH_PRIORITY_SCHEME, /**< High priority scheme. */ --}; - - /** - * nss_wifili_wme_stream_classes -@@ -244,20 +184,6 @@ enum nss_wifili_msg_types { - NSS_WIFILI_ISOLATION_MSG, - NSS_WIFILI_PEER_EXT_STATS_MSG, - NSS_WIFILI_CLR_STATS, -- NSS_WIFILI_PEER_4ADDR_EVENT_MSG, -- NSS_WIFILI_DBDC_REPEATER_LOOP_DETECTION_MSG, -- NSS_WIFILI_PEER_UPDATE_AUTH_FLAG, -- NSS_WIFILI_SEND_MESH_CAPABILITY_INFO, -- NSS_WIFILI_PDEV_TX_CAPTURE_MSG, -- NSS_WIFILI_PEER_TX_CAPTURE_MSG, -- NSS_WIFILI_PDEV_V3_RX_ERROR_STATS_SYNC_MSG, -- NSS_WIFILI_SEND_DBG_LATENCY_EVENT_MSG, -- NSS_WIFILI_SET_TX_LATENCY_THRESHOLD, -- NSS_WIFILI_SET_TX_LATENCY_PKTLOG_THRESHOLD, -- NSS_WIFILI_SET_V3_STATS_TX_DROP_TID, -- NSS_WIFILI_SET_V3_STATS_TX_DROP_THRESHOLD, -- NSS_WIFILI_ASTENTRY_SYNC_MSG, -- NSS_WIFILI_MECENTRY_SYNC_MSG, - NSS_WIFILI_MAX_MSG - }; - -@@ -404,8 +330,6 @@ enum nss_wifili_error_types { - /**< Invalid TLV length. */ - NSS_WIFILI_EMESG_RX_BUF_LEN_INVALID, - /**< Invalid Rx buffer length. */ -- NSS_WIFILI_EMSG_TX_CAPTURE_MODE_UPDATE_FAIL, -- /**< Tx capture mode update failure. */ - NSS_WIFILI_EMSG_UNKNOWN - /**< Unknown error message. */ - }; -@@ -435,7 +359,6 @@ enum nss_wifili_radio_cmd { - NSS_WIFILI_SET_FORCE_CLIENT_MCAST_TRAFFIC, /**< Flag to force multicast traffic for a radio. */ - NSS_WIFILI_SET_DROP_SECONDARY_MCAST, /**< Flag to drop multicast traffic on secondary radio. */ - NSS_WIFILI_SET_DBDC_FASTLANE, /**< Flag to set DBDC fast-lane mode. */ -- NSS_WIFILI_SET_DBDC_NOBACKHAUL_RADIO, /**< Flag to set DBDC to no backhaul radio. */ - NSS_WIFILI_RADIO_MAX_CMD /**< Maximum radio command index. */ - }; - -@@ -541,8 +464,6 @@ enum nss_wifili_stats_tx_comp { - NSS_WIFILI_STATS_TX_DESC_FREE_INV_COOKIE, /**< Number of invalid cookie packets. */ - NSS_WIFILI_STATS_TX_DESC_FREE_HW_RING_EMPTY, /**< Number of times hardware ring empty found. */ - NSS_WIFILI_STATS_TX_DESC_FREE_REAPED, /**< Number of Tx packets that are reaped out of the Tx completion ring. */ -- NSS_WIFILI_STATS_TX_CAPTURE_ENQUEUE, /**< Number of Tx packets enqueued to host. */ -- NSS_WIFILI_STATS_TX_CAPTURE_ENQUEUE_FAIL, /**< Number of Tx packets failed to enqueue to host. */ - NSS_WIFILI_STATS_TX_DESC_FREE_MAX, /**< Number of Tx completion statistics. */ - }; - -@@ -642,14 +563,14 @@ enum nss_wifili_stats_rxdma_ring { - * Wifili WBM(Wireless Buffer Manager) ring statistics. - */ - enum nss_wifili_stats_wbm { -- NSS_WIFILI_STATS_WBM_IE_LOCAL_ALLOC_FAIL, /**< Number of Wireless Buffer Manager internal local allocation failures. */ -- NSS_WIFILI_STATS_WBM_SRC_DMA, /**< Number of receive invalid source DMA. */ -- NSS_WIFILI_STATS_WBM_SRC_DMA_CODE_INV, /**< Number of receive invalid source DMA. */ -- NSS_WIFILI_STATS_WBM_SRC_REO, /**< Number of receive invalid source reorder. */ -- NSS_WIFILI_STATS_WBM_SRC_REO_CODE_NULLQ, /**< Number of receive invalid reorder error with NULL queue. */ -- NSS_WIFILI_STATS_WBM_SRC_REO_CODE_INV, /**< Number of receive invalid reorder code invalid. */ -- NSS_WIFILI_STATS_WBM_SRC_INV, /**< Number of receive invalid source invalid. */ -- NSS_WIFILI_STATS_WBM_MAX, /**< Number of receive Wireless Buffer Manager statistics. */ -+ NSS_WIFILI_STATS_WBM_IE_LOCAL_ALLOC_FAIL, /**< Number of Wireless Buffer Manger internal local allocation failures. */ -+ NSS_WIFILI_STATS_WBM_SRC_DMA, /**< Number of Rx invalid source DMA. */ -+ NSS_WIFILI_STATS_WBM_SRC_DMA_CODE_INV, /**< Number of Rx invalid source DMA. */ -+ NSS_WIFILI_STATS_WBM_SRC_REO, /**< Number of Rx invalid source reorder. */ -+ NSS_WIFILI_STATS_WBM_SRC_REO_CODE_NULLQ, /**< Number of Rx invalid reorder error with NULL queue. */ -+ NSS_WIFILI_STATS_WBM_SRC_REO_CODE_INV, /**< Number of Rx invalid reorder code invalid. */ -+ NSS_WIFILI_STATS_WBM_SRC_INV, /**< Number of Rx invalid source invalid. */ -+ NSS_WIFILI_STATS_WBM_MAX, /**< Number of Rx Wireless Buffer Manager statistics. */ - }; - - /** -@@ -681,12 +602,9 @@ struct nss_wifili_stats { - * NSS wifili soc stats - */ - struct nss_wifili_soc_stats { -- uint32_t soc_maxpdev; -- /**< Maximum number of radios per SoC. */ -+ uint32_t soc_maxpdev; /**< Maximum number of radios per SoC. */ - struct nss_wifili_stats stats_wifili; -- /**< Per-SoC statistics. */ -- char soc_type[NSS_WIFILI_SOC_STRING_SIZE_MAX]; -- /**< Target SoC type string. */ -+ /**< Per-SoC statistics. */ - }; - - /** -@@ -732,13 +650,11 @@ struct nss_wifili_hal_srng_info{ - */ - struct nss_wifili_hal_srng_soc_msg { - uint32_t dev_base_addr; -- /**< Base address of WLAN device. */ -+ /**< Base address of wlan dev. */ - uint32_t shadow_rdptr_mem_addr; - /**< Shadow read pointer address. */ - uint32_t shadow_wrptr_mem_addr; - /**< Shadow write pointer address. */ -- uint32_t lmac_rings_start_id; -- /**< Start ID of LMAC rings. */ - }; - - /** -@@ -857,10 +773,6 @@ struct nss_wifili_pdev_init_msg { - /**< Number of descriptors per Rx pool. */ - uint32_t target_pdev_id; - /**< Target physical device ID. */ -- uint8_t scheme_id; -- /**< Radio scheme ID. */ -- uint8_t reserved[3]; -- /**< Padding for alignment. */ - }; - - /** -@@ -911,10 +823,6 @@ struct nss_wifili_peer_msg { - /**< AST hash to be used during packet transmission. */ - uint32_t pext_stats_mem; - /**< Peer extended statistics memory. */ -- uint32_t flags; -- /**< Peer flags. */ -- uint32_t peer_memory_size; -- /**< Peer memory allocated from host to NSS. */ - }; - - /** -@@ -1030,12 +938,10 @@ struct nss_wifili_tx_tcl_ring_stats { - * Tx completion ring statistics. - */ - struct nss_wifili_tx_comp_ring_stats { -- uint32_t invalid_bufsrc; /**< Tx completion ring descriptor invalid buffer source. */ -- uint32_t invalid_cookie; /**< Tx completion ring descriptor has invalid cookies. */ -- uint32_t hw_ring_empty; /**< Tx completion hardware ring empty. */ -- uint32_t ring_reaped; /**< Tx completion successfull ring reaped. */ -- uint32_t tx_cap_enqueue_count; /**< Number of Tx packets enqueued to host. */ -- uint32_t tx_cap_enqueue_fail_count; /**< Number of Tx packets failed to enqueue to host. */ -+ uint32_t invalid_bufsrc; /**< Tx comp (Completion) ring descriptor invalid buffer source. */ -+ uint32_t invalid_cookie; /**< Tx comletion ring descriptor has invalid cookies. */ -+ uint32_t hw_ring_empty; /**< Tx completion hardware ring empty. */ -+ uint32_t ring_reaped; /**< Tx completion successfull ring reaped. */ - }; - - /** -@@ -1074,16 +980,16 @@ struct nss_wifili_rx_wbm_ring_stats { - uint32_t invalid_buf_mgr; /**< Invalid buffer manager. */ - uint32_t err_src_rxdma; /**< Wireless Buffer Manager source is Rx DMA ring. */ - uint32_t err_src_rxdma_code_inv; /**< Wireless Buffer Manager source DMA reason unknown. */ -- uint32_t err_src_reo; /**< Wireless Buffer Manager source is receive reorder ring. */ -- uint32_t err_src_reo_code_nullq; /**< Wireless Buffer Manager source receive reorder ring because of NULL TLV. */ -- uint32_t err_src_reo_code_inv; /**< Wireless Buffer Manager source receive reorder ring reason unknown. */ -+ uint32_t err_src_reo; /**< Wireless Buffer Manager source is Rx reorder ring. */ -+ uint32_t err_src_reo_code_nullq; /**< Wireless Buffer Manager source Rx reorder ring because of NULL TLV. */ -+ uint32_t err_src_reo_code_inv; /**< Wireless Buffer Manager source Rx reorder ring reason unknown. */ - uint32_t err_src_invalid; /**< Wireless Buffer Manager source is unknown. */ - uint32_t err_reo_codes[NSS_WIFILI_REO_CODE_MAX]; -- /**< Receive reoder error codes. */ -+ /**< Rx reoder error codes. */ - uint32_t err_dma_codes[NSS_WIFILI_DMA_CODE_MAX]; - /**< DMA error codes. */ - uint32_t err_internal_codes[NSS_WIFILI_WBM_INTERNAL_ERR_MAX]; -- /**< Wireless Buffer Manager error codes. */ -+ /**< Wireless Buffer Manger error codes. */ - }; - - /** -@@ -1260,50 +1166,6 @@ struct nss_wifili_pdev_v3_delay_stats_sy - }; - - /** -- * nss_wifili_v3_reo_stats -- * Wifili REO error statistics for version 3. -- */ --struct nss_wifili_v3_reo_stats { -- uint32_t err_src_reo_code_inv; -- /**< Reason for the Wireless Buffer Manager Rx REO ring is unknown.. */ -- uint32_t err_reo_codes[NSS_WIFILI_REO_CODE_MAX]; -- /**< Rx REO error codes. */ --}; -- --/** -- * nss_wifili_v3_rxdma_stats -- * Wifili Rx DMA error statistics for version 3. -- */ --struct nss_wifili_v3_rxdma_stats { -- uint32_t err_src_rxdma_code_inv; -- /**< DMA reason unknown. */ -- uint32_t err_dma_codes[NSS_WIFILI_DMA_CODE_MAX]; -- /**< DMA Rx error codes. */ --}; -- --/** -- * nss_wifili_radio_error_stats_v3 -- * Wifili radio error statistics for version 3. -- */ --struct nss_wifili_radio_error_stats_v3 { -- struct nss_wifili_v3_reo_stats reo_stats[NSS_WIFILI_MAX_VOW_TID_NUM]; -- /**< REO statistics per maximum version 3 TID values. */ -- struct nss_wifili_v3_rxdma_stats rxdma_stats[NSS_WIFILI_MAX_VOW_TID_NUM]; -- /**< Rx DMA statistics per maximum version 3 TID values. */ --}; -- --/** -- * nss_wifili_pdev_v3_error_stats_sync_msg -- * Wifili message to synchronize version 3 error statistics to HLOS. -- */ --struct nss_wifili_pdev_v3_error_stats_sync_msg { -- uint32_t radio_id; -- /**< Radio ID of Wifili message. */ -- struct nss_wifili_radio_error_stats_v3 wlpv3_error_stats; -- /**< Wifli version 3 error statistics. */ --}; -- --/** - * nss_wifili_device_stats - * Wifili specific statistics. - */ -@@ -1339,8 +1201,6 @@ struct nss_wifili_device_stats { - struct nss_wifili_stats_sync_msg { - struct nss_wifili_device_stats stats; - /**< Device statistics. */ -- uint32_t target_type; -- /**< Target SoC type. */ - }; - - /** -@@ -1417,7 +1277,6 @@ struct nss_wifili_rx_err { - struct nss_wifili_rx_ctrl_stats { - struct nss_wifili_rx_err err; /**< Rx peer errors. */ - uint32_t multipass_rx_pkt_drop; /**< Total number of multipass packets without a VLAN header. */ -- uint32_t peer_unauth_rx_pkt_drop; /**< Number of receive packets dropped due to an authorized peer. */ - uint32_t reserved_type[NSS_WIFILI_MAX_RESERVED_TYPE]; /**< Reserved type for future use. */ - uint32_t non_amsdu_cnt; /**< Number of MSDUs with no MSDU level aggregation. */ - uint32_t amsdu_cnt; /**< Number of MSDUs part of AMSDU. */ -@@ -1433,19 +1292,6 @@ struct nss_wifili_rx_ctrl_stats { - uint32_t rx_intra_bss_fail_bytes; /**< Total Intra-BSS bytes received. */ - uint32_t bcast_rcv_cnt; /**< Total number of broadcast packets received. */ - uint32_t bcast_rcv_bytes; /**< Total number of broadcast bytes received. */ -- uint32_t defrag_mcast_drop; /**< Total number of defrag multicast dropped packets. */ -- uint32_t mcast_3addr_drop; /**< Total number of 3 address multicast dropped packets. */ --}; -- --/** -- * nss_wifili_retry_ctrl_stats -- * Peer retry statistics. -- */ --struct nss_wifili_retry_ctrl_stats { -- uint32_t tx_failed_retry_count; /**< Transmit failed retry count. */ -- uint32_t tx_retry_count; /**< Transmit retry count. */ -- uint32_t tx_multiple_retry_count; /**< Transmit multiple retry count. */ -- uint32_t rx_retry_count; /**< Receive retry count. */ - }; - - /** -@@ -1458,8 +1304,6 @@ struct nss_wifili_peer_ctrl_stats { - /**< Peer Tx control statistics. */ - struct nss_wifili_rx_ctrl_stats rx; - /**< Peer Rx control statistics. */ -- struct nss_wifili_retry_ctrl_stats retry; -- /**< Peer retry Statistics. */ - }; - - /** -@@ -1686,14 +1530,6 @@ struct nss_wifili_peer_isolation_msg { - }; - - /** -- * nss_wifili_dbdc_repeater_loop_detection_msg -- * Wifili DBDC repeater loop detection message. -- */ --struct nss_wifili_dbdc_repeater_loop_detection_msg { -- bool dbdc_loop_detected; /**< DBDC repeater loop detection flag. */ --}; -- --/** - * nss_wifili_dbdc_repeater_set_msg - * Wifili DBDC repeater set message. - */ -@@ -1746,16 +1582,6 @@ struct nss_wifili_clr_stats_msg { - }; - - /** -- * nss_wifili_update_auth_flag -- * Peer authentication flag message. -- */ --struct nss_wifili_peer_update_auth_flag { -- uint16_t peer_id; /**< Peer ID. */ -- uint8_t auth_flag; /**< Peer authentication flag. */ -- uint8_t reserved; /**< Alignment padding. */ --}; -- --/** - * nss_wifili_update_pdev_lmac_id_msg - * Physical device ID and lower MAC ID update message. - */ -@@ -1775,25 +1601,6 @@ struct nss_wifili_radio_cmd_msg { - uint32_t value; /**< Value of the command. */ - }; - --/* -- * nss_wifili_pdev_tx_capture_msg -- * Tx capture enable per pdev message. -- */ --struct nss_wifili_pdev_tx_capture_msg { -- uint8_t pdev_id; /**< Physical device ID. */ -- uint8_t tx_cap_config; /**< Flag to enable or disable Tx capture for physical device. */ --}; -- --/* -- * nss_wifili_peer_tx_capture_msg -- * Tx capture enable per peer message. -- */ --struct nss_wifili_peer_tx_capture_msg { -- uint16_t peer_id; /**< Peer ID. */ -- uint8_t tx_cap_config; /**< Flag to enable or disable Tx capture for peer. */ -- uint8_t reserved; /**< Reserved. */ --}; -- - /** - * nss_wifili_radio_buf_cfg_msg - * Wi-Fi Radio buffer requirement configuration. -@@ -1831,108 +1638,6 @@ struct nss_wifili_radio_cfg_msg { - }; - - /** -- * struct wifili_peer_wds_4addr_allow_msg -- * Per-peer four address configuration message. -- */ --struct nss_wifili_peer_wds_4addr_allow_msg { -- uint32_t peer_id; /**< Peer ID. */ -- uint32_t if_num; /**< Associate virtual interface number. */ -- bool enable; /**< Boolean flag to enable/disable four address frames. */ --}; -- --/** -- * struct nss_wifili_mesh_capability_info -- * Wi-Fi mesh capability flag. -- */ --struct nss_wifili_mesh_capability_info { -- bool mesh_enable; /**< Wi-Fi mesh capability flag. */ --}; -- --/** -- * struct nss_wifili_dbg_latency_event_msg -- * Wifili debug latency event sent to host. -- */ --struct nss_wifili_dbg_latency_event_msg { -- uint32_t tid; /**< Traffic Identifier (TID) value. */ -- uint32_t pktlog_en; /**< Packet log enable value. */ -- uint32_t value; /**< Packet log enumeration value. */ -- uint32_t tx_latency; /**< Transmit latency value of event. */ -- uint32_t tx_drop; /**< Tx drop value */ -- uint16_t peer_id; /**< Peer ID of event. */ -- uint8_t reserved[2]; /**< Reserved field. */ --}; -- --/* -- * nss_wifili_set_tx_latency_threshold -- * Sets transmit latency threshold value. -- */ --struct nss_wifili_set_tx_latency_threshold { -- uint32_t radio_id; /**< Radio ID of event. */ -- uint32_t latency_threshold; /**< Latency threshold value.. */ --}; -- --/* -- * nss_wifli_v3_stats_set_vow_tid_msg -- * Sets TID value for version 3 debugging. -- */ --struct nss_wifli_v3_stats_set_vow_tid_msg { -- uint32_t radio_id; /**< Radio ID. */ -- uint32_t tid; /**< Traffic Identifier (TID) value. */ --}; -- --/* -- * nss_wifili_set_tx_drop_threshold -- * Set Tx drop threshold value. -- */ --struct nss_wifili_set_tx_drop_threshold { -- uint32_t radio_id; /**< Radio ID. */ -- uint32_t tx_drop_threshold; /**< Tx drop threshold value. */ --}; -- --/* -- * nss_wifi_peer_map_astentry_info -- * NSS wifi peer map AST entry information. -- */ --struct nss_wifi_peer_map_astentry_info { -- uint16_t entry_no; /**< Entry number. */ -- uint16_t dest_mac_addr[ETH_ALEN/2]; /**< MAC address. */ -- uint16_t peer_id; /**< Peer ID. */ -- uint16_t hw_ast_idx; /**< Peer associated hardware IDX. */ -- uint16_t astinfoseq; /**< AST entry information sequence. */ -- uint8_t radio_id; /**< AST entry radio ID. */ -- uint8_t ast_type; /**< AST entry type. */ --}; -- --/* -- * nss_wifili_astentry_info_msg -- * NSS wifili AST entry information message. -- */ --struct nss_wifili_astentry_info_msg { -- uint16_t nentries; /**< Number of entries in the information message. */ -- struct nss_wifi_peer_map_astentry_info info[0]; /**< AST entry information specific message. */ --}; -- --/* -- * nss_wifi_peer_map_mecentry_info -- * NSS wifi peer map MEC entry information. -- */ --struct nss_wifi_peer_map_mecentry_info { -- uint16_t entry_no; /**< Entry number. */ -- uint16_t mac_addr[ETH_ALEN/2]; /**< MAC address. */ -- uint8_t radio_id; /**< MEC entry radio ID. */ -- uint8_t reserved[3]; /**< Reserved fields. */ --}; -- --/* -- * nss_wifili_mecentry_info_msg -- * NSS wifili MEC entry information message. -- */ --struct nss_wifili_mecentry_info_msg { -- uint16_t nentries; /**< Number of entries in the information message. */ -- struct nss_wifi_peer_map_mecentry_info info[0]; /**< MEC entry information specific message. */ --}; -- --/* - * nss_wifili_msg - * Structure that describes wifili messages. - */ -@@ -2008,32 +1713,6 @@ struct nss_wifili_msg { - /**< Peer extended statistics message. */ - struct nss_wifili_clr_stats_msg clrstats; - /**< Clear NSS firmware statistics. */ -- struct nss_wifili_peer_wds_4addr_allow_msg wpswm; -- /**< Peer four-address event message. */ -- struct nss_wifili_dbdc_repeater_loop_detection_msg wdrldm; -- /**< Wifili DBDC repeater loop detection message. */ -- struct nss_wifili_peer_update_auth_flag peer_auth; -- /**< Peer authentication flag message. */ -- struct nss_wifili_mesh_capability_info cap_info; -- /**< Mesh capability flag. */ -- struct nss_wifili_pdev_tx_capture_msg pdevtxcapmsg; -- /**< Wifili physical device Tx capture message. */ -- struct nss_wifili_peer_tx_capture_msg peertxcapmsg; -- /**< Wifili peer Tx capture message. */ -- struct nss_wifili_pdev_v3_error_stats_sync_msg v3_rx_error_stats_msg; -- /**< Wifili version 3 Rx error statistics message. */ -- struct nss_wifili_dbg_latency_event_msg dbg_info; -- /**< Debug latency event for host. */ -- struct nss_wifili_set_tx_latency_threshold tx_latency_threshold; -- /**< Tx latency threshold value. */ -- struct nss_wifli_v3_stats_set_vow_tid_msg v3_tid; -- /**< TID value for version 3. */ -- struct nss_wifili_set_tx_drop_threshold tx_drop_threshold; -- /**< Tx drop threshold value. */ -- struct nss_wifili_astentry_info_msg astinfo; -- /**< Wifili AST database entry information message. */ -- struct nss_wifili_mecentry_info_msg mecinfo; -- /**< Wifili MEC database entry information message. */ - } msg; /**< Message payload. */ - }; - -@@ -2178,60 +1857,7 @@ void nss_unregister_wifili_radio_if(uint - * @return - * External interface number. - */ --nss_if_num_t nss_get_available_wifili_external_if(void); -- --/** -- * nss_wifili_release_external_if -- * Release the used interface number -- * -- * @datatypes -- * nss_if_num -- * -- * @param[in] if_num NSS interface number. -- * -- * @return -- * void -- */ --void nss_wifili_release_external_if(nss_if_num_t ifnum); -- --/** -- * nss_wifili_thread_scheme_alloc -- * Allocate thread scheme entry and return scheme index. -- * -- * @param[in] nss_ctx NSS context pointer. -- * @param[in] radio_ifnum Radio interface number. -- * @param[in] radio_priority Radio Priority requested. -- * -- * @return -- * uint8_t. -- */ --uint8_t nss_wifili_thread_scheme_alloc(struct nss_ctx_instance *nss_ctx, -- int32_t radio_ifnum, -- uint32_t radio_priority); -- --/** -- * nss_wifili_thread_scheme_dealloc -- * Release thread scheme database entry. -- * -- * @param[in] nss_ctx NSS context pointer. -- * @param[in] radio_ifnum Radio interface number. -- * -- * @return -- * void. -- */ --void nss_wifili_thread_scheme_dealloc(struct nss_ctx_instance *nss_ctx, -- int32_t radio_ifnum); -- --/** -- * nss_wifili_get_radio_num -- * Get radio number. -- * -- * @param[in] nss_ctx NSS context pointer. -- * -- * @return -- * uint32_t. -- */ --uint32_t nss_wifili_get_radio_num(struct nss_ctx_instance *nss_ctx); -+uint32_t nss_get_available_wifili_external_if(void); - - /** - * nss_wifili_stats_register_notifier ---- a/nss_capwap.c -+++ b/nss_capwap.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2020, 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. -@@ -49,32 +49,16 @@ struct nss_capwap_handle { - static struct nss_capwap_handle *nss_capwap_hdl[NSS_MAX_DYNAMIC_INTERFACES]; - - /* -- * nss_capwap_get_interface_type() -- * Function to get the type of dynamic interface. -- */ --static enum nss_dynamic_interface_type nss_capwap_get_interface_type(uint32_t if_num) --{ -- struct nss_ctx_instance *nss_ctx; -- nss_ctx = &nss_top_main.nss[nss_top_main.capwap_handler_id]; -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- return nss_dynamic_interface_get_type(nss_ctx, if_num); --} -- --/* - * nss_capwap_verify_if_num() - * Verify if_num passed to us. - */ - static bool nss_capwap_verify_if_num(uint32_t if_num) - { -- enum nss_dynamic_interface_type type; -- - if (nss_is_dynamic_interface(if_num) == false) { - return false; - } - -- type = nss_capwap_get_interface_type(if_num); -- if ((type != NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_HOST_INNER) && (type != NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_OUTER) ) { -+ if (nss_dynamic_interface_get_type(nss_capwap_get_ctx(), if_num) != NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP) { - return false; - } - -@@ -104,10 +88,10 @@ static void nss_capwap_refcnt_dec(int32_ - } - - /* -- * nss_capwap_refcnt_get() -+ * nss_capwap_refcnt() - * Get refcnt on the tunnel. - */ --static uint32_t nss_capwap_refcnt_get(int32_t if_num) -+static uint32_t nss_capwap_refcnt(int32_t if_num) - { - if_num = if_num - NSS_DYNAMIC_IF_START; - return atomic_read(&nss_capwap_hdl[if_num]->refcnt); -@@ -149,62 +133,45 @@ static nss_capwap_msg_callback_t nss_cap - } - - /* -- * nss_capwap_update_stats() -+ * nss_capwapmgr_update_stats() - * Update per-tunnel stats for each CAPWAP interface. - */ --static void nss_capwap_update_stats(struct nss_capwap_handle *handle, struct nss_capwap_stats_msg *fstats) -+static void nss_capwapmgr_update_stats(struct nss_capwap_handle *handle, struct nss_capwap_stats_msg *fstats) - { - struct nss_capwap_tunnel_stats *stats; -- enum nss_dynamic_interface_type type; - - stats = &handle->stats; -- type = nss_capwap_get_interface_type(handle->if_num); - -- switch(type) { -- case NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_OUTER: -- stats->rx_segments += fstats->rx_segments; -- stats->dtls_pkts += fstats->dtls_pkts; -- stats->rx_dup_frag += fstats->rx_dup_frag; -- stats->rx_oversize_drops += fstats->rx_oversize_drops; -- stats->rx_frag_timeout_drops += fstats->rx_frag_timeout_drops; -- stats->rx_n2h_drops += fstats->rx_n2h_drops; -- stats->rx_n2h_queue_full_drops += fstats->rx_n2h_queue_full_drops; -- stats->rx_mem_failure_drops += fstats->rx_mem_failure_drops; -- stats->rx_csum_drops += fstats->rx_csum_drops; -- stats->rx_malformed += fstats->rx_malformed; -- stats->rx_frag_gap_drops += fstats->rx_frag_gap_drops; -- -- /* -- * Update pnode rx stats for OUTER node. -- */ -- stats->pnode_stats.rx_packets += fstats->pnode_stats.rx_packets; -- stats->pnode_stats.rx_bytes += fstats->pnode_stats.rx_bytes; -- stats->pnode_stats.rx_dropped += nss_cmn_rx_dropped_sum(&fstats->pnode_stats); -- break; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_HOST_INNER: -- stats->tx_segments += fstats->tx_segments; -- stats->tx_queue_full_drops += fstats->tx_queue_full_drops; -- stats->tx_mem_failure_drops += fstats->tx_mem_failure_drops; -- stats->tx_dropped_sg_ref += fstats->tx_dropped_sg_ref; -- stats->tx_dropped_ver_mis += fstats->tx_dropped_ver_mis; -- stats->tx_dropped_hroom += fstats->tx_dropped_hroom; -- stats->tx_dropped_dtls += fstats->tx_dropped_dtls; -- stats->tx_dropped_nwireless += fstats->tx_dropped_nwireless; -- -- /* -- * Update pnode tx stats for INNER node. -- */ -- stats->pnode_stats.tx_packets += fstats->pnode_stats.tx_packets; -- stats->pnode_stats.tx_bytes += fstats->pnode_stats.tx_bytes; -- stats->tx_dropped_inner += nss_cmn_rx_dropped_sum(&fstats->pnode_stats); -- break; -- -- default: -- nss_warning("%px: Received invalid dynamic interface type: %d", handle, type); -- nss_assert(0); -- return; -- } -+ stats->rx_segments += fstats->rx_segments; -+ stats->dtls_pkts += fstats->dtls_pkts; -+ -+ stats->rx_dup_frag += fstats->rx_dup_frag; -+ stats->rx_oversize_drops += fstats->rx_oversize_drops; -+ stats->rx_frag_timeout_drops += fstats->rx_frag_timeout_drops; -+ stats->rx_queue_full_drops += fstats->rx_queue_full_drops; -+ stats->rx_n2h_queue_full_drops += fstats->rx_n2h_queue_full_drops; -+ stats->rx_mem_failure_drops += fstats->rx_mem_failure_drops; -+ stats->rx_csum_drops += fstats->rx_csum_drops; -+ stats->rx_malformed += fstats->rx_malformed; -+ stats->rx_frag_gap_drops += fstats->rx_frag_gap_drops; -+ -+ stats->tx_segments += fstats->tx_segments; -+ stats->tx_queue_full_drops += fstats->tx_queue_full_drops; -+ stats->tx_mem_failure_drops += fstats->tx_mem_failure_drops; -+ stats->tx_dropped_sg_ref += fstats->tx_dropped_sg_ref; -+ stats->tx_dropped_ver_mis += fstats->tx_dropped_ver_mis; -+ stats->tx_dropped_hroom += fstats->tx_dropped_hroom; -+ stats->tx_dropped_dtls += fstats->tx_dropped_dtls; -+ stats->tx_dropped_nwireless += fstats->tx_dropped_nwireless; -+ -+ /* -+ * add pnode stats now. -+ */ -+ stats->pnode_stats.rx_packets += fstats->pnode_stats.rx_packets; -+ stats->pnode_stats.rx_bytes += fstats->pnode_stats.rx_bytes; -+ stats->pnode_stats.rx_dropped += nss_cmn_rx_dropped_sum(&fstats->pnode_stats); -+ stats->pnode_stats.tx_packets += fstats->pnode_stats.tx_packets; -+ stats->pnode_stats.tx_bytes += fstats->pnode_stats.tx_bytes; - - /* - * Set to 1 when the tunnel is operating in fast memory. -@@ -250,7 +217,7 @@ static void nss_capwap_msg_handler(struc - /* - * Update driver statistics and send statistics notifications to the registered modules. - */ -- nss_capwap_update_stats(nss_capwap_hdl[if_num], &ntm->msg.stats); -+ nss_capwapmgr_update_stats(nss_capwap_hdl[if_num], &ntm->msg.stats); - nss_capwap_stats_notify(ncm->interface, nss_ctx->id); - } - } -@@ -295,23 +262,23 @@ static bool nss_capwap_instance_alloc(st - memset(h, 0, sizeof(struct nss_capwap_handle)); - h->if_num = if_num; - -- spin_lock_bh(&nss_capwap_spinlock); -+ spin_lock(&nss_capwap_spinlock); - if (nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START] != NULL) { -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - kfree(h); - nss_warning("%px: Another thread is already allocated instance for :%d", nss_ctx, if_num); - return false; - } - - nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START] = h; -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - - return true; - } - - /* - * nss_capwap_tx_msg() -- * Transmit a CAPWAP message to NSS FW. Don't call this from softirq/interrupts. -+ * Transmit a CAPWAP message to NSS FW. Don't call this from softirq/interrupts. - */ - nss_tx_status_t nss_capwap_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_capwap_msg *msg) - { -@@ -332,14 +299,14 @@ nss_tx_status_t nss_capwap_tx_msg(struct - } - - if_num = msg->cm.interface - NSS_DYNAMIC_IF_START; -- spin_lock_bh(&nss_capwap_spinlock); -+ spin_lock(&nss_capwap_spinlock); - if (!nss_capwap_hdl[if_num]) { -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - nss_warning("%px: capwap tunnel if_num is not there: %d", nss_ctx, msg->cm.interface); - return NSS_TX_FAILURE_BAD_PARAM; - } - nss_capwap_refcnt_inc(msg->cm.interface); -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - - /* - * Trace messages. -@@ -381,14 +348,14 @@ bool nss_capwap_get_stats(uint32_t if_nu - } - - if_num = if_num - NSS_DYNAMIC_IF_START; -- spin_lock_bh(&nss_capwap_spinlock); -+ spin_lock(&nss_capwap_spinlock); - if (nss_capwap_hdl[if_num] == NULL) { -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - return false; - } - - memcpy(stats, &nss_capwap_hdl[if_num]->stats, sizeof(struct nss_capwap_tunnel_stats)); -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - return true; - } - EXPORT_SYMBOL(nss_capwap_get_stats); -@@ -409,13 +376,13 @@ struct nss_ctx_instance *nss_capwap_noti - return NULL; - } - -- spin_lock_bh(&nss_capwap_spinlock); -+ spin_lock(&nss_capwap_spinlock); - if (nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START] != NULL) { -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - nss_warning("%px: notfiy register tunnel already exists for interface %d", nss_ctx, if_num); - return NULL; - } -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - - return nss_ctx; - } -@@ -443,9 +410,9 @@ nss_tx_status_t nss_capwap_notify_unregi - } - - index = if_num - NSS_DYNAMIC_IF_START; -- spin_lock_bh(&nss_capwap_spinlock); -+ spin_lock(&nss_capwap_spinlock); - if (nss_capwap_hdl[index] == NULL) { -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - nss_warning("%px: notify unregister received for unallocated if_num: %d", nss_ctx, if_num); - return NSS_TX_FAILURE_BAD_PARAM; - } -@@ -454,14 +421,14 @@ nss_tx_status_t nss_capwap_notify_unregi - * It's the responsibility of caller to wait and call us again. We return failure saying - * that we can't remove msg handler now. - */ -- if (nss_capwap_refcnt_get(if_num) != 0) { -- spin_unlock_bh(&nss_capwap_spinlock); -+ if (nss_capwap_refcnt(if_num) != 0) { -+ spin_unlock(&nss_capwap_spinlock); - nss_warning("%px: notify unregister tunnel %d: has reference", nss_ctx, if_num); - return NSS_TX_FAILURE_QUEUE; - } - - nss_capwap_set_msg_callback(if_num, NULL, NULL); -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - - return NSS_TX_SUCCESS; - } -@@ -482,12 +449,12 @@ struct nss_ctx_instance *nss_capwap_data - return NULL; - } - -- spin_lock_bh(&nss_capwap_spinlock); -+ spin_lock(&nss_capwap_spinlock); - if (nss_ctx->subsys_dp_register[if_num].ndev != NULL) { -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - return NULL; - } -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - - core_status = nss_core_register_handler(nss_ctx, if_num, nss_capwap_msg_handler, NULL); - if (core_status != NSS_CORE_STATUS_SUCCESS) { -@@ -521,18 +488,18 @@ bool nss_capwap_data_unregister(uint32_t - return false; - } - -- spin_lock_bh(&nss_capwap_spinlock); -+ spin_lock(&nss_capwap_spinlock); - /* - * It's the responsibility of caller to wait and call us again. - */ -- if (nss_capwap_refcnt_get(if_num) != 0) { -- spin_unlock_bh(&nss_capwap_spinlock); -+ if (nss_capwap_refcnt(if_num) != 0) { -+ spin_unlock(&nss_capwap_spinlock); - nss_warning("%px: notify unregister tunnel %d: has reference", nss_ctx, if_num); - return false; - } - h = nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START]; - nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START] = NULL; -- spin_unlock_bh(&nss_capwap_spinlock); -+ spin_unlock(&nss_capwap_spinlock); - - (void) nss_core_unregister_handler(nss_ctx, if_num); - ---- a/nss_capwap_stats.c -+++ b/nss_capwap_stats.c -@@ -50,7 +50,7 @@ static ssize_t nss_capwap_stats_encap(ch - tcnt = s->tx_dropped_ver_mis; - break; - case 5: -- tcnt = s->tx_dropped_inner; -+ tcnt = 0; - break; - case 6: - tcnt = s->tx_dropped_hroom; -@@ -114,7 +114,7 @@ static ssize_t nss_capwap_stats_decap(ch - tcnt = s->rx_frag_gap_drops; - break; - case 9: -- tcnt = s->rx_n2h_drops; -+ tcnt = s->rx_queue_full_drops; - return snprintf(line, len, "%s = %llu (n2h = %llu)\n", nss_capwap_strings_decap_stats[i].stats_name, tcnt, s->rx_n2h_queue_full_drops); - case 10: - tcnt = s->rx_n2h_queue_full_drops; -@@ -166,22 +166,12 @@ static ssize_t nss_capwap_stats_read(str - - for (; if_num <= max_if_num; if_num++) { - bool isthere; -- enum nss_dynamic_interface_type dtype; - - if (nss_is_dynamic_interface(if_num) == false) { - continue; - } - -- dtype = nss_dynamic_interface_get_type(nss_capwap_get_ctx(), if_num); -- -- /* -- * Read encap stats from inner node and decap stats from outer node. -- */ -- if ((type == 1) && (dtype != NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_HOST_INNER)) { -- continue; -- } -- -- if ((type == 0) && (dtype != NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_OUTER)) { -+ if (nss_dynamic_interface_get_type(nss_capwap_get_ctx(), if_num) != NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP) { - continue; - } - ---- a/nss_capwap_strings.c -+++ b/nss_capwap_strings.c -@@ -32,7 +32,7 @@ struct nss_stats_info nss_capwap_strings - {"tx_segments", NSS_STATS_TYPE_SPECIAL}, - {"tx_drop_seg_ref", NSS_STATS_TYPE_DROP}, - {"tx_drop_ver_mismatch",NSS_STATS_TYPE_DROP}, -- {"tx_dropped_inner", NSS_STATS_TYPE_DROP}, -+ {"tx_drop_unalign", NSS_STATS_TYPE_DROP}, - {"tx_drop_hroom", NSS_STATS_TYPE_DROP}, - {"tx_drop_DTLS", NSS_STATS_TYPE_DROP}, - {"tx_drop_nwireless", NSS_STATS_TYPE_DROP}, -@@ -69,7 +69,7 @@ struct nss_stats_info nss_capwap_strings - {"rx_drop_frag_timeout",NSS_STATS_TYPE_DROP}, - {"rx_drop_frag_dup", NSS_STATS_TYPE_DROP}, - {"rx_drop_frag_gap", NSS_STATS_TYPE_DROP}, -- {"rx_drop_n2h", NSS_STATS_TYPE_DROP}, -+ {"rx_drop_qfull", NSS_STATS_TYPE_DROP}, - {"rx_drop_n2h_qfull", NSS_STATS_TYPE_DROP}, - {"rx_drop_mem_fail", NSS_STATS_TYPE_DROP}, - {"rx_drop_csum", NSS_STATS_TYPE_DROP}, ---- a/nss_clmap.c -+++ b/nss_clmap.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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. -@@ -23,7 +23,6 @@ - #include "nss_cmn.h" - #include "nss_tx_rx_common.h" - #include "nss_clmap_stats.h" --#include "nss_clmap_strings.h" - #include "nss_clmap_log.h" - - #define NSS_CLMAP_TX_TIMEOUT 3000 -@@ -107,7 +106,6 @@ static void nss_clmap_msg_handler(struct - switch (nclm->cm.type) { - case NSS_CLMAP_MSG_TYPE_SYNC_STATS: - nss_clmap_stats_sync(nss_ctx, &nclm->msg.stats, ncm->interface); -- nss_clmap_stats_notify(nss_ctx, ncm->interface); - break; - } - -@@ -116,7 +114,7 @@ static void nss_clmap_msg_handler(struct - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data; -+ ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; - } - - /* -@@ -338,9 +336,7 @@ EXPORT_SYMBOL(nss_clmap_get_ctx); - */ - void nss_clmap_init() - { -+ nss_clmap_stats_dentry_create(); - sema_init(&clmap_pvt.sem, 1); - init_completion(&clmap_pvt.complete); -- -- nss_clmap_stats_dentry_create(); -- nss_clmap_strings_dentry_create(); - } ---- a/nss_clmap_stats.c -+++ b/nss_clmap_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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. -@@ -15,25 +15,15 @@ - */ - - #include "nss_tx_rx_common.h" --#include "nss_clmap.h" - #include "nss_clmap_stats.h" --#include "nss_clmap_strings.h" - --/* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_clmap_stats_notifier); -- --/* -- * Spinlock to protect clmap statistics update/read -- */ - DEFINE_SPINLOCK(nss_clmap_stats_lock); - - struct nss_clmap_stats *stats_db[NSS_CLMAP_MAX_DEBUG_INTERFACES] = {NULL}; - - /* - * nss_clmap_interface_type_str -- * Clmap interface type string. -+ * Clmap interface type string. - */ - static char *nss_clmap_interface_type_str[NSS_CLMAP_INTERFACE_TYPE_MAX] = { - "Upstream", -@@ -41,23 +31,34 @@ static char *nss_clmap_interface_type_st - }; - - /* -- * nss_clmap_stats_session_unregister -- * Unregister debug statistic for clmap session. -+ * nss_clmap_stats_str -+ * Clmap statistics strings for nss tunnel stats - */ --void nss_clmap_stats_session_unregister(uint32_t if_num) --{ -- uint32_t i; -- -- spin_lock_bh(&nss_clmap_stats_lock); -- for (i = 0; i < NSS_CLMAP_MAX_DEBUG_INTERFACES; i++) { -- if (stats_db[i] && (stats_db[i]->nss_if_num == if_num)) { -- kfree(stats_db[i]); -- stats_db[i] = NULL; -- break; -- } -- } -- spin_unlock_bh(&nss_clmap_stats_lock); --} -+static char *nss_clmap_stats_str[NSS_CLMAP_INTERFACE_STATS_MAX] = { -+ "rx_pkts", -+ "rx_bytes", -+ "tx_pkts", -+ "tx_bytes", -+ "rx_queue_0_dropped", -+ "rx_queue_1_dropped", -+ "rx_queue_2_dropped", -+ "rx_queue_3_dropped", -+ "MAC DB look up failed", -+ "Invalid packet count", -+ "Headroom drop", -+ "Next node queue full drop", -+ "Pbuf alloc failed drop", -+ "Linear failed drop", -+ "Shared packet count", -+ "Ethernet frame error", -+ "Macdb create requests count", -+ "Macdb create failures MAC exists count", -+ "Macdb create failures MAC table full count", -+ "Macdb destroy requests count", -+ "Macdb destroy failures MAC not found count", -+ "Macdb destroy failures MAC unhashed count", -+ "Macdb flush requests count" -+}; - - /* - * nss_clmap_stats_session_register -@@ -94,6 +95,25 @@ bool nss_clmap_stats_session_register(ui - } - - /* -+ * nss_clmap_stats_session_unregister -+ * Unregister debug statistic for clmap session. -+ */ -+void nss_clmap_stats_session_unregister(uint32_t if_num) -+{ -+ uint32_t i; -+ -+ spin_lock_bh(&nss_clmap_stats_lock); -+ for (i = 0; i < NSS_CLMAP_MAX_DEBUG_INTERFACES; i++) { -+ if (stats_db[i] && (stats_db[i]->nss_if_num == if_num)) { -+ kfree(stats_db[i]); -+ stats_db[i] = NULL; -+ break; -+ } -+ } -+ spin_unlock_bh(&nss_clmap_stats_lock); -+} -+ -+/* - * nss_clmap_get_debug_stats() - * Get clmap debug statistics. - */ -@@ -122,12 +142,12 @@ static int nss_clmap_get_debug_stats(str - static ssize_t nss_clmap_stats_read(struct file *fp, char __user *ubuf, - size_t sz, loff_t *ppos) - { -- uint32_t max_output_lines = (NSS_CLMAP_INTERFACE_STATS_MAX * NSS_CLMAP_MAX_DEBUG_INTERFACES) + NSS_STATS_EXTRA_OUTPUT_LINES; -+ uint32_t max_output_lines = 2 + (NSS_CLMAP_INTERFACE_STATS_MAX * NSS_CLMAP_MAX_DEBUG_INTERFACES + 2) + 2; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - size_t size_wr = 0; - ssize_t bytes_read = 0; - struct net_device *dev; -- uint32_t id; -+ uint32_t id, i; - struct nss_clmap_stats *clmap_stats = NULL; - int interface_cnt; - -@@ -151,7 +171,8 @@ static ssize_t nss_clmap_stats_read(stru - * Get clmap statistics. - */ - interface_cnt = nss_clmap_get_debug_stats(clmap_stats); -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "clmap stats", NSS_STATS_SINGLE_CORE); -+ size_wr = scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\n clmap Interface statistics start:\n\n"); - for (id = 0; id < interface_cnt; id++) { - struct nss_clmap_stats *clmsp = clmap_stats + id; - -@@ -169,10 +190,16 @@ static ssize_t nss_clmap_stats_read(stru - clmsp->nss_if_num, nss_clmap_interface_type_str[clmsp->nss_if_type], dev->name); - dev_put(dev); - -- size_wr += nss_stats_print("clmap", NULL, NSS_STATS_SINGLE_INSTANCE, nss_clmap_strings_stats, -- clmsp->stats, NSS_CLMAP_INTERFACE_STATS_MAX, lbuf, size_wr, size_al); -+ for (i = 0; i < NSS_CLMAP_INTERFACE_STATS_MAX; i++) { -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\t%s = %llu\n", nss_clmap_stats_str[i], -+ clmsp->stats[i]); -+ } -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - } - -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\n clmap Interface statistics end\n"); - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(clmap_stats); -@@ -245,52 +272,3 @@ void nss_clmap_stats_dentry_create(void) - { - nss_stats_create_dentry("clmap", &nss_clmap_stats_ops); - } -- --/* -- * nss_clmap_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_clmap_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_clmap_stats_notification clmap_stats; -- struct nss_clmap_stats *s = NULL; -- int i; -- -- spin_lock_bh(&nss_clmap_stats_lock); -- for (i = 0; i < NSS_CLMAP_MAX_DEBUG_INTERFACES; i++) { -- if (!stats_db[i] || (stats_db[i]->nss_if_num != if_num)) { -- continue; -- } -- -- s = stats_db[i]; -- clmap_stats.core_id = nss_ctx->id; -- clmap_stats.if_num = if_num; -- memcpy(clmap_stats.stats_ctx, s->stats, sizeof(clmap_stats.stats_ctx)); -- spin_unlock_bh(&nss_clmap_stats_lock); -- atomic_notifier_call_chain(&nss_clmap_stats_notifier, NSS_STATS_EVENT_NOTIFY, &clmap_stats); -- return; -- } -- spin_unlock_bh(&nss_clmap_stats_lock); --} -- --/* -- * nss_clmap_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_clmap_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_clmap_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_clmap_stats_unregister_notifier); -- --/* -- * nss_clmap_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_clmap_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_clmap_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_clmap_stats_register_notifier); ---- a/nss_clmap_stats.h -+++ b/nss_clmap_stats.h -@@ -1,6 +1,6 @@ - /* - ****************************************************************************** -- * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019, 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. -@@ -20,11 +20,50 @@ - #define NSS_CLMAP_MAX_DEBUG_INTERFACES 2 * NSS_CLMAP_MAX_INTERFACES - - /* -+ * Clmap NSS interface type. -+ */ -+enum nss_clmap_interface_type { -+ NSS_CLMAP_INTERFACE_TYPE_US, -+ NSS_CLMAP_INTERFACE_TYPE_DS, -+ NSS_CLMAP_INTERFACE_TYPE_MAX -+}; -+ -+/* -+ * Clmap statistic counters. -+ */ -+enum nss_clmap_stats_type { -+ NSS_CLMAP_INTERFACE_STATS_RX_PKTS, -+ NSS_CLMAP_INTERFACE_STATS_RX_BYTES, -+ NSS_CLMAP_INTERFACE_STATS_TX_PKTS, -+ NSS_CLMAP_INTERFACE_STATS_TX_BYTES, -+ NSS_CLMAP_INTERFACE_STATS_RX_QUEUE_0_DROPPED, -+ NSS_CLMAP_INTERFACE_STATS_RX_QUEUE_1_DROPPED, -+ NSS_CLMAP_INTERFACE_STATS_RX_QUEUE_2_DROPPED, -+ NSS_CLMAP_INTERFACE_STATS_RX_QUEUE_3_DROPPED, -+ NSS_CLMAP_INTERFACE_STATS_DROPPED_MACDB_LOOKUP_FAILED, -+ NSS_CLMAP_INTERFACE_STATS_DROPPED_INVALID_PACKET_SIZE, -+ NSS_CLMAP_INTERFACE_STATS_DROPPED_LOW_HEADROOM, -+ NSS_CLMAP_INTERFACE_STATS_DROPPED_NEXT_NODE_QUEUE_FULL, -+ NSS_CLMAP_INTERFACE_STATS_DROPPED_PBUF_ALLOC_FAILED, -+ NSS_CLMAP_INTERFACE_STATS_DROPPED_LINEAR_FAILED, -+ NSS_CLMAP_INTERFACE_STATS_SHARED_PACKET_CNT, -+ NSS_CLMAP_INTERFACE_STATS_ETHERNET_FRAME_ERROR, -+ NSS_CLMAP_INTERFACE_STATS_MACDB_CREATE_REQUESTS_CNT, -+ NSS_CLMAP_INTERFACE_STATS_MACDB_CREATE_MAC_EXISTS_CNT, -+ NSS_CLMAP_INTERFACE_STATS_MACDB_CREATE_MAC_TABLE_FULL_CNT, -+ NSS_CLMAP_INTERFACE_STATS_MACDB_DESTROY_REQUESTS_CNT, -+ NSS_CLMAP_INTERFACE_STATS_MACDB_DESTROY_MAC_NOT_FOUND_CNT, -+ NSS_CLMAP_INTERFACE_STATS_MACDB_DESTROY_MAC_UNHASHED_CNT, -+ NSS_CLMAP_INTERFACE_STATS_MACDB_FLUSH_REQUESTS_CNT, -+ NSS_CLMAP_INTERFACE_STATS_MAX, -+}; -+ -+/* - * Clmap session debug statistics. - */ - struct nss_clmap_stats { -- uint64_t stats[NSS_CLMAP_INTERFACE_STATS_MAX]; /* Clmap statistics. */ -- int32_t if_index; /* Interface index. */ -+ uint64_t stats[NSS_CLMAP_INTERFACE_STATS_MAX]; -+ int32_t if_index; - uint32_t nss_if_num; /* NSS interface number. */ - enum nss_clmap_interface_type nss_if_type; /* NSS interface type. */ - bool valid; -@@ -33,7 +72,6 @@ struct nss_clmap_stats { - /* - * Clmap statistics APIs. - */ --extern void nss_clmap_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); - extern bool nss_clmap_stats_session_register(uint32_t if_num, enum nss_clmap_interface_type if_type, struct net_device *netdev); - extern void nss_clmap_stats_session_unregister(uint32_t if_num); - extern void nss_clmap_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_clmap_stats_msg *stats_msg, uint32_t if_num); ---- a/nss_clmap_strings.c -+++ /dev/null -@@ -1,73 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2020-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_strings.h" --#include "nss_clmap_strings.h" -- --/* -- * nss_clmap_strings_stats -- * Clmap statistics strings for nss tunnel stats -- */ --struct nss_stats_info nss_clmap_strings_stats[NSS_CLMAP_INTERFACE_STATS_MAX] = { -- {"rx_pkts", NSS_STATS_TYPE_COMMON}, -- {"rx_bytes", NSS_STATS_TYPE_COMMON}, -- {"tx_pkts", NSS_STATS_TYPE_COMMON}, -- {"tx_bytes", NSS_STATS_TYPE_COMMON}, -- {"rx_queue_0_dropped", NSS_STATS_TYPE_DROP}, -- {"rx_queue_1_dropped", NSS_STATS_TYPE_DROP}, -- {"rx_queue_2_dropped", NSS_STATS_TYPE_DROP}, -- {"rx_queue_3_dropped", NSS_STATS_TYPE_DROP}, -- {"MAC DB look up failed", NSS_STATS_TYPE_SPECIAL}, -- {"Invalid packet count", NSS_STATS_TYPE_SPECIAL}, -- {"Headroom drop", NSS_STATS_TYPE_SPECIAL}, -- {"Next node queue full drop", NSS_STATS_TYPE_SPECIAL}, -- {"Pbuf alloc failed drop", NSS_STATS_TYPE_SPECIAL}, -- {"Linear failed drop", NSS_STATS_TYPE_SPECIAL}, -- {"Shared packet count", NSS_STATS_TYPE_SPECIAL}, -- {"Ethernet frame error", NSS_STATS_TYPE_SPECIAL}, -- {"Macdb create requests count", NSS_STATS_TYPE_SPECIAL}, -- {"Macdb create failures MAC exists count", NSS_STATS_TYPE_SPECIAL}, -- {"Macdb create failures MAC table full count", NSS_STATS_TYPE_SPECIAL}, -- {"Macdb destroy requests count", NSS_STATS_TYPE_SPECIAL}, -- {"Macdb destroy failures MAC not found count", NSS_STATS_TYPE_SPECIAL}, -- {"Macdb destroy failures MAC unhashed count", NSS_STATS_TYPE_SPECIAL}, -- {"Macdb flush requests count", NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_clmap_strings_read() -- * Read clmap statistics names -- */ --static ssize_t nss_clmap_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_clmap_strings_stats, NSS_CLMAP_INTERFACE_STATS_MAX); --} -- --/* -- * nss_clmap_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(clmap); -- --/* -- * nss_clmap_strings_dentry_create() -- * Create clmap statistics strings debug entry. -- */ --void nss_clmap_strings_dentry_create(void) --{ -- nss_strings_create_dentry("clmap", &nss_clmap_strings_ops); --} ---- a/nss_clmap_strings.h -+++ /dev/null -@@ -1,25 +0,0 @@ --/* -- *************************************************************************** -- * Copyright (c) 2020-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. -- *************************************************************************** -- */ -- --#ifndef __NSS_CLMAP_STRINGS_H --#define __NSS_CLMAP_STRINGS_H -- --#include "nss_clmap_stats.h" -- --extern struct nss_stats_info nss_clmap_strings_stats[NSS_CLMAP_INTERFACE_STATS_MAX]; --extern void nss_clmap_strings_dentry_create(void); -- --#endif /* __NSS_CLMAP_STRINGS_H */ ---- a/nss_cmn.c -+++ b/nss_cmn.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2020, 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. -@@ -197,7 +197,8 @@ bool nss_cmn_interface_is_redirect(struc - { - enum nss_dynamic_interface_type type = nss_dynamic_interface_get_type(nss_ctx, interface_num); - -- return type == NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H -+ return type == NSS_DYNAMIC_INTERFACE_TYPE_WIFI -+ || type == NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H - || type == NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N - || type == NSS_DYNAMIC_INTERFACE_TYPE_VIRTIF_DEPRECATED; - } --- a/nss_core.c +++ b/nss_core.c -@@ -1,12 +1,9 @@ - /* - ************************************************************************** -- * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2013-2020, 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 -@@ -37,13 +34,7 @@ - #endif - #include - #include "nss_tx_rx_common.h" -- --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - #include "nss_data_plane.h" --#endif --#ifdef NSS_DATA_PLANE_LITE_SUPPORT --#include "nss_data_plane_lite.h" --#endif - - #define NSS_CORE_JUMBO_LINEAR_BUF_SIZE 128 - -@@ -61,7 +52,9 @@ +@@ -52,7 +52,9 @@ (((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)))) || \ (((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)))) || \ (((LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)))) || \ @@ -7738,124 +383,145 @@ #error "Check skb recycle code in this file to match Linux version" #endif -@@ -85,10 +78,6 @@ uint16_t pn_qlimits[NSS_MAX_NUM_PRI] = { - module_param_array(pn_qlimits, short, NULL, 0); - MODULE_PARM_DESC(pn_qlimits, "Queue limit per queue"); - --static int qos_mem_size = 0; --module_param(qos_mem_size, int, S_IRUGO); --MODULE_PARM_DESC(qos_mem_size, "QoS memory size"); -- - /* - * Atomic variables to control jumbo_mru & paged_mode - */ -@@ -96,24 +85,6 @@ static atomic_t jumbo_mru; - static atomic_t paged_mode; - - /* -- * nss_core_update_qos_mem_size() -- * Update the memory size for QoS -- */ --void nss_core_update_qos_mem_size(int size) --{ -- qos_mem_size = size; --} -- --/* -- * nss_core_get_qos_mem_size() -- * Get the memeory size for QoS -- */ --int nss_core_get_qos_mem_size(void) --{ -- return qos_mem_size; --} -- --/* - * nss_core_update_max_ipv4_conn() - * Update the maximum number of configured IPv4 connections - */ -@@ -221,12 +192,12 @@ uint32_t nss_core_register_msg_handler(s - /* - * Check if already registered +@@ -381,7 +383,7 @@ void nss_core_handle_nss_status_pkt(stru + * Check for version number */ -- if (nss_ctx->nss_rx_interface_handlers[interface].msg_cb) { -+ if (nss_ctx->nss_rx_interface_handlers[nss_ctx->id][interface].msg_cb) { - nss_warning("Error - Duplicate Interface CB Registered for interface %d\n", interface); - return NSS_CORE_STATUS_FAILURE; + if (ncm->version != expected_version) { +- nss_warning("%p: Message %d for interface %d received with invalid version %d, expected version %d", ++ nss_warning("%px: Message %d for interface %d received with invalid version %d, expected version %d", + nss_ctx, ncm->type, nss_if, ncm->version, expected_version); + return; } - -- nss_ctx->nss_rx_interface_handlers[interface].msg_cb = msg_cb; -+ nss_ctx->nss_rx_interface_handlers[nss_ctx->id][interface].msg_cb = msg_cb; - - return NSS_CORE_STATUS_SUCCESS; - } -@@ -245,7 +216,7 @@ uint32_t nss_core_unregister_msg_handler - return NSS_CORE_STATUS_FAILURE; - } - -- nss_ctx->nss_rx_interface_handlers[interface].msg_cb = NULL; -+ nss_ctx->nss_rx_interface_handlers[nss_ctx->id][interface].msg_cb = NULL; - - return NSS_CORE_STATUS_SUCCESS; - } -@@ -270,13 +241,13 @@ uint32_t nss_core_register_handler(struc - /* - * Check if already registered +@@ -390,7 +392,7 @@ void nss_core_handle_nss_status_pkt(stru + * Validate message size */ -- if (nss_ctx->nss_rx_interface_handlers[interface].cb != NULL) { -+ if (nss_ctx->nss_rx_interface_handlers[nss_ctx->id][interface].cb != NULL) { - nss_warning("Error - Duplicate Interface CB Registered for interface %d\n", interface); - return NSS_CORE_STATUS_FAILURE; + if (ncm->len > nbuf->len) { +- nss_warning("%p: Message %d for interface %d received with invalid length %d, expected length %d", ++ nss_warning("%px: Message %d for interface %d received with invalid length %d, expected length %d", + nss_ctx, ncm->type, nss_if, nbuf->len, ncm->len); + return; } - -- nss_ctx->nss_rx_interface_handlers[interface].cb = cb; -- nss_ctx->nss_rx_interface_handlers[interface].app_data = app_data; -+ nss_ctx->nss_rx_interface_handlers[nss_ctx->id][interface].cb = cb; -+ nss_ctx->nss_rx_interface_handlers[nss_ctx->id][interface].app_data = app_data; - - return NSS_CORE_STATUS_SUCCESS; - } -@@ -295,8 +266,8 @@ uint32_t nss_core_unregister_handler(str - return NSS_CORE_STATUS_FAILURE; - } - -- nss_ctx->nss_rx_interface_handlers[interface].cb = NULL; -- nss_ctx->nss_rx_interface_handlers[interface].app_data = NULL; -+ nss_ctx->nss_rx_interface_handlers[nss_ctx->id][interface].cb = NULL; -+ nss_ctx->nss_rx_interface_handlers[nss_ctx->id][interface].app_data = NULL; - - return NSS_CORE_STATUS_SUCCESS; - } -@@ -325,17 +296,6 @@ void nss_core_set_subsys_dp_type(struct - } - - /* -- * nss_core_is_mq_enabled() -- * Get multi-queue status. -- * -- * Returns 'true' if multi-queue is enabled otherwise returns 'false'. -- */ --bool nss_core_is_mq_enabled(void) --{ -- return pn_mq_en; --} -- --/* - * nss_core_register_subsys_dp() - * Registers a netdevice and associated information at a given interface. - * -@@ -445,8 +405,8 @@ void nss_core_handle_nss_status_pkt(stru +@@ -399,7 +401,7 @@ void nss_core_handle_nss_status_pkt(stru + * Check for validity of interface number + */ + if (nss_if >= NSS_MAX_NET_INTERFACES) { +- nss_warning("%p: Message %d received with invalid interface number %d", nss_ctx, ncm->type, nss_if); ++ nss_warning("%px: Message %d received with invalid interface number %d", nss_ctx, ncm->type, nss_if); return; } -- cb = nss_ctx->nss_rx_interface_handlers[nss_if].cb; -- app_data = nss_ctx->nss_rx_interface_handlers[nss_if].app_data; -+ cb = nss_ctx->nss_rx_interface_handlers[nss_ctx->id][nss_if].cb; -+ app_data = nss_ctx->nss_rx_interface_handlers[nss_ctx->id][nss_if].app_data; +@@ -407,14 +409,14 @@ void nss_core_handle_nss_status_pkt(stru + app_data = nss_ctx->nss_rx_interface_handlers[nss_ctx->id][nss_if].app_data; if (!cb) { - nss_warning("%px: Callback not registered for interface %d", nss_ctx, nss_if); -@@ -964,6 +924,7 @@ static inline void nss_core_handle_buffe +- nss_warning("%p: Callback not registered for interface %d", nss_ctx, nss_if); ++ nss_warning("%px: Callback not registered for interface %d", nss_ctx, nss_if); + return; + } + + cb(nss_ctx, ncm, app_data); + + if (ncm->interface != nss_if) { +- nss_warning("%p: Invalid NSS I/F %d expected %d", nss_ctx, ncm->interface, nss_if); ++ nss_warning("%px: Invalid NSS I/F %d expected %d", nss_ctx, ncm->interface, nss_if); + } + + return; +@@ -464,16 +466,16 @@ static uint32_t nss_soc_mem_info(void) + + ppp = (__be32 *)of_get_property(node, "#address-cells", NULL); + addr_cells = ppp ? be32_to_cpup(ppp) : 2; +- nss_info("%p addr cells %d\n", ppp, addr_cells); ++ nss_info("%px addr cells %d\n", ppp, addr_cells); + ppp = (__be32 *)of_get_property(node, "#size-cells", NULL); + size_cells = ppp ? be32_to_cpup(ppp) : 2; +- nss_info("%p size cells %d\n", ppp, size_cells); ++ nss_info("%px size cells %d\n", ppp, size_cells); + + for_each_child_of_node(node, snode) { + /* + * compare (snode->full_name, "/reserved-memory/nss@40000000") may be safer + */ +- nss_info("%p snode %s fn %s\n", snode, snode->name, snode->full_name); ++ nss_info("%px snode %s fn %s\n", snode, snode->name, snode->full_name); + if (strcmp(snode->name, "nss") == 0) + break; + } +@@ -509,8 +511,9 @@ static void nss_get_ddr_info(struct nss_ + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)) + cached = global_page_state(NR_FILE_PAGES); + #else +- cached = global_zone_page_state(NR_FILE_PAGES); ++ cached = global_node_page_state(NR_FILE_PAGES); + #endif ++ + avail_ddr = (vals.totalram + cached + vals.sharedram) * vals.mem_unit; + mmu->num_active_cores = nss_top_main.num_nss; + +@@ -569,7 +572,7 @@ case3: + } + } + of_node_put(node); +- nss_info_always("incorrect memory info %p items %d\n", ++ nss_info_always("incorrect memory info %px items %d\n", + ppp, n_items); + } + +@@ -599,7 +602,7 @@ static void nss_send_ddr_info(struct nss + struct nss_n2h_msg nnm; + struct nss_cmn_msg *ncm = &nnm.cm; + uint32_t ret; +- nss_info("%p: send DDR info\n", nss_own); ++ nss_info("%px: send DDR info\n", nss_own); + + nss_cmn_msg_init(ncm, NSS_N2H_INTERFACE, NSS_TX_DDR_INFO_VIA_N2H_CFG, + sizeof(struct nss_mmu_ddr_info), NULL, NULL); +@@ -609,7 +612,7 @@ static void nss_send_ddr_info(struct nss + + ret = nss_core_send_cmd(nss_own, &nnm, sizeof(nnm), NSS_NBUF_PAYLOAD_SIZE); + if (ret != NSS_TX_SUCCESS) { +- nss_info_always("%p: Failed to send DDR info for core %d\n", nss_own, nss_own->id); ++ nss_info_always("%px: Failed to send DDR info for core %d\n", nss_own, nss_own->id); + } + } + +@@ -653,7 +656,7 @@ static inline uint16_t nss_core_cause_to + static inline void nss_dump_desc(struct nss_ctx_instance *nss_ctx, struct n2h_descriptor *desc) + { + printk("bad descriptor dump for nss core = %d\n", nss_ctx->id); +- printk("\topaque = %p\n", (void *)desc->opaque); ++ printk("\topaque = %px\n", (void *)desc->opaque); + printk("\tinterface = %d\n", desc->interface_num); + printk("\tbuffer_type = %d\n", desc->buffer_type); + printk("\tbit_flags = %x\n", desc->bit_flags); +@@ -759,7 +762,7 @@ static inline void nss_core_handle_virt_ + */ + ndev = subsys_dp_reg->ndev; + if (unlikely(!ndev)) { +- nss_warning("%p: Received packet for unregistered virtual interface %d", ++ nss_warning("%px: Received packet for unregistered virtual interface %d", + nss_ctx, interface_num); + + /* +@@ -830,7 +833,7 @@ static inline void nss_core_handle_virt_ + xmit_ret = ndev->netdev_ops->ndo_start_xmit(nbuf, ndev); + if (unlikely(xmit_ret == NETDEV_TX_BUSY)) { + dev_kfree_skb_any(nbuf); +- nss_info("%p: Congestion at virtual interface %d, %p", nss_ctx, interface_num, ndev); ++ nss_info("%px: Congestion at virtual interface %d, %px", nss_ctx, interface_num, ndev); + } + dev_put(ndev); + } +@@ -892,7 +895,7 @@ static inline void nss_core_handle_buffe + /* + * linearize or free if requested. + */ +- if (unlikely(skb_is_nonlinear(nbuf))) { ++ if (unlikely(skb_is_nonlinear(nbuf))) { + if (nss_core_skb_needs_linearize(nbuf, ndev->features) && __skb_linearize(nbuf)) { + dev_kfree_skb_any(nbuf); + return; +@@ -921,6 +924,7 @@ static inline void nss_core_handle_buffe dev_put(ndev); } @@ -7863,7 +529,22 @@ /* * nss_core_handle_ext_buffer_pkt() * Handle Extended data plane packet received on physical or virtual interface. -@@ -1008,6 +969,7 @@ static inline void nss_core_handle_ext_b +@@ -950,11 +954,11 @@ static inline void nss_core_handle_ext_b + ext_cb = subsys_dp_reg->ext_cb; + if (likely(ext_cb) && likely(ndev)) { + +- if (unlikely(skb_is_nonlinear(nbuf))) { ++ if (unlikely(skb_is_nonlinear(nbuf))) { + if (nss_core_skb_needs_linearize(nbuf, ndev->features) && __skb_linearize(nbuf)) { + /* +- * We needed to linearize, but __skb_linearize() failed. So free the nbuf. +- */ ++ * We needed to linearize, but __skb_linearize() failed. So free the nbuf. ++ */ + dev_kfree_skb_any(nbuf); + return; + } +@@ -965,6 +969,7 @@ static inline void nss_core_handle_ext_b dev_kfree_skb_any(nbuf); } } @@ -7871,27 +552,31 @@ /* * nss_core_rx_pbuf() -@@ -1024,7 +986,9 @@ static inline void nss_core_rx_pbuf(stru +@@ -981,8 +986,10 @@ static inline void nss_core_rx_pbuf(stru NSS_PKT_STATS_DEC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); if (interface_num >= NSS_MAX_NET_INTERFACES) { +#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_INVALID_INTERFACE]); +- nss_warning("%p: Invalid interface_num: %d", nss_ctx, interface_num); +#endif - nss_warning("%px: Invalid interface_num: %d", nss_ctx, interface_num); ++ nss_warning("%px: Invalid interface_num: %d", nss_ctx, interface_num); dev_kfree_skb_any(nbuf); return; -@@ -1034,7 +998,9 @@ static inline void nss_core_rx_pbuf(stru + } +@@ -991,8 +998,10 @@ static inline void nss_core_rx_pbuf(stru * Check if core_id value is valid. */ if (core_id > nss_top_main.num_nss) { +#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_INVALID_CORE_ID]); +- nss_warning("%p: Invalid core id: %d", nss_ctx, core_id); +#endif - nss_warning("%px: Invalid core id: %d", nss_ctx, core_id); ++ nss_warning("%px: Invalid core id: %d", nss_ctx, core_id); dev_kfree_skb_any(nbuf); return; -@@ -1066,9 +1032,11 @@ static inline void nss_core_rx_pbuf(stru + } +@@ -1023,9 +1032,11 @@ static inline void nss_core_rx_pbuf(stru nss_core_handle_bounced_pkt(nss_ctx, reg, nbuf); break; @@ -7903,26 +588,157 @@ case N2H_BUFFER_STATUS: NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_STATUS]); -@@ -1100,7 +1068,9 @@ static inline void nss_core_rx_pbuf(stru +@@ -1051,19 +1062,36 @@ static inline void nss_core_rx_pbuf(stru + status = nss_core_send_buffer(nss_ctx, 0, nbuf, NSS_IF_H2N_DATA_QUEUE, H2N_BUFFER_RATE_TEST, H2N_BIT_FLAG_BUFFER_REUSABLE); + if (unlikely(status != NSS_CORE_STATUS_SUCCESS)) { + dev_kfree_skb_any(nbuf); +- nss_warning("%p: Unable to enqueue\n", nss_ctx); ++ nss_warning("%px: Unable to enqueue\n", nss_ctx); + } + nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_DATA_COMMAND_QUEUE); break; default: +#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_RX_INVALID_BUFFER_TYPE]); +- nss_warning("%p: Invalid buffer type %d received from NSS", nss_ctx, buffer_type); +#endif - nss_warning("%px: Invalid buffer type %d received from NSS", nss_ctx, buffer_type); ++ nss_warning("%px: Invalid buffer type %d received from NSS", nss_ctx, buffer_type); dev_kfree_skb_any(nbuf); } -@@ -1116,7 +1086,7 @@ static inline void nss_core_set_skb_clas - #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) - nbuf->tc_verd = SET_TC_NCLS_NSS(nbuf->tc_verd); - #else -- skb_set_tc_classify_offload(nbuf); -+ skb_skip_tc_classify(nbuf); - #endif - #endif } -@@ -1658,7 +1628,7 @@ static int32_t nss_core_handle_cause_que + + /* ++ * nss_core_set_skb_classify() ++ * Set skb field to avoid ingress shaping. ++ */ ++static inline void nss_core_set_skb_classify(struct sk_buff *nbuf) ++{ ++#ifdef CONFIG_NET_CLS_ACT ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) ++ nbuf->tc_verd = SET_TC_NCLS_NSS(nbuf->tc_verd); ++#else ++ skb_skip_tc_classify(nbuf); ++#endif ++#endif ++} ++ ++/* + * nss_core_handle_nrfrag_skb() + * Handled the processing of fragmented skb's + */ +@@ -1091,7 +1119,7 @@ static inline bool nss_core_handle_nr_fr + * Free the old head as the frag list is corrupt. + */ + if (unlikely(jumbo_start)) { +- nss_warning("%p: received a full frame before a last", jumbo_start); ++ nss_warning("%px: received a full frame before a last", jumbo_start); + dev_kfree_skb_any(jumbo_start); + *jumbo_start_ptr = NULL; + } +@@ -1116,9 +1144,10 @@ static inline bool nss_core_handle_nr_fr + * ingress shaped flag set. + */ + if (unlikely(desc->bit_flags & N2H_BIT_FLAG_INGRESS_SHAPED)) { +- nbuf->tc_verd = SET_TC_NCLS_NSS(nbuf->tc_verd); ++ nss_core_set_skb_classify(nbuf); + } + #endif ++ + goto pull; + } + +@@ -1138,7 +1167,7 @@ static inline bool nss_core_handle_nr_fr + * Free the old head as the frag list is corrupt. + */ + if (unlikely(jumbo_start)) { +- nss_warning("%p: received the second head before a last", jumbo_start); ++ nss_warning("%px: received the second head before a last", jumbo_start); + dev_kfree_skb_any(jumbo_start); + } + +@@ -1156,7 +1185,7 @@ static inline bool nss_core_handle_nr_fr + * ingress shaped flag set. + */ + if (unlikely(desc->bit_flags & N2H_BIT_FLAG_INGRESS_SHAPED)) { +- nbuf->tc_verd = SET_TC_NCLS_NSS(nbuf->tc_verd); ++ nss_core_set_skb_classify(nbuf); + } + #endif + +@@ -1181,7 +1210,7 @@ static inline bool nss_core_handle_nr_fr + /* + * Middle before first! Free the middle. + */ +- nss_warning("%p: saw a middle skb before head", nbuf); ++ nss_warning("%px: saw a middle skb before head", nbuf); + dev_kfree_skb_any(nbuf); + return false; + } +@@ -1219,7 +1248,7 @@ pull: + if (buffer_type != N2H_BUFFER_STATUS) { + if (!pskb_may_pull(nbuf, ETH_HLEN)) { + dev_kfree_skb(nbuf); +- nss_warning("%p: could not pull eth header", nbuf); ++ nss_warning("%px: could not pull eth header", nbuf); + return false; + } + } +@@ -1258,7 +1287,7 @@ static inline bool nss_core_handle_linea + * Free the old head as the frag list is corrupt. + */ + if (unlikely(head)) { +- nss_warning("%p: received a full frame before a last", head); ++ nss_warning("%px: received a full frame before a last", head); + dev_kfree_skb_any(head); + *head_ptr = NULL; + } +@@ -1271,7 +1300,7 @@ static inline bool nss_core_handle_linea + * ingress shaped flag set. + */ + if (unlikely(desc->bit_flags & N2H_BIT_FLAG_INGRESS_SHAPED)) { +- nbuf->tc_verd = SET_TC_NCLS_NSS(nbuf->tc_verd); ++ nss_core_set_skb_classify(nbuf); + } + #endif + +@@ -1300,7 +1329,7 @@ static inline bool nss_core_handle_linea + * Free the old head as the frag list is corrupt. + */ + if (unlikely(head)) { +- nss_warning("%p: received the second head before a last", head); ++ nss_warning("%px: received the second head before a last", head); + NSS_PKT_STATS_DEC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); + dev_kfree_skb_any(head); + } +@@ -1312,7 +1341,7 @@ static inline bool nss_core_handle_linea + /* + * We don't support chain in a chain. + */ +- nss_warning("%p: skb already has a fraglist", nbuf); ++ nss_warning("%px: skb already has a fraglist", nbuf); + NSS_PKT_STATS_DEC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); + dev_kfree_skb_any(nbuf); + return false; +@@ -1329,7 +1358,7 @@ static inline bool nss_core_handle_linea + * ingress shaped flag set. + */ + if (unlikely(desc->bit_flags & N2H_BIT_FLAG_INGRESS_SHAPED)) { +- nbuf->tc_verd = SET_TC_NCLS_NSS(nbuf->tc_verd); ++ nss_core_set_skb_classify(nbuf); + } + #endif + +@@ -1352,7 +1381,7 @@ static inline bool nss_core_handle_linea + /* + * Middle before first! Free the middle. + */ +- nss_warning("%p: saw a middle skb before head", nbuf); ++ nss_warning("%px: saw a middle skb before head", nbuf); + dev_kfree_skb_any(nbuf); + + return false; +@@ -1599,7 +1628,7 @@ static int32_t nss_core_handle_cause_que * */ if (unlikely((buffer_type == N2H_BUFFER_CRYPTO_RESP))) { @@ -7931,106 +747,170 @@ goto consume; } -@@ -1734,7 +1704,6 @@ static void nss_core_init_nss(struct nss - { - struct nss_top_instance *nss_top; - int ret; -- int i; +@@ -1612,8 +1641,8 @@ static int32_t nss_core_handle_cause_que + * a linear skb chain. If so we need to free. + */ + if (unlikely(n2h_desc_ring->head)) { +- nss_warning("%p: we should not have an incomplete paged skb while" +- " constructing a linear skb %p", nbuf, n2h_desc_ring->head); ++ nss_warning("%px: we should not have an incomplete paged skb while" ++ " constructing a linear skb %px", nbuf, n2h_desc_ring->head); - NSS_CORE_DMA_CACHE_MAINT((void *)if_map, sizeof(*if_map), DMA_FROM_DEVICE); - NSS_CORE_DSB(); -@@ -1750,9 +1719,6 @@ static void nss_core_init_nss(struct nss - #ifdef NSS_DRV_C2C_ENABLE - nss_ctx->c2c_start = nss_ctx->meminfo_ctx.c2c_start_dma; - #endif -- for (i = 0; i < NSS_H2N_DESC_RING_NUM; i++) { -- nss_ctx->h2n_desc_rings[i].nss_index_local = 0; -- } + NSS_PKT_STATS_DEC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); + dev_kfree_skb_any(n2h_desc_ring->head); +@@ -1632,8 +1661,8 @@ static int32_t nss_core_handle_cause_que + * a paged skb. If so we need to free the paged_skb and handle the linear skb. + */ + if (unlikely(n2h_desc_ring->jumbo_start)) { +- nss_warning("%p: we should not have an incomplete linear skb while" +- " constructing a paged skb %p", nbuf, n2h_desc_ring->jumbo_start); ++ nss_warning("%px: we should not have an incomplete linear skb while" ++ " constructing a paged skb %px", nbuf, n2h_desc_ring->jumbo_start); - nss_top = nss_ctx->nss_top; - spin_lock_bh(&nss_top->lock); -@@ -1763,12 +1729,6 @@ static void nss_core_init_nss(struct nss + NSS_PKT_STATS_DEC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NSS_SKB_COUNT]); + dev_kfree_skb_any(n2h_desc_ring->jumbo_start); +@@ -1699,7 +1728,7 @@ static void nss_core_init_nss(struct nss + if (nss_ctx->id) { ret = nss_n2h_update_queue_config_async(nss_ctx, pn_mq_en, pn_qlimits); if (ret != NSS_TX_SUCCESS) { - nss_warning("%px: Failed to send pnode queue config to core 1\n", nss_ctx); -- return; -- } -- -- ret = nss_project_pri_mq_map_configure(nss_ctx); -- if (ret != NSS_TX_SUCCESS) { -- nss_warning("%px: Failed to send pnode priority to multi-queue config to core 1\n", nss_ctx); +- nss_warning("Failed to send pnode queue config to core 1\n"); ++ nss_warning("%px: Failed to send pnode queue config to core 1\n", nss_ctx); } return; } -@@ -1776,21 +1736,20 @@ static void nss_core_init_nss(struct nss - /* - * If nss core0 is up, then we are ready to hook to nss-gmac - */ --#if defined(NSS_DATA_PLANE_GENERIC_SUPPORT) || defined(NSS_DATA_PLANE_LITE_SUPPORT) --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - if (nss_data_plane_schedule_registration()) { -+ - /* - * Configure the maximum number of IPv4/IPv6 +@@ -1714,9 +1743,14 @@ static void nss_core_init_nss(struct nss * connections supported by the accelerator. */ --#ifdef NSS_DRV_IPV4_ENABLE nss_ipv4_conn_cfg = max_ipv4_conn; -- nss_ipv4_update_conn_count(max_ipv4_conn); --#endif - - #ifdef NSS_DRV_IPV6_ENABLE ++ ++#ifdef NSS_DRV_IPV6_ENABLE nss_ipv6_conn_cfg = max_ipv6_conn; -+ nss_ipv4_update_conn_count(max_ipv4_conn); + nss_ipv4_update_conn_count(max_ipv4_conn); nss_ipv6_update_conn_count(max_ipv6_conn); +#else + nss_ipv4_update_conn_count(max_ipv4_conn); - #endif ++#endif #ifdef NSS_MEM_PROFILE_LOW -@@ -1804,25 +1763,11 @@ static void nss_core_init_nss(struct nss - nss_warning("%px: Failed to update empty buffer pool config\n", nss_ctx); + /* +@@ -1726,7 +1760,7 @@ static void nss_core_init_nss(struct nss + */ + ret = nss_n2h_cfg_empty_pool_size(nss_ctx, NSS_LOW_MEM_EMPTY_POOL_BUF_SZ); + if (ret != NSS_TX_SUCCESS) { +- nss_warning("%p: Failed to update empty buffer pool config\n", nss_ctx); ++ nss_warning("%px: Failed to update empty buffer pool config\n", nss_ctx); } #endif -- --#ifdef NSS_DRV_SHAPER_ENABLE -- ret = nss_n2h_cfg_qos_mem_size(nss_ctx, qos_mem_size); -- if (ret != NSS_TX_SUCCESS) { -- nss_warning("%px: Failed to update QoS memory pool config\n", nss_ctx); -- } --#endif --#endif /* NSS_DATA_PLANE_GENERIC_SUPPORT */ -- --#ifdef NSS_DATA_PLANE_LITE_SUPPORT -- if (nss_data_plane_lite_schedule_registration()) { -- nss_data_plane_lite_register(nss_ctx); --#endif } else { - spin_lock_bh(&nss_top->lock); - nss_ctx->state = NSS_CORE_STATE_UNINITIALIZED; - spin_unlock_bh(&nss_top->lock); - } --#endif /* NSS_DATA_PLANE_GENERIC_SUPPORT || NSS_DATA_PLANE_LITE_SUPPORT */ - } +@@ -1764,7 +1798,7 @@ static void nss_core_alloc_paged_buffers + * ERR: + */ + NSS_PKT_STATS_INC(&nss_top->stats_drv[alloc_fail_count]); +- nss_warning("%p: Could not obtain empty paged buffer", nss_ctx); ++ nss_warning("%px: Could not obtain empty paged buffer", nss_ctx); + break; + } - /* -@@ -2281,15 +2226,6 @@ static void nss_core_handle_cause_nonque - #endif - } +@@ -1775,7 +1809,7 @@ static void nss_core_alloc_paged_buffers + */ + dev_kfree_skb_any(nbuf); + NSS_PKT_STATS_INC(&nss_top->stats_drv[alloc_fail_count]); +- nss_warning("%p: Could not obtain empty page", nss_ctx); ++ nss_warning("%px: Could not obtain empty page", nss_ctx); + break; + } + +@@ -1798,7 +1832,7 @@ static void nss_core_alloc_paged_buffers + * ERR: + */ + dev_kfree_skb_any(nbuf); +- nss_warning("%p: DMA mapping failed for empty buffer", nss_ctx); ++ nss_warning("%px: DMA mapping failed for empty buffer", nss_ctx); + break; + } + /* +@@ -1856,7 +1890,7 @@ static void nss_core_alloc_jumbo_mru_buf + * ERR: + */ + NSS_PKT_STATS_INC(&nss_top->stats_drv[NSS_DRV_STATS_NBUF_ALLOC_FAILS]); +- nss_warning("%p: Could not obtain empty jumbo mru buffer", nss_ctx); ++ nss_warning("%px: Could not obtain empty jumbo mru buffer", nss_ctx); + break; + } + +@@ -1871,7 +1905,7 @@ static void nss_core_alloc_jumbo_mru_buf + * ERR: + */ + dev_kfree_skb_any(nbuf); +- nss_warning("%p: DMA mapping failed for empty buffer", nss_ctx); ++ nss_warning("%px: DMA mapping failed for empty buffer", nss_ctx); + break; + } + +@@ -1932,7 +1966,7 @@ static void nss_core_alloc_max_avail_siz + * ERR: + */ + NSS_PKT_STATS_INC(&nss_top->stats_drv[NSS_DRV_STATS_NBUF_ALLOC_FAILS]); +- nss_warning("%p: Could not obtain empty buffer", nss_ctx); ++ nss_warning("%px: Could not obtain empty buffer", nss_ctx); + break; + } + +@@ -1946,7 +1980,7 @@ static void nss_core_alloc_max_avail_siz + * ERR: + */ + dev_kfree_skb_any(nbuf); +- nss_warning("%p: DMA mapping failed for empty buffer", nss_ctx); ++ nss_warning("%px: DMA mapping failed for empty buffer", nss_ctx); + break; + } + +@@ -2023,7 +2057,7 @@ static inline void nss_core_handle_empty + mask = size - 1; + count = ((nss_index - hlos_index - 1) + size) & (mask); + +- nss_trace("%p: Adding %d buffers to empty queue\n", nss_ctx, count); ++ nss_trace("%px: Adding %d buffers to empty queue\n", nss_ctx, count); --#if defined(NSS_DRV_EDMA_LITE_ENABLE) -- /* -- * check if point offload it enabled; if yes then send message -- */ -- if (nss_edma_lite_enabled(nss_ctx) && !nss_edma_lite_is_configured()) { -- nss_edma_lite_msg_cfg_map(nss_ctx); -- } --#endif -- /* - * TODO: find better mechanism to handle empty buffers - */ -@@ -2658,7 +2594,11 @@ static inline bool nss_core_skb_can_reus + * Fill empty buffer queue with buffers leaving one empty descriptor +@@ -2074,7 +2108,7 @@ static inline void nss_core_handle_paged + + mask = size - 1; + count = ((nss_index - hlos_index - 1) + size) & (mask); +- nss_trace("%p: Adding %d buffers to paged buffer queue", nss_ctx, count); ++ nss_trace("%px: Adding %d buffers to paged buffer queue", nss_ctx, count); + + /* + * Fill empty buffer queue with buffers leaving one empty descriptor +@@ -2101,7 +2135,7 @@ static inline void nss_core_handle_paged + static inline void nss_core_handle_tx_unblocked(struct nss_ctx_instance *nss_ctx) + { + int32_t i; +- nss_trace("%p: Data queue unblocked", nss_ctx); ++ nss_trace("%px: Data queue unblocked", nss_ctx); + + /* + * Call callback functions of drivers that have registered with us +@@ -2153,7 +2187,7 @@ static void nss_core_handle_cause_nonque + nss_core_init_nss(nss_ctx, if_map); + nss_send_ddr_info(nss_ctx); + +- nss_info_always("%p: nss core %d booted successfully\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss core %d booted successfully\n", nss_ctx, nss_ctx->id); + nss_top = nss_ctx->nss_top; + + #ifdef NSS_DRV_C2C_ENABLE +@@ -2348,7 +2382,7 @@ int nss_core_handle_napi(struct napi_str + break; + + default: +- nss_warning("%p: Invalid cause %x received from nss", nss_ctx, int_cause); ++ nss_warning("%px: Invalid cause %x received from nss", nss_ctx, int_cause); + nss_assert(0); + break; + } +@@ -2560,7 +2594,11 @@ static inline bool nss_core_skb_can_reus if (unlikely(irqs_disabled())) return false; @@ -8042,263 +922,1407 @@ return false; if (unlikely(skb_is_nonlinear(nbuf))) -@@ -3046,7 +2986,7 @@ static inline int32_t nss_core_send_buff - */ - void nss_core_init_handlers(struct nss_ctx_instance *nss_ctx) - { -- struct nss_rx_cb_list *cb_list = nss_ctx->nss_rx_interface_handlers; -+ struct nss_rx_cb_list *cb_list = nss_ctx->nss_rx_interface_handlers[nss_ctx->id]; - memset(cb_list, 0, sizeof(*cb_list) * NSS_MAX_NET_INTERFACES); - } +@@ -2705,7 +2743,7 @@ no_reuse: + bit_flags &= ~H2N_BIT_FLAG_BUFFER_REUSABLE; + frag0phyaddr = nss_core_dma_map_single(nss_ctx->dev, nbuf); + if (unlikely(dma_mapping_error(nss_ctx->dev, frag0phyaddr))) { +- nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, nbuf->head); ++ nss_warning("%px: DMA mapping failed for virtual address = %px", nss_ctx, nbuf->head); + return 0; + } -@@ -3100,52 +3040,48 @@ int32_t nss_core_send_buffer(struct nss_ - * Take a lock for queue - */ - spin_lock_bh(&h2n_desc_ring->lock); -- nss_index = h2n_desc_ring->nss_index_local; -- hlos_index = h2n_desc_ring->hlos_index; -- count = ((nss_index - hlos_index - 1) + size) & (mask); +@@ -2741,7 +2779,7 @@ static inline int32_t nss_core_send_buff - /* -- * If local index shows that there is not enough space in the ring, -- * Read the actual index from the consumer's generation (NSS-FW). -+ * We need to work out if there's sufficent space in our transmit descriptor -+ * ring to place all the segments of a nbuf. - */ -+ NSS_CORE_DMA_CACHE_MAINT((void *)&if_map->h2n_nss_index[qid], sizeof(uint32_t), DMA_FROM_DEVICE); -+ NSS_CORE_DSB(); -+ nss_index = if_map->h2n_nss_index[qid]; -+ -+ hlos_index = h2n_desc_ring->hlos_index; -+ -+ count = ((nss_index - hlos_index - 1) + size) & (mask); -+ - if (unlikely(count < (segments + 1))) { - /* -- * We need to work out if there's sufficent space in our transmit descriptor -- * ring to place all the segments of a nbuf. -- */ -- NSS_CORE_DMA_CACHE_MAINT((void *)&if_map->h2n_nss_index[qid], sizeof(uint32_t), DMA_FROM_DEVICE); -- NSS_CORE_DSB(); -- nss_index = if_map->h2n_nss_index[qid]; -- h2n_desc_ring->nss_index_local = nss_index; -- count = ((nss_index - hlos_index - 1) + size) & (mask); -- if (unlikely(count < (segments + 1))) { -- /* -- * NOTE: tx_q_full_cnt and TX_STOPPED flags will be used -- * when we will add support for DESC Q congestion management -- * in future -- */ -- h2n_desc_ring->tx_q_full_cnt++; -- h2n_desc_ring->flags |= NSS_H2N_DESC_RING_FLAGS_TX_STOPPED; -- spin_unlock_bh(&h2n_desc_ring->lock); -- nss_warning("%px: Data/Command Queue full reached", nss_ctx); -+ * NOTE: tx_q_full_cnt and TX_STOPPED flags will be used -+ * when we will add support for DESC Q congestion management -+ * in future -+ */ -+ h2n_desc_ring->tx_q_full_cnt++; -+ h2n_desc_ring->flags |= NSS_H2N_DESC_RING_FLAGS_TX_STOPPED; -+ spin_unlock_bh(&h2n_desc_ring->lock); + uint32_t frag0phyaddr = nss_core_dma_map_single(nss_ctx->dev, nbuf); + if (unlikely(dma_mapping_error(nss_ctx->dev, frag0phyaddr))) { +- nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, nbuf->head); ++ nss_warning("%px: DMA mapping failed for virtual address = %px", nss_ctx, nbuf->head); + return 0; + } + +@@ -2781,7 +2819,7 @@ static inline int32_t nss_core_send_buff + + buffer = skb_frag_dma_map(nss_ctx->dev, frag, 0, skb_frag_size(frag), DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(nss_ctx->dev, buffer))) { +- nss_warning("%p: DMA mapping failed for fragment", nss_ctx); ++ nss_warning("%px: DMA mapping failed for fragment", nss_ctx); + nss_core_send_unwind_dma(nss_ctx->dev, desc_if, hlos_index, i + 1, false); + return -(i + 1); + } +@@ -2836,7 +2874,7 @@ static inline int32_t nss_core_send_buff + + uint32_t frag0phyaddr = nss_core_dma_map_single(nss_ctx->dev, nbuf); + if (unlikely(dma_mapping_error(nss_ctx->dev, frag0phyaddr))) { +- nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, nbuf->head); ++ nss_warning("%px: DMA mapping failed for virtual address = %px", nss_ctx, nbuf->head); + return 0; + } + +@@ -2875,7 +2913,7 @@ static inline int32_t nss_core_send_buff + + buffer = nss_core_dma_map_single(nss_ctx->dev, iter); + if (unlikely(dma_mapping_error(nss_ctx->dev, buffer))) { +- nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, iter->head); ++ nss_warning("%px: DMA mapping failed for virtual address = %px", nss_ctx, iter->head); + nss_core_send_unwind_dma(nss_ctx->dev, desc_if, hlos_index, i + 1, true); + return -(i+1); + } +@@ -2886,7 +2924,7 @@ static inline int32_t nss_core_send_buff + */ + nr_frags = skb_shinfo(iter)->nr_frags; + if (unlikely(nr_frags > 0)) { +- nss_warning("%p: fraglist with page data are not supported: %p\n", nss_ctx, iter); ++ nss_warning("%px: fraglist with page data are not supported: %px\n", nss_ctx, iter); + nss_core_send_unwind_dma(nss_ctx->dev, desc_if, hlos_index, i + 1, true); + return -(i+1); + } +@@ -2993,7 +3031,7 @@ int32_t nss_core_send_buffer(struct nss_ + * Check that segments do not overflow the number of descriptors + */ + if (unlikely(segments > size)) { +- nss_warning("%p: Unable to fit in skb - %d segments in our descriptors", nss_ctx, segments); ++ nss_warning("%px: Unable to fit in skb - %d segments in our descriptors", nss_ctx, segments); + return NSS_CORE_STATUS_FAILURE; + } + } +@@ -3024,7 +3062,7 @@ int32_t nss_core_send_buffer(struct nss_ + h2n_desc_ring->tx_q_full_cnt++; + h2n_desc_ring->flags |= NSS_H2N_DESC_RING_FLAGS_TX_STOPPED; + spin_unlock_bh(&h2n_desc_ring->lock); +- nss_warning("%p: Data/Command Queue full reached", nss_ctx); + nss_warning("%px: Data/Command Queue full reached", nss_ctx); #if (NSS_PKT_STATS_ENABLED == 1) -- if (nss_ctx->id == NSS_CORE_0) { -- NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_QUEUE_FULL_0]); -- } else if (nss_ctx->id == NSS_CORE_1) { -- NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_QUEUE_FULL_1]); -- } else { -- nss_warning("%px: Invalid nss core: %d\n", nss_ctx, nss_ctx->id); -- } -+ if (nss_ctx->id == NSS_CORE_0) { -+ NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_QUEUE_FULL_0]); -+ } else if (nss_ctx->id == NSS_CORE_1) { -+ NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_QUEUE_FULL_1]); -+ } else { + if (nss_ctx->id == NSS_CORE_0) { +@@ -3032,7 +3070,7 @@ int32_t nss_core_send_buffer(struct nss_ + } else if (nss_ctx->id == NSS_CORE_1) { + NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_QUEUE_FULL_1]); + } else { +- nss_warning("%p: Invalid nss core: %d\n", nss_ctx, nss_ctx->id); + nss_warning("%px: Invalid nss core: %d\n", nss_ctx, nss_ctx->id); -+ } + } #endif -- /* -- * Enable de-congestion interrupt from NSS -- */ -- nss_hal_enable_interrupt(nss_ctx, nss_ctx->int_ctx[0].shift_factor, NSS_N2H_INTR_TX_UNBLOCKED); -- return NSS_CORE_STATUS_FAILURE_QUEUE; -- } -+ /* -+ * Enable de-congestion interrupt from NSS -+ */ -+ nss_hal_enable_interrupt(nss_ctx, nss_ctx->int_ctx[0].shift_factor, NSS_N2H_INTR_TX_UNBLOCKED); -+ -+ return NSS_CORE_STATUS_FAILURE_QUEUE; +@@ -3090,7 +3128,7 @@ int32_t nss_core_send_buffer(struct nss_ + /* + * We failed and hence we need to unmap dma regions + */ +- nss_warning("%p: failed to map DMA regions:%d", nss_ctx, -count); ++ nss_warning("%px: failed to map DMA regions:%d", nss_ctx, -count); + spin_unlock_bh(&h2n_desc_ring->lock); + return NSS_CORE_STATUS_FAILURE; } +@@ -3144,18 +3182,18 @@ int32_t nss_core_send_cmd(struct nss_ctx + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: interface: %d type: %d message dropped as core not ready\n", nss_ctx, ncm->interface, ncm->type); ++ nss_warning("%px: interface: %d type: %d message dropped as core not ready\n", nss_ctx, ncm->interface, ncm->type); + return NSS_TX_FAILURE_NOT_READY; + } + + if (nss_cmn_get_msg_len(ncm) > size) { +- nss_warning("%p: interface: %d type: %d message length %d is invalid, size = %d\n", ++ nss_warning("%px: interface: %d type: %d message length %d is invalid, size = %d\n", + nss_ctx, ncm->interface, ncm->type, nss_cmn_get_msg_len(ncm), size); + return NSS_TX_FAILURE_TOO_LARGE; + } + + if (buf_size > PAGE_SIZE) { +- nss_warning("%p: interface: %d type: %d tx request size too large: %u", ++ nss_warning("%px: interface: %d type: %d tx request size too large: %u", + nss_ctx, ncm->interface, ncm->type, buf_size); + return NSS_TX_FAILURE_BAD_PARAM; + } +@@ -3163,7 +3201,7 @@ int32_t nss_core_send_cmd(struct nss_ctx + nbuf = dev_alloc_skb(buf_size); + if (unlikely(!nbuf)) { + NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_NBUF_ALLOC_FAILS]); +- nss_warning("%p: interface: %d type: %d msg dropped as command allocation failed", nss_ctx, ncm->interface, ncm->type); ++ nss_warning("%px: interface: %d type: %d msg dropped as command allocation failed", nss_ctx, ncm->interface, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -3173,7 +3211,7 @@ int32_t nss_core_send_cmd(struct nss_ctx + if (status != NSS_CORE_STATUS_SUCCESS) { + dev_kfree_skb_any(nbuf); + NSS_PKT_STATS_INC(&nss_ctx->nss_top->stats_drv[NSS_DRV_STATS_TX_CMD_QUEUE_FULL]); +- nss_warning("%p: interface: %d type: %d unable to enqueue message status %d\n", nss_ctx, ncm->interface, ncm->type, status); ++ nss_warning("%px: interface: %d type: %d unable to enqueue message status %d\n", nss_ctx, ncm->interface, ncm->type, status); + return status; + } + +@@ -3193,7 +3231,7 @@ int32_t nss_core_send_packet(struct nss_ + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: interface: %d packet dropped as core not ready\n", nss_ctx, if_num); ++ nss_warning("%px: interface: %d packet dropped as core not ready\n", nss_ctx, if_num); + return NSS_TX_FAILURE_NOT_READY; + } + +@@ -3205,7 +3243,7 @@ int32_t nss_core_send_packet(struct nss_ + #endif + status = nss_core_send_buffer(nss_ctx, if_num, nbuf, NSS_IF_H2N_DATA_QUEUE + queue_id, H2N_BUFFER_PACKET, flag); + if (status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: interface: %d unable to enqueue packet status %d\n", nss_ctx, if_num, status); ++ nss_warning("%px: interface: %d unable to enqueue packet status %d\n", nss_ctx, if_num, status); + return status; + } + +--- a/nss_meminfo.c ++++ b/nss_meminfo.c +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018-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 +@@ -53,7 +53,7 @@ static void *nss_meminfo_alloc_sdram(str + */ + addr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); + if (!addr) +- nss_info_always("%p: failed to alloc a sdram block of size %u\n", nss_ctx, size); ++ nss_info_always("%px: failed to alloc a sdram block of size %u\n", nss_ctx, size); + + kmemleak_not_leak((void *)addr); + return addr; +@@ -100,7 +100,7 @@ static uint32_t nss_meminfo_alloc_imem(s + new_tail = (new_tail + mask) & ~mask; + + if (size > (mem_ctx->imem_end - new_tail)) { +- nss_info_always("%p: failed to alloc an IMEM block of size %u\n", nss_ctx, size); ++ nss_info_always("%px: failed to alloc an IMEM block of size %u\n", nss_ctx, size); + return addr; + } + +@@ -147,7 +147,7 @@ static uint32_t nss_meminfo_alloc_utcm_s + new_tail = (new_tail + mask) & ~mask; + + if (size > (mem_ctx->utcm_shared_end - new_tail)) { +- nss_info_always("%p: failed to alloc an UTCM_SHARED block of size %u\n", nss_ctx, size); ++ nss_info_always("%px: failed to alloc an UTCM_SHARED block of size %u\n", nss_ctx, size); + return addr; + } + +@@ -292,7 +292,7 @@ static bool nss_meminfo_init_block_lists + struct nss_meminfo_block *b = (struct nss_meminfo_block *) + kmalloc(sizeof(struct nss_meminfo_block), GFP_KERNEL); + if (!b) { +- nss_info_always("%p: failed to allocate meminfo block\n", nss_ctx); ++ nss_info_always("%px: failed to allocate meminfo block\n", nss_ctx); + goto cleanup; + } + +@@ -311,11 +311,20 @@ static bool nss_meminfo_init_block_lists + switch (mtype) { + case NSS_MEMINFO_MEMTYPE_IMEM: + /* ++ * For SOC's where TCM is not present ++ */ ++ if (!nss_ctx->vphys) { ++ nss_info_always("%px:IMEM requested but TCM not defined " ++ "for this SOC\n", nss_ctx); ++ goto cleanup; ++ } + - desc = &desc_ring[hlos_index]; ++ /* + * Return SoC real address for IMEM as DMA address. + */ + dma_addr = nss_meminfo_alloc_imem(nss_ctx, r->size, r->alignment); + if (!dma_addr) { +- nss_info_always("%p: failed to alloc IMEM block\n", nss_ctx); ++ nss_info_always("%px: failed to alloc IMEM block\n", nss_ctx); + goto cleanup; + } + +@@ -328,13 +337,13 @@ static bool nss_meminfo_init_block_lists + case NSS_MEMINFO_MEMTYPE_SDRAM: + kern_addr = nss_meminfo_alloc_sdram(nss_ctx, r->size); + if (!kern_addr) { +- nss_info_always("%p: failed to alloc SDRAM block\n", nss_ctx); ++ nss_info_always("%px: failed to alloc SDRAM block\n", nss_ctx); + goto cleanup; + } + + dma_addr = dma_map_single(nss_ctx->dev, kern_addr, r->size, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(nss_ctx->dev, dma_addr))) { +- nss_info_always("%p: failed to map SDRAM block\n", nss_ctx); ++ nss_info_always("%px: failed to map SDRAM block\n", nss_ctx); + goto cleanup; + } + break; +@@ -344,7 +353,7 @@ static bool nss_meminfo_init_block_lists + */ + dma_addr = nss_meminfo_alloc_utcm_shared(nss_ctx, r->size, r->alignment); + if (!dma_addr) { +- nss_info_always("%p: failed to alloc UTCM_SHARED block\n", nss_ctx); ++ nss_info_always("%px: failed to alloc UTCM_SHARED block\n", nss_ctx); + goto cleanup; + } + break; +@@ -361,12 +370,12 @@ static bool nss_meminfo_init_block_lists + */ + r->size /= coreinfo.num_active_cores; + dma_addr = coreinfo.start_address + nss_ctx->id * r->size; +- nss_info_always("%p: NSS core %d DDR from %x to %x\n", nss_ctx, ++ nss_info_always("%px: NSS core %d DDR from %x to %x\n", nss_ctx, + nss_ctx->id, dma_addr, dma_addr + r->size); + } + break; + default: +- nss_info_always("%p: %d unsupported memory type\n", nss_ctx, mtype); ++ nss_info_always("%px: %d unsupported memory type\n", nss_ctx, mtype); + goto cleanup; + } + +@@ -399,7 +408,7 @@ static bool nss_meminfo_init_block_lists + + if (strcmp(r->name, "profile_dma_ctrl") == 0) { + mem_ctx->sdma_ctrl = kern_addr; +- nss_info_always("%p: set sdma %p\n", nss_ctx, kern_addr); ++ nss_info_always("%px: set sdma %px\n", nss_ctx, kern_addr); + } + + /* +@@ -453,6 +462,15 @@ static bool nss_meminfo_allocate_n2h_h2n + } + break; + case NSS_MEMINFO_MEMTYPE_IMEM: ++ /* ++ * For SOC's where TCM is not present ++ */ ++ if (!nss_ctx->vphys) { ++ nss_info_always("%px:IMEM requested but TCM not defined " ++ "for this SOC\n", nss_ctx); ++ return false; ++ } ++ + info->dma_addr = nss_meminfo_alloc_imem(nss_ctx, info->total_size, L1_CACHE_BYTES); + if (!info->dma_addr) + return false; +@@ -504,7 +522,7 @@ static bool nss_meminfo_configure_n2h_h2 + * N2H ring allocations + */ + if (!(nss_meminfo_allocate_n2h_h2n_rings(nss_ctx, n2h_info))) { +- nss_info_always("%p: failed to allocate/map n2h rings\n", nss_ctx); ++ nss_info_always("%px: failed to allocate/map n2h rings\n", nss_ctx); + return false; + } + +@@ -512,11 +530,18 @@ static bool nss_meminfo_configure_n2h_h2 + * H2N ring allocations + */ + if (!(nss_meminfo_allocate_n2h_h2n_rings(nss_ctx, h2n_info))) { +- nss_info_always("%p: failed to allocate/map h2n_rings\n", nss_ctx); ++ nss_info_always("%px: failed to allocate/map h2n_rings\n", nss_ctx); + goto cleanup; + } /* ---- a/nss_core.h -+++ b/nss_core.h -@@ -1,12 +1,9 @@ ++ * Returning true allows to execute firmware bin ++ */ ++ if (!mem_ctx->if_map) { ++ return true; ++ } ++ ++ /* + * Bring a fresh copy of if_map from memory in order to read it correctly. + */ + if_map = mem_ctx->if_map; +@@ -537,7 +562,7 @@ static bool nss_meminfo_configure_n2h_h2 + + if_map->n2h_desc_if[i].size = NSS_RING_SIZE; + if_map->n2h_desc_if[i].desc_addr = n2h_info->dma_addr + i * sizeof(struct n2h_descriptor) * (NSS_RING_SIZE + 2); +- nss_info("%p: N2H ring %d, size %d, addr = %x\n", nss_ctx, i, if_map->n2h_desc_if[i].size, if_map->n2h_desc_if[i].desc_addr); ++ nss_info("%px: N2H ring %d, size %d, addr = %x\n", nss_ctx, i, if_map->n2h_desc_if[i].size, if_map->n2h_desc_if[i].desc_addr); + } + + /* +@@ -552,7 +577,7 @@ static bool nss_meminfo_configure_n2h_h2 + + if_map->h2n_desc_if[i].size = NSS_RING_SIZE; + if_map->h2n_desc_if[i].desc_addr = h2n_info->dma_addr + i * sizeof(struct h2n_descriptor) * (NSS_RING_SIZE + 2); +- nss_info("%p: H2N ring %d, size %d, addr = %x\n", nss_ctx, i, if_map->h2n_desc_if[i].size, if_map->h2n_desc_if[i].desc_addr); ++ nss_info("%px: H2N ring %d, size %d, addr = %x\n", nss_ctx, i, if_map->h2n_desc_if[i].size, if_map->h2n_desc_if[i].desc_addr); + } + + /* +@@ -705,16 +730,15 @@ bool nss_meminfo_init(struct nss_ctx_ins + struct nss_meminfo_map *map; + struct nss_top_instance *nss_top = &nss_top_main; + +- NSS_VERIFY_CTX_MAGIC(nss_ctx); + mem_ctx = &nss_ctx->meminfo_ctx; + + /* + * meminfo_start is the label where the start address of meminfo map is stored. + */ +- meminfo_start = (uint32_t *)ioremap_nocache(nss_ctx->load + NSS_MEMINFO_MAP_START_OFFSET, ++ meminfo_start = (uint32_t *)ioremap(nss_ctx->load + NSS_MEMINFO_MAP_START_OFFSET, + NSS_MEMINFO_RESERVE_AREA_SIZE); + if (!meminfo_start) { +- nss_info_always("%p: cannot remap meminfo start\n", nss_ctx); ++ nss_info_always("%px: cannot remap meminfo start\n", nss_ctx); + return false; + } + +@@ -722,14 +746,14 @@ bool nss_meminfo_init(struct nss_ctx_ins + * Check meminfo start magic + */ + if ((uint16_t)meminfo_start[0] != NSS_MEMINFO_RESERVE_AREA_MAGIC) { +- nss_info_always("%p: failed to verify meminfo start magic\n", nss_ctx); ++ nss_info_always("%px: failed to verify meminfo start magic\n", nss_ctx); + return false; + } + + map = &mem_ctx->meminfo_map; + map->start = (uint32_t *)ioremap_cache(meminfo_start[1], NSS_MEMINFO_MAP_SIZE); + if (!map->start) { +- nss_info_always("%p: failed to remap meminfo map\n", nss_ctx); ++ nss_info_always("%px: failed to remap meminfo map\n", nss_ctx); + return false; + } + +@@ -737,7 +761,7 @@ bool nss_meminfo_init(struct nss_ctx_ins + * Check meminfo map magic + */ + if ((uint16_t)map->start[0] != NSS_MEMINFO_MAP_START_MAGIC) { +- nss_info_always("%p: failed to verify meminfo map magic\n", nss_ctx); ++ nss_info_always("%px: failed to verify meminfo map magic\n", nss_ctx); + return false; + } + +@@ -756,7 +780,7 @@ bool nss_meminfo_init(struct nss_ctx_ins + * Init UTCM_SHARED if supported + */ + if (!nss_top->hal_ops->init_utcm_shared(nss_ctx, meminfo_start)) { +- nss_info_always("%p: failed to initialize UTCM_SHARED meminfo\n", nss_ctx); ++ nss_info_always("%px: failed to initialize UTCM_SHARED meminfo\n", nss_ctx); + return false; + } + +@@ -764,7 +788,7 @@ bool nss_meminfo_init(struct nss_ctx_ins + * Init meminfo block lists + */ + if (!nss_meminfo_init_block_lists(nss_ctx)) { +- nss_info_always("%p: failed to initialize meminfo block lists\n", nss_ctx); ++ nss_info_always("%px: failed to initialize meminfo block lists\n", nss_ctx); + return false; + } + +@@ -776,6 +800,6 @@ bool nss_meminfo_init(struct nss_ctx_ins + + nss_meminfo_init_debugfs(nss_ctx); + +- nss_info_always("%p: meminfo init succeed\n", nss_ctx); ++ nss_info_always("%px: meminfo init succeed\n", nss_ctx); + return true; + } +--- a/nss_hal/fsm9010/nss_hal_pvt.c ++++ b/nss_hal/fsm9010/nss_hal_pvt.c +@@ -1,6 +1,6 @@ /* ************************************************************************** -- * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved. +- * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2015-2020, 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 -@@ -41,10 +38,8 @@ - #include "nss_phys_if.h" - #include "nss_hlos_if.h" - #include "nss_oam.h" --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - #include "nss_data_plane.h" - #include "nss_gmac_stats.h" --#endif - #include "nss_meminfo.h" - #include "nss_stats.h" +@@ -130,12 +130,12 @@ static struct nss_platform_data *__nss_h + nss_ctx->id = npd->id; -@@ -191,7 +186,7 @@ static inline void nss_core_dma_cache_ma - /* - * NSS maximum IRQ per interrupt instance/core - */ --#if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) || defined(NSS_HAL_IPQ95XX_SUPPORT) -+#if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) - #define NSS_MAX_IRQ_PER_INSTANCE 6 - #define NSS_MAX_IRQ_PER_CORE 10 /* must match with NSS_HAL_N2H_INTR_PURPOSE_MAX */ - #elif defined(NSS_HAL_IPQ50XX_SUPPORT) -@@ -238,7 +233,6 @@ static inline void nss_core_dma_cache_ma - * - */ - #define NSS_FREQ_SCALE_NA 0xFAADFAAD /* Frequency scale not supported */ --#define NSS_FREQ_NA 0x0 /* Instructions Per ms Min */ + if (of_address_to_resource(np, 0, &res_nphys) != 0) { +- nss_info_always("%p: nss%d: of_address_to_resource() fail for nphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: of_address_to_resource() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; + } - #define NSS_FREQ_110 110000000 /* Frequency in hz */ - #define NSS_FREQ_110_MIN 0x03000 /* Instructions Per ms Min */ -@@ -282,14 +276,6 @@ static inline void nss_core_dma_cache_ma - #define NSS_FREQ_800_MIN 0x07000 /* Instructions Per ms Min */ - #define NSS_FREQ_800_MAX 0x25000 /* Instructions Per ms Max */ + if (of_address_to_resource(np, 1, &res_vphys) != 0) { +- nss_info_always("%p: nss%d: of_address_to_resource() fail for vphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: of_address_to_resource() fail for vphys\n", nss_ctx, nss_ctx->id); + goto out; + } --#define NSS_FREQ_850 850000000 /* Frequency in hz */ --#define NSS_FREQ_850_MIN 0x07000 /* Instructions Per ms Min */ --#define NSS_FREQ_850_MAX 0x0c000 /* Instructions Per ms Max */ -- --#define NSS_FREQ_1000 1000000000 /* Frequency in hz */ --#define NSS_FREQ_1000_MIN 0x0c000 /* Instructions Per ms Min */ --#define NSS_FREQ_1000_MAX 0x25000 /* Instructions Per ms Max */ -- - #define NSS_FREQ_1497 1497600000 /* Frequency in hz */ - #if defined(NSS_HAL_IPQ60XX_SUPPORT) - #define NSS_FREQ_1497_MIN 0x18000 /* Instructions Per ms Min */ -@@ -394,7 +380,6 @@ struct hlos_n2h_desc_ring { - struct hlos_h2n_desc_rings { - struct h2n_desc_if_instance desc_ring; /* Descriptor ring */ - uint32_t hlos_index; -- uint32_t nss_index_local; /* Index number for the next descriptor (NSS owned) */ - spinlock_t lock; /* Lock to save from simultaneous access */ - uint32_t flags; /* Flags */ - uint64_t tx_q_full_cnt; /* Descriptor queue full count */ -@@ -492,9 +477,6 @@ struct nss_ctx_instance { - /* Service code callbacks */ - void *service_code_ctx[NSS_MAX_SERVICE_CODE]; - /* Service code callback contexts */ -- nss_edma_lite_msg_callback_t edma_lite_callback; -- /* EDMA lite callback */ -- void *edma_lite_ctx; /* EDMA lite context */ - spinlock_t decongest_cb_lock; /* Lock to protect queue decongestion cb table */ - uint16_t phys_if_mtu[NSS_MAX_PHYSICAL_INTERFACES]; - /* Current MTU value of physical interface */ -@@ -504,7 +486,7 @@ struct nss_ctx_instance { - /* Worker thread statistics */ - struct nss_unaligned_stats unaligned_stats; - /* Unaligned emulation performance statistics */ -- struct nss_rx_cb_list nss_rx_interface_handlers[NSS_MAX_NET_INTERFACES]; -+ struct nss_rx_cb_list nss_rx_interface_handlers[NSS_MAX_CORES][NSS_MAX_NET_INTERFACES]; - /* NSS interface callback handlers */ - struct nss_subsystem_dataplane_register subsys_dp_register[NSS_MAX_NET_INTERFACES]; - /* Subsystem registration data */ -@@ -577,9 +559,6 @@ struct nss_top_instance { - uint8_t mirror_handler_id; - uint8_t wmdb_handler_id; - uint8_t dma_handler_id; -- uint8_t udp_st_handler_id; -- uint8_t edma_lite_handler_id[NSS_MAX_CORES]; -- uint8_t trustsec_rx_handler_id; +@@ -145,15 +145,15 @@ static struct nss_platform_data *__nss_h + npd->nphys = res_nphys.start; + npd->vphys = res_vphys.start; - /* - * Data/Message callbacks for various interfaces -@@ -674,10 +653,8 @@ struct nss_top_instance { - */ - atomic64_t stats_drv[NSS_DRV_STATS_MAX]; - /* Hlos driver statistics */ --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - uint64_t stats_gmac[NSS_MAX_PHYSICAL_INTERFACES][NSS_GMAC_STATS_MAX]; - /* GMAC statistics */ --#endif - uint64_t stats_node[NSS_MAX_NET_INTERFACES][NSS_STATS_NODE_MAX]; - /* IPv4 statistics per interface */ - bool nss_hal_common_init_done; -@@ -690,10 +667,8 @@ struct nss_top_instance { - */ - uint64_t last_rx_jiffies; /* Time of the last RX message from the NA in jiffies */ - struct nss_hal_ops *hal_ops; /* nss_hal ops for this target platform */ --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - struct nss_data_plane_ops *data_plane_ops; - /* nss_data_plane ops for this target platform */ --#endif - }; +- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); ++ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); + if (!npd->nmap) { +- nss_info_always("%p: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; + } - #if (NSS_PKT_STATS_ENABLED == 1) -@@ -919,12 +894,6 @@ struct nss_platform_data { - /* Does this core handle TLS Tunnel ? */ - enum nss_feature_enabled mirror_enabled; - /* Does this core handle mirror? */ -- enum nss_feature_enabled udp_st_enabled; -- /* Does this core handle udp st? */ -- enum nss_feature_enabled edma_lite_enabled; -- /* Does this core handle EDMA lite? */ -- enum nss_feature_enabled trustsec_enabled; -- /* Does this core handle TrustSec? */ - }; - #endif + npd->vmap = ioremap_cache(npd->vphys, resource_size(&res_vphys)); + if (!npd->vmap) { +- nss_info_always("%p: nss%d: ioremap() fail for vphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: ioremap() fail for vphys\n", nss_ctx, nss_ctx->id); + goto out; + } -@@ -975,8 +944,6 @@ extern uint32_t nss_core_unregister_hand - extern void nss_core_init_handlers(struct nss_ctx_instance *nss_ctx); - void nss_core_update_max_ipv4_conn(int conn); - void nss_core_update_max_ipv6_conn(int conn); --void nss_core_update_qos_mem_size(int size); --int nss_core_get_qos_mem_size(void); - extern void nss_core_register_subsys_dp(struct nss_ctx_instance *nss_ctx, uint32_t if_num, - nss_phys_if_rx_callback_t cb, - nss_phys_if_rx_ext_data_callback_t ext_cb, -@@ -984,11 +951,10 @@ extern void nss_core_register_subsys_dp( - uint32_t features); - extern void nss_core_unregister_subsys_dp(struct nss_ctx_instance *nss_ctx, uint32_t if_num); - void nss_core_set_subsys_dp_type(struct nss_ctx_instance *nss_ctx, struct net_device *ndev, uint32_t if_num, uint32_t type); --extern bool nss_core_is_mq_enabled(void); +@@ -163,7 +163,7 @@ static struct nss_platform_data *__nss_h + for (i = 0 ; i < npd->num_irq; i++) { + npd->irq[i] = irq_of_parse_and_map(np, i); + if (!npd->irq[i]) { +- nss_info_always("%p: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); ++ nss_info_always("%px: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); + goto out; + } + } +@@ -285,7 +285,7 @@ static int __nss_hal_request_irq(struct + err = request_irq(npd->irq[irq_num], nss_hal_handle_irq, 0, "nss", int_ctx); + } + if (err) { +- nss_warning("%p: IRQ%d request failed", nss_ctx, npd->irq[irq_num]); ++ nss_warning("%px: IRQ%d request failed", nss_ctx, npd->irq[irq_num]); + return err; + } - static inline nss_if_rx_msg_callback_t nss_core_get_msg_handler(struct nss_ctx_instance *nss_ctx, uint32_t interface) - { -- return nss_ctx->nss_rx_interface_handlers[interface].msg_cb; -+ return nss_ctx->nss_rx_interface_handlers[nss_ctx->id][interface].msg_cb; +@@ -305,7 +305,7 @@ void __nss_hal_init_imem(struct nss_ctx_ + mem_ctx->imem_end = mem_ctx->imem_head + NSS_IMEM_SIZE; + mem_ctx->imem_tail = mem_ctx->imem_head; + +- nss_info("%p: IMEM init: head: 0x%x end: 0x%x tail: 0x%x\n", nss_ctx, ++ nss_info("%px: IMEM init: head: 0x%x end: 0x%x tail: 0x%x\n", nss_ctx, + mem_ctx->imem_head, mem_ctx->imem_end, mem_ctx->imem_tail); } - static inline uint32_t nss_core_get_max_buf_size(struct nss_ctx_instance *nss_ctx) -@@ -1056,6 +1022,5 @@ extern void nss_ppe_free(void); - */ - extern nss_tx_status_t nss_n2h_cfg_empty_pool_size(struct nss_ctx_instance *nss_ctx, uint32_t pool_sz); - extern nss_tx_status_t nss_n2h_paged_buf_pool_init(struct nss_ctx_instance *nss_ctx); --extern nss_tx_status_t nss_n2h_cfg_qos_mem_size(struct nss_ctx_instance *nss_ctx, uint32_t pool_sz); +--- a/nss_hal/ipq60xx/nss_hal_pvt.c ++++ b/nss_hal/ipq60xx/nss_hal_pvt.c +@@ -192,12 +192,12 @@ static struct nss_platform_data *__nss_h + nss_ctx->id = npd->id; - #endif /* __NSS_CORE_H */ + if (of_address_to_resource(np, 0, &res_nphys) != 0) { +- nss_info_always("%p: nss%d: of_address_to_resource() fail for nphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: of_address_to_resource() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; + } + + if (of_address_to_resource(np, 1, &res_qgic_phys) != 0) { +- nss_info_always("%p: nss%d: of_address_to_resource() fail for qgic_phys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: of_address_to_resource() fail for qgic_phys\n", nss_ctx, nss_ctx->id); + goto out; + } + +@@ -207,15 +207,15 @@ static struct nss_platform_data *__nss_h + npd->nphys = res_nphys.start; + npd->qgic_phys = res_qgic_phys.start; + +- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); ++ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); + if (!npd->nmap) { +- nss_info_always("%p: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; + } + +- npd->qgic_map = ioremap_nocache(npd->qgic_phys, resource_size(&res_qgic_phys)); ++ npd->qgic_map = ioremap(npd->qgic_phys, resource_size(&res_qgic_phys)); + if (!npd->qgic_map) { +- nss_info_always("%p: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); + goto out; + } + +@@ -227,7 +227,7 @@ static struct nss_platform_data *__nss_h + for (i = 0 ; i < npd->num_irq; i++) { + npd->irq[i] = irq_of_parse_and_map(np, i); + if (!npd->irq[i]) { +- nss_info_always("%p: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); ++ nss_info_always("%px: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); + goto out; + } + } +@@ -261,21 +261,21 @@ static int nss_hal_clock_set_and_enable( + + nss_clk = devm_clk_get(dev, id); + if (IS_ERR(nss_clk)) { +- pr_err("%p: cannot get clock: %s\n", dev, id); ++ pr_err("%px: cannot get clock: %s\n", dev, id); + return -EFAULT; + } + + if (rate) { + err = clk_set_rate(nss_clk, rate); + if (err) { +- pr_err("%p: cannot set %s freq\n", dev, id); ++ pr_err("%px: cannot set %s freq\n", dev, id); + return -EFAULT; + } + } + + err = clk_prepare_enable(nss_clk); + if (err) { +- pr_err("%p: cannot enable clock: %s\n", dev, id); ++ pr_err("%px: cannot enable clock: %s\n", dev, id); + return -EFAULT; + } + +@@ -313,7 +313,6 @@ static int __nss_hal_core_reset(struct p + value &= ~NSS_CORE_GCC_RESET_2; + nss_write_32(nss_misc_reset, 0x0, value); + +- + /* + * Program address configuration + */ +@@ -416,33 +415,33 @@ static int __nss_hal_common_reset(struct + */ + cmn = of_find_node_by_name(NULL, "nss-common"); + if (!cmn) { +- pr_err("%p: Unable to find nss-common node\n", nss_dev); ++ pr_err("%px: Unable to find nss-common node\n", nss_dev); + return -EFAULT; + } + + if (of_address_to_resource(cmn, 0, &res_nss_misc_reset) != 0) { +- pr_err("%p: of_address_to_resource() return error for nss_misc_reset\n", nss_dev); ++ pr_err("%px: of_address_to_resource() return error for nss_misc_reset\n", nss_dev); + of_node_put(cmn); + return -EFAULT; + } + + if (of_address_to_resource(cmn, 1, &res_nss_misc_reset_flag) != 0) { +- pr_err("%p: of_address_to_resource() return error for nss_misc_reset_flag\n", nss_dev); ++ pr_err("%px: of_address_to_resource() return error for nss_misc_reset_flag\n", nss_dev); + of_node_put(cmn); + return -EFAULT; + } + + of_node_put(cmn); + +- nss_misc_reset = ioremap_nocache(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); ++ nss_misc_reset = ioremap(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); + if (!nss_misc_reset) { +- pr_err("%p: ioremap fail for nss_misc_reset\n", nss_dev); ++ pr_err("%px: ioremap fail for nss_misc_reset\n", nss_dev); + return -EFAULT; + } + +- nss_misc_reset_flag = ioremap_nocache(res_nss_misc_reset_flag.start, resource_size(&res_nss_misc_reset_flag)); ++ nss_misc_reset_flag = ioremap(res_nss_misc_reset_flag.start, resource_size(&res_nss_misc_reset_flag)); + if (!nss_misc_reset_flag) { +- pr_err("%p: ioremap fail for nss_misc_reset_flag\n", nss_dev); ++ pr_err("%px: ioremap fail for nss_misc_reset_flag\n", nss_dev); + return -EFAULT; + } + +@@ -706,7 +705,7 @@ bool __nss_hal_init_utcm_shared(struct n + * Check meminfo utcm_shared map magic + */ + if ((uint16_t)utcm_shared_map_magic != NSS_MEMINFO_RESERVE_AREA_UTCM_SHARED_MAP_MAGIC) { +- nss_info_always("%p: failed to verify UTCM_SHARED map magic\n", nss_ctx); ++ nss_info_always("%px: failed to verify UTCM_SHARED map magic\n", nss_ctx); + return false; + } + +@@ -714,7 +713,7 @@ bool __nss_hal_init_utcm_shared(struct n + mem_ctx->utcm_shared_end = mem_ctx->utcm_shared_head + utcm_shared_size; + mem_ctx->utcm_shared_tail = mem_ctx->utcm_shared_head; + +- nss_info("%p: UTCM_SHARED init: head: 0x%x end: 0x%x tail: 0x%x\n", nss_ctx, ++ nss_info("%px: UTCM_SHARED init: head: 0x%x end: 0x%x tail: 0x%x\n", nss_ctx, + mem_ctx->utcm_shared_head, mem_ctx->utcm_shared_end, mem_ctx->utcm_shared_tail); + return true; + } +--- a/nss_hal/ipq806x/nss_hal_pvt.c ++++ b/nss_hal/ipq806x/nss_hal_pvt.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2013, 2015-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2013, 2015-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. +@@ -443,12 +443,12 @@ static struct nss_platform_data *__nss_h + nss_ctx->id = npd->id; + + if (of_address_to_resource(np, 0, &res_nphys) != 0) { +- nss_info_always("%p: nss%d: of_address_to_resource() fail for nphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: of_address_to_resource() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; + } + + if (of_address_to_resource(np, 1, &res_vphys) != 0) { +- nss_info_always("%p: nss%d: of_address_to_resource() fail for vphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: of_address_to_resource() fail for vphys\n", nss_ctx, nss_ctx->id); + goto out; + } + +@@ -458,15 +458,16 @@ static struct nss_platform_data *__nss_h + npd->nphys = res_nphys.start; + npd->vphys = res_vphys.start; + +- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); ++ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); + if (!npd->nmap) { +- nss_info_always("%p: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; + } + ++ nss_assert(npd->vphys); + npd->vmap = ioremap_cache(npd->vphys, resource_size(&res_vphys)); + if (!npd->vmap) { +- nss_info_always("%p: nss%d: ioremap() fail for vphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: ioremap() fail for vphys\n", nss_ctx, nss_ctx->id); + goto out; + } + +@@ -485,7 +486,7 @@ static struct nss_platform_data *__nss_h + for (i = 0 ; i < npd->num_irq; i++) { + npd->irq[i] = irq_of_parse_and_map(np, i); + if (!npd->irq[i]) { +- nss_info_always("%p: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); ++ nss_info_always("%px: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); + goto out; + } + } +@@ -523,7 +524,7 @@ static int __nss_hal_core_reset(struct p + */ + rstctl = devm_reset_control_get(&nss_dev->dev, "clkrst-clamp"); + if (IS_ERR(rstctl)) { +- nss_info_always("%p: Deassert UBI32 core%d reset clamp failed", nss_dev, nss_dev->id); ++ nss_info_always("%px: Deassert UBI32 core%d reset clamp failed", nss_dev, nss_dev->id); + return -EFAULT; + } + reset_control_deassert(rstctl); +@@ -533,7 +534,7 @@ static int __nss_hal_core_reset(struct p + */ + rstctl = devm_reset_control_get(&nss_dev->dev, "clamp"); + if (IS_ERR(rstctl)) { +- nss_info_always("%p: Deassert UBI32 core%d clamp failed", nss_dev, nss_dev->id); ++ nss_info_always("%px: Deassert UBI32 core%d clamp failed", nss_dev, nss_dev->id); + return -EFAULT; + } + reset_control_deassert(rstctl); +@@ -543,7 +544,7 @@ static int __nss_hal_core_reset(struct p + */ + rstctl = devm_reset_control_get(&nss_dev->dev, "ahb"); + if (IS_ERR(rstctl)) { +- nss_info_always("%p: Deassert AHB core%d reset failed", nss_dev, nss_dev->id); ++ nss_info_always("%px: Deassert AHB core%d reset failed", nss_dev, nss_dev->id); + return -EFAULT; + } + reset_control_deassert(rstctl); +@@ -553,7 +554,7 @@ static int __nss_hal_core_reset(struct p + */ + rstctl = devm_reset_control_get(&nss_dev->dev, "axi"); + if (IS_ERR(rstctl)) { +- nss_info_always("%p: Deassert core%d AXI reset failed", nss_dev, nss_dev->id); ++ nss_info_always("%px: Deassert core%d AXI reset failed", nss_dev, nss_dev->id); + return -EFAULT; + } + reset_control_deassert(rstctl); +@@ -699,20 +700,20 @@ static int __nss_hal_common_reset(struct + */ + cmn = of_find_node_by_name(NULL, "nss-common"); + if (!cmn) { +- pr_err("%p: Unable to find nss-common node\n", nss_dev); ++ pr_err("%px: Unable to find nss-common node\n", nss_dev); + return -EFAULT; + } + + if (of_address_to_resource(cmn, 0, &res_nss_fpb_base) != 0) { +- pr_err("%p: of_address_to_resource() return error for nss_fpb_base\n", nss_dev); ++ pr_err("%px: of_address_to_resource() return error for nss_fpb_base\n", nss_dev); + of_node_put(cmn); + return -EFAULT; + } + of_node_put(cmn); + +- fpb_base = ioremap_nocache(res_nss_fpb_base.start, resource_size(&res_nss_fpb_base)); ++ fpb_base = ioremap(res_nss_fpb_base.start, resource_size(&res_nss_fpb_base)); + if (!fpb_base) { +- pr_err("%p: ioremap fail for nss_fpb_base\n", nss_dev); ++ pr_err("%px: ioremap fail for nss_fpb_base\n", nss_dev); + return -EFAULT; + } + +@@ -726,31 +727,31 @@ static int __nss_hal_common_reset(struct + */ + nss_tcm_src = clk_get(&nss_dev->dev, NSS_TCM_SRC_CLK); + if (IS_ERR(nss_tcm_src)) { +- pr_err("%p: cannot get clock: %s\n", nss_dev, NSS_TCM_SRC_CLK); ++ pr_err("%px: cannot get clock: %s\n", nss_dev, NSS_TCM_SRC_CLK); + return -EFAULT; + } + + err = clk_set_rate(nss_tcm_src, NSSTCM_FREQ); + if (err) { +- pr_err("%p: cannot set NSSTCM freq\n", nss_dev); ++ pr_err("%px: cannot set NSSTCM freq\n", nss_dev); + return -EFAULT; + } + + err = clk_prepare_enable(nss_tcm_src); + if (err) { +- pr_err("%p: cannot enable NSSTCM clock source\n", nss_dev); ++ pr_err("%px: cannot enable NSSTCM clock source\n", nss_dev); + return -EFAULT; + } + + nss_tcm_clk = clk_get(&nss_dev->dev, NSS_TCM_CLK); + if (IS_ERR(nss_tcm_clk)) { +- pr_err("%p: cannot get clock: %s\n", nss_dev, NSS_TCM_CLK); ++ pr_err("%px: cannot get clock: %s\n", nss_dev, NSS_TCM_CLK); + return -EFAULT; + } + + err = clk_prepare_enable(nss_tcm_clk); + if (err) { +- pr_err("%p: cannot enable NSSTCM clock\n", nss_dev); ++ pr_err("%px: cannot enable NSSTCM clock\n", nss_dev); + return -EFAULT; + } + +@@ -759,24 +760,24 @@ static int __nss_hal_common_reset(struct + */ + nss_fab0_clk = clk_get(&nss_dev->dev, NSS_FABRIC0_CLK); + if (IS_ERR(nss_fab0_clk)) { +- pr_err("%p: cannot get clock: %s\n", nss_dev, NSS_FABRIC0_CLK); ++ pr_err("%px: cannot get clock: %s\n", nss_dev, NSS_FABRIC0_CLK); + nss_fab0_clk = NULL; + } else { + err = clk_prepare_enable(nss_fab0_clk); + if (err) { +- pr_err("%p: cannot enable clock: %s\n", nss_dev, NSS_FABRIC0_CLK); ++ pr_err("%px: cannot enable clock: %s\n", nss_dev, NSS_FABRIC0_CLK); + return -EFAULT; + } + } + + nss_fab1_clk = clk_get(&nss_dev->dev, NSS_FABRIC1_CLK); + if (IS_ERR(nss_fab1_clk)) { +- pr_err("%p: cannot get clock: %s\n", nss_dev, NSS_FABRIC1_CLK); ++ pr_err("%px: cannot get clock: %s\n", nss_dev, NSS_FABRIC1_CLK); + nss_fab1_clk = NULL; + } else { + err = clk_prepare_enable(nss_fab1_clk); + if (err) { +- pr_err("%p: cannot enable clock: %s\n", nss_dev, NSS_FABRIC1_CLK); ++ pr_err("%px: cannot enable clock: %s\n", nss_dev, NSS_FABRIC1_CLK); + return -EFAULT; + } + } +@@ -969,7 +970,7 @@ static int __nss_hal_clock_configure(str + nss_core0_clk = clk_get(&nss_dev->dev, NSS_CORE_CLK); + if (IS_ERR(nss_core0_clk)) { + err = PTR_ERR(nss_core0_clk); +- nss_info_always("%p: Regulator %s get failed, err=%d\n", nss_ctx, dev_name(&nss_dev->dev), err); ++ nss_info_always("%px: Regulator %s get failed, err=%d\n", nss_ctx, dev_name(&nss_dev->dev), err); + return err; + } + +@@ -1107,13 +1108,13 @@ clk_complete: + */ + err = clk_set_rate(nss_core0_clk, nss_runtime_samples.freq_scale[NSS_FREQ_MID_SCALE].frequency); + if (err) { +- nss_info_always("%p: cannot set nss core0 clock\n", nss_ctx); ++ nss_info_always("%px: cannot set nss core0 clock\n", nss_ctx); + return -EFAULT; + } + + err = clk_prepare_enable(nss_core0_clk); + if (err) { +- nss_info_always("%p: cannot enable nss core0 clock\n", nss_ctx); ++ nss_info_always("%px: cannot enable nss core0 clock\n", nss_ctx); + return -EFAULT; + } + +@@ -1177,7 +1178,7 @@ static int __nss_hal_request_irq(struct + err = request_irq(npd->irq[irq_num], nss_hal_handle_irq, 0, "nss", int_ctx); + } + if (err) { +- nss_info_always("%p: IRQ%d request failed", nss_ctx, npd->irq[irq_num]); ++ nss_info_always("%px: IRQ%d request failed", nss_ctx, npd->irq[irq_num]); + return err; + } + +@@ -1198,7 +1199,7 @@ void __nss_hal_init_imem(struct nss_ctx_ + mem_ctx->imem_end = mem_ctx->imem_head + NSS_IMEM_SIZE; + mem_ctx->imem_tail = mem_ctx->imem_head; + +- nss_info("%p: IMEM init: head: 0x%x end: 0x%x tail: 0x%x\n", nss_ctx, ++ nss_info("%px: IMEM init: head: 0x%x end: 0x%x tail: 0x%x\n", nss_ctx, + mem_ctx->imem_head, mem_ctx->imem_end, mem_ctx->imem_tail); + } + +--- a/nss_hal/ipq807x/nss_hal_pvt.c ++++ b/nss_hal/ipq807x/nss_hal_pvt.c +@@ -213,17 +213,17 @@ static struct nss_platform_data *__nss_h + nss_ctx->id = npd->id; + + if (of_address_to_resource(np, 0, &res_nphys) != 0) { +- nss_info_always("%p: nss%d: of_address_to_resource() fail for nphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: of_address_to_resource() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; + } + + if (of_address_to_resource(np, 1, &res_vphys) != 0) { +- nss_info_always("%p: nss%d: of_address_to_resource() fail for vphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: of_address_to_resource() fail for vphys\n", nss_ctx, nss_ctx->id); + goto out; + } + + if (of_address_to_resource(np, 2, &res_qgic_phys) != 0) { +- nss_info_always("%p: nss%d: of_address_to_resource() fail for qgic_phys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: of_address_to_resource() fail for qgic_phys\n", nss_ctx, nss_ctx->id); + goto out; + } + +@@ -234,21 +234,21 @@ static struct nss_platform_data *__nss_h + npd->vphys = res_vphys.start; + npd->qgic_phys = res_qgic_phys.start; + +- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); ++ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); + if (!npd->nmap) { +- nss_info_always("%p: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); + goto out; + } + + npd->vmap = ioremap_cache(npd->vphys, resource_size(&res_vphys)); + if (!npd->vmap) { +- nss_info_always("%p: nss%d: ioremap() fail for vphys\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: ioremap() fail for vphys\n", nss_ctx, nss_ctx->id); + goto out; + } + +- npd->qgic_map = ioremap_nocache(npd->qgic_phys, resource_size(&res_qgic_phys)); ++ npd->qgic_map = ioremap(npd->qgic_phys, resource_size(&res_qgic_phys)); + if (!npd->qgic_map) { +- nss_info_always("%p: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); ++ nss_info_always("%px: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); + goto out; + } + +@@ -267,7 +267,7 @@ static struct nss_platform_data *__nss_h + for (i = 0 ; i < npd->num_irq; i++) { + npd->irq[i] = irq_of_parse_and_map(np, i); + if (!npd->irq[i]) { +- nss_info_always("%p: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); ++ nss_info_always("%px: nss%d: irq_of_parse_and_map() fail for irq %d\n", nss_ctx, nss_ctx->id, i); + goto out; + } + } +@@ -368,21 +368,21 @@ static int nss_hal_clock_set_and_enable( + + nss_clk = devm_clk_get(dev, id); + if (IS_ERR(nss_clk)) { +- pr_err("%p: cannot get clock: %s\n", dev, id); ++ pr_err("%px: cannot get clock: %s\n", dev, id); + return -EFAULT; + } + + if (rate) { + err = clk_set_rate(nss_clk, rate); + if (err) { +- pr_err("%p: cannot set %s freq\n", dev, id); ++ pr_err("%px: cannot set %s freq\n", dev, id); + return -EFAULT; + } + } + + err = clk_prepare_enable(nss_clk); + if (err) { +- pr_err("%p: cannot enable clock: %s\n", dev, id); ++ pr_err("%px: cannot enable clock: %s\n", dev, id); + return -EFAULT; + } + +@@ -455,20 +455,20 @@ static int __nss_hal_common_reset(struct + */ + cmn = of_find_node_by_name(NULL, "nss-common"); + if (!cmn) { +- pr_err("%p: Unable to find nss-common node\n", nss_dev); ++ pr_err("%px: Unable to find nss-common node\n", nss_dev); + return -EFAULT; + } + + if (of_address_to_resource(cmn, 0, &res_nss_misc_reset) != 0) { +- pr_err("%p: of_address_to_resource() return error for nss_misc_reset\n", nss_dev); ++ pr_err("%px: of_address_to_resource() return error for nss_misc_reset\n", nss_dev); + of_node_put(cmn); + return -EFAULT; + } + of_node_put(cmn); + +- nss_misc_reset = ioremap_nocache(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); ++ nss_misc_reset = ioremap(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); + if (!nss_misc_reset) { +- pr_err("%p: ioremap fail for nss_misc_reset\n", nss_dev); ++ pr_err("%px: ioremap fail for nss_misc_reset\n", nss_dev); + return -EFAULT; + } + +@@ -504,7 +504,6 @@ static int __nss_hal_clock_configure(str + return -EFAULT; + } + +- + /* + * For IPQ807x, any rate above 1497 is Turbo Voltage + * Temporary set the voltage to turbo till we start scaling frequenices. +@@ -735,7 +734,7 @@ void __nss_hal_init_imem(struct nss_ctx_ + mem_ctx->imem_end = mem_ctx->imem_head + NSS_IMEM_SIZE; + mem_ctx->imem_tail = mem_ctx->imem_head; + +- nss_info("%p: IMEM init: head: 0x%x end: 0x%x tail: 0x%x\n", nss_ctx, ++ nss_info("%px: IMEM init: head: 0x%x end: 0x%x tail: 0x%x\n", nss_ctx, + mem_ctx->imem_head, mem_ctx->imem_end, mem_ctx->imem_tail); + } + +--- a/nss_hal/nss_hal.c ++++ b/nss_hal/nss_hal.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016-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. +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + #include "nss_hal.h" + #include "nss_arch.h" +@@ -40,7 +41,6 @@ + /* + * Macros + */ +-#define MIN_IMG_SIZE (64*1024) + #define NSS_AP0_IMAGE "qca-nss0.bin" + #define NSS_AP1_IMAGE "qca-nss1.bin" + +@@ -61,7 +61,7 @@ int nss_hal_firmware_load(struct nss_ctx + } else if (nss_ctx->id == 1) { + rc = request_firmware(&nss_fw, NSS_AP1_IMAGE, &(nss_dev->dev)); + } else { +- nss_warning("%p: Invalid nss dev: %d\n", nss_ctx, nss_ctx->id); ++ nss_warning("%px: Invalid nss dev: %d\n", nss_ctx, nss_ctx->id); + return -EINVAL; + } + +@@ -69,18 +69,14 @@ int nss_hal_firmware_load(struct nss_ctx + * Check if the file read is successful + */ + if (rc) { +- nss_info_always("%p: request_firmware failed with err code: %d", nss_ctx, rc); ++ nss_info_always("%px: request_firmware failed with err code: %d", nss_ctx, rc); + return rc; + } + +- if (nss_fw->size < MIN_IMG_SIZE) { +- nss_info_always("%p: nss firmware is truncated, size:%d", nss_ctx, (int)nss_fw->size); +- return rc; +- } + +- load_mem = ioremap_nocache(npd->load_addr, nss_fw->size); ++ load_mem = ioremap(npd->load_addr, nss_fw->size); + if (!load_mem) { +- nss_info_always("%p: ioremap_nocache failed: %x", nss_ctx, npd->load_addr); ++ nss_info_always("%px: ioremap failed: %x", nss_ctx, npd->load_addr); + release_firmware(nss_fw); + return rc; + } +@@ -92,6 +88,7 @@ int nss_hal_firmware_load(struct nss_ctx + return 0; + } + ++ + /* + * nss_hal_dt_parse_features() + */ +@@ -102,14 +99,12 @@ void nss_hal_dt_parse_features(struct de + */ + npd->bridge_enabled = of_property_read_bool(np, "qcom,bridge-enabled"); + npd->capwap_enabled = of_property_read_bool(np, "qcom,capwap-enabled"); +- npd->clmap_enabled = of_property_read_bool(np, "qcom,clmap-enabled"); + npd->crypto_enabled = of_property_read_bool(np, "qcom,crypto-enabled"); + npd->dtls_enabled = of_property_read_bool(np, "qcom,dtls-enabled"); + npd->gre_enabled = of_property_read_bool(np, "qcom,gre-enabled"); + npd->gre_redir_enabled = of_property_read_bool(np, "qcom,gre-redir-enabled"); + npd->gre_tunnel_enabled = of_property_read_bool(np, "qcom,gre_tunnel_enabled"); + npd->gre_redir_mark_enabled = of_property_read_bool(np, "qcom,gre-redir-mark-enabled"); +- npd->igs_enabled = of_property_read_bool(np, "qcom,igs-enabled"); + npd->ipsec_enabled = of_property_read_bool(np, "qcom,ipsec-enabled"); + npd->ipv4_enabled = of_property_read_bool(np, "qcom,ipv4-enabled"); + npd->ipv4_reasm_enabled = of_property_read_bool(np, "qcom,ipv4-reasm-enabled"); +@@ -123,20 +118,18 @@ void nss_hal_dt_parse_features(struct de + npd->pptp_enabled = of_property_read_bool(np, "qcom,pptp-enabled"); + npd->portid_enabled = of_property_read_bool(np, "qcom,portid-enabled"); + npd->pvxlan_enabled = of_property_read_bool(np, "qcom,pvxlan-enabled"); ++ npd->clmap_enabled = of_property_read_bool(np, "qcom,clmap-enabled"); + npd->qvpn_enabled = of_property_read_bool(np, "qcom,qvpn-enabled"); + npd->rmnet_rx_enabled = of_property_read_bool(np, "qcom,rmnet_rx-enabled"); + npd->shaping_enabled = of_property_read_bool(np, "qcom,shaping-enabled"); +- npd->tls_enabled = of_property_read_bool(np, "qcom,tls-enabled"); + npd->tstamp_enabled = of_property_read_bool(np, "qcom,tstamp-enabled"); + npd->turbo_frequency = of_property_read_bool(np, "qcom,turbo-frequency"); + npd->tun6rd_enabled = of_property_read_bool(np, "qcom,tun6rd-enabled"); + npd->tunipip6_enabled = of_property_read_bool(np, "qcom,tunipip6-enabled"); + npd->vlan_enabled = of_property_read_bool(np, "qcom,vlan-enabled"); +- npd->vxlan_enabled = of_property_read_bool(np, "qcom,vxlan-enabled"); + npd->wlanredirect_enabled = of_property_read_bool(np, "qcom,wlanredirect-enabled"); + npd->wifioffload_enabled = of_property_read_bool(np, "qcom,wlan-dataplane-offload-enabled"); +- npd->match_enabled = of_property_read_bool(np, "qcom,match-enabled"); +- npd->mirror_enabled = of_property_read_bool(np, "qcom,mirror-enabled"); ++ npd->igs_enabled = of_property_read_bool(np, "qcom,igs-enabled"); + } + /* + * nss_hal_clean_up_irq() +@@ -180,7 +173,7 @@ static int nss_hal_register_irq(struct n + int_ctx->nss_ctx = nss_ctx; + err = nss_top->hal_ops->request_irq(nss_ctx, npd, irq_num); + if (err) { +- nss_warning("%p: IRQ request for queue %d failed", nss_ctx, irq_num); ++ nss_warning("%px: IRQ request for queue %d failed", nss_ctx, irq_num); + return err; + } + +@@ -240,27 +233,27 @@ int nss_hal_probe(struct platform_device + */ + nss_ctx->dev = &nss_dev->dev; + +- nss_info("%p: NSS_DEV_ID %s\n", nss_ctx, dev_name(&nss_dev->dev)); ++ nss_info("%px: NSS_DEV_ID %s\n", nss_ctx, dev_name(&nss_dev->dev)); + + /* + * Do firmware load from nss-drv if required + */ + err = nss_top->hal_ops->firmware_load(nss_ctx, nss_dev, npd); + if (err) { +- nss_info_always("%p: firmware load from driver failed\n", nss_ctx); ++ nss_info_always("%px: firmware load from driver failed\n", nss_ctx); + goto err_init; + } + + err = nss_top->hal_ops->clock_configure(nss_ctx, nss_dev, npd); + if (err) { +- nss_info_always("%p: clock configure failed\n", nss_ctx); ++ nss_info_always("%px: clock configure failed\n", nss_ctx); + goto err_init; + } + + /* + * Get load address of NSS firmware + */ +- nss_info("%p: Setting NSS%d Firmware load address to %x\n", nss_ctx, nss_ctx->id, npd->load_addr); ++ nss_info("%px: Setting NSS%d Firmware load address to %x\n", nss_ctx, nss_ctx->id, npd->load_addr); + nss_top->nss[nss_ctx->id].load = npd->load_addr; + + /* +@@ -292,12 +285,11 @@ int nss_hal_probe(struct platform_device + * Physical address of logical registers space + */ + nss_ctx->vphys = npd->vphys; +- nss_assert(nss_ctx->vphys); +- nss_info("%d:ctx=%p, vphys=%x, vmap=%p, nphys=%x, nmap=%p", nss_ctx->id, ++ nss_info("%d:ctx=%px, vphys=%x, vmap=%px, nphys=%x, nmap=%px", nss_ctx->id, + nss_ctx, nss_ctx->vphys, nss_ctx->vmap, nss_ctx->nphys, nss_ctx->nmap); + + if (!nss_meminfo_init(nss_ctx)) { +- nss_info_always("%p: meminfo init failed\n", nss_ctx); ++ nss_info_always("%px: meminfo init failed\n", nss_ctx); + err = -EFAULT; + goto err_init; + } +@@ -321,7 +313,7 @@ int nss_hal_probe(struct platform_device + if (npd->tstamp_enabled == NSS_FEATURE_ENABLED) { + tstamp_ndev = nss_tstamp_register_netdev(); + if (!tstamp_ndev) { +- nss_warning("%p: Unable to register the TSTAMP net_device", nss_ctx); ++ nss_warning("%px: Unable to register the TSTAMP net_device", nss_ctx); + npd->tstamp_enabled = NSS_FEATURE_NOT_ENABLED; + } + nss_top->tstamp_handler_id = nss_dev->id; +@@ -363,8 +355,10 @@ int nss_hal_probe(struct platform_device + nss_top->ipv4_handler_id = nss_dev->id; + nss_ipv4_register_handler(); + ++#ifdef NSS_DRV_EDMA_ENABLE + nss_top->edma_handler_id = nss_dev->id; + nss_edma_register_handler(); ++#endif + nss_eth_rx_register_handler(nss_ctx); + #ifdef NSS_DRV_LAG_ENABLE + nss_lag_register_handler(); +@@ -380,27 +374,35 @@ int nss_hal_probe(struct platform_device + nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N] = nss_dev->id; + } + ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,3)) + #ifdef NSS_DRV_CAPWAP_ENABLE + if (npd->capwap_enabled == NSS_FEATURE_ENABLED) { + nss_top->capwap_handler_id = nss_dev->id; + nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP] = nss_dev->id; + } + #endif ++#endif + ++#ifdef NSS_DRV_IPV4_REASM_ENABLE + if (npd->ipv4_reasm_enabled == NSS_FEATURE_ENABLED) { + nss_top->ipv4_reasm_handler_id = nss_dev->id; + nss_ipv4_reasm_register_handler(); + } ++#endif + ++#ifdef NSS_DRV_IPV6_ENABLE + if (npd->ipv6_enabled == NSS_FEATURE_ENABLED) { + nss_top->ipv6_handler_id = nss_dev->id; + nss_ipv6_register_handler(); + } + ++#ifdef NSS_DRV_IPV6_REASM_ENABLE + if (npd->ipv6_reasm_enabled == NSS_FEATURE_ENABLED) { + nss_top->ipv6_reasm_handler_id = nss_dev->id; + nss_ipv6_reasm_register_handler(); + } ++#endif ++#endif + + #ifdef NSS_DRV_CRYPTO_ENABLE + /* +@@ -415,6 +417,11 @@ int nss_hal_probe(struct platform_device + nss_top->crypto_enabled = 1; + nss_crypto_register_handler(); + #endif ++ ++#if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) ++ nss_top->dma_handler_id = nss_dev->id; ++ nss_dma_register_handler(); ++#endif + } + #endif + +@@ -451,16 +458,20 @@ int nss_hal_probe(struct platform_device + } + #endif + ++#ifdef NSS_DRV_PPPOE_ENABLE + if (npd->pppoe_enabled == NSS_FEATURE_ENABLED) { + nss_top->pppoe_handler_id = nss_dev->id; + nss_pppoe_register_handler(); + } ++#endif + ++#ifdef NSS_DRV_PPE_ENABLE + if (npd->ppe_enabled == NSS_FEATURE_ENABLED) { + nss_top->ppe_handler_id = nss_dev->id; + nss_ppe_register_handler(); + nss_ppe_vp_register_handler(); + } ++#endif + + #ifdef NSS_DRV_L2TP_ENABLE + if (npd->l2tpv2_enabled == NSS_FEATURE_ENABLED) { +@@ -547,22 +558,26 @@ int nss_hal_probe(struct platform_device + } + #endif + ++#ifdef NSS_DRV_WIFI_ENABLE + if (npd->wifioffload_enabled == NSS_FEATURE_ENABLED) { + nss_top->wifi_handler_id = nss_dev->id; + nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_VAP] = nss_dev->id; + nss_wifi_register_handler(); + nss_wifili_register_handler(); ++#if (NSS_FW_VERSION_CODE <= NSS_FW_VERSION(11,0)) ++ nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFILI] = nss_dev->id; ++#else + nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_INTERNAL] = nss_dev->id; + nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_EXTERNAL0] = nss_dev->id; + nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_EXTERNAL1] = nss_dev->id; +- + /* + * Register wifi mac database when offload enabled + */ + nss_top->wmdb_handler_id = nss_dev->id; + nss_wifi_mac_db_register_handler(); ++#endif + } +- ++#endif + + #ifdef NSS_DRV_OAM_ENABLE + if (npd->oam_enabled == NSS_FEATURE_ENABLED) { +@@ -571,17 +586,21 @@ int nss_hal_probe(struct platform_device + } + #endif + ++#ifdef NSS_DRV_BRIDGE_ENABLE + if (npd->bridge_enabled == NSS_FEATURE_ENABLED) { + nss_top->bridge_handler_id = nss_dev->id; + nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_BRIDGE] = nss_dev->id; + nss_bridge_init(); + } ++#endif + ++#ifdef NSS_DRV_VLAN_ENABLE + if (npd->vlan_enabled == NSS_FEATURE_ENABLED) { + nss_top->vlan_handler_id = nss_dev->id; + nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_VLAN] = nss_dev->id; + nss_vlan_register_handler(); + } ++#endif + + #ifdef NSS_DRV_QVPN_ENABLE + #if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) +@@ -635,12 +654,15 @@ int nss_hal_probe(struct platform_device + } + #endif + ++#ifdef NSS_DRV_MATCH_ENABLE + if (npd->match_enabled == NSS_FEATURE_ENABLED) { + nss_top->match_handler_id = nss_dev->id; + nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_MATCH] = nss_dev->id; + nss_match_init(); + } ++#endif + ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,1)) + #ifdef NSS_DRV_TLS_ENABLE + #if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) + if (npd->tls_enabled == NSS_FEATURE_ENABLED) { +@@ -651,12 +673,15 @@ int nss_hal_probe(struct platform_device + } + #endif + #endif ++#ifdef NSS_DRV_MIRROR_ENABLE + if (npd->mirror_enabled == NSS_FEATURE_ENABLED) { + nss_top->mirror_handler_id = nss_dev->id; + nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_MIRROR] = nss_dev->id; + nss_mirror_register_handler(); + nss_info("%d: NSS mirror is enabled", nss_dev->id); + } ++#endif ++#endif + + if (nss_ctx->id == 0) { + #if (NSS_FREQ_SCALE_SUPPORT == 1) +@@ -685,7 +710,7 @@ int nss_hal_probe(struct platform_device + spin_lock_init(&(nss_ctx->decongest_cb_lock)); + nss_ctx->magic = NSS_CTX_MAGIC; + +- nss_info("%p: Reseting NSS core %d now", nss_ctx, nss_ctx->id); ++ nss_info("%px: Reseting NSS core %d now", nss_ctx, nss_ctx->id); + + /* + * Enable clocks and bring NSS core out of reset +@@ -716,7 +741,7 @@ int nss_hal_probe(struct platform_device + nss_hal_enable_interrupt(nss_ctx, nss_ctx->int_ctx[i].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS); + } + +- nss_info("%p: All resources initialized and nss core%d has been brought out of reset", nss_ctx, nss_dev->id); ++ nss_info("%px: All resources initialized and nss core%d has been brought out of reset", nss_ctx, nss_dev->id); + goto out; + + err_register_irq: +@@ -787,6 +812,6 @@ int nss_hal_remove(struct platform_devic + } + } + +- nss_info("%p: All resources freed for nss core%d", nss_ctx, nss_dev->id); ++ nss_info("%px: All resources freed for nss core%d", nss_ctx, nss_dev->id); + return 0; + } +--- a/nss_ppe.c ++++ b/nss_ppe.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016-2018, 2020, 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. +@@ -72,12 +72,12 @@ nss_tx_status_t nss_ppe_tx_msg(struct ns + * Sanity check the message + */ + if (ncm->type >= NSS_PPE_MSG_MAX) { +- nss_warning("%p: message type out of range: %d\n", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d\n", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + + if (!nss_ppe_verify_ifnum(ncm->interface)) { +- nss_warning("%p: invalid interface %d\n", nss_ctx, ncm->interface); ++ nss_warning("%px: invalid interface %d\n", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + +@@ -102,14 +102,14 @@ nss_tx_status_t nss_ppe_tx_msg_sync(stru + + status = nss_ppe_tx_msg(nss_ctx, npm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: ppe_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: ppe_tx_msg failed\n", nss_ctx); + up(&ppe_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&ppe_pvt.complete, msecs_to_jiffies(NSS_PPE_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: ppe msg tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: ppe msg tx failed due to timeout\n", nss_ctx); + ppe_pvt.response = NSS_TX_FAILURE; + } + +@@ -244,7 +244,7 @@ static void nss_ppe_handler(struct nss_c + + nss_ppe_msg_callback_t cb; + +- nss_trace("nss_ctx: %p ppe msg: %p\n", nss_ctx, msg); ++ nss_trace("nss_ctx: %px ppe msg: %px\n", nss_ctx, msg); + BUG_ON(!nss_ppe_verify_ifnum(ncm->interface)); + + /* +@@ -256,12 +256,12 @@ static void nss_ppe_handler(struct nss_c + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_PPE_MSG_MAX) { +- nss_warning("%p: received invalid message %d for PPE interface\n", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for PPE interface\n", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ppe_msg)) { +- nss_warning("%p: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -354,7 +354,7 @@ void nss_ppe_init(void) + /* + * Get the PPE base address + */ +- ppe_pvt.ppe_base = ioremap_nocache(PPE_BASE_ADDR, PPE_REG_SIZE); ++ ppe_pvt.ppe_base = ioremap(PPE_BASE_ADDR, PPE_REG_SIZE); + if (!ppe_pvt.ppe_base) { + nss_warning("DRV can't get PPE base address\n"); + return; --- a/nss_coredump.c +++ b/nss_coredump.c -@@ -25,7 +25,11 @@ +@@ -1,6 +1,8 @@ + /* + ************************************************************************** + * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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. +@@ -23,7 +25,11 @@ #include "nss_hal.h" #include "nss_log.h" #include @@ -8310,498 +2334,2858 @@ #include /* for time */ #include "nss_tx_rx_common.h" +@@ -43,7 +49,8 @@ static struct workqueue_struct *coredump + */ + static void nss_coredump_wait(struct work_struct *work) + { +- panic("did not get all coredump finished signals\n"); ++ if (!(nss_cmd_buf.coredump & 0xFFFFFFFE)) ++ panic("did not get all coredump finished signals\n"); + } + + /* +@@ -79,7 +86,7 @@ static int nss_panic_handler(struct noti + continue; + nss_ctx->state |= NSS_CORE_STATE_PANIC; + nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_TRIGGER_COREDUMP); +- nss_warning("panic call NSS FW %p to dump %x\n", ++ nss_warning("panic call NSS FW %px to dump %x\n", + nss_ctx->nmap, nss_ctx->state); + } + +@@ -138,7 +145,7 @@ void nss_fw_coredump_notify(struct nss_c + dma_addr_t dma_addr; + uint32_t offset, index; + +- nss_warning("%p: COREDUMP %x Baddr %p stat %x", ++ nss_warning("%px: COREDUMP %x Baddr %px stat %x", + nss_own, intr, nss_own->nmap, nss_own->state); + nss_own->state |= NSS_CORE_STATE_FW_DEAD; + queue_delayed_work(coredump_workqueue, &coredump_queuewait, +@@ -154,14 +161,14 @@ void nss_fw_coredump_notify(struct nss_c + dma_addr = nss_own->meminfo_ctx.logbuffer_dma; + } + +- dma_sync_single_for_cpu(NULL, dma_addr, sizeof(struct nss_log_descriptor), DMA_FROM_DEVICE); ++ dma_sync_single_for_cpu(nss_own->dev, dma_addr, sizeof(struct nss_log_descriptor), DMA_FROM_DEVICE); + + /* + * If the current entry is smaller than or equal to the number of NSS_LOG_COREDUMP_LINE_NUM, + * only print whatever is in the buffer. Otherwise, dump last NSS_LOG_COREDUMP_LINE_NUM + * to the dmessage. + */ +- nss_info_always("%p: Starting NSS-FW logbuffer dump for core %u\n", ++ nss_info_always("%px: Starting NSS-FW logbuffer dump for core %u\n", + nss_own, nss_own->id); + nle_init = nld->log_ring_buffer; + if (nld->current_entry <= NSS_LOG_COREDUMP_LINE_NUM) { +@@ -181,9 +188,9 @@ void nss_fw_coredump_notify(struct nss_c + + offset = (index * sizeof(struct nss_log_entry)) + + offsetof(struct nss_log_descriptor, log_ring_buffer); +- dma_sync_single_for_cpu(NULL, dma_addr + offset, ++ dma_sync_single_for_cpu(nss_own->dev, dma_addr + offset, + sizeof(struct nss_log_entry), DMA_FROM_DEVICE); +- nss_info_always("%p: %s\n", nss_own, nle_print->message); ++ nss_info_always("%px: %s\n", nss_own, nle_print->message); + nle_print++; + } + +@@ -223,7 +230,7 @@ void nss_fw_coredump_notify(struct nss_c + * Notify any live core to dump. + */ + if (!(nss_ctx->state & NSS_CORE_STATE_FW_DEAD) && nss_ctx->nmap) { +- nss_warning("notify NSS FW %p for coredump\n", nss_ctx->nmap); ++ nss_warning("notify NSS FW %px for coredump\n", nss_ctx->nmap); + nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_TRIGGER_COREDUMP); + continue; + } +--- a/Makefile.fsm ++++ b/Makefile.fsm +@@ -36,6 +36,7 @@ qca-nss-drv-objs := \ + nss_gre_tunnel_log.o \ + nss_gre_tunnel_stats.o \ + nss_if.o \ ++ nss_if_log.o \ + nss_init.o \ + nss_ipsec.o \ + nss_ipsec_log.o \ +@@ -110,7 +111,7 @@ qca-nss-drv-objs := \ + + qca-nss-drv-objs += nss_hal/nss_hal.o + qca-nss-drv-objs += nss_hal/fsm9010/nss_hal_pvt.o +-qca-nss-drv-objs += nss_data_plane/nss_data_plane.o ++qca-nss-drv-objs += nss_data_plane/nss_data_plane_common.o + qca-nss-drv-objs += nss_data_plane/nss_data_plane_gmac.o + + ccflags-y += -I$(obj)/nss_hal/include +--- a/exports/nss_api_if.h ++++ b/exports/nss_api_if.h +@@ -44,10 +44,12 @@ + #include "nss_ipv6.h" + #include "nss_shaper.h" + #include "nss_if.h" ++#include "nss_phy_if.h" + #include "nss_virt_if.h" + #include "nss_pppoe.h" + #include "nss_crypto.h" + #include "nss_crypto_cmn.h" ++#include "nss_dma.h" + + #include "nss_profiler.h" + #include "nss_dynamic_interface.h" +@@ -117,7 +119,11 @@ + #define NSS_MAX_PHYSICAL_INTERFACES 8 /**< Maximum number of physical interfaces. */ + #define NSS_MAX_VIRTUAL_INTERFACES 16 /**< Maximum number of virtual interfaces. */ + #define NSS_MAX_TUNNEL_INTERFACES 4 /**< Maximum number of tunnel interfaces. */ +-#define NSS_MAX_SPECIAL_INTERFACES 66 /**< Maximum number of special interfaces. */ ++#if (NSS_FW_VERSION_CODE < NSS_FW_VERSION(11,1)) ++#define NSS_MAX_SPECIAL_INTERFACES 55 /**< Maximum number of special interfaces. */ ++#else ++#define NSS_MAX_SPECIAL_INTERFACES 67 /**< Maximum number of special interfaces. */ ++#endif + #define NSS_MAX_WIFI_RADIO_INTERFACES 3 /**< Maximum number of radio interfaces. */ + + /* +@@ -251,6 +257,10 @@ + /**< Special interface number for timestamp receive. */ + #define NSS_GRE_REDIR_MARK_INTERFACE (NSS_SPECIAL_IF_START + 56) + /**< Special interface number for GRE redirect mark. */ ++#if (NSS_FW_VERSION_CODE < NSS_FW_VERSION(11,1)) ++#define NSS_RMNET_RX_INTERFACE (NSS_SPECIAL_IF_START + 57) ++ /**< Special interface number for RMNET receive handler. */ ++#else + #define NSS_VXLAN_INTERFACE (NSS_SPECIAL_IF_START + 57) + /**< Special interface number for VxLAN handler. */ + #define NSS_RMNET_RX_INTERFACE (NSS_SPECIAL_IF_START + 58) +@@ -262,9 +272,12 @@ + #define NSS_TLS_INTERFACE (NSS_SPECIAL_IF_START + 61) + /**< Special interface number for TLS. */ + #define NSS_PPE_VP_INTERFACE (NSS_SPECIAL_IF_START + 62) +- /**< Special interface number for the virtual port interface. */ ++ /**< Special interface number for the virtual port (62, 63, 64) interface. */ + #define NSS_WIFI_MAC_DB_INTERFACE (NSS_SPECIAL_IF_START + 65) + /**< Special interface number for the Wi-Fi MAC database. */ ++#define NSS_DMA_INTERFACE (NSS_SPECIAL_IF_START + 66) ++ /**< Special interface number for the DMA interface. */ ++#endif + + #ifdef __KERNEL__ /* only kernel will use. */ + +--- a/exports/nss_bridge.h ++++ b/exports/nss_bridge.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016-2018,2020, 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. +@@ -338,8 +338,8 @@ nss_tx_status_t nss_bridge_tx_vsi_unassi + * @datatypes + * nss_bridge_fdb_learn_mode + * +- * @param[in] if_num Interface number of the bridge. +- * @param[in] fdb_learn FDB learning disable/enable. ++ * @param[in] bridge_if_num Interface number of the bridge. ++ * @param[in] fdb_learn FDB learning disable/enable. + * + * @return + * Status of the Tx operation. +--- a/exports/nss_clmap.h ++++ b/exports/nss_clmap.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -22,6 +22,11 @@ + #ifndef __NSS_CLMAP_H + #define __NSS_CLMAP_H + ++ /** ++ * @addtogroup nss_clmap_subsystem ++ * @{ ++ */ ++ + /** + * Maximum number of supported client map interface. + */ +@@ -87,7 +92,7 @@ struct nss_clmap_stats_msg { + + /** + * nss_clmap_mac_msg +- * CLient map MAC message structure. ++ * Client map MAC message structure. + */ + struct nss_clmap_mac_msg { + uint32_t vlan_id; /**< VLAN ID. */ +@@ -200,7 +205,7 @@ extern nss_tx_status_t nss_clmap_tx_msg_ + * sk_buff + * + * @param[in] nss_ctx Pointer to the NSS context. +- * @param[in] os_buf Pointer to the data buffer. ++ * @param[in] buf Pointer to the data buffer. + * @param[in] if_num NSS interface number. + * + * @return +--- /dev/null ++++ b/exports/nss_dma.h +@@ -0,0 +1,264 @@ ++/* ++ ************************************************************************** ++ * Copyright (c) 2020, 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. ++ ************************************************************************** ++ */ ++/** ++ * @file nss_dma.h ++ * NSS DMA for linearization and split interface definitions. ++ */ ++ ++#ifndef __NSS_DMA_H ++#define __NSS_DMA_H ++ ++/** ++ * @addtogroup nss_dma_subsystem ++ * @{ ++ */ ++ ++/** ++ * nss_dma_msg_type ++ * Supported message types. ++ */ ++enum nss_dma_msg_type { ++ NSS_DMA_MSG_TYPE_NONE, /**< Invalid message type. */ ++ NSS_DMA_MSG_TYPE_CONFIGURE, /**< Configure DMA. */ ++ NSS_DMA_MSG_TYPE_SYNC_STATS, /**< Statistics synchronization. */ ++ NSS_DMA_MSG_TYPE_TEST_PERF, /**< Performance test. */ ++ NSS_DMA_MSG_TYPE_MAX /**< Maximum message type. */ ++}; ++ ++/** ++ * nss_dma_msg_error ++ * Message error types. ++ */ ++enum nss_dma_msg_error { ++ NSS_DMA_MSG_ERROR_NONE, /**< No error. */ ++ NSS_DMA_MSG_ERROR_HW_INIT, /**< Invalid operation. */ ++ NSS_DMA_MSG_ERROR_UNHANDLED, /**< Invalid test ID. */ ++ NSS_DMA_MSG_ERROR_TEST, /**< Performance test failed. */ ++ NSS_DMA_MSG_ERROR_MAX /**< Maximum error type. */ ++}; ++ ++/** ++ * nss_dma_test_type ++ * DMA Test types. ++ */ ++enum nss_dma_test_type { ++ NSS_DMA_TEST_TYPE_DEFAULT = 0, /**< Test default segment size. */ ++ NSS_DMA_TEST_TYPE_SWEEP, /**< Test sweep segment size. */ ++ NSS_DMA_TEST_TYPE_LARGE, /**< Test large segment size. */ ++ NSS_DMA_TEST_TYPE_VERIFY, /**< Verify contents at receive processing. */ ++ NSS_DMA_TEST_TYPE_MAX /**< Maximum test type. */ ++}; ++ ++#ifdef __KERNEL__ /* only kernel will use. */ ++/* ++ * Maximum number of HW specific statistics ++ */ ++#define NSS_DMA_HW_ERROR_MAX 16 ++ ++/* ++ * Test configuration flags ++ */ ++#define NSS_DMA_TEST_FLAGS_LINEARIZE 0x01 /**< Linearize test. */ ++#define NSS_DMA_TEST_FLAGS_SPLIT 0x02 /**< Split test. */ ++ ++/** ++ * nss_dma_test_cfg ++ * Test configuration. ++ */ ++struct nss_dma_test_cfg { ++ struct nss_cmn_node_stats node_stats; /**< Common node statistics for DMA interface. */ ++ uint32_t flags; /**< Test configuration flags. */ ++ uint32_t time_delta; /**< Difference between start and end. */ ++ uint16_t packet_count; /**< Number of packets to send. */ ++ uint16_t type; /**< Type of test to run. */ ++}; ++ ++/** ++ * nss_dma_stats ++ * DMA statistics. ++ */ ++struct nss_dma_stats { ++ struct nss_cmn_node_stats node_stats; /**< Common node statistics for DMA interface. */ ++ uint32_t no_req; /**< Request descriptor not available. */ ++ uint32_t no_desc; /**< DMA descriptors not available. */ ++ uint32_t fail_nexthop; /**< Failed to retrive next hop. */ ++ uint32_t fail_nexthop_queue; /**< Failed to queue next hop. */ ++ uint32_t fail_linear_sz; /**< Failed to get memory for linearization. */ ++ uint32_t fail_linear_alloc; /**< Failed to allocate buffer for linearization. */ ++ uint32_t fail_linear_no_sg; /**< Skip linearization due to non-SG packet. */ ++ uint32_t fail_split_sz; /**< Failed to spliting buffer into multiple buffers. */ ++ uint32_t fail_split_alloc; /**< Failed to allocate buffer for split. */ ++ uint32_t fail_sync_alloc; /**< Failed to allocate buffer for sending statistics. */ ++ uint32_t fail_ctx_active; /**< Failed to queue as the node is not active. */ ++ uint32_t fail_hw[NSS_DMA_HW_ERROR_MAX]; /**< Hardware failures. */ ++}; ++ ++/** ++ * nss_dma_msg ++ * Message structure for configuring the DMA interface. ++ */ ++struct nss_dma_msg { ++ struct nss_cmn_msg cm; /**< Common message header. */ ++ ++ /** ++ * Payload of a NSS core-to-core transmission rule or statistics message. ++ */ ++ union { ++ struct nss_dma_test_cfg test_cfg; ++ /**< DMA test configuration. */ ++ struct nss_dma_stats stats; /**< DMA interface statistics. */ ++ } msg; /**< Message payload. */ ++}; ++ ++/** ++ * nss_dma_register_handler ++ * Registers the DMA message handler. ++ * ++ * @datatypes ++ * nss_ctx_instance ++ * ++ * @param[in] nss_ctx Pointer to the NSS context. ++ * ++ * @return ++ * None. ++ */ ++void nss_dma_register_handler(void); ++ ++/** ++ * Callback function for receiving DMA messages. ++ * ++ * @datatypes ++ * nss_c2c_tx_msg ++ * ++ * @param[in] app_data Pointer to the application context of the message. ++ * @param[in] msg Pointer to the message data. ++ */ ++typedef void (*nss_dma_msg_callback_t)(void *app_data, struct nss_cmn_msg *msg); ++ ++/** ++ * nss_dma_tx_msg ++ * Transmits a DMA message to the NSS. ++ * ++ * @datatypes ++ * nss_ctx_instance \n ++ * nss_dma_msg ++ * ++ * @param[in] nss_ctx Pointer to the NSS context. ++ * @param[in] ndm Pointer to the message data. ++ * ++ * @return ++ * Status of the transmit operation. ++ */ ++extern nss_tx_status_t nss_dma_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_dma_msg *ndm); ++ ++/** ++ * nss_dma_msg_init ++ * Initializes DMA messages. ++ * ++ * @datatypes ++ * nss_dma_msg \n ++ * nss_dma_msg_callback_t ++ * ++ * @param[in] ndm Pointer to the NSS interface message. ++ * @param[in] if_num NSS interface number. ++ * @param[in] type Type of message. ++ * @param[in] len Size of the payload. ++ * @param[in] cb Callback function for the message. ++ * @param[in] app_data Pointer to the application context of the message. ++ * ++ * @return ++ * None. ++ */ ++extern void nss_dma_msg_init(struct nss_dma_msg *ndm, uint16_t if_num, uint32_t type, uint32_t len, ++ nss_dma_msg_callback_t cb, void *app_data); ++ ++/** ++ * nss_dma_notify_register ++ * Registers a notifier callback for DMA messages with the NSS. ++ * ++ * @datatypes ++ * nss_dma_msg_callback_t ++ * ++ * @param[in] core NSS core number index to the notifier callback table. ++ * @param[in] cb Callback function for the message. ++ * @param[in] app_data Pointer to the application context of the message. ++ * ++ * @return ++ * Pointer to the NSS core context. ++ */ ++struct nss_ctx_instance *nss_dma_notify_register(int core, nss_dma_msg_callback_t cb, void *app_data); ++ ++/** ++ * nss_dma_notify_unregister ++ * Deregisters a DMA message notifier callback from the NSS. ++ * ++ * @param[in] core NSS core number index to the notifier callback table. ++ * ++ * @return ++ * None. ++ * ++ * @dependencies ++ * The notifier callback must have been previously registered. ++ */ ++void nss_dma_notify_unregister(int core); ++ ++/** ++ * nss_dma_register_sysctl ++ * Registers the DMA interface to Linux system control tree. ++ * ++ * @return ++ * None. ++ */ ++extern void nss_dma_register_sysctl(void); ++ ++/** ++ * nss_dma_unregister_sysctl ++ * Deregisters the DMA interface from Linux system control tree. ++ * ++ * @return ++ * None. ++ * ++ * @dependencies ++ * The system control must have been previously registered. ++ */ ++extern void nss_dma_unregister_sysctl(void); ++ ++/** ++ * nss_dma_init ++ * Initializes the DMA interface. ++ * ++ * @return ++ * None. ++ */ ++void nss_dma_init(void); ++ ++/** ++ * nss_dma_get_context ++ * Get the per NSS core context enabled for DMA. ++ * ++ * @return ++ * Pointer to the NSS core context. ++ */ ++extern struct nss_ctx_instance *nss_dma_get_context(void); ++#endif /*__KERNEL__ */ ++ ++/** ++ * @} ++ */ ++ ++#endif /* __NSS_C2C_TX_H */ +--- a/exports/nss_dtls_cmn.h ++++ b/exports/nss_dtls_cmn.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2017-2020, 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. +@@ -31,8 +31,10 @@ + #define NSS_DTLS_CMN_CTX_HDR_UDPLITE 0x0002 /**< DTLS with UDPLite. */ + #define NSS_DTLS_CMN_CTX_HDR_CAPWAP 0x0004 /**< DTLS with CAPWAP. */ + #define NSS_DTLS_CMN_CTX_CIPHER_MODE_GCM 0x0008 /**< DTLS with GCM cipher mode. */ +-#define NSS_DTLS_CMN_CTX_OUTER_UDPLITE_CSUM 0x10000 /**< Checksum only UDPLite header. */ +-#define NSS_DTLS_CMN_CTX_INNER_ACCEPT_ALL 0x20000 ++#define NSS_DTLS_CMN_CTX_ENCAP_UDPLITE_CSUM 0x10000 /**< Checksum only UDPLite header. */ ++#define NSS_DTLS_CMN_CTX_ENCAP_METADATA 0x20000 /**< Valid metadata in encapsulation direction. */ ++#define NSS_DTLS_CMN_CTX_DECAP_ACCEPT_ALL 0x40000 /**< Exception all error packets to host. */ ++ + #define NSS_DTLS_CMN_CLE_MAX 32 /**< Max classification error. */ + + /** +--- a/exports/nss_gre_tunnel.h ++++ b/exports/nss_gre_tunnel.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016-2018,2020, 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. +@@ -104,7 +104,7 @@ enum nss_gre_tunnel_error_types { + struct nss_gre_tunnel_di_to_wlan_id { + uint32_t dynamic_interface_num; /**< Dynamic interface number. */ + uint16_t wlan_id; /**< WLAN ID number. */ +- uint16_t reserved0; /**< Reserved padding. */ ++ uint16_t fwd_policy; /**< Forward policy bits. */ + }; + + /** +--- a/exports/nss_if.h ++++ b/exports/nss_if.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014-2020, 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. +@@ -22,6 +22,8 @@ + #ifndef __NSS_IF_H + #define __NSS_IF_H + ++#define NSS_IF_TX_TIMEOUT 3000 /* 3 Seconds */ ++ + /** + * @addtogroup nss_driver_subsystem + * @{ +@@ -323,20 +325,51 @@ extern nss_tx_status_t nss_if_tx_buf(str + nss_tx_status_t nss_if_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_if_msg *nim); + + /** +- * nss_phys_if_set_nexthop +- * Configure nexthop for an interface. ++ * nss_if_msg_sync ++ * Sends a message to the NSS interface and wait for the response. ++ * ++ * @datatypes ++ * nss_ctx_instance \n ++ * nss_if_msg ++ * ++ * @param[in,out] nss_ctx Pointer to the NSS context. ++ * @param[in] nim Pointer to the NSS interface message. ++ * ++ * @return ++ * Status of the Tx operation. ++ */ ++nss_tx_status_t nss_if_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_if_msg *nim); ++ ++/** ++ * nss_if_set_nexthop ++ * Configure the next hop for an interface. + * + * @datatypes + * nss_ctx_instance + * + * @param[in] nss_ctx Pointer to the NSS context. +- * @param[in] if_num Network physical or virtual interface number. +- * @param[in] nexthop Network physical or virtual interface number. ++ * @param[in] if_num NSS interface number. ++ * @param[in] nexthop NSS interface number for next hop node. ++ * ++ * @return ++ * Status of the Tx operation. ++ */ ++nss_tx_status_t nss_if_set_nexthop(struct nss_ctx_instance *nss_ctx, uint32_t if_num, uint32_t nexthop); ++ ++/** ++ * nss_if_reset_nexthop ++ * De-configure the next hop for an interface. ++ * ++ * @datatypes ++ * nss_ctx_instance ++ * ++ * @param[in] nss_ctx Pointer to the NSS context. ++ * @param[in] if_num NSS interface number. + * + * @return + * Status of the Tx operation. + */ +-nss_tx_status_t nss_phys_if_set_nexthop(struct nss_ctx_instance *nss_ctx, uint32_t if_num, uint32_t nexthop); ++nss_tx_status_t nss_if_reset_nexthop(struct nss_ctx_instance *nss_ctx, uint32_t if_num); + + /** + * @} +--- a/exports/nss_ipsec_cmn.h ++++ b/exports/nss_ipsec_cmn.h +@@ -23,7 +23,7 @@ + #define __NSS_IPSEC_CMN_H_ + + /** +- * @addtogroup nss_nss_ipsec_subsystem ++ * @addtogroup nss_ipsec_subsystem + * @{ + */ + +--- a/exports/nss_l2tpv2.h ++++ b/exports/nss_l2tpv2.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2015,2017-2020, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2015, 2017-2020, 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. +@@ -103,7 +103,7 @@ struct nss_l2tpv2_session_destroy_msg { + + /** + * nss_l2tpv2_bind_ipsec_if_msg +- * Message for binding IPsec interface with L2TP. ++ * Message for binding the IPsec interface with L2TP. + * + * Message for configuring the L2TP session with an + * IPsec inner interface number. This is used when +@@ -139,7 +139,7 @@ struct nss_l2tpv2_sync_session_stats_msg + uint32_t decap_pbuf_alloc_fail; + /**< Buffer allocation failure during decapsulation. */ + uint32_t decap_l2tpoipsec_src_error; +- /**< Packets dropped due to wrong source for L2TPoIPsec flow. */ ++ /**< Packets dropped due to the wrong source for the L2TPoIPsec flow. */ + } debug_stats; /**< Debug statistics object for l2tp v2. */ + }; + +--- /dev/null ++++ b/exports/nss_phy_if.h +@@ -0,0 +1,67 @@ ++/* ++ ************************************************************************** ++ * Copyright (c) 2020, 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. ++ ************************************************************************** ++ */ ++ ++/** ++ * @file nss_phy_if.h.h ++ * NSS physical interface definitions. ++ */ ++ ++#ifndef __NSS_PHY_IF_H ++#define __NSS_PHY_IF_H ++ ++/** ++ * @addtogroup nss_driver_subsystem ++ * @{ ++ */ ++ ++/** ++ * nss_phys_if_reset_nexthop ++ * De-configure nexthop for an interface. ++ * ++ * @datatypes ++ * nss_ctx_instance ++ * ++ * @param[in] nss_ctx Pointer to the NSS context. ++ * @param[in] if_num Network physical interface number. ++ * ++ * @return ++ * Status of the Tx operation. ++ */ ++nss_tx_status_t nss_phys_if_reset_nexthop(struct nss_ctx_instance *nss_ctx, uint32_t if_num); ++ ++/** ++ * nss_phys_if_set_nexthop ++ * Configure nexthop for an interface. ++ * ++ * @datatypes ++ * nss_ctx_instance ++ * ++ * @param[in] nss_ctx Pointer to the NSS context. ++ * @param[in] if_num Network physical interface number. ++ * @param[in] nexthop Network physical or virtual interface number. ++ * ++ * @return ++ * Status of the Tx operation. ++ */ ++nss_tx_status_t nss_phys_if_set_nexthop(struct nss_ctx_instance *nss_ctx, uint32_t if_num, uint32_t nexthop); ++ ++/** ++ * @} ++ */ ++ ++#endif /* __NSS_PHY_IF_H */ +--- a/exports/nss_pvxlan.h ++++ b/exports/nss_pvxlan.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -270,7 +270,7 @@ extern nss_tx_status_t nss_pvxlan_tx_msg + * sk_buff + * + * @param[in] nss_ctx Pointer to the NSS context. +- * @param[in] os_buf Pointer to the data buffer. ++ * @param[in] buf Pointer to the data buffer. + * @param[in] if_num NSS interface number. + * + * @return +--- a/exports/nss_rmnet_rx.h ++++ b/exports/nss_rmnet_rx.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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 +@@ -27,7 +27,7 @@ + #include "nss_if.h" + + /** +- * @addtogroup nss_virtual_if_subsystem ++ * @addtogroup nss_rmnet_subsystem + * @{ + */ + +--- a/exports/nss_trustsec_tx.h ++++ b/exports/nss_trustsec_tx.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016-2017, 2020 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. +@@ -32,10 +32,11 @@ + * Message types for TrustSec Tx requests and responses. + */ + enum nss_trustsec_tx_msg_types { +- NSS_TRUSTSEC_TX_CONFIGURE_MSG, +- NSS_TRUSTSEC_TX_UNCONFIGURE_MSG, +- NSS_TRUSTSEC_TX_STATS_SYNC_MSG, +- NSS_TRUSTSEC_TX_MAX_MSG_TYPE ++ NSS_TRUSTSEC_TX_MSG_CONFIGURE, /** Configure the TrustSec node. */ ++ NSS_TRUSTSEC_TX_MSG_UNCONFIGURE, /** Unconfigure the TrustSec node. */ ++ NSS_TRUSTSEC_TX_MSG_STATS_SYNC, /** Statistics sychronization. */ ++ NSS_TRUSTSEC_TX_MSG_UPDATE_NEXTHOP, /** Update next hop. */ ++ NSS_TRUSTSEC_TX_MSG_MAX /** Maximum message type. */ + }; + + /** +@@ -43,11 +44,14 @@ enum nss_trustsec_tx_msg_types { + * Error types for the TrustSec Tx interface. + */ + enum nss_trustsec_tx_error_types { +- NSS_TRUSTSEC_TX_ERR_INVAL_SRC_IF, +- NSS_TRUSTSEC_TX_ERR_RECONFIGURE_SRC_IF, +- NSS_TRUSTSEC_TX_ERR_DEST_IF_NOT_FOUND, +- NSS_TRUSTSEC_TX_ERR_NOT_CONFIGURED, +- NSS_TRUSTSEC_TX_ERR_UNKNOWN, ++ NSS_TRUSTSEC_TX_ERR_NONE, /** No error */ ++ NSS_TRUSTSEC_TX_ERR_INVAL_SRC_IF, /** Source interface is invalid. */ ++ NSS_TRUSTSEC_TX_ERR_RECONFIGURE_SRC_IF, /** Source interface is already configured. */ ++ NSS_TRUSTSEC_TX_ERR_DEST_IF_NOT_FOUND, /** Destination interface is not found. */ ++ NSS_TRUSTSEC_TX_ERR_NOT_CONFIGURED, /** Source interface is not configured. */ ++ NSS_TRUSTSEC_TX_ERR_SGT_MISMATCH, /** SGT mismatches. */ ++ NSS_TRUSTSEC_TX_ERR_UNKNOWN, /** Error is unknown. */ ++ NSS_TRUSTSEC_TX_ERR_MAX, /** Maximum error message. */ + }; + + /** +@@ -83,6 +87,17 @@ struct nss_trustsec_tx_stats_sync_msg { + }; + + /** ++ * nss_trustsec_tx_update_nexthop_msg ++ * Message information for updating the next hop for a TrustSec Tx interface. ++ */ ++struct nss_trustsec_tx_update_nexthop_msg { ++ uint32_t src; /**< Interface number of the source tunnel. */ ++ uint32_t dest; /**< Outgoing interface number. */ ++ uint16_t sgt; /**< Security Group Tag value to embed in the TrustSec header. */ ++ uint8_t reserved[2]; /**< Reserved for word alignment. */ ++}; ++ ++/** + * nss_trustsec_tx_msg + * Data for sending and receiving TrustSec Tx messages. + */ +@@ -99,6 +114,8 @@ struct nss_trustsec_tx_msg { + /**< De-configure TrustSec Tx. */ + struct nss_trustsec_tx_stats_sync_msg stats_sync; + /**< Synchronize TrustSec Tx statistics. */ ++ struct nss_trustsec_tx_update_nexthop_msg upd_nexthop; ++ /**< Update next hop of TrustSec Tx. */ + } msg; /**< Message payload. */ + }; + +@@ -166,6 +183,19 @@ extern nss_tx_status_t nss_trustsec_tx_m + extern nss_tx_status_t nss_trustsec_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_trustsec_tx_msg *msg); + + /** ++ * nss_trustsec_tx_update_nexthop ++ * Updates the next hop of the TrustSec. ++ * ++ * @param[in] src Source interface number. ++ * @param[in] dest Destination interface number. ++ * @param[in] sgt Security Group Tag value. ++ * ++ * @return ++ * Pointer to the NSS core context. ++ */ ++extern nss_tx_status_t nss_trustsec_tx_update_nexthop(uint32_t src, uint32_t dest, uint16_t sgt); ++ ++/** + * nss_trustsec_tx_get_ctx + * Gets the NSS context. + * +@@ -180,7 +210,7 @@ extern struct nss_ctx_instance *nss_trus + * + * @param[in] src Source interface number. + * @param[in] dest Destination interface number. +- * @param[in] sgt Security Group Tag value ++ * @param[in] sgt Security Group Tag value. + * + * @return + * Pointer to the NSS core context. +--- a/exports/nss_tunipip6.h ++++ b/exports/nss_tunipip6.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014, 2017-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014, 2017-2018, 2020, 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. +@@ -30,16 +30,18 @@ + #define NSS_TUNIPIP6_MAX_FMR_NUMBER 4 /**< Maximum number of forward mapping rule (FMR). */ + + /** +- * nss_tunipip6_fmr +- * Forward mapping rule (FMR) for direct forwarding traffic to the node in the same domain. ++ * nss_tunipip6_map_rule ++ * Mapping rule (FMR/BMR) for forwarding traffic to the node in the same domain. + */ +-struct nss_tunipip6_fmr { ++struct nss_tunipip6_map_rule { + uint32_t ip6_prefix[4]; /**< An IPv6 prefix assigned by a mapping rule. */ + uint32_t ip4_prefix; /**< An IPv4 prefix assigned by a mapping rule. */ + uint32_t ip6_prefix_len; /**< IPv6 prefix length. */ + uint32_t ip4_prefix_len; /**< IPv4 prefix length. */ ++ uint32_t ip6_suffix[4]; /**< IPv6 suffix. */ ++ uint32_t ip6_suffix_len; /**< IPv6 suffix length. */ + uint32_t ea_len; /**< Embedded Address (EA) bits. */ +- uint32_t offset; /**< PSID offset default 6. */ ++ uint32_t psid_offset; /**< PSID offset default 6. */ + }; + + /** +@@ -50,6 +52,11 @@ enum nss_tunipip6_metadata_types { + NSS_TUNIPIP6_TX_ENCAP_IF_CREATE, + NSS_TUNIPIP6_TX_DECAP_IF_CREATE, + NSS_TUNIPIP6_RX_STATS_SYNC, ++ NSS_TUNIPIP6_FMR_RULE_ADD, ++ NSS_TUNIPIP6_FMR_RULE_DEL, ++ NSS_TUNIPIP6_FMR_RULE_FLUSH, ++ NSS_TUNIPIP6_BMR_RULE_ADD, ++ NSS_TUNIPIP6_BMR_RULE_DEL, + NSS_TUNIPIP6_MAX, + }; + +@@ -58,16 +65,16 @@ enum nss_tunipip6_metadata_types { + * Payload for configuring the DS-Lite interface. + */ + struct nss_tunipip6_create_msg { +- struct nss_tunipip6_fmr fmr[NSS_TUNIPIP6_MAX_FMR_NUMBER]; /**< Tunnel FMR array. */ + uint32_t saddr[4]; /**< Tunnel source address. */ + uint32_t daddr[4]; /**< Tunnel destination address. */ + uint32_t flowlabel; /**< Tunnel IPv6 flow label. */ + uint32_t flags; /**< Tunnel additional flags. */ +- uint32_t fmr_number; /**< Tunnel FMR number. */ + uint32_t sibling_if_num; /**< Sibling interface number. */ +- uint16_t reserved1; /**< Reserved for alignment. */ + uint8_t hop_limit; /**< Tunnel IPv6 hop limit. */ + uint8_t draft03; /**< Use MAP-E draft03 specification. */ ++ bool ttl_inherit; /**< Inherit IPv4 TTL to hoplimit. */ ++ bool tos_inherit; /**< Inherit IPv4 ToS. */ ++ bool frag_id_update; /**< Enable update of fragment identifier of IPv4. */ + }; + + /** +@@ -90,10 +97,12 @@ struct nss_tunipip6_msg { + */ + union { + struct nss_tunipip6_create_msg tunipip6_create; +- /**< Create a DS-Lite tunnel. */ ++ /**< Create a DS-Lite/IPIP6 tunnel. */ + struct nss_tunipip6_stats_sync_msg stats_sync; + /**< Synchronized statistics for the DS-Lite interface. */ +- } msg; /**< Message payload for IPIP6 Tunnel messages exchanged with NSS core. */ ++ struct nss_tunipip6_map_rule map_rule; ++ /**< BMR/FMR rule to add/delete, new or existing rules. */ ++ } msg; /**< Message payload for IPIP6 tunnel messages exchanged with NSS core. */ + }; + + /** +@@ -124,6 +133,22 @@ typedef void (*nss_tunipip6_msg_callback + extern nss_tx_status_t nss_tunipip6_tx(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *msg); + + /** ++ * nss_tunipip6_tx_sync ++ * Sends a DS-Lite message to NSS core synchronously. ++ * ++ * @datatypes ++ * nss_ctx_instance \n ++ * nss_tunipip6_msg ++ * ++ * @param[in] nss_ctx Pointer to the NSS context. ++ * @param[in] msg Pointer to the message data. ++ * ++ * @return ++ * Status of the Tx operation. ++ */ ++extern nss_tx_status_t nss_tunipip6_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *msg); ++ ++/** + * Callback function for receiving DS-Lite data. + * + * @datatypes +--- a/exports/nss_wifi.h ++++ b/exports/nss_wifi.h +@@ -90,6 +90,8 @@ enum nss_wifi_metadata_types { + NSS_WIFI_CMD_MSG, + NSS_WIFI_ENABLE_OL_STATSV2_MSG, + NSS_WIFI_OL_PEER_TIME_MSG, ++ NSS_WIFI_PEER_SET_VLAN_ID_MSG, ++ NSS_WIFI_PEER_ISOLATION_MSG, + NSS_WIFI_MAX_MSG + }; + +@@ -739,7 +741,16 @@ struct nss_wifi_ol_stats_msg { + * Station kickout message from NSS Firmware + */ + struct nss_wifi_sta_kickout_msg { +- uint32_t peer_id; /**< ID of the peer. */ ++ uint32_t peer_id; /**< Peer ID. */ ++}; ++ ++/** ++ * nss_wifi_peer_isolation_msg ++ * Peer isolation message ++ */ ++struct nss_wifi_peer_isolation_msg { ++ uint16_t peer_id; /**< Peer ID. */ ++ uint16_t isolation; /**< Isolation enabled/disabled. */ + }; + + /** +@@ -905,6 +916,8 @@ struct nss_wifi_msg { + /**< Enable version 2 tx/rx stats. */ + struct nss_wifi_ol_peer_time_msg wopt_msg; + /**< Send per peer/TID timestamp statistics to host. */ ++ struct nss_wifi_peer_isolation_msg isolation_msg; ++ /**< Enable or disable peer isolation. */ + } msg; /**< Message Payload. */ + }; + +--- a/exports/nss_wifi_vdev.h ++++ b/exports/nss_wifi_vdev.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2015-2020, 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. +@@ -762,6 +762,9 @@ struct nss_wifi_vdev_per_packet_metadata + */ + struct nss_wifi_vdev_meshmode_rx_metadata { + uint16_t rs_ratephy; /**< PHY rate. */ ++ uint16_t rs_ratephy_lo; /**< PHY rate lower bytes. */ ++ uint16_t rs_ratephy_hi; /**< PHY rate higher bytes. */ ++ uint16_t cntr_chan_freq; /** Center channel frequency. */ + uint16_t vdev_id; /**< Virtual device ID. */ + uint16_t peer_id; /**< Peer ID. */ + uint16_t rs_rssi; /**< Received signal strength indication (noise floor adjusted). */ +--- a/exports/nss_wifili_if.h ++++ b/exports/nss_wifili_if.h +@@ -92,6 +92,8 @@ + /**< Maximum number of physical devices on the external SoC. */ + #define NSS_WIFILI_PEER_AST_FLOWQ_MAX 4 + /**< Maximum number of flow queues. */ ++#define NSS_WIFILI_WBM_INTERNAL_ERR_MAX 5 ++ /**< WBM internal maximum errors. */ + + /* + * Radio specific flags +@@ -179,6 +181,9 @@ enum nss_wifili_msg_types { + NSS_WIFILI_PEER_AST_FLOWID_MAP_MSG, + NSS_WIFILI_PEER_MEC_AGEOUT_MSG, + NSS_WIFILI_JITTER_STATS_MSG, ++ NSS_WIFILI_ISOLATION_MSG, ++ NSS_WIFILI_PEER_EXT_STATS_MSG, ++ NSS_WIFILI_CLR_STATS, + NSS_WIFILI_MAX_MSG + }; + +@@ -558,6 +563,7 @@ enum nss_wifili_stats_rxdma_ring { + * Wifili WBM(Wireless Buffer Manager) ring statistics. + */ + enum nss_wifili_stats_wbm { ++ NSS_WIFILI_STATS_WBM_IE_LOCAL_ALLOC_FAIL, /**< Number of Wireless Buffer Manger internal local allocation failures. */ + NSS_WIFILI_STATS_WBM_SRC_DMA, /**< Number of Rx invalid source DMA. */ + NSS_WIFILI_STATS_WBM_SRC_DMA_CODE_INV, /**< Number of Rx invalid source DMA. */ + NSS_WIFILI_STATS_WBM_SRC_REO, /**< Number of Rx invalid source reorder. */ +@@ -762,7 +768,7 @@ struct nss_wifili_pdev_init_msg { + uint32_t hwmode; + /**< MAC hardware mode. */ + uint32_t lmac_id; +- /**< lower MAC ID. */ ++ /**< Lower MAC ID. */ + uint32_t num_rx_swdesc; + /**< Number of descriptors per Rx pool. */ + uint32_t target_pdev_id; +@@ -807,14 +813,16 @@ struct nss_wifili_peer_msg { + /**< Hardware address search table index. */ + uint8_t is_nawds; + /**< NAWDS enabled for peer. */ +- uint8_t reserved; +- /**< Padding for alignment. */ ++ uint8_t pext_stats_valid; ++ /**< Peer extended statistics valid. */ + uint16_t psta_vdev_id; + /**< Proxy station VAP ID. */ + uint32_t nss_peer_mem; + /**< Holds peer memory adderss for NSS. */ + uint32_t tx_ast_hash; + /**< AST hash to be used during packet transmission. */ ++ uint32_t pext_stats_mem; ++ /**< Peer extended statistics memory. */ + }; + + /** +@@ -980,6 +988,8 @@ struct nss_wifili_rx_wbm_ring_stats { + /**< Rx reoder error codes. */ + uint32_t err_dma_codes[NSS_WIFILI_DMA_CODE_MAX]; + /**< DMA error codes. */ ++ uint32_t err_internal_codes[NSS_WIFILI_WBM_INTERNAL_ERR_MAX]; ++ /**< Wireless Buffer Manger error codes. */ + }; + + /** +@@ -1119,9 +1129,9 @@ struct nss_wifili_v3_tx_rx_per_ac_stats + */ + struct nss_wifili_radio_tx_rx_stats_v3 { + struct nss_wifili_v3_tx_rx_per_tid_stats tid_stats[NSS_WIFILI_MAX_TID]; +- /**< Per TID Tx and Rx statistics. */ ++ /**< Per-TID Tx and Rx statistics. */ + struct nss_wifili_v3_tx_rx_per_ac_stats ac_stats[NSS_WIFILI_WME_AC_MAX]; +- /**< Per Access Category Tx and Rx statistics. */ ++ /**< Per-Access Category Tx and Rx statistics. */ + }; + + /** +@@ -1130,7 +1140,7 @@ struct nss_wifili_radio_tx_rx_stats_v3 { + */ + struct nss_wifili_radio_delay_stats_v3 { + struct nss_wifili_v3_delay_per_tid_stats v3_delay_stats[NSS_WIFILI_MAX_TID]; +- /**< Per TID delay statistics. */ ++ /**< Per-TID delay statistics. */ + }; + + /** +@@ -1320,8 +1330,8 @@ struct nss_wifili_peer_stats_msg { + * Wifili sojourn per TID statistics. + */ + struct nss_wifili_sojourn_per_tid_stats { +- uint32_t avg_sojourn_msdu; /**< Average per TID of all time difference. */ +- uint32_t sum_sojourn_msdu; /**< Sum per TID of all time difference. */ ++ uint32_t avg_sojourn_msdu; /**< Average per-TID of all time difference. */ ++ uint32_t sum_sojourn_msdu; /**< Sum per-TID of all time difference. */ + uint32_t num_msdus; /**< MSDUs per TID. */ + }; + +@@ -1373,7 +1383,6 @@ struct nss_wifili_jitter_stats_msg { + struct nss_wifili_jitter_stats jitter_stats[1]; /**< Jitter statistics. */ + }; + +- + /** + * nss_wifili_wds_peer_msg + * Wi-Fi Wireless distribution system (WDS) peer-specific message. +@@ -1387,6 +1396,34 @@ struct nss_wifili_wds_peer_msg { + }; + + /** ++ * nss_wifili_peer_delay_stats ++ * Per-peer delay statistics. ++ */ ++struct nss_wifili_peer_delay_stats { ++ struct nss_wifili_delay_stats swq_delay; /**< Software enqueue delay. */ ++ struct nss_wifili_delay_stats hwtx_delay; /**< Hardware transmit delay. */ ++}; ++ ++/** ++ * nss_wifili_peer_ext_stats ++ * Peer extended statistics. ++ */ ++struct nss_wifili_peer_ext_stats { ++ uint32_t peer_id; /**< Peer ID. */ ++ struct nss_wifili_peer_delay_stats delay_stats[NSS_WIFILI_MAX_TID]; ++ /**< Delay statistics. */ ++}; ++ ++/** ++ * nss_wifili_peer_ext_stats_msg ++ * Peer extended statistics message. ++ */ ++struct nss_wifili_peer_ext_stats_msg { ++ uint32_t npeers; /**< Number of peers. */ ++ struct nss_wifili_peer_ext_stats ext_stats[1]; /**< Extended statistics. */ ++}; ++ ++/** + * nss_wifili_stats_cfg_msg + * Wifili stats enable/disable configuration message. + */ +@@ -1484,6 +1521,15 @@ struct nss_wifili_peer_vlan_id_msg { + }; + + /** ++ * nss_wifili_peer_isolation_msg ++ * Wifili peer isolation message. ++ */ ++struct nss_wifili_peer_isolation_msg { ++ uint16_t peer_id; /**< Peer ID. */ ++ uint16_t isolation; /**< Isolation enabled/disabled. */ ++}; ++ ++/** + * nss_wifili_dbdc_repeater_set_msg + * Wifili DBDC repeater set message. + */ +@@ -1528,6 +1574,14 @@ struct nss_wifili_enable_v3_stats_msg { + }; + + /** ++ * nss_wifili_clr_stats_msg ++ * NSS firmware statistics clear message. ++ */ ++struct nss_wifili_clr_stats_msg { ++ uint8_t vdev_id;; /**< VAP ID. */ ++}; ++ ++/** + * nss_wifili_update_pdev_lmac_id_msg + * Physical device ID and lower MAC ID update message. + */ +@@ -1652,6 +1706,13 @@ struct nss_wifili_msg { + /**< Multicast echo check active information specific message. */ + struct nss_wifili_jitter_stats_msg jt_stats_msg; + /**type >= NSS_BRIDGE_MSG_TYPE_MAX) { +- nss_warning("%p: received invalid message %d for bridge interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for bridge interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_bridge_msg)) { +- nss_warning("%p: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -150,12 +150,12 @@ nss_tx_status_t nss_bridge_tx_msg(struct + * Sanity check the message + */ + if (!nss_is_dynamic_interface(ncm->interface)) { +- nss_warning("%p: tx request for interface that is not a bridge: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for interface that is not a bridge: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_BRIDGE_MSG_TYPE_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -186,7 +186,7 @@ nss_tx_status_t nss_bridge_tx_msg_sync(s + + status = nss_bridge_tx_msg(nss_ctx, nbm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: bridge_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: bridge_tx_msg failed\n", nss_ctx); + up(&bridge_pvt.sem); + return status; + } +@@ -194,7 +194,7 @@ nss_tx_status_t nss_bridge_tx_msg_sync(s + ret = wait_for_completion_timeout(&bridge_pvt.complete, msecs_to_jiffies(NSS_BRIDGE_TX_TIMEOUT)); + + if (!ret) { +- nss_warning("%p: bridge msg tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: bridge msg tx failed due to timeout\n", nss_ctx); + bridge_pvt.response = NSS_TX_FAILURE; + } + +@@ -229,7 +229,7 @@ nss_tx_status_t nss_bridge_tx_vsi_assign + } + + if (nss_bridge_verify_if_num(if_num) == false) { +- nss_warning("%p: invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: invalid interface %d", nss_ctx, if_num); + return NSS_TX_FAILURE; + } + +@@ -257,7 +257,7 @@ nss_tx_status_t nss_bridge_tx_vsi_unassi + } + + if (nss_bridge_verify_if_num(if_num) == false) { +- nss_warning("%p: invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: invalid interface %d", nss_ctx, if_num); + return NSS_TX_FAILURE; + } + +@@ -286,7 +286,7 @@ nss_tx_status_t nss_bridge_tx_set_mtu_ms + } + + if (nss_bridge_verify_if_num(bridge_if_num) == false) { +- nss_warning("%p: received invalid interface %d", nss_ctx, bridge_if_num); ++ nss_warning("%px: received invalid interface %d", nss_ctx, bridge_if_num); + return NSS_TX_FAILURE; + } + +@@ -316,7 +316,7 @@ nss_tx_status_t nss_bridge_tx_set_mac_ad + } + + if (nss_bridge_verify_if_num(bridge_if_num) == false) { +- nss_warning("%p: received invalid interface %d", nss_ctx, bridge_if_num); ++ nss_warning("%px: received invalid interface %d", nss_ctx, bridge_if_num); + return NSS_TX_FAILURE; + } + +@@ -345,13 +345,13 @@ nss_tx_status_t nss_bridge_tx_join_msg(u + } + + if (nss_bridge_verify_if_num(bridge_if_num) == false) { +- nss_warning("%p: received invalid interface %d\n", nss_ctx, bridge_if_num); ++ nss_warning("%px: received invalid interface %d\n", nss_ctx, bridge_if_num); + return NSS_TX_FAILURE; + } + + slave_if_num = nss_cmn_get_interface_number_by_dev(netdev); + if (slave_if_num < 0) { +- nss_warning("%p: invalid slave device %p\n", nss_ctx, netdev); ++ nss_warning("%px: invalid slave device %px\n", nss_ctx, netdev); + return NSS_TX_FAILURE; + } + +@@ -379,13 +379,13 @@ nss_tx_status_t nss_bridge_tx_leave_msg( + } + + if (nss_bridge_verify_if_num(bridge_if_num) == false) { +- nss_warning("%p: received invalid interface %d\n", nss_ctx, bridge_if_num); ++ nss_warning("%px: received invalid interface %d\n", nss_ctx, bridge_if_num); + return NSS_TX_FAILURE; + } + + slave_if_num = nss_cmn_get_interface_number_by_dev(netdev); + if (slave_if_num < 0) { +- nss_warning("%p: invalid slave device %p\n", nss_ctx, netdev); ++ nss_warning("%px: invalid slave device %px\n", nss_ctx, netdev); + return NSS_TX_FAILURE; + } + +@@ -412,12 +412,12 @@ nss_tx_status_t nss_bridge_tx_set_fdb_le + } + + if (nss_bridge_verify_if_num(bridge_if_num) == false) { +- nss_warning("%p: received invalid interface %d\n", nss_ctx, bridge_if_num); ++ nss_warning("%px: received invalid interface %d\n", nss_ctx, bridge_if_num); + return NSS_TX_FAILURE; + } + + if (fdb_learn >= NSS_BRIDGE_FDB_LEARN_MODE_MAX) { +- nss_warning("%p: received invalid fdb learn mode %d\n", nss_ctx, fdb_learn); ++ nss_warning("%px: received invalid fdb learn mode %d\n", nss_ctx, fdb_learn); + return NSS_TX_FAILURE; + } + +--- a/nss_bridge_log.c ++++ b/nss_bridge_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -38,7 +38,7 @@ static int8_t *nss_bridge_log_message_ty + static void nss_bridge_join_msg(struct nss_bridge_msg *nbm) + { + struct nss_bridge_join_msg *nbjm __maybe_unused = &nbm->msg.br_join; +- nss_trace("%p: NSS Bridge Join message \n" ++ nss_trace("%px: NSS Bridge Join message \n" + "Interface Number: %d\n", + nbm, nbjm->if_num); + } +@@ -50,7 +50,7 @@ static void nss_bridge_join_msg(struct n + static void nss_bridge_leave_msg(struct nss_bridge_msg *nbm) + { + struct nss_bridge_leave_msg *nblm __maybe_unused = &nbm->msg.br_leave; +- nss_trace("%p: NSS Bridge Leave message: \n" ++ nss_trace("%px: NSS Bridge Leave message: \n" + "Interface Number: %d\n", + nbm, nblm->if_num); + } +@@ -63,7 +63,7 @@ static void nss_bridge_fdb_learn_msg(str + { + struct nss_bridge_set_fdb_learn_msg *nbflm __maybe_unused = + &nbm->msg.fdb_learn; +- nss_trace("%p: NSS Bridge Set FDB Learn message: \n" ++ nss_trace("%px: NSS Bridge Set FDB Learn message: \n" + "Mode: %d\n", + nbm, nbflm->mode); + } +@@ -88,7 +88,7 @@ static void nss_bridge_log_verbose(struc + break; + + default: +- nss_trace("%p: Invalid message type\n", nbm); ++ nss_trace("%px: Invalid message type\n", nbm); + break; + } + } +@@ -100,11 +100,11 @@ static void nss_bridge_log_verbose(struc + void nss_bridge_log_tx_msg(struct nss_bridge_msg *nbm) + { + if (nbm->cm.type >= NSS_BRIDGE_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", nbm); ++ nss_warning("%px: Invalid message type\n", nbm); + return; + } + +- nss_info("%p: type[%d]:%s\n", nbm, nbm->cm.type, nss_bridge_log_message_types_str[nbm->cm.type - NSS_IF_MAX_MSG_TYPES - 1]); ++ nss_info("%px: type[%d]:%s\n", nbm, nbm->cm.type, nss_bridge_log_message_types_str[nbm->cm.type - NSS_IF_MAX_MSG_TYPES - 1]); + nss_bridge_log_verbose(nbm); + } + +@@ -115,18 +115,18 @@ void nss_bridge_log_tx_msg(struct nss_br + void nss_bridge_log_rx_msg(struct nss_bridge_msg *nbm) + { + if (nbm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nbm); ++ nss_warning("%px: Invalid response\n", nbm); + return; + } + + if (nbm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nbm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nbm, nbm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nbm, nbm->cm.type, + nss_bridge_log_message_types_str[nbm->cm.type - NSS_IF_MAX_MSG_TYPES - 1], + nbm->cm.response, nss_cmn_response_str[nbm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + nbm, nbm->cm.type, nss_bridge_log_message_types_str[nbm->cm.type - NSS_IF_MAX_MSG_TYPES - 1], + nbm->cm.response, nss_cmn_response_str[nbm->cm.response]); + +--- a/nss_c2c_rx.c ++++ b/nss_c2c_rx.c +@@ -43,7 +43,7 @@ static void nss_c2c_rx_interface_handler + nss_c2c_rx_msg_callback_t cb; + + if (!nss_c2c_rx_verify_if_num(ncm->interface)) { +- nss_warning("%p: invalid interface %d for c2c_tx\n", nss_ctx, ncm->interface); ++ nss_warning("%px: invalid interface %d for c2c_tx\n", nss_ctx, ncm->interface); + return; + } + +@@ -51,12 +51,12 @@ static void nss_c2c_rx_interface_handler + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_C2C_RX_MSG_TYPE_MAX) { +- nss_warning("%p: received invalid message %d for c2c_rx", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for c2c_rx", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_c2c_rx_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +--- a/nss_c2c_tx.c ++++ b/nss_c2c_tx.c +@@ -68,7 +68,7 @@ static void nss_c2c_tx_msg_handler(struc + nss_c2c_tx_msg_callback_t cb; + + if (!nss_c2c_tx_verify_if_num(ncm->interface)) { +- nss_warning("%p: invalid interface %d for c2c_tx\n", nss_ctx, ncm->interface); ++ nss_warning("%px: invalid interface %d for c2c_tx\n", nss_ctx, ncm->interface); + return; + } + +@@ -76,12 +76,12 @@ static void nss_c2c_tx_msg_handler(struc + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_C2C_TX_MSG_TYPE_MAX) { +- nss_warning("%p: received invalid message %d for c2c_tx", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for c2c_tx", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_c2c_tx_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -137,7 +137,7 @@ static void nss_c2c_tx_msg_handler(struc + */ + void nss_c2c_tx_register_handler(struct nss_ctx_instance *nss_ctx) + { +- nss_info("%p: nss_c2c_tx_register_handler", nss_ctx); ++ nss_info("%px: nss_c2c_tx_register_handler", nss_ctx); + nss_core_register_handler(nss_ctx, NSS_C2C_TX_INTERFACE, nss_c2c_tx_msg_handler, NULL); + + if (nss_ctx->id == NSS_CORE_0) { +@@ -159,12 +159,12 @@ nss_tx_status_t nss_c2c_tx_tx_msg(struct + * Sanity check the message + */ + if (!nss_c2c_tx_verify_if_num(ncm->interface)) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_C2C_TX_MSG_TYPE_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -185,11 +185,11 @@ static void nss_c2c_tx_msg_cfg_map_callb + { + struct nss_ctx_instance *nss_ctx __attribute__((unused)) = (struct nss_ctx_instance *)app_data; + if (nctm->cm.response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p: nss c2c_tx_map configuration failed: %d for NSS core %d\n", ++ nss_warning("%px: nss c2c_tx_map configuration failed: %d for NSS core %d\n", + nss_ctx, nctm->cm.error, nss_ctx->id); + } + +- nss_info("%p: nss c2c_tx_map configuration succeeded for NSS core %d\n", ++ nss_info("%px: nss c2c_tx_map configuration succeeded for NSS core %d\n", + nss_ctx, nss_ctx->id); + } + +@@ -205,13 +205,13 @@ static void nss_c2c_tx_msg_performance_t + * Test start has been failed. Restore the value to initial state. + */ + if (nctm->cm.response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p: nss c2c_tx test start failed: %d for NSS core %d\n", ++ nss_warning("%px: nss c2c_tx test start failed: %d for NSS core %d\n", + nss_ctx, nctm->cm.error, nss_ctx->id); + nss_c2c_tx_test_id = -1; + return; + } + +- nss_info("%p: nss c2c_tx test successfully initialized for NSS core %d\n", ++ nss_info("%px: nss c2c_tx test successfully initialized for NSS core %d\n", + nss_ctx, nss_ctx->id); + } + +@@ -225,7 +225,7 @@ nss_tx_status_t nss_c2c_tx_msg_cfg_map(s + struct nss_c2c_tx_msg nctm; + struct nss_c2c_tx_map *cfg_map; + +- nss_info("%p: C2C map:%x\n", nss_ctx, tx_map); ++ nss_info("%px: C2C map:%x\n", nss_ctx, tx_map); + nss_c2c_tx_msg_init(&nctm, NSS_C2C_TX_INTERFACE, NSS_C2C_TX_MSG_TYPE_TX_MAP, + sizeof(struct nss_c2c_tx_map), nss_c2c_tx_msg_cfg_map_callback, (void *)nss_ctx); + +@@ -251,7 +251,7 @@ nss_tx_status_t nss_c2c_tx_msg_performan + struct nss_c2c_tx_msg nctm; + struct nss_c2c_tx_test *test; + +- nss_info("%p: C2C test message:%x\n", nss_ctx, test_id); ++ nss_info("%px: C2C test message:%x\n", nss_ctx, test_id); + nss_c2c_tx_msg_init(&nctm, NSS_C2C_TX_INTERFACE, NSS_C2C_TX_MSG_TYPE_PERFORMANCE_TEST, + sizeof(struct nss_c2c_tx_test), nss_c2c_tx_msg_performance_test_callback, (void *)nss_ctx); + +@@ -299,12 +299,12 @@ static int nss_c2c_tx_performance_test_h + } + + if (current_state != -1) { +- nss_warning("%p: Another test is running.\n", nss_ctx); ++ nss_warning("%px: Another test is running.\n", nss_ctx); + return -EINVAL; + } + + if (nss_c2c_tx_test_id >= NSS_C2C_TX_TEST_TYPE_MAX || nss_c2c_tx_test_id <= 0) { +- nss_warning("%p: Invalid test ID.\n", nss_ctx); ++ nss_warning("%px: Invalid test ID.\n", nss_ctx); + nss_c2c_tx_test_id = current_state; + return -EINVAL; + } +@@ -313,7 +313,7 @@ static int nss_c2c_tx_performance_test_h + ret_c2c_tx = nss_c2c_tx_msg_performance_test(nss_ctx, nss_c2c_tx_test_id); + + if (ret_c2c_tx != NSS_SUCCESS) { +- nss_warning("%p: Starting the test has failed.\n", nss_ctx); ++ nss_warning("%px: Starting the test has failed.\n", nss_ctx); + nss_c2c_tx_test_id = -1; + } + +--- a/nss_c2c_tx_log.c ++++ b/nss_c2c_tx_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -46,7 +46,7 @@ static int8_t *nss_c2c_tx_log_error_resp + static void nss_c2c_tx_map_msg(struct nss_c2c_tx_msg *nctm) + { + struct nss_c2c_tx_map *nctmm __maybe_unused = &nctm->msg.map; +- nss_trace("%p: NSS C2C TX Map message: \n" ++ nss_trace("%px: NSS C2C TX Map message: \n" + "C2C Receiver Queue Start Address: %d\n" + "C2C Interrupt Register Address: %d\n", + nctm, +@@ -65,7 +65,7 @@ static void nss_c2c_tx_log_verbose(struc + break; + + default: +- nss_trace("%p: Invalid message type\n", nctm); ++ nss_trace("%px: Invalid message type\n", nctm); + break; + } + } +@@ -77,11 +77,11 @@ static void nss_c2c_tx_log_verbose(struc + void nss_c2c_tx_log_tx_msg(struct nss_c2c_tx_msg *nctm) + { + if (nctm->cm.type >= NSS_C2C_TX_MSG_TYPE_MAX) { +- nss_info("%p: Invalid message type\n", nctm); ++ nss_info("%px: Invalid message type\n", nctm); + return; + } + +- nss_info("%p: type[%d]:%s\n", nctm, nctm->cm.type, nss_c2c_tx_log_message_types_str[nctm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nctm, nctm->cm.type, nss_c2c_tx_log_message_types_str[nctm->cm.type]); + nss_c2c_tx_log_verbose(nctm); + } + +@@ -92,26 +92,26 @@ void nss_c2c_tx_log_tx_msg(struct nss_c2 + void nss_c2c_tx_log_rx_msg(struct nss_c2c_tx_msg *nctm) + { + if (nctm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nctm); ++ nss_warning("%px: Invalid response\n", nctm); + return; + } + + if (nctm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nctm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nctm, nctm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nctm, nctm->cm.type, + nss_c2c_tx_log_message_types_str[nctm->cm.type], + nctm->cm.response, nss_cmn_response_str[nctm->cm.response]); + goto verbose; + } + + if (nctm->cm.error >= NSS_C2C_TX_MSG_ERROR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + nctm, nctm->cm.type, nss_c2c_tx_log_message_types_str[nctm->cm.type], + nctm->cm.response, nss_cmn_response_str[nctm->cm.response], + nctm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + nctm, nctm->cm.type, nss_c2c_tx_log_message_types_str[nctm->cm.type], + nctm->cm.response, nss_cmn_response_str[nctm->cm.response], + nctm->cm.error, nss_c2c_tx_log_error_response_types_str[nctm->cm.error]); +--- a/nss_capwap.c ++++ b/nss_capwap.c +@@ -192,12 +192,12 @@ static void nss_capwap_msg_handler(struc + * Is this a valid request/response packet? + */ + if (ncm->type > NSS_CAPWAP_MSG_TYPE_MAX) { +- nss_warning("%p: received invalid message %d for CAPWAP interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for CAPWAP interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_capwap_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -234,7 +234,7 @@ static void nss_capwap_msg_handler(struc + * Do we have a callback + */ + if (!ncm->cb) { +- nss_trace("%p: cb is null for interface %d", nss_ctx, ncm->interface); ++ nss_trace("%px: cb is null for interface %d", nss_ctx, ncm->interface); + return; + } + +@@ -255,7 +255,7 @@ static bool nss_capwap_instance_alloc(st + */ + h = kmalloc(sizeof(struct nss_capwap_handle), GFP_ATOMIC); + if (h == NULL) { +- nss_warning("%p: no memory for allocating CAPWAP instance for interface : %d", nss_ctx, if_num); ++ nss_warning("%px: no memory for allocating CAPWAP instance for interface : %d", nss_ctx, if_num); + return false; + } + +@@ -266,7 +266,7 @@ static bool nss_capwap_instance_alloc(st + if (nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START] != NULL) { + spin_unlock(&nss_capwap_spinlock); + kfree(h); +- nss_warning("%p: Another thread is already allocated instance for :%d", nss_ctx, if_num); ++ nss_warning("%px: Another thread is already allocated instance for :%d", nss_ctx, if_num); + return false; + } + +@@ -302,7 +302,7 @@ nss_tx_status_t nss_capwap_tx_msg(struct + spin_lock(&nss_capwap_spinlock); + if (!nss_capwap_hdl[if_num]) { + spin_unlock(&nss_capwap_spinlock); +- nss_warning("%p: capwap tunnel if_num is not there: %d", nss_ctx, msg->cm.interface); ++ nss_warning("%px: capwap tunnel if_num is not there: %d", nss_ctx, msg->cm.interface); + return NSS_TX_FAILURE_BAD_PARAM; + } + nss_capwap_refcnt_inc(msg->cm.interface); +@@ -372,14 +372,14 @@ struct nss_ctx_instance *nss_capwap_noti + nss_ctx = &nss_top_main.nss[nss_top_main.capwap_handler_id]; + + if (nss_capwap_verify_if_num(if_num) == false) { +- nss_warning("%p: notfiy register received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: notfiy register received for invalid interface %d", nss_ctx, if_num); + return NULL; + } + + spin_lock(&nss_capwap_spinlock); + if (nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START] != NULL) { + spin_unlock(&nss_capwap_spinlock); +- nss_warning("%p: notfiy register tunnel already exists for interface %d", nss_ctx, if_num); ++ nss_warning("%px: notfiy register tunnel already exists for interface %d", nss_ctx, if_num); + return NULL; + } + spin_unlock(&nss_capwap_spinlock); +@@ -399,13 +399,13 @@ nss_tx_status_t nss_capwap_notify_unregi + int index; + + if (nss_capwap_verify_if_num(if_num) == false) { +- nss_warning("%p: notify unregister received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: notify unregister received for invalid interface %d", nss_ctx, if_num); + return NSS_TX_FAILURE_BAD_PARAM; + } + + nss_top = nss_ctx->nss_top; + if (nss_top == NULL) { +- nss_warning("%p: notify unregister received for invalid nss_top %d", nss_ctx, if_num); ++ nss_warning("%px: notify unregister received for invalid nss_top %d", nss_ctx, if_num); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -413,7 +413,7 @@ nss_tx_status_t nss_capwap_notify_unregi + spin_lock(&nss_capwap_spinlock); + if (nss_capwap_hdl[index] == NULL) { + spin_unlock(&nss_capwap_spinlock); +- nss_warning("%p: notify unregister received for unallocated if_num: %d", nss_ctx, if_num); ++ nss_warning("%px: notify unregister received for unallocated if_num: %d", nss_ctx, if_num); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -423,7 +423,7 @@ nss_tx_status_t nss_capwap_notify_unregi + */ + if (nss_capwap_refcnt(if_num) != 0) { + spin_unlock(&nss_capwap_spinlock); +- nss_warning("%p: notify unregister tunnel %d: has reference", nss_ctx, if_num); ++ nss_warning("%px: notify unregister tunnel %d: has reference", nss_ctx, if_num); + return NSS_TX_FAILURE_QUEUE; + } + +@@ -445,7 +445,7 @@ struct nss_ctx_instance *nss_capwap_data + + nss_ctx = nss_capwap_get_ctx(); + if (nss_capwap_verify_if_num(if_num) == false) { +- nss_warning("%p: data register received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: data register received for invalid interface %d", nss_ctx, if_num); + return NULL; + } + +@@ -458,12 +458,12 @@ struct nss_ctx_instance *nss_capwap_data + + core_status = nss_core_register_handler(nss_ctx, if_num, nss_capwap_msg_handler, NULL); + if (core_status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: nss core register handler failed for if_num:%d with error :%d", nss_ctx, if_num, core_status); ++ nss_warning("%px: nss core register handler failed for if_num:%d with error :%d", nss_ctx, if_num, core_status); + return NULL; + } + + if (nss_capwap_instance_alloc(nss_ctx, if_num) == false) { +- nss_warning("%p: couldn't allocate tunnel instance for if_num:%d", nss_ctx, if_num); ++ nss_warning("%px: couldn't allocate tunnel instance for if_num:%d", nss_ctx, if_num); + return NULL; + } + +@@ -484,7 +484,7 @@ bool nss_capwap_data_unregister(uint32_t + + nss_ctx = nss_capwap_get_ctx(); + if (nss_capwap_verify_if_num(if_num) == false) { +- nss_warning("%p: data unregister received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: data unregister received for invalid interface %d", nss_ctx, if_num); + return false; + } + +@@ -494,7 +494,7 @@ bool nss_capwap_data_unregister(uint32_t + */ + if (nss_capwap_refcnt(if_num) != 0) { + spin_unlock(&nss_capwap_spinlock); +- nss_warning("%p: notify unregister tunnel %d: has reference", nss_ctx, if_num); ++ nss_warning("%px: notify unregister tunnel %d: has reference", nss_ctx, if_num); + return false; + } + h = nss_capwap_hdl[if_num - NSS_DYNAMIC_IF_START]; +@@ -533,7 +533,7 @@ int nss_capwap_ifnum_with_core_id(int if + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + if (nss_is_dynamic_interface(if_num) == false) { +- nss_info("%p: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); ++ nss_info("%px: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); + return 0; + } + return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); +--- a/nss_capwap_log.c ++++ b/nss_capwap_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -69,10 +69,10 @@ static int8_t *nss_capwap_log_error_resp + static void nss_capwap_rule_msg(struct nss_capwap_msg *ncm) + { + struct nss_capwap_rule_msg *ncrm __maybe_unused = &ncm->msg.rule; +- nss_trace("%p: NSS CAPWAP Rule message \n" +- "Encap Rule Src IP: %p\n" ++ nss_trace("%px: NSS CAPWAP Rule message \n" ++ "Encap Rule Src IP: %px\n" + "Encap Rule Src Port: %d\n" +- "Encap Rule Dst Ip: %p\n" ++ "Encap Rule Dst Ip: %px\n" + "Encap Rule Dst Port: %d\n" + "Encap Rule Path MTU: %d\n" + "Decap Rule Reassembly Timeout: %d\n" +@@ -87,7 +87,7 @@ static void nss_capwap_rule_msg(struct n + "GMAC Interface Number: %d\n" + "Enabled Features: %x\n" + "DTLS Interface Number: %d\n" +- "BSSID: %p\n" ++ "BSSID: %px\n" + "Outer Segment Value: %x\n", + ncrm, + &ncrm->encap.src_ip.ip, +@@ -114,7 +114,7 @@ static void nss_capwap_rule_msg(struct n + static void nss_capwap_path_mtu_msg(struct nss_capwap_msg *ncm) + { + struct nss_capwap_path_mtu_msg *ncpmm __maybe_unused = &ncm->msg.mtu; +- nss_trace("%p: NSS CAPWAP Path MTU message \n" ++ nss_trace("%px: NSS CAPWAP Path MTU message \n" + "CAPWAP Path MTU: %d\n", + ncpmm, + ncpmm->path_mtu); +@@ -127,7 +127,7 @@ static void nss_capwap_path_mtu_msg(stru + static void nss_capwap_version_msg(struct nss_capwap_msg *ncm) + { + struct nss_capwap_version_msg *ncvm __maybe_unused = &ncm->msg.version; +- nss_trace("%p: NSS CAPWAP Version message \n" ++ nss_trace("%px: NSS CAPWAP Version message \n" + "CAPWAP Version: %d\n", + ncvm, + ncvm->version); +@@ -140,7 +140,7 @@ static void nss_capwap_version_msg(struc + static void nss_capwap_dtls_msg(struct nss_capwap_msg *ncm) + { + struct nss_capwap_dtls_msg *ncdm __maybe_unused = &ncm->msg.dtls; +- nss_trace("%p: NSS CAPWAP dtls message \n" ++ nss_trace("%px: NSS CAPWAP dtls message \n" + "CAPWAP DTLS Enable: %d\n" + "CAPWAP DTLS Inner Interface Number: %d\n" + "CAPWAP MTU Adjust: %d\n" +@@ -156,7 +156,7 @@ static void nss_capwap_dtls_msg(struct n + */ + static void nss_capwap_flow_rule_msg(struct nss_capwap_flow_rule_msg *ncfrm) + { +- nss_trace("%p: NSS CAPWAP Flow Rule message \n" ++ nss_trace("%px: NSS CAPWAP Flow Rule message \n" + "CAPWAP IP Version: %d\n" + "CAPWAP Layer 4 Protocol: %d\n" + "CAPWAP Source Port: %d\n" +@@ -226,7 +226,7 @@ static void nss_capwap_log_verbose(struc + break; + + default: +- nss_trace("%p: Invalid message type\n", ncm); ++ nss_trace("%px: Invalid message type\n", ncm); + break; + } + } +@@ -238,11 +238,11 @@ static void nss_capwap_log_verbose(struc + void nss_capwap_log_tx_msg(struct nss_capwap_msg *ncm) + { + if (ncm->cm.type >= NSS_CAPWAP_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", ncm); ++ nss_warning("%px: Invalid message type\n", ncm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ncm, ncm->cm.type, nss_capwap_log_message_types_str[ncm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ncm, ncm->cm.type, nss_capwap_log_message_types_str[ncm->cm.type]); + nss_capwap_log_verbose(ncm); + } + +@@ -253,26 +253,26 @@ void nss_capwap_log_tx_msg(struct nss_ca + void nss_capwap_log_rx_msg(struct nss_capwap_msg *ncm) + { + if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ncm); ++ nss_warning("%px: Invalid response\n", ncm); + return; + } + + if (ncm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ncm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, + nss_capwap_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response]); + goto verbose; + } + + if (ncm->cm.error >= NSS_CAPWAP_ERROR_MSG_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ncm, ncm->cm.type, nss_capwap_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ncm, ncm->cm.type, nss_capwap_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error, nss_capwap_log_error_response_types_str[ncm->cm.error]); +--- a/nss_capwap_stats.c ++++ b/nss_capwap_stats.c +@@ -117,15 +117,18 @@ static ssize_t nss_capwap_stats_decap(ch + tcnt = s->rx_queue_full_drops; + return snprintf(line, len, "%s = %llu (n2h = %llu)\n", nss_capwap_strings_decap_stats[i].stats_name, tcnt, s->rx_n2h_queue_full_drops); + case 10: +- tcnt = s->rx_mem_failure_drops; ++ tcnt = s->rx_n2h_queue_full_drops; + break; + case 11: +- tcnt = s->rx_csum_drops; ++ tcnt = s->rx_mem_failure_drops; + break; + case 12: +- tcnt = s->rx_malformed; ++ tcnt = s->rx_csum_drops; + break; + case 13: ++ tcnt = s->rx_malformed; ++ break; ++ case 14: + tcnt = s->fast_mem; + break; + default: +--- a/nss_clmap.c ++++ b/nss_clmap.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -88,12 +88,12 @@ static void nss_clmap_msg_handler(struct + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_CLMAP_MSG_TYPE_MAX) { +- nss_warning("%p: received invalid message %d for clmap interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for clmap interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_clmap_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -113,7 +113,7 @@ static void nss_clmap_msg_handler(struct + * Update the callback and app_data for NOTIFY messages. + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_top_main.if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; + } + +@@ -122,7 +122,7 @@ static void nss_clmap_msg_handler(struct + */ + cb = (nss_clmap_msg_callback_t)ncm->cb; + if (!cb) { +- nss_trace("%p: cb is null for interface %d", nss_ctx, ncm->interface); ++ nss_trace("%px: cb is null for interface %d", nss_ctx, ncm->interface); + return; + } + +@@ -169,14 +169,14 @@ nss_tx_status_t nss_clmap_tx_msg_sync(st + + status = nss_clmap_tx_msg(nss_ctx, nclm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: clmap_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: clmap_tx_msg failed\n", nss_ctx); + up(&clmap_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&clmap_pvt.complete, msecs_to_jiffies(NSS_CLMAP_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: clmap tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: clmap tx sync failed due to timeout\n", nss_ctx); + clmap_pvt.response = NSS_TX_FAILURE; + } + +@@ -205,19 +205,25 @@ EXPORT_SYMBOL(nss_clmap_tx_buf); + bool nss_clmap_unregister(uint32_t if_num) + { + struct nss_ctx_instance *nss_ctx; ++ int status; + + nss_ctx = nss_clmap_get_ctx(); + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (!nss_clmap_verify_if_num(if_num)) { +- nss_warning("%p: clmap unregister request received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: clmap unregister request received for invalid interface %d", nss_ctx, if_num); ++ return false; ++ } ++ ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Failed to unregister handler for clmap NSS I/F:%u\n", nss_ctx, if_num); + return false; + } + +- nss_clmap_stats_session_unregister(if_num); +- nss_core_unregister_handler(nss_ctx, if_num); + nss_core_unregister_subsys_dp(nss_ctx, if_num); +- nss_top_main.if_rx_msg_callback[if_num] = NULL; ++ nss_core_unregister_handler(nss_ctx, if_num); ++ nss_clmap_stats_session_unregister(if_num); + + return true; + } +@@ -242,8 +248,8 @@ struct nss_ctx_instance *nss_clmap_regis + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (!nss_clmap_verify_if_num(if_num)) { +- nss_warning("%p: clmap register request received for invalid interface %d", nss_ctx, if_num); +- return NULL; ++ nss_warning("%px: clmap register request received for invalid interface %d", nss_ctx, if_num); ++ goto fail; + } + + if (di_type == NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_US) { +@@ -253,22 +259,33 @@ struct nss_ctx_instance *nss_clmap_regis + } + + if (!stats_status) { +- nss_warning("%p: statistics registration failed for interface: %d\n", nss_ctx, if_num); +- return NULL; ++ nss_warning("%px: statistics registration failed for interface: %d\n", nss_ctx, if_num); ++ goto fail; + } + + core_status = nss_core_register_handler(nss_ctx, if_num, nss_clmap_msg_handler, (void *)netdev); + if (core_status != NSS_CORE_STATUS_SUCCESS) { +- nss_clmap_stats_session_unregister(if_num); +- nss_warning("%p: NSS core register handler failed for if_num:%d with error :%d", nss_ctx, if_num, core_status); +- return NULL; ++ goto core_reg_fail; ++ } ++ ++ core_status = nss_core_register_msg_handler(nss_ctx, if_num, notify_cb); ++ if (core_status != NSS_CORE_STATUS_SUCCESS) { ++ goto msg_reg_fail; + } + + nss_core_register_subsys_dp(nss_ctx, if_num, data_cb, NULL, (void *)netdev, netdev, features); + nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, di_type); +- nss_top_main.if_rx_msg_callback[if_num] = notify_cb; + + return nss_ctx; ++ ++msg_reg_fail: ++ nss_core_unregister_handler(nss_ctx, if_num); ++core_reg_fail: ++ nss_clmap_stats_session_unregister(if_num); ++ nss_warning("%px: NSS core register handler failed for if_num:%d with error :%d", nss_ctx, if_num, core_status); ++fail: ++ return NULL; ++ + } + EXPORT_SYMBOL(nss_clmap_register); + +@@ -282,7 +299,7 @@ int nss_clmap_ifnum_with_core_id(int if_ + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + if (!nss_is_dynamic_interface(if_num)) { +- nss_warning("%p: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); ++ nss_warning("%px: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); + return 0; + } + return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); +--- a/nss_clmap_log.c ++++ b/nss_clmap_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -59,7 +59,7 @@ static char *nss_clmap_log_error_types_s + */ + static void nss_clmap_log_mac_msg(struct nss_clmap_mac_msg *npvcm) + { +- nss_trace("%p: NSS clmap MAC message \n" ++ nss_trace("%px: NSS clmap MAC message \n" + "Clmap Mac Addr: %x : %x : %x" + "Clmap Flags: %u\n" + "Clmap VLAN ID: %u\n" +@@ -76,7 +76,7 @@ static void nss_clmap_log_mac_msg(struct + */ + static void nss_clmap_log_interface_enable_msg(struct nss_clmap_msg *npvm) + { +- nss_trace("%p: NSS clmap interface state message: Enable \n", npvm); ++ nss_trace("%px: NSS clmap interface state message: Enable \n", npvm); + } + + /* +@@ -85,7 +85,7 @@ static void nss_clmap_log_interface_enab + */ + static void nss_clmap_log_interface_disable_msg(struct nss_clmap_msg *npvm) + { +- nss_trace("%p: NSS clmap interface state message: Disable \n", npvm); ++ nss_trace("%px: NSS clmap interface state message: Disable \n", npvm); + } + + /* +@@ -115,7 +115,7 @@ static void nss_clmap_log_mac_del_msg(st + static void nss_clmap_log_mac_flush_msg(struct nss_clmap_msg *npvm) + { + struct nss_clmap_flush_mac_msg *npvcm __maybe_unused = &npvm->msg.mac_flush; +- nss_trace("%p: NSS clmap MAC flush message \n" ++ nss_trace("%px: NSS clmap MAC flush message \n" + "Clmap Next-hop Interface Number: %d\n", + npvcm, npvcm->nexthop_ifnum); + } +@@ -151,7 +151,7 @@ static void nss_clmap_log_verbose(struct + break; + + default: +- nss_trace("%p: Invalid message type\n", npvm); ++ nss_trace("%px: Invalid message type\n", npvm); + break; + } + } +@@ -163,11 +163,11 @@ static void nss_clmap_log_verbose(struct + void nss_clmap_log_tx_msg(struct nss_clmap_msg *npvm) + { + if (npvm->cm.type >= NSS_CLMAP_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", npvm); ++ nss_warning("%px: Invalid message type\n", npvm); + return; + } + +- nss_info("%p: type[%d]:%s\n", npvm, npvm->cm.type, nss_clmap_log_message_types_str[npvm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", npvm, npvm->cm.type, nss_clmap_log_message_types_str[npvm->cm.type]); + nss_clmap_log_verbose(npvm); + } + +@@ -178,26 +178,26 @@ void nss_clmap_log_tx_msg(struct nss_clm + void nss_clmap_log_rx_msg(struct nss_clmap_msg *npvm) + { + if (npvm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", npvm); ++ nss_warning("%px: Invalid response\n", npvm); + return; + } + + if (npvm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (npvm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", npvm, npvm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", npvm, npvm->cm.type, + nss_clmap_log_message_types_str[npvm->cm.type], + npvm->cm.response, nss_cmn_response_str[npvm->cm.response]); + goto verbose; + } + + if (npvm->cm.error >= NSS_CLMAP_ERROR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + npvm, npvm->cm.type, nss_clmap_log_message_types_str[npvm->cm.type], + npvm->cm.response, nss_cmn_response_str[npvm->cm.response], + npvm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + npvm, npvm->cm.type, nss_clmap_log_message_types_str[npvm->cm.type], + npvm->cm.response, nss_cmn_response_str[npvm->cm.response], + npvm->cm.error, nss_clmap_log_error_types_str[npvm->cm.error]); +--- a/nss_clmap_stats.c ++++ b/nss_clmap_stats.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -79,7 +79,7 @@ bool nss_clmap_stats_session_register(ui + if (!stats_db[i]) { + stats_db[i] = (struct nss_clmap_stats *)kzalloc(sizeof(struct nss_clmap_stats), GFP_KERNEL); + if (!stats_db[i]) { +- nss_warning("%p: could not allocate memory for statistics database for interface id: %d\n", netdev, if_num); ++ nss_warning("%px: could not allocate memory for statistics database for interface id: %d\n", netdev, if_num); + break; + } + stats_db[i]->valid = true; +@@ -228,7 +228,7 @@ void nss_clmap_stats_sync(struct nss_ctx + + if (!s) { + spin_unlock_bh(&nss_clmap_stats_lock); +- nss_warning("%p: Interface not found: %u", nss_ctx, if_num); ++ nss_warning("%px: Interface not found: %u", nss_ctx, if_num); + return; + } + +--- a/nss_cmn.c ++++ b/nss_cmn.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014-2020, 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. +@@ -75,7 +75,7 @@ int32_t nss_cmn_get_interface_number(str + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: Interface number could not be found as core not ready\n", nss_ctx); ++ nss_warning("%px: Interface number could not be found as core not ready\n", nss_ctx); + return -1; + } + +@@ -90,7 +90,7 @@ int32_t nss_cmn_get_interface_number(str + } + } + +- nss_warning("%p: Interface number could not be found as interface has not registered yet\n", nss_ctx); ++ nss_warning("%px: Interface number could not be found as interface has not registered yet\n", nss_ctx); + return -1; + } + EXPORT_SYMBOL(nss_cmn_get_interface_number); +@@ -119,7 +119,7 @@ struct net_device *nss_cmn_get_interface + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: Interface device could not be found as core not ready\n", nss_ctx); ++ nss_warning("%px: Interface device could not be found as core not ready\n", nss_ctx); + return NULL; + } + +@@ -152,7 +152,7 @@ int32_t nss_cmn_get_interface_number_by_ + } + } + +- nss_warning("Interface number could not be found for %p (%s) as interface has not registered yet\n", dev, dev->name); ++ nss_warning("Interface number could not be found for %px (%s) as interface has not registered yet\n", dev, dev->name); + return -1; + } + EXPORT_SYMBOL(nss_cmn_get_interface_number_by_dev_and_type); +@@ -287,7 +287,7 @@ nss_cb_register_status_t nss_cmn_registe + /* + * We already have a callback registered for this service code. + */ +- nss_warning("%p: a callback is registered already for this service code %d\n", nss_ctx, service_code); ++ nss_warning("%px: a callback is registered already for this service code %d\n", nss_ctx, service_code); + + return NSS_CB_REGISTER_FAILED; + } +@@ -310,7 +310,7 @@ nss_cb_unregister_status_t nss_cmn_unreg + /* + * No callback was registered for this service code. + */ +- nss_warning("%p: no callback is registered for this service code %d\n", nss_ctx, service_code); ++ nss_warning("%px: no callback is registered for this service code %d\n", nss_ctx, service_code); + return NSS_CB_UNREGISTER_FAILED; + } + +--- a/nss_core.h ++++ b/nss_core.h +@@ -232,6 +232,8 @@ static inline void nss_core_dma_cache_ma + * INFO: The LOW and MAX value together describe the "performance" band that we should operate the frequency at. + * + */ ++#define NSS_FREQ_SCALE_NA 0xFAADFAAD /* Frequency scale not supported */ ++ + #define NSS_FREQ_110 110000000 /* Frequency in hz */ + #define NSS_FREQ_110_MIN 0x03000 /* Instructions Per ms Min */ + #define NSS_FREQ_110_MAX 0x07000 /* Instructions Per ms Max */ +@@ -556,12 +558,11 @@ struct nss_top_instance { + uint8_t tls_handler_id; + uint8_t mirror_handler_id; + uint8_t wmdb_handler_id; ++ uint8_t dma_handler_id; + + /* + * Data/Message callbacks for various interfaces + */ +- nss_if_rx_msg_callback_t if_rx_msg_callback[NSS_MAX_NET_INTERFACES]; +- /* All interfaces message callback functions */ + nss_phys_if_msg_callback_t phys_if_msg_callback[NSS_MAX_PHYSICAL_INTERFACES]; + /* Physical interface event callback functions */ + nss_virt_if_msg_callback_t virt_if_msg_callback[NSS_MAX_VIRTUAL_INTERFACES]; +@@ -909,7 +910,7 @@ static inline void nss_core_log_msg_fail + /* + * TODO: Is it worth doing value to name on these values? + */ +- nss_warning("%p: msg failure - interface: %d, type: %d, response: %d, error: %d", ++ nss_warning("%px: msg failure - interface: %d, type: %d, response: %d, error: %d", + nss_ctx, ncm->interface, ncm->type, ncm->response, ncm->error); + } + +--- a/nss_crypto.c ++++ b/nss_crypto.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2013,2015-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2013,2015-2020, 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. +@@ -67,22 +67,22 @@ static void nss_crypto_msg_handler(struc + * Sanity check the message type + */ + if (ncm->type > NSS_CRYPTO_MSG_TYPE_MAX) { +- nss_warning("%p: rx message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: rx message type out of range: %d", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_crypto_msg)) { +- nss_warning("%p: rx message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: rx message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + + if (ncm->interface != NSS_CRYPTO_INTERFACE) { +- nss_warning("%p: rx message request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: rx message request for another interface: %d", nss_ctx, ncm->interface); + return; + } + + if (ncm->response == NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: rx message response for if %d, type %d, is invalid: %d", nss_ctx, ncm->interface, ++ nss_warning("%px: rx message response for if %d, type %d, is invalid: %d", nss_ctx, ncm->interface, + ncm->type, ncm->response); + return; + } +@@ -92,7 +92,6 @@ static void nss_crypto_msg_handler(struc + ncm->app_data = (nss_ptr_t)crypto_ctx; + } + +- + nss_core_log_msg_failures(nss_ctx, ncm); + + /* +@@ -105,7 +104,7 @@ static void nss_crypto_msg_handler(struc + */ + cb = (nss_crypto_msg_callback_t)ncm->cb; + if (unlikely(!cb)) { +- nss_trace("%p: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); ++ nss_trace("%px: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); + return; + } + cb((void *)ncm->app_data, nim); +@@ -124,20 +123,20 @@ nss_tx_status_t nss_crypto_tx_msg(struct + { + struct nss_cmn_msg *ncm = &msg->cm; + +- nss_info("%p: tx message %d for if %d\n", nss_ctx, ncm->type, ncm->interface); ++ nss_info("%px: tx message %d for if %d\n", nss_ctx, ncm->type, ncm->interface); + + BUILD_BUG_ON(NSS_NBUF_PAYLOAD_SIZE < sizeof(struct nss_crypto_msg)); + + if (ncm->interface != NSS_CRYPTO_INTERFACE) { +- nss_warning("%p: tx message request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx message request for another interface: %d", nss_ctx, ncm->interface); + } + + if (ncm->type > NSS_CRYPTO_MSG_TYPE_MAX) { +- nss_warning("%p: tx message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: tx message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +- nss_info("msg params version:%d, interface:%d, type:%d, cb:%p, app_data:%p, len:%d\n", ++ nss_info("msg params version:%d, interface:%d, type:%d, cb:%px, app_data:%px, len:%d\n", + ncm->version, ncm->interface, ncm->type, (void *)ncm->cb, (void *)ncm->app_data, ncm->len); + + /* +@@ -156,17 +155,17 @@ nss_tx_status_t nss_crypto_tx_buf(struct + { + int32_t status; + +- nss_trace("%p: tx_data buf=%p", nss_ctx, skb); ++ nss_trace("%px: tx_data buf=%px", nss_ctx, skb); + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: tx_data packet dropped as core not ready", nss_ctx); ++ nss_warning("%px: tx_data packet dropped as core not ready", nss_ctx); + return NSS_TX_FAILURE_NOT_READY; + } + + status = nss_core_send_buffer(nss_ctx, if_num, skb, NSS_IF_H2N_DATA_QUEUE, H2N_BUFFER_PACKET, H2N_BIT_FLAG_BUFFER_REUSABLE); + if (unlikely(status != NSS_CORE_STATUS_SUCCESS)) { +- nss_warning("%p: tx_data Unable to enqueue packet", nss_ctx); ++ nss_warning("%px: tx_data Unable to enqueue packet", nss_ctx); + if (status == NSS_CORE_STATUS_FAILURE_QUEUE) { + return NSS_TX_FAILURE_QUEUE; + } +@@ -226,7 +225,7 @@ struct nss_ctx_instance *nss_crypto_data + nss_ctx = &nss_top_main.nss[nss_top_main.crypto_handler_id]; + + if ((if_num >= NSS_MAX_NET_INTERFACES) && (if_num < NSS_MAX_PHYSICAL_INTERFACES)) { +- nss_warning("%p: data register received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: data register received for invalid interface %d", nss_ctx, if_num); + return NULL; + } + +@@ -245,7 +244,7 @@ struct nss_ctx_instance *nss_crypto_data + void nss_crypto_data_unregister(struct nss_ctx_instance *nss_ctx, uint32_t if_num) + { + if ((if_num >= NSS_MAX_NET_INTERFACES) && (if_num < NSS_MAX_PHYSICAL_INTERFACES)) { +- nss_warning("%p: data unregister received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: data unregister received for invalid interface %d", nss_ctx, if_num); + return; + } + --- a/nss_crypto_cmn.c +++ b/nss_crypto_cmn.c -@@ -21,8 +21,6 @@ - - #include "nss_tx_rx_common.h" - #include "nss_crypto_cmn.h" --#include "nss_crypto_cmn_strings.h" --#include "nss_crypto_cmn_stats.h" - #include "nss_crypto_cmn_log.h" - - /* -@@ -96,18 +94,6 @@ static void nss_crypto_cmn_msg_handler(s +@@ -62,7 +62,7 @@ static void nss_crypto_cmn_msg_handler(s + * Sanity check the message type */ - nss_crypto_cmn_log_rx_msg(nim); + if (ncm->type > NSS_CRYPTO_CMN_MSG_TYPE_MAX) { +- nss_warning("%p: rx message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: rx message type out of range: %d", nss_ctx, ncm->type); + return; + } -- switch (nim->cm.type) { -- case NSS_CRYPTO_CMN_MSG_TYPE_SYNC_NODE_STATS: -- case NSS_CRYPTO_CMN_MSG_TYPE_SYNC_ENG_STATS: -- case NSS_CRYPTO_CMN_MSG_TYPE_SYNC_CTX_STATS: -- /* -- * Update driver statistics and send statistics -- * notification to the registered modules. -- */ -- nss_crypto_cmn_stats_sync(nss_ctx, &nim->msg.stats); -- nss_crypto_cmn_stats_notify(nss_ctx); -- break; -- } - /* - * Load, Test & call +@@ -72,12 +72,12 @@ static void nss_crypto_cmn_msg_handler(s + * the intended interface. */ -@@ -226,12 +212,6 @@ nss_tx_status_t nss_crypto_cmn_tx_msg_sy - * further details read Linux/Documentation/memory-barrier.txt + if (nss_cmn_get_msg_len(ncm) > sizeof(*nim)) { +- nss_warning("%p: rx message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: rx message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + + if (ncm->response == NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: rx message response for if %d, type %d, is invalid: %d", nss_ctx, ++ nss_warning("%px: rx message response for if %d, type %d, is invalid: %d", nss_ctx, + ncm->interface, ncm->type, ncm->response); + return; + } +@@ -99,7 +99,7 @@ static void nss_crypto_cmn_msg_handler(s */ - smp_rmb(); -- -- if (msg->cm.response != NSS_CMN_RESPONSE_ACK) { -- up(&pvt->sem); -- return NSS_TX_FAILURE; -- } -- - up(&pvt->sem); + cb = (nss_crypto_cmn_msg_callback_t)ncm->cb; + if (unlikely(!cb)) { +- nss_warning("%p: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); + return; + } - return NSS_TX_SUCCESS; -@@ -377,9 +357,6 @@ void nss_crypto_cmn_register_handler(voi - sema_init(&g_nss_crypto_cmn.sem, 1); - init_completion(&g_nss_crypto_cmn.complete); - nss_core_register_handler(nss_ctx, NSS_CRYPTO_CMN_INTERFACE, nss_crypto_cmn_msg_handler, NULL); -- -- nss_crypto_cmn_stats_dentry_create(); -- nss_crypto_cmn_strings_dentry_create(); - } +@@ -115,12 +115,12 @@ nss_tx_status_t nss_crypto_cmn_tx_msg(st + struct nss_cmn_msg *ncm = &msg->cm; + uint16_t msg_len = nss_cmn_get_msg_len(ncm); - /* ---- a/nss_crypto_cmn_stats.c -+++ /dev/null -@@ -1,166 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2020, 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_core.h" --#include "nss_crypto_cmn_stats.h" --#include "nss_crypto_cmn_strings.h" -- --/* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_crypto_cmn_stats_notifier); -- --/* -- * Spinlock to protect CRYPTO_CMN statistics update/read -- */ --DEFINE_SPINLOCK(nss_crypto_cmn_stats_lock); -- --/* -- * nss_crypto_cmn_stats -- * crypto common statistics -- */ --uint64_t nss_crypto_cmn_stats[NSS_CRYPTO_CMN_STATS_MAX]; -- --/* -- * nss_crypto_cmn_stats_read() -- * Read crypto common statistics -- */ --static ssize_t nss_crypto_cmn_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- int32_t i; -- -- /* -- * Max output lines = #stats + -- * few blank lines for banner printing + Number of Extra outputlines -- * for future reference to add new stats -- */ -- uint32_t max_output_lines = NSS_CRYPTO_CMN_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- size_t size_wr = 0; -- ssize_t bytes_read = 0; -- uint64_t *stats_shadow; -- -- char *lbuf = vzalloc(size_al); -- if (unlikely(!lbuf)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return -ENOMEM; -- } -- -- stats_shadow = vzalloc(NSS_CRYPTO_CMN_STATS_MAX * 8); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- vfree(lbuf); -- return -ENOMEM; -- } -- -- /* -- * crypto common statistics -- */ -- spin_lock_bh(&nss_crypto_cmn_stats_lock); -- for (i = 0; i < NSS_CRYPTO_CMN_STATS_MAX; i++) -- stats_shadow[i] = nss_crypto_cmn_stats[i]; -- -- spin_unlock_bh(&nss_crypto_cmn_stats_lock); -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "crypto_cmn", NSS_STATS_SINGLE_CORE); -- size_wr += nss_stats_print("crypto_cmn", NULL, NSS_STATS_SINGLE_INSTANCE, nss_crypto_cmn_strings_stats, -- stats_shadow, NSS_CRYPTO_CMN_STATS_MAX, lbuf, size_wr, size_al); -- -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- vfree(lbuf); -- vfree(stats_shadow); -- -- return bytes_read; --} -- --/* -- * nss_crypto_cmn_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(crypto_cmn); -- --/* -- * nss_crypto_cmn_stats_dentry_create() -- * Create crypto common statistics debug entry. -- */ --void nss_crypto_cmn_stats_dentry_create(void) --{ -- nss_stats_create_dentry("crypto_cmn", &nss_crypto_cmn_stats_ops); --} -- --/* -- * nss_crypto_cmn_stats_sync() -- * Handle the syncing of NSS crypto common statistics. -- */ --void nss_crypto_cmn_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_crypto_cmn_stats *nct) --{ -- int j; -- -- spin_lock_bh(&nss_crypto_cmn_stats_lock); -- -- /* -- * Common node stats -- */ -- nss_crypto_cmn_stats[NSS_STATS_NODE_RX_PKTS] += nct->nstats.rx_packets; -- nss_crypto_cmn_stats[NSS_STATS_NODE_RX_BYTES] += nct->nstats.rx_bytes; -- nss_crypto_cmn_stats[NSS_STATS_NODE_TX_PKTS] += nct->nstats.tx_packets; -- nss_crypto_cmn_stats[NSS_STATS_NODE_TX_BYTES] += nct->nstats.tx_bytes; -- -- for (j = 0; j < NSS_MAX_NUM_PRI; j++) -- nss_crypto_cmn_stats[NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += nct->nstats.rx_dropped[j]; -- -- /* -- * crypto common statistics -- */ -- nss_crypto_cmn_stats[NSS_CRYPTO_CMN_STATS_FAIL_VERSION] += nct->fail_version; -- nss_crypto_cmn_stats[NSS_CRYPTO_CMN_STATS_FAIL_CTX] += nct->fail_ctx; -- nss_crypto_cmn_stats[NSS_CRYPTO_CMN_STATS_FAIL_DMA] += nct->fail_dma; -- -- spin_unlock_bh(&nss_crypto_cmn_stats_lock); --} -- --/* -- * nss_crypto_cmn_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_crypto_cmn_stats_notify(struct nss_ctx_instance *nss_ctx) --{ -- struct nss_crypto_cmn_stats_notification crypto_cmn_stats; -- -- crypto_cmn_stats.core_id = nss_ctx->id; -- memcpy(crypto_cmn_stats.stats, nss_crypto_cmn_stats, sizeof(crypto_cmn_stats.stats)); -- atomic_notifier_call_chain(&nss_crypto_cmn_stats_notifier, NSS_STATS_EVENT_NOTIFY, &crypto_cmn_stats); --} -- --/* -- * nss_crypto_cmn_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_crypto_cmn_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_crypto_cmn_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_crypto_cmn_stats_register_notifier); -- --/* -- * nss_crypto_cmn_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_crypto_cmn_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_crypto_cmn_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_crypto_cmn_stats_unregister_notifier); ---- a/nss_crypto_cmn_stats.h -+++ /dev/null -@@ -1,77 +0,0 @@ --/* -- ****************************************************************************** -- * Copyright (c) 2020, 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. -- * **************************************************************************** -- */ -- --#ifndef __NSS_CRYPTO_CMN_STATS_H --#define __NSS_CRYPTO_CMN_STATS_H -- --#include -- --/** -- * nss_crypto_cmn_stats_types -- * crypto common transmission node statistics -- */ --enum nss_crypto_cmn_stats_types { -- NSS_CRYPTO_CMN_STATS_FAIL_VERSION = NSS_STATS_NODE_MAX, /* version mismatch failures */ -- NSS_CRYPTO_CMN_STATS_FAIL_CTX, /* context related failures */ -- NSS_CRYPTO_CMN_STATS_FAIL_DMA, /* dma descriptor full */ -- NSS_CRYPTO_CMN_STATS_MAX, /* Maximum message type */ --}; -- --/** -- * nss_crypto_cmn_stats_notification -- * crypto common transmission statistics structure -- */ --struct nss_crypto_cmn_stats_notification { -- uint32_t core_id; /* core ID */ -- uint64_t stats[NSS_CRYPTO_CMN_STATS_MAX]; /* transmission statistics */ --}; -- --/* -- * crypto common statistics APIs -- */ --extern void nss_crypto_cmn_stats_notify(struct nss_ctx_instance *nss_ctx); --extern void nss_crypto_cmn_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_crypto_cmn_stats *nct); --extern void nss_crypto_cmn_stats_dentry_create(void); -- --/** -- * nss_crypto_cmn_stats_register_notifier -- * Registers a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or -2 on failure. -- */ --extern int nss_crypto_cmn_stats_register_notifier(struct notifier_block *nb); -- --/** -- * nss_crypto_cmn_stats_unregister_notifier -- * Deregisters a statistics notifier. -- * -- * @datatypes -- * notifier_block -- * -- * @param[in] nb Notifier block. -- * -- * @return -- * 0 on success or -2 on failure. -- */ --extern int nss_crypto_cmn_stats_unregister_notifier(struct notifier_block *nb); -- --#endif /* __NSS_CRYPTO_CMN_STATS_H */ ---- a/nss_crypto_cmn_strings.c -+++ /dev/null -@@ -1,61 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2020, 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_strings.h" --#include "nss_crypto_cmn_strings.h" -- --/* -- * nss_crypto_cmn_strings_stats -- * crypto common statistics strings. -- */ --struct nss_stats_info nss_crypto_cmn_strings_stats[NSS_CRYPTO_CMN_STATS_MAX] = { -- {"rx_pkts", NSS_STATS_TYPE_COMMON}, -- {"rx_byts", NSS_STATS_TYPE_COMMON}, -- {"tx_pkts", NSS_STATS_TYPE_COMMON}, -- {"tx_byts", NSS_STATS_TYPE_COMMON}, -- {"rx_queue[0]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[1]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[2]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[3]_drops", NSS_STATS_TYPE_DROP}, -- {"fail_version", NSS_STATS_TYPE_SPECIAL}, -- {"fail_ctx", NSS_STATS_TYPE_SPECIAL}, -- {"fail_dma", NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_crypto_cmn_strings_read() -- * Read crypto common node statistics names -- */ --static ssize_t nss_crypto_cmn_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_crypto_cmn_strings_stats, NSS_CRYPTO_CMN_STATS_MAX); --} -- --/* -- * nss_crypto_cmn_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(crypto_cmn); -- --/* -- * nss_crypto_cmn_strings_dentry_create() -- * Create crypto common statistics strings debug entry. -- */ --void nss_crypto_cmn_strings_dentry_create(void) --{ -- nss_strings_create_dentry("crypto_cmn", &nss_crypto_cmn_strings_ops); --} ---- a/nss_crypto_cmn_strings.h -+++ /dev/null -@@ -1,25 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2020, 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. -- ************************************************************************** -- */ -- --#ifndef __NSS_CRYPTO_CMN_STRINGS_H --#define __NSS_CRYPTO_CMN_STRINGS_H -- --#include "nss_crypto_cmn_stats.h" -- --extern struct nss_stats_info nss_crypto_cmn_strings_stats[NSS_CRYPTO_CMN_STATS_MAX]; --extern void nss_crypto_cmn_strings_dentry_create(void); -- --#endif /* __NSS_CRYPTO_CMN_STRINGS_H */ ---- a/nss_data_plane/hal/include/nss_data_plane_hal.h -+++ b/nss_data_plane/hal/include/nss_data_plane_hal.h -@@ -17,22 +17,6 @@ - #include "nss_phys_if.h" - #include +- nss_info("%p: tx message %d for if %d", nss_ctx, ncm->type, ncm->interface); ++ nss_info("%px: tx message %d for if %d", nss_ctx, ncm->type, ncm->interface); --#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)) --#define NSS_DATA_PLANE_SUPPORTED_FEATURES (NETIF_F_HIGHDMA \ -- | NETIF_F_HW_CSUM \ -- | NETIF_F_RXCSUM \ -- | NETIF_F_SG \ -- | NETIF_F_FRAGLIST \ -- | (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)) --#else --#define NSS_DATA_PLANE_SUPPORTED_FEATURES (NETIF_F_HIGHDMA \ -- | NETIF_F_HW_CSUM \ -- | NETIF_F_RXCSUM \ -- | NETIF_F_SG \ -- | NETIF_F_FRAGLIST \ -- | (NETIF_F_TSO | NETIF_F_TSO6)) --#endif -- + BUILD_BUG_ON(NSS_NBUF_PAYLOAD_SIZE < sizeof(*msg)); + + if (ncm->type > NSS_CRYPTO_CMN_MSG_TYPE_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -129,11 +129,11 @@ nss_tx_status_t nss_crypto_cmn_tx_msg(st + * the sender accidentally programmed a incorrect length into the message. + */ + if (msg_len != sizeof(*msg)) { +- nss_warning("%p: message request len bad: %d", nss_ctx, msg_len); ++ nss_warning("%px: message request len bad: %d", nss_ctx, msg_len); + return NSS_TX_FAILURE_BAD_PARAM; + } + +- nss_trace("%p: msg params version:%d, interface:%d, type:%d, cb:%p, app_data:%p, len:%d", ++ nss_trace("%px: msg params version:%d, interface:%d, type:%d, cb:%px, app_data:%px, len:%d", + nss_ctx, ncm->version, ncm->interface, ncm->type, + (void *)ncm->cb, (void *)ncm->app_data, ncm->len); + +@@ -189,7 +189,7 @@ nss_tx_status_t nss_crypto_cmn_tx_msg_sy + + status = nss_crypto_cmn_tx_msg(nss_ctx, msg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: tx_msg failed", nss_ctx); ++ nss_warning("%px: tx_msg failed", nss_ctx); + up(&pvt->sem); + return status; + } +@@ -200,7 +200,7 @@ nss_tx_status_t nss_crypto_cmn_tx_msg_sy + ret = wait_for_completion_timeout(&pvt->complete, NSS_CRYPTO_CMN_TX_TIMEO_TICKS); + if (!ret) { + atomic_inc(&pvt->seq_no); +- nss_warning("%p: tx_msg_sync timed out", nss_ctx); ++ nss_warning("%px: tx_msg_sync timed out", nss_ctx); + up(&pvt->sem); + return NSS_TX_FAILURE; + } +@@ -229,7 +229,7 @@ nss_tx_status_t nss_crypto_cmn_tx_buf(st + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: tx_data packet dropped as core not ready", nss_ctx); ++ nss_warning("%px: tx_data packet dropped as core not ready", nss_ctx); + return NSS_TX_FAILURE_NOT_READY; + } + +@@ -239,11 +239,11 @@ nss_tx_status_t nss_crypto_cmn_tx_buf(st + break; + + case NSS_CORE_STATUS_FAILURE_QUEUE: /* queue full condition */ +- nss_warning("%p: H2N queue full for tx_buf", nss_ctx); ++ nss_warning("%px: H2N queue full for tx_buf", nss_ctx); + return NSS_TX_FAILURE_QUEUE; + + default: +- nss_warning("%p: general failure for tx_buf", nss_ctx); ++ nss_warning("%px: general failure for tx_buf", nss_ctx); + return NSS_TX_FAILURE; + } + +@@ -298,7 +298,7 @@ struct nss_ctx_instance *nss_crypto_cmn_ + nss_ctx = &nss_top_main.nss[nss_top_main.crypto_handler_id]; + + if (if_num < NSS_SPECIAL_IF_START) { +- nss_warning("%p: interface number is not special interface %d", nss_ctx, if_num); ++ nss_warning("%px: interface number is not special interface %d", nss_ctx, if_num); + return NULL; + } + +@@ -325,7 +325,7 @@ EXPORT_SYMBOL(nss_crypto_cmn_data_regist + void nss_crypto_cmn_data_unregister(struct nss_ctx_instance *nss_ctx, uint32_t if_num) + { + if (if_num < NSS_SPECIAL_IF_START) { +- nss_warning("%p: interface number is not special interface %d", nss_ctx, if_num); ++ nss_warning("%px: interface number is not special interface %d", nss_ctx, if_num); + return; + } + +--- a/nss_crypto_cmn_log.c ++++ b/nss_crypto_cmn_log.c +@@ -1,6 +1,6 @@ /* - * nss_data_plane_param - */ -@@ -49,6 +33,5 @@ struct nss_data_plane_param { - void nss_data_plane_hal_add_dp_ops(struct nss_dp_data_plane_ops *dp_ops); - void nss_data_plane_hal_register(struct nss_ctx_instance *nss_ctx); - void nss_data_plane_hal_unregister(struct nss_ctx_instance *nss_ctx); --void nss_data_plane_hal_set_features(struct nss_dp_data_plane_ctx *dpc); - uint16_t nss_data_plane_hal_get_mtu_sz(uint16_t mtu); - void nss_data_plane_hal_stats_sync(struct nss_data_plane_param *ndpp, struct nss_phys_if_stats *stats); ---- a/nss_data_plane/hal/nss_ipq60xx.c -+++ b/nss_data_plane/hal/nss_ipq60xx.c -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. + ************************************************************************** +- * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2020, 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 -@@ -40,12 +40,25 @@ static int nss_data_plane_hal_vsi_unassi - } - - /* -+ * nss_data_plane_hal_get_stats() -+ * Called by nss-dp to get GMAC stats -+ */ -+static void nss_data_plane_hal_get_stats(struct nss_dp_data_plane_ctx *dpc, -+ struct nss_dp_gmac_stats *stats) -+{ -+ /* -+ * EDMA doesn't send extended statistics. -+ */ -+} -+ -+/* - * nss_data_plane_hal_add_dp_ops() - */ - void nss_data_plane_hal_add_dp_ops(struct nss_dp_data_plane_ops *dp_ops) + * 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. +@@ -65,7 +65,7 @@ static int8_t *nss_crypto_cmn_log_error_ + static void nss_crypto_cmn_node_msg(struct nss_crypto_cmn_msg *ncm) { - dp_ops->vsi_assign = nss_data_plane_hal_vsi_assign; - dp_ops->vsi_unassign = nss_data_plane_hal_vsi_unassign; -+ dp_ops->get_stats = nss_data_plane_hal_get_stats; + struct nss_crypto_cmn_node *ncnm __maybe_unused = &ncm->msg.node; +- nss_trace("%p: NSS crypto common node message:\n" ++ nss_trace("%px: NSS crypto common node message:\n" + "Crypto Common Max DMA Rings: %d\n" + "Crypto Common Max Contex: %d\n" + "Crypto Common Max Context Size: %d\n", +@@ -80,8 +80,8 @@ static void nss_crypto_cmn_node_msg(stru + static void nss_crypto_cmn_engine_msg(struct nss_crypto_cmn_msg *ncm) + { + struct nss_crypto_cmn_engine *ncem __maybe_unused = &ncm->msg.eng; +- nss_trace("%p: NSS crypto common engine message \n" +- "Crypto Common Firmware Version: %p\n" ++ nss_trace("%px: NSS crypto common engine message \n" ++ "Crypto Common Firmware Version: %px\n" + "Crypto Common DMA Mask: %x\n" + "Crypto Common Token Count: %d\n", + ncem, &ncem->fw_ver, +@@ -95,7 +95,7 @@ static void nss_crypto_cmn_engine_msg(st + static void nss_crypto_cmn_dma_msg(struct nss_crypto_cmn_msg *ncm) + { + struct nss_crypto_cmn_dma *ncdm __maybe_unused = &ncm->msg.dma; +- nss_trace("%p: NSS crypto common dma message \n" ++ nss_trace("%px: NSS crypto common dma message \n" + "Crypto Common DMA Pair ID: %d\n", + ncdm, ncdm->pair_id); + } +@@ -107,13 +107,13 @@ static void nss_crypto_cmn_dma_msg(struc + static void nss_crypto_cmn_ctx_msg(struct nss_crypto_cmn_msg *ncm) + { + struct nss_crypto_cmn_ctx *nccm __maybe_unused = &ncm->msg.ctx; +- nss_trace("%p: NSS crypto common context message \n" +- "Crypto Common Context Spare Words: %p\n" ++ nss_trace("%px: NSS crypto common context message \n" ++ "Crypto Common Context Spare Words: %px\n" + "Crypto Common Index: %d\n" + "Crypto Common Secure Offset: %d\n" +- "Crypto Common Cipher Key: %p\n" +- "Crypto Common Authorization Key: %p\n" +- "Crypto Common Nonce Value: %p\n" ++ "Crypto Common Cipher Key: %px\n" ++ "Crypto Common Authorization Key: %px\n" ++ "Crypto Common Nonce Value: %px\n" + "Crypto Common Algorithm: %x\n" + "Crypto Common Context Specific Flags: %x\n", + nccm, &nccm->spare, +@@ -154,7 +154,7 @@ static void nss_crypto_cmn_log_verbose(s + break; + + default: +- nss_warning("%p: Invalid message type\n", ncm); ++ nss_warning("%px: Invalid message type\n", ncm); + break; + } + } +@@ -166,11 +166,11 @@ static void nss_crypto_cmn_log_verbose(s + void nss_crypto_cmn_log_tx_msg(struct nss_crypto_cmn_msg *ncm) + { + if (ncm->cm.type >= NSS_CRYPTO_CMN_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", ncm); ++ nss_warning("%px: Invalid message type\n", ncm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ncm, ncm->cm.type, nss_crypto_cmn_log_message_types_str[ncm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ncm, ncm->cm.type, nss_crypto_cmn_log_message_types_str[ncm->cm.type]); + nss_crypto_cmn_log_verbose(ncm); } +@@ -181,26 +181,26 @@ void nss_crypto_cmn_log_tx_msg(struct ns + void nss_crypto_cmn_log_rx_msg(struct nss_crypto_cmn_msg *ncm) + { + if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ncm); ++ nss_warning("%px: Invalid response\n", ncm); + return; + } + + if (ncm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ncm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, + nss_crypto_cmn_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response]); + goto verbose; + } + + if (ncm->cm.error >= NSS_CRYPTO_CMN_MSG_ERROR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ncm, ncm->cm.type, nss_crypto_cmn_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ncm, ncm->cm.type, nss_crypto_cmn_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error, nss_crypto_cmn_log_error_response_types_str[ncm->cm.error]); +--- a/nss_crypto_log.c ++++ b/nss_crypto_log.c +@@ -1,6 +1,6 @@ /* -@@ -71,17 +84,6 @@ void nss_data_plane_hal_unregister(struc + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -53,12 +53,12 @@ static int8_t *nss_crypto_log_error_resp + static void nss_crypto_config_eng_msg(struct nss_crypto_msg *ncm) + { + struct nss_crypto_config_eng *nccem __maybe_unused = &ncm->msg.eng; +- nss_trace("%p: NSS Crypto Config Engine Message:\n" ++ nss_trace("%px: NSS Crypto Config Engine Message:\n" + "Crypto Engine Number: %d\n" + "Crypto BAM Physical Base Address: %x\n" + "Crypto Physical Base Address: %x\n" +- "Crypto Pipe Description Address: %p\n" +- "Crypto Session Indices: %p\n", ++ "Crypto Pipe Description Address: %px\n" ++ "Crypto Session Indices: %px\n", + nccem, nccem->eng_id, + nccem->bam_pbase, nccem->crypto_pbase, + &nccem->desc_paddr, &nccem->idx); +@@ -71,7 +71,7 @@ static void nss_crypto_config_eng_msg(st + static void nss_crypto_config_session_msg(struct nss_crypto_msg *ncm) + { + struct nss_crypto_config_session *nccsm __maybe_unused = &ncm->msg.session; +- nss_trace("%p: NSS Crypto Config Session message \n" ++ nss_trace("%px: NSS Crypto Config Session message \n" + "Crypto Session Index: %d\n" + "Crypto Session State: %d\n" + "Crypto Session Initialization Vector Length: %d\n", +@@ -95,7 +95,7 @@ static void nss_crypto_log_verbose(struc + break; + + default: +- nss_warning("%p: Invalid message type\n", ncm); ++ nss_warning("%px: Invalid message type\n", ncm); + break; + } + } +@@ -107,11 +107,11 @@ static void nss_crypto_log_verbose(struc + void nss_crypto_log_tx_msg(struct nss_crypto_msg *ncm) + { + if (ncm->cm.type >= NSS_CRYPTO_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", ncm); ++ nss_warning("%px: Invalid message type\n", ncm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ncm, ncm->cm.type, nss_crypto_log_message_types_str[ncm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ncm, ncm->cm.type, nss_crypto_log_message_types_str[ncm->cm.type]); + nss_crypto_log_verbose(ncm); } - /* -- * nss_data_plane_hal_set_features -- */ --void nss_data_plane_hal_set_features(struct nss_dp_data_plane_ctx *dpc) --{ -- dpc->dev->features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; -- dpc->dev->hw_features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; -- dpc->dev->vlan_features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; -- dpc->dev->wanted_features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; --} -- --/* - * nss_data_plane_hal_stats_sync() - */ - void nss_data_plane_hal_stats_sync(struct nss_data_plane_param *ndpp, ---- a/nss_data_plane/hal/nss_ipq807x.c -+++ b/nss_data_plane/hal/nss_ipq807x.c -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. +@@ -122,26 +122,26 @@ void nss_crypto_log_tx_msg(struct nss_cr + void nss_crypto_log_rx_msg(struct nss_crypto_msg *ncm) + { + if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ncm); ++ nss_warning("%px: Invalid response\n", ncm); + return; + } + + if (ncm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ncm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, + nss_crypto_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response]); + goto verbose; + } + + if (ncm->cm.error >= NSS_CRYPTO_MSG_ERROR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ncm, ncm->cm.type, nss_crypto_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ncm, ncm->cm.type, nss_crypto_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error, nss_crypto_log_error_response_types_str[ncm->cm.error]); +--- /dev/null ++++ b/nss_data_plane/hal/include/nss_data_plane_hal.h +@@ -0,0 +1,37 @@ ++/* + * Copyright (c) 2016-2020, 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 -@@ -40,12 +40,25 @@ static int nss_data_plane_hal_vsi_unassi - } - - /* ++ * ++ * 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_phys_if.h" ++#include ++ ++/* ++ * nss_data_plane_param ++ */ ++struct nss_data_plane_param { ++ struct nss_dp_data_plane_ctx dpc; /* data plane ctx base class */ ++ int if_num; /* physical interface number */ ++ struct nss_ctx_instance *nss_ctx; /* which nss core */ ++ struct nss_dp_gmac_stats gmac_stats; /* SoC specific stats for GMAC */ ++ int notify_open; /* This data plane interface has been opened or not */ ++ uint32_t features; /* skb types supported by this interface */ ++ uint32_t bypass_nw_process; /* Do we want to bypass NW processing in NSS for this data plane? */ ++}; ++ ++void nss_data_plane_hal_add_dp_ops(struct nss_dp_data_plane_ops *dp_ops); ++void nss_data_plane_hal_register(struct nss_ctx_instance *nss_ctx); ++void nss_data_plane_hal_unregister(struct nss_ctx_instance *nss_ctx); ++uint16_t nss_data_plane_hal_get_mtu_sz(uint16_t mtu); ++void nss_data_plane_hal_stats_sync(struct nss_data_plane_param *ndpp, struct nss_phys_if_stats *stats); +--- /dev/null ++++ b/nss_data_plane/hal/nss_ipq60xx.c +@@ -0,0 +1,106 @@ ++/* ++ * Copyright (c) 2018-2020, 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_core.h" ++#include "nss_data_plane_hal.h" ++ ++/* ++ * nss_data_plane_hal_vsi_assign() ++ * Called by nss-dp to assign vsi of a data plane ++ */ ++static int nss_data_plane_hal_vsi_assign(struct nss_dp_data_plane_ctx *dpc, uint32_t vsi) ++{ ++ struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; ++ ++ return nss_phys_if_vsi_assign(dp->nss_ctx, vsi, dp->if_num); ++} ++ ++/* ++ * nss_data_plane_hal_vsi_unassign() ++ * Called by nss-dp to unassign vsi of a data plane ++ */ ++static int nss_data_plane_hal_vsi_unassign(struct nss_dp_data_plane_ctx *dpc, uint32_t vsi) ++{ ++ struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; ++ ++ return nss_phys_if_vsi_unassign(dp->nss_ctx, vsi, dp->if_num); ++} ++ ++/* + * nss_data_plane_hal_get_stats() + * Called by nss-dp to get GMAC stats + */ @@ -8814,67 +5198,205 @@ +} + +/* - * nss_data_plane_hal_add_dp_ops() - */ - void nss_data_plane_hal_add_dp_ops(struct nss_dp_data_plane_ops *dp_ops) - { - dp_ops->vsi_assign = nss_data_plane_hal_vsi_assign; - dp_ops->vsi_unassign = nss_data_plane_hal_vsi_unassign; ++ * nss_data_plane_hal_add_dp_ops() ++ */ ++void nss_data_plane_hal_add_dp_ops(struct nss_dp_data_plane_ops *dp_ops) ++{ ++ dp_ops->vsi_assign = nss_data_plane_hal_vsi_assign; ++ dp_ops->vsi_unassign = nss_data_plane_hal_vsi_unassign; + dp_ops->get_stats = nss_data_plane_hal_get_stats; - } - - /* -@@ -71,17 +84,6 @@ void nss_data_plane_hal_unregister(struc - } - - /* -- * nss_data_plane_hal_set_features -- */ --void nss_data_plane_hal_set_features(struct nss_dp_data_plane_ctx *dpc) --{ -- dpc->dev->features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; -- dpc->dev->hw_features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; -- dpc->dev->vlan_features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; -- dpc->dev->wanted_features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; --} -- --/* - * nss_data_plane_hal_stats_sync() - */ - void nss_data_plane_hal_stats_sync(struct nss_data_plane_param *ndpp, ++} ++ ++/* ++ * nss_data_plane_hal_register() ++ */ ++void nss_data_plane_hal_register(struct nss_ctx_instance *nss_ctx) ++{ ++ /* ++ * Packets with the ptp service code should be delivered to ++ * PHY driver for timestamping. ++ */ ++ nss_cmn_register_service_code(nss_ctx, nss_phy_tstamp_rx_buf, ++ NSS_PTP_EVENT_SERVICE_CODE, nss_ctx); ++} ++ ++/* ++ * nss_data_plane_hal_unregister() ++ */ ++void nss_data_plane_hal_unregister(struct nss_ctx_instance *nss_ctx) ++{ ++ nss_cmn_unregister_service_code(nss_ctx, nss_phy_tstamp_rx_buf, ++ NSS_PTP_EVENT_SERVICE_CODE); ++} ++ ++/* ++ * nss_data_plane_hal_stats_sync() ++ */ ++void nss_data_plane_hal_stats_sync(struct nss_data_plane_param *ndpp, ++ struct nss_phys_if_stats *stats) ++{ ++ /* ++ * EDMA does not pass sync interface stats through phys_if_stats ++ */ ++} ++ ++/* ++ * nss_data_plane_hal_get_mtu_sz() ++ */ ++uint16_t nss_data_plane_hal_get_mtu_sz(uint16_t mtu) ++{ ++ /* ++ * Reserve space for preheader ++ */ ++ return mtu + NSS_DP_PREHEADER_SIZE; ++} +--- /dev/null ++++ b/nss_data_plane/hal/nss_ipq807x.c +@@ -0,0 +1,106 @@ ++/* ++ * Copyright (c) 2016-2020, 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_core.h" ++#include "nss_data_plane_hal.h" ++ ++/* ++ * nss_data_plane_hal_vsi_assign() ++ * Called by nss-dp to assign vsi of a data plane ++ */ ++static int nss_data_plane_hal_vsi_assign(struct nss_dp_data_plane_ctx *dpc, uint32_t vsi) ++{ ++ struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; ++ ++ return nss_phys_if_vsi_assign(dp->nss_ctx, vsi, dp->if_num); ++} ++ ++/* ++ * nss_data_plane_hal_vsi_unassign() ++ * Called by nss-dp to unassign vsi of a data plane ++ */ ++static int nss_data_plane_hal_vsi_unassign(struct nss_dp_data_plane_ctx *dpc, uint32_t vsi) ++{ ++ struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; ++ ++ return nss_phys_if_vsi_unassign(dp->nss_ctx, vsi, dp->if_num); ++} ++ ++/* ++ * nss_data_plane_hal_get_stats() ++ * Called by nss-dp to get GMAC stats ++ */ ++static void nss_data_plane_hal_get_stats(struct nss_dp_data_plane_ctx *dpc, ++ struct nss_dp_gmac_stats *stats) ++{ ++ /* ++ * EDMA doesn't send extended statistics. ++ */ ++} ++ ++/* ++ * nss_data_plane_hal_add_dp_ops() ++ */ ++void nss_data_plane_hal_add_dp_ops(struct nss_dp_data_plane_ops *dp_ops) ++{ ++ dp_ops->vsi_assign = nss_data_plane_hal_vsi_assign; ++ dp_ops->vsi_unassign = nss_data_plane_hal_vsi_unassign; ++ dp_ops->get_stats = nss_data_plane_hal_get_stats; ++} ++ ++/* ++ * nss_data_plane_hal_register() ++ */ ++void nss_data_plane_hal_register(struct nss_ctx_instance *nss_ctx) ++{ ++ /* ++ * Packets with the ptp service code should be delivered to ++ * PHY driver for timestamping. ++ */ ++ nss_cmn_register_service_code(nss_ctx, nss_phy_tstamp_rx_buf, ++ NSS_PTP_EVENT_SERVICE_CODE, nss_ctx); ++} ++ ++/* ++ * nss_data_plane_hal_unregister() ++ */ ++void nss_data_plane_hal_unregister(struct nss_ctx_instance *nss_ctx) ++{ ++ nss_cmn_unregister_service_code(nss_ctx, nss_phy_tstamp_rx_buf, ++ NSS_PTP_EVENT_SERVICE_CODE); ++} ++ ++/* ++ * nss_data_plane_hal_stats_sync() ++ */ ++void nss_data_plane_hal_stats_sync(struct nss_data_plane_param *ndpp, ++ struct nss_phys_if_stats *stats) ++{ ++ /* ++ * EDMA does not pass sync interface stats through phys_if_stats ++ */ ++} ++ ++/* ++ * nss_data_plane_hal_get_mtu_sz() ++ */ ++uint16_t nss_data_plane_hal_get_mtu_sz(uint16_t mtu) ++{ ++ /* ++ * Reserve space for preheader ++ */ ++ return mtu + NSS_DP_PREHEADER_SIZE; ++} --- a/nss_data_plane/include/nss_data_plane.h +++ b/nss_data_plane/include/nss_data_plane.h @@ -1,6 +1,6 @@ /* ************************************************************************** -- * Copyright (c) 2014-2017,2020-2021, The Linux Foundation. All rights reserved. +- * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2017,2020, 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. -@@ -25,8 +25,6 @@ - #include - #include "nss_phys_if.h" +@@ -54,7 +54,7 @@ struct nss_data_plane_ops { + }; --#define NSS_DATA_PLANE_MAX_PACKET_LEN 65535 -- - /* - * nss_data_plane_schedule_registration() - * Called from nss_init to schedule a work to do data_plane register to data plane host driver + extern struct nss_data_plane_ops nss_data_plane_gmac_ops; +-extern struct nss_data_plane_ops nss_data_plane_edma_ops; ++extern struct nss_data_plane_ops nss_data_plane_ops; + + extern int nss_skip_nw_process; + #endif --- a/nss_data_plane/nss_data_plane.c +++ b/nss_data_plane/nss_data_plane.c @@ -1,6 +1,6 @@ /* ************************************************************************** -- * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. +- * Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, 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. -@@ -19,6 +19,22 @@ - #include "nss_tx_rx_common.h" - #include "nss_data_plane_hal.h" +@@ -16,69 +16,390 @@ + #include "nss_data_plane.h" + #include "nss_core.h" ++#include "nss_tx_rx_common.h" ++#include "nss_data_plane_hal.h" + +-static struct delayed_work nss_data_plane_work; +-static struct workqueue_struct *nss_data_plane_workqueue; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)) +#define NSS_DATA_PLANE_SUPPORTED_FEATURES (NETIF_F_HIGHDMA \ + | NETIF_F_HW_CSUM \ @@ -8890,40 +5412,214 @@ + | NETIF_F_FRAGLIST \ + | (NETIF_F_TSO | NETIF_F_TSO6)) +#endif -+ + +-extern bool pn_mq_en; +-extern uint16_t pn_qlimits[NSS_MAX_NUM_PRI]; ++/* ++ * nss_data_plane_param ++ */ ++struct nss_data_plane_param nss_data_plane_params[NSS_DP_MAX_INTERFACES]; + /* - * nss_data_plane_param +- * nss_data_plane_work_function() +- * Work function that gets queued to "install" the data plane overlays ++ * __nss_data_plane_init() */ -@@ -101,6 +117,12 @@ static int __nss_data_plane_mac_addr(str - static int __nss_data_plane_change_mtu(struct nss_dp_data_plane_ctx *dpc, uint32_t mtu) +-static void nss_data_plane_work_function(struct work_struct *work) ++static int __nss_data_plane_init(struct nss_dp_data_plane_ctx *dpc) { - struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; +- int ret; +- struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[NSS_CORE_0]; +- struct nss_top_instance *nss_top = nss_ctx->nss_top; ++ struct net_device *netdev = dpc->dev; ++ netdev->needed_headroom += 32; ++ return NSS_DP_SUCCESS; ++} ++ ++/* ++ * __nss_data_plane_open() ++ * Called by nss-dp to notify open to nss-fw ++ */ ++static int __nss_data_plane_open(struct nss_dp_data_plane_ctx *dpc, uint32_t tx_desc_ring, uint32_t rx_desc_ring, uint32_t mode) ++{ ++ struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; ++ ++ if (dp->notify_open) { ++ return NSS_DP_SUCCESS; ++ } ++ ++ if (nss_phys_if_open(dp->nss_ctx, tx_desc_ring, rx_desc_ring, mode, dp->if_num, dp->bypass_nw_process) == NSS_TX_SUCCESS) { ++ dp->notify_open = 1; ++ return NSS_DP_SUCCESS; ++ } ++ return NSS_DP_FAILURE; ++} ++ ++/* ++ * __nss_data_plane_close() ++ * Called by nss-dp to notify close to nss-fw ++ */ ++static int __nss_data_plane_close(struct nss_dp_data_plane_ctx *dpc) ++{ ++ struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; ++ ++ if (!dp->notify_open) { ++ return NSS_DP_SUCCESS; ++ } ++ ++ if (nss_phys_if_close(dp->nss_ctx, dp->if_num) == NSS_TX_SUCCESS) { ++ dp->notify_open = 0; ++ return NSS_DP_SUCCESS; ++ } ++ return NSS_DP_FAILURE; ++} ++ ++/* ++ * __nss_data_plane_link_state() ++ * Called by nss-dp to notify link state change to nss-fw ++ */ ++static int __nss_data_plane_link_state(struct nss_dp_data_plane_ctx *dpc, uint32_t link_state) ++{ ++ struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; ++ ++ return nss_phys_if_link_state(dp->nss_ctx, link_state, dp->if_num); ++} ++ ++/* ++ * __nss_data_plane_mac_addr() ++ * Called by nss-dp to set mac address ++ */ ++static int __nss_data_plane_mac_addr(struct nss_dp_data_plane_ctx *dpc, uint8_t *addr) ++{ ++ struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; + ++ return nss_phys_if_mac_addr(dp->nss_ctx, addr, dp->if_num); ++} ++ ++/* ++ * __nss_data_plane_change_mtu() ++ * Called by nss-dp to change mtu of a data plane ++ */ ++static int __nss_data_plane_change_mtu(struct nss_dp_data_plane_ctx *dpc, uint32_t mtu) ++{ ++ struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; + + if (mtu > NSS_DP_MAX_MTU_SIZE) { + nss_warning("%px: MTU exceeds MAX size %d\n", dp, mtu); + return NSS_DP_FAILURE; + } + - return nss_phys_if_change_mtu(dp->nss_ctx, mtu, dp->if_num); - } - -@@ -160,9 +182,8 @@ static netdev_tx_t __nss_data_plane_buf( - goto drop; ++ return nss_phys_if_change_mtu(dp->nss_ctx, mtu, dp->if_num); ++} ++ ++/* ++ * __nss_data_plane_pause_on_off() ++ * Called by nss-dp to enable/disable pause frames ++ */ ++static int __nss_data_plane_pause_on_off(struct nss_dp_data_plane_ctx *dpc, uint32_t pause_on) ++{ ++ struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; ++ ++ return nss_phys_if_pause_on_off(dp->nss_ctx, pause_on, dp->if_num); ++} ++ ++#ifdef NSS_DRV_QRFS_ENABLE ++/* ++ * __nss_data_plane_rx_flow_steer() ++ * Called by nss-dp to set flow rule of a data plane ++ */ ++static int __nss_data_plane_rx_flow_steer(struct nss_dp_data_plane_ctx *dpc, struct sk_buff *skb, ++ uint32_t cpu, bool is_add) ++{ ++ if (is_add) { ++ return nss_qrfs_set_flow_rule(skb, cpu, NSS_QRFS_MSG_FLOW_ADD); ++ } ++ ++ return nss_qrfs_set_flow_rule(skb, cpu, NSS_QRFS_MSG_FLOW_DELETE); ++} ++#endif ++ ++/* ++ * __nss_data_plane_deinit() ++ * Place holder for nss-dp ops to free NSS data plane resources ++ */ ++static int __nss_data_plane_deinit(struct nss_dp_data_plane_ctx *dpc) ++{ + /* +- * The queue config command is a synchronous command and needs to be issued +- * in process context, before NSS data plane switch. ++ * TODO: Implement free up of NSS data plane resources + */ +- ret = nss_n2h_update_queue_config_sync(nss_ctx, pn_mq_en, pn_qlimits); +- if (ret != NSS_TX_SUCCESS) { +- nss_warning("Failed to send pnode queue config to core 0\n"); ++ return NSS_TX_SUCCESS; ++} ++ ++/* ++ * __nss_data_plane_buf() ++ * Called by nss-dp to pass a sk_buff for xmit ++ */ ++static netdev_tx_t __nss_data_plane_buf(struct nss_dp_data_plane_ctx *dpc, struct sk_buff *skb) ++{ ++ struct nss_data_plane_param *dp = (struct nss_data_plane_param *)dpc; ++ int extra_head = dpc->dev->needed_headroom - skb_headroom(skb); ++ int extra_tail = 0; ++ nss_tx_status_t status; ++ struct net_device *dev = dpc->dev; ++ ++ if (skb->len < ETH_HLEN) { ++ nss_warning("skb->len ( %u ) < ETH_HLEN ( %u ) \n", skb->len, ETH_HLEN); ++ goto drop; } -- if (skb->len > NSS_DATA_PLANE_MAX_PACKET_LEN) { -- nss_warning("skb->len ( %u ) > Maximum packet length ( %u ) \n", -- skb->len, NSS_DATA_PLANE_MAX_PACKET_LEN); +- nss_top->data_plane_ops->data_plane_register(nss_ctx); + if (skb->len > NSS_DP_MAX_PACKET_LEN) { + nss_warning("skb->len ( %u ) > Maximum packet length ( %u ) \n", skb->len, NSS_DP_MAX_PACKET_LEN); - goto drop; - } - -@@ -207,7 +228,10 @@ drop: - */ - static void __nss_data_plane_set_features(struct nss_dp_data_plane_ctx *dpc) - { -- nss_data_plane_hal_set_features(dpc); ++ goto drop; ++ } ++ ++ if (skb_cloned(skb) || extra_head > 0) { ++ /* ++ * If it is a clone and headroom is already enough, ++ * We just make a copy and clear the clone flag. ++ */ ++ if (extra_head <= 0) ++ extra_head = extra_tail = 0; ++ /* ++ * If tailroom is enough to accommodate the added headroom, ++ * then allocate a buffer of same size and do relocations. ++ * It might help kmalloc_reserve() not double the size. ++ */ ++ if (skb->end - skb->tail >= extra_head) ++ extra_tail = -extra_head; ++ ++ if (pskb_expand_head(skb, extra_head, extra_tail, GFP_ATOMIC)) { ++ nss_warning("%px: Unable to expand skb for headroom\n", dp); ++ goto drop; ++ } ++ } ++ ++ status = nss_phys_if_buf(dp->nss_ctx, skb, dp->if_num); ++ if (likely(status == NSS_TX_SUCCESS)) { ++ return NETDEV_TX_OK; ++ } else if (status == NSS_TX_FAILURE_QUEUE) { ++ return NETDEV_TX_BUSY; ++ } ++ ++drop: ++ dev_kfree_skb_any(skb); ++ dev->stats.tx_dropped++; ++ ++ return NETDEV_TX_OK; ++} ++ ++/* ++ * __nss_data_plane_set_features() ++ * Called by nss-dp to allow data plane to modify the set of features it supports ++ */ ++static void __nss_data_plane_set_features(struct nss_dp_data_plane_ctx *dpc) ++{ + dpc->dev->features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; + dpc->dev->hw_features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; + dpc->dev->vlan_features |= NSS_DATA_PLANE_SUPPORTED_FEATURES; @@ -8931,70 +5627,1586 @@ } /* ---- a/nss_data_plane/nss_data_plane_common.c -+++ b/nss_data_plane/nss_data_plane_common.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2016,2020-2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2016,2020 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. -@@ -39,16 +39,9 @@ static void nss_data_plane_work_function - */ - ret = nss_n2h_update_queue_config_sync(nss_ctx, pn_mq_en, pn_qlimits); - if (ret != NSS_TX_SUCCESS) { -- nss_warning("%px: Failed to send pnode queue config to core 0\n", nss_ctx); -- goto data_plane_reg; -+ nss_warning("Failed to send pnode queue config to core 0\n"); +- * nss_data_plane_schedule_registration() +- * Called from nss_init to schedule a work to do data_plane register to data plane host ++ * nss offload data plane ops + */ +-bool nss_data_plane_schedule_registration(void) ++static struct nss_dp_data_plane_ops dp_ops = { ++ .init = __nss_data_plane_init, ++ .open = __nss_data_plane_open, ++ .close = __nss_data_plane_close, ++ .link_state = __nss_data_plane_link_state, ++ .mac_addr = __nss_data_plane_mac_addr, ++ .change_mtu = __nss_data_plane_change_mtu, ++ .xmit = __nss_data_plane_buf, ++ .set_features = __nss_data_plane_set_features, ++ .pause_on_off = __nss_data_plane_pause_on_off, ++#ifdef NSS_DRV_QRFS_ENABLE ++ .rx_flow_steer = __nss_data_plane_rx_flow_steer, ++#endif ++ .deinit = __nss_data_plane_deinit, ++}; ++ ++/* ++ * nss_data_plane_register_to_nss_dp() ++ */ ++static bool nss_data_plane_register_to_nss_dp(struct nss_ctx_instance *nss_ctx, int if_num) + { +- if (!queue_work_on(1, nss_data_plane_workqueue, &nss_data_plane_work.work)) { +- nss_warning("Failed to register data plane workqueue on core 1\n"); ++ struct nss_data_plane_param *ndpp = &nss_data_plane_params[if_num]; ++ struct nss_top_instance *nss_top = nss_ctx->nss_top; ++ struct net_device *netdev; ++ bool is_open; ++ int core; ++ ++ netdev = nss_dp_get_netdev_by_nss_if_num(if_num); ++ if (!netdev) { ++ nss_info("%px: Platform don't have data plane%d enabled, \ ++ don't bring up nss_phys_if and don't register to nss-dp\n", ++ nss_ctx, if_num); + return false; } -- ret = nss_project_pri_mq_map_configure(nss_ctx); -- if (ret != NSS_TX_SUCCESS) { -- nss_warning("%px: Failed to send pnode priority to multi-queue config to core 0\n", nss_ctx); -- } -- --data_plane_reg: - nss_top->data_plane_ops->data_plane_register(nss_ctx); +- nss_info("Register data plane workqueue on core 1\n"); ++ is_open = nss_dp_is_in_open_state(netdev); ++ ndpp->dpc.dev = netdev; ++ ndpp->nss_ctx = nss_ctx; ++ ndpp->if_num = if_num; ++ ndpp->notify_open = 0; ++ ndpp->features = 0; ++ ++ /* ++ * Add data plane ops applicable to this SoC. ++ */ ++ nss_data_plane_hal_add_dp_ops(&dp_ops); ++ ++ /* ++ * Check if NSS NW processing to be bypassed for this data plane ++ */ ++ if (nss_skip_nw_process) { ++ ndpp->bypass_nw_process = 1; ++ } else { ++ ndpp->bypass_nw_process = 0; ++ } ++ ++ if (nss_dp_override_data_plane(netdev, &dp_ops, (struct nss_dp_data_plane_ctx *)ndpp) != NSS_DP_SUCCESS) { ++ nss_info("%px: Override nss-dp data plane for port %dfailed\n", nss_ctx, if_num); ++ return false; ++ } ++ ++ /* ++ * Setup the receive callback so that data pkts received form NSS-FW will ++ * be redirected to the nss-dp driver as we are overriding the data plane ++ */ ++ nss_top->phys_if_handler_id[if_num] = nss_ctx->id; ++ nss_phys_if_register_handler(nss_ctx, if_num); ++ ++ /* ++ * Packets recieved on physical interface can be exceptioned to HLOS ++ * from any NSS core so we need to register data plane for all ++ */ ++ for (core = 0; core < nss_top->num_nss; core++) { ++ nss_core_register_subsys_dp(&nss_top->nss[core], if_num, nss_dp_receive, NULL, NULL, netdev, ndpp->features); ++ } ++ ++ /* ++ * Now we are registered and our side is ready, if the data plane was opened, ask it to start again ++ */ ++ if (is_open) { ++ nss_dp_start_data_plane(netdev, (struct nss_dp_data_plane_ctx *)ndpp); ++ } + return true; } ---- a/nss_data_plane/nss_data_plane_gmac.c -+++ b/nss_data_plane/nss_data_plane_gmac.c -@@ -20,7 +20,7 @@ - #include "nss_tx_rx_common.h" - #include - --#define NSS_DP_GMAC_SUPPORTED_FEATURES (NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_FRAGLIST | (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)) -+#define NSS_DP_GMAC_SUPPORTED_FEATURES (NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_FRAGLIST | (NETIF_F_TSO | NETIF_F_TSO6)) - #define NSS_DATA_PLANE_GMAC_MAX_INTERFACES 4 - - static DEFINE_SPINLOCK(nss_data_plane_gmac_stats_lock); ---- a/nss_dma.c -+++ b/nss_dma.c -@@ -128,7 +128,7 @@ static void nss_dma_msg_handler(struct n - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data; -+ ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; + /* +- * nss_data_plane_init_delay_work() ++ * nss_data_plane_unregister_from_nss_dp() ++ */ ++static void nss_data_plane_unregister_from_nss_dp(int if_num) ++{ ++ /* ++ * Do any SoC specific un-registrations. ++ */ ++ nss_data_plane_hal_unregister(nss_data_plane_params[if_num].nss_ctx); ++ ++ nss_dp_restore_data_plane(nss_data_plane_params[if_num].dpc.dev); ++ nss_data_plane_params[if_num].dpc.dev = NULL; ++ nss_data_plane_params[if_num].nss_ctx = NULL; ++ nss_data_plane_params[if_num].if_num = 0; ++ nss_data_plane_params[if_num].notify_open = 0; ++ nss_data_plane_params[if_num].bypass_nw_process = 0; ++} ++ ++/* ++ * __nss_data_plane_register() + */ +-int nss_data_plane_init_delay_work(void) ++static void __nss_data_plane_register(struct nss_ctx_instance *nss_ctx) + { +- nss_data_plane_workqueue = create_singlethread_workqueue("nss_data_plane_workqueue"); +- if (!nss_data_plane_workqueue) { +- nss_warning("Can't allocate workqueue\n"); +- return -ENOMEM; ++ int i; ++ ++ for (i = NSS_DP_START_IFNUM; i < NSS_DP_MAX_INTERFACES; i++) { ++ if (!nss_data_plane_register_to_nss_dp(nss_ctx, i)) { ++ nss_warning("%px: Register data plane failed for data plane %d\n", nss_ctx, i); ++ } else { ++ nss_info("%px: Register data plan to data plane %d success\n", nss_ctx, i); ++ } } - /* ---- a/nss_dma_stats.h -+++ b/nss_dma_stats.h -@@ -1,6 +1,6 @@ +- INIT_DELAYED_WORK(&nss_data_plane_work, nss_data_plane_work_function); +- return 0; ++ /* ++ * Do any SoC specific registrations. ++ */ ++ nss_data_plane_hal_register(nss_ctx); + } + /* - ****************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. +- * nss_data_plane_destroy_delay_work() ++ * __nss_data_plane_unregister() + */ +-void nss_data_plane_destroy_delay_work(void) ++static void __nss_data_plane_unregister(void) + { +- destroy_workqueue(nss_data_plane_workqueue); ++ int i, core; ++ ++ for (core = 0; core < nss_top_main.num_nss; core++) { ++ for (i = NSS_DP_START_IFNUM; i < NSS_DP_MAX_INTERFACES; i++) { ++ if (nss_top_main.nss[core].subsys_dp_register[i].ndev) { ++ nss_data_plane_unregister_from_nss_dp(i); ++ nss_core_unregister_subsys_dp(&nss_top_main.nss[core], i); ++ } ++ } ++ } ++} ++ ++/* ++ * __nss_data_plane_stats_sync() ++ */ ++static void __nss_data_plane_stats_sync(struct nss_phys_if_stats *stats, uint16_t interface) ++{ ++ nss_data_plane_hal_stats_sync(&nss_data_plane_params[interface], stats); + } ++ ++/* ++ * __nss_data_plane_get_mtu_sz() ++ */ ++static uint16_t __nss_data_plane_get_mtu_sz(uint16_t mtu) ++{ ++ return nss_data_plane_hal_get_mtu_sz(mtu); ++} ++ ++/* ++ * nss_data_plane_ops ++ */ ++struct nss_data_plane_ops nss_data_plane_ops = { ++ .data_plane_register = &__nss_data_plane_register, ++ .data_plane_unregister = &__nss_data_plane_unregister, ++ .data_plane_stats_sync = &__nss_data_plane_stats_sync, ++ .data_plane_get_mtu_sz = &__nss_data_plane_get_mtu_sz, ++}; +--- /dev/null ++++ b/nss_data_plane/nss_data_plane_common.c +@@ -0,0 +1,84 @@ ++/* ++ ************************************************************************** ++ * Copyright (c) 2014-2016,2020 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_data_plane.h" ++#include "nss_core.h" ++ ++static struct delayed_work nss_data_plane_work; ++static struct workqueue_struct *nss_data_plane_workqueue; ++ ++extern bool pn_mq_en; ++extern uint16_t pn_qlimits[NSS_MAX_NUM_PRI]; ++ ++/* ++ * nss_data_plane_work_function() ++ * Work function that gets queued to "install" the data plane overlays ++ */ ++static void nss_data_plane_work_function(struct work_struct *work) ++{ ++ int ret; ++ struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[NSS_CORE_0]; ++ struct nss_top_instance *nss_top = nss_ctx->nss_top; ++ ++ /* ++ * The queue config command is a synchronous command and needs to be issued ++ * in process context, before NSS data plane switch. ++ */ ++ ret = nss_n2h_update_queue_config_sync(nss_ctx, pn_mq_en, pn_qlimits); ++ if (ret != NSS_TX_SUCCESS) { ++ nss_warning("Failed to send pnode queue config to core 0\n"); ++ } ++ ++ nss_top->data_plane_ops->data_plane_register(nss_ctx); ++} ++ ++/* ++ * nss_data_plane_schedule_registration() ++ * Called from nss_init to schedule a work to do data_plane register to data plane host ++ */ ++bool nss_data_plane_schedule_registration(void) ++{ ++ if (!queue_work_on(1, nss_data_plane_workqueue, &nss_data_plane_work.work)) { ++ nss_warning("Failed to register data plane workqueue on core 1\n"); ++ return false; ++ } ++ ++ nss_info("Register data plane workqueue on core 1\n"); ++ return true; ++} ++ ++/* ++ * nss_data_plane_init_delay_work() ++ */ ++int nss_data_plane_init_delay_work(void) ++{ ++ nss_data_plane_workqueue = create_singlethread_workqueue("nss_data_plane_workqueue"); ++ if (!nss_data_plane_workqueue) { ++ nss_warning("Can't allocate workqueue\n"); ++ return -ENOMEM; ++ } ++ ++ INIT_DELAYED_WORK(&nss_data_plane_work, nss_data_plane_work_function); ++ return 0; ++} ++ ++/* ++ * nss_data_plane_destroy_delay_work() ++ */ ++void nss_data_plane_destroy_delay_work(void) ++{ ++ destroy_workqueue(nss_data_plane_workqueue); ++} +--- a/nss_data_plane/nss_data_plane_edma.c ++++ /dev/null +@@ -1,425 +0,0 @@ +-/* +- ************************************************************************** +- * Copyright (c) 2016-2020, 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_data_plane.h" +-#include "nss_core.h" +-#include "nss_tx_rx_common.h" +-#include +- +-#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)) +-#define NSS_DP_EDMA_SUPPORTED_FEATURES (NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_FRAGLIST | (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)) +-#else +-#define NSS_DP_EDMA_SUPPORTED_FEATURES (NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_FRAGLIST | (NETIF_F_TSO | NETIF_F_TSO6)) +-#endif +-#define NSS_DATA_PLANE_EDMA_MAX_INTERFACES 6 +-#define NSS_DATA_PLANE_EDMA_MAX_MTU_SIZE 9216 +-#define NSS_DATA_PLANE_EDMA_PREHEADER_SIZE 32 +-#define NSS_DATA_PLANE_EDMA_MAX_PACKET_LEN 65535 +- +-/* +- * nss_data_plane_edma_param +- */ +-struct nss_data_plane_edma_param { +- struct nss_dp_data_plane_ctx dpc; /* data plane ctx base class */ +- int if_num; /* physical interface number */ +- struct nss_ctx_instance *nss_ctx; /* which nss core */ +- int notify_open; /* This data plane interface has been opened or not */ +- uint32_t features; /* skb types supported by this interface */ +- uint32_t bypass_nw_process; /* Do we want to bypass NW processing in NSS for this data plane? */ +-} nss_data_plane_edma_params[NSS_DATA_PLANE_EDMA_MAX_INTERFACES + 1]; +- +-/* +- * __nss_data_plane_init() +- */ +-static int __nss_data_plane_init(struct nss_dp_data_plane_ctx *dpc) +-{ +- struct net_device *netdev = dpc->dev; +- netdev->needed_headroom += 32; +- return NSS_DP_SUCCESS; +-} +- +-/* +- * __nss_data_plane_open() +- * Called by nss-dp to notify open to nss-fw +- */ +-static int __nss_data_plane_open(struct nss_dp_data_plane_ctx *dpc, uint32_t tx_desc_ring, uint32_t rx_desc_ring, uint32_t mode) +-{ +- struct nss_data_plane_edma_param *dp = (struct nss_data_plane_edma_param *)dpc; +- +- if (dp->notify_open) { +- return NSS_DP_SUCCESS; +- } +- if (nss_phys_if_open(dp->nss_ctx, tx_desc_ring, rx_desc_ring, mode, dp->if_num, dp->bypass_nw_process) == NSS_TX_SUCCESS) { +- dp->notify_open = 1; +- return NSS_DP_SUCCESS; +- } +- return NSS_DP_FAILURE; +-} +- +-/* +- * __nss_data_plane_close() +- * Called by nss-dp to notify close to nss-fw +- */ +-static int __nss_data_plane_close(struct nss_dp_data_plane_ctx *dpc) +-{ +- struct nss_data_plane_edma_param *dp = (struct nss_data_plane_edma_param *)dpc; +- +- if (!dp->notify_open) { +- return NSS_DP_SUCCESS; +- } +- if (nss_phys_if_close(dp->nss_ctx, dp->if_num) == NSS_TX_SUCCESS) { +- dp->notify_open = 0; +- return NSS_DP_SUCCESS; +- } +- return NSS_DP_FAILURE; +-} +- +-/* +- * __nss_data_plane_link_state() +- * Called by nss-dp to notify link state change to nss-fw +- */ +-static int __nss_data_plane_link_state(struct nss_dp_data_plane_ctx *dpc, uint32_t link_state) +-{ +- struct nss_data_plane_edma_param *dp = (struct nss_data_plane_edma_param *)dpc; +- +- return nss_phys_if_link_state(dp->nss_ctx, link_state, dp->if_num); +-} +- +-/* +- * __nss_data_plane_mac_addr() +- * Called by nss-dp to set mac address +- */ +-static int __nss_data_plane_mac_addr(struct nss_dp_data_plane_ctx *dpc, uint8_t *addr) +-{ +- struct nss_data_plane_edma_param *dp = (struct nss_data_plane_edma_param *)dpc; +- +- return nss_phys_if_mac_addr(dp->nss_ctx, addr, dp->if_num); +-} +- +-/* +- * __nss_data_plane_change_mtu() +- * Called by nss-dp to change mtu of a data plane +- */ +-static int __nss_data_plane_change_mtu(struct nss_dp_data_plane_ctx *dpc, uint32_t mtu) +-{ +- struct nss_data_plane_edma_param *dp = (struct nss_data_plane_edma_param *)dpc; +- +- if (mtu > NSS_DATA_PLANE_EDMA_MAX_MTU_SIZE) { +- nss_warning("%p: MTU exceeds MAX size %d\n", dp, mtu); +- return NSS_DP_FAILURE; +- } +- +- return nss_phys_if_change_mtu(dp->nss_ctx, mtu, dp->if_num); +-} +- +-/* +- * __nss_data_plane_pause_on_off() +- * Called by nss-dp to enable/disable pause frames +- */ +-static int __nss_data_plane_pause_on_off(struct nss_dp_data_plane_ctx *dpc, uint32_t pause_on) +-{ +- struct nss_data_plane_edma_param *dp = (struct nss_data_plane_edma_param *)dpc; +- +- return nss_phys_if_pause_on_off(dp->nss_ctx, pause_on, dp->if_num); +-} +- +-/* +- * __nss_data_plane_vsi_assign() +- * Called by nss-dp to assign vsi of a data plane +- */ +-static int __nss_data_plane_vsi_assign(struct nss_dp_data_plane_ctx *dpc, uint32_t vsi) +-{ +- struct nss_data_plane_edma_param *dp = (struct nss_data_plane_edma_param *)dpc; +- +- return nss_phys_if_vsi_assign(dp->nss_ctx, vsi, dp->if_num); +-} +- +-/* +- * __nss_data_plane_vsi_unassign() +- * Called by nss-dp to unassign vsi of a data plane +- */ +-static int __nss_data_plane_vsi_unassign(struct nss_dp_data_plane_ctx *dpc, uint32_t vsi) +-{ +- struct nss_data_plane_edma_param *dp = (struct nss_data_plane_edma_param *)dpc; +- +- return nss_phys_if_vsi_unassign(dp->nss_ctx, vsi, dp->if_num); +-} +- +-#ifdef NSS_DRV_QRFS_ENABLE +-/* +- * __nss_data_plane_rx_flow_steer() +- * Called by nss-dp to set flow rule of a data plane +- */ +-static int __nss_data_plane_rx_flow_steer(struct nss_dp_data_plane_ctx *dpc, struct sk_buff *skb, +- uint32_t cpu, bool is_add) +-{ +- if (is_add) { +- return nss_qrfs_set_flow_rule(skb, cpu, NSS_QRFS_MSG_FLOW_ADD); +- } +- +- return nss_qrfs_set_flow_rule(skb, cpu, NSS_QRFS_MSG_FLOW_DELETE); +-} +-#endif +- +-/* +- * __nss_data_plane_deinit() +- * Place holder for nss-dp ops to free NSS data plane resources +- */ +-static int __nss_data_plane_deinit(struct nss_dp_data_plane_ctx *dpc) +-{ +- /* +- * TODO: Implement free up of NSS data plane resources +- */ +- return NSS_TX_SUCCESS; +-} +- +-/* +- * __nss_data_plane_buf() +- * Called by nss-dp to pass a sk_buff for xmit +- */ +-static netdev_tx_t __nss_data_plane_buf(struct nss_dp_data_plane_ctx *dpc, struct sk_buff *skb) +-{ +- struct nss_data_plane_edma_param *dp = (struct nss_data_plane_edma_param *)dpc; +- int extra_head = dpc->dev->needed_headroom - skb_headroom(skb); +- int extra_tail = 0; +- nss_tx_status_t status; +- struct net_device *dev = dpc->dev; +- +- if (skb->len < ETH_HLEN) { +- nss_warning("skb->len ( %u ) < ETH_HLEN ( %u ) \n", skb->len, ETH_HLEN); +- goto drop; +- } +- +- if (skb->len > NSS_DATA_PLANE_EDMA_MAX_PACKET_LEN) { +- nss_warning("skb->len ( %u ) > Maximum packet length ( %u ) \n", skb->len, NSS_DATA_PLANE_EDMA_MAX_PACKET_LEN); +- goto drop; +- } +- +- if (skb_cloned(skb) || extra_head > 0) { +- /* +- * If it is a clone and headroom is already enough, +- * We just make a copy and clear the clone flag. +- */ +- if (extra_head <= 0) +- extra_head = extra_tail = 0; +- /* +- * If tailroom is enough to accommodate the added headroom, +- * then allocate a buffer of same size and do relocations. +- * It might help kmalloc_reserve() not double the size. +- */ +- if (skb->end - skb->tail >= extra_head) +- extra_tail = -extra_head; +- +- if (pskb_expand_head(skb, extra_head, extra_tail, GFP_ATOMIC)) { +- nss_warning("%p: Unable to expand skb for headroom\n", dp); +- goto drop; +- } +- } +- +- status = nss_phys_if_buf(dp->nss_ctx, skb, dp->if_num); +- if (likely(status == NSS_TX_SUCCESS)) { +- return NETDEV_TX_OK; +- } else if (status == NSS_TX_FAILURE_QUEUE) { +- return NETDEV_TX_BUSY; +- } +- +-drop: +- dev_kfree_skb_any(skb); +- dev->stats.tx_dropped++; +- +- return NETDEV_TX_OK; +-} +- +-/* +- * __nss_data_plane_set_features() +- * Called by nss-dp to allow data plane to modify the set of features it supports +-*/ +-static void __nss_data_plane_set_features(struct nss_dp_data_plane_ctx *dpc) +-{ +- dpc->dev->features |= NSS_DP_EDMA_SUPPORTED_FEATURES; +- dpc->dev->hw_features |= NSS_DP_EDMA_SUPPORTED_FEATURES; +- dpc->dev->vlan_features |= NSS_DP_EDMA_SUPPORTED_FEATURES; +- dpc->dev->wanted_features |= NSS_DP_EDMA_SUPPORTED_FEATURES; +-} +- +-/* +- * nss offload data plane ops +- */ +-static struct nss_dp_data_plane_ops dp_ops = { +- .init = __nss_data_plane_init, +- .open = __nss_data_plane_open, +- .close = __nss_data_plane_close, +- .link_state = __nss_data_plane_link_state, +- .mac_addr = __nss_data_plane_mac_addr, +- .change_mtu = __nss_data_plane_change_mtu, +- .xmit = __nss_data_plane_buf, +- .set_features = __nss_data_plane_set_features, +- .pause_on_off = __nss_data_plane_pause_on_off, +- .vsi_assign = __nss_data_plane_vsi_assign, +- .vsi_unassign = __nss_data_plane_vsi_unassign, +-#ifdef NSS_DRV_QRFS_ENABLE +- .rx_flow_steer = __nss_data_plane_rx_flow_steer, +-#endif +- .deinit = __nss_data_plane_deinit, +-}; +- +-/* +- * nss_data_plane_register_to_nss_dp() +- */ +-static bool nss_data_plane_register_to_nss_dp(struct nss_ctx_instance *nss_ctx, int if_num) +-{ +- struct nss_data_plane_edma_param *ndpp = &nss_data_plane_edma_params[if_num]; +- struct nss_top_instance *nss_top = nss_ctx->nss_top; +- struct net_device *netdev; +- bool is_open; +- int core; +- +- netdev = nss_dp_get_netdev_by_macid(if_num); +- if (!netdev) { +- nss_info("%p: Platform don't have data plane%d enabled, don't bring up nss_phys_if and don't register to nss-dp\n", nss_ctx, if_num); +- return false; +- } +- +- is_open = nss_dp_is_in_open_state(netdev); +- ndpp->dpc.dev = netdev; +- ndpp->nss_ctx = nss_ctx; +- ndpp->if_num = if_num; +- ndpp->notify_open = 0; +- ndpp->features = 0; +- +- /* +- * Check if NSS NW processing to be bypassed for this data plane +- */ +- if (nss_skip_nw_process) { +- ndpp->bypass_nw_process = 1; +- } else { +- ndpp->bypass_nw_process = 0; +- } +- +- if (nss_dp_override_data_plane(netdev, &dp_ops, (struct nss_dp_data_plane_ctx *)ndpp) != NSS_DP_SUCCESS) { +- nss_info("%p: Override nss-dp data plane for port %dfailed\n", nss_ctx, if_num); +- return false; +- } +- +- /* +- * Setup the receive callback so that data pkts received form NSS-FW will +- * be redirected to the nss-dp driver as we are overriding the data plane +- */ +- nss_top->phys_if_handler_id[if_num] = nss_ctx->id; +- nss_phys_if_register_handler(nss_ctx, if_num); +- +- /* +- * Packets recieved on physical interface can be exceptioned to HLOS +- * from any NSS core so we need to register data plane for all +- */ +- for (core = 0; core < nss_top->num_nss; core++) { +- nss_core_register_subsys_dp(&nss_top->nss[core], if_num, nss_dp_receive, NULL, NULL, netdev, ndpp->features); +- } +- +- /* +- * Now we are registered and our side is ready, if the data plane was opened, ask it to start again +- */ +- if (is_open) { +- nss_dp_start_data_plane(netdev, (struct nss_dp_data_plane_ctx *)ndpp); +- } +- return true; +-} +- +-/* +- * nss_data_plane_unregister_from_nss_dp() +- */ +-static void nss_data_plane_unregister_from_nss_dp(int if_num) +-{ +- nss_cmn_unregister_service_code(nss_data_plane_edma_params[if_num].nss_ctx, +- nss_phy_tstamp_rx_buf, NSS_PTP_EVENT_SERVICE_CODE); +- nss_dp_restore_data_plane(nss_data_plane_edma_params[if_num].dpc.dev); +- nss_data_plane_edma_params[if_num].dpc.dev = NULL; +- nss_data_plane_edma_params[if_num].nss_ctx = NULL; +- nss_data_plane_edma_params[if_num].if_num = 0; +- nss_data_plane_edma_params[if_num].notify_open = 0; +- nss_data_plane_edma_params[if_num].bypass_nw_process = 0; +-} +- +-/* +- * __nss_data_plane_register() +- */ +-static void __nss_data_plane_register(struct nss_ctx_instance *nss_ctx) +-{ +- int i; +- +- for (i = 1; i < NSS_DATA_PLANE_EDMA_MAX_INTERFACES + 1; i++) { +- if (!nss_data_plane_register_to_nss_dp(nss_ctx, i)) { +- nss_warning("%p: Register data plane failed for data plane %d\n", nss_ctx, i); +- } else { +- nss_info("%p: Register data plan to data plane %d success\n", nss_ctx, i); +- } +- } +- +- /* +- * Packets with the ptp service code should be delivered to PHY driver for timestamping +- */ +- nss_cmn_register_service_code(nss_ctx, nss_phy_tstamp_rx_buf, +- NSS_PTP_EVENT_SERVICE_CODE, nss_ctx); +- +-} +- +-/* +- * __nss_data_plane_unregister() +- */ +-static void __nss_data_plane_unregister(void) +-{ +- int i, core; +- +- for (core = 0; core < nss_top_main.num_nss; core++) { +- for (i = 1; i < NSS_DATA_PLANE_EDMA_MAX_INTERFACES + 1; i++) { +- if (nss_top_main.nss[core].subsys_dp_register[i].ndev) { +- nss_data_plane_unregister_from_nss_dp(i); +- nss_core_unregister_subsys_dp(&nss_top_main.nss[core], i); +- } +- } +- } +-} +- +-/* +- * __nss_data_plane_stats_sync() +- */ +-static void __nss_data_plane_stats_sync(struct nss_phys_if_stats *stats, uint16_t interface) +-{ +- /* +- * EDMA does not pass sync interface stats through phys_if_stats +- */ +-} +- +-/* +- * __nss_data_plane_get_mtu_sz() +- */ +-static uint16_t __nss_data_plane_get_mtu_sz(uint16_t mtu) +-{ +- /* +- * Reserve space for preheader +- */ +- return mtu + NSS_DATA_PLANE_EDMA_PREHEADER_SIZE; +-} +- +-/* +- * nss_data_plane_edma_ops +- */ +-struct nss_data_plane_ops nss_data_plane_edma_ops = { +- .data_plane_register = &__nss_data_plane_register, +- .data_plane_unregister = &__nss_data_plane_unregister, +- .data_plane_stats_sync = &__nss_data_plane_stats_sync, +- .data_plane_get_mtu_sz = &__nss_data_plane_get_mtu_sz, +-}; +--- /dev/null ++++ b/nss_dma.c +@@ -0,0 +1,501 @@ ++/* ++ ************************************************************************** ++ * Copyright (c) 2020-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. ++ ************************************************************************** ++ */ ++ ++/* ++ * nss_dma.c ++ * NSS DMA APIs ++ */ ++ ++#include ++#include "nss_dma_stats.h" ++#include "nss_dma_log.h" ++#include "nss_dma_strings.h" ++ ++/* ++ * Test configuration value ++ */ ++struct nss_dma_test_cfg_val { ++ int val; /* field value */ ++ int min; /* Minimum value */ ++ int max; /* Maximum value */ ++}; ++ ++/* ++ * Test configuration for user ++ */ ++struct nss_dma_test_cfg_user { ++ struct nss_dma_test_cfg_val run; /* test run state */ ++ struct nss_dma_test_cfg_val code; /* test run code */ ++ struct nss_dma_test_cfg_val type; /* test type code */ ++ struct nss_dma_test_cfg_val packets; /* packet count per loop */ ++ int result_tx_packets; /* test results TX packets */ ++ int result_rx_packets; /* test result RX packets */ ++ int result_time; /* test time */ ++}; ++ ++static struct nss_dma_test_cfg_user test_cfg = { ++ .run = {.val = 0, .min = 0 /* stopped */, .max = 1 /* running */}, ++ .code = {.val = 1, .min = 1 /* linearize */, .max = 2 /* split */}, ++ .type = {.val = NSS_DMA_TEST_TYPE_DEFAULT, .min = NSS_DMA_TEST_TYPE_DEFAULT, .max = NSS_DMA_TEST_TYPE_MAX}, ++ .packets = {.val = 1, .min = 1, .max = 65536}, ++}; ++ ++/* ++ * Private data structure. ++ */ ++struct nss_dma_pvt { ++ struct semaphore sem; /* Semaphore structure. */ ++ struct completion complete; /* Completion structure. */ ++ int response; /* Response from FW. */ ++ void *cb; /* Original cb for sync msgs. */ ++ void *app_data; /* Original app_data for sync msgs. */ ++}; ++ ++static struct nss_dma_pvt nss_dma_cfg_pvt; ++ ++/* ++ * nss_dma_verify_if_num() ++ * Verify if_num passed to us. ++ */ ++static inline bool nss_dma_verify_if_num(uint32_t if_num) ++{ ++ return if_num == NSS_DMA_INTERFACE; ++} ++ ++/* ++ * nss_dma_interface_handler() ++ * Handle NSS -> HLOS messages for DMA Statistics ++ */ ++static void nss_dma_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, ++ __attribute__((unused))void *app_data) ++{ ++ struct nss_dma_msg *ndm = (struct nss_dma_msg *)ncm; ++ nss_dma_msg_callback_t cb; ++ ++ if (!nss_dma_verify_if_num(ncm->interface)) { ++ nss_warning("%px: invalid interface %d for dma\n", nss_ctx, ncm->interface); ++ return; ++ } ++ ++ /* ++ * Is this a valid request/response packet? ++ */ ++ if (ncm->type >= NSS_DMA_MSG_TYPE_MAX) { ++ nss_warning("%px: received invalid message %d for dma", nss_ctx, ncm->type); ++ return; ++ } ++ ++ if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_dma_msg)) { ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ return; ++ } ++ ++ /* ++ * Trace messages. ++ */ ++ nss_dma_log_rx_msg(ndm); ++ ++ /* ++ * Log failures ++ */ ++ nss_core_log_msg_failures(nss_ctx, ncm); ++ ++ /* ++ * Update driver statistics and send statistics notifications to the registered modules. ++ */ ++ if (ndm->cm.type == NSS_DMA_MSG_TYPE_SYNC_STATS) { ++ nss_dma_stats_sync(nss_ctx, &ndm->msg.stats); ++ nss_dma_stats_notify(nss_ctx); ++ } ++ ++ /* ++ * Update the callback and app_data for NOTIFY messages ++ */ ++ if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); ++ ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; ++ } ++ ++ /* ++ * Do we have a callback? ++ */ ++ if (!ncm->cb) { ++ return; ++ } ++ ++ /* ++ * callback ++ */ ++ cb = (nss_dma_msg_callback_t)ncm->cb; ++ cb((void *)ncm->app_data, ncm); ++} ++ ++/* ++ * nss_dma_register_handler() ++ * Register handler for messaging ++ */ ++void nss_dma_register_handler(void) ++{ ++ struct nss_ctx_instance *nss_ctx = nss_dma_get_context(); ++ ++ nss_info("%px: nss_dma_register_handler", nss_ctx); ++ nss_core_register_handler(nss_ctx, NSS_DMA_INTERFACE, nss_dma_msg_handler, NULL); ++ ++ nss_dma_stats_dentry_create(); ++ nss_dma_strings_dentry_create(); ++} ++EXPORT_SYMBOL(nss_dma_register_handler); ++ ++/* ++ * nss_dma_tx_msg() ++ * Transmit an dma message to the FW with a specified size. ++ */ ++nss_tx_status_t nss_dma_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_dma_msg *ndm) ++{ ++ struct nss_cmn_msg *ncm = &ndm->cm; ++ ++ /* ++ * Sanity check the message ++ */ ++ if (!nss_dma_verify_if_num(ncm->interface)) { ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); ++ return NSS_TX_FAILURE; ++ } ++ ++ if (ncm->type >= NSS_DMA_MSG_TYPE_MAX) { ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); ++ return NSS_TX_FAILURE; ++ } ++ ++ /* ++ * Trace messages. ++ */ ++ nss_dma_log_tx_msg(ndm); ++ ++ return nss_core_send_cmd(nss_ctx, ndm, sizeof(*ndm), NSS_NBUF_PAYLOAD_SIZE); ++} ++EXPORT_SYMBOL(nss_dma_tx_msg); ++ ++/* ++ * nss_dma_msg_test_callback() ++ * Callback function for dma test start configuration ++ */ ++static void nss_dma_msg_test_callback(void *app_data, struct nss_cmn_msg *ncm) ++{ ++ struct nss_ctx_instance *nss_ctx __attribute__((unused)) = (struct nss_ctx_instance *)app_data; ++ struct nss_dma_msg *ndm = (struct nss_dma_msg *)ncm; ++ struct nss_dma_test_cfg *ndtc = &ndm->msg.test_cfg; ++ struct nss_cmn_node_stats *ncns = &ndtc->node_stats; ++ ++ test_cfg.run.val = 0; /* test completed */ ++ ++ /* ++ * Test start has been failed. Restore the value to initial state. ++ */ ++ if (ndm->cm.response != NSS_CMN_RESPONSE_ACK) { ++ nss_warning("%px: nss dma test failed: %d \n", nss_ctx, ndm->cm.error); ++ test_cfg.result_tx_packets = 0; ++ test_cfg.result_rx_packets = 0; ++ test_cfg.result_time = 0; ++ return; ++ } ++ ++ test_cfg.result_tx_packets = ncns->tx_packets; ++ test_cfg.result_rx_packets = ncns->rx_packets; ++ test_cfg.result_time = ndtc->time_delta; ++ ++ nss_info("%px: nss dma test complete\n", nss_ctx); ++ nss_info("%px: results tx=%u, rx=%u, time=%u\n", ndm, ncns->tx_packets, ncns->rx_packets, ndtc->time_delta); ++} ++ ++/* ++ * nss_dma_msg_test() ++ * Send NSS DMA test start message. ++ */ ++static nss_tx_status_t nss_dma_msg_test(struct nss_ctx_instance *nss_ctx) ++{ ++ struct nss_dma_msg ndm; ++ uint32_t flags = 0; ++ int32_t status; ++ size_t len; ++ ++ len = sizeof(struct nss_cmn_msg) + sizeof(struct nss_dma_test_cfg); ++ ++ nss_info("%px: DMA test message:%x\n", nss_ctx, test_cfg.run.val); ++ if (test_cfg.code.val == 1) { ++ flags = NSS_DMA_TEST_FLAGS_LINEARIZE; ++ } ++ ++ nss_dma_msg_init(&ndm, NSS_DMA_INTERFACE, NSS_DMA_MSG_TYPE_TEST_PERF, len, nss_dma_msg_test_callback, nss_ctx); ++ ++ ndm.msg.test_cfg.packet_count = test_cfg.packets.val; ++ ndm.msg.test_cfg.type = test_cfg.type.val; ++ ndm.msg.test_cfg.flags = flags; ++ ++ status = nss_dma_tx_msg(nss_ctx, &ndm); ++ if (unlikely(status != NSS_TX_SUCCESS)) { ++ return status; ++ } ++ ++ /* ++ * Test is now running ++ */ ++ test_cfg.run.val = 1; ++ return NSS_TX_SUCCESS; ++} ++ ++/* ++ * nss_dma_msg_init() ++ * Initialize DMA message. ++ */ ++void nss_dma_msg_init(struct nss_dma_msg *ndm, uint16_t if_num, uint32_t type, uint32_t len, nss_dma_msg_callback_t cb, ++ void *app_data) ++{ ++ nss_cmn_msg_init(&ndm->cm, if_num, type, len, (void *)cb, app_data); ++} ++EXPORT_SYMBOL(nss_dma_msg_init); ++ ++/* ++ * nss_crypto_cmn_get_context() ++ * get NSS context instance for crypto handle ++ */ ++struct nss_ctx_instance *nss_dma_get_context(void) ++{ ++ return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.dma_handler_id]; ++} ++EXPORT_SYMBOL(nss_dma_get_context); ++ ++/* ++ * nss_dma_test_handler() ++ * Handles the performance test. ++ */ ++static int nss_dma_test_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) ++{ ++ struct nss_ctx_instance *nss_ctx = nss_dma_get_context(); ++ int cur_state = test_cfg.run.val; ++ int ret; ++ ++ ret = proc_dointvec(ctl, write, buffer, lenp, ppos); ++ if (ret != NSS_SUCCESS) { ++ return ret; ++ } ++ ++ if (!write) { ++ return ret; ++ } ++ ++ /* ++ * Check any tests are already scheduled ++ */ ++ if (cur_state > 0) { ++ nss_info("%px: Test is already running, stopping it.\n", nss_ctx); ++ } else { ++ nss_info("%px: Test is not running, starting it.\n", nss_ctx); ++ } ++ ++ ret = nss_dma_msg_test(nss_ctx); ++ if (ret != NSS_SUCCESS) { ++ nss_warning("%px: Test configuration has failed.\n", nss_ctx); ++ test_cfg.run.val = 0; ++ } ++ ++ return ret; ++} ++ ++static struct ctl_table nss_dma_table[] = { ++ { ++ .procname = "test_run", ++ .data = &test_cfg.run.val, ++ .maxlen = sizeof(int), ++ .mode = 0644, ++ .proc_handler = nss_dma_test_handler, ++ .extra1 = &test_cfg.run.min, ++ .extra2 = &test_cfg.run.max, ++ }, ++ { ++ .procname = "test_code", ++ .data = &test_cfg.code.val, ++ .maxlen = sizeof(int), ++ .mode = 0644, ++ .proc_handler = proc_dointvec_minmax, ++ .extra1 = &test_cfg.code.min, ++ .extra2 = &test_cfg.code.max, ++ }, ++ { ++ .procname = "test_type", ++ .data = &test_cfg.type.val, ++ .maxlen = sizeof(int), ++ .mode = 0644, ++ .proc_handler = proc_dointvec_minmax, ++ .extra1 = &test_cfg.type.min, ++ .extra2 = &test_cfg.type.max, ++ }, ++ { ++ .procname = "test_packets", ++ .data = &test_cfg.packets.val, ++ .maxlen = sizeof(int), ++ .mode = 0644, ++ .proc_handler = proc_dointvec_minmax, ++ .extra1 = &test_cfg.packets.min, ++ .extra2 = &test_cfg.packets.max, ++ }, ++ { ++ .procname = "result_tx", ++ .data = &test_cfg.result_tx_packets, ++ .maxlen = sizeof(int), ++ .mode = 0644, ++ .proc_handler = proc_dointvec, ++ }, ++ { ++ .procname = "result_rx", ++ .data = &test_cfg.result_rx_packets, ++ .maxlen = sizeof(int), ++ .mode = 0644, ++ .proc_handler = proc_dointvec, ++ }, ++ { ++ .procname = "result_time", ++ .data = &test_cfg.result_time, ++ .maxlen = sizeof(int), ++ .mode = 0644, ++ .proc_handler = proc_dointvec, ++ }, ++ { } ++}; ++ ++static struct ctl_table nss_dma_dir[] = { ++ { ++ .procname = "dma", ++ .mode = 0555, ++ .child = nss_dma_table, ++ }, ++ { } ++}; ++ ++static struct ctl_table nss_dma_root_dir[] = { ++ { ++ .procname = "nss", ++ .mode = 0555, ++ .child = nss_dma_dir, ++ }, ++ { } ++}; ++ ++static struct ctl_table nss_dma_root[] = { ++ { ++ .procname = "dev", ++ .mode = 0555, ++ .child = nss_dma_root_dir, ++ }, ++ { } ++}; ++ ++static struct ctl_table_header *nss_dma_header; ++ ++/* ++ * nss_dma_register_sysctl() ++ */ ++void nss_dma_register_sysctl(void) ++{ ++ ++ /* ++ * dma sema init. ++ */ ++ sema_init(&nss_dma_cfg_pvt.sem, 1); ++ init_completion(&nss_dma_cfg_pvt.complete); ++ ++ /* ++ * Register sysctl table. ++ */ ++ nss_dma_header = register_sysctl_table(nss_dma_root); ++} ++ ++/* ++ * nss_dma_unregister_sysctl() ++ * Unregister sysctl specific to dma ++ */ ++void nss_dma_unregister_sysctl(void) ++{ ++ /* ++ * Unregister sysctl table. ++ */ ++ if (nss_dma_header) { ++ unregister_sysctl_table(nss_dma_header); ++ } ++} ++ ++/* ++ * nss_dma_notify_register() ++ * Register to receive dma notify messages. ++ */ ++struct nss_ctx_instance *nss_dma_notify_register(int core, nss_dma_msg_callback_t cb, void *app_data) ++{ ++ struct nss_ctx_instance *nss_ctx = nss_dma_get_context(); ++ uint32_t ret; ++ ++ ret = nss_core_register_handler(nss_ctx, NSS_DMA_INTERFACE, nss_dma_msg_handler, app_data); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: unable to register event handler for DMA interface", nss_ctx); ++ return NULL; ++ } ++ ++ ret = nss_core_register_msg_handler(nss_ctx, NSS_DMA_INTERFACE, cb); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_core_unregister_handler(nss_ctx, NSS_DMA_INTERFACE); ++ nss_warning("%px: unable to register event handler for DMA interface", nss_ctx); ++ return NULL; ++ } ++ ++ return nss_ctx; ++} ++EXPORT_SYMBOL(nss_dma_notify_register); ++ ++/* ++ * nss_dma_notify_unregister() ++ * Unregister to receive dma notify messages. ++ */ ++void nss_dma_notify_unregister(int core) ++{ ++ struct nss_ctx_instance *nss_ctx = nss_dma_get_context(); ++ uint32_t ret; ++ ++ BUG_ON(!nss_ctx); ++ ++ ret = nss_core_unregister_msg_handler(nss_ctx, NSS_DMA_INTERFACE); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: unable to unregister event handler for DMA interface", nss_ctx); ++ return; ++ } ++ ++ ret = nss_core_unregister_handler(nss_ctx, NSS_DMA_INTERFACE); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: unable to unregister event handler for DMA interface", nss_ctx); ++ return; ++ } ++ ++ return; ++} ++EXPORT_SYMBOL(nss_dma_notify_unregister); ++ ++/* ++ * nss_dma_init() ++ */ ++void nss_dma_init(void) ++{ ++ nss_dma_register_sysctl(); ++} +--- /dev/null ++++ b/nss_dma_log.c +@@ -0,0 +1,140 @@ ++/* ++ ************************************************************************** + * Copyright (c) 2020, 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 -@@ -21,10 +21,44 @@ - - #include - ++ * ++ * 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. ++ ************************************************************************** ++ */ ++ ++/* ++ * nss_dma_log.c ++ * NSS DMA logger file. ++ */ ++ ++#include "nss_core.h" ++ ++/* ++ * nss_dma_log_message_types_str ++ * DMA message strings ++ */ ++static int8_t *nss_dma_log_message_types_str[NSS_DMA_MSG_TYPE_MAX] __maybe_unused = { ++ "DMA invalid message", ++ "DMA Configure message", ++ "DMA Statistics sync message", ++ "DMA Test linearization performance", ++}; ++ ++/* ++ * nss_dma_log_error_response_types_str ++ * Strings for error types for DMA messages ++ */ ++static int8_t *nss_dma_log_error_response_types_str[NSS_DMA_MSG_ERROR_MAX] __maybe_unused = { ++ "No error", ++ "HW initialization failed", ++ "Unhandled message type for node", ++ "Error performing the test", ++}; ++ ++/* ++ * nss_dma_map_msg() ++ * Log NSS DMA configure message. ++ */ ++static void nss_dma_configure_msg(struct nss_dma_msg *ndm) ++{ ++ nss_trace("%px: NSS DMA configure message: \n",ndm); ++} ++ ++/* ++ * nss_dma_test_perf_msg() ++ * Log NSS DMA performace test message. ++ */ ++static void nss_dma_test_perf_msg(struct nss_dma_msg *ndm) ++{ ++ struct nss_dma_test_cfg *ndtc = &ndm->msg.test_cfg; ++ struct nss_cmn_node_stats *ncns = &ndtc->node_stats; ++ ++ nss_trace("%px: NSS DMA test perf message: \n",ndm); ++ nss_trace("%px: processed (TX: %u, RX:%u, time:%u)\n", ndm, ncns->tx_packets, ncns->rx_packets, ndtc->time_delta); ++ nss_trace("%px: test parameters (type:%u, packet_cnt:%u)\n", ndm, ndtc->type, ndtc->packet_count); ++} ++ ++/* ++ * nss_dma_log_verbose() ++ * Log message contents. ++ */ ++static void nss_dma_log_verbose(struct nss_dma_msg *ndm) ++{ ++ switch (ndm->cm.type) { ++ case NSS_DMA_MSG_TYPE_CONFIGURE: ++ nss_dma_configure_msg(ndm); ++ break; ++ ++ case NSS_DMA_MSG_TYPE_TEST_PERF: ++ nss_dma_test_perf_msg(ndm); ++ break; ++ ++ default: ++ nss_trace("%px: Invalid message type\n", ndm); ++ break; ++ } ++} ++ ++/* ++ * nss_dma_log_tx_msg() ++ * Log messages transmitted to FW. ++ */ ++void nss_dma_log_tx_msg(struct nss_dma_msg *ndm) ++{ ++ if (ndm->cm.type >= NSS_DMA_MSG_TYPE_MAX) { ++ nss_info("%px: Invalid message type\n", ndm); ++ return; ++ } ++ ++ nss_info("%px: type[%d]:%s\n", ndm, ndm->cm.type, nss_dma_log_message_types_str[ndm->cm.type]); ++ nss_dma_log_verbose(ndm); ++} ++ ++/* ++ * nss_dma_log_rx_msg() ++ * Log messages received from FW. ++ */ ++void nss_dma_log_rx_msg(struct nss_dma_msg *ndm) ++{ ++ if (ndm->cm.response >= NSS_CMN_RESPONSE_LAST) { ++ nss_warning("%px: Invalid response\n", ndm); ++ return; ++ } ++ ++ if (ndm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ndm->cm.response == NSS_CMN_RESPONSE_ACK)) { ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ndm, ndm->cm.type, ++ nss_dma_log_message_types_str[ndm->cm.type], ++ ndm->cm.response, nss_cmn_response_str[ndm->cm.response]); ++ goto verbose; ++ } ++ ++ if (ndm->cm.error >= NSS_DMA_MSG_ERROR_MAX) { ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ ndm, ndm->cm.type, nss_dma_log_message_types_str[ndm->cm.type], ++ ndm->cm.response, nss_cmn_response_str[ndm->cm.response], ++ ndm->cm.error); ++ goto verbose; ++ } ++ ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ ndm, ndm->cm.type, nss_dma_log_message_types_str[ndm->cm.type], ++ ndm->cm.response, nss_cmn_response_str[ndm->cm.response], ++ ndm->cm.error, nss_dma_log_error_response_types_str[ndm->cm.error]); ++ ++verbose: ++ nss_dma_log_verbose(ndm); ++} +--- /dev/null ++++ b/nss_dma_log.h +@@ -0,0 +1,38 @@ ++/* ++ ****************************************************************************** ++ * Copyright (c) 2020, 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. ++ * **************************************************************************** ++ */ ++ ++#ifndef __NSS_DMA_LOG_H ++#define __NSS_DMA_LOG_H ++/* ++ * nss_dma_log.h ++ * NSS DMA Log Header File ++ */ ++ ++/* ++ * nss_dma_log_tx_msg ++ * Logs an DMA message that is sent to the NSS firmware. ++ */ ++void nss_dma_log_tx_msg(struct nss_dma_msg *ndm); ++ ++/* ++ * nss_dma_log_rx_msg ++ * Logs an DMA message that is received from the NSS firmware. ++ */ ++void nss_dma_log_rx_msg(struct nss_dma_msg *ndm); ++ ++#endif /* __NSS_DMA_LOG_H */ +--- /dev/null ++++ b/nss_dma_stats.c +@@ -0,0 +1,163 @@ ++/* ++ ************************************************************************** ++ * Copyright (c) 2020-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_core.h" ++#include "nss_dma.h" ++#include "nss_dma_stats.h" ++#include "nss_dma_strings.h" ++ ++/* ++ * Declare atomic notifier data structure for statistics. ++ */ ++ATOMIC_NOTIFIER_HEAD(nss_dma_stats_notifier); ++ ++/* ++ * Spinlock to protect DMA statistics update/read ++ */ ++DEFINE_SPINLOCK(nss_dma_stats_lock); ++ ++/* ++ * nss_dma_stats ++ * DMA statistics ++ */ ++uint64_t nss_dma_stats[NSS_DMA_STATS_MAX]; ++ ++/* ++ * nss_dma_stats_read() ++ * Read DMA statistics ++ */ ++static ssize_t nss_dma_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) ++{ ++ /* ++ * Max output lines = #stats * NSS_MAX_CORES + ++ * few blank lines for banner printing + Number of Extra outputlines for future reference to add new stats ++ */ ++ uint32_t max_output_lines = NSS_DMA_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; ++ size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; ++ uint64_t *stats_shadow; ++ ssize_t bytes_read = 0; ++ size_t size_wr = 0; ++ char *lbuf; ++ int32_t i; ++ ++ lbuf = vzalloc(size_al); ++ if (!lbuf) { ++ nss_warning("Could not allocate memory for local statistics buffer"); ++ return -ENOMEM; ++ } ++ ++ stats_shadow = vzalloc(NSS_DMA_STATS_MAX * 8); ++ if (!stats_shadow) { ++ nss_warning("Could not allocate memory for local shadow buffer"); ++ vfree(lbuf); ++ return -ENOMEM; ++ } ++ ++ /* ++ * DMA statistics ++ */ ++ spin_lock_bh(&nss_dma_stats_lock); ++ for (i = 0; i < NSS_DMA_STATS_MAX; i++) { ++ stats_shadow[i] = nss_dma_stats[i]; ++ } ++ spin_unlock_bh(&nss_dma_stats_lock); ++ ++ size_wr += nss_stats_banner(lbuf, size_wr, size_al, "dma", nss_top_main.dma_handler_id); ++ size_wr += nss_stats_print("dma", NULL, NSS_STATS_SINGLE_INSTANCE, nss_dma_strings_stats, ++ stats_shadow, NSS_DMA_STATS_MAX, lbuf, size_wr, size_al); ++ ++ bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); ++ ++ vfree(lbuf); ++ vfree(stats_shadow); ++ return bytes_read; ++} ++ ++/* ++ * nss_dma_stats_ops ++ */ ++NSS_STATS_DECLARE_FILE_OPERATIONS(dma); ++ ++/* ++ * nss_dma_stats_dentry_create() ++ * Create DMA statistics debug entry. ++ */ ++void nss_dma_stats_dentry_create(void) ++{ ++ nss_stats_create_dentry("dma", &nss_dma_stats_ops); ++} ++ ++/* ++ * nss_dma_stats_sync() ++ * Handle the syncing of NSS DMA statistics. ++ */ ++void nss_dma_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_dma_stats *nds) ++{ ++ uint64_t *dma_stats; ++ uint32_t *msg_stats; ++ uint16_t i = 0; ++ ++ spin_lock_bh(&nss_dma_stats_lock); ++ ++ msg_stats = (uint32_t *)nds; ++ dma_stats = nss_dma_stats; ++ ++ for (i = 0; i < NSS_DMA_STATS_MAX; i++, dma_stats++, msg_stats++) { ++ *dma_stats += *msg_stats; ++ } ++ ++ spin_unlock_bh(&nss_dma_stats_lock); ++} ++ ++/* ++ * nss_dma_stats_notify() ++ * Sends notifications to all the registered modules. ++ * ++ * Leverage NSS-FW statistics timing to update Netlink. ++ */ ++void nss_dma_stats_notify(struct nss_ctx_instance *nss_ctx) ++{ ++ struct nss_dma_stats_notification dma_stats; ++ ++ spin_lock_bh(&nss_dma_stats_lock); ++ dma_stats.core_id = nss_ctx->id; ++ memcpy(dma_stats.stats_ctx, nss_dma_stats, sizeof(dma_stats.stats_ctx)); ++ spin_unlock_bh(&nss_dma_stats_lock); ++ ++ atomic_notifier_call_chain(&nss_dma_stats_notifier, NSS_STATS_EVENT_NOTIFY, &dma_stats); ++} ++ ++/* ++ * nss_dma_stats_unregister_notifier() ++ * Deregisters statistics notifier. ++ */ ++int nss_dma_stats_unregister_notifier(struct notifier_block *nb) ++{ ++ return atomic_notifier_chain_unregister(&nss_dma_stats_notifier, nb); ++} ++EXPORT_SYMBOL(nss_dma_stats_unregister_notifier); ++ ++/* ++ * nss_dma_stats_register_notifier() ++ * Registers statistics notifier. ++ */ ++int nss_dma_stats_register_notifier(struct notifier_block *nb) ++{ ++ return atomic_notifier_chain_register(&nss_dma_stats_notifier, nb); ++} ++EXPORT_SYMBOL(nss_dma_stats_register_notifier); +--- /dev/null ++++ b/nss_dma_stats.h +@@ -0,0 +1,65 @@ ++/* ++ ****************************************************************************** ++ * Copyright (c) 2020, 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. ++ * **************************************************************************** ++ */ ++ ++#ifndef __NSS_DMA_STATS_H ++#define __NSS_DMA_STATS_H ++ ++#include ++ +/** + * nss_dma_stats_types + * DMA node statistics. @@ -9030,636 +7242,12529 @@ + NSS_DMA_STATS_MAX, /**< Maximum message type. */ +}; + ++/* ++ * DMA statistics APIs ++ */ ++extern void nss_dma_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_dma_stats *nds); ++extern void nss_dma_stats_dentry_create(void); ++ ++#endif /* __NSS_DMA_STATS_H */ +--- /dev/null ++++ b/nss_dma_strings.c +@@ -0,0 +1,88 @@ ++/* ++ ************************************************************************** ++ * Copyright (c) 2020, 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_strings.h" ++#include "nss_dma_stats.h" ++ ++/* ++ * nss_dma_strings_stats ++ * DMA statistics strings. ++ */ ++struct nss_stats_info nss_dma_strings_stats[NSS_DMA_STATS_MAX] = { ++ {"rx_pkts" , NSS_STATS_TYPE_COMMON}, ++ {"rx_byts" , NSS_STATS_TYPE_COMMON}, ++ {"tx_pkts" , NSS_STATS_TYPE_COMMON}, ++ {"tx_byts" , NSS_STATS_TYPE_COMMON}, ++ {"rx_queue[0]_drops" , NSS_STATS_TYPE_DROP}, ++ {"rx_queue[1]_drops" , NSS_STATS_TYPE_DROP}, ++ {"rx_queue[2]_drops" , NSS_STATS_TYPE_DROP}, ++ {"rx_queue[3]_drops" , NSS_STATS_TYPE_DROP}, ++ {"no_req" , NSS_STATS_TYPE_SPECIAL}, ++ {"no_desc" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_nexthop" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_nexthop_queue" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_linear_sz" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_linear_alloc" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_linear_no_sg" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_split_sz" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_split_alloc" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_sync_alloc" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_ctx_active" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[0]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[1]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[2]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[3]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[4]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[5]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[6]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[7]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[8]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[9]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[10]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[11]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[12]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[13]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[14]" , NSS_STATS_TYPE_SPECIAL}, ++ {"fail_hw[15]" , NSS_STATS_TYPE_SPECIAL}, ++}; ++ ++ ++/* ++ * nss_dma_strings_read() ++ * Read DMA node statistics names ++ */ ++static ssize_t nss_dma_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) ++{ ++ return nss_strings_print(ubuf, sz, ppos, nss_dma_strings_stats, NSS_DMA_STATS_MAX); ++} ++ ++/* ++ * nss_dma_strings_ops ++ */ ++NSS_STRINGS_DECLARE_FILE_OPERATIONS(dma); ++ ++/* ++ * nss_dma_strings_dentry_create() ++ * Create DMA statistics strings debug entry. ++ */ ++void nss_dma_strings_dentry_create(void) ++{ ++ nss_strings_create_dentry("dma", &nss_dma_strings_ops); ++} +--- /dev/null ++++ b/nss_dma_strings.h +@@ -0,0 +1,25 @@ ++/* ++ ************************************************************************** ++ * Copyright (c) 2020, 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. ++ ************************************************************************** ++ */ ++ ++#ifndef __NSS_DMA_STRINGS_H ++#define __NSS_DMA_STRINGS_H ++ ++extern struct nss_stats_info nss_dma_strings_stats[NSS_DMA_STATS_MAX]; ++extern void nss_dma_strings_dentry_create(void); ++ ++#endif /* __NSS_DMA_STRINGS_H */ +--- a/nss_dtls.c ++++ b/nss_dtls.c +@@ -1,6 +1,6 @@ /* - * DMA statistics APIs - */ --extern void nss_dma_stats_notify(struct nss_ctx_instance *nss_ctx); - extern void nss_dma_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_dma_stats *nds); - extern void nss_dma_stats_dentry_create(void); + ************************************************************************** +- * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016-2020, 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. +@@ -163,14 +163,14 @@ static void nss_dtls_handler(struct nss_ + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_DTLS_MSG_MAX) { +- nss_warning("%p: received invalid message %d " ++ nss_warning("%px: received invalid message %d " + "for DTLS interface %d", + nss_ctx, ncm->type, ncm->interface); + return; + } + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_dtls_msg)) { +- nss_warning("%p: dtls message length is invalid: %d", ++ nss_warning("%px: dtls message length is invalid: %d", + nss_ctx, ncm->len); + return; + } +@@ -211,7 +211,7 @@ static void nss_dtls_handler(struct nss_ + * call dtls session callback + */ + if (!cb) { +- nss_warning("%p: No callback for dtls session interface %d", ++ nss_warning("%px: No callback for dtls session interface %d", + nss_ctx, ncm->interface); + return; + } +@@ -279,7 +279,7 @@ nss_tx_status_t nss_dtls_tx_msg(struct n + BUG_ON(!nss_dtls_verify_if_num(ncm->interface)); + + if (ncm->type > NSS_DTLS_MSG_MAX) { +- nss_warning("%p: dtls message type out of range: %d", ++ nss_warning("%px: dtls message type out of range: %d", + nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } +@@ -312,7 +312,7 @@ nss_tx_status_t nss_dtls_tx_msg_sync(str + + status = nss_dtls_tx_msg(nss_ctx, msg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: dtls_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: dtls_tx_msg failed\n", nss_ctx); + up(&dtls_pvt.sem); + return status; + } +@@ -320,7 +320,7 @@ nss_tx_status_t nss_dtls_tx_msg_sync(str + ret = wait_for_completion_timeout(&dtls_pvt.complete, msecs_to_jiffies(NSS_DTLS_TX_TIMEOUT)); + + if (!ret) { +- nss_warning("%p: DTLS msg tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: DTLS msg tx failed due to timeout\n", nss_ctx); + dtls_pvt.response = NSS_TX_FAILURE; + } + +@@ -364,13 +364,13 @@ struct nss_ctx_instance *nss_dtls_regist + spin_unlock_bh(&nss_dtls_session_stats_lock); + + if (i == NSS_MAX_DTLS_SESSIONS) { +- nss_warning("%p: Cannot find free slot for " ++ nss_warning("%px: Cannot find free slot for " + "DTLS session stats, I/F:%u\n", nss_ctx, if_num); + return NULL; + } + + if (nss_ctx->subsys_dp_register[if_num].ndev) { +- nss_warning("%p: Cannot find free slot for " ++ nss_warning("%px: Cannot find free slot for " + "DTLS NSS I/F:%u\n", nss_ctx, if_num); + + return NULL; +@@ -407,12 +407,12 @@ void nss_dtls_unregister_if(uint32_t if_ + spin_unlock_bh(&nss_dtls_session_stats_lock); + + if (i == NSS_MAX_DTLS_SESSIONS) { +- nss_warning("%p: Cannot find debug stats for DTLS session %d\n", nss_ctx, if_num); ++ nss_warning("%px: Cannot find debug stats for DTLS session %d\n", nss_ctx, if_num); + return; + } + + if (!nss_ctx->subsys_dp_register[if_num].ndev) { +- nss_warning("%p: Cannot find registered netdev for DTLS NSS I/F:%u\n", nss_ctx, if_num); ++ nss_warning("%px: Cannot find registered netdev for DTLS NSS I/F:%u\n", nss_ctx, if_num); + + return; + } --- a/nss_dtls_cmn.c +++ b/nss_dtls_cmn.c @@ -1,6 +1,6 @@ /* ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. +- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2020, 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. -@@ -16,16 +16,15 @@ +@@ -147,18 +147,18 @@ static void nss_dtls_cmn_handler(struct - #include "nss_tx_rx_common.h" - #include "nss_dtls_cmn_log.h" --#include "nss_dtls_cmn_stats.h" --#include "nss_dtls_cmn_strings.h" + NSS_VERIFY_CTX_MAGIC(nss_ctx); - #define NSS_DTLS_CMN_TX_TIMEOUT 3000 /* 3 Seconds */ - #define NSS_DTLS_CMN_INTERFACE_MAX_LONG BITS_TO_LONGS(NSS_MAX_NET_INTERFACES) -- -+#define NSS_DTLS_CMN_STATS_MAX_LINES (NSS_STATS_NODE_MAX + 32) -+#define NSS_DTLS_CMN_STATS_SIZE_PER_IF (NSS_STATS_MAX_STR_LENGTH * NSS_DTLS_CMN_STATS_MAX_LINES) - /* - * Private data structure. - */ --static struct nss_dtls_cmn_pvt { -+static struct nss_dtls_cmn_cmn_pvt { - struct semaphore sem; - struct completion complete; - enum nss_dtls_cmn_error resp; -@@ -33,6 +32,91 @@ static struct nss_dtls_cmn_pvt { - } dtls_cmn_pvt; +- nss_trace("%p: handle event for interface num :%u", nss_ctx, ncm->interface); ++ nss_trace("%px: handle event for interface num :%u", nss_ctx, ncm->interface); - /* -+ * nss_dtls_cmn_stats_sync() -+ * Update dtls_cmn node statistics. -+ */ -+static void nss_dtls_cmn_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm) -+{ -+ struct nss_dtls_cmn_msg *ndcm = (struct nss_dtls_cmn_msg *)ncm; -+ struct nss_top_instance *nss_top = nss_ctx->nss_top; -+ struct nss_dtls_cmn_ctx_stats *msg_stats = &ndcm->msg.stats; -+ uint64_t *if_stats; -+ -+ spin_lock_bh(&nss_top->stats_lock); -+ -+ /* -+ * Update common node stats, -+ * Note: DTLS only supports a single queue for RX. -+ */ -+ if_stats = nss_top->stats_node[ncm->interface]; -+ if_stats[NSS_STATS_NODE_RX_PKTS] += msg_stats->pkt.rx_packets; -+ if_stats[NSS_STATS_NODE_RX_BYTES] += msg_stats->pkt.rx_bytes; -+ if_stats[NSS_STATS_NODE_RX_QUEUE_0_DROPPED] += msg_stats->pkt.rx_dropped[0]; -+ -+ if_stats[NSS_STATS_NODE_TX_PKTS] += msg_stats->pkt.tx_packets; -+ if_stats[NSS_STATS_NODE_TX_BYTES] += msg_stats->pkt.tx_bytes; -+ -+ spin_unlock_bh(&nss_top->stats_lock); -+} -+ -+/* -+ * nss_dtls_cmn_stats_read() -+ * Read dtls_cmn node statiistics. -+ */ -+static ssize_t nss_dtls_cmn_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -+{ -+ struct nss_ctx_instance *nss_ctx = nss_dtls_cmn_get_context(); -+ enum nss_dynamic_interface_type type; -+ ssize_t bytes_read = 0; -+ size_t len = 0, size; -+ uint32_t if_num; -+ char *buf; -+ -+ size = NSS_DTLS_CMN_STATS_SIZE_PER_IF * bitmap_weight(dtls_cmn_pvt.if_map, NSS_MAX_NET_INTERFACES); -+ -+ buf = kzalloc(size, GFP_KERNEL); -+ if (!buf) { -+ nss_warning("Could not allocate memory for local statistics buffer"); -+ return 0; -+ } -+ -+ /* -+ * Common node stats for each DTLS dynamic interface. -+ */ -+ for_each_set_bit(if_num, dtls_cmn_pvt.if_map, NSS_MAX_NET_INTERFACES) { -+ -+ type = nss_dynamic_interface_get_type(nss_ctx, if_num); -+ -+ switch (type) { -+ case NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_INNER: -+ len += scnprintf(buf + len, size - len, "\nInner if_num:%03u", if_num); -+ break; -+ -+ case NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_OUTER: -+ len += scnprintf(buf + len, size - len, "\nOuter if_num:%03u", if_num); -+ break; -+ -+ default: -+ len += scnprintf(buf + len, size - len, "\nUnknown(%d) if_num:%03u", type, if_num); -+ break; -+ } -+ -+ len += scnprintf(buf + len, size - len, "\n-------------------\n"); -+ len += nss_stats_fill_common_stats(if_num, NSS_STATS_SINGLE_INSTANCE, buf, len, size - len, "dtls_cmn"); -+ } -+ -+ bytes_read = simple_read_from_buffer(ubuf, sz, ppos, buf, len); -+ kfree(buf); -+ -+ return bytes_read; -+} -+ -+/* -+ * nss_dtls_cmn_stats_ops. -+ */ -+NSS_STATS_DECLARE_FILE_OPERATIONS(dtls_cmn) -+ -+/* - * nss_dtls_cmn_verify_ifnum() - * Verify if the interface number is a DTLS interface. - */ -@@ -78,17 +162,15 @@ static void nss_dtls_cmn_handler(struct + /* + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_DTLS_CMN_MSG_MAX) { +- nss_warning("%p:Bad message type(%d) for DTLS interface %d", nss_ctx, ncm->type, ncm->interface); ++ nss_warning("%px:Bad message type(%d) for DTLS interface %d", nss_ctx, ncm->type, ncm->interface); return; } -- if (ncm->type == NSS_DTLS_CMN_MSG_TYPE_SYNC_STATS) { -+ if (ncm->type == NSS_DTLS_CMN_MSG_TYPE_SYNC_STATS) - nss_dtls_cmn_stats_sync(nss_ctx, ncm); -- nss_dtls_cmn_stats_notify(nss_ctx, ncm->interface); -- } + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_dtls_cmn_msg)) { +- nss_warning("%p:Bad message length(%d)", nss_ctx, ncm->len); ++ nss_warning("%px:Bad message length(%d)", nss_ctx, ncm->len); + return; + } - /* +@@ -169,7 +169,7 @@ static void nss_dtls_cmn_handler(struct * Update the callback and app_data for NOTIFY messages. */ if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data; -+ ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; +- ncm->cb = (nss_ptr_t)nss_top_main.if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; } - /* -@@ -139,15 +221,6 @@ static void nss_dtls_cmn_callback(void * +@@ -193,11 +193,11 @@ static void nss_dtls_cmn_handler(struct + * Call DTLS session callback. + */ + if (!cb) { +- nss_warning("%p: No callback for dtls session interface %d", nss_ctx, ncm->interface); ++ nss_warning("%px: No callback for dtls session interface %d", nss_ctx, ncm->interface); + return; + } + +- nss_trace("%p: calling dtlsmgr event handler(%u)", nss_ctx, ncm->interface); ++ nss_trace("%px: calling dtlsmgr event handler(%u)", nss_ctx, ncm->interface); + cb(app_data, ncm); } - /* -- * nss_dtls_cmn_ifmap_get() -- * Return DTLS common active interfaces map. -- */ --unsigned long *nss_dtls_cmn_ifmap_get(void) --{ -- return dtls_cmn_pvt.if_map; --} -- --/* - * nss_dtls_cmn_tx_buf() - * Transmit buffer over DTLS interface. - */ -@@ -446,6 +519,5 @@ void nss_dtls_cmn_register_handler(void) - { - sema_init(&dtls_cmn_pvt.sem, 1); - init_completion(&dtls_cmn_pvt.complete); -- nss_dtls_cmn_stats_dentry_create(); -- nss_dtls_cmn_strings_dentry_create(); -+ nss_stats_create_dentry("dtls_cmn", &nss_dtls_cmn_stats_ops); +@@ -242,12 +242,12 @@ nss_tx_status_t nss_dtls_cmn_tx_msg(stru + struct nss_cmn_msg *ncm = &msg->cm; + + if (ncm->type >= NSS_DTLS_CMN_MSG_MAX) { +- nss_warning("%p: dtls message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: dtls message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + + if (!nss_dtls_cmn_verify_ifnum(nss_ctx, ncm->interface)) { +- nss_warning("%p: dtls message interface is bad: %u", nss_ctx, ncm->interface); ++ nss_warning("%px: dtls message interface is bad: %u", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + +@@ -276,7 +276,7 @@ nss_tx_status_t nss_dtls_cmn_tx_msg_sync + * Length of the message should be the based on type. + */ + if (len > sizeof(ndcm_local.msg)) { +- nss_warning("%p: (%u)Bad message length(%u) for type (%d)", nss_ctx, if_num, len, type); ++ nss_warning("%px: (%u)Bad message length(%u) for type (%d)", nss_ctx, if_num, len, type); + return NSS_TX_FAILURE_TOO_LARGE; + } + +@@ -284,7 +284,7 @@ nss_tx_status_t nss_dtls_cmn_tx_msg_sync + * Response buffer is a required for copying the response for message. + */ + if (!resp) { +- nss_warning("%p: (%u)Response buffer is empty, type(%d)", nss_ctx, if_num, type); ++ nss_warning("%px: (%u)Response buffer is empty, type(%d)", nss_ctx, if_num, type); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -306,13 +306,13 @@ nss_tx_status_t nss_dtls_cmn_tx_msg_sync + + status = nss_dtls_cmn_tx_msg(nss_ctx, &ndcm_local); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: dtls_tx_msg failed", nss_ctx); ++ nss_warning("%px: dtls_tx_msg failed", nss_ctx); + goto done; + } + + ret = wait_for_completion_timeout(&dtls_cmn_pvt.complete, msecs_to_jiffies(NSS_DTLS_CMN_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: DTLS msg tx failed due to timeout", nss_ctx); ++ nss_warning("%px: DTLS msg tx failed due to timeout", nss_ctx); + status = NSS_TX_FAILURE_NOT_READY; + goto done; + } +@@ -354,11 +354,16 @@ struct nss_ctx_instance *nss_dtls_cmn_no + + ret = nss_core_register_handler(nss_ctx, if_num, nss_dtls_cmn_handler, app_data); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: unable to register event handler for interface(%u)", nss_ctx, if_num); ++ nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); + return NULL; + } + +- nss_top_main.if_rx_msg_callback[if_num] = ev_cb; ++ ret = nss_core_register_msg_handler(nss_ctx, if_num, ev_cb); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_core_unregister_handler(nss_ctx, if_num); ++ nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); ++ return NULL; ++ } + + return nss_ctx; } +@@ -375,13 +380,17 @@ void nss_dtls_cmn_notify_unregister(uint + + BUG_ON(!nss_ctx); + +- ret = nss_core_unregister_handler(nss_ctx, if_num); ++ ret = nss_core_unregister_msg_handler(nss_ctx, if_num); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: unable to un register event handler for interface(%u)", nss_ctx, if_num); ++ nss_warning("%px: unable to unregister event handler for interface(%u)", nss_ctx, if_num); + return; + } + +- nss_top_main.if_rx_msg_callback[if_num] = NULL; ++ ret = nss_core_unregister_handler(nss_ctx, if_num); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: unable to unregister event handler for interface(%u)", nss_ctx, if_num); ++ return; ++ } + + return; + } +@@ -403,12 +412,12 @@ struct nss_ctx_instance *nss_dtls_cmn_re + uint32_t ret; + + if (!nss_dtls_cmn_verify_ifnum(nss_ctx, if_num)) { +- nss_warning("%p: DTLS Interface is not dynamic:%u", nss_ctx, if_num); ++ nss_warning("%px: DTLS Interface is not dynamic:%u", nss_ctx, if_num); + return NULL; + } + + if (nss_ctx->subsys_dp_register[if_num].ndev) { +- nss_warning("%p: Cannot find free slot for DTLS NSS I/F:%u", nss_ctx, if_num); ++ nss_warning("%px: Cannot find free slot for DTLS NSS I/F:%u", nss_ctx, if_num); + return NULL; + } + +@@ -417,11 +426,16 @@ struct nss_ctx_instance *nss_dtls_cmn_re + + ret = nss_core_register_handler(nss_ctx, if_num, nss_dtls_cmn_handler, app_data); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: unable to register event handler for interface(%u)", nss_ctx, if_num); ++ nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); + return NULL; + } + +- nss_top_main.if_rx_msg_callback[if_num] = ev_cb; ++ ret = nss_core_register_msg_handler(nss_ctx, if_num, ev_cb); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_core_unregister_handler(nss_ctx, if_num); ++ nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); ++ return NULL; ++ } + + /* + * Atomically set the bitmap for the interface number. +@@ -438,9 +452,10 @@ EXPORT_SYMBOL(nss_dtls_cmn_register_if); + void nss_dtls_cmn_unregister_if(uint32_t if_num) + { + struct nss_ctx_instance *nss_ctx = nss_dtls_cmn_get_context(); ++ uint32_t ret; + + if (!nss_ctx->subsys_dp_register[if_num].ndev) { +- nss_warning("%p: Cannot find registered netdev for DTLS NSS I/F:%u", nss_ctx, if_num); ++ nss_warning("%px: Cannot find registered netdev for DTLS NSS I/F:%u", nss_ctx, if_num); + return; + } + +@@ -449,8 +464,13 @@ void nss_dtls_cmn_unregister_if(uint32_t + */ + clear_bit(if_num, dtls_cmn_pvt.if_map); + ++ ret = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: unable to unregister event handler for interface(%u)", nss_ctx, if_num); ++ return; ++ } ++ + nss_core_unregister_handler(nss_ctx, if_num); +- nss_top_main.if_rx_msg_callback[if_num] = NULL; + + nss_core_unregister_subsys_dp(nss_ctx, if_num); + nss_ctx->subsys_dp_register[if_num].type = 0; --- a/nss_dtls_cmn_log.c +++ b/nss_dtls_cmn_log.c -@@ -1,12 +1,9 @@ +@@ -1,6 +1,6 @@ /* ************************************************************************** - * Copyright (c) 2018, 2020, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved. -- * +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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 -@@ -35,8 +32,7 @@ static int8_t *nss_dtls_cmn_log_message_ - "DTLS_CMN Switch DTLS Transform", - "DTLS_CMN Deconfigure Context", - "DTLS_CMN Synchronize Stats", -- "DTLS_CMN Node Statistics", -- "DTLS_CMN Update VP" -+ "DTLS_CMN Node Statistics" - }; +@@ -63,12 +63,12 @@ static int8_t *nss_dtls_cmn_log_error_re + static void nss_dtls_cmn_hdr_config_msg(struct nss_dtls_cmn_msg *ndm) + { + struct nss_dtls_cmn_ctx_config_hdr *ndchm __maybe_unused = &ndm->msg.hdr_cfg; +- nss_trace("%p: NSS DTLS_CMN Header Configure Message:\n" ++ nss_trace("%px: NSS DTLS_CMN Header Configure Message:\n" + "DTLS_CMN flags: %x\n" + "DTLS_CMN destination interface number: %d\n" + "DTLS_CMN source interface number: %d\n" +- "DTLS_CMN source ip: %p\n" +- "DTLS_CMN destination ip: %p\n" ++ "DTLS_CMN source ip: %px\n" ++ "DTLS_CMN destination ip: %px\n" + "DTLS_CMN source port: %d\n" + "DTLS_CMN destination port: %d\n" + "DTLS_CMN time to live: %d\n" +@@ -90,7 +90,7 @@ static void nss_dtls_cmn_hdr_config_msg( + static void nss_dtls_cmn_dtls_config_msg(struct nss_dtls_cmn_msg *ndm) + { + struct nss_dtls_cmn_ctx_config_dtls *ndcdm __maybe_unused = &ndm->msg.dtls_cfg; +- nss_trace("%p: NSS DTLS_CMN DTLS Configure Message:\n" ++ nss_trace("%px: NSS DTLS_CMN DTLS Configure Message:\n" + "DTLS_CMN version: %d\n" + "DTLS_CMN crypto Index: %d\n" + "DTLS_CMN window size: %d\n" +@@ -122,7 +122,7 @@ static void nss_dtls_cmn_log_verbose(str + break; + + default: +- nss_warning("%p: Invalid message type\n", ndm); ++ nss_warning("%px: Invalid message type\n", ndm); + break; + } + } +@@ -134,11 +134,11 @@ static void nss_dtls_cmn_log_verbose(str + void nss_dtls_cmn_log_tx_msg(struct nss_dtls_cmn_msg *ndm) + { + if (ndm->cm.type >= NSS_DTLS_CMN_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", ndm); ++ nss_warning("%px: Invalid message type\n", ndm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ndm, ndm->cm.type, nss_dtls_cmn_log_message_types_str[ndm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ndm, ndm->cm.type, nss_dtls_cmn_log_message_types_str[ndm->cm.type]); + nss_dtls_cmn_log_verbose(ndm); + } + +@@ -149,26 +149,26 @@ void nss_dtls_cmn_log_tx_msg(struct nss_ + void nss_dtls_cmn_log_rx_msg(struct nss_dtls_cmn_msg *ndm) + { + if (ndm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ndm); ++ nss_warning("%px: Invalid response\n", ndm); + return; + } + + if (ndm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ndm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ndm, ndm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ndm, ndm->cm.type, + nss_dtls_cmn_log_message_types_str[ndm->cm.type], + ndm->cm.response, nss_cmn_response_str[ndm->cm.response]); + goto verbose; + } + + if (ndm->cm.error >= NSS_DTLS_CMN_ERROR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ndm, ndm->cm.type, nss_dtls_cmn_log_message_types_str[ndm->cm.type], + ndm->cm.response, nss_cmn_response_str[ndm->cm.response], + ndm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ndm, ndm->cm.type, nss_dtls_cmn_log_message_types_str[ndm->cm.type], + ndm->cm.response, nss_cmn_response_str[ndm->cm.response], + ndm->cm.error, nss_dtls_cmn_log_error_response_types_str[ndm->cm.error]); +--- a/nss_dtls_log.c ++++ b/nss_dtls_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -54,7 +54,7 @@ static int8_t *nss_dtls_log_error_respon + static void nss_dtls_session_config_msg(struct nss_dtls_msg *ndm) + { + struct nss_dtls_session_configure *ndscm __maybe_unused = &ndm->msg.cfg; +- nss_trace("%p: NSS DTLS Session Configure Message:\n" ++ nss_trace("%px: NSS DTLS Session Configure Message:\n" + "DTLS Version: %d\n" + "DTLS Flags: %x\n" + "DTLS crypto index encap: %d\n" +@@ -70,8 +70,8 @@ static void nss_dtls_session_config_msg( + "DTLS NSS interface: %x\n" + "DTLS source port: %d\n" + "DTLS destination port: %d\n" +- "DTLS source ip: %p\n" +- "DTLS destination ip: %p\n" ++ "DTLS source ip: %px\n" ++ "DTLS destination ip: %px\n" + "DTLS window size: %d\n" + "DTLS epoch: %d\n" + "DTLS outer IP TTL: %d\n" +@@ -98,7 +98,7 @@ static void nss_dtls_session_config_msg( + static void nss_dtls_session_cipher_update_msg(struct nss_dtls_msg *ndm) + { + struct nss_dtls_session_cipher_update *ndscum __maybe_unused = &ndm->msg.cipher_update; +- nss_trace("%p: NSS DTLS Session Cipher Update message\n" ++ nss_trace("%px: NSS DTLS Session Cipher Update message\n" + "DTLS crypto index: %d\n" + "DTLS hash length: %d\n" + "DTLS crypto IV length for encapsulation: %d\n" +@@ -129,7 +129,7 @@ static void nss_dtls_log_verbose(struct + break; + + default: +- nss_warning("%p: Invalid message type\n", ndm); ++ nss_warning("%px: Invalid message type\n", ndm); + break; + } + } +@@ -141,11 +141,11 @@ static void nss_dtls_log_verbose(struct + void nss_dtls_log_tx_msg(struct nss_dtls_msg *ndm) + { + if (ndm->cm.type >= NSS_DTLS_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", ndm); ++ nss_warning("%px: Invalid message type\n", ndm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ndm, ndm->cm.type, nss_dtls_log_message_types_str[ndm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ndm, ndm->cm.type, nss_dtls_log_message_types_str[ndm->cm.type]); + nss_dtls_log_verbose(ndm); + } + +@@ -156,26 +156,26 @@ void nss_dtls_log_tx_msg(struct nss_dtls + void nss_dtls_log_rx_msg(struct nss_dtls_msg *ndm) + { + if (ndm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ndm); ++ nss_warning("%px: Invalid response\n", ndm); + return; + } + + if (ndm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ndm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ndm, ndm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ndm, ndm->cm.type, + nss_dtls_log_message_types_str[ndm->cm.type], + ndm->cm.response, nss_cmn_response_str[ndm->cm.response]); + goto verbose; + } + + if (ndm->cm.error >= NSS_DTLS_ERR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ndm, ndm->cm.type, nss_dtls_log_message_types_str[ndm->cm.type], + ndm->cm.response, nss_cmn_response_str[ndm->cm.response], + ndm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ndm, ndm->cm.type, nss_dtls_log_message_types_str[ndm->cm.type], + ndm->cm.response, nss_cmn_response_str[ndm->cm.response], + ndm->cm.error, nss_dtls_log_error_response_types_str[ndm->cm.error]); +--- a/nss_dynamic_interface.c ++++ b/nss_dynamic_interface.c +@@ -54,12 +54,12 @@ static void nss_dynamic_interface_handle + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_DYNAMIC_INTERFACE_MAX) { +- nss_warning("%p: received invalid message %d for dynamic interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for dynamic interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_dynamic_interface_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -79,12 +79,12 @@ static void nss_dynamic_interface_handle + switch (ndim->cm.type) { + case NSS_DYNAMIC_INTERFACE_ALLOC_NODE: + if (ncm->response == NSS_CMN_RESPONSE_ACK) { +- nss_info("%p alloc_node response ack if_num %d\n", nss_ctx, ndim->msg.alloc_node.if_num); ++ nss_info("%px alloc_node response ack if_num %d\n", nss_ctx, ndim->msg.alloc_node.if_num); + if_num = ndim->msg.alloc_node.if_num; + if (if_num > 0) { + nss_dynamic_interface_assigned_types[nss_ctx->id][if_num - NSS_DYNAMIC_IF_START] = ndim->msg.alloc_node.type; + } else { +- nss_warning("%p: if_num < 0\n", nss_ctx); ++ nss_warning("%px: if_num < 0\n", nss_ctx); + } + } + +@@ -92,7 +92,7 @@ static void nss_dynamic_interface_handle + + case NSS_DYNAMIC_INTERFACE_DEALLOC_NODE: + if (ncm->response == NSS_CMN_RESPONSE_ACK) { +- nss_info("%p dealloc_node response ack if_num %d\n", nss_ctx, ndim->msg.dealloc_node.if_num); ++ nss_info("%px dealloc_node response ack if_num %d\n", nss_ctx, ndim->msg.dealloc_node.if_num); + if_num = ndim->msg.dealloc_node.if_num; + nss_dynamic_interface_assigned_types[nss_ctx->id][if_num - NSS_DYNAMIC_IF_START] = NSS_DYNAMIC_INTERFACE_TYPE_NONE; + /* +@@ -104,7 +104,7 @@ static void nss_dynamic_interface_handle + break; + + default: +- nss_warning("%p: Received response %d for type %d, interface %d", ++ nss_warning("%px: Received response %d for type %d, interface %d", + nss_ctx, ncm->response, ncm->type, ncm->interface); + return; + } +@@ -113,7 +113,7 @@ static void nss_dynamic_interface_handle + * Do we have a callback? + */ + if (!ncm->cb) { +- nss_warning("%p: nss_dynamic_interface_handler cb is NULL\n", nss_ctx); ++ nss_warning("%px: nss_dynamic_interface_handler cb is NULL\n", nss_ctx); + return; + } + +@@ -154,12 +154,12 @@ nss_tx_status_t nss_dynamic_interface_tx + * Sanity check the message + */ + if (ncm->interface != NSS_DYNAMIC_INTERFACE) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_DYNAMIC_INTERFACE_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -183,7 +183,7 @@ static nss_tx_status_t nss_dynamic_inter + + status = nss_dynamic_interface_tx(nss_ctx, ndim); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: not able to transmit msg successfully\n", nss_ctx); ++ nss_warning("%px: not able to transmit msg successfully\n", nss_ctx); + return status; + } + +@@ -192,7 +192,7 @@ static nss_tx_status_t nss_dynamic_inter + */ + ret = wait_for_completion_timeout(&di_data->complete, msecs_to_jiffies(NSS_DYNAMIC_INTERFACE_COMP_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: Waiting for ack timed out\n", nss_ctx); ++ nss_warning("%px: Waiting for ack timed out\n", nss_ctx); + return NSS_TX_FAILURE; + } + +@@ -243,7 +243,7 @@ int nss_dynamic_interface_alloc_node(enu + */ + status = nss_dynamic_interface_tx_sync(nss_ctx, &di_data, &ndim); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p not able to transmit alloc node msg\n", nss_ctx); ++ nss_warning("%px not able to transmit alloc node msg\n", nss_ctx); + return -1; + } + +@@ -251,7 +251,7 @@ int nss_dynamic_interface_alloc_node(enu + * Check response and return -1 if its a NACK else proceed. + */ + if (di_data.response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p Received NACK from NSS - Response:%d\n", nss_ctx, di_data.response); ++ nss_warning("%px Received NACK from NSS - Response:%d\n", nss_ctx, di_data.response); + return -1; + } + +@@ -286,7 +286,7 @@ nss_tx_status_t nss_dynamic_interface_de + init_completion(&di_data.complete); + + if (nss_is_dynamic_interface(if_num) == false) { +- nss_warning("%p: nss_dynamic_interface if_num is not in range %d\n", nss_ctx, if_num); ++ nss_warning("%px: nss_dynamic_interface if_num is not in range %d\n", nss_ctx, if_num); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -302,12 +302,12 @@ nss_tx_status_t nss_dynamic_interface_de + */ + status = nss_dynamic_interface_tx_sync(nss_ctx, &di_data, &ndim); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p not able to transmit alloc node msg\n", nss_ctx); ++ nss_warning("%px not able to transmit alloc node msg\n", nss_ctx); + return status; + } + + if (di_data.response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p Received NACK from NSS\n", nss_ctx); ++ nss_warning("%px Received NACK from NSS\n", nss_ctx); + return -1; + } + +--- a/nss_dynamic_interface_log.c ++++ b/nss_dynamic_interface_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -52,7 +52,7 @@ static int8_t *nss_dynamic_interface_log + static void nss_dynamic_interface_alloc_node_log_msg(struct nss_dynamic_interface_msg *ndm) + { + struct nss_dynamic_interface_alloc_node_msg *ndanm __maybe_unused = &ndm->msg.alloc_node; +- nss_trace("%p: NSS Dynamic Interface Alloc Node Message:\n" ++ nss_trace("%px: NSS Dynamic Interface Alloc Node Message:\n" + "Dynamic Interface Type: %d\n" + "Dynamic Interface Number: %d\n", + ndanm, ndanm->type, +@@ -66,7 +66,7 @@ static void nss_dynamic_interface_alloc_ + static void nss_dynamic_interface_dealloc_node_log_msg(struct nss_dynamic_interface_msg *ndm) + { + struct nss_dynamic_interface_dealloc_node_msg *nddnm __maybe_unused = &ndm->msg.dealloc_node; +- nss_trace("%p: NSS Dynamic Interface Alloc Node Message:\n" ++ nss_trace("%px: NSS Dynamic Interface Alloc Node Message:\n" + "Dynamic Interface Type: %d\n" + "Dynamic Interface Number: %d\n", + nddnm, nddnm->type, +@@ -89,7 +89,7 @@ static void nss_dynamic_interface_log_ve + break; + + default: +- nss_warning("%p: Invalid message type\n", ndm); ++ nss_warning("%px: Invalid message type\n", ndm); + break; + } + } +@@ -101,11 +101,11 @@ static void nss_dynamic_interface_log_ve + void nss_dynamic_interface_log_tx_msg(struct nss_dynamic_interface_msg *ndm) + { + if (ndm->cm.type >= NSS_DYNAMIC_INTERFACE_MAX) { +- nss_warning("%p: Invalid message type\n", ndm); ++ nss_warning("%px: Invalid message type\n", ndm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ndm, ndm->cm.type, nss_dynamic_interface_log_message_types_str[ndm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ndm, ndm->cm.type, nss_dynamic_interface_log_message_types_str[ndm->cm.type]); + nss_dynamic_interface_log_verbose(ndm); + } + +@@ -116,26 +116,26 @@ void nss_dynamic_interface_log_tx_msg(st + void nss_dynamic_interface_log_rx_msg(struct nss_dynamic_interface_msg *ndm) + { + if (ndm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ndm); ++ nss_warning("%px: Invalid response\n", ndm); + return; + } + + if (ndm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ndm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ndm, ndm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ndm, ndm->cm.type, + nss_dynamic_interface_log_message_types_str[ndm->cm.type], + ndm->cm.response, nss_cmn_response_str[ndm->cm.response]); + goto verbose; + } + + if (ndm->cm.error >= NSS_DYNAMIC_INTERFACE_ERR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ndm, ndm->cm.type, nss_dynamic_interface_log_message_types_str[ndm->cm.type], + ndm->cm.response, nss_cmn_response_str[ndm->cm.response], + ndm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n, error[%d]:%s\n", + ndm, ndm->cm.type, nss_dynamic_interface_log_message_types_str[ndm->cm.type], + ndm->cm.response, nss_cmn_response_str[ndm->cm.response], + ndm->cm.error, nss_dynamic_interface_log_error_response_types_str[ndm->cm.error]); +--- a/nss_edma.c ++++ b/nss_edma.c +@@ -40,7 +40,7 @@ static void nss_edma_interface_handler(s + * Is this a valid request/response packet? + */ + if (nem->cm.type >= NSS_METADATA_TYPE_EDMA_MAX) { +- nss_warning("%p: received invalid message %d for edma interface", nss_ctx, nem->cm.type); ++ nss_warning("%px: received invalid message %d for edma interface", nss_ctx, nem->cm.type); + return; + } + +@@ -67,7 +67,7 @@ static void nss_edma_interface_handler(s + /* + * Check response + */ +- nss_info("%p: Received response %d for type %d, interface %d", ++ nss_info("%px: Received response %d for type %d, interface %d", + nss_ctx, ncm->response, ncm->type, ncm->interface); + } + } +--- a/nss_eth_rx.c ++++ b/nss_eth_rx.c +@@ -41,7 +41,7 @@ static void nss_eth_rx_interface_handler + * Is this a valid request/response packet? + */ + if (nem->cm.type >= NSS_METADATA_TYPE_ETH_RX_MAX) { +- nss_warning("%p: received invalid message %d for eth_rx interface", nss_ctx, nem->cm.type); ++ nss_warning("%px: received invalid message %d for eth_rx interface", nss_ctx, nem->cm.type); + return; + } + +@@ -59,7 +59,7 @@ static void nss_eth_rx_interface_handler + /* + * Check response + */ +- nss_info("%p: Received response %d for type %d, interface %d", ++ nss_info("%px: Received response %d for type %d, interface %d", + nss_ctx, ncm->response, ncm->type, ncm->interface); + } + } +--- a/nss_freq.c ++++ b/nss_freq.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2013, 2015-2019 The Linux Foundation. All rights reserved. ++ * Copyright (c) 2013, 2015-2020 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. +@@ -66,7 +66,7 @@ static void nss_freq_handle_ack(struct n + /* + * NSS finished start noficiation - HW change clocks and send end notification + */ +- nss_info("%p: NSS ACK Received: %d - Change HW CLK/Send Finish to NSS\n", nss_ctx, nfa->ack); ++ nss_info("%px: NSS ACK Received: %d - Change HW CLK/Send Finish to NSS\n", nss_ctx, nfa->ack); + + return; + } +@@ -75,12 +75,12 @@ static void nss_freq_handle_ack(struct n + /* + * NSS finished end notification - Done + */ +- nss_info("%p: NSS ACK Received: %d - End Notification ACK - Running: %dmhz\n", nss_ctx, nfa->ack, nfa->freq_current); ++ nss_info("%px: NSS ACK Received: %d - End Notification ACK - Running: %dmhz\n", nss_ctx, nfa->ack, nfa->freq_current); + nss_runtime_samples.freq_scale_ready = 1; + return; + } + +- nss_info("%p: NSS had an error - Running: %dmhz\n", nss_ctx, nfa->freq_current); ++ nss_info("%px: NSS had an error - Running: %dmhz\n", nss_ctx, nfa->freq_current); + } /* -@@ -57,9 +53,7 @@ static int8_t *nss_dtls_cmn_log_error_re - "DTLS_CMN Switch Hardware Context Fail", - "DTLS_CMN Already Configured", - "DTLS_CMN No Memory", -- "DTLS_CMN Copy Nonce Failure", -- "DTLS_CMN Update VP Failure", -- "DTLS_CMN Destroy VP Failure" -+ "DTLS_CMN Copy Nonce Failure" - }; +@@ -185,7 +185,7 @@ static void nss_freq_compute_cpu_usage(s + nss_freq_cpu_status.min = nss_freq_cpu_status.used; + } - /* ---- a/nss_dtls_cmn_stats.c -+++ /dev/null -@@ -1,215 +0,0 @@ --/* -- *************************************************************************** -- * Copyright (c) 2020-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_core.h" --#include "nss_dtls_cmn.h" --#include "nss_dtls_cmn_stats.h" --#include "nss_dtls_cmn_strings.h" -- --/* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_dtls_cmn_stats_notifier); -- --/* -- * Spinlock to protect dtls common statistics update/read -- */ --DEFINE_SPINLOCK(nss_dtls_cmn_stats_lock); -- --unsigned long *nss_dtls_cmn_ifmap_get(void); -- --/* -- * nss_dtls_cmn_ctx_stats -- * dtls common ctx statistics -- */ --uint64_t nss_dtls_cmn_ctx_stats[NSS_MAX_NET_INTERFACES][NSS_DTLS_CMN_CTX_STATS_MAX]; -- --/* -- * nss_dtls_cmn_stats_iface_type() -- * Return a string for each interface type. -- */ --static const char *nss_dtls_cmn_stats_iface_type(enum nss_dynamic_interface_type type) --{ -- switch (type) { -- case NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_INNER: -- return "dtls_cmn_inner"; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_OUTER: -- return "dtls_cmn_outer"; -- -- default: -- return "invalid_interface"; -- -- } +- nss_trace("%p: max_instructions:%d cpu_usage:%d max_usage:%d min_usage:%d\n", nss_ctx, ++ nss_trace("%px: max_instructions:%d cpu_usage:%d max_usage:%d min_usage:%d\n", nss_ctx, + nss_freq_cpu_status.max_ins, nss_freq_cpu_status.used, nss_freq_cpu_status.max, nss_freq_cpu_status.min); + + nss_freq_cpu_status.total = 0; +@@ -249,10 +249,10 @@ void nss_freq_scale_frequency(struct nss + * Print out statistics every 10 samples + */ + if (nss_runtime_samples.message_rate_limit++ >= NSS_MESSAGE_RATE_LIMIT) { +- nss_trace("%p: Running AVG:%x Sample:%x Divider:%d\n", nss_ctx, nss_runtime_samples.average, inst_cnt, nss_runtime_samples.sample_count); +- nss_trace("%p: Current Frequency Index:%d\n", nss_ctx, index); +- nss_trace("%p: Auto Scale Ready:%d Auto Scale:%d\n", nss_ctx, nss_runtime_samples.freq_scale_ready, nss_cmd_buf.auto_scale); +- nss_trace("%p: Current Rate:%x\n", nss_ctx, nss_runtime_samples.average); ++ nss_trace("%px: Running AVG:%x Sample:%x Divider:%d\n", nss_ctx, nss_runtime_samples.average, inst_cnt, nss_runtime_samples.sample_count); ++ nss_trace("%px: Current Frequency Index:%d\n", nss_ctx, index); ++ nss_trace("%px: Auto Scale Ready:%d Auto Scale:%d\n", nss_ctx, nss_runtime_samples.freq_scale_ready, nss_cmd_buf.auto_scale); ++ nss_trace("%px: Current Rate:%x\n", nss_ctx, nss_runtime_samples.average); + + nss_runtime_samples.message_rate_limit = 0; + } +@@ -361,7 +361,7 @@ static void nss_freq_interface_handler(s + /* + * Check response + */ +- nss_info("%p: Received response %d for type %d, interface %d", nss_ctx, ncm->response, ncm->type, ncm->interface); ++ nss_info("%px: Received response %d for type %d, interface %d", nss_ctx, ncm->response, ncm->type, ncm->interface); + } + } + } +@@ -375,7 +375,7 @@ nss_tx_status_t nss_freq_change(struct n + struct nss_corefreq_msg ncm; + struct nss_freq_msg *nfc; + +- nss_info("%p: frequency changing to: %d\n", nss_ctx, eng); ++ nss_info("%px: frequency changing to: %d\n", nss_ctx, eng); + + /* + * Update the max instruction count for a frequency during down scaling. +@@ -459,4 +459,4 @@ void nss_freq_init_cpu_usage(void) + nss_freq_cpu_status.avg_ctr = 0; + + nss_freq_stats_dentry_create(); -} +\ No newline at end of file ++} +--- a/nss_freq_log.c ++++ b/nss_freq_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -39,7 +39,7 @@ static int8_t *nss_freq_log_message_type + static void nss_freq_log_msg(struct nss_corefreq_msg *ncm) + { + struct nss_freq_msg *nfm __maybe_unused = &ncm->msg.nfc; +- nss_trace("%p: NSS Freq Message:\n" ++ nss_trace("%px: NSS Freq Message:\n" + "Frequency request: %d\n" + "Frequency start/end: %d\n" + "Frequency stats enable: %d\n" +@@ -69,7 +69,7 @@ static void nss_freq_log_verbose(struct + break; + + default: +- nss_warning("%p: Invalid message type\n", ncm); ++ nss_warning("%px: Invalid message type\n", ncm); + break; + } + } +@@ -81,17 +81,17 @@ static void nss_freq_log_verbose(struct + void nss_freq_log_rx_msg(struct nss_corefreq_msg *ncm) + { + if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ncm); ++ nss_warning("%px: Invalid response\n", ncm); + return; + } + + if (ncm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ncm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d], response[%d]:%s\n", ncm, ncm->cm.type, ++ nss_info("%px: type[%d], response[%d]:%s\n", ncm, ncm->cm.type, + ncm->cm.response, nss_cmn_response_str[ncm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + ncm, ncm->cm.type, nss_freq_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response]); + +--- a/nss_gre.c ++++ b/nss_gre.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2017-2020, 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. +@@ -101,12 +101,12 @@ static void nss_gre_msg_handler(struct n + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_GRE_MSG_MAX) { +- nss_warning("%p: received invalid message %d for GRE STD interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for GRE STD interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_gre_msg)) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return; + } + +@@ -151,7 +151,7 @@ static void nss_gre_msg_handler(struct n + * call gre-std callback + */ + if (!cb) { +- nss_warning("%p: No callback for gre-std interface %d", ++ nss_warning("%px: No callback for gre-std interface %d", + nss_ctx, ncm->interface); + return; + } +@@ -217,12 +217,12 @@ nss_tx_status_t nss_gre_tx_msg(struct ns + * Sanity check the message + */ + if (!nss_is_dynamic_interface(ncm->interface)) { +- nss_warning("%p: tx request for non dynamic interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for non dynamic interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_GRE_MSG_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -253,14 +253,14 @@ nss_tx_status_t nss_gre_tx_msg_sync(stru + + status = nss_gre_tx_msg(nss_ctx, msg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: gre_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: gre_tx_msg failed\n", nss_ctx); + up(&nss_gre_pvt.sem); + return status; + } + ret = wait_for_completion_timeout(&nss_gre_pvt.complete, msecs_to_jiffies(NSS_GRE_TX_TIMEOUT)); + + if (!ret) { +- nss_warning("%p: GRE STD tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: GRE STD tx sync failed due to timeout\n", nss_ctx); + nss_gre_pvt.response = NSS_TX_FAILURE; + } + +@@ -310,7 +310,7 @@ struct nss_ctx_instance *nss_gre_registe + break; + + default: +- nss_warning("%p: Unable to register. Wrong interface type %d\n", nss_ctx, type); ++ nss_warning("%px: Unable to register. Wrong interface type %d\n", nss_ctx, type); + return NULL; + } + +@@ -340,7 +340,7 @@ void nss_gre_unregister_if(uint32_t if_n + + dev = nss_cmn_get_interface_dev(nss_ctx, if_num); + if (!dev) { +- nss_warning("%p: Unable to find net device for the interface %d\n", nss_ctx, if_num); ++ nss_warning("%px: Unable to find net device for the interface %d\n", nss_ctx, if_num); + return; + } + +@@ -373,7 +373,7 @@ int nss_gre_ifnum_with_core_id(int if_nu + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + if (!nss_is_dynamic_interface(if_num)) { +- nss_warning("%p: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); ++ nss_warning("%px: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); + return 0; + } + +--- a/nss_gre_log.c ++++ b/nss_gre_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -41,7 +41,7 @@ static int8_t *nss_gre_log_message_types + static void nss_gre_log_config_msg(struct nss_gre_msg *ngm) + { + struct nss_gre_config_msg *ngcm __maybe_unused = &ngm->msg.cmsg; +- nss_trace("%p: NSS GRE Config message\n" ++ nss_trace("%px: NSS GRE Config message\n" + "GRE flags: %d\n" + "GRE ikey: %d\n" + "GRE okey: %d\n" +@@ -78,7 +78,7 @@ static void nss_gre_log_config_msg(struc + static void nss_gre_log_deconfig_msg(struct nss_gre_msg *ngm) + { + struct nss_gre_deconfig_msg *ngdm __maybe_unused = &ngm->msg.dmsg; +- nss_trace("%p: NSS GRE deconfig message\n" ++ nss_trace("%px: NSS GRE deconfig message\n" + "GRE interface number: %d\n", + ngdm, ngdm->if_number); + } +@@ -90,7 +90,7 @@ static void nss_gre_log_deconfig_msg(str + static void nss_gre_log_linkup_msg(struct nss_gre_msg *ngm) + { + struct nss_gre_linkup_msg *nglm __maybe_unused = &ngm->msg.linkup; +- nss_trace("%p: NSS GRE linkup message\n" ++ nss_trace("%px: NSS GRE linkup message\n" + "GRE interface number: %d\n", + nglm, nglm->if_number); + } +@@ -102,7 +102,7 @@ static void nss_gre_log_linkup_msg(struc + static void nss_gre_log_linkdown_msg(struct nss_gre_msg *ngm) + { + struct nss_gre_linkdown_msg *ngdm __maybe_unused = &ngm->msg.linkdown; +- nss_trace("%p: NSS GRE linkdown message\n" ++ nss_trace("%px: NSS GRE linkdown message\n" + "GRE interface number: %d\n", + ngdm, ngdm->if_number); + } +@@ -140,7 +140,7 @@ static void nss_gre_log_verbose(struct n + break; + + default: +- nss_trace("%p: Invalid message type\n", ngm); ++ nss_trace("%px: Invalid message type\n", ngm); + break; + } + } +@@ -152,11 +152,11 @@ static void nss_gre_log_verbose(struct n + void nss_gre_log_tx_msg(struct nss_gre_msg *ngm) + { + if (ngm->cm.type >= NSS_GRE_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", ngm); ++ nss_warning("%px: Invalid message type\n", ngm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_log_message_types_str[NSS_GRE_LOG_MESSAGE_TYPE_INDEX(ngm->cm.type)]); ++ nss_info("%px: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_log_message_types_str[NSS_GRE_LOG_MESSAGE_TYPE_INDEX(ngm->cm.type)]); + nss_gre_log_verbose(ngm); + } + +@@ -167,18 +167,18 @@ void nss_gre_log_tx_msg(struct nss_gre_m + void nss_gre_log_rx_msg(struct nss_gre_msg *ngm) + { + if (ngm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ngm); ++ nss_warning("%px: Invalid response\n", ngm); + return; + } + + if (ngm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ngm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ngm, ngm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ngm, ngm->cm.type, + nss_gre_log_message_types_str[NSS_GRE_LOG_MESSAGE_TYPE_INDEX(ngm->cm.type)], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + ngm, ngm->cm.type, nss_gre_log_message_types_str[NSS_GRE_LOG_MESSAGE_TYPE_INDEX(ngm->cm.type)], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response]); + +--- a/nss_gre_redir.c ++++ b/nss_gre_redir.c +@@ -85,12 +85,12 @@ static void nss_gre_redir_tunnel_update_ + type = nss_dynamic_interface_get_type(nss_ctx, if_num); + dev = nss_cmn_get_interface_dev(nss_ctx, if_num); + if (!dev) { +- nss_warning("%p: Unable to find net device for the interface %d\n", nss_ctx, if_num); ++ nss_warning("%px: Unable to find net device for the interface %d\n", nss_ctx, if_num); + return; + } + + if (!nss_gre_redir_verify_ifnum(if_num)) { +- nss_warning("%p: Unknown type for interface %d\n", nss_ctx, if_num); ++ nss_warning("%px: Unknown type for interface %d\n", nss_ctx, if_num); + return; + } + +@@ -102,7 +102,7 @@ static void nss_gre_redir_tunnel_update_ + } + + if (i == NSS_GRE_REDIR_MAX_INTERFACES) { +- nss_warning("%p: Unable to find tunnel stats instance for interface %d\n", nss_ctx, if_num); ++ nss_warning("%px: Unable to find tunnel stats instance for interface %d\n", nss_ctx, if_num); + return; + } + +@@ -184,12 +184,12 @@ static void nss_gre_redir_msg_handler(st + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_GRE_REDIR_MAX_MSG_TYPES) { +- nss_warning("%p: Received invalid message %d for gre interface", nss_ctx, ncm->type); ++ nss_warning("%px: Received invalid message %d for gre interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_gre_redir_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -198,7 +198,7 @@ static void nss_gre_redir_msg_handler(st + * to the same callback/app_data. + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; + } + +@@ -261,7 +261,7 @@ static struct nss_ctx_instance *nss_gre_ + + if (idx == -1) { + spin_unlock_bh(&nss_gre_redir_stats_lock); +- nss_warning("%p: Maximum number of gre_redir tunnel_stats instances are already allocated\n", nss_ctx); ++ nss_warning("%px: Maximum number of gre_redir tunnel_stats instances are already allocated\n", nss_ctx); + return NULL; + } + +@@ -284,13 +284,29 @@ static struct nss_ctx_instance *nss_gre_ + } + spin_unlock_bh(&nss_gre_redir_stats_lock); + +- nss_warning("%p: Not able to register handler for gre_redir interface %d with NSS core\n", nss_ctx, if_num); ++ nss_warning("%px: Not able to register handler for gre_redir interface %d with NSS core\n", nss_ctx, if_num); ++ return NULL; ++ } ++ ++ /* ++ * Registering handler for sending tunnel interface msgs to NSS. ++ */ ++ status = nss_core_register_msg_handler(nss_ctx, if_num, cb_func_msg); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_core_unregister_handler(nss_ctx, if_num); ++ spin_lock_bh(&nss_gre_redir_stats_lock); ++ tun_stats[idx].ref_count--; ++ if (!tun_stats[idx].ref_count) { ++ tun_stats[idx].dev = NULL; ++ } ++ spin_unlock_bh(&nss_gre_redir_stats_lock); ++ ++ nss_warning("%px: Not able to register handler for gre_redir interface %d with NSS core\n", nss_ctx, if_num); + return NULL; + } + + nss_core_register_subsys_dp(nss_ctx, if_num, cb_func_data, NULL, NULL, netdev, features); + nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, type); +- nss_top_main.if_rx_msg_callback[if_num] = cb_func_msg; + return nss_ctx; + } + +@@ -324,13 +340,13 @@ int nss_gre_redir_alloc_and_register_nod + (type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_US) && + (type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_DS)) { + +- nss_warning("%p: Unknown type %u\n", dev, type); ++ nss_warning("%px: Unknown type %u\n", dev, type); + return -1; + } + + ifnum = nss_dynamic_interface_alloc_node(type); + if (ifnum == -1) { +- nss_warning("%p: Unable to allocate GRE_REDIR node of type = %u\n", dev, type); ++ nss_warning("%px: Unable to allocate GRE_REDIR node of type = %u\n", dev, type); + return -1; + } + +@@ -369,12 +385,12 @@ nss_tx_status_t nss_gre_redir_configure_ + + if (ngrcm->ip_hdr_type != NSS_GRE_REDIR_IP_HDR_TYPE_IPV4 && + ngrcm->ip_hdr_type != NSS_GRE_REDIR_IP_HDR_TYPE_IPV6) { +- nss_warning("%p: Unknown IP header type %u\n", nss_ctx, ngrcm->ip_hdr_type); ++ nss_warning("%px: Unknown IP header type %u\n", nss_ctx, ngrcm->ip_hdr_type); + return NSS_TX_FAILURE_BAD_PARAM; + } + + if (ngrcm->gre_version != NSS_GRE_REDIR_HEADER_VERSION) { +- nss_warning("%p: Incorrect header version %u\n", nss_ctx, ngrcm->gre_version); ++ nss_warning("%px: Incorrect header version %u\n", nss_ctx, ngrcm->gre_version); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -383,13 +399,13 @@ nss_tx_status_t nss_gre_redir_configure_ + (iftype == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_OFFL_INNER) || + (iftype == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_SJACK_INNER))) { + +- nss_warning("%p: Incorrect interface type %u\n", nss_ctx, iftype); ++ nss_warning("%px: Incorrect interface type %u\n", nss_ctx, iftype); + return NSS_TX_FAILURE_BAD_PARAM; + } + + outerif_type = nss_dynamic_interface_get_type(nss_ctx, ngrcm->except_outerif); + if (outerif_type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_OUTER) { +- nss_warning("%p: Incorrect type for exception interface %u\n", nss_ctx, outerif_type); ++ nss_warning("%px: Incorrect type for exception interface %u\n", nss_ctx, outerif_type); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -409,7 +425,7 @@ nss_tx_status_t nss_gre_redir_configure_ + + status = nss_gre_redir_tx_msg_sync(nss_ctx, &config); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to configure inner node %d.\n", nss_ctx, ifnum); ++ nss_warning("%px: Unable to configure inner node %d.\n", nss_ctx, ifnum); + } + + return status; +@@ -436,13 +452,13 @@ nss_tx_status_t nss_gre_redir_exception_ + + iftype = nss_dynamic_interface_get_type(nss_ctx, ifnum); + if (iftype != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_DS) { +- nss_warning("%p: Incorrect interface type %u\n", nss_ctx, iftype); ++ nss_warning("%px: Incorrect interface type %u\n", nss_ctx, iftype); + return NSS_TX_FAILURE_BAD_PARAM; + } + + vap_type = nss_dynamic_interface_get_type(nss_ctx, ngrcm->dst_vap_nssif); + if ((vap_type != NSS_DYNAMIC_INTERFACE_TYPE_VAP)) { +- nss_warning("%p: Incorrect type for vap interface type = %u", nss_ctx, vap_type); ++ nss_warning("%px: Incorrect type for vap interface type = %u", nss_ctx, vap_type); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -454,7 +470,7 @@ nss_tx_status_t nss_gre_redir_exception_ + + status = nss_gre_redir_tx_msg_sync(nss_ctx, &config); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to register callback from gre redir exception ds %d\n", nss_ctx, ifnum); ++ nss_warning("%px: Unable to register callback from gre redir exception ds %d\n", nss_ctx, ifnum); + } + + return status; +@@ -481,13 +497,13 @@ nss_tx_status_t nss_gre_redir_configure_ + + if (ngrcm->ip_hdr_type != NSS_GRE_REDIR_IP_HDR_TYPE_IPV4 && + ngrcm->ip_hdr_type != NSS_GRE_REDIR_IP_HDR_TYPE_IPV6) { +- nss_warning("%p: Unknown IP header type %u\n", nss_ctx, ngrcm->ip_hdr_type); ++ nss_warning("%px: Unknown IP header type %u\n", nss_ctx, ngrcm->ip_hdr_type); + return NSS_TX_FAILURE_BAD_PARAM; + } + + iftype = nss_dynamic_interface_get_type(nss_ctx, ifnum); + if (iftype != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_OUTER) { +- nss_warning("%p: Incorrect interface type %u\n", nss_ctx, iftype); ++ nss_warning("%px: Incorrect interface type %u\n", nss_ctx, iftype); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -499,7 +515,7 @@ nss_tx_status_t nss_gre_redir_configure_ + (ngrcm->except_sjackif + && sjackif_type != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_SJACK_INNER)) { + +- nss_warning("%p: Incorrect type for exception interface hostif_type = %u" ++ nss_warning("%px: Incorrect type for exception interface hostif_type = %u" + "offlif_type = %u sjackif_type = %u\n", nss_ctx, hostif_type, + offlif_type, sjackif_type); + return NSS_TX_FAILURE_BAD_PARAM; +@@ -517,7 +533,7 @@ nss_tx_status_t nss_gre_redir_configure_ + + status = nss_gre_redir_tx_msg_sync(nss_ctx, &config); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to configure outer node %d\n", nss_ctx, ifnum); ++ nss_warning("%px: Unable to configure outer node %d\n", nss_ctx, ifnum); + } + + return status; +@@ -565,12 +581,12 @@ nss_tx_status_t nss_gre_redir_tx_msg(str + */ + if (((ncm->interface < NSS_DYNAMIC_IF_START) || (ncm->interface >= (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES))) && + ncm->interface != NSS_GRE_REDIR_INTERFACE) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_GRE_REDIR_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -592,14 +608,14 @@ nss_tx_status_t nss_gre_redir_tx_msg_syn + ngrm->cm.app_data = (nss_ptr_t)NULL; + status = nss_gre_redir_tx_msg(nss_ctx, ngrm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: gre_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: gre_tx_msg failed\n", nss_ctx); + up(&nss_gre_redir_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&nss_gre_redir_pvt.complete, msecs_to_jiffies(NSS_GRE_REDIR_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: GRE tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: GRE tx sync failed due to timeout\n", nss_ctx); + nss_gre_redir_pvt.response = NSS_TX_FAILURE; + } + +@@ -617,7 +633,7 @@ nss_tx_status_t nss_gre_redir_tx_buf(str + { + uint32_t type; + +- nss_trace("%p: gre_redir If Tx packet, id:%d, data=%p", nss_ctx, if_num, os_buf->data); ++ nss_trace("%px: gre_redir If Tx packet, id:%d, data=%px", nss_ctx, if_num, os_buf->data); + + /* + * We expect Tx packets to the tunnel only from an interface of +@@ -626,7 +642,7 @@ nss_tx_status_t nss_gre_redir_tx_buf(str + type = nss_dynamic_interface_get_type(nss_ctx, if_num); + if (!((type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_HOST_INNER) + || (type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_DS))) { +- nss_warning("%p: Unknown type for interface %u\n", nss_ctx, type); ++ nss_warning("%px: Unknown type for interface %u\n", nss_ctx, type); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -642,7 +658,7 @@ nss_tx_status_t nss_gre_redir_tx_buf_nor + { + uint32_t type; + +- nss_trace("%p: gre_redir If Tx packet, id:%d, data=%p", nss_ctx, if_num, os_buf->data); ++ nss_trace("%px: gre_redir If Tx packet, id:%d, data=%px", nss_ctx, if_num, os_buf->data); + + /* + * We expect Tx packets to the tunnel only from an interface of +@@ -651,7 +667,7 @@ nss_tx_status_t nss_gre_redir_tx_buf_nor + type = nss_dynamic_interface_get_type(nss_ctx, if_num); + if (!((type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_HOST_INNER) + || (type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_DS))) { +- nss_warning("%p: Unknown type for interface %u\n", nss_ctx, type); ++ nss_warning("%px: Unknown type for interface %u\n", nss_ctx, type); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -675,19 +691,24 @@ bool nss_gre_redir_unregister_if(uint32_ + + dev = nss_cmn_get_interface_dev(nss_ctx, if_num); + if (!dev) { +- nss_warning("%p: Unable to find net device for the interface %d\n", nss_ctx, if_num); ++ nss_warning("%px: Unable to find net device for the interface %d\n", nss_ctx, if_num); ++ return false; ++ } ++ ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to unregister handler for gre_redir interface %d with NSS core\n", nss_ctx, if_num); + return false; + } + + status = nss_core_unregister_handler(nss_ctx, if_num); + if (status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Not able to unregister handler for gre_redir interface %d with NSS core\n", nss_ctx, if_num); ++ nss_warning("%px: Not able to unregister handler for gre_redir interface %d with NSS core\n", nss_ctx, if_num); + return false; + } + + nss_core_set_subsys_dp_type(nss_ctx, dev, if_num, NSS_DYNAMIC_INTERFACE_TYPE_NONE); + nss_core_unregister_subsys_dp(nss_ctx, if_num); +- nss_top_main.if_rx_msg_callback[if_num] = NULL; + spin_lock_bh(&nss_gre_redir_stats_lock); + + /* +@@ -740,7 +761,7 @@ void nss_gre_redir_register_handler(void + + gre_redir_dentry = nss_gre_redir_stats_dentry_create(); + if (!gre_redir_dentry) { +- nss_warning("%p: Not able to create debugfs entry\n", nss_ctx); ++ nss_warning("%px: Not able to create debugfs entry\n", nss_ctx); + return; + } + +@@ -751,7 +772,7 @@ void nss_gre_redir_register_handler(void + if (status != NSS_CORE_STATUS_SUCCESS) { + debugfs_remove_recursive(gre_redir_dentry); + gre_redir_dentry = NULL; +- nss_warning("%p: Not able to register handler for gre_redir base interface with NSS core\n", nss_ctx); ++ nss_warning("%px: Not able to register handler for gre_redir base interface with NSS core\n", nss_ctx); + return; + } + } +--- a/nss_gre_redir_lag_ds.c ++++ b/nss_gre_redir_lag_ds.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -88,7 +88,7 @@ static void nss_gre_redir_lag_ds_update_ + spin_lock_bh(&nss_gre_redir_lag_ds_stats_lock); + if (!nss_gre_redir_lag_ds_get_node_idx(ifnum, &idx)) { + spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); +- nss_warning("%p: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); ++ nss_warning("%px: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); + return; + } + +@@ -132,12 +132,12 @@ static void nss_gre_redir_lag_ds_msg_han + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_GRE_REDIR_LAG_DS_MAX_MSG_TYPES) { +- nss_warning("%p: received invalid message %d for gre interface\n", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for gre interface\n", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_gre_redir_lag_ds_msg)) { +- nss_warning("%p: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -146,7 +146,7 @@ static void nss_gre_redir_lag_ds_msg_han + * to the same callback/app_data. + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; + } + +@@ -197,18 +197,23 @@ static enum nss_gre_redir_lag_err_types + nss_assert(nss_ctx); + nss_assert(!nss_gre_redir_lag_ds_verify_ifnum(if_num)); + ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to unregister handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); ++ return NSS_GRE_REDIR_LAG_ERR_CORE_UNREGISTER_FAILED; ++ } ++ + status = nss_core_unregister_handler(nss_ctx, if_num); + if (status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Not able to unregister handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); ++ nss_warning("%px: Not able to unregister handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); + return NSS_GRE_REDIR_LAG_ERR_CORE_UNREGISTER_FAILED; + } + + nss_core_unregister_subsys_dp(nss_ctx, if_num); +- nss_top_main.if_rx_msg_callback[if_num] = NULL; + spin_lock_bh(&nss_gre_redir_lag_ds_stats_lock); + if (!nss_gre_redir_lag_ds_get_node_idx(if_num, &idx)) { + spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); +- nss_warning("%p: Stats context not found.\n", nss_ctx); ++ nss_warning("%px: Stats context not found.\n", nss_ctx); + return NSS_GRE_REDIR_LAG_ERR_STATS_INDEX_NOT_FOUND; + } + +@@ -235,13 +240,22 @@ static struct nss_ctx_instance *nss_gre_ + */ + status = nss_core_register_handler(nss_ctx, if_num, nss_gre_redir_lag_ds_msg_handler, app_ctx); + if (status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Not able to register handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); ++ nss_warning("%px: Not able to register handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); ++ return NULL; ++ } ++ ++ /* ++ * Registering handler for sending tunnel interface msgs to NSS. ++ */ ++ status = nss_core_register_msg_handler(nss_ctx, if_num, cb_func_msg); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_core_unregister_handler(nss_ctx, if_num); ++ nss_warning("%px: Not able to register handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); + return NULL; + } + + nss_core_register_subsys_dp(nss_ctx, if_num, cb_func_data, NULL, NULL, netdev, features); + nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, type); +- nss_top_main.if_rx_msg_callback[if_num] = cb_func_msg; + spin_lock_bh(&nss_gre_redir_lag_ds_stats_lock); + for (i = 0; i < NSS_GRE_REDIR_LAG_MAX_NODE; i++) { + if (!tun_stats[i].valid) { +@@ -304,12 +318,12 @@ nss_tx_status_t nss_gre_redir_lag_ds_tx_ + * of type NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS. + */ + if (!nss_gre_redir_lag_ds_verify_ifnum(ncm->interface)) { +- nss_warning("%p: tx request for another interface: %d\n", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d\n", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_GRE_REDIR_LAG_DS_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d\n", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d\n", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -334,14 +348,14 @@ nss_tx_status_t nss_gre_redir_lag_ds_tx_ + + status = nss_gre_redir_lag_ds_tx_msg(nss_ctx, ngrm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: GRE LAG DS msg tx failed\n", nss_ctx); ++ nss_warning("%px: GRE LAG DS msg tx failed\n", nss_ctx); + up(&nss_gre_redir_lag_ds_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&nss_gre_redir_lag_ds_pvt.complete, msecs_to_jiffies(NSS_GRE_REDIR_LAG_DS_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: GRE LAG DS tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: GRE LAG DS tx sync failed due to timeout\n", nss_ctx); + nss_gre_redir_lag_ds_pvt.response = NSS_TX_FAILURE; + } + +@@ -362,19 +376,19 @@ enum nss_gre_redir_lag_err_types nss_gre + nss_tx_status_t status; + + if (!nss_gre_redir_lag_ds_verify_ifnum(ifnum)) { +- nss_warning("%p: Unknown interface type %u.\n", nss_ctx, ifnum); ++ nss_warning("%px: Unknown interface type %u.\n", nss_ctx, ifnum); + return NSS_GRE_REDIR_LAG_ERR_INCORRECT_IFNUM; + } + + ret = nss_gre_redir_lag_ds_unregister_if(ifnum); + if (ret) { +- nss_warning("%p: Unable to unregister interface %u.\n", nss_ctx, ifnum); ++ nss_warning("%px: Unable to unregister interface %u.\n", nss_ctx, ifnum); + return ret; + } + + status = nss_dynamic_interface_dealloc_node(ifnum, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to deallocate node %u\n", nss_ctx, ifnum); ++ nss_warning("%px: Unable to deallocate node %u\n", nss_ctx, ifnum); + return NSS_GRE_REDIR_LAG_ERR_DEALLOC_FAILED; + } + +@@ -396,17 +410,17 @@ int nss_gre_redir_lag_ds_alloc_and_regis + + ifnum = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS); + if (ifnum == -1) { +- nss_warning("%p: Unable to allocate GRE_LAG node of type = %u\n", dev, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS); ++ nss_warning("%px: Unable to allocate GRE_LAG node of type = %u\n", dev, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS); + return -1; + } + + nss_ctx = nss_gre_redir_lag_ds_register_if(ifnum, dev, cb_func_data, + cb_func_msg, 0, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS, app_ctx); + if (!nss_ctx) { +- nss_warning("%p: Unable to register GRE_LAG node of type = %u\n", dev, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS); ++ nss_warning("%px: Unable to register GRE_LAG node of type = %u\n", dev, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS); + status = nss_dynamic_interface_dealloc_node(ifnum, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to deallocate node of type = %u.\n", dev, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS); ++ nss_warning("%px: Unable to deallocate node of type = %u.\n", dev, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS); + } + + return -1; +--- a/nss_gre_redir_lag_ds_log.c ++++ b/nss_gre_redir_lag_ds_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -51,8 +51,8 @@ static int8_t *nss_gre_redir_lag_ds_log_ + static void nss_gre_redir_lag_ds_log_add_sta_msg(struct nss_gre_redir_lag_ds_msg *ngm) + { + struct nss_gre_redir_lag_ds_add_sta_msg *ngasm __maybe_unused = &ngm->msg.add_sta; +- nss_trace("%p: NSS GRE REDIR LAG DS Add STA Message:\n" +- "GRE REDIR LAG DS Station MAC Address: %p\n" ++ nss_trace("%px: NSS GRE REDIR LAG DS Add STA Message:\n" ++ "GRE REDIR LAG DS Station MAC Address: %px\n" + "GRE REDIR LAG DS Reorder Type: %d\n", + ngasm, ngasm->mac, ngasm->reorder_type); + } +@@ -64,8 +64,8 @@ static void nss_gre_redir_lag_ds_log_add + static void nss_gre_redir_lag_ds_log_del_sta_msg(struct nss_gre_redir_lag_ds_msg *ngm) + { + struct nss_gre_redir_lag_ds_delete_sta_msg *ngdsm __maybe_unused = &ngm->msg.del_sta; +- nss_trace("%p: NSS GRE REDIR LAG DS Del STA Message:\n" +- "GRE REDIR LAG DS Station MAC Address: %p\n", ++ nss_trace("%px: NSS GRE REDIR LAG DS Del STA Message:\n" ++ "GRE REDIR LAG DS Station MAC Address: %px\n", + ngdsm, ngdsm->mac); + } + +@@ -76,8 +76,8 @@ static void nss_gre_redir_lag_ds_log_del + static void nss_gre_redir_lag_ds_log_update_sta_msg(struct nss_gre_redir_lag_ds_msg *ngm) + { + struct nss_gre_redir_lag_ds_update_sta_msg *ngusm __maybe_unused = &ngm->msg.update_sta; +- nss_trace("%p: NSS GRE REDIR LAG DS Update STA Message:\n" +- "GRE REDIR LAG DS Station MAC Address: %p\n" ++ nss_trace("%px: NSS GRE REDIR LAG DS Update STA Message:\n" ++ "GRE REDIR LAG DS Station MAC Address: %px\n" + "GRE REDIR LAG DS Reorder Type: %d\n", + ngusm, ngusm->mac, ngusm->reorder_type); + } +@@ -108,7 +108,7 @@ static void nss_gre_redir_lag_ds_log_ver + break; + + default: +- nss_warning("%p: Invalid message type\n", ngm); ++ nss_warning("%px: Invalid message type\n", ngm); + break; + } + } +@@ -120,11 +120,11 @@ static void nss_gre_redir_lag_ds_log_ver + void nss_gre_redir_lag_ds_log_tx_msg(struct nss_gre_redir_lag_ds_msg *ngm) + { + if (ngm->cm.type >= NSS_GRE_REDIR_LAG_DS_MAX_MSG_TYPES) { +- nss_warning("%p: Invalid message type\n", ngm); ++ nss_warning("%px: Invalid message type\n", ngm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_redir_lag_ds_log_message_types_str[ngm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_redir_lag_ds_log_message_types_str[ngm->cm.type]); + nss_gre_redir_lag_ds_log_verbose(ngm); + } + +@@ -135,26 +135,26 @@ void nss_gre_redir_lag_ds_log_tx_msg(str + void nss_gre_redir_lag_ds_log_rx_msg(struct nss_gre_redir_lag_ds_msg *ngm) + { + if (ngm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ngm); ++ nss_warning("%px: Invalid response\n", ngm); + return; + } + + if (ngm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ngm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ngm, ngm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ngm, ngm->cm.type, + nss_gre_redir_lag_ds_log_message_types_str[ngm->cm.type], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response]); + goto verbose; + } + + if (ngm->cm.error >= NSS_GRE_REDIR_LAG_ERR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ngm, ngm->cm.type, nss_gre_redir_lag_ds_log_message_types_str[ngm->cm.type], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response], + ngm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ngm, ngm->cm.type, nss_gre_redir_lag_ds_log_message_types_str[ngm->cm.type], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response], + ngm->cm.error, nss_gre_redir_lag_ds_log_error_response_types_str[ngm->cm.error]); +--- a/nss_gre_redir_lag_us.c ++++ b/nss_gre_redir_lag_us.c +@@ -111,7 +111,7 @@ static void nss_gre_redir_lag_us_update_ + spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); + if (!nss_gre_redir_lag_us_get_node_idx(ifnum, &idx)) { + spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); +- nss_warning("%p: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); ++ nss_warning("%px: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); + return; + } + +@@ -150,7 +150,7 @@ static void nss_gre_redir_lag_us_hash_up + spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); + if (!nss_gre_redir_lag_us_get_node_idx(ifnum, &idx)) { + spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); +- nss_warning("%p: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); ++ nss_warning("%px: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); + return; + } + +@@ -209,12 +209,12 @@ static void nss_gre_redir_lag_us_msg_han + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_GRE_REDIR_LAG_US_MAX_MSG_TYPES) { +- nss_warning("%p: received invalid message %d for gre interface\n", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for gre interface\n", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_gre_redir_lag_us_msg)) { +- nss_warning("%p: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -223,7 +223,7 @@ static void nss_gre_redir_lag_us_msg_han + * to the same callback/app_data. + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; + } + +@@ -274,12 +274,12 @@ static nss_tx_status_t nss_gre_redir_lag + * interface of type NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US. + */ + if (!nss_gre_redir_lag_us_verify_ifnum(ncm->interface)) { +- nss_warning("%p: tx request for another interface: %d\n", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d\n", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_GRE_REDIR_LAG_US_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d\n", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d\n", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -311,14 +311,14 @@ static nss_tx_status_t nss_gre_redir_lag + + status = nss_gre_redir_lag_us_tx_msg_with_size(nss_ctx, ngrm, size); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: gre_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: gre_tx_msg failed\n", nss_ctx); + up(&nss_gre_redir_lag_us_sync_ctx.sem); + return status; + } + + ret = wait_for_completion_timeout(&nss_gre_redir_lag_us_sync_ctx.complete, msecs_to_jiffies(NSS_GRE_REDIR_LAG_US_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: GRE LAG US tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: GRE LAG US tx sync failed due to timeout\n", nss_ctx); + nss_gre_redir_lag_us_sync_ctx.response = NSS_TX_FAILURE; + } + +@@ -358,7 +358,7 @@ static void nss_gre_redir_lag_us_stats_s + } + + retry--; +- nss_warning("%p: TX_NOT_OKAY, try again later\n", nss_ctx); ++ nss_warning("%px: TX_NOT_OKAY, try again later\n", nss_ctx); + usleep_range(100, 200); + } + +@@ -383,7 +383,7 @@ static bool nss_gre_redir_lag_us_sync_wo + spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); + if (!nss_gre_redir_lag_us_get_node_idx(ifnum, &idx)) { + spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); +- nss_warning("%p: Unable to init work. Stats context not found.\n", nss_ctx); ++ nss_warning("%px: Unable to init work. Stats context not found.\n", nss_ctx); + return false; + } + +@@ -394,7 +394,7 @@ static bool nss_gre_redir_lag_us_sync_wo + &(cmn_ctx.stats_ctx[idx].nss_gre_redir_lag_us_work), NSS_GRE_REDIR_LAG_US_STATS_SYNC_PERIOD); + if (!ret) { + spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); +- nss_warning("%p: Unable to queue work function to work queue\n", nss_ctx); ++ nss_warning("%px: Unable to queue work function to work queue\n", nss_ctx); + return false; + } + +@@ -415,14 +415,19 @@ static enum nss_gre_redir_lag_err_types + nss_assert(nss_ctx); + nss_assert(!nss_gre_redir_lag_us_verify_ifnum(if_num)); + ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to unregister handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); ++ return NSS_GRE_REDIR_LAG_ERR_CORE_UNREGISTER_FAILED; ++ } ++ + status = nss_core_unregister_handler(nss_ctx, if_num); + if (status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Not able to unregister handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); ++ nss_warning("%px: Not able to unregister handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); + return NSS_GRE_REDIR_LAG_ERR_CORE_UNREGISTER_FAILED; + } + + nss_core_unregister_subsys_dp(nss_ctx, if_num); +- nss_top_main.if_rx_msg_callback[if_num] = NULL; + + spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); + if (!nss_gre_redir_lag_us_get_node_idx(if_num, &idx)) { +@@ -479,7 +484,22 @@ static struct nss_ctx_instance *nss_gre_ + */ + status = nss_core_register_handler(nss_ctx, if_num, nss_gre_redir_lag_us_msg_handler, app_ctx); + if (status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Not able to register handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); ++ nss_warning("%px: Not able to register handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); ++ spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); ++ cmn_ctx.stats_ctx[i].valid = false; ++ cmn_ctx.stats_ctx[i].cb = NULL; ++ cmn_ctx.stats_ctx[i].app_data = NULL; ++ spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); ++ return NULL; ++ } ++ ++ /* ++ * Registering handler for sending tunnel interface msgs to NSS. ++ */ ++ status = nss_core_register_msg_handler(nss_ctx, if_num, cb_func_msg); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_core_unregister_handler(nss_ctx, if_num); ++ nss_warning("%px: Not able to register handler for gre_lag interface %d with NSS core\n", nss_ctx, if_num); + spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); + cmn_ctx.stats_ctx[i].valid = false; + cmn_ctx.stats_ctx[i].cb = NULL; +@@ -490,7 +510,6 @@ static struct nss_ctx_instance *nss_gre_ + + nss_core_register_subsys_dp(nss_ctx, if_num, cb_func_data, NULL, NULL, netdev, features); + nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, type); +- nss_top_main.if_rx_msg_callback[if_num] = cb_func_msg; + return nss_ctx; + } + +@@ -524,32 +543,32 @@ bool nss_gre_redir_lag_us_configure_node + + config = (struct nss_gre_redir_lag_us_msg *) kzalloc(sizeof(struct nss_gre_redir_lag_us_msg), GFP_KERNEL); + if (!config) { +- nss_warning("%p: Unable to allocate memory to send configure message.\n", nss_ctx); ++ nss_warning("%px: Unable to allocate memory to send configure message.\n", nss_ctx); + return false; + } + + iftype = nss_dynamic_interface_get_type(nss_ctx, ifnum); + if (iftype != NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US) { +- nss_warning("%p: Incorrect interface type %u\n", nss_ctx, iftype); ++ nss_warning("%px: Incorrect interface type %u\n", nss_ctx, iftype); + kfree(config); + return false; + } + + if (!ngluc) { +- nss_warning("%p: Pointer to GRE redir LAG US message is NULL.\n", nss_ctx); ++ nss_warning("%px: Pointer to GRE redir LAG US message is NULL.\n", nss_ctx); + kfree(config); + return false; + } + + if ((ngluc->num_slaves < NSS_GRE_REDIR_LAG_MIN_SLAVE) || (ngluc->num_slaves > NSS_GRE_REDIR_LAG_MAX_SLAVE)) { +- nss_warning("%p: Number of slaves is not in reange\n", nss_ctx); ++ nss_warning("%px: Number of slaves is not in reange\n", nss_ctx); + kfree(config); + return false; + } + + ret = nss_gre_redir_lag_us_sync_work_init(ifnum); + if (!ret) { +- nss_warning("%p: Unable to initialize work queue\n", nss_ctx); ++ nss_warning("%px: Unable to initialize work queue\n", nss_ctx); + kfree(config); + return false; + } +@@ -571,7 +590,7 @@ bool nss_gre_redir_lag_us_configure_node + spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); + if (nss_gre_redir_lag_us_get_node_idx(ifnum, &idx)) { + spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); +- nss_warning("%p: Stats context not found.\n", nss_ctx); ++ nss_warning("%px: Stats context not found.\n", nss_ctx); + return false; + } + +@@ -581,7 +600,7 @@ bool nss_gre_redir_lag_us_configure_node + * Work is per LAG US node. Cancel work as configuration failed. + */ + cancel_delayed_work_sync(&(cmn_ctx.stats_ctx[idx].nss_gre_redir_lag_us_work)); +- nss_warning("%p: Unable to configure upstream lag node %d.\n", nss_ctx, ifnum); ++ nss_warning("%px: Unable to configure upstream lag node %d.\n", nss_ctx, ifnum); + return false; + } + EXPORT_SYMBOL(nss_gre_redir_lag_us_configure_node); +@@ -645,19 +664,19 @@ enum nss_gre_redir_lag_err_types nss_gre + nss_tx_status_t status; + + if (!nss_gre_redir_lag_us_verify_ifnum(ifnum)) { +- nss_warning("%p: Unknown interface type %u.\n", nss_ctx, ifnum); ++ nss_warning("%px: Unknown interface type %u.\n", nss_ctx, ifnum); + return NSS_GRE_REDIR_LAG_ERR_INCORRECT_IFNUM; + } + + ret = nss_gre_redir_lag_us_unregister_if(ifnum); + if (ret) { +- nss_warning("%p: Unable to unregister interface %u.\n", nss_ctx, ifnum); ++ nss_warning("%px: Unable to unregister interface %u.\n", nss_ctx, ifnum); + return ret; + } + + status = nss_dynamic_interface_dealloc_node(ifnum, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to deallocate node %u\n", nss_ctx, ifnum); ++ nss_warning("%px: Unable to deallocate node %u\n", nss_ctx, ifnum); + return NSS_GRE_REDIR_LAG_ERR_DEALLOC_FAILED; + } + +@@ -679,17 +698,17 @@ int nss_gre_redir_lag_us_alloc_and_regis + + ifnum = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US); + if (ifnum == -1) { +- nss_warning("%p: Unable to allocate GRE_LAG node of type = %u\n", dev, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US); ++ nss_warning("%px: Unable to allocate GRE_LAG node of type = %u\n", dev, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US); + return -1; + } + + nss_ctx = nss_gre_redir_lag_us_register_if(ifnum, dev, cb_func_data, + cb_func_msg, 0, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US, app_ctx); + if (!nss_ctx) { +- nss_warning("%p: Unable to register GRE_LAG node of type = %u\n", dev, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US); ++ nss_warning("%px: Unable to register GRE_LAG node of type = %u\n", dev, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US); + status = nss_dynamic_interface_dealloc_node(ifnum, NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to deallocate node.\n", dev); ++ nss_warning("%px: Unable to deallocate node.\n", dev); + } + + return -1; +--- a/nss_gre_redir_lag_us_log.c ++++ b/nss_gre_redir_lag_us_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -53,10 +53,10 @@ static int8_t *nss_gre_redir_lag_us_log_ + static void nss_gre_redir_lag_us_log_config_msg(struct nss_gre_redir_lag_us_msg *ngm) + { + struct nss_gre_redir_lag_us_config_msg *ngcm __maybe_unused = &ngm->msg.config_us; +- nss_trace("%p: NSS GRE REDIR LAG Config Message:\n" ++ nss_trace("%px: NSS GRE REDIR LAG Config Message:\n" + "GRE REDIR LAG US Hash Mode: %d\n" + "GRE REDIR LAG US Number of Slaves: %d\n" +- "GRE REDIR LAG US Interface Number: %p\n", ++ "GRE REDIR LAG US Interface Number: %px\n", + ngcm, ngcm->hash_mode, ngcm->num_slaves, + ngcm->if_num); + } +@@ -68,10 +68,10 @@ static void nss_gre_redir_lag_us_log_con + static void nss_gre_redir_lag_us_log_add_hash_node_msg(struct nss_gre_redir_lag_us_msg *ngm) + { + struct nss_gre_redir_lag_us_add_hash_node_msg *ngam __maybe_unused = &ngm->msg.add_hash; +- nss_trace("%p: NSS GRE REDIR LAG Add Hash Node Message:\n" ++ nss_trace("%px: NSS GRE REDIR LAG Add Hash Node Message:\n" + "GRE REDIR LAG US Interface Number: %d\n" +- "GRE REDIR LAG US Source MAC: %p\n" +- "GRE REDIR LAG US Destination MAC: %p\n", ++ "GRE REDIR LAG US Source MAC: %px\n" ++ "GRE REDIR LAG US Destination MAC: %px\n", + ngam, ngam->if_num, ngam->src_mac, + ngam->dest_mac); + } +@@ -83,9 +83,9 @@ static void nss_gre_redir_lag_us_log_add + static void nss_gre_redir_lag_us_log_del_hash_node_msg(struct nss_gre_redir_lag_us_msg *ngm) + { + struct nss_gre_redir_lag_us_del_hash_node_msg *ngdm __maybe_unused = &ngm->msg.del_hash; +- nss_trace("%p: NSS GRE REDIR LAG Del Hash Node Message:\n" +- "GRE REDIR LAG US Source MAC: %p\n" +- "GRE REDIR LAG US Destination MAC: %p\n", ++ nss_trace("%px: NSS GRE REDIR LAG Del Hash Node Message:\n" ++ "GRE REDIR LAG US Source MAC: %px\n" ++ "GRE REDIR LAG US Destination MAC: %px\n", + ngdm, ngdm->src_mac,ngdm->dest_mac); + } + +@@ -96,9 +96,9 @@ static void nss_gre_redir_lag_us_log_del + static void nss_gre_redir_lag_us_log_query_hash_node_msg(struct nss_gre_redir_lag_us_msg *ngm) + { + struct nss_gre_redir_lag_us_query_hash_node_msg *ngqm __maybe_unused = &ngm->msg.query_hash; +- nss_trace("%p: NSS GRE REDIR LAG Query Hash Node Message:\n" +- "GRE REDIR LAG US Source MAC: %p\n" +- "GRE REDIR LAG US Destination MAC: %p\n" ++ nss_trace("%px: NSS GRE REDIR LAG Query Hash Node Message:\n" ++ "GRE REDIR LAG US Source MAC: %px\n" ++ "GRE REDIR LAG US Destination MAC: %px\n" + "GRE REDIR LAG US Interface Number: %d\n", + ngqm, ngqm->src_mac, ngqm->dest_mac, + ngqm->ifnum); +@@ -135,7 +135,7 @@ static void nss_gre_redir_lag_us_log_ver + break; + + default: +- nss_warning("%p: Invalid message type\n", ngm); ++ nss_warning("%px: Invalid message type\n", ngm); + break; + } + } +@@ -147,11 +147,11 @@ static void nss_gre_redir_lag_us_log_ver + void nss_gre_redir_lag_us_log_tx_msg(struct nss_gre_redir_lag_us_msg *ngm) + { + if (ngm->cm.type >= NSS_GRE_REDIR_LAG_US_MAX_MSG_TYPES) { +- nss_warning("%p: Invalid message type\n", ngm); ++ nss_warning("%px: Invalid message type\n", ngm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_redir_lag_us_log_message_types_str[ngm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_redir_lag_us_log_message_types_str[ngm->cm.type]); + nss_gre_redir_lag_us_log_verbose(ngm); + } + +@@ -162,26 +162,26 @@ void nss_gre_redir_lag_us_log_tx_msg(str + void nss_gre_redir_lag_us_log_rx_msg(struct nss_gre_redir_lag_us_msg *ngm) + { + if (ngm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ngm); ++ nss_warning("%px: Invalid response\n", ngm); + return; + } + + if (ngm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ngm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ngm, ngm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ngm, ngm->cm.type, + nss_gre_redir_lag_us_log_message_types_str[ngm->cm.type], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response]); + goto verbose; + } + + if (ngm->cm.error >= NSS_GRE_REDIR_LAG_ERR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ngm, ngm->cm.type, nss_gre_redir_lag_us_log_message_types_str[ngm->cm.type], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response], + ngm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ngm, ngm->cm.type, nss_gre_redir_lag_us_log_message_types_str[ngm->cm.type], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response], + ngm->cm.error, nss_gre_redir_lag_us_log_error_response_types_str[ngm->cm.error]); +--- a/nss_gre_redir_log.c ++++ b/nss_gre_redir_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018-2020, 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. +@@ -43,10 +43,10 @@ static int8_t *nss_gre_redir_log_message + static void nss_gre_redir_log_inner_configure_msg(struct nss_gre_redir_msg *ngm) + { + struct nss_gre_redir_inner_configure_msg *ngicm __maybe_unused = &ngm->msg.inner_configure; +- nss_trace("%p: NSS GRE Redir Inner Configure message" ++ nss_trace("%px: NSS GRE Redir Inner Configure message" + "GRE REDIR IP Header Type: %d\n" +- "GRE REDIR Source IP: %p\n" +- "GRE REDIR Destination IP: %p\n" ++ "GRE REDIR Source IP: %px\n" ++ "GRE REDIR Destination IP: %px\n" + "GRE REDIR Outer Interface: %d\n" + "GRE REDIR Do not Fragment: %d\n" + "GRE REDIR IP TTL: %d\n" +@@ -64,7 +64,7 @@ static void nss_gre_redir_log_inner_conf + static void nss_gre_redir_log_interface_map_msg(struct nss_gre_redir_msg *ngm) + { + struct nss_gre_redir_interface_map_msg *ngicm __maybe_unused = &ngm->msg.interface_map; +- nss_trace("%p: NSS GRE Redir Interface Map message" ++ nss_trace("%px: NSS GRE Redir Interface Map message" + "GRE REDIR NSS VAP Interface: %d\n" + "GRE REDIR Next Hop NSS Interface: %d\n" + "GRE REDIR Radio ID: %d\n" +@@ -85,7 +85,7 @@ static void nss_gre_redir_log_interface_ + static void nss_gre_redir_log_interface_unmap_msg(struct nss_gre_redir_msg *ngm) + { + struct nss_gre_redir_interface_unmap_msg *ngicm __maybe_unused = &ngm->msg.interface_unmap; +- nss_trace("%p: NSS GRE Redir Interface Map message" ++ nss_trace("%px: NSS GRE Redir Interface Map message" + "GRE REDIR NSS VAP Interface: %d\n" + "GRE REDIR Radio ID: %d\n" + "GRE REDIR VAP ID: %d\n", +@@ -100,7 +100,7 @@ static void nss_gre_redir_log_interface_ + static void nss_gre_redir_log_sjack_map_msg(struct nss_gre_redir_msg *ngm) + { + struct nss_gre_redir_sjack_map_msg *ngscm __maybe_unused = &ngm->msg.sjack_map; +- nss_trace("%p: NSS GRE Redir SJACK Map message" ++ nss_trace("%px: NSS GRE Redir SJACK Map message" + "GRE REDIR Eth NSS Interface: %d\n" + "GRE REDIR Eth Interface ID: %d\n" + "GRE REDIR IPSec pattern: %x\n", +@@ -115,7 +115,7 @@ static void nss_gre_redir_log_sjack_map_ + static void nss_gre_redir_log_sjack_unmap_msg(struct nss_gre_redir_msg *ngm) + { + struct nss_gre_redir_sjack_unmap_msg *ngscm __maybe_unused = &ngm->msg.sjack_unmap; +- nss_trace("%p: NSS GRE Redir SJACK Map message" ++ nss_trace("%px: NSS GRE Redir SJACK Map message" + "GRE REDIR Eth NSS Interface: %d\n" + "GRE REDIR Eth Interface ID: %d\n", + ngscm, ngscm->eth_nssif, +@@ -129,7 +129,7 @@ static void nss_gre_redir_log_sjack_unma + static void nss_gre_redir_log_outer_configure_msg(struct nss_gre_redir_msg *ngm) + { + struct nss_gre_redir_outer_configure_msg *ngocm __maybe_unused = &ngm->msg.outer_configure; +- nss_trace("%p: NSS GRE Redir Outer Configure message" ++ nss_trace("%px: NSS GRE Redir Outer Configure message" + "GRE REDIR IP Header Type: %d\n" + "GRE REDIR Host Inner Interface: %d\n" + "GRE REDIR NSS Inner Interface: %d\n" +@@ -149,7 +149,7 @@ static void nss_gre_redir_log_outer_conf + static void nss_gre_redir_log_exception_ds_reg_cb_msg(struct nss_gre_redir_msg *ngm) + { + struct nss_gre_redir_exception_ds_reg_cb_msg *exception_ds_configure __maybe_unused = &ngm->msg.exception_ds_configure; +- nss_trace("%p: NSS GRE redir exception completion callback registration message\n" ++ nss_trace("%px: NSS GRE redir exception completion callback registration message\n" + "vap_if_num: %d\n", ngm, exception_ds_configure->dst_vap_nssif); + } + +@@ -195,7 +195,7 @@ static void nss_gre_redir_log_verbose(st + break; + + default: +- nss_warning("%p: Invalid message type\n", ngm); ++ nss_warning("%px: Invalid message type\n", ngm); + break; + } + } +@@ -207,11 +207,11 @@ static void nss_gre_redir_log_verbose(st + void nss_gre_redir_log_tx_msg(struct nss_gre_redir_msg *ngm) + { + if (ngm->cm.type >= NSS_GRE_REDIR_MAX_MSG_TYPES) { +- nss_warning("%p: Invalid message type\n", ngm); ++ nss_warning("%px: Invalid message type\n", ngm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_redir_log_message_types_str[ngm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_redir_log_message_types_str[ngm->cm.type]); + nss_gre_redir_log_verbose(ngm); + } + +@@ -222,18 +222,18 @@ void nss_gre_redir_log_tx_msg(struct nss + void nss_gre_redir_log_rx_msg(struct nss_gre_redir_msg *ngm) + { + if (ngm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ngm); ++ nss_warning("%px: Invalid response\n", ngm); + return; + } + + if (ngm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ngm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ngm, ngm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ngm, ngm->cm.type, + nss_gre_redir_log_message_types_str[ngm->cm.type], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + ngm, ngm->cm.type, nss_gre_redir_log_message_types_str[ngm->cm.type], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response]); + +--- a/nss_gre_redir_mark.c ++++ b/nss_gre_redir_mark.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -62,12 +62,12 @@ static void nss_gre_redir_mark_stats_syn + struct net_device *dev; + dev = nss_cmn_get_interface_dev(nss_ctx, if_num); + if (!dev) { +- nss_warning("%p: Unable to find net device for the interface %d\n", nss_ctx, if_num); ++ nss_warning("%px: Unable to find net device for the interface %d\n", nss_ctx, if_num); + return; + } + + if (if_num != NSS_GRE_REDIR_MARK_INTERFACE) { +- nss_warning("%p: Unknown type for interface %d\n", nss_ctx, if_num); ++ nss_warning("%px: Unknown type for interface %d\n", nss_ctx, if_num); + return; + } + +@@ -116,12 +116,12 @@ static void nss_gre_redir_mark_handler(s + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_GRE_REDIR_MARK_MSG_MAX) { +- nss_warning("%p: received invalid message %d for GRE redir mark interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for GRE redir mark interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_gre_redir_mark_msg)) { +- nss_warning("%p: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -145,7 +145,7 @@ static void nss_gre_redir_mark_handler(s + * interface. + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_top_main.if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].ndev; + } + +@@ -202,7 +202,7 @@ nss_tx_status_t nss_gre_redir_mark_reg_c + + vap_type = nss_dynamic_interface_get_type(nss_ctx, ngrcm->nss_if_num); + if ((vap_type != NSS_DYNAMIC_INTERFACE_TYPE_VAP)) { +- nss_warning("%p: Incorrect type for vap interface type = %u", nss_ctx, vap_type); ++ nss_warning("%px: Incorrect type for vap interface type = %u", nss_ctx, vap_type); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -214,7 +214,7 @@ nss_tx_status_t nss_gre_redir_mark_reg_c + + status = nss_gre_redir_mark_tx_msg_sync(nss_ctx, &config); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to register callback from GRE redir mark interface %d\n", nss_ctx, ifnum); ++ nss_warning("%px: Unable to register callback from GRE redir mark interface %d\n", nss_ctx, ifnum); + } + + return status; +@@ -238,12 +238,12 @@ nss_tx_status_t nss_gre_redir_mark_tx_ms + * interface should be of type of redir mark + */ + if (ncm->interface != NSS_GRE_REDIR_MARK_INTERFACE) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_GRE_REDIR_MARK_MSG_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -268,14 +268,14 @@ nss_tx_status_t nss_gre_redir_mark_tx_ms + ngrm->cm.app_data = (nss_ptr_t)NULL; + status = nss_gre_redir_mark_tx_msg(nss_ctx, ngrm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: GRE redir mark tx_msg failed\n", nss_ctx); ++ nss_warning("%px: GRE redir mark tx_msg failed\n", nss_ctx); + up(&nss_gre_redir_mark_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&nss_gre_redir_mark_pvt.complete, msecs_to_jiffies(NSS_GRE_REDIR_MARK_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: GRE redir mark message tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: GRE redir mark message tx sync failed due to timeout\n", nss_ctx); + nss_gre_redir_mark_pvt.response = NSS_TX_FAILURE; + } + +@@ -291,13 +291,13 @@ EXPORT_SYMBOL(nss_gre_redir_mark_tx_msg_ + */ + nss_tx_status_t nss_gre_redir_mark_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num) + { +- nss_trace("%p: GRE redir mark If Tx packet, interface id:%d, data=%p", nss_ctx, if_num, os_buf->data); ++ nss_trace("%px: GRE redir mark If Tx packet, interface id:%d, data=%px", nss_ctx, if_num, os_buf->data); + + /* + * We expect Tx packets to the GRE redir mark interface only. + */ + if (if_num != NSS_GRE_REDIR_MARK_INTERFACE) { +- nss_warning("%p: Invalid interface:%d for GRE redir mark packets\n", nss_ctx, if_num); ++ nss_warning("%px: Invalid interface:%d for GRE redir mark packets\n", nss_ctx, if_num); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -323,6 +323,7 @@ bool nss_gre_redir_mark_unregister_if(ui + { + struct nss_ctx_instance *nss_ctx __maybe_unused = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.gre_redir_handler_id]; + struct net_device *dev; ++ uint32_t status; + + nss_assert(nss_ctx); + nss_assert(if_num == NSS_GRE_REDIR_MARK_INTERFACE); +@@ -332,7 +333,14 @@ bool nss_gre_redir_mark_unregister_if(ui + BUG_ON(!dev); + + nss_core_unregister_subsys_dp(nss_ctx, if_num); +- nss_top_main.if_rx_msg_callback[if_num] = NULL; ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to unregister handler for gre_redir_mark interface %d with NSS core\n", ++ nss_ctx, if_num); ++ return false; ++ } ++ ++ nss_ctx->nss_rx_interface_handlers[nss_ctx->id][if_num].msg_cb = NULL; + return true; + } + EXPORT_SYMBOL(nss_gre_redir_mark_unregister_if); +@@ -346,6 +354,7 @@ struct nss_ctx_instance *nss_gre_redir_m + uint32_t features) + { + struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.gre_redir_handler_id]; ++ uint32_t status; + + nss_assert(nss_ctx); + nss_assert(if_num == NSS_GRE_REDIR_MARK_INTERFACE); +@@ -354,7 +363,13 @@ struct nss_ctx_instance *nss_gre_redir_m + * Registering the interface with network data path. + */ + nss_core_register_subsys_dp(nss_ctx, if_num, cb_func_data, NULL, NULL, netdev, features); +- nss_top_main.if_rx_msg_callback[if_num] = cb_func_msg; ++ status = nss_core_register_msg_handler(nss_ctx, NSS_GRE_REDIR_MARK_INTERFACE, cb_func_msg); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to register handler for gre_redir_mark interface %d with NSS core\n", ++ nss_ctx, if_num); ++ return NULL; ++ } ++ + return nss_ctx; + } + EXPORT_SYMBOL(nss_gre_redir_mark_register_if); +@@ -385,7 +400,7 @@ void nss_gre_redir_mark_register_handler + */ + gre_redir_mark_dentry = nss_gre_redir_mark_stats_dentry_create(); + if (!gre_redir_mark_dentry) { +- nss_warning("%p: Not able to create debugfs entry\n", nss_ctx); ++ nss_warning("%px: Not able to create debugfs entry\n", nss_ctx); + return; + } + +@@ -397,7 +412,7 @@ void nss_gre_redir_mark_register_handler + if (status != NSS_CORE_STATUS_SUCCESS) { + debugfs_remove_recursive(gre_redir_mark_dentry); + gre_redir_mark_dentry = NULL; +- nss_warning("%p: Not able to register handler for GRE redir mark with NSS core\n", nss_ctx); ++ nss_warning("%px: Not able to register handler for GRE redir mark with NSS core\n", nss_ctx); + return; + } + } +--- a/nss_gre_redir_mark_log.c ++++ b/nss_gre_redir_mark_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -14,7 +14,6 @@ + ************************************************************************** + */ + +- + #include "nss_core.h" + + /* +@@ -43,7 +42,7 @@ static int8_t *nss_gre_redir_mark_log_er + static void nss_gre_redir_mark_log_reg_cb_msg(struct nss_gre_redir_mark_msg *ncm) + { + struct nss_gre_redir_mark_register_cb_msg *reg_cb_msg __maybe_unused = &ncm->msg.reg_cb_msg; +- nss_trace("%p: NSS GRE redir mark callback registration message \n" ++ nss_trace("%px: NSS GRE redir mark callback registration message \n" + "nss_if_num: %d\n", ncm, reg_cb_msg->nss_if_num); + } + +@@ -65,7 +64,7 @@ static void nss_gre_redir_mark_log_verbo + break; + + default: +- nss_trace("%p: Invalid message type\n", ncm); ++ nss_trace("%px: Invalid message type\n", ncm); + break; + } + } +@@ -77,11 +76,11 @@ static void nss_gre_redir_mark_log_verbo + void nss_gre_redir_mark_log_tx_msg(struct nss_gre_redir_mark_msg *ngm) + { + if (ngm->cm.type >= NSS_GRE_REDIR_MARK_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", ngm); ++ nss_warning("%px: Invalid message type\n", ngm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_redir_mark_log_message_types_str[ngm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_redir_mark_log_message_types_str[ngm->cm.type]); + nss_gre_redir_mark_log_verbose(ngm); + } + /* +@@ -91,26 +90,26 @@ void nss_gre_redir_mark_log_tx_msg(struc + void nss_gre_redir_mark_log_rx_msg(struct nss_gre_redir_mark_msg *ncm) + { + if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ncm); ++ nss_warning("%px: Invalid response\n", ncm); + return; + } + + if (ncm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ncm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, + nss_gre_redir_mark_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response]); + goto verbose; + } + + if (ncm->cm.error >= NSS_GRE_REDIR_MARK_ERROR_TYPE_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ncm, ncm->cm.type, nss_gre_redir_mark_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ncm, ncm->cm.type, nss_gre_redir_mark_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error, nss_gre_redir_mark_log_error_response_types_str[ncm->cm.error]); +@@ -118,4 +117,3 @@ void nss_gre_redir_mark_log_rx_msg(struc + verbose: + nss_gre_redir_mark_log_verbose(ncm); + } +- +--- a/nss_gre_tunnel.c ++++ b/nss_gre_tunnel.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016-2020, 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. +@@ -74,12 +74,12 @@ static void nss_gre_tunnel_handler(struc + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_GRE_TUNNEL_MSG_MAX) { +- nss_warning("%p: received invalid message %d for GRE_TUNNEL interface %d", nss_ctx, ncm->type, ncm->interface); ++ nss_warning("%px: received invalid message %d for GRE_TUNNEL interface %d", nss_ctx, ncm->type, ncm->interface); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_gre_tunnel_msg)) { +- nss_warning("%p: gre_tunnel message length is invalid: %d", nss_ctx, ncm->len); ++ nss_warning("%px: gre_tunnel message length is invalid: %d", nss_ctx, ncm->len); + return; + } + +@@ -153,7 +153,7 @@ nss_tx_status_t nss_gre_tunnel_inquiry( + nim.msg.configure = *inquiry_info; + nss_tx_status = nss_gre_tunnel_tx_msg(nss_ctx, &nim); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: Send GT inquiry message failed\n", inquiry_info); ++ nss_warning("%px: Send GT inquiry message failed\n", inquiry_info); + } + + return nss_tx_status; +@@ -181,7 +181,7 @@ int nss_gre_tunnel_ifnum_with_core_id(in + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (nss_is_dynamic_interface(if_num) == false) { +- nss_info("%p: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); ++ nss_info("%px: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); + return 0; + } + +@@ -219,7 +219,7 @@ nss_tx_status_t nss_gre_tunnel_tx_msg(st + * Sanity check message + */ + if (ncm->type >= NSS_GRE_TUNNEL_MSG_MAX) { +- nss_warning("%p: gre_tunnel message type out of range: %d", ++ nss_warning("%px: gre_tunnel message type out of range: %d", + nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } +@@ -272,7 +272,7 @@ nss_tx_status_t nss_gre_tunnel_tx_msg_sy + + status = nss_gre_tunnel_tx_msg(nss_ctx, ngtm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: gre_tunnel_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: gre_tunnel_tx_msg failed\n", nss_ctx); + up(&gre_tunnel_pvt.sem); + return status; + } +@@ -280,7 +280,7 @@ nss_tx_status_t nss_gre_tunnel_tx_msg_sy + ret = wait_for_completion_timeout(&gre_tunnel_pvt.complete, msecs_to_jiffies(NSS_GRE_TUNNEL_TX_TIMEOUT)); + + if (!ret) { +- nss_warning("%p: GRE Tunnel msg tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: GRE Tunnel msg tx failed due to timeout\n", nss_ctx); + gre_tunnel_pvt.response = NSS_TX_FAILURE; + } + +@@ -330,12 +330,12 @@ struct nss_ctx_instance *nss_gre_tunnel_ + spin_unlock_bh(&nss_gre_tunnel_stats_session_debug_lock); + + if (i == NSS_MAX_GRE_TUNNEL_SESSIONS) { +- nss_warning("%p: Cannot find free slot for GRE Tunnel session stats, I/F:%u\n", nss_ctx, if_num); ++ nss_warning("%px: Cannot find free slot for GRE Tunnel session stats, I/F:%u\n", nss_ctx, if_num); + return NULL; + } + + if (nss_ctx->subsys_dp_register[if_num].ndev) { +- nss_warning("%p: Cannot find free slot for GRE Tunnel NSS I/F:%u\n", nss_ctx, if_num); ++ nss_warning("%px: Cannot find free slot for GRE Tunnel NSS I/F:%u\n", nss_ctx, if_num); + nss_gre_tunnel_session_debug_stats[i].valid = false; + nss_gre_tunnel_session_debug_stats[i].if_num = 0; + nss_gre_tunnel_session_debug_stats[i].if_index = 0; +@@ -374,12 +374,12 @@ void nss_gre_tunnel_unregister_if(uint32 + spin_unlock_bh(&nss_gre_tunnel_stats_session_debug_lock); + + if (i == NSS_MAX_GRE_TUNNEL_SESSIONS) { +- nss_warning("%p: Cannot find debug stats for GRE Tunnel session: %d\n", nss_ctx, if_num); ++ nss_warning("%px: Cannot find debug stats for GRE Tunnel session: %d\n", nss_ctx, if_num); + return; + } + + if (!nss_ctx->subsys_dp_register[if_num].ndev) { +- nss_warning("%p: Cannot find registered netdev for GRE Tunnel NSS I/F: %d\n", nss_ctx, if_num); ++ nss_warning("%px: Cannot find registered netdev for GRE Tunnel NSS I/F: %d\n", nss_ctx, if_num); + + return; + } +--- a/nss_gre_tunnel_log.c ++++ b/nss_gre_tunnel_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -40,7 +40,7 @@ static int8_t *nss_gre_tunnel_log_messag + static void nss_gre_tunnel_log_configure_msg(struct nss_gre_tunnel_msg *ngm) + { + struct nss_gre_tunnel_configure *ngcm __maybe_unused = &ngm->msg.configure; +- nss_trace("%p: NSS GRE Tunnel configure message \n" ++ nss_trace("%px: NSS GRE Tunnel configure message \n" + "Meta Header Version: %d\n" + "GRE Mode: %x\n" + "IP Type: %x\n" +@@ -51,7 +51,7 @@ static void nss_gre_tunnel_log_configure + "Encryption Crypto Index: %d\n" + "Decryption Crypto Index: %d\n" + "Word0 header: %d\n" +- "Initialization Vector: %p\n" ++ "Initialization Vector: %px\n" + "Sibling Interface Number: %d\n" + "TTL: %d\n" + "RPS: %d\n" +@@ -90,7 +90,7 @@ static void nss_gre_tunnel_log_configure + static void nss_gre_tunnel_log_di_to_wlan_id_msg(struct nss_gre_tunnel_msg *ngm) + { + struct nss_gre_tunnel_di_to_wlan_id *ngdm __maybe_unused = &ngm->msg.dtwi; +- nss_trace("%p: NSS GRE Dynamic Interface to WLAN ID message: \n" ++ nss_trace("%px: NSS GRE Dynamic Interface to WLAN ID message: \n" + "Dynamic Interface Number: %d\n" + "WLAN ID: %x\n", + ngdm, ngdm->dynamic_interface_num, +@@ -121,7 +121,7 @@ static void nss_gre_tunnel_log_verbose(s + break; + + default: +- nss_trace("%p: Invalid message type\n", ngm); ++ nss_trace("%px: Invalid message type\n", ngm); + break; + } + } +@@ -133,11 +133,11 @@ static void nss_gre_tunnel_log_verbose(s + void nss_gre_tunnel_log_tx_msg(struct nss_gre_tunnel_msg *ngm) + { + if (ngm->cm.type >= NSS_GRE_TUNNEL_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", ngm); ++ nss_warning("%px: Invalid message type\n", ngm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_tunnel_log_message_types_str[ngm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ngm, ngm->cm.type, nss_gre_tunnel_log_message_types_str[ngm->cm.type]); + nss_gre_tunnel_log_verbose(ngm); + } + +@@ -148,18 +148,18 @@ void nss_gre_tunnel_log_tx_msg(struct ns + void nss_gre_tunnel_log_rx_msg(struct nss_gre_tunnel_msg *ngm) + { + if (ngm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ngm); ++ nss_warning("%px: Invalid response\n", ngm); + return; + } + + if (ngm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ngm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ngm, ngm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ngm, ngm->cm.type, + nss_gre_tunnel_log_message_types_str[ngm->cm.type], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + ngm, ngm->cm.type, nss_gre_tunnel_log_message_types_str[ngm->cm.type], + ngm->cm.response, nss_cmn_response_str[ngm->cm.response]); + +--- a/nss_gre_tunnel_stats.c ++++ b/nss_gre_tunnel_stats.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2017, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2017, 2020, 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. +@@ -76,7 +76,7 @@ void nss_gre_tunnel_stats_session_sync(s + + if (!s) { + spin_unlock_bh(&nss_gre_tunnel_stats_session_debug_lock); +- nss_warning("%p: Session not found: %u", nss_ctx, if_num); ++ nss_warning("%px: Session not found: %u", nss_ctx, if_num); + return; + } + +@@ -247,4 +247,3 @@ void nss_gre_tunnel_stats_dentry_create( + { + nss_stats_create_dentry("gre_tunnel", &nss_gre_tunnel_stats_ops); + } +- +--- a/nss_if.c ++++ b/nss_if.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014-2016, 2018-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014-2016, 2018-2020, 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. +@@ -20,6 +20,74 @@ + */ + + #include "nss_tx_rx_common.h" ++#include "nss_if_log.h" ++ ++/* ++ * nss_if_pvt ++ * NSS private structure to handle the completion of NSS -> HLOS messages. ++ */ ++static struct nss_if_pvt { ++ struct semaphore sem; ++ struct completion complete; ++ int response; ++} nss_if; ++ ++static bool nss_if_sem_init_done; ++ ++/* ++ * nss_if_callback ++ * Callback to handle the completion of NSS ->HLOS messages. ++ */ ++static void nss_if_callback(void *app_data, struct nss_if_msg *nim) ++{ ++ if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { ++ nss_warning("nss_if Error response %d\n", nim->cm.response); ++ nss_if.response = NSS_TX_FAILURE; ++ complete(&nss_if.complete); ++ return; ++ } ++ ++ nss_if.response = NSS_TX_SUCCESS; ++ complete(&nss_if.complete); ++} ++ ++/* ++ * nss_if_msg_sync() ++ * Send a message to an interface and wait for the response. ++ */ ++nss_tx_status_t nss_if_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_if_msg *nim) ++{ ++ nss_tx_status_t status; ++ int ret = 0; ++ ++ if (!nss_if_sem_init_done) { ++ sema_init(&nss_if.sem, 1); ++ init_completion(&nss_if.complete); ++ nss_if_sem_init_done = 1; ++ } ++ ++ down(&nss_if.sem); ++ ++ status = nss_if_tx_msg(nss_ctx, nim); ++ if (status != NSS_TX_SUCCESS) { ++ nss_warning("%px: nss_if_msg failed\n", nss_ctx); ++ up(&nss_if.sem); ++ return status; ++ } ++ ++ ret = wait_for_completion_timeout(&nss_if.complete, msecs_to_jiffies(NSS_IF_TX_TIMEOUT)); ++ ++ if (!ret) { ++ nss_warning("%px: nss_if tx failed due to timeout\n", nss_ctx); ++ nss_if.response = NSS_TX_FAILURE; ++ } ++ ++ status = nss_if.response; ++ up(&nss_if.sem); ++ ++ return status; ++} ++EXPORT_SYMBOL(nss_if_msg_sync); + + /* + * nss_if_msg_handler() +@@ -35,18 +103,18 @@ void nss_if_msg_handler(struct nss_ctx_i + * We only support base class messages with this interface + */ + if (ncm->type > NSS_IF_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return; + } + + if (!nss_is_dynamic_interface(ncm->interface) && + !((ncm->interface >= NSS_PHYSICAL_IF_START) && (ncm->interface < NSS_VIRTUAL_IF_START))) { +- nss_warning("%p: interface %d not in physical or dynamic if range\n", nss_ctx, ncm->interface); ++ nss_warning("%px: interface %d not in physical or dynamic if range\n", nss_ctx, ncm->interface); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_if_msg)) { +- nss_warning("%p: message length too big: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: message length too big: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -56,6 +124,11 @@ void nss_if_msg_handler(struct nss_ctx_i + nss_core_log_msg_failures(nss_ctx, ncm); + + /* ++ * Trace messages. ++ */ ++ nss_if_log_rx_msg(nim); ++ ++ /* + * Do we have a callback? + */ + if (!ncm->cb) { +@@ -75,11 +148,11 @@ void nss_if_msg_handler(struct nss_ctx_i + */ + nss_tx_status_t nss_if_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num) + { +- nss_trace("%p: If Tx packet, id:%d, data=%p", nss_ctx, if_num, os_buf->data); ++ nss_trace("%px: If Tx packet, id:%d, data=%px", nss_ctx, if_num, os_buf->data); + + if (!nss_is_dynamic_interface(if_num) && + !((if_num >= NSS_PHYSICAL_IF_START) && (if_num < NSS_VIRTUAL_IF_START))) { +- nss_warning("%p: interface %d not in physical or dynamic if range\n", nss_ctx, if_num); ++ nss_warning("%px: interface %d not in physical or dynamic if range\n", nss_ctx, if_num); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -100,14 +173,28 @@ nss_tx_status_t nss_if_tx_msg(struct nss + /* + * Sanity check the message + */ +- if (ncm->type > NSS_IF_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ if (ncm->type >= NSS_IF_MAX_MSG_TYPES) { ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + ++ /* ++ * Sanity check the message for valid interfaces. ++ */ ++ if (ncm->interface < NSS_PHYSICAL_IF_START || ++ ncm->interface >= NSS_MAX_NET_INTERFACES ) { ++ nss_warning("%px: Tx request for invalid interface: %d", nss_ctx, ncm->interface); ++ return NSS_TX_FAILURE_BAD_PARAM; ++ } ++ ++ /* ++ * Trace messages. ++ */ ++ nss_if_log_tx_msg(nim); ++ + dev = nss_ctx->subsys_dp_register[ncm->interface].ndev; + if (!dev) { +- nss_warning("%p: Unregister interface %d: no context", nss_ctx, ncm->interface); ++ nss_warning("%px: Unregister interface %d: no context", nss_ctx, ncm->interface); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -134,6 +221,50 @@ void nss_if_unregister(uint32_t if_num) + { + } + ++/* ++ * nss_if_reset_nexthop() ++ * De-configures the nexthop for an interface ++ */ ++nss_tx_status_t nss_if_reset_nexthop(struct nss_ctx_instance *nss_ctx, uint32_t if_num) ++{ ++ struct nss_if_msg nim; ++ ++ NSS_VERIFY_CTX_MAGIC(nss_ctx); ++ ++ nss_trace("Resetting Nexthop. nss_ctx: %px ifnum: %u", nss_ctx, if_num); ++ ++ nss_cmn_msg_init(&nim.cm, if_num, NSS_IF_RESET_NEXTHOP, 0, nss_if_callback, NULL); ++ ++ return nss_if_msg_sync(nss_ctx, &nim); ++} ++EXPORT_SYMBOL(nss_if_reset_nexthop); ++ ++/* ++ * nss_if_set_nexthop() ++ * Configures the nexthop for an interface ++ */ ++nss_tx_status_t nss_if_set_nexthop(struct nss_ctx_instance *nss_ctx, uint32_t if_num, uint32_t nexthop) ++{ ++ struct nss_if_msg nim; ++ ++ NSS_VERIFY_CTX_MAGIC(nss_ctx); ++ ++ if (nexthop >= NSS_MAX_NET_INTERFACES) { ++ nss_warning("%px: Invalid nexthop interface number: %d", nss_ctx, nexthop); ++ return NSS_TX_FAILURE_BAD_PARAM; ++ } ++ ++ nss_trace("%px: NSS If nexthop will be set to %d, id:%d\n", nss_ctx, nexthop, if_num); ++ ++ nss_cmn_msg_init(&nim.cm, if_num, NSS_IF_SET_NEXTHOP, ++ sizeof(struct nss_if_set_nexthop), nss_if_callback, NULL); ++ ++ nim.msg.set_nexthop.nexthop = nexthop; ++ ++ return nss_if_msg_sync(nss_ctx, &nim); ++} ++EXPORT_SYMBOL(nss_if_set_nexthop); ++ + EXPORT_SYMBOL(nss_if_tx_msg); + EXPORT_SYMBOL(nss_if_register); + EXPORT_SYMBOL(nss_if_unregister); +--- /dev/null ++++ b/nss_if_log.c +@@ -0,0 +1,429 @@ ++/* ++ ************************************************************************** ++ * Copyright (c) 2020, 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. ++ ************************************************************************** ++ */ ++ ++/* ++ * nss_if_log.c ++ * NSS Interface logger file. ++ */ ++ ++#include "nss_core.h" ++ ++/* ++ * nss_if_log_message_types_str ++ * NSS interface rule message strings ++ */ ++static int8_t *nss_if_log_message_types_str[NSS_IF_MAX_MSG_TYPES] __maybe_unused = { ++ "NSS interface Open message", ++ "NSS interface close message", ++ "NSS interface link state notify message", ++ "NSS interface MTU change message", ++ "NSS interface MAC address set message", ++ "NSS interface stats message", ++ "NSS interface ishaper assign message", ++ "NSS interface bshaper assign message", ++ "NSS interface ishaper unassign message", ++ "NSS interface bshaper unassign message", ++ "NSS interface ishaper config message", ++ "NSS interface bshaper config message", ++ "NSS interface pause on off message", ++ "NSS interface VSI assign message", ++ "NSS interface VSI unassign message", ++ "NSS interface set next hop message", ++ "NSS interface set IGS node message", ++ "NSS interface clear IGS node message", ++ "NSS interface reset next hop message", ++}; ++ ++/* ++ * nss_if_log_error_response_types_str ++ * Strings for error types for NSS interface messages ++ */ ++static int8_t *nss_if_log_error_response_types_str[NSS_IF_ERROR_TYPE_MAX] __maybe_unused = { ++ "No Ishapers", ++ "No Bshapers", ++ "No Ishaper", ++ "No Bshaper", ++ "No Old Ishaper", ++ "No Old Bshaper", ++ "Ishaper config failed", ++ "Bshaper config failed", ++ "Unknown error", ++ "Interface open error", ++ "Interface invalid MTU error", ++ "Invalid MAC address error", ++ "VSI no match error", ++ "VSI reassign error", ++ "Invalid VSI error", ++ "Max error", ++}; ++ ++/* ++ * nss_if_log_rule_open() ++ * Log NSS open interface message. ++ */ ++static void nss_if_log_rule_open(struct nss_if_msg *nim) ++{ ++ struct nss_if_open *niom __maybe_unused = &nim->msg.open; ++ nss_trace("%px: NSS open interface message \n" ++ "tx_desc_ring: %X\n" ++ "rx_desc_ring: %X\n" ++ "rx_forward_if: %u\n" ++ "alignment_mode: %u\n", ++ nim, ++ niom->tx_desc_ring, ++ niom->rx_desc_ring, ++ niom->rx_forward_if, ++ niom->alignment_mode); ++} ++ ++/* ++ * nss_if_log_rule_close() ++ * Log NSS close interface message. ++ */ ++static void nss_if_log_rule_close(struct nss_if_msg *nim) ++{ ++ nss_trace("%px: NSS close interface message \n", nim); ++} ++ ++/* ++ * nss_if_log_rule_link_state_notify() ++ * Log NSS interface link state notify message. ++ */ ++static void nss_if_log_rule_link_state_notify(struct nss_if_msg *nim) ++{ ++ struct nss_if_link_state_notify *nilstm __maybe_unused = &nim->msg.link_state_notify; ++ nss_trace("%px: NSS interface link state notify interface message \n" ++ "state: %u\n", ++ nim, ++ nilstm->state); ++} ++ ++/* ++ * nss_if_log_rule_mtu_change() ++ * Log NSS interface MTU change message. ++ */ ++static void nss_if_log_rule_mtu_change(struct nss_if_msg *nim) ++{ ++ struct nss_if_mtu_change *nimcm __maybe_unused = &nim->msg.mtu_change; ++ nss_trace("%px: NSS interface MTU change message \n" ++ "min_buf_size: %u\n", ++ nim, ++ nimcm->min_buf_size); ++} ++ ++/* ++ * nss_if_log_rule_mac_addr_set() ++ * Log NSS interface MAC address set message. ++ */ ++static void nss_if_log_rule_mac_addr_set(struct nss_if_msg *nim) ++{ ++ struct nss_if_mac_address_set *nimasm __maybe_unused = &nim->msg.mac_address_set; ++ nss_trace("%px: NSS interface MAC address set message \n" ++ "MAC address: %X:%X:%X:%X:%X:%X\n", ++ nim, ++ nimasm->mac_addr[0], nimasm->mac_addr[1], nimasm->mac_addr[2], ++ nimasm->mac_addr[3], nimasm->mac_addr[4], nimasm->mac_addr[5]); ++} ++ ++/* ++ * nss_if_log_rule_stats() ++ * Log NSS interface stats message. ++ */ ++static void nss_if_log_rule_stats(struct nss_if_msg *nim) ++{ ++ uint16_t i; ++ struct nss_cmn_node_stats *nism __maybe_unused = &nim->msg.stats; ++ ++ nss_trace("%px: NSS interface stats message \n" ++ "rx_packets: %u\n" ++ "rx_bytes: %u\n" ++ "tx_packets: %u\n" ++ "tx_bytes: %u\n", ++ nim, ++ nism->rx_packets, ++ nism->rx_bytes, ++ nism->tx_packets, ++ nism->tx_bytes); ++ ++ for(i=0; i < NSS_MAX_NUM_PRI; i++) ++ { ++ nss_trace("rx_dropped[%u]: %u\n", i, nism->rx_dropped[i]); ++ } ++} ++ ++/* ++ * nss_if_log_rule_shaper_assign() ++ * Log NSS interface shaper assignment message. ++ */ ++static void nss_if_log_rule_shaper_assign(struct nss_if_msg *nim) ++{ ++ struct nss_if_shaper_assign *shaper_assign_msg __maybe_unused = &nim->msg.shaper_assign; ++ nss_trace("%px: NSS interface shaper assign message \n" ++ "shaper_id: %u\n" ++ "new_shaper_id: %u\n", ++ nim, ++ shaper_assign_msg->shaper_id, ++ shaper_assign_msg->new_shaper_id); ++} ++ ++/* ++ * nss_if_log_rule_shaper_unassign() ++ * Log NSS interface shaper unassignment message. ++ */ ++static void nss_if_log_rule_shaper_unassign(struct nss_if_msg *nim) ++{ ++ struct nss_if_shaper_unassign *shaper_unassign_msg __maybe_unused = &nim->msg.shaper_unassign; ++ nss_trace("%px: NSS interface shaper unassign message \n" ++ "shaper_id: %u\n", ++ nim, ++ shaper_unassign_msg->shaper_id); ++} ++ ++/* ++ * nss_if_log_rule_shaper_config() ++ * Log NSS interface shaper configuration message. ++ */ ++static void nss_if_log_rule_shaper_config(struct nss_if_msg *nim) ++{ ++ struct nss_if_shaper_configure *shaper_configure_msg __maybe_unused = &nim->msg.shaper_configure; ++ nss_trace("%px: NSS interface shaper configuration message \n" ++ "request_type: %u\n" ++ "response_type: %u\n", ++ nim, ++ shaper_configure_msg->config.request_type, ++ shaper_configure_msg->config.response_type); ++} ++ ++/* ++ * nss_if_log_rule_pause_on_off() ++ * Log NSS interface pause on off message. ++ */ ++static void nss_if_log_rule_pause_on_off(struct nss_if_msg *nim) ++{ ++ struct nss_if_pause_on_off *pause_on_off_msg __maybe_unused = &nim->msg.pause_on_off; ++ nss_trace("%px: NSS interface pause ON/OFF message \n" ++ "pause_on: %u\n", ++ nim, ++ pause_on_off_msg->pause_on); ++} ++ ++/* ++ * nss_if_log_rule_vsi_assign() ++ * Log NSS interface VSI assignment message. ++ */ ++static void nss_if_log_rule_vsi_assign(struct nss_if_msg *nim) ++{ ++ struct nss_if_vsi_assign *vsi_assign_msg __maybe_unused = &nim->msg.vsi_assign; ++ nss_trace("%px: NSS interface VSI assignment message \n" ++ "VSI: %u\n", ++ nim, ++ vsi_assign_msg->vsi); ++} ++ ++/* ++ * nss_if_log_rule_vsi_unassign() ++ * Log NSS interface VSI unassignment message. ++ */ ++static void nss_if_log_rule_vsi_unassign(struct nss_if_msg *nim) ++{ ++ struct nss_if_vsi_unassign *vsi_unassign_msg __maybe_unused = &nim->msg.vsi_unassign; ++ nss_trace("%px: NSS interface VSI unassignment message \n" ++ "VSI: %u\n", ++ nim, ++ vsi_unassign_msg->vsi); ++} ++ ++/* ++ * nss_if_log_rule_set_nexthop() ++ * Log NSS interface set nexthop message. ++ */ ++static void nss_if_log_rule_set_nexthop(struct nss_if_msg *nim) ++{ ++ struct nss_if_set_nexthop *nisn __maybe_unused = &nim->msg.set_nexthop; ++ nss_trace("%px: NSS interface set nethop message \n" ++ "Nexthop: %u\n", ++ nim, ++ nisn->nexthop); ++} ++ ++/* ++ * nss_if_log_rule_set_igs_node() ++ * Log NSS interface set IGS node message. ++ */ ++static void nss_if_log_rule_set_igs_node(struct nss_if_msg *nim) ++{ ++ struct nss_if_igs_config *igs_config_msg __maybe_unused = &nim->msg.config_igs; ++ nss_trace("%px: NSS interface set IGS node message \n" ++ "igs_num: %d\n", ++ nim, ++ igs_config_msg->igs_num); ++} ++ ++/* ++ * nss_if_log_rule_clear_igs_node() ++ * Log NSS interface clear IGS node message. ++ */ ++static void nss_if_log_rule_clear_igs_node(struct nss_if_msg *nim) ++{ ++ struct nss_if_igs_config *igs_config_msg __maybe_unused = &nim->msg.config_igs; ++ nss_trace("%px: NSS interface clear IGS node message \n" ++ "igs_num: %d\n", ++ nim, ++ igs_config_msg->igs_num); ++} ++ ++/* ++ * nss_if_log_rule_reset_nexthop() ++ * Log NSS interface reset nexthop message. ++ */ ++static void nss_if_log_rule_reset_nexthop(struct nss_if_msg *nim) ++{ ++ nss_trace("%px: NSS interface reset nexthop message \n", nim); ++} ++ ++/* ++ * nss_if_log_verbose() ++ * Log message contents. ++ */ ++static void nss_if_log_verbose(struct nss_if_msg *nim) ++{ ++ nss_trace("NSS interface number: %u\n", nim->cm.interface); ++ ++ switch (nim->cm.type) { ++ case NSS_IF_OPEN: ++ nss_if_log_rule_open(nim); ++ break; ++ ++ case NSS_IF_CLOSE: ++ nss_if_log_rule_close(nim); ++ break; ++ ++ case NSS_IF_LINK_STATE_NOTIFY: ++ nss_if_log_rule_link_state_notify(nim); ++ break; ++ ++ case NSS_IF_MTU_CHANGE: ++ nss_if_log_rule_mtu_change(nim); ++ break; ++ ++ case NSS_IF_MAC_ADDR_SET: ++ nss_if_log_rule_mac_addr_set(nim); ++ break; ++ ++ case NSS_IF_STATS: ++ nss_if_log_rule_stats(nim); ++ break; ++ ++ case NSS_IF_ISHAPER_ASSIGN: ++ case NSS_IF_BSHAPER_ASSIGN: ++ nss_if_log_rule_shaper_assign(nim); ++ break; ++ ++ case NSS_IF_ISHAPER_UNASSIGN: ++ case NSS_IF_BSHAPER_UNASSIGN: ++ nss_if_log_rule_shaper_unassign(nim); ++ break; ++ ++ case NSS_IF_ISHAPER_CONFIG: ++ case NSS_IF_BSHAPER_CONFIG: ++ nss_if_log_rule_shaper_config(nim); ++ break; ++ ++ case NSS_IF_PAUSE_ON_OFF: ++ nss_if_log_rule_pause_on_off(nim); ++ break; ++ ++ case NSS_IF_VSI_ASSIGN: ++ nss_if_log_rule_vsi_assign(nim); ++ break; ++ ++ case NSS_IF_VSI_UNASSIGN: ++ nss_if_log_rule_vsi_unassign(nim); ++ break; ++ ++ case NSS_IF_SET_NEXTHOP: ++ nss_if_log_rule_set_nexthop(nim); ++ break; ++ ++ case NSS_IF_SET_IGS_NODE: ++ nss_if_log_rule_set_igs_node(nim); ++ break; ++ ++ case NSS_IF_CLEAR_IGS_NODE: ++ nss_if_log_rule_clear_igs_node(nim); ++ break; ++ ++ case NSS_IF_RESET_NEXTHOP: ++ nss_if_log_rule_reset_nexthop(nim); ++ break; ++ ++ default: ++ nss_trace("%px: Invalid message type\n", nim); ++ break; ++ } ++} ++ ++/* ++ * nss_if_log_rx_msg() ++ * Log messages received from FW. ++ */ ++void nss_if_log_rx_msg(struct nss_if_msg *nim) ++{ ++ if (nim->cm.response >= NSS_CMN_RESPONSE_LAST) { ++ nss_info("%px: Invalid response\n", nim); ++ return; ++ } ++ ++ if (nim->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nim->cm.response == NSS_CMN_RESPONSE_ACK)) { ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nim, nim->cm.type, ++ nss_if_log_message_types_str[nim->cm.type], ++ nim->cm.response, nss_cmn_response_str[nim->cm.response]); ++ goto verbose; ++ } ++ ++ if (nim->cm.error >= NSS_IF_ERROR_TYPE_MAX) { ++ nss_info("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nim, nim->cm.type, nss_if_log_message_types_str[nim->cm.type], ++ nim->cm.response, nss_cmn_response_str[nim->cm.response], ++ nim->cm.error); ++ goto verbose; ++ } ++ ++ nss_info("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nim, nim->cm.type, nss_if_log_message_types_str[nim->cm.type], ++ nim->cm.response, nss_cmn_response_str[nim->cm.response], ++ nim->cm.error, nss_if_log_error_response_types_str[nim->cm.error]); ++ ++verbose: ++ nss_if_log_verbose(nim); ++} ++ ++/* ++ * nss_if_log_tx_msg() ++ * Log messages transmitted to FW. ++ */ ++void nss_if_log_tx_msg(struct nss_if_msg *nim) ++{ ++ if (nim->cm.type >= NSS_IF_MAX_MSG_TYPES) { ++ nss_info("%px: Invalid message type\n", nim); ++ return; ++ } ++ ++ nss_info("%px: type[%d]:%s\n", nim, nim->cm.type, nss_if_log_message_types_str[nim->cm.type]); ++ nss_if_log_verbose(nim); ++} +--- /dev/null ++++ b/nss_if_log.h +@@ -0,0 +1,40 @@ ++/* ++ ************************************************************************** ++ * Copyright (c) 2020, 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. ++ ************************************************************************** ++ */ ++ ++#ifndef __NSS_IF_LOG_H ++#define __NSS_IF_LOG_H ++ ++/* ++ * nss_if_log.h ++ * NSS Interface header file. ++ */ ++ ++/* ++ * nss_if_log_tx_msg ++ * Logs an NSS interface message that is sent to the NSS firmware. ++ */ ++void nss_if_log_tx_msg(struct nss_if_msg *nim); ++ ++/* ++ * nss_if_log_rx_msg ++ * Logs an NSS interface message that is received from the NSS firmware. ++ */ ++void nss_if_log_rx_msg(struct nss_if_msg *nim); ++ ++ ++#endif /* __NSS_IF_LOG_H */ +--- a/nss_igs.c ++++ b/nss_igs.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -57,12 +57,12 @@ static void nss_igs_handler(struct nss_c + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_IGS_MSG_MAX) { +- nss_warning("%p: received invalid message %d for IGS interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for IGS interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_igs_msg)) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return; + } + +@@ -79,7 +79,7 @@ static void nss_igs_handler(struct nss_c + * Update the callback and app_data for NOTIFY messages + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_top_main.if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)app_data; + } + +@@ -93,7 +93,7 @@ static void nss_igs_handler(struct nss_c + * call igs callback + */ + if (!cb) { +- nss_warning("%p: No callback for igs interface %d", ++ nss_warning("%px: No callback for igs interface %d", + nss_ctx, ncm->interface); + return; + } +@@ -108,15 +108,18 @@ static void nss_igs_handler(struct nss_c + void nss_igs_unregister_if(uint32_t if_num) + { + struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.igs_handler_id]; ++ uint32_t status; + + nss_assert(nss_ctx); + nss_assert(nss_igs_verify_if_num(if_num)); + + nss_core_unregister_subsys_dp(nss_ctx, if_num); + +- nss_top_main.if_rx_msg_callback[if_num] = NULL; +- + nss_core_unregister_handler(nss_ctx, if_num); ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to unregister handler for interface %d with NSS core\n", nss_ctx, if_num); ++ } + + nss_igs_stats_reset(if_num); + } +@@ -131,18 +134,23 @@ struct nss_ctx_instance *nss_igs_registe + uint32_t features) + { + struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.igs_handler_id]; ++ uint32_t status; + + nss_assert(nss_ctx); + nss_assert(nss_igs_verify_if_num(if_num)); + ++ nss_core_register_handler(nss_ctx, if_num, nss_igs_handler, netdev); ++ status = nss_core_register_msg_handler(nss_ctx, if_num, event_callback); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_core_unregister_handler(nss_ctx, if_num); ++ nss_warning("%px: Not able to register handler for interface %d with NSS core\n", nss_ctx, if_num); ++ return NULL; ++ } ++ + nss_core_register_subsys_dp(nss_ctx, if_num, NULL, 0, netdev, netdev, features); + nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, type); + +- nss_top_main.if_rx_msg_callback[if_num] = event_callback; +- +- nss_core_register_handler(nss_ctx, if_num, nss_igs_handler, netdev); + nss_igs_stats_dentry_create(); +- + nss_igs_stats_init(if_num, netdev); + + return nss_ctx; +--- a/nss_init.c ++++ b/nss_init.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2013-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. +@@ -307,7 +307,9 @@ static int nss_get_freq_table_handler(st + + i = 0; + while (i < NSS_FREQ_MAX_SCALE) { +- printk("%d Hz ", nss_runtime_samples.freq_scale[i].frequency); ++ if (nss_runtime_samples.freq_scale[i].frequency != NSS_FREQ_SCALE_NA) { ++ printk("%d Hz ", nss_runtime_samples.freq_scale[i].frequency); ++ } + i++; + } + printk("\n"); +@@ -660,7 +662,7 @@ static int __init nss_init(void) + #if defined(NSS_HAL_IPQ807x_SUPPORT) + if (of_machine_is_compatible("qcom,ipq807x") || of_machine_is_compatible("qcom,ipq8074")) { + nss_top_main.hal_ops = &nss_hal_ipq807x_ops; +- nss_top_main.data_plane_ops = &nss_data_plane_edma_ops; ++ nss_top_main.data_plane_ops = &nss_data_plane_ops; + #if defined(NSS_MEM_PROFILE_LOW) + nss_top_main.num_nss = 1; + #else +@@ -671,14 +673,14 @@ static int __init nss_init(void) + #if defined(NSS_HAL_IPQ60XX_SUPPORT) + if (of_machine_is_compatible("qcom,ipq6018")) { + nss_top_main.hal_ops = &nss_hal_ipq60xx_ops; +- nss_top_main.data_plane_ops = &nss_data_plane_edma_ops; ++ nss_top_main.data_plane_ops = &nss_data_plane_ops; + nss_top_main.num_nss = 1; + } + #endif + #if defined(NSS_HAL_IPQ50XX_SUPPORT) + if (of_machine_is_compatible("qcom,ipq5018")) { + nss_top_main.hal_ops = &nss_hal_ipq50xx_ops; +- nss_top_main.data_plane_ops = &nss_data_plane_edma_ops; ++ nss_top_main.data_plane_ops = &nss_data_plane_ops; + nss_top_main.num_nss = 1; + } + #endif +@@ -738,7 +740,9 @@ static int __init nss_init(void) + * Registering sysctl for ipv4/6 specific config. + */ + nss_ipv4_register_sysctl(); ++#ifdef NSS_DRV_IPV6_ENABLE + nss_ipv6_register_sysctl(); ++#endif + + /* + * Registering sysctl for n2h specific config. +@@ -771,11 +775,12 @@ static int __init nss_init(void) + */ + nss_project_register_sysctl(); + ++#ifdef NSS_DRV_PPPOE_ENABLE + /* + * Registering sysctl for pppoe specific config. + */ + nss_pppoe_register_sysctl(); +- ++#endif + /* + * Setup Runtime Sample values + */ +@@ -860,9 +865,13 @@ static int __init nss_init(void) + /* + * INIT ppe on supported platform + */ +- if (of_machine_is_compatible("qcom,ipq807x") || of_machine_is_compatible("qcom,ipq8074")|| of_machine_is_compatible("qcom,ipq6018")) { +- nss_ppe_init(); +- } ++#ifdef NSS_DRV_PPE_ENABLE ++ nss_ppe_init(); ++#endif ++ ++#ifdef NSS_DRV_DMA_ENABLE ++ nss_dma_init(); ++#endif + + /* + * Register platform_driver +@@ -898,22 +907,23 @@ static void __exit nss_cleanup(void) + nss_c2c_tx_unregister_sysctl(); + #endif + ++#ifdef NSS_DRV_PPPOE_ENABLE + /* + * Unregister pppoe specific sysctl + */ + nss_pppoe_unregister_sysctl(); ++#endif + + /* +- * Unregister ipv4/6 specific sysctl ++ * Unregister ipv4/6 specific sysctl and free allocated to connection tables + */ + nss_ipv4_unregister_sysctl(); +- nss_ipv6_unregister_sysctl(); - --/* -- * nss_dtls_cmn_stats_read() -- * Read dtls common node statistics. -- */ --static ssize_t nss_dtls_cmn_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ - /* -- * Max output lines = #stats + -- * few blank lines for banner printing + Number of Extra outputlines -- * for future reference to add new stats +- * Free Memory allocated for connection tables - */ -- uint32_t max_output_lines = NSS_DTLS_CMN_CTX_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- struct nss_ctx_instance *nss_ctx = nss_dtls_cmn_get_context(); -- enum nss_dynamic_interface_type type; -- unsigned long *ifmap; -- uint64_t *stats_shadow; -- ssize_t bytes_read = 0; -- size_t size_wr = 0; -- uint32_t if_num; + nss_ipv4_free_conn_tables(); ++ ++#ifdef NSS_DRV_IPV6_ENABLE ++ nss_ipv6_unregister_sysctl(); + nss_ipv6_free_conn_tables(); ++#endif + + nss_project_unregister_sysctl(); + nss_data_plane_destroy_delay_work(); +@@ -921,9 +931,9 @@ static void __exit nss_cleanup(void) + /* + * cleanup ppe on supported platform + */ +- if (of_machine_is_compatible("qcom,ipq807x") || of_machine_is_compatible("qcom,ipq6018")) { +- nss_ppe_free(); +- } ++#ifdef NSS_DRV_PPE_ENABLE ++ nss_ppe_free(); ++#endif + + platform_driver_unregister(&nss_driver); + } +--- a/nss_ipsec.c ++++ b/nss_ipsec.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2013-2020, 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. +@@ -136,19 +136,19 @@ static void nss_ipsec_msg_handler(struct + * Sanity check the message type + */ + if (ncm->type > NSS_IPSEC_MSG_TYPE_MAX) { +- nss_warning("%p: rx message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: rx message type out of range: %d", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ipsec_msg)) { +- nss_warning("%p: rx message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: rx message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + + BUG_ON((if_num != NSS_IPSEC_ENCAP_INTERFACE_NUM) && (if_num != NSS_IPSEC_DECAP_INTERFACE_NUM)); + + if (ncm->response == NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: rx message response for if %d, type %d, is invalid: %d", nss_ctx, ncm->interface, ++ nss_warning("%px: rx message response for if %d, type %d, is invalid: %d", nss_ctx, ncm->interface, + ncm->type, ncm->response); + return; + } +@@ -169,7 +169,7 @@ static void nss_ipsec_msg_handler(struct + */ + cb = (nss_ipsec_msg_callback_t)ncm->cb; + if (unlikely(!cb)) { +- nss_trace("%p: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); ++ nss_trace("%px: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); + return; + } + +@@ -215,7 +215,7 @@ nss_tx_status_t nss_ipsec_tx_msg(struct + { + struct nss_cmn_msg *ncm = &msg->cm; + +- nss_info("%p: message %d for if %d\n", nss_ctx, ncm->type, ncm->interface); ++ nss_info("%px: message %d for if %d\n", nss_ctx, ncm->type, ncm->interface); + + BUILD_BUG_ON(NSS_NBUF_PAYLOAD_SIZE < sizeof(struct nss_ipsec_msg)); + +@@ -225,16 +225,16 @@ nss_tx_status_t nss_ipsec_tx_msg(struct + nss_ipsec_log_tx_msg(msg); + + if ((ncm->interface != NSS_IPSEC_ENCAP_INTERFACE_NUM) && (ncm->interface != NSS_IPSEC_DECAP_INTERFACE_NUM)) { +- nss_warning("%p: tx message request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx message request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_IPSEC_MSG_TYPE_MAX) { +- nss_warning("%p: tx message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: tx message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +- nss_info("msg params version:%d, interface:%d, type:%d, cb:%p, app_data:%p, len:%d\n", ++ nss_info("msg params version:%d, interface:%d, type:%d, cb:%px, app_data:%px, len:%d\n", + ncm->version, ncm->interface, ncm->type, (void *)ncm->cb, (void *)ncm->app_data, ncm->len); + + return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); +@@ -257,7 +257,7 @@ nss_tx_status_t nss_ipsec_tx_msg_sync(st + * Length of the message should be the based on type + */ + if (len > sizeof(nim_local.msg)) { +- nss_warning("%p: (%u)Bad message length(%u) for type (%d)", nss_ctx, if_num, len, type); ++ nss_warning("%px: (%u)Bad message length(%u) for type (%d)", nss_ctx, if_num, len, type); + return NSS_TX_FAILURE_TOO_LARGE; + } + +@@ -265,7 +265,7 @@ nss_tx_status_t nss_ipsec_tx_msg_sync(st + * Response buffer is a required for copying the response for message + */ + if (!resp) { +- nss_warning("%p: (%u)Response buffer is empty, type(%d)", nss_ctx, if_num, type); ++ nss_warning("%px: (%u)Response buffer is empty, type(%d)", nss_ctx, if_num, type); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -297,13 +297,13 @@ nss_tx_status_t nss_ipsec_tx_msg_sync(st + + status = nss_ipsec_tx_msg(nss_ctx, &nim_local); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: ipsec_tx_msg failed", nss_ctx); ++ nss_warning("%px: ipsec_tx_msg failed", nss_ctx); + goto done; + } + + ret = wait_for_completion_timeout(&nss_ipsec.complete, NSS_IPSEC_TX_TIMEO_TICKS); + if (!ret) { +- nss_warning("%p: IPsec msg tx failed due to timeout", nss_ctx); ++ nss_warning("%px: IPsec msg tx failed due to timeout", nss_ctx); + status = NSS_TX_FAILURE_NOT_ENABLED; + goto done; + } +@@ -339,7 +339,7 @@ nss_tx_status_t nss_ipsec_tx_buf(struct + { + struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[nss_top_main.ipsec_handler_id]; + +- nss_trace("%p: IPsec If Tx packet, id:%d, data=%p", nss_ctx, if_num, skb->data); ++ nss_trace("%px: IPsec If Tx packet, id:%d, data=%px", nss_ctx, if_num, skb->data); + + return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); + } +@@ -362,7 +362,7 @@ struct nss_ctx_instance *nss_ipsec_notif + struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_id]; + + if (if_num >= NSS_MAX_NET_INTERFACES) { +- nss_warning("%p: notfiy register received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: notfiy register received for invalid interface %d", nss_ctx, if_num); + return NULL; + } + +@@ -390,7 +390,7 @@ void nss_ipsec_notify_unregister(struct + struct nss_top_instance *nss_top = nss_ctx->nss_top; + + if (if_num >= NSS_MAX_NET_INTERFACES) { +- nss_warning("%p: notify unregister received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: notify unregister received for invalid interface %d", nss_ctx, if_num); + return; + } + +@@ -419,7 +419,7 @@ struct nss_ctx_instance *nss_ipsec_data_ + nss_ctx = &nss_top_main.nss[nss_top_main.ipsec_handler_id]; + + if ((if_num >= NSS_MAX_NET_INTERFACES) && (if_num < NSS_MAX_PHYSICAL_INTERFACES)){ +- nss_warning("%p: data register received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: data register received for invalid interface %d", nss_ctx, if_num); + return NULL; + } + +@@ -451,7 +451,7 @@ void nss_ipsec_data_unregister(struct ns + struct nss_ctx_instance *nss_ctx0; + + if ((if_num >= NSS_MAX_NET_INTERFACES) && (if_num < NSS_MAX_PHYSICAL_INTERFACES)){ +- nss_warning("%p: data unregister received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: data unregister received for invalid interface %d", nss_ctx, if_num); + return; + } + +@@ -529,7 +529,7 @@ bool nss_ipsec_ppe_port_config(struct ns + if_num = NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); + + if (nss_ppe_tx_ipsec_config_msg(if_num, vsi_num, netdev->mtu, netdev->mtu) != NSS_TX_SUCCESS) { +- nss_warning("%p: Failed to configure PPE IPsec port", nss_ctx); ++ nss_warning("%px: Failed to configure PPE IPsec port", nss_ctx); + return false; + } + +@@ -550,7 +550,7 @@ bool nss_ipsec_ppe_mtu_update(struct nss + if_num = NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); + + if (nss_ppe_tx_ipsec_mtu_msg(if_num, mtu, mru) != NSS_TX_SUCCESS) { +- nss_warning("%p: Failed to update PPE MTU for IPsec port", nss_ctx); ++ nss_warning("%px: Failed to update PPE MTU for IPsec port", nss_ctx); + return false; + } + +--- a/nss_ipsec_cmn.c ++++ b/nss_ipsec_cmn.c +@@ -180,12 +180,12 @@ static void nss_ipsec_cmn_msg_handler(st + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_IPSEC_CMN_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type(%u) for interface(%u)\n", nss_ctx, ncm->type, ncm->interface); ++ nss_warning("%px: Invalid message type(%u) for interface(%u)\n", nss_ctx, ncm->type, ncm->interface); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ipsec_cmn_msg)) { +- nss_warning("%p: Invalid message length(%d)\n", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Invalid message length(%d)\n", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -216,11 +216,11 @@ static void nss_ipsec_cmn_msg_handler(st + * Call IPsec message callback + */ + if (!cb) { +- nss_warning("%p: No callback for IPsec interface %d\n", nss_ctx, ncm->interface); ++ nss_warning("%px: No callback for IPsec interface %d\n", nss_ctx, ncm->interface); + return; + } + +- nss_trace("%p: calling ipsecsmgr message handler(%u)\n", nss_ctx, ncm->interface); ++ nss_trace("%px: calling ipsecsmgr message handler(%u)\n", nss_ctx, ncm->interface); + cb(app_data, ncm); + } + +@@ -297,17 +297,17 @@ nss_tx_status_t nss_ipsec_cmn_tx_msg(str + * Sanity check the message + */ + if (ncm->type >= NSS_IPSEC_CMN_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type(%u)\n", nss_ctx, ncm->type); ++ nss_warning("%px: Invalid message type(%u)\n", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + + if (!nss_ipsec_cmn_verify_ifnum(nss_ctx, ncm->interface)) { +- nss_warning("%p: Invalid message interface(%u)\n", nss_ctx, ncm->interface); ++ nss_warning("%px: Invalid message interface(%u)\n", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ipsec_cmn_msg)) { +- nss_warning("%p: Invalid message length(%u)\n", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Invalid message length(%u)\n", nss_ctx, nss_cmn_get_msg_len(ncm)); + return NSS_TX_FAILURE; + } + +@@ -331,7 +331,7 @@ nss_tx_status_t nss_ipsec_cmn_tx_msg_syn + * Length of the message should be the based on type + */ + if (len > sizeof(struct nss_ipsec_cmn_msg)) { +- nss_warning("%p: Invalid message length(%u), type (%d), I/F(%u)\n", nss_ctx, len, type, if_num); ++ nss_warning("%px: Invalid message length(%u), type (%d), I/F(%u)\n", nss_ctx, len, type, if_num); + return NSS_TX_FAILURE; + } + +@@ -348,13 +348,13 @@ nss_tx_status_t nss_ipsec_cmn_tx_msg_syn + + status = nss_ipsec_cmn_tx_msg(nss_ctx, local_nicm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Failed to send message\n", nss_ctx); ++ nss_warning("%px: Failed to send message\n", nss_ctx); + goto done; + } + + ret = wait_for_completion_timeout(&ipsec_cmn_pvt.complete, msecs_to_jiffies(NSS_IPSEC_CMN_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: Failed to receive response, timeout(%d)\n", nss_ctx, ret); ++ nss_warning("%px: Failed to receive response, timeout(%d)\n", nss_ctx, ret); + status = NSS_TX_FAILURE_NOT_READY; + goto done; + } +@@ -388,11 +388,11 @@ EXPORT_SYMBOL(nss_ipsec_cmn_tx_msg_sync) + */ + nss_tx_status_t nss_ipsec_cmn_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num) + { +- nss_trace("%p: Send to IPsec I/F(%u), skb(%p)\n", nss_ctx, if_num, os_buf); ++ nss_trace("%px: Send to IPsec I/F(%u), skb(%px)\n", nss_ctx, if_num, os_buf); + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (!nss_ipsec_cmn_verify_ifnum(nss_ctx, if_num)) { +- nss_warning("%p: Interface number(%d) is not IPSec type\n", nss_ctx, if_num); ++ nss_warning("%px: Interface number(%d) is not IPSec type\n", nss_ctx, if_num); + return NSS_TX_FAILURE; + } + +@@ -413,12 +413,12 @@ struct nss_ctx_instance *nss_ipsec_cmn_r + uint32_t status; + + if (!nss_ipsec_cmn_verify_ifnum(nss_ctx, if_num)) { +- nss_warning("%p: Invalid IPsec interface(%u)\n", nss_ctx, if_num); ++ nss_warning("%px: Invalid IPsec interface(%u)\n", nss_ctx, if_num); + return NULL; + } + + if (nss_ctx->subsys_dp_register[if_num].ndev) { +- nss_warning("%p: Failed find free slot for IPsec NSS I/F:%u\n", nss_ctx, if_num); ++ nss_warning("%px: Failed find free slot for IPsec NSS I/F:%u\n", nss_ctx, if_num); + return NULL; + } + +@@ -430,14 +430,14 @@ struct nss_ctx_instance *nss_ipsec_cmn_r + */ + status = nss_core_register_handler(nss_ctx, if_num, nss_ipsec_cmn_msg_handler, app_ctx); + if (status != NSS_CORE_STATUS_SUCCESS){ +- nss_warning("%p: Failed to register message handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); ++ nss_warning("%px: Failed to register message handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); + return NULL; + } + + status = nss_core_register_msg_handler(nss_ctx, if_num, cb_msg); + if (status != NSS_CORE_STATUS_SUCCESS) { + nss_core_unregister_handler(nss_ctx, if_num); +- nss_warning("%p: Failed to register message handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); ++ nss_warning("%px: Failed to register message handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); + return NULL; + } + +@@ -466,13 +466,13 @@ bool nss_ipsec_cmn_unregister_if(uint32_ + nss_assert(nss_ctx); + + if (!nss_ipsec_cmn_verify_ifnum(nss_ctx, if_num)) { +- nss_warning("%p: Invalid IPsec interface(%u)\n", nss_ctx, if_num); ++ nss_warning("%px: Invalid IPsec interface(%u)\n", nss_ctx, if_num); + return false; + } + + dev = nss_cmn_get_interface_dev(nss_ctx, if_num); + if (!dev) { +- nss_warning("%p: Failed to find registered netdev for IPsec NSS I/F:%u\n", nss_ctx, if_num); ++ nss_warning("%px: Failed to find registered netdev for IPsec NSS I/F:%u\n", nss_ctx, if_num); + return false; + } + +@@ -485,13 +485,13 @@ bool nss_ipsec_cmn_unregister_if(uint32_ + + status = nss_core_unregister_msg_handler(nss_ctx, if_num); + if (status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Failed to unregister handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); ++ nss_warning("%px: Failed to unregister handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); + return false; + } + + status = nss_core_unregister_handler(nss_ctx, if_num); + if (status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Failed to unregister handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); ++ nss_warning("%px: Failed to unregister handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); + return false; + } + +@@ -512,14 +512,14 @@ struct nss_ctx_instance *nss_ipsec_cmn_n + + ret = nss_core_register_handler(nss_ctx, if_num, nss_ipsec_cmn_msg_handler, app_data); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: unable to register event handler for interface(%u)\n", nss_ctx, if_num); ++ nss_warning("%px: unable to register event handler for interface(%u)\n", nss_ctx, if_num); + return NULL; + } + + ret = nss_core_register_msg_handler(nss_ctx, if_num, cb); + if (ret != NSS_CORE_STATUS_SUCCESS) { + nss_core_unregister_handler(nss_ctx, if_num); +- nss_warning("%p: Failed to register message handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); ++ nss_warning("%px: Failed to register message handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); + return NULL; + } + +@@ -536,19 +536,19 @@ void nss_ipsec_cmn_notify_unregister(str + uint32_t ret; + + if (if_num >= NSS_MAX_NET_INTERFACES) { +- nss_warning("%p: notify unregister received for invalid interface %d\n", nss_ctx, if_num); ++ nss_warning("%px: notify unregister received for invalid interface %d\n", nss_ctx, if_num); + return; + } + + ret = nss_core_unregister_msg_handler(nss_ctx, if_num); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: unable to unregister event handler for interface(%u)\n", nss_ctx, if_num); ++ nss_warning("%px: unable to unregister event handler for interface(%u)\n", nss_ctx, if_num); + return; + } + + ret = nss_core_unregister_handler(nss_ctx, if_num); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: unable to unregister event handler for interface(%u)\n", nss_ctx, if_num); ++ nss_warning("%px: unable to unregister event handler for interface(%u)\n", nss_ctx, if_num); + return; + } + } +@@ -565,7 +565,7 @@ bool nss_ipsec_cmn_ppe_port_config(struc + if_num = NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); + + if (nss_ppe_tx_ipsec_config_msg(if_num, vsi_num, netdev->mtu, netdev->mtu) != NSS_TX_SUCCESS) { +- nss_warning("%p: Failed to configure PPE IPsec port\n", nss_ctx); ++ nss_warning("%px: Failed to configure PPE IPsec port\n", nss_ctx); + return false; + } + +@@ -586,7 +586,7 @@ bool nss_ipsec_cmn_ppe_mtu_update(struct + if_num = NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); + + if (nss_ppe_tx_ipsec_mtu_msg(if_num, mtu, mru) != NSS_TX_SUCCESS) { +- nss_warning("%p: Failed to update PPE MTU for IPsec port\n", nss_ctx); ++ nss_warning("%px: Failed to update PPE MTU for IPsec port\n", nss_ctx); + return false; + } + +--- a/nss_ipsec_cmn_log.c ++++ b/nss_ipsec_cmn_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018-2020, 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. +@@ -145,7 +145,7 @@ static void nss_ipsec_cmn_log_node_msg(s + { + struct nss_ipsec_cmn_node *node_msg __maybe_unused = &nim->msg.node; + +- nss_trace("%p: NSS IPSEC Node Message:\n" ++ nss_trace("%px: NSS IPSEC Node Message:\n" + "%s: %d\n" + "%s: %d\n" + "%s: %d\n", nim, +@@ -162,7 +162,7 @@ static void nss_ipsec_cmn_log_ctx_msg(st + { + struct nss_ipsec_cmn_ctx *ctx_msg __maybe_unused = &nim->msg.ctx; + +- nss_trace("%p: NSS IPSEC CTX Message:\n" ++ nss_trace("%px: NSS IPSEC CTX Message:\n" + "%s: %s\n" + "%s: %d\n", nim, + nss_ipsec_cmn_log_ctx_str[0], nss_ipsec_cmn_ctx_types_str[ctx_msg->type], +@@ -179,7 +179,7 @@ static void nss_ipsec_cmn_log_sa_msg(str + struct nss_ipsec_cmn_sa_tuple *tuple = &sa_msg->sa_tuple; + struct nss_ipsec_cmn_sa_data *data __maybe_unused = &sa_msg->sa_data; + +- nss_trace("%p: NSS IPSEC SA Message:\n", nim); ++ nss_trace("%px: NSS IPSEC SA Message:\n", nim); + + if (tuple->ip_ver == 4) { + nss_trace("%s: %pI4\n%s: %pI4\n", +@@ -224,7 +224,7 @@ static void nss_ipsec_cmn_log_flow_msg(s + struct nss_ipsec_cmn_flow_tuple *flow = &flow_msg->flow_tuple; + struct nss_ipsec_cmn_sa_tuple *sa = &flow_msg->sa_tuple; + +- nss_trace("%p: NSS IPSEC Flow Message:\n", nim); ++ nss_trace("%px: NSS IPSEC Flow Message:\n", nim); + + if (sa->ip_ver == 4) { + nss_trace("%s: %pI4\n%s: %pI4\n", +@@ -298,7 +298,7 @@ static void nss_ipsec_cmn_log_verbose(st + break; + + default: +- nss_warning("%p: Invalid message type\n", nim); ++ nss_warning("%px: Invalid message type\n", nim); + break; + } + } +@@ -310,11 +310,11 @@ static void nss_ipsec_cmn_log_verbose(st + void nss_ipsec_cmn_log_tx_msg(struct nss_ipsec_cmn_msg *nim) + { + if (nim->cm.type >= NSS_IPSEC_CMN_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", nim); ++ nss_warning("%px: Invalid message type\n", nim); + return; + } + +- nss_info("%p: type[%d]:%s\n", nim, nim->cm.type, nss_ipsec_cmn_log_msg_types_str[nim->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nim, nim->cm.type, nss_ipsec_cmn_log_msg_types_str[nim->cm.type]); + nss_ipsec_cmn_log_verbose(nim); + } + +@@ -325,26 +325,26 @@ void nss_ipsec_cmn_log_tx_msg(struct nss + void nss_ipsec_cmn_log_rx_msg(struct nss_ipsec_cmn_msg *nim) + { + if (nim->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nim); ++ nss_warning("%px: Invalid response\n", nim); + return; + } + + if (nim->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nim->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nim, nim->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nim, nim->cm.type, + nss_ipsec_cmn_log_msg_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response]); + goto verbose; + } + + if (nim->cm.error >= NSS_IPSEC_CMN_MSG_ERROR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + nim, nim->cm.type, nss_ipsec_cmn_log_msg_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response], + nim->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + nim, nim->cm.type, nss_ipsec_cmn_log_msg_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response], + nim->cm.error, nss_ipsec_cmn_log_error_str[nim->cm.error]); +--- a/nss_ipsec_log.c ++++ b/nss_ipsec_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -63,7 +63,7 @@ static void nss_ipsec_log_rule_msg(struc + { + struct nss_ipsec_rule *nir __maybe_unused = &nim->msg.rule; + +- nss_trace("%p: NSS IPSEC Rule Message:\n" ++ nss_trace("%px: NSS IPSEC Rule Message:\n" + "IPSEC ESP SPI Index: %dn" + "IPSEC TTL Hop Limit: %dn" + "IPSEC IP Version: %x\n" +@@ -115,7 +115,7 @@ static void nss_ipsec_log_rule_msg(struc + static void nss_ipsec_log_configure_node_msg(struct nss_ipsec_msg *nim) + { + struct nss_ipsec_configure_node *nicn __maybe_unused = &nim->msg.node; +- nss_trace("%p: NSS IPSEC Configure Node\n" ++ nss_trace("%px: NSS IPSEC Configure Node\n" + "IPSEC DMA Redirect: %d\n" + "IPSEC DMA Lookaside: %d\n", + nicn, nicn->dma_redirect, +@@ -149,7 +149,7 @@ static void nss_ipsec_log_verbose(struct + break; + + default: +- nss_warning("%p: Invalid message type\n", nim); ++ nss_warning("%px: Invalid message type\n", nim); + break; + } + } +@@ -161,11 +161,11 @@ static void nss_ipsec_log_verbose(struct + void nss_ipsec_log_tx_msg(struct nss_ipsec_msg *nim) + { + if (nim->cm.type >= NSS_IPSEC_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", nim); ++ nss_warning("%px: Invalid message type\n", nim); + return; + } + +- nss_info("%p: type[%d]:%s\n", nim, nim->cm.type, nss_ipsec_log_message_types_str[nim->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nim, nim->cm.type, nss_ipsec_log_message_types_str[nim->cm.type]); + nss_ipsec_log_verbose(nim); + } + +@@ -176,26 +176,26 @@ void nss_ipsec_log_tx_msg(struct nss_ips + void nss_ipsec_log_rx_msg(struct nss_ipsec_msg *nim) + { + if (nim->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nim); ++ nss_warning("%px: Invalid response\n", nim); + return; + } + + if (nim->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nim->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nim, nim->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nim, nim->cm.type, + nss_ipsec_log_message_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response]); + goto verbose; + } + + if (nim->cm.error >= NSS_IPSEC_ERROR_TYPE_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + nim, nim->cm.type, nss_ipsec_log_message_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response], + nim->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + nim, nim->cm.type, nss_ipsec_log_message_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response], + nim->cm.error, nss_ipsec_log_error_response_types_str[nim->cm.error]); +--- a/nss_ipv4.c ++++ b/nss_ipv4.c +@@ -84,12 +84,12 @@ static void nss_ipv4_rx_msg_handler(stru + * Sanity check the message type + */ + if (ncm->type >= NSS_IPV4_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ipv4_msg)) { +- nss_warning("%p: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -221,7 +221,7 @@ nss_tx_status_t nss_ipv4_conn_inquiry(st + nim.msg.inquiry.rr.tuple = *ipv4_5t_p; + nss_tx_status = nss_ipv4_tx(nss_ctx, &nim); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: Send inquiry message failed\n", ipv4_5t_p); ++ nss_warning("%px: Send inquiry message failed\n", ipv4_5t_p); + } + + return nss_tx_status; +@@ -240,12 +240,12 @@ nss_tx_status_t nss_ipv4_tx_with_size(st + * Sanity check the message + */ + if (ncm->interface != NSS_IPV4_RX_INTERFACE) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_IPV4_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -286,14 +286,14 @@ nss_tx_status_t nss_ipv4_tx_sync(struct + + status = nss_ipv4_tx(nss_ctx, nim); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss ipv4 msg tx failed\n", nss_ctx); ++ nss_warning("%px: nss ipv4 msg tx failed\n", nss_ctx); + up(&nss_ipv4_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&nss_ipv4_pvt.complete, msecs_to_jiffies(NSS_IPV4_TX_MSG_TIMEOUT)); + if (!ret) { +- nss_warning("%p: IPv4 tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: IPv4 tx sync failed due to timeout\n", nss_ctx); + nss_ipv4_pvt.response = NSS_TX_FAILURE; + } + +@@ -396,14 +396,14 @@ static void nss_ipv4_conn_cfg_process_ca + struct nss_ctx_instance *nss_ctx __maybe_unused = nss_ipv4_get_mgr(); + + if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p: IPv4 connection configuration failed with error: %d\n", nss_ctx, nim->cm.error); ++ nss_warning("%px: IPv4 connection configuration failed with error: %d\n", nss_ctx, nim->cm.error); + nss_core_update_max_ipv4_conn(NSS_FW_DEFAULT_NUM_CONN); + nss_ipv4_free_conn_tables(); + return; + } + + nss_ipv4_conn_cfg = ntohl(nirccm->num_conn); +- nss_info("%p: IPv4 connection configuration success: %d\n", nss_ctx, nim->cm.error); ++ nss_info("%px: IPv4 connection configuration success: %d\n", nss_ctx, nim->cm.error); + } + + /* +@@ -417,17 +417,17 @@ static int nss_ipv4_conn_cfg_process(str + nss_tx_status_t nss_tx_status; + + if ((!nss_ipv4_ct_info.ce_table_size) || (!nss_ipv4_ct_info.cme_table_size)) { +- nss_warning("%p: connection entry or connection match entry table size not available\n", ++ nss_warning("%px: connection entry or connection match entry table size not available\n", + nss_ctx); + return -EINVAL; + } + +- nss_info("%p: IPv4 supported connections: %d\n", nss_ctx, conn); ++ nss_info("%px: IPv4 supported connections: %d\n", nss_ctx, conn); + + nss_ipv4_ct_info.ce_mem = __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, + get_order(nss_ipv4_ct_info.ce_table_size)); + if (!nss_ipv4_ct_info.ce_mem) { +- nss_warning("%p: Memory allocation failed for IPv4 Connections: %d\n", ++ nss_warning("%px: Memory allocation failed for IPv4 Connections: %d\n", + nss_ctx, + conn); + goto fail; +@@ -436,7 +436,7 @@ static int nss_ipv4_conn_cfg_process(str + nss_ipv4_ct_info.cme_mem = __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, + get_order(nss_ipv4_ct_info.cme_table_size)); + if (!nss_ipv4_ct_info.ce_mem) { +- nss_warning("%p: Memory allocation failed for IPv4 Connections: %d\n", ++ nss_warning("%px: Memory allocation failed for IPv4 Connections: %d\n", + nss_ctx, + conn); + goto fail; +@@ -450,19 +450,19 @@ static int nss_ipv4_conn_cfg_process(str + nirccm->num_conn = htonl(conn); + nirccm->ce_mem = dma_map_single(nss_ctx->dev, (void *)nss_ipv4_ct_info.ce_mem, nss_ipv4_ct_info.ce_table_size, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(nss_ctx->dev, nirccm->ce_mem))) { +- nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, (void *)nss_ipv4_ct_info.ce_mem); ++ nss_warning("%px: DMA mapping failed for virtual address = %px", nss_ctx, (void *)nss_ipv4_ct_info.ce_mem); + goto fail; + } + + nirccm->cme_mem = dma_map_single(nss_ctx->dev, (void *)nss_ipv4_ct_info.cme_mem, nss_ipv4_ct_info.cme_table_size, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(nss_ctx->dev, nirccm->cme_mem))) { +- nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, (void *)nss_ipv4_ct_info.cme_mem); ++ nss_warning("%px: DMA mapping failed for virtual address = %px", nss_ctx, (void *)nss_ipv4_ct_info.cme_mem); + goto fail; + } + + nss_tx_status = nss_ipv4_tx(nss_ctx, &nim); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_tx error setting IPv4 Connections: %d\n", ++ nss_warning("%px: nss_tx error setting IPv4 Connections: %d\n", + nss_ctx, + conn); + goto fail; +@@ -485,7 +485,7 @@ static void nss_ipv4_update_conn_count_c + struct nss_ctx_instance *nss_ctx = nss_ipv4_get_mgr(); + + if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p: IPv4 fetch connection info failed with error: %d\n", nss_ctx, nim->cm.error); ++ nss_warning("%px: IPv4 fetch connection info failed with error: %d\n", nss_ctx, nim->cm.error); + nss_core_update_max_ipv4_conn(NSS_FW_DEFAULT_NUM_CONN); + return; + } +@@ -496,7 +496,7 @@ static void nss_ipv4_update_conn_count_c + nss_ipv4_ct_info.cme_table_size = ntohl(nircgts->cme_table_size); + + if (nss_ipv4_conn_cfg_process(nss_ctx, ntohl(nircgts->num_conn)) != 0) { +- nss_warning("%p: IPv4 connection entry or connection match entry table size\ ++ nss_warning("%px: IPv4 connection entry or connection match entry table size\ + not available\n", nss_ctx); + } + +@@ -522,7 +522,7 @@ int nss_ipv4_update_conn_count(int ipv4_ + * By default, NSS FW is configured with default number of connections. + */ + if (ipv4_num_conn == NSS_FW_DEFAULT_NUM_CONN) { +- nss_info("%p: Default number of connections (%d) already configured\n", nss_ctx, ipv4_num_conn); ++ nss_info("%px: Default number of connections (%d) already configured\n", nss_ctx, ipv4_num_conn); + return 0; + } + +@@ -536,7 +536,7 @@ int nss_ipv4_update_conn_count(int ipv4_ + if ((ipv4_num_conn & NSS_NUM_CONN_QUANTA_MASK) || + (sum_of_conn > NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6) || + (ipv4_num_conn < NSS_MIN_NUM_CONN)) { +- nss_warning("%p: input supported connections (%d) does not adhere\ ++ nss_warning("%px: input supported connections (%d) does not adhere\ + specifications\n1) not multiple of 1024,\n2) is less than \ + min val: %d, OR\n IPv4/6 total exceeds %d\n", + nss_ctx, +@@ -555,7 +555,7 @@ int nss_ipv4_update_conn_count(int ipv4_ + nss_tx_status = nss_ipv4_tx(nss_ctx, &nim); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: Send fetch connection info message failed\n", nss_ctx); ++ nss_warning("%px: Send fetch connection info message failed\n", nss_ctx); + return -EINVAL; + } + +@@ -616,7 +616,7 @@ static int nss_ipv4_accel_mode_cfg_handl + + nss_tx_status = nss_ipv4_tx_sync(nss_ctx, &nim); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: Send acceleration mode message failed\n", nss_ctx); ++ nss_warning("%px: Send acceleration mode message failed\n", nss_ctx); + nss_ipv4_accel_mode_cfg = current_value; + return -EIO; + } +@@ -665,7 +665,7 @@ static int nss_ipv4_dscp_map_cfg_handler + + status = nss_ipv4_tx_sync(nss_ctx, &nim); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: ipv4 dscp2pri config message failed\n", nss_ctx); ++ nss_warning("%px: ipv4 dscp2pri config message failed\n", nss_ctx); + return -EFAULT; + } + +--- a/nss_ipv4_log.c ++++ b/nss_ipv4_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016, 2018, 2020, 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. +@@ -63,7 +63,7 @@ static int8_t *nss_ipv4_log_error_respon + static void nss_ipv4_log_rule_create_msg(struct nss_ipv4_msg *nim) + { + struct nss_ipv4_rule_create_msg *nircm __maybe_unused = &nim->msg.rule_create; +- nss_trace("%p: IPv4 create rule message \n" ++ nss_trace("%px: IPv4 create rule message \n" + "Protocol: %d\n" + "from_mtu: %u\n" + "to_mtu: %u\n" +@@ -124,7 +124,7 @@ static void nss_ipv4_log_rule_create_msg + static void nss_ipv4_log_destroy_rule_msg(struct nss_ipv4_msg *nim) + { + struct nss_ipv4_rule_destroy_msg *nirdm __maybe_unused = &nim->msg.rule_destroy; +- nss_trace("%p: IPv4 destroy rule message: \n" ++ nss_trace("%px: IPv4 destroy rule message: \n" + "flow_ip: %pI4h:%d\n" + "return_ip: %pI4h:%d\n" + "protocol: %d\n", +@@ -142,7 +142,7 @@ static void nss_ipv4_log_conn_sync(struc + { + struct nss_ipv4_conn_sync *sync = &nim->msg.conn_stats; + if (sync->flow_tx_packet_count || sync->return_tx_packet_count) { +- nss_trace("%p: IPv4 connection stats sync message: \n" ++ nss_trace("%px: IPv4 connection stats sync message: \n" + "Protocol: %d\n" + "src_addr: %pI4h:%d\n" + "dest_addr: %pI4h:%d\n" +@@ -176,7 +176,7 @@ static void nss_ipv4_log_conn_sync(struc + static void nss_ipv4_log_conn_cfg_msg(struct nss_ipv4_msg *nim) + { + struct nss_ipv4_rule_conn_cfg_msg *nirccm __maybe_unused = &nim->msg.rule_conn_cfg; +- nss_trace("%p: IPv4 number of connections supported rule message: \n" ++ nss_trace("%px: IPv4 number of connections supported rule message: \n" + "num_conn: %d\n", + nim, + nirccm->num_conn); +@@ -191,7 +191,7 @@ static void nss_ipv4_log_mc_rule_create_ + uint16_t vif; + struct nss_ipv4_mc_rule_create_msg *nimrcm = &nim->msg.mc_rule_create; + for (vif = 0; vif < nimrcm->if_count ; vif++) { +- nss_trace("%p: IPv4 multicast create rule message \n" ++ nss_trace("%px: IPv4 multicast create rule message \n" + "Rule flag: %x\n" + "Vif: %d\n" + "Protocol: %d\n" +@@ -227,7 +227,7 @@ static void nss_ipv4_log_conn_sync_many_ + for (i = 0; i < nicsm->count; i++) { + struct nss_ipv4_conn_sync *sync = &nicsm->conn_sync[i]; + if (sync->flow_tx_packet_count || sync->return_tx_packet_count) { +- nss_trace("%p: IPv4 many conn sync message \n" ++ nss_trace("%px: IPv4 many conn sync message \n" + "count: %d\n" + "i: %d\n" + "Protocol: %d\n" +@@ -295,7 +295,7 @@ static void nss_ipv4_log_verbose(struct + break; + + default: +- nss_trace("%p: Invalid message type\n", nim); ++ nss_trace("%px: Invalid message type\n", nim); + break; + } + } +@@ -307,11 +307,11 @@ static void nss_ipv4_log_verbose(struct + void nss_ipv4_log_tx_msg(struct nss_ipv4_msg *nim) + { + if (nim->cm.type >= NSS_IPV4_MAX_MSG_TYPES) { +- nss_info("%p: Invalid message type\n", nim); ++ nss_info("%px: Invalid message type\n", nim); + return; + } + +- nss_info("%p: type[%d]:%s\n", nim, nim->cm.type, nss_ipv4_log_message_types_str[nim->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nim, nim->cm.type, nss_ipv4_log_message_types_str[nim->cm.type]); + nss_ipv4_log_verbose(nim); + } + +@@ -322,26 +322,26 @@ void nss_ipv4_log_tx_msg(struct nss_ipv4 + void nss_ipv4_log_rx_msg(struct nss_ipv4_msg *nim) + { + if (nim->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_info("%p: Invalid response\n", nim); ++ nss_info("%px: Invalid response\n", nim); + return; + } + + if (nim->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nim->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nim, nim->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nim, nim->cm.type, + nss_ipv4_log_message_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response]); + goto verbose; + } + + if (nim->cm.error >= NSS_IPV4_LAST) { +- nss_info("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_info("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + nim, nim->cm.type, nss_ipv4_log_message_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response], + nim->cm.error); + goto verbose; + } + +- nss_info("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + nim, nim->cm.type, nss_ipv4_log_message_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response], + nim->cm.error, nss_ipv4_log_error_response_types_str[nim->cm.error]); +--- a/nss_ipv4_stats.c ++++ b/nss_ipv4_stats.c +@@ -130,7 +130,7 @@ void nss_ipv4_stats_conn_sync_many(struc + * Sanity check for the stats count + */ + if (nicsm->count * sizeof(struct nss_ipv4_conn_sync) >= nicsm->size) { +- nss_warning("%p: stats sync count %u exceeds the size of this msg %u", nss_ctx, nicsm->count, nicsm->size); ++ nss_warning("%px: stats sync count %u exceeds the size of this msg %u", nss_ctx, nicsm->count, nicsm->size); + return; + } + +--- a/nss_ipv6.c ++++ b/nss_ipv6.c +@@ -84,12 +84,12 @@ static void nss_ipv6_rx_msg_handler(stru + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_IPV6_MAX_MSG_TYPES) { +- nss_warning("%p: received invalid message %d for IPv6 interface", nss_ctx, nim->cm.type); ++ nss_warning("%px: received invalid message %d for IPv6 interface", nss_ctx, nim->cm.type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ipv6_msg)) { +- nss_warning("%p: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -224,7 +224,7 @@ nss_tx_status_t nss_ipv6_conn_inquiry(st + nim.msg.inquiry.rr.tuple = *ipv6_5t_p; + nss_tx_status = nss_ipv6_tx(nss_ctx, &nim); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: Send inquiry message failed\n", ipv6_5t_p); ++ nss_warning("%px: Send inquiry message failed\n", ipv6_5t_p); + } + + return nss_tx_status; +@@ -243,12 +243,12 @@ nss_tx_status_t nss_ipv6_tx_with_size(st + * Sanity check the message + */ + if (ncm->interface != NSS_IPV6_RX_INTERFACE) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_IPV6_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -289,14 +289,14 @@ nss_tx_status_t nss_ipv6_tx_sync(struct + + status = nss_ipv6_tx(nss_ctx, nim); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss ipv6 msg tx failed\n", nss_ctx); ++ nss_warning("%px: nss ipv6 msg tx failed\n", nss_ctx); + up(&nss_ipv6_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&nss_ipv6_pvt.complete, msecs_to_jiffies(NSS_IPV6_TX_MSG_TIMEOUT)); + if (!ret) { +- nss_warning("%p: IPv6 tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: IPv6 tx sync failed due to timeout\n", nss_ctx); + nss_ipv6_pvt.response = NSS_TX_FAILURE; + } + +@@ -399,7 +399,7 @@ static void nss_ipv6_conn_cfg_process_ca + struct nss_ctx_instance *nss_ctx __maybe_unused = nss_ipv6_get_mgr(); + + if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p: IPv6 connection configuration failed with error: %d\n", nss_ctx, nim->cm.error); ++ nss_warning("%px: IPv6 connection configuration failed with error: %d\n", nss_ctx, nim->cm.error); + nss_core_update_max_ipv6_conn(NSS_FW_DEFAULT_NUM_CONN); + nss_ipv6_free_conn_tables(); + return; +@@ -407,7 +407,7 @@ static void nss_ipv6_conn_cfg_process_ca + + nss_ipv6_conn_cfg = ntohl(nirccm->num_conn); + +- nss_info("%p: IPv6 connection configuration success: %d\n", nss_ctx, nim->cm.error); ++ nss_info("%px: IPv6 connection configuration success: %d\n", nss_ctx, nim->cm.error); + } + + /* +@@ -421,34 +421,34 @@ static int nss_ipv6_conn_cfg_process(str + nss_tx_status_t nss_tx_status; + + if ((!nss_ipv6_ct_info.ce_table_size) || (!nss_ipv6_ct_info.cme_table_size)) { +- nss_warning("%p: connection entry or connection match entry table size not available\n", ++ nss_warning("%px: connection entry or connection match entry table size not available\n", + nss_ctx); + return -EINVAL; + } + +- nss_info("%p: IPv6 supported connections: %d\n", nss_ctx, conn); ++ nss_info("%px: IPv6 supported connections: %d\n", nss_ctx, conn); + + nss_ipv6_ct_info.ce_mem = __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, + get_order(nss_ipv6_ct_info.ce_table_size)); + if (!nss_ipv6_ct_info.ce_mem) { +- nss_warning("%p: Memory allocation failed for IPv6 Connections: %d\n", ++ nss_warning("%px: Memory allocation failed for IPv6 Connections: %d\n", + nss_ctx, + conn); + goto fail; + } +- nss_info("%p: CE Memory allocated for IPv6 Connections: %d\n", ++ nss_info("%px: CE Memory allocated for IPv6 Connections: %d\n", + nss_ctx, + conn); + + nss_ipv6_ct_info.cme_mem = __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, + get_order(nss_ipv6_ct_info.cme_table_size)); + if (!nss_ipv6_ct_info.cme_mem) { +- nss_warning("%p: Memory allocation failed for IPv6 Connections: %d\n", ++ nss_warning("%px: Memory allocation failed for IPv6 Connections: %d\n", + nss_ctx, + conn); + goto fail; + } +- nss_info("%p: CME Memory allocated for IPv6 Connections: %d\n", ++ nss_info("%px: CME Memory allocated for IPv6 Connections: %d\n", + nss_ctx, + conn); + +@@ -460,19 +460,19 @@ static int nss_ipv6_conn_cfg_process(str + nirccm->num_conn = htonl(conn); + nirccm->ce_mem = dma_map_single(nss_ctx->dev, (void *)nss_ipv6_ct_info.ce_mem, nss_ipv6_ct_info.ce_table_size, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(nss_ctx->dev, nirccm->ce_mem))) { +- nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, (void *)nss_ipv6_ct_info.ce_mem); ++ nss_warning("%px: DMA mapping failed for virtual address = %px", nss_ctx, (void *)nss_ipv6_ct_info.ce_mem); + goto fail; + } + + nirccm->cme_mem = dma_map_single(nss_ctx->dev, (void *)nss_ipv6_ct_info.cme_mem, nss_ipv6_ct_info.cme_table_size, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(nss_ctx->dev, nirccm->cme_mem))) { +- nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, (void *)nss_ipv6_ct_info.cme_mem); ++ nss_warning("%px: DMA mapping failed for virtual address = %px", nss_ctx, (void *)nss_ipv6_ct_info.cme_mem); + goto fail; + } + + nss_tx_status = nss_ipv6_tx(nss_ctx, &nim); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_tx error setting IPv6 Connections: %d\n", ++ nss_warning("%px: nss_tx error setting IPv6 Connections: %d\n", + nss_ctx, + conn); + goto fail; +@@ -495,7 +495,7 @@ static void nss_ipv6_update_conn_count_c + struct nss_ctx_instance *nss_ctx = nss_ipv6_get_mgr(); + + if (nim->cm.response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p: IPv6 fetch connection info failed with error: %d\n", nss_ctx, nim->cm.error); ++ nss_warning("%px: IPv6 fetch connection info failed with error: %d\n", nss_ctx, nim->cm.error); + nss_core_update_max_ipv6_conn(NSS_FW_DEFAULT_NUM_CONN); + return; + } +@@ -506,7 +506,7 @@ static void nss_ipv6_update_conn_count_c + nss_ipv6_ct_info.cme_table_size = ntohl(nircgts->cme_table_size); + + if (nss_ipv6_conn_cfg_process(nss_ctx, ntohl(nircgts->num_conn)) != 0) { +- nss_warning("%p: IPv6 connection entry or connection match entry table size\ ++ nss_warning("%px: IPv6 connection entry or connection match entry table size\ + not available\n", nss_ctx); + } + +@@ -532,7 +532,7 @@ int nss_ipv6_update_conn_count(int ipv6_ + * By default, NSS FW is configured with default number of connections. + */ + if (ipv6_num_conn == NSS_FW_DEFAULT_NUM_CONN) { +- nss_info("%p: Default number of connections (%d) already configured\n", nss_ctx, ipv6_num_conn); ++ nss_info("%px: Default number of connections (%d) already configured\n", nss_ctx, ipv6_num_conn); + return 0; + } + +@@ -547,7 +547,7 @@ int nss_ipv6_update_conn_count(int ipv6_ + if ((ipv6_num_conn & NSS_NUM_CONN_QUANTA_MASK) || + (sum_of_conn > NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6) || + (ipv6_num_conn < NSS_MIN_NUM_CONN)) { +- nss_warning("%p: input supported connections (%d) does not adhere\ ++ nss_warning("%px: input supported connections (%d) does not adhere\ + specifications\n1) not power of 2,\n2) is less than \ + min val: %d, OR\n IPv4/6 total exceeds %d\n", + nss_ctx, +@@ -565,7 +565,7 @@ int nss_ipv6_update_conn_count(int ipv6_ + nircgts->num_conn = htonl(ipv6_num_conn); + nss_tx_status = nss_ipv6_tx(nss_ctx, &nim); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: Send acceleration mode message failed\n", nss_ctx); ++ nss_warning("%px: Send acceleration mode message failed\n", nss_ctx); + return -EINVAL; + } + +@@ -626,7 +626,7 @@ static int nss_ipv6_accel_mode_cfg_handl + + nss_tx_status = nss_ipv6_tx_sync(nss_ctx, &nim); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: Send acceleration mode message failed\n", nss_ctx); ++ nss_warning("%px: Send acceleration mode message failed\n", nss_ctx); + nss_ipv6_accel_mode_cfg = current_value; + return -EIO; + } +@@ -674,7 +674,7 @@ static int nss_ipv6_dscp_map_cfg_handler + + status = nss_ipv6_tx_sync(nss_ctx, &nim); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: ipv6 dscp2pri config message failed\n", nss_ctx); ++ nss_warning("%px: ipv6 dscp2pri config message failed\n", nss_ctx); + return -EFAULT; + } + +--- a/nss_ipv6_log.c ++++ b/nss_ipv6_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016, 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016, 2018, 2020, 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. +@@ -80,7 +80,7 @@ static void nss_ipv6_log_rule_create_msg + NSS_IPV6_ADDR_TO_NW(nircm->tuple.flow_ip, src_ip); + NSS_IPV6_ADDR_TO_NW(nircm->tuple.return_ip, dest_ip); + +- nss_trace("%p: IPv6 create rule message \n" ++ nss_trace("%px: IPv6 create rule message \n" + "Protocol: %d\n" + "from_mtu: %u\n" + "to_mtu: %u\n" +@@ -143,7 +143,7 @@ static void nss_ipv6_log_destroy_rule_ms + NSS_IPV6_ADDR_TO_NW(nirdm->tuple.flow_ip, src_ip); + NSS_IPV6_ADDR_TO_NW(nirdm->tuple.return_ip, dest_ip); + +- nss_trace("%p: IPv6 destroy rule message: \n" ++ nss_trace("%px: IPv6 destroy rule message: \n" + "flow_ip: %pI6:%d\n" + "return_ip: %pI6:%d\n" + "protocol: %d\n", +@@ -167,7 +167,7 @@ static void nss_ipv6_log_conn_sync(struc + NSS_IPV6_ADDR_TO_NW(sync->flow_ip, src_ip); + NSS_IPV6_ADDR_TO_NW(sync->return_ip, dest_ip); + +- nss_trace("%p: IPv6 connection stats sync message: \n" ++ nss_trace("%px: IPv6 connection stats sync message: \n" + "Protocol: %d\n" + "src_addr: %pI6:%d\n" + "dest_addr: %pI6:%d\n" +@@ -201,7 +201,7 @@ static void nss_ipv6_log_conn_sync(struc + static void nss_ipv6_log_conn_cfg_msg(struct nss_ipv6_msg *nim) + { + struct nss_ipv6_rule_conn_cfg_msg *nirccm __maybe_unused = &nim->msg.rule_conn_cfg; +- nss_trace("%p: IPv6 number of connections supported rule message: \n" ++ nss_trace("%px: IPv6 number of connections supported rule message: \n" + "num_conn: %d\n", + nim, + nirccm->num_conn); +@@ -222,7 +222,7 @@ static void nss_ipv6_log_mc_rule_create_ + NSS_IPV6_ADDR_TO_NW(nimrcm->tuple.return_ip, dest_ip); + + for (vif = 0; vif < nimrcm->if_count ; vif++) { +- nss_trace("%p: IPv6 multicast create rule message \n" ++ nss_trace("%px: IPv6 multicast create rule message \n" + "Rule flag: %x\n" + "Vif: %d\n" + "Protocol: %d\n" +@@ -264,7 +264,7 @@ static void nss_ipv6_log_conn_sync_many_ + NSS_IPV6_ADDR_TO_NW(sync->flow_ip, src_ip); + NSS_IPV6_ADDR_TO_NW(sync->return_ip, dest_ip); + +- nss_trace("%p: IPv6 many conn sync message \n" ++ nss_trace("%px: IPv6 many conn sync message \n" + "count: %d\n" + "i: %d\n" + "Protocol: %d\n" +@@ -332,7 +332,7 @@ static void nss_ipv6_log_verbose(struct + break; + + default: +- nss_trace("%p: Invalid message type\n", nim); ++ nss_trace("%px: Invalid message type\n", nim); + break; + } + } +@@ -343,7 +343,7 @@ static void nss_ipv6_log_verbose(struct + */ + void nss_ipv6_log_tx_msg(struct nss_ipv6_msg *nim) + { +- nss_info("%p: type[%d]: %s\n", nim, nim->cm.type, nss_ipv6_log_message_types_str[nim->cm.type]); ++ nss_info("%px: type[%d]: %s\n", nim, nim->cm.type, nss_ipv6_log_message_types_str[nim->cm.type]); + nss_ipv6_log_verbose(nim); + } + +@@ -354,26 +354,26 @@ void nss_ipv6_log_tx_msg(struct nss_ipv6 + void nss_ipv6_log_rx_msg(struct nss_ipv6_msg *nim) + { + if (nim->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_info("%p: Invalid response\n", nim); ++ nss_info("%px: Invalid response\n", nim); + return; + } + + if (nim->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nim->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]: %s, response[%d]: %s\n", nim, nim->cm.type, ++ nss_info("%px: type[%d]: %s, response[%d]: %s\n", nim, nim->cm.type, + nss_ipv6_log_message_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response]); + goto verbose; + } + + if (nim->cm.error > NSS_IPV6_CR_MULTICAST_UPDATE_INVALID_IF) { +- nss_info("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_info("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + nim, nim->cm.type, nss_ipv6_log_message_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response], + nim->cm.error); + goto verbose; + } + +- nss_info("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + nim, nim->cm.type, nss_ipv6_log_message_types_str[nim->cm.type], + nim->cm.response, nss_cmn_response_str[nim->cm.response], + nim->cm.error, nss_ipv6_log_error_response_types_str[nim->cm.error]); +--- a/nss_ipv6_stats.c ++++ b/nss_ipv6_stats.c +@@ -132,7 +132,7 @@ void nss_ipv6_stats_conn_sync_many(struc + * Sanity check for the stats count + */ + if (nicsm->count * sizeof(struct nss_ipv6_conn_sync) >= nicsm->size) { +- nss_warning("%p: stats sync count %u exceeds the size of this msg %u", nss_ctx, nicsm->count, nicsm->size); ++ nss_warning("%px: stats sync count %u exceeds the size of this msg %u", nss_ctx, nicsm->count, nicsm->size); + return; + } + +--- a/nss_l2tpv2.c ++++ b/nss_l2tpv2.c +@@ -95,12 +95,12 @@ static void nss_l2tpv2_handler(struct ns + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_L2TPV2_MSG_MAX) { +- nss_warning("%p: received invalid message %d for L2TP interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for L2TP interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_l2tpv2_msg)) { +- nss_warning("%p: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: message length is invalid: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -145,7 +145,7 @@ static void nss_l2tpv2_handler(struct ns + * call l2tpv2 tunnel callback + */ + if (!ctx) { +- nss_warning("%p: Event received for l2tpv2 tunnel interface %d before registration", nss_ctx, ncm->interface); ++ nss_warning("%px: Event received for l2tpv2 tunnel interface %d before registration", nss_ctx, ncm->interface); + return; + } + +@@ -169,12 +169,12 @@ nss_tx_status_t nss_l2tpv2_tx(struct nss + * Sanity check the message + */ + if (!nss_is_dynamic_interface(ncm->interface)) { +- nss_warning("%p: tx request for non dynamic interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for non dynamic interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_L2TPV2_MSG_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +--- a/nss_l2tpv2_log.c ++++ b/nss_l2tpv2_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -38,7 +38,7 @@ static int8_t *nss_l2tpv2_log_message_ty + static void nss_l2tpv2_log_session_create_msg(struct nss_l2tpv2_msg *nlm) + { + struct nss_l2tpv2_session_create_msg *nlcm __maybe_unused = &nlm->msg.session_create_msg; +- nss_trace("%p: NSS L2TPV2 Session Create message \n" ++ nss_trace("%px: NSS L2TPV2 Session Create message \n" + "L2TPV2 Local Tunnel ID: %x\n" + "L2TPV2 Local Session ID: %x\n" + "L2TPV2 Peer Tunnel ID: %x\n" +@@ -67,7 +67,7 @@ static void nss_l2tpv2_log_session_creat + static void nss_l2tpv2_log_session_destroy_msg(struct nss_l2tpv2_msg *nlm) + { + struct nss_l2tpv2_session_destroy_msg *nldm __maybe_unused = &nlm->msg.session_destroy_msg; +- nss_trace("%p: NSS L2TPV2 Session Destroy message \n" ++ nss_trace("%px: NSS L2TPV2 Session Destroy message \n" + "L2TPV2 Local Tunnel ID: %x\n" + "L2TPV2 Local Session ID: %x\n", + nldm, nldm->local_tunnel_id, +@@ -96,7 +96,7 @@ static void nss_l2tpv2_log_verbose(struc + break; + + default: +- nss_trace("%p: Invalid message type\n", nlm); ++ nss_trace("%px: Invalid message type\n", nlm); + break; + } + } +@@ -108,11 +108,11 @@ static void nss_l2tpv2_log_verbose(struc + void nss_l2tpv2_log_tx_msg(struct nss_l2tpv2_msg *nlm) + { + if (nlm->cm.type >= NSS_L2TPV2_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", nlm); ++ nss_warning("%px: Invalid message type\n", nlm); + return; + } + +- nss_info("%p: type[%d]:%s\n", nlm, nlm->cm.type, nss_l2tpv2_log_message_types_str[nlm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nlm, nlm->cm.type, nss_l2tpv2_log_message_types_str[nlm->cm.type]); + nss_l2tpv2_log_verbose(nlm); + } + +@@ -123,18 +123,18 @@ void nss_l2tpv2_log_tx_msg(struct nss_l2 + void nss_l2tpv2_log_rx_msg(struct nss_l2tpv2_msg *nlm) + { + if (nlm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nlm); ++ nss_warning("%px: Invalid response\n", nlm); + return; + } + + if (nlm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nlm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nlm, nlm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nlm, nlm->cm.type, + nss_l2tpv2_log_message_types_str[nlm->cm.type], + nlm->cm.response, nss_cmn_response_str[nlm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + nlm, nlm->cm.type, nss_l2tpv2_log_message_types_str[nlm->cm.type], + nlm->cm.response, nss_cmn_response_str[nlm->cm.response]); + +--- a/nss_lag.c ++++ b/nss_lag.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014-2018, 2020, 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. +@@ -90,7 +90,7 @@ nss_tx_status_t nss_lag_tx(struct nss_ct + nss_lag_verify_ifnum(ncm->interface); + + if (ncm->type > NSS_TX_METADATA_LAG_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -123,7 +123,6 @@ void *nss_register_lag_if(uint32_t if_nu + } + EXPORT_SYMBOL(nss_register_lag_if); + +- + /** + * nss_unregister_lag_if() + */ +@@ -140,7 +139,6 @@ void nss_unregister_lag_if(uint32_t if_n + } + EXPORT_SYMBOL(nss_unregister_lag_if); + +- + /** + * nss_lag_handler() + */ +@@ -163,12 +161,12 @@ void nss_lag_handler(struct nss_ctx_inst + nss_lag_log_rx_msg(lm); + + if (ncm->type >= NSS_TX_METADATA_LAG_MAX) { +- nss_warning("%p: received invalid message %d for LAG interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for LAG interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_lag_msg)) { +- nss_warning("%p: invalid length for LAG message: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: invalid length for LAG message: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -201,7 +199,6 @@ void nss_lag_handler(struct nss_ctx_inst + cb(ctx, lm); + } + +- + /** + * nss_lag_register_handler() + */ +@@ -256,7 +253,7 @@ nss_tx_status_t nss_lag_tx_slave_state(u + + status = nss_lag_tx(nss_ctx, &nm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Send LAG update failed, status: %d\n", nss_ctx, ++ nss_warning("%px: Send LAG update failed, status: %d\n", nss_ctx, + status); + return NSS_TX_FAILURE; + } +@@ -267,7 +264,7 @@ nss_tx_status_t nss_lag_tx_slave_state(u + ret = wait_for_completion_timeout(&lag_msg_state.complete, + msecs_to_jiffies(NSS_LAG_RESP_TIMEOUT)); + if (!ret) { +- nss_warning("%p: Waiting for ack timed out\n", nss_ctx); ++ nss_warning("%px: Waiting for ack timed out\n", nss_ctx); + return NSS_TX_FAILURE; + } + +--- a/nss_lag_log.c ++++ b/nss_lag_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -36,7 +36,7 @@ static int8_t *nss_lag_log_message_types + static void nss_lag_log_state_change_msg(struct nss_lag_msg *nlm) + { + struct nss_lag_state_change *nlcm __maybe_unused = &nlm->msg.state; +- nss_trace("%p: NSS LAG State Change message \n" ++ nss_trace("%px: NSS LAG State Change message \n" + "LAG ID: %x\n" + "LAG Interface: %x\n" + "LAG Event: %d\n", +@@ -54,9 +54,9 @@ static void nss_lag_log_verbose(struct n + case NSS_TX_METADATA_LAG_STATE_CHANGE: + nss_lag_log_state_change_msg(nlm); + break; +- ++ + default: +- nss_trace("%p: Invalid message type\n", nlm); ++ nss_trace("%px: Invalid message type\n", nlm); + break; + } + } +@@ -68,11 +68,11 @@ static void nss_lag_log_verbose(struct n + void nss_lag_log_tx_msg(struct nss_lag_msg *nlm) + { + if (nlm->cm.type >= NSS_TX_METADATA_LAG_MAX) { +- nss_warning("%p: Invalid message type\n", nlm); ++ nss_warning("%px: Invalid message type\n", nlm); + return; + } + +- nss_info("%p: type[%d]:%s\n", nlm, nlm->cm.type, nss_lag_log_message_types_str[nlm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nlm, nlm->cm.type, nss_lag_log_message_types_str[nlm->cm.type]); + nss_lag_log_verbose(nlm); + } + +@@ -83,18 +83,18 @@ void nss_lag_log_tx_msg(struct nss_lag_m + void nss_lag_log_rx_msg(struct nss_lag_msg *nlm) + { + if (nlm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nlm); ++ nss_warning("%px: Invalid response\n", nlm); + return; + } + + if (nlm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nlm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nlm, nlm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nlm, nlm->cm.type, + nss_lag_log_message_types_str[nlm->cm.type], + nlm->cm.response, nss_cmn_response_str[nlm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + nlm, nlm->cm.type, nss_lag_log_message_types_str[nlm->cm.type], + nlm->cm.response, nss_cmn_response_str[nlm->cm.response]); + +--- a/nss_log.c ++++ b/nss_log.c +@@ -108,7 +108,7 @@ static int nss_log_open(struct inode *in + + data = kzalloc(sizeof(struct nss_log_data), GFP_KERNEL); + if (!data) { +- nss_warning("%p: Failed to allocate memory for log_data", nss_ctx); ++ nss_warning("%px: Failed to allocate memory for log_data", nss_ctx); + return -ENOMEM; + } + +@@ -116,7 +116,7 @@ static int nss_log_open(struct inode *in + if (!nss_rbe[nss_id].addr) { + mutex_unlock(&nss_log_mutex); + kfree(data); +- nss_warning("%p: Ring buffer not configured yet for nss_id:%d", nss_ctx, nss_id); ++ nss_warning("%px: Ring buffer not configured yet for nss_id:%d", nss_ctx, nss_id); + return -EIO; + } + +@@ -196,7 +196,7 @@ static ssize_t nss_log_read(struct file + + desc = data->load_mem; + if (!desc) { +- nss_warning("%p: load_mem is NULL", data); ++ nss_warning("%px: load_mem is NULL", data); + return -EINVAL; + } + +@@ -333,12 +333,12 @@ static void nss_debug_interface_handler( + * Is this a valid request/response packet? + */ + if (ncm->type > NSS_DEBUG_INTERFACE_TYPE_MAX) { +- nss_warning("%p: received invalid message %d for CAPWAP interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for CAPWAP interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_log_debug_interface_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -356,7 +356,7 @@ static void nss_debug_interface_handler( + * Do we have a callback + */ + if (!ncm->cb) { +- nss_trace("%p: cb is null for interface %d", nss_ctx, ncm->interface); ++ nss_trace("%px: cb is null for interface %d", nss_ctx, ncm->interface); + return; + } + +@@ -376,12 +376,12 @@ static nss_tx_status_t nss_debug_interfa + * Sanity check the message + */ + if (ncm->interface != NSS_DEBUG_INTERFACE) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_DEBUG_INTERFACE_TYPE_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -411,21 +411,21 @@ bool nss_debug_log_buffer_alloc(uint8_t + nss_ctx = &nss_top->nss[nss_id]; + + if (nss_ctx->state != NSS_CORE_STATE_INITIALIZED) { +- nss_warning("%p: NSS Core:%d is not initialized yet\n", nss_ctx, nss_id); ++ nss_warning("%px: NSS Core:%d is not initialized yet\n", nss_ctx, nss_id); + return false; + } + + size = sizeof(struct nss_log_descriptor) + (sizeof(struct nss_log_entry) * nentry); + addr = kmalloc(size, GFP_ATOMIC); + if (!addr) { +- nss_warning("%p: Failed to allocate memory for logging (size:%d)\n", nss_ctx, size); ++ nss_warning("%px: Failed to allocate memory for logging (size:%d)\n", nss_ctx, size); + return false; + } + + memset(addr, 0, size); + dma_addr = (uint32_t)dma_map_single(nss_ctx->dev, addr, size, DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(nss_ctx->dev, dma_addr))) { +- nss_warning("%p: Failed to map address in DMA", nss_ctx); ++ nss_warning("%px: Failed to map address in DMA", nss_ctx); + kfree(addr); + return false; + } +@@ -444,7 +444,7 @@ bool nss_debug_log_buffer_alloc(uint8_t + * release the reference. + */ + if (!wait_event_timeout(nss_log_wq, !nss_rbe[nss_id].ref_cnt, 5 * HZ)) { +- nss_warning("%p: Timeout waiting for refcnt to become 0\n", nss_ctx); ++ nss_warning("%px: Timeout waiting for refcnt to become 0\n", nss_ctx); + goto fail; + } + +@@ -455,7 +455,7 @@ bool nss_debug_log_buffer_alloc(uint8_t + } + if (nss_rbe[nss_id].ref_cnt > 0) { + mutex_unlock(&nss_log_mutex); +- nss_warning("%p: Some other thread is contending..opting out\n", nss_ctx); ++ nss_warning("%px: Some other thread is contending..opting out\n", nss_ctx); + goto fail; + } + } +@@ -473,7 +473,7 @@ bool nss_debug_log_buffer_alloc(uint8_t + status = nss_debug_interface_tx(nss_ctx, &msg); + if (status != NSS_TX_SUCCESS) { + mutex_unlock(&nss_log_mutex); +- nss_warning("%p: Failed to send message to debug interface:%d\n", nss_ctx, status); ++ nss_warning("%px: Failed to send message to debug interface:%d\n", nss_ctx, status); + goto fail; + } + +@@ -484,13 +484,13 @@ bool nss_debug_log_buffer_alloc(uint8_t + */ + if (!wait_event_timeout(msg_wq, msg_event, 5 * HZ)) { + mutex_unlock(&nss_log_mutex); +- nss_warning("%p: Timeout send message to debug interface\n", nss_ctx); ++ nss_warning("%px: Timeout send message to debug interface\n", nss_ctx); + goto fail; + } + + if (msg_response != NSS_CMN_RESPONSE_ACK) { + mutex_unlock(&nss_log_mutex); +- nss_warning("%p: Response error for send message to debug interface:%d\n", nss_ctx, msg_response); ++ nss_warning("%px: Response error for send message to debug interface:%d\n", nss_ctx, msg_response); + goto fail; + } + +--- a/nss_lso_rx.c ++++ b/nss_lso_rx.c +@@ -45,7 +45,7 @@ static void nss_rx_lso_rx_interface_hand + /* + * Check response + */ +- nss_info("%p: Received response %d for type %d, interface %d", nss_ctx, ncm->response, ncm->type, ncm->interface); ++ nss_info("%px: Received response %d for type %d, interface %d", nss_ctx, ncm->response, ncm->type, ncm->interface); + } + } + } +--- a/nss_map_t.c ++++ b/nss_map_t.c +@@ -165,12 +165,12 @@ static void nss_map_t_handler(struct nss + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_MAP_T_MSG_MAX) { +- nss_warning("%p: received invalid message %d for MAP-T interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for MAP-T interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_map_t_msg)) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return; + } + +@@ -208,7 +208,7 @@ static void nss_map_t_handler(struct nss + * call map-t callback + */ + if (!cb) { +- nss_warning("%p: No callback for map-t interface %d", ++ nss_warning("%px: No callback for map-t interface %d", + nss_ctx, ncm->interface); + return; + } +@@ -259,12 +259,12 @@ nss_tx_status_t nss_map_t_tx(struct nss_ + * Sanity check the message + */ + if (!nss_map_t_verify_if_num(ncm->interface)) { +- nss_warning("%p: tx request is not for a MAP-T dynamic interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request is not for a MAP-T dynamic interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_MAP_T_MSG_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -290,14 +290,14 @@ nss_tx_status_t nss_map_t_tx_sync(struct + + status = nss_map_t_tx(nss_ctx, msg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: map_t_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: map_t_tx_msg failed\n", nss_ctx); + up(&nss_map_t_pvt.sem); + return status; + } + ret = wait_for_completion_timeout(&nss_map_t_pvt.complete, msecs_to_jiffies(NSS_MAP_T_TX_TIMEOUT)); + + if (!ret) { +- nss_warning("%p: MAP-T tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: MAP-T tx sync failed due to timeout\n", nss_ctx); + nss_map_t_pvt.response = NSS_TX_FAILURE; + } + +--- a/nss_map_t_log.c ++++ b/nss_map_t_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -38,7 +38,7 @@ static int8_t *nss_map_t_log_message_typ + static void nss_map_t_log_rule_configure_msg(struct nss_map_t_msg *ntm) + { + struct nss_map_t_instance_rule_config_msg *ntcm __maybe_unused = &ntm->msg.create_msg; +- nss_trace("%p: NSS MAP_T Rule Configure message \n" ++ nss_trace("%px: NSS MAP_T Rule Configure message \n" + "MAP_T Rule Seq Number: %d\n" + "MAP_T Total Number of Rules: %d\n" + "MAP_T Local IPv6 Prefix Length: %d\n" +@@ -54,9 +54,9 @@ static void nss_map_t_log_rule_configure + "MAP_T Remote PSID Offset: %d\n" + "MAP_T Local MAP Style: %d\n" + "MAP_T Remote Map Style: %d\n" +- "MAP_T Local IPv6 Prefix: %p\n" +- "MAP_T Reserved B: %p\n" +- "MAP_T Remote IPv6 Prefix: %p\n" ++ "MAP_T Local IPv6 Prefix: %px\n" ++ "MAP_T Reserved B: %px\n" ++ "MAP_T Remote IPv6 Prefix: %px\n" + "MAP_T Valid Rule: %d\n", + ntcm, ntcm->rule_num, ntcm->total_rules, + ntcm->local_ipv6_prefix_len, ntcm->local_ipv4_prefix, +@@ -77,7 +77,7 @@ static void nss_map_t_log_rule_configure + static void nss_map_t_log_rule_deconfig_msg(struct nss_map_t_msg *ntm) + { + struct nss_map_t_instance_rule_deconfig_msg *ntdm __maybe_unused = &ntm->msg.destroy_msg; +- nss_trace("%p: NSS MAP_T Rule Deconfigure message \n" ++ nss_trace("%px: NSS MAP_T Rule Deconfigure message \n" + "MAP_T Interface Number: %d\n", + ntdm, ntdm->if_number); + } +@@ -104,7 +104,7 @@ static void nss_map_t_log_verbose(struct + break; + + default: +- nss_trace("%p: Invalid message type\n", ntm); ++ nss_trace("%px: Invalid message type\n", ntm); + break; + } + } +@@ -116,11 +116,11 @@ static void nss_map_t_log_verbose(struct + void nss_map_t_log_tx_msg(struct nss_map_t_msg *ntm) + { + if (ntm->cm.type >= NSS_MAP_T_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", ntm); ++ nss_warning("%px: Invalid message type\n", ntm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ntm, ntm->cm.type, nss_map_t_log_message_types_str[ntm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ntm, ntm->cm.type, nss_map_t_log_message_types_str[ntm->cm.type]); + nss_map_t_log_verbose(ntm); + } + +@@ -131,18 +131,18 @@ void nss_map_t_log_tx_msg(struct nss_map + void nss_map_t_log_rx_msg(struct nss_map_t_msg *ntm) + { + if (ntm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ntm); ++ nss_warning("%px: Invalid response\n", ntm); + return; + } + + if (ntm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ntm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, + nss_map_t_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + ntm, ntm->cm.type, nss_map_t_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); + +--- a/nss_match.c ++++ b/nss_match.c +@@ -96,12 +96,12 @@ static nss_tx_status_t nss_match_msg_tx( + * Sanity check the message + */ + if (!nss_match_verify_if_num(ncm->interface)) { +- nss_warning("%p: Tx request for non dynamic interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: Tx request for non dynamic interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_MATCH_MSG_MAX) { +- nss_warning("%p: Message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: Message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -131,12 +131,12 @@ static void nss_match_handler(struct nss + * Is this a valid request/response packet? + */ + if (nem->cm.type >= NSS_MATCH_MSG_MAX) { +- nss_warning("%p: Received invalid message %d for MATCH interface", nss_ctx, nem->cm.type); ++ nss_warning("%px: Received invalid message %d for MATCH interface", nss_ctx, nem->cm.type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_match_msg)) { +- nss_warning("%p: Unexpected message length: %d, on interface: %d", ++ nss_warning("%px: Unexpected message length: %d, on interface: %d", + nss_ctx, nss_cmn_get_msg_len(ncm), ncm->interface); + return; + } +@@ -151,7 +151,7 @@ static void nss_match_handler(struct nss + } + + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + } + + /* +@@ -190,14 +190,14 @@ nss_tx_status_t nss_match_msg_tx_sync(st + + status = nss_match_msg_tx(nss_ctx, matchm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_match_msg_tx failed\n", nss_ctx); ++ nss_warning("%px: nss_match_msg_tx failed\n", nss_ctx); + up(&match_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&match_pvt.complete, msecs_to_jiffies(NSS_MATCH_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: MATCH tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: MATCH tx failed due to timeout\n", nss_ctx); + match_pvt.response = NSS_TX_FAILURE; + } + +@@ -215,22 +215,27 @@ EXPORT_SYMBOL(nss_match_msg_tx_sync); + struct nss_ctx_instance *nss_match_register_instance(int if_num, nss_match_msg_sync_callback_t notify_cb) + { + struct nss_ctx_instance *nss_ctx; ++ uint32_t status; + + nss_ctx = nss_match_get_context(); + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (!nss_match_verify_if_num(if_num)) { +- nss_warning("%p: Incorrect interface number: %d", nss_ctx, if_num); ++ nss_warning("%px: Incorrect interface number: %d", nss_ctx, if_num); + return NULL; + } + + nss_core_register_handler(nss_ctx, if_num, nss_match_handler, NULL); +- nss_top_main.if_rx_msg_callback[if_num] = (nss_if_rx_msg_callback_t)notify_cb; ++ status = nss_core_register_msg_handler(nss_ctx, if_num, (nss_if_rx_msg_callback_t)notify_cb); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to register handler for interface %d with NSS core\n", nss_ctx, if_num); ++ return NULL; ++ } + + if (!nss_match_ifnum_add(if_num)) { +- nss_warning("Unable to add match inteface : %u\n", if_num); ++ nss_warning("%px: Unable to add match inteface : %u\n", nss_ctx, if_num); + nss_core_unregister_handler(nss_ctx, if_num); +- nss_top_main.if_rx_msg_callback[if_num] = NULL; ++ nss_core_unregister_msg_handler(nss_ctx, if_num); + return NULL; + } + +@@ -245,17 +250,23 @@ EXPORT_SYMBOL(nss_match_register_instanc + bool nss_match_unregister_instance(int if_num) + { + struct nss_ctx_instance *nss_ctx; ++ uint32_t status; + + nss_ctx = nss_match_get_context(); + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (!nss_match_verify_if_num(if_num)) { +- nss_warning("%p: Incorrect interface number: %d", nss_ctx, if_num); ++ nss_warning("%px: Incorrect interface number: %d", nss_ctx, if_num); + return false; + } + + nss_core_unregister_handler(nss_ctx, if_num); +- nss_top_main.if_rx_msg_callback[if_num] = NULL; ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to unregister handler for interface %d with NSS core\n", nss_ctx, if_num); ++ return false; ++ } ++ + nss_match_ifnum_delete(if_num); + + return true; +--- a/nss_match_log.c ++++ b/nss_match_log.c +@@ -72,7 +72,7 @@ static void nss_match_log_profile_config + struct nss_match_profile_configure_msg *nmcm __maybe_unused = &nmm->msg.configure_msg; + int mask_num, mask_word; + +- nss_trace("%p: NSS match configuration message \n" ++ nss_trace("%px: NSS match configuration message \n" + "Match profile type: %u \n" + "Match mask flag: %u \n", + nmcm, +@@ -94,7 +94,7 @@ static void nss_match_log_profile_config + static void nss_match_log_vow_rule_msg(struct nss_match_msg *nmm) + { + struct nss_match_rule_vow_msg *nmvrm __maybe_unused = &nmm->msg.vow_rule; +- nss_trace("%p: NSS match VoW rule message \n" ++ nss_trace("%px: NSS match VoW rule message \n" + "Match rule id: %hu \n" + "Match mask id: %hu \n" + "Match action: action flag = %u, next node = %u, priority = %hu \n" +@@ -119,7 +119,7 @@ static void nss_match_log_vow_rule_msg(s + static void nss_match_log_l2_rule_msg(struct nss_match_msg *nmm) + { + struct nss_match_rule_l2_msg *nmlrm __maybe_unused = &nmm->msg.l2_rule; +- nss_trace("%p: NSS match L2 rule message \n" ++ nss_trace("%px: NSS match L2 rule message \n" + "Match rule id: %hu \n" + "Match mask id: %hu \n" + "Match action: action flag = %u, next node = %u, priority = %hu \n" +@@ -169,7 +169,7 @@ static void nss_match_log_verbose(struct + break; + + default: +- nss_trace("%p: Invalid message type\n", nmm); ++ nss_trace("%px: Invalid message type\n", nmm); + break; + } + } +@@ -181,11 +181,11 @@ static void nss_match_log_verbose(struct + void nss_match_log_tx_msg(struct nss_match_msg *nmm) + { + if (nmm->cm.type >= NSS_MATCH_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", nmm); ++ nss_warning("%px: Invalid message type\n", nmm); + return; + } + +- nss_info("%p: type[%d]:%s\n", nmm, nmm->cm.type, nss_match_log_message_types_str[nmm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nmm, nmm->cm.type, nss_match_log_message_types_str[nmm->cm.type]); + nss_match_log_verbose(nmm); + } + +@@ -196,26 +196,26 @@ void nss_match_log_tx_msg(struct nss_mat + void nss_match_log_rx_msg(struct nss_match_msg *nmm) + { + if (nmm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nmm); ++ nss_warning("%px: Invalid response\n", nmm); + return; + } + + if (nmm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nmm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nmm, nmm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nmm, nmm->cm.type, + nss_match_log_message_types_str[nmm->cm.type], + nmm->cm.response, nss_cmn_response_str[nmm->cm.response]); + goto verbose; + } + + if (nmm->cm.error >= NSS_MATCH_ERROR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + nmm, nmm->cm.type, nss_match_log_message_types_str[nmm->cm.type], + nmm->cm.response, nss_cmn_response_str[nmm->cm.response], + nmm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + nmm, nmm->cm.type, nss_match_log_message_types_str[nmm->cm.type], + nmm->cm.response, nss_cmn_response_str[nmm->cm.response], + nmm->cm.error, nss_match_log_error_types_str[nmm->cm.error]); +--- a/nss_mirror.c ++++ b/nss_mirror.c +@@ -68,12 +68,12 @@ static void nss_mirror_handler(struct ns + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_MIRROR_MSG_MAX) { +- nss_warning("%p: received invalid message %d for mirror interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for mirror interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_mirror_msg)) { +- nss_warning("%p: Length of message is greater than expected.", nss_ctx); ++ nss_warning("%px: Length of message is greater than expected.", nss_ctx); + return; + } + +@@ -96,7 +96,7 @@ static void nss_mirror_handler(struct ns + * Update the callback and app_data for NOTIFY messages. + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_top_main.if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)app_data; + } + +@@ -110,7 +110,7 @@ static void nss_mirror_handler(struct ns + * Call mirror interface callback. + */ + if (!cb) { +- nss_warning("%p: No callback for mirror interface %d", ++ nss_warning("%px: No callback for mirror interface %d", + nss_ctx, ncm->interface); + return; + } +@@ -150,12 +150,12 @@ nss_tx_status_t nss_mirror_tx_msg(struct + * Sanity check the message. + */ + if (!nss_mirror_verify_if_num(ncm->interface)) { +- nss_warning("%p: tx request for non mirror interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for non mirror interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_MIRROR_MSG_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -183,14 +183,14 @@ nss_tx_status_t nss_mirror_tx_msg_sync(s + + status = nss_mirror_tx_msg(nss_ctx, msg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: mirror_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: mirror_tx_msg failed\n", nss_ctx); + up(&nss_mirror_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&nss_mirror_pvt.complete, msecs_to_jiffies(NSS_MIRROR_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: Mirror interface tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: Mirror interface tx sync failed due to timeout\n", nss_ctx); + nss_mirror_pvt.response = NSS_TX_FAILURE; + } + +@@ -207,16 +207,20 @@ EXPORT_SYMBOL(nss_mirror_tx_msg_sync); + void nss_mirror_unregister_if(uint32_t if_num) + { + struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.mirror_handler_id]; ++ uint32_t status; + + nss_assert(nss_ctx); + nss_assert(nss_mirror_verify_if_num(if_num)); + + nss_core_unregister_subsys_dp(nss_ctx, if_num); + +- nss_top_main.if_rx_msg_callback[if_num] = NULL; +- + nss_core_unregister_handler(nss_ctx, if_num); + ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to unregister handler for interface %d with NSS core\n", nss_ctx, if_num); ++ } ++ + atomic_dec(&nss_mirror_num_instances); + nss_mirror_stats_reset(if_num); + } +@@ -239,23 +243,27 @@ struct nss_ctx_instance *nss_mirror_regi + nss_assert(nss_mirror_verify_if_num(if_num)); + + if (atomic_read(&nss_mirror_num_instances) == NSS_MAX_MIRROR_DYNAMIC_INTERFACES) { +- nss_warning("%p: Maximum number of mirror interfaces are already allocated\n", nss_ctx); ++ nss_warning("%px: Maximum number of mirror interfaces are already allocated\n", nss_ctx); + return NULL; + } + + ret = nss_mirror_stats_init(if_num, netdev); + if (ret < 0) { +- nss_warning("%p: Error in initializaing mirror stats.\n", nss_ctx); ++ nss_warning("%px: Error in initializaing mirror stats.\n", nss_ctx); ++ return NULL; ++ } ++ ++ nss_core_register_handler(nss_ctx, if_num, nss_mirror_handler, netdev); ++ ret = nss_core_register_msg_handler(nss_ctx, if_num, event_callback); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_core_unregister_handler(nss_ctx, if_num); ++ nss_warning("%px: Not able to register handler for mirror interface %d with NSS core\n", nss_ctx, if_num); + return NULL; + } + + nss_core_register_subsys_dp(nss_ctx, if_num, data_callback, NULL, NULL, netdev, features); + nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, NSS_DYNAMIC_INTERFACE_TYPE_MIRROR); + +- nss_top_main.if_rx_msg_callback[if_num] = event_callback; +- +- nss_core_register_handler(nss_ctx, if_num, nss_mirror_handler, netdev); +- + atomic_inc(&nss_mirror_num_instances); + return nss_ctx; + } +--- a/nss_mirror_log.c ++++ b/nss_mirror_log.c +@@ -62,7 +62,7 @@ static void nss_mirror_log_configure_msg + { + struct nss_mirror_configure_msg *config_msg __maybe_unused = &nmm->msg.config; + +- nss_trace("%p: NSS Mirror Config message \n" ++ nss_trace("%px: NSS Mirror Config message \n" + "Packet clone size: %u\n" + "Packet clone point: %hu\n", + config_msg, +@@ -78,7 +78,7 @@ static void nss_mirror_log_set_nexthop_m + { + struct nss_mirror_set_nexthop_msg *nexthop_msg __maybe_unused = &nmm->msg.nexthop; + +- nss_trace("%p: NSS Mirror Nexthop message \n" ++ nss_trace("%px: NSS Mirror Nexthop message \n" + "Nexthop interface number: %u\n", + nexthop_msg, + nexthop_msg->if_num); +@@ -90,7 +90,7 @@ static void nss_mirror_log_set_nexthop_m + */ + static void nss_mirror_log_enable_msg(struct nss_mirror_msg *nmm) + { +- nss_trace("%p: NSS Mirror message: Enable \n", nmm); ++ nss_trace("%px: NSS Mirror message: Enable \n", nmm); + } + + /* +@@ -99,7 +99,7 @@ static void nss_mirror_log_enable_msg(st + */ + static void nss_mirror_log_disable_msg(struct nss_mirror_msg *nmm) + { +- nss_trace("%p: NSS Mirror message: Disable \n", nmm); ++ nss_trace("%px: NSS Mirror message: Disable \n", nmm); + } + + /* +@@ -108,7 +108,7 @@ static void nss_mirror_log_disable_msg(s + */ + static void nss_mirror_log_reset_nexthop_msg(struct nss_mirror_msg *nmm) + { +- nss_trace("%p: NSS Mirror message: Reset Nexthop \n", nmm); ++ nss_trace("%px: NSS Mirror message: Reset Nexthop \n", nmm); + } + + /* +@@ -142,7 +142,7 @@ static void nss_mirror_log_verbose(struc + break; + + default: +- nss_trace("%p: Invalid message type\n", nmm); ++ nss_trace("%px: Invalid message type\n", nmm); + break; + } + } +@@ -154,11 +154,11 @@ static void nss_mirror_log_verbose(struc + void nss_mirror_log_tx_msg(struct nss_mirror_msg *nmm) + { + if (nmm->cm.type >= NSS_MIRROR_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", nmm); ++ nss_warning("%px: Invalid message type\n", nmm); + return; + } + +- nss_info("%p: type[%d]:%s\n", nmm, nmm->cm.type, nss_mirror_log_message_types_str[nmm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nmm, nmm->cm.type, nss_mirror_log_message_types_str[nmm->cm.type]); + nss_mirror_log_verbose(nmm); + } + +@@ -169,26 +169,26 @@ void nss_mirror_log_tx_msg(struct nss_mi + void nss_mirror_log_rx_msg(struct nss_mirror_msg *nmm) + { + if (nmm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nmm); ++ nss_warning("%px: Invalid response\n", nmm); + return; + } + + if (nmm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nmm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nmm, nmm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nmm, nmm->cm.type, + nss_mirror_log_message_types_str[nmm->cm.type], + nmm->cm.response, nss_cmn_response_str[nmm->cm.response]); + goto verbose; + } + + if (nmm->cm.error >= NSS_MIRROR_ERROR_TYPE_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + nmm, nmm->cm.type, nss_mirror_log_message_types_str[nmm->cm.type], + nmm->cm.response, nss_cmn_response_str[nmm->cm.response], + nmm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + nmm, nmm->cm.type, nss_mirror_log_message_types_str[nmm->cm.type], + nmm->cm.response, nss_cmn_response_str[nmm->cm.response], + nmm->cm.error, nss_mirror_log_error_response_types_str[nmm->cm.error]); +--- a/nss_n2h.c ++++ b/nss_n2h.c +@@ -74,7 +74,7 @@ static void nss_n2h_interface_handler(st + * Is this a valid request/response packet? + */ + if (nnm->cm.type >= NSS_METADATA_TYPE_N2H_MAX) { +- nss_warning("%p: received invalid message %d for Offload stats interface", nss_ctx, nnm->cm.type); ++ nss_warning("%px: received invalid message %d for Offload stats interface", nss_ctx, nnm->cm.type); + return; + } + +@@ -88,11 +88,11 @@ static void nss_n2h_interface_handler(st + break; + + case NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG: +- nss_info("%p: empty pool buf cfg response from FW", nss_ctx); ++ nss_info("%px: empty pool buf cfg response from FW", nss_ctx); + break; + + case NSS_TX_METADATA_TYPE_N2H_FLUSH_PAYLOADS: +- nss_info("%p: flush payloads cmd response from FW", nss_ctx); ++ nss_info("%px: flush payloads cmd response from FW", nss_ctx); + break; + + case NSS_RX_METADATA_TYPE_N2H_STATS_SYNC: +@@ -108,7 +108,7 @@ static void nss_n2h_interface_handler(st + /* + * Check response + */ +- nss_info("%p: Received response %d for type %d, interface %d", ++ nss_info("%px: Received response %d for type %d, interface %d", + nss_ctx, ncm->response, ncm->type, ncm->interface); + } + } +@@ -252,12 +252,12 @@ static void nss_n2h_set_wifi_payloads_ca + + nss_n2h_wp.response = NSS_FAILURE; + complete(&nss_n2h_wp.complete); +- nss_warning("%p: wifi pool configuration failed : %d\n", nss_ctx, ++ nss_warning("%px: wifi pool configuration failed : %d\n", nss_ctx, + nnm->cm.error); + return; + } + +- nss_info("%p: wifi payload configuration succeeded: %d\n", nss_ctx, ++ nss_info("%px: wifi payload configuration succeeded: %d\n", nss_ctx, + nnm->cm.error); + nss_n2h_wp.response = NSS_SUCCESS; + nss_n2h_wp.wifi_pool = ntohl(nnm->msg.wp.payloads); +@@ -282,7 +282,7 @@ static int nss_n2h_get_payload_info(nss_ + nss_tx_status = nss_n2h_tx_msg(nss_ctx, nnm); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: core %d nss_tx error errorn", nss_ctx, (int)core_num); ++ nss_warning("%px: core %d nss_tx error errorn", nss_ctx, (int)core_num); + return NSS_FAILURE; + } + +@@ -292,12 +292,12 @@ static int nss_n2h_get_payload_info(nss_ + ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, + msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: core %d waiting for ack timed out\n", nss_ctx, (int)core_num); ++ nss_warning("%px: core %d waiting for ack timed out\n", nss_ctx, (int)core_num); + return NSS_FAILURE; + } + + if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) { +- nss_warning("%p: core %d response returned failure\n", nss_ctx, (int)core_num); ++ nss_warning("%px: core %d response returned failure\n", nss_ctx, (int)core_num); + return NSS_FAILURE; + } + +@@ -387,12 +387,12 @@ static int nss_n2h_set_empty_buf_pool(st + } + + if ((*new_val < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { +- nss_warning("%p: core %d setting %d < min number of buffer", ++ nss_warning("%px: core %d setting %d < min number of buffer", + nss_ctx, (int)core_num, *new_val); + goto failure; + } + +- nss_info("%p: core %d number of empty pool buffer is : %d\n", ++ nss_info("%px: core %d number of empty pool buffer is : %d\n", + nss_ctx, (int)core_num, *new_val); + + nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, +@@ -406,7 +406,7 @@ static int nss_n2h_set_empty_buf_pool(st + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: core %d nss_tx error empty pool buffer: %d\n", ++ nss_warning("%px: core %d nss_tx error empty pool buffer: %d\n", + nss_ctx, (int)core_num, *new_val); + goto failure; + } +@@ -417,7 +417,7 @@ static int nss_n2h_set_empty_buf_pool(st + ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, + msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num); ++ nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num); + goto failure; + } + +@@ -489,12 +489,12 @@ static int nss_n2h_set_empty_paged_pool_ + } + + if ((*new_val < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { +- nss_warning("%p: core %d setting %d < min number of buffer", ++ nss_warning("%px: core %d setting %d < min number of buffer", + nss_ctx, (int)core_num, *new_val); + goto failure; + } + +- nss_info("%p: core %d number of empty paged pool buffer is : %d\n", ++ nss_info("%px: core %d number of empty paged pool buffer is : %d\n", + nss_ctx, (int)core_num, *new_val); + + nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, +@@ -508,7 +508,7 @@ static int nss_n2h_set_empty_paged_pool_ + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: core %d nss_tx error empty paged pool buffer: %d\n", ++ nss_warning("%px: core %d nss_tx error empty paged pool buffer: %d\n", + nss_ctx, (int)core_num, *new_val); + goto failure; + } +@@ -519,7 +519,7 @@ static int nss_n2h_set_empty_paged_pool_ + ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, + msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num); ++ nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num); + goto failure; + } + +@@ -590,25 +590,25 @@ static int nss_n2h_set_water_mark(struct + + if ((*low < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) || + (*high < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { +- nss_warning("%p: core %d setting %d, %d < min number of buffer", ++ nss_warning("%px: core %d setting %d, %d < min number of buffer", + nss_ctx, core_num, *low, *high); + goto failure; + } + + if ((*low > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ) || + (*high > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) { +- nss_warning("%p: core %d setting %d, %d is > upper limit", ++ nss_warning("%px: core %d setting %d, %d is > upper limit", + nss_ctx, core_num, *low, *high); + goto failure; + } + + if (*low > *high) { +- nss_warning("%p: core %d setting low %d is more than high %d", ++ nss_warning("%px: core %d setting low %d is more than high %d", + nss_ctx, core_num, *low, *high); + goto failure; + } + +- nss_info("%p: core %d number of low : %d and high : %d\n", ++ nss_info("%px: core %d number of low : %d and high : %d\n", + nss_ctx, core_num, *low, *high); + + nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, +@@ -623,7 +623,7 @@ static int nss_n2h_set_water_mark(struct + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: core %d nss_tx error setting : %d, %d\n", ++ nss_warning("%px: core %d nss_tx error setting : %d, %d\n", + nss_ctx, core_num, *low, *high); + goto failure; + } +@@ -634,7 +634,7 @@ static int nss_n2h_set_water_mark(struct + ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, + msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx, ++ nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx, + core_num); + goto failure; + } +@@ -704,25 +704,25 @@ static int nss_n2h_set_paged_water_mark( + + if ((*low < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) || + (*high < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { +- nss_warning("%p: core %d setting %d, %d < min number of buffer", ++ nss_warning("%px: core %d setting %d, %d < min number of buffer", + nss_ctx, core_num, *low, *high); + goto failure; + } + + if ((*low > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ) || + (*high > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) { +- nss_warning("%p: core %d setting %d, %d is > upper limit", ++ nss_warning("%px: core %d setting %d, %d is > upper limit", + nss_ctx, core_num, *low, *high); + goto failure; + } + + if (*low > *high) { +- nss_warning("%p: core %d setting low %d is more than high %d", ++ nss_warning("%px: core %d setting low %d is more than high %d", + nss_ctx, core_num, *low, *high); + goto failure; + } + +- nss_info("%p: core %d number of low : %d and high : %d\n", ++ nss_info("%px: core %d number of low : %d and high : %d\n", + nss_ctx, core_num, *low, *high); + + nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, +@@ -737,7 +737,7 @@ static int nss_n2h_set_paged_water_mark( + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: core %d nss_tx error setting : %d, %d\n", ++ nss_warning("%px: core %d nss_tx error setting : %d, %d\n", + nss_ctx, core_num, *low, *high); + goto failure; + } +@@ -748,7 +748,7 @@ static int nss_n2h_set_paged_water_mark( + ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete, + msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx, ++ nss_warning("%px: core %d Waiting for ack timed out\n", nss_ctx, + core_num); + goto failure; + } +@@ -815,18 +815,18 @@ static int nss_n2h_cfg_wifi_pool(struct + goto failure; + + if ((*payloads < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) { +- nss_warning("%p: wifi setting %d < min number of buffer", ++ nss_warning("%px: wifi setting %d < min number of buffer", + nss_ctx, *payloads); + goto failure; + } + + if ((*payloads > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ)) { +- nss_warning("%p: wifi setting %d > max number of buffer", ++ nss_warning("%px: wifi setting %d > max number of buffer", + nss_ctx, *payloads); + goto failure; + } + +- nss_info("%p: wifi payloads : %d\n", ++ nss_info("%px: wifi payloads : %d\n", + nss_ctx, *payloads); + + nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, +@@ -840,7 +840,7 @@ static int nss_n2h_cfg_wifi_pool(struct + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: wifi setting %d nss_tx error", ++ nss_warning("%px: wifi setting %d nss_tx error", + nss_ctx, *payloads); + goto failure; + } +@@ -851,7 +851,7 @@ static int nss_n2h_cfg_wifi_pool(struct + ret = wait_for_completion_timeout(&nss_n2h_wp.complete, + msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: Waiting for ack timed out\n", nss_ctx); ++ nss_warning("%px: Waiting for ack timed out\n", nss_ctx); + goto failure; + } + +@@ -1039,7 +1039,7 @@ nss_tx_status_t nss_n2h_update_queue_con + + status = nss_n2h_tx_msg(nss_ctx, &nnm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_tx error to send pnode queue config\n", nss_ctx); ++ nss_warning("%px: nss_tx error to send pnode queue config\n", nss_ctx); + return status; + } + +@@ -1092,14 +1092,14 @@ nss_tx_status_t nss_n2h_update_queue_con + status = nss_n2h_tx_msg(nss_ctx, &nnm); + + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: n2h_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: n2h_tx_msg failed\n", nss_ctx); + up(&nss_n2h_q_cfg_pvt.sem); + return status; + } + ret = wait_for_completion_timeout(&nss_n2h_q_cfg_pvt.complete, msecs_to_jiffies(NSS_N2H_TX_TIMEOUT)); + + if (!ret) { +- nss_warning("%p: Timeout expired for pnode queue config sync message\n", nss_ctx); ++ nss_warning("%px: Timeout expired for pnode queue config sync message\n", nss_ctx); + nss_n2h_q_cfg_pvt.response = NSS_TX_FAILURE; + } + +@@ -1134,7 +1134,7 @@ static nss_tx_status_t nss_n2h_mitigatio + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_tx error setting mitigation\n", nss_ctx); ++ nss_warning("%px: nss_tx error setting mitigation\n", nss_ctx); + goto failure; + } + +@@ -1143,7 +1143,7 @@ static nss_tx_status_t nss_n2h_mitigatio + */ + ret = wait_for_completion_timeout(&nss_n2h_mitigationcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: Waiting for ack timed out\n", nss_ctx); ++ nss_warning("%px: Waiting for ack timed out\n", nss_ctx); + goto failure; + } + +@@ -1215,7 +1215,7 @@ static nss_tx_status_t nss_n2h_buf_pool_ + if (nss_tx_status != NSS_TX_SUCCESS) { + + nss_n2h_buf_pool_free(buf_pool); +- nss_warning("%p: nss_tx error setting pbuf\n", nss_ctx); ++ nss_warning("%px: nss_tx error setting pbuf\n", nss_ctx); + goto failure; + } + +@@ -1224,7 +1224,7 @@ static nss_tx_status_t nss_n2h_buf_pool_ + */ + ret = wait_for_completion_timeout(&nss_n2h_bufcp[core_num].complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: Waiting for ack timed out\n", nss_ctx); ++ nss_warning("%px: Waiting for ack timed out\n", nss_ctx); + goto failure; + } + +@@ -1246,7 +1246,6 @@ failure: + return NSS_FAILURE; + } + +- + /* + * nss_mitigation_handler() + * Enable NSS MITIGATION +@@ -1432,7 +1431,7 @@ static int nss_n2h_set_queue_limit_sync( + * We dont allow shortening of the queue size at run-time + */ + if (nss_n2h_queue_limit[core_id] < current_val) { +- nss_warning("%p: New queue limit %d less than previous value %d. Cant allow shortening\n", ++ nss_warning("%px: New queue limit %d less than previous value %d. Cant allow shortening\n", + nss_ctx, nss_n2h_queue_limit[core_id], current_val); + nss_n2h_queue_limit[core_id] = current_val; + return NSS_TX_FAILURE; +@@ -1453,7 +1452,7 @@ static int nss_n2h_set_queue_limit_sync( + + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nim); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: n2h queue limit message send failed\n", nss_ctx); ++ nss_warning("%px: n2h queue limit message send failed\n", nss_ctx); + nss_n2h_queue_limit[core_id] = current_val; + up(&nss_n2h_q_lim_pvt.sem); + return nss_tx_status; +@@ -1461,7 +1460,7 @@ static int nss_n2h_set_queue_limit_sync( + + ret = wait_for_completion_timeout(&nss_n2h_q_lim_pvt.complete, msecs_to_jiffies(NSS_N2H_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: Timeout expired for queue limit sync message\n", nss_ctx); ++ nss_warning("%px: Timeout expired for queue limit sync message\n", nss_ctx); + nss_n2h_queue_limit[core_id] = current_val; + up(&nss_n2h_q_lim_pvt.sem); + return NSS_TX_FAILURE; +@@ -1512,11 +1511,11 @@ static void nss_n2h_host_bp_cfg_callback + if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { + nss_n2h_host_bp_cfg_pvt.response = NSS_FAILURE; + complete(&nss_n2h_host_bp_cfg_pvt.complete); +- nss_warning("%p: n2h back pressure configuration failed : %d\n", nss_ctx, nnm->cm.error); ++ nss_warning("%px: n2h back pressure configuration failed : %d\n", nss_ctx, nnm->cm.error); + return; + } + +- nss_info("%p: n2h back pressure configuration succeeded: %d\n", nss_ctx, nnm->cm.error); ++ nss_info("%px: n2h back pressure configuration succeeded: %d\n", nss_ctx, nnm->cm.error); + nss_n2h_host_bp_cfg_pvt.response = NSS_SUCCESS; + complete(&nss_n2h_host_bp_cfg_pvt.complete); + } +@@ -1541,7 +1540,7 @@ static nss_tx_status_t nss_n2h_host_bp_c + + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_tx error setting back pressure\n", nss_ctx); ++ nss_warning("%px: nss_tx error setting back pressure\n", nss_ctx); + up(&nss_n2h_host_bp_cfg_pvt.sem); + return NSS_FAILURE; + } +@@ -1551,7 +1550,7 @@ static nss_tx_status_t nss_n2h_host_bp_c + */ + ret = wait_for_completion_timeout(&nss_n2h_host_bp_cfg_pvt.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: Waiting for ack timed out\n", nss_ctx); ++ nss_warning("%px: Waiting for ack timed out\n", nss_ctx); + up(&nss_n2h_host_bp_cfg_pvt.sem); + return NSS_FAILURE; + } +@@ -1599,7 +1598,7 @@ static int nss_n2h_host_bp_cfg_handler(s + ret_bp = nss_n2h_host_bp_cfg_sync(nss_ctx, nss_n2h_host_bp_config[core_id]); + + if (ret_bp != NSS_SUCCESS) { +- nss_warning("%p: n2h back pressure config failed\n", nss_ctx); ++ nss_warning("%px: n2h back pressure config failed\n", nss_ctx); + nss_n2h_host_bp_config[core_id] = current_state; + } + +@@ -1903,18 +1902,18 @@ nss_tx_status_t nss_n2h_cfg_empty_pool_s + nss_tx_status_t nss_tx_status; + + if (pool_sz < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ) { +- nss_warning("%p: setting pool size %d < min number of buffer", ++ nss_warning("%px: setting pool size %d < min number of buffer", + nss_ctx, pool_sz); + return NSS_TX_FAILURE; + } + + if (pool_sz > NSS_N2H_MAX_EMPTY_POOL_BUF_SZ) { +- nss_warning("%p: setting pool size %d > max number of buffer", ++ nss_warning("%px: setting pool size %d > max number of buffer", + nss_ctx, pool_sz); + return NSS_TX_FAILURE; + } + +- nss_info("%p: update number of empty buffer pool size: %d\n", ++ nss_info("%px: update number of empty buffer pool size: %d\n", + nss_ctx, pool_sz); + + nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, +@@ -1926,7 +1925,7 @@ nss_tx_status_t nss_n2h_cfg_empty_pool_s + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_tx error empty buffer pool: %d\n", nss_ctx, pool_sz); ++ nss_warning("%px: nss_tx error empty buffer pool: %d\n", nss_ctx, pool_sz); + return nss_tx_status; + } + +@@ -1953,7 +1952,7 @@ nss_tx_status_t nss_n2h_paged_buf_pool_i + + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: failed to send paged buf configuration init command to NSS\n", ++ nss_warning("%px: failed to send paged buf configuration init command to NSS\n", + nss_ctx); + return NSS_TX_FAILURE; + } +@@ -1986,7 +1985,7 @@ nss_tx_status_t nss_n2h_flush_payloads(s + + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: failed to send flush payloads command to NSS\n", ++ nss_warning("%px: failed to send flush payloads command to NSS\n", + nss_ctx); + + return NSS_TX_FAILURE; +@@ -2017,12 +2016,12 @@ nss_tx_status_t nss_n2h_tx_msg(struct ns + * Sanity check the message + */ + if (ncm->interface != NSS_N2H_INTERFACE) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_METADATA_TYPE_N2H_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +--- a/nss_oam.c ++++ b/nss_oam.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016-2018, 2020 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. +@@ -45,12 +45,12 @@ static void nss_oam_rx_msg_handler(struc + * Sanity check the message type + */ + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_oam_msg)) { +- nss_warning("%p: recevied with invalid msg size: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: recevied with invalid msg size: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + + if (ncm->type > NSS_OAM_MSG_TYPE_MAX) { +- nss_warning("%p: received with invalid resp type: %d", nss_ctx, ncm->type); ++ nss_warning("%px: received with invalid resp type: %d", nss_ctx, ncm->type); + return; + } + +@@ -66,7 +66,7 @@ static void nss_oam_rx_msg_handler(struc + + cb = (nss_oam_msg_callback_t)ncm->cb; + if (unlikely(!cb)) { +- nss_trace("%p: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); ++ nss_trace("%px: rx handler has been unregistered for i/f: %d", nss_ctx, ncm->interface); + return; + } + cb((void *)ncm->app_data, nom); +@@ -86,12 +86,12 @@ nss_tx_status_t nss_oam_tx_msg(struct ns + nss_oam_log_tx_msg(nom); + + if (ncm->type > NSS_OAM_MSG_TYPE_MAX) { +- nss_warning("%p: CMD type for oam module is invalid - %d", nss_ctx, ncm->type); ++ nss_warning("%px: CMD type for oam module is invalid - %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE_BAD_PARAM; + } + + if (ncm->interface != NSS_OAM_INTERFACE) { +- nss_warning("%p: tx message request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx message request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + +--- a/nss_oam_log.c ++++ b/nss_oam_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -37,8 +37,8 @@ static int8_t *nss_oam_log_message_types + static void nss_oam_log_get_fw_version_msg(struct nss_oam_msg *nom) + { + struct nss_oam_fw_ver *nofm __maybe_unused = &nom->msg.fw_ver; +- nss_trace("%p: NSS OAM Get FW Version message \n" +- "OAM FW Version: %p\n", ++ nss_trace("%px: NSS OAM Get FW Version message \n" ++ "OAM FW Version: %px\n", + nofm, nofm->string); + } + +@@ -54,7 +54,7 @@ static void nss_oam_log_verbose(struct n + break; + + default: +- nss_trace("%p: Invalid message type\n", nom); ++ nss_trace("%px: Invalid message type\n", nom); + break; + } + } +@@ -66,11 +66,11 @@ static void nss_oam_log_verbose(struct n + void nss_oam_log_tx_msg(struct nss_oam_msg *nom) + { + if (nom->cm.type >= NSS_OAM_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", nom); ++ nss_warning("%px: Invalid message type\n", nom); + return; + } + +- nss_info("%p: type[%d]:%s\n", nom, nom->cm.type, nss_oam_log_message_types_str[nom->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nom, nom->cm.type, nss_oam_log_message_types_str[nom->cm.type]); + nss_oam_log_verbose(nom); + } + +@@ -81,18 +81,18 @@ void nss_oam_log_tx_msg(struct nss_oam_m + void nss_oam_log_rx_msg(struct nss_oam_msg *nom) + { + if (nom->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nom); ++ nss_warning("%px: Invalid response\n", nom); + return; + } + + if (nom->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nom->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nom, nom->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nom, nom->cm.type, + nss_oam_log_message_types_str[nom->cm.type], + nom->cm.response, nss_cmn_response_str[nom->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + nom, nom->cm.type, nss_oam_log_message_types_str[nom->cm.type], + nom->cm.response, nss_cmn_response_str[nom->cm.response]); + +--- a/nss_phys_if.c ++++ b/nss_phys_if.c +@@ -77,17 +77,17 @@ static void nss_phys_if_msg_handler(stru + * Sanity check the message type + */ + if (ncm->type > NSS_PHYS_IF_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return; + } + + if (!NSS_IS_IF_TYPE(PHYSICAL, ncm->interface)) { +- nss_warning("%p: response for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: response for another interface: %d", nss_ctx, ncm->interface); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_phys_if_msg)) { +- nss_warning("%p: message length too big: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: message length too big: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -162,7 +162,7 @@ static void nss_phys_if_callback(void *a + */ + nss_tx_status_t nss_phys_if_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num) + { +- nss_trace("%p: Phys If Tx packet, id:%d, data=%p", nss_ctx, if_num, os_buf->data); ++ nss_trace("%px: Phys If Tx packet, id:%d, data=%px", nss_ctx, if_num, os_buf->data); + + #ifdef NSS_DRV_TSTAMP_ENABLE + /* +@@ -196,18 +196,18 @@ nss_tx_status_t nss_phys_if_msg(struct n + * Sanity check the message + */ + if (!NSS_IS_IF_TYPE(PHYSICAL, ncm->interface)) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_PHYS_IF_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + + dev = nss_ctx->subsys_dp_register[ncm->interface].ndev; + if (!dev) { +- nss_warning("%p: Unregister physical interface %d: no context", nss_ctx, ncm->interface); ++ nss_warning("%px: Unregister physical interface %d: no context", nss_ctx, ncm->interface); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -228,7 +228,7 @@ nss_tx_status_t nss_phys_if_msg_sync(str + status = nss_phys_if_msg(nss_ctx, nim); + if(status != NSS_TX_SUCCESS) + { +- nss_warning("%p: nss_phys_if_msg failed\n", nss_ctx); ++ nss_warning("%px: nss_phys_if_msg failed\n", nss_ctx); + up(&phif.sem); + return status; + } +@@ -237,7 +237,7 @@ nss_tx_status_t nss_phys_if_msg_sync(str + + if(!ret) + { +- nss_warning("%p: phys_if tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: phys_if tx failed due to timeout\n", nss_ctx); + phif.response = NSS_TX_FAILURE; + } + +@@ -326,7 +326,7 @@ nss_tx_status_t nss_phys_if_open(struct + struct nss_if_open *nio; + + NSS_VERIFY_CTX_MAGIC(nss_ctx); +- nss_info("%p: Phys If Open, id:%d, TxDesc: %x, RxDesc: %x\n", nss_ctx, if_num, tx_desc_ring, rx_desc_ring); ++ nss_info("%px: Phys If Open, id:%d, TxDesc: %x, RxDesc: %x\n", nss_ctx, if_num, tx_desc_ring, rx_desc_ring); + + nss_cmn_msg_init(&nim.cm, if_num, NSS_PHYS_IF_OPEN, + sizeof(struct nss_if_open), nss_phys_if_callback, NULL); +@@ -345,7 +345,7 @@ nss_tx_status_t nss_phys_if_open(struct + nio->rx_forward_if = NSS_PORTID_INTERFACE; + nio->alignment_mode = NSS_IF_DATA_ALIGN_2BYTE; + } else { +- nss_info("%p: Phys If Open, unknown mode %d\n", nss_ctx, mode); ++ nss_info("%px: Phys If Open, unknown mode %d\n", nss_ctx, mode); + return NSS_TX_FAILURE; + } + +@@ -370,7 +370,7 @@ nss_tx_status_t nss_phys_if_close(struct + struct nss_phys_if_msg nim; + + NSS_VERIFY_CTX_MAGIC(nss_ctx); +- nss_info("%p: Phys If Close, id:%d \n", nss_ctx, if_num); ++ nss_info("%px: Phys If Close, id:%d \n", nss_ctx, if_num); + + nss_cmn_msg_init(&nim.cm, if_num, NSS_PHYS_IF_CLOSE, + sizeof(struct nss_if_close), nss_phys_if_callback, NULL); +@@ -388,7 +388,7 @@ nss_tx_status_t nss_phys_if_link_state(s + struct nss_if_link_state_notify *nils; + + NSS_VERIFY_CTX_MAGIC(nss_ctx); +- nss_info("%p: Phys If Link State, id:%d, State: %x\n", nss_ctx, if_num, link_state); ++ nss_info("%px: Phys If Link State, id:%d, State: %x\n", nss_ctx, if_num, link_state); + + nss_cmn_msg_init(&nim.cm, if_num, NSS_PHYS_IF_LINK_STATE_NOTIFY, + sizeof(struct nss_if_link_state_notify), nss_phys_if_callback, NULL); +@@ -408,7 +408,7 @@ nss_tx_status_t nss_phys_if_mac_addr(str + struct nss_if_mac_address_set *nmas; + + NSS_VERIFY_CTX_MAGIC(nss_ctx); +- nss_info("%p: Phys If MAC Address, id:%d\n", nss_ctx, if_num); ++ nss_info("%px: Phys If MAC Address, id:%d\n", nss_ctx, if_num); + nss_assert(addr != 0); + + nss_cmn_msg_init(&nim.cm, if_num, NSS_PHYS_IF_MAC_ADDR_SET, +@@ -441,7 +441,7 @@ nss_tx_status_t nss_phys_if_change_mtu(s + } + #endif + NSS_VERIFY_CTX_MAGIC(nss_ctx); +- nss_info("%p: Phys If Change MTU, id:%d, mtu=%d\n", nss_ctx, if_num, mtu); ++ nss_info("%px: Phys If Change MTU, id:%d, mtu=%d\n", nss_ctx, if_num, mtu); + + nss_cmn_msg_init(&nim.cm, if_num, NSS_PHYS_IF_MTU_CHANGE, + sizeof(struct nss_if_mtu_change), nss_phys_if_callback, NULL); +@@ -491,7 +491,6 @@ nss_tx_status_t nss_phys_if_change_mtu(s + nss_ctx->max_buf_size = NSS_EMPTY_BUFFER_SIZE; + #endif + +- + #if (NSS_SKB_REUSE_SUPPORT == 1) + if (nss_ctx->max_buf_size > nss_core_get_max_reuse()) + nss_core_set_max_reuse(ALIGN(nss_ctx->max_buf_size * 2, PAGE_SIZE)); +@@ -524,7 +523,7 @@ nss_tx_status_t nss_phys_if_vsi_assign(s + struct nss_phys_if_msg nim; + + NSS_VERIFY_CTX_MAGIC(nss_ctx); +- nss_info("%p: Phys If VSI Assign, id:%d\n", nss_ctx, if_num); ++ nss_info("%px: Phys If VSI Assign, id:%d\n", nss_ctx, if_num); + + memset(&nim, 0, sizeof(struct nss_phys_if_msg)); + +@@ -544,7 +543,7 @@ nss_tx_status_t nss_phys_if_vsi_unassign + struct nss_phys_if_msg nim; + + NSS_VERIFY_CTX_MAGIC(nss_ctx); +- nss_info("%p: Phys If VSI Unassign, id:%d\n", nss_ctx, if_num); ++ nss_info("%px: Phys If VSI Unassign, id:%d\n", nss_ctx, if_num); + + memset(&nim, 0, sizeof(struct nss_phys_if_msg)); + +@@ -565,7 +564,7 @@ nss_tx_status_t nss_phys_if_pause_on_off + struct nss_if_pause_on_off *nipe; + + NSS_VERIFY_CTX_MAGIC(nss_ctx); +- nss_info("%p: phys if pause is set to %d, id:%d\n", nss_ctx, pause_on, if_num); ++ nss_info("%px: phys if pause is set to %d, id:%d\n", nss_ctx, pause_on, if_num); + + nss_cmn_msg_init(&nim.cm, if_num, NSS_PHYS_IF_PAUSE_ON_OFF, + sizeof(struct nss_if_pause_on_off), nss_phys_if_callback, NULL); +@@ -577,6 +576,23 @@ nss_tx_status_t nss_phys_if_pause_on_off + } + + /* ++ * nss_phys_if_reset_nexthop() ++ * De-configures nexthop for an interface ++ */ ++nss_tx_status_t nss_phys_if_reset_nexthop(struct nss_ctx_instance *nss_ctx, uint32_t if_num) ++{ ++ struct nss_phys_if_msg nim; ++ ++ NSS_VERIFY_CTX_MAGIC(nss_ctx); ++ ++ nss_cmn_msg_init(&nim.cm, if_num, NSS_PHYS_IF_RESET_NEXTHOP, ++ 0, nss_phys_if_callback, NULL); ++ ++ return nss_phys_if_msg_sync(nss_ctx, &nim); ++} ++EXPORT_SYMBOL(nss_phys_if_reset_nexthop); ++ ++/* + * nss_phys_if_set_nexthop() + * Configures nexthop for an interface + */ +@@ -587,11 +603,11 @@ nss_tx_status_t nss_phys_if_set_nexthop( + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (nexthop >= NSS_MAX_NET_INTERFACES) { +- nss_warning("%p: Invalid nexthop interface number: %d", nss_ctx, nexthop); ++ nss_warning("%px: Invalid nexthop interface number: %d", nss_ctx, nexthop); + return NSS_TX_FAILURE_BAD_PARAM; + } + +- nss_info("%p: Phys If nexthop will be set to %d, id:%d\n", nss_ctx, nexthop, if_num); ++ nss_info("%px: Phys If nexthop will be set to %d, id:%d\n", nss_ctx, nexthop, if_num); + + nss_cmn_msg_init(&nim.cm, if_num, NSS_PHYS_IF_SET_NEXTHOP, + sizeof(struct nss_if_set_nexthop), nss_phys_if_callback, NULL); +--- a/nss_phys_if.h ++++ b/nss_phys_if.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014-2020, 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. +@@ -124,6 +124,7 @@ enum nss_phys_if_msg_types { + NSS_PHYS_IF_VSI_ASSIGN = NSS_IF_VSI_ASSIGN, + NSS_PHYS_IF_VSI_UNASSIGN = NSS_IF_VSI_UNASSIGN, + NSS_PHYS_IF_SET_NEXTHOP = NSS_IF_SET_NEXTHOP, ++ NSS_PHYS_IF_RESET_NEXTHOP = NSS_IF_RESET_NEXTHOP, + NSS_PHYS_IF_EXTENDED_STATS_SYNC = NSS_IF_MAX_MSG_TYPES + 1, + NSS_PHYS_IF_MAX_MSG_TYPES + }; +--- a/nss_portid.c ++++ b/nss_portid.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2015-2018, 2020, 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. +@@ -60,12 +60,12 @@ static void nss_portid_handler(struct ns + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_PORTID_MAX_MSG_TYPE) { +- nss_warning("%p: received invalid message %d for portid interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for portid interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_portid_msg)) { +- nss_warning("%p: message size incorrect: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: message size incorrect: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -88,7 +88,7 @@ static void nss_portid_handler(struct ns + * to the same callback/app_data. + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].ndev; + } + +@@ -184,12 +184,12 @@ nss_tx_status_t nss_portid_tx_msg(struct + * Sanity check the message + */ + if (ncm->interface != NSS_PORTID_INTERFACE) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_PORTID_MAX_MSG_TYPE) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -228,7 +228,7 @@ nss_tx_status_t nss_portid_tx_msg_sync(s + status = nss_portid_tx_msg(nss_ctx, msg); + if(status != NSS_TX_SUCCESS) + { +- nss_warning("%p: nss_phys_if_msg failed\n", nss_ctx); ++ nss_warning("%px: nss_phys_if_msg failed\n", nss_ctx); + up(&pid.sem); + return status; + } +@@ -237,7 +237,7 @@ nss_tx_status_t nss_portid_tx_msg_sync(s + + if(!ret) + { +- nss_warning("%p: portid tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: portid tx failed due to timeout\n", nss_ctx); + pid.response = NSS_TX_FAILURE; + } + +@@ -377,7 +377,7 @@ bool nss_portid_unregister_port_if(uint3 + + nss_ctx = nss_portid_get_ctx(); + if (nss_portid_verify_if_num(if_num) == false) { +- nss_warning("%p: unregister received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: unregister received for invalid interface %d", nss_ctx, if_num); + return false; + } + +--- a/nss_portid_log.c ++++ b/nss_portid_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -38,7 +38,7 @@ static int8_t *nss_portid_log_message_ty + static void nss_portid_log_configure_msg(struct nss_portid_msg *npm) + { + struct nss_portid_configure_msg *npcm __maybe_unused = &npm->msg.configure; +- nss_trace("%p: NSS PORTID Configure message \n" ++ nss_trace("%px: NSS PORTID Configure message \n" + "PORTID Interface Number: %d\n" + "PORTID Interface ID: %d\n" + "PORTID GMAC ID: %d\n", +@@ -53,7 +53,7 @@ static void nss_portid_log_configure_msg + static void nss_portid_log_unconfigure_msg(struct nss_portid_msg *npm) + { + struct nss_portid_unconfigure_msg *npum __maybe_unused = &npm->msg.unconfigure; +- nss_trace("%p: NSS PORTID Configure message \n" ++ nss_trace("%px: NSS PORTID Configure message \n" + "PORTID Interface Number: %d\n" + "PORTID Interface ID: %d\n", + npum, npum->port_if_num, +@@ -82,7 +82,7 @@ static void nss_portid_log_verbose(struc + break; + + default: +- nss_trace("%p: Invalid message type\n", npm); ++ nss_trace("%px: Invalid message type\n", npm); + break; + } + } +@@ -94,11 +94,11 @@ static void nss_portid_log_verbose(struc + void nss_portid_log_tx_msg(struct nss_portid_msg *npm) + { + if (npm->cm.type >= NSS_PORTID_MAX_MSG_TYPE) { +- nss_warning("%p: Invalid message type\n", npm); ++ nss_warning("%px: Invalid message type\n", npm); + return; + } + +- nss_info("%p: type[%d]:%s\n", npm, npm->cm.type, nss_portid_log_message_types_str[npm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", npm, npm->cm.type, nss_portid_log_message_types_str[npm->cm.type]); + nss_portid_log_verbose(npm); + } + +@@ -109,18 +109,18 @@ void nss_portid_log_tx_msg(struct nss_po + void nss_portid_log_rx_msg(struct nss_portid_msg *npm) + { + if (npm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", npm); ++ nss_warning("%px: Invalid response\n", npm); + return; + } + + if (npm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (npm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", npm, npm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", npm, npm->cm.type, + nss_portid_log_message_types_str[npm->cm.type], + npm->cm.response, nss_cmn_response_str[npm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + npm, npm->cm.type, nss_portid_log_message_types_str[npm->cm.type], + npm->cm.response, nss_cmn_response_str[npm->cm.response]); + +--- a/nss_portid_stats.c ++++ b/nss_portid_stats.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016-2017, 2019 The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016-2017, 2019-2020 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. +@@ -140,7 +140,7 @@ void nss_portid_stats_sync(struct nss_ct + spin_lock_bh(&nss_portid_spinlock); + hdl = &nss_portid_hdl[npsm->port_id]; + if (hdl->if_num == 0) { +- nss_warning("%p: nss_portid recv'd stats with unconfigured port %d", nss_ctx, npsm->port_id); ++ nss_warning("%px: nss_portid recv'd stats with unconfigured port %d", nss_ctx, npsm->port_id); + spin_unlock_bh(&nss_portid_spinlock); + return; + } +--- a/nss_ppe_log.c ++++ b/nss_ppe_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -57,7 +57,7 @@ static int8_t *nss_ppe_log_error_respons + static void nss_ppe_log_port_config_msg(struct nss_ppe_msg *npm) + { + struct nss_ppe_ipsec_port_config_msg *npcm __maybe_unused = &npm->msg.ipsec_config; +- nss_trace("%p: NSS PPE Port Configure Message:\n" ++ nss_trace("%px: NSS PPE Port Configure Message:\n" + "PPE NSS Interface Number: %d\n" + "PPE MTU: %d\n" + "PPE VSI Number: %d\n", +@@ -72,7 +72,7 @@ static void nss_ppe_log_port_config_msg( + static void nss_ppe_log_port_mtu_msg(struct nss_ppe_msg *npm) + { + struct nss_ppe_ipsec_port_mtu_msg *npmm __maybe_unused = &npm->msg.ipsec_mtu; +- nss_trace("%p: NSS PPE Port Configure Message:\n" ++ nss_trace("%px: NSS PPE Port Configure Message:\n" + "PPE NSS Interface Number: %d\n" + "PPE MTU: %d\n", + npmm, npmm->nss_ifnum, +@@ -86,7 +86,7 @@ static void nss_ppe_log_port_mtu_msg(str + static void nss_ppe_log_add_intf_msg(struct nss_ppe_msg *npm) + { + struct nss_ppe_ipsec_add_intf_msg *npam __maybe_unused = &npm->msg.ipsec_addif; +- nss_trace("%p: NSS PPE IPSEC add Interface Message:\n" ++ nss_trace("%px: NSS PPE IPSEC add Interface Message:\n" + "PPE NSS Interface Number: %d\n", + npam, npam->nss_ifnum); + } +@@ -98,7 +98,7 @@ static void nss_ppe_log_add_intf_msg(str + static void nss_ppe_log_del_intf_msg(struct nss_ppe_msg *npm) + { + struct nss_ppe_ipsec_del_intf_msg *npdm __maybe_unused = &npm->msg.ipsec_delif; +- nss_trace("%p: NSS PPE IPSEC Delete Interface Message:\n" ++ nss_trace("%px: NSS PPE IPSEC Delete Interface Message:\n" + "PPE NSS Interface Number: %d\n", + npdm, npdm->nss_ifnum); + } +@@ -133,7 +133,7 @@ static void nss_ppe_log_verbose(struct n + break; + + default: +- nss_warning("%p: Invalid message type\n", npm); ++ nss_warning("%px: Invalid message type\n", npm); + break; + } + } +@@ -145,11 +145,11 @@ static void nss_ppe_log_verbose(struct n + void nss_ppe_log_tx_msg(struct nss_ppe_msg *npm) + { + if (npm->cm.type >= NSS_PPE_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", npm); ++ nss_warning("%px: Invalid message type\n", npm); + return; + } + +- nss_info("%p: type[%d]:%s\n", npm, npm->cm.type, nss_ppe_log_message_types_str[npm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", npm, npm->cm.type, nss_ppe_log_message_types_str[npm->cm.type]); + nss_ppe_log_verbose(npm); + } + +@@ -160,26 +160,26 @@ void nss_ppe_log_tx_msg(struct nss_ppe_m + void nss_ppe_log_rx_msg(struct nss_ppe_msg *npm) + { + if (npm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", npm); ++ nss_warning("%px: Invalid response\n", npm); + return; + } + + if (npm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (npm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", npm, npm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", npm, npm->cm.type, + nss_ppe_log_message_types_str[npm->cm.type], + npm->cm.response, nss_cmn_response_str[npm->cm.response]); + goto verbose; + } + + if (npm->cm.error >= PPE_ERROR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + npm, npm->cm.type, nss_ppe_log_message_types_str[npm->cm.type], + npm->cm.response, nss_cmn_response_str[npm->cm.response], + npm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + npm, npm->cm.type, nss_ppe_log_message_types_str[npm->cm.type], + npm->cm.response, nss_cmn_response_str[npm->cm.response], + npm->cm.error, nss_ppe_log_error_response_types_str[npm->cm.error]); +--- a/nss_ppe_vp.c ++++ b/nss_ppe_vp.c +@@ -90,12 +90,12 @@ nss_tx_status_t nss_ppe_vp_tx_msg(struct + * Sanity check the message + */ + if (ncm->type >= NSS_PPE_VP_MSG_MAX) { +- nss_warning("%p: message type out of range: %d\n", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d\n", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + + if (!nss_ppe_vp_verify_ifnum(ncm->interface)) { +- nss_warning("%p: invalid interface %d\n", nss_ctx, ncm->interface); ++ nss_warning("%px: invalid interface %d\n", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + +@@ -117,14 +117,14 @@ nss_tx_status_t nss_ppe_vp_tx_msg_sync(s + + status = nss_ppe_vp_tx_msg(nss_ctx, npvm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: ppe_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: ppe_tx_msg failed\n", nss_ctx); + up(&ppe_vp_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&ppe_vp_pvt.complete, msecs_to_jiffies(NSS_PPE_VP_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: ppe_vp msg tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: ppe_vp msg tx failed due to timeout\n", nss_ctx); + ppe_vp_pvt.response = NSS_TX_FAILURE; + } + +@@ -145,13 +145,13 @@ nss_tx_status_t nss_ppe_vp_tx_config_msg + nss_tx_status_t status; + + if (type >= NSS_DYNAMIC_INTERFACE_TYPE_MAX) { +- nss_warning("%p: Dynamic if msg drooped as type is wrong:%d\n", nss_ctx, type); ++ nss_warning("%px: Dynamic if msg drooped as type is wrong:%d\n", nss_ctx, type); + return -1; + } + + npvm = kzalloc(sizeof(struct nss_ppe_vp_msg), GFP_KERNEL); + if (!npvm) { +- nss_warning("%p: Unable to allocate message\n", nss_ctx); ++ nss_warning("%px: Unable to allocate message\n", nss_ctx); + return -1; + } + +@@ -164,7 +164,7 @@ nss_tx_status_t nss_ppe_vp_tx_config_msg + + status = nss_ppe_vp_tx_msg_sync(nss_ctx, npvm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to send ppe_vp config message for type:%d\n", nss_ctx, type); ++ nss_warning("%px: Unable to send ppe_vp config message for type:%d\n", nss_ctx, type); + } + + kfree(npvm); +@@ -181,7 +181,7 @@ static void nss_ppe_vp_handler(struct ns + nss_ppe_vp_msg_callback_t cb; + void *ctx; + +- nss_trace("nss_ctx: %p ppe_vp msg: %p\n", nss_ctx, msg); ++ nss_trace("nss_ctx: %px ppe_vp msg: %px\n", nss_ctx, msg); + BUG_ON(!nss_ppe_vp_verify_ifnum(ncm->interface)); + + /* +@@ -193,12 +193,12 @@ static void nss_ppe_vp_handler(struct ns + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_PPE_VP_MSG_MAX) { +- nss_warning("%p: received invalid message %d for PPE_VP interface\n", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for PPE_VP interface\n", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ppe_vp_msg)) { +- nss_warning("%p: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -389,7 +389,7 @@ void nss_ppe_vp_register_handler(void) + + nss_ppe_vp_dentry = nss_ppe_vp_stats_dentry_create(); + if (nss_ppe_vp_dentry == NULL) { +- nss_warning("%p: Not able to create debugfs entry\n", nss_ctx); ++ nss_warning("%px: Not able to create debugfs entry\n", nss_ctx); + return; + } + +--- a/nss_ppe_vp_log.c ++++ b/nss_ppe_vp_log.c +@@ -49,7 +49,7 @@ static int8_t *nss_ppe_vp_log_error_resp + static void nss_ppe_vp_log_config_msg(struct nss_ppe_vp_msg *npvm) + { + struct nss_ppe_vp_config_msg *npcm __maybe_unused = &npvm->msg.vp_config; +- nss_trace("%p: NSS PPE VP configuration message:\n" ++ nss_trace("%px: NSS PPE VP configuration message:\n" + "Dynamic interface type: %d is_vp_support_enable: %d\n", + npcm, npcm->type, npcm->vp_enable); + } +@@ -72,7 +72,7 @@ static void nss_ppe_vp_log_verbose(struc + break; + + default: +- nss_warning("%p: Invalid message type\n", npvm); ++ nss_warning("%px: Invalid message type\n", npvm); + break; + } + } +@@ -84,11 +84,11 @@ static void nss_ppe_vp_log_verbose(struc + void nss_ppe_vp_log_tx_msg(struct nss_ppe_vp_msg *npvm) + { + if (npvm->cm.type >= NSS_PPE_VP_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", npvm); ++ nss_warning("%px: Invalid message type\n", npvm); + return; + } + +- nss_info("%p: type[%d]:%s\n", npvm, npvm->cm.type, nss_ppe_vp_log_message_types_str[npvm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", npvm, npvm->cm.type, nss_ppe_vp_log_message_types_str[npvm->cm.type]); + nss_ppe_vp_log_verbose(npvm); + } + +@@ -99,26 +99,26 @@ void nss_ppe_vp_log_tx_msg(struct nss_pp + void nss_ppe_vp_log_rx_msg(struct nss_ppe_vp_msg *npvm) + { + if (npvm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", npvm); ++ nss_warning("%px: Invalid response\n", npvm); + return; + } + + if (npvm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (npvm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", npvm, npvm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", npvm, npvm->cm.type, + nss_ppe_vp_log_message_types_str[npvm->cm.type], + npvm->cm.response, nss_cmn_response_str[npvm->cm.response]); + goto verbose; + } + + if (npvm->cm.error >= NSS_PPE_VP_MSG_ERROR_TYPE_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + npvm, npvm->cm.type, nss_ppe_vp_log_message_types_str[npvm->cm.type], + npvm->cm.response, nss_cmn_response_str[npvm->cm.response], + npvm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + npvm, npvm->cm.type, nss_ppe_vp_log_message_types_str[npvm->cm.type], + npvm->cm.response, nss_cmn_response_str[npvm->cm.response], + npvm->cm.error, nss_ppe_vp_log_error_response_types_str[npvm->cm.error]); +--- a/nss_pppoe.c ++++ b/nss_pppoe.c +@@ -80,13 +80,13 @@ static nss_tx_status_t nss_pppoe_tx_msg( + */ + type = nss_dynamic_interface_get_type(nss_pppoe_get_context(), ncm->interface); + if ((ncm->interface != NSS_PPPOE_INTERFACE) && (type != NSS_DYNAMIC_INTERFACE_TYPE_PPPOE)) { +- nss_warning("%p: tx request for not PPPoE interface: %d type: %d\n", ++ nss_warning("%px: tx request for not PPPoE interface: %d type: %d\n", + nss_ctx, ncm->interface, type); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_PPPOE_MSG_MAX) { +- nss_warning("%p: message type out of range: %d\n", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d\n", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -139,12 +139,12 @@ static void nss_pppoe_handler(struct nss + * Sanity check the message type + */ + if (ncm->type >= NSS_PPPOE_MSG_MAX) { +- nss_warning("%p: message type out of range: %d\n", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d\n", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_pppoe_msg)) { +- nss_warning("%p: message length is invalid: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: message length is invalid: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -165,7 +165,7 @@ static void nss_pppoe_handler(struct nss + nss_pppoe_stats_notify(nss_ctx, ncm->interface); + break; + default: +- nss_warning("%p: Received response %d for type %d, interface %d\n", ++ nss_warning("%px: Received response %d for type %d, interface %d\n", + nss_ctx, ncm->response, ncm->type, ncm->interface); + } + +@@ -227,7 +227,7 @@ int nss_pppoe_br_accel_mode_handler(stru + + new_val = nss_pppoe_br_accel_mode; + if ((new_val < NSS_PPPOE_BR_ACCEL_MODE_DIS) || (new_val >= NSS_PPPOE_BR_ACCEL_MODE_MAX)) { +- nss_warning("%p: value out of range: %d\n", nss_ctx, new_val); ++ nss_warning("%px: value out of range: %d\n", nss_ctx, new_val); + nss_pppoe_br_accel_mode = current_value; + nss_pppoe_br_help(new_val); + return -EINVAL; +@@ -242,7 +242,7 @@ int nss_pppoe_br_accel_mode_handler(stru + + status = nss_pppoe_tx_msg_sync(nss_ctx, &npm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Send acceleration mode message failed\n", nss_ctx); ++ nss_warning("%px: Send acceleration mode message failed\n", nss_ctx); + nss_pppoe_br_accel_mode = current_value; + return -EIO; + } +@@ -278,14 +278,14 @@ nss_tx_status_t nss_pppoe_tx_msg_sync(st + + status = nss_pppoe_tx_msg(nss_ctx, msg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_pppoe_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: nss_pppoe_tx_msg failed\n", nss_ctx); + up(&pppoe_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&pppoe_pvt.complete, msecs_to_jiffies(NSS_PPPOE_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: PPPoE msg tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: PPPoE msg tx failed due to timeout\n", nss_ctx); + pppoe_pvt.response = NSS_TX_FAILURE; + } + +--- a/nss_pppoe_log.c ++++ b/nss_pppoe_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -38,7 +38,7 @@ static int8_t *nss_pppoe_log_message_typ + static void nss_pppoe_log_session_create_msg(struct nss_pppoe_msg *npm) + { + struct nss_pppoe_create_msg *npcm __maybe_unused = &npm->msg.create; +- nss_trace("%p: NSS PPPOE Session Create message \n" ++ nss_trace("%px: NSS PPPOE Session Create message \n" + "PPPOE Base Interface Number: %d\n" + "PPPOE MTU: %d\n" + "PPPOE Server MAC: %pM\n" +@@ -56,7 +56,7 @@ static void nss_pppoe_log_session_create + static void nss_pppoe_log_session_destroy_msg(struct nss_pppoe_msg *npm) + { + struct nss_pppoe_destroy_msg *npdm __maybe_unused = &npm->msg.destroy; +- nss_trace("%p: NSS PPPOE Session Destroy message \n" ++ nss_trace("%px: NSS PPPOE Session Destroy message \n" + "PPPOE Session ID: %d\n" + "PPPOE Server MAC: %pM\n" + "PPPOE Local MAC: %pM\n", +@@ -86,7 +86,7 @@ static void nss_pppoe_log_verbose(struct + break; + + default: +- nss_trace("%p: Invalid message type\n", npm); ++ nss_trace("%px: Invalid message type\n", npm); + break; + } + } +@@ -98,11 +98,11 @@ static void nss_pppoe_log_verbose(struct + void nss_pppoe_log_tx_msg(struct nss_pppoe_msg *npm) + { + if (npm->cm.type >= NSS_PPPOE_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", npm); ++ nss_warning("%px: Invalid message type\n", npm); + return; + } + +- nss_info("%p: type[%d]:%s\n", npm, npm->cm.type, nss_pppoe_log_message_types_str[npm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", npm, npm->cm.type, nss_pppoe_log_message_types_str[npm->cm.type]); + nss_pppoe_log_verbose(npm); + } + +@@ -113,18 +113,18 @@ void nss_pppoe_log_tx_msg(struct nss_ppp + void nss_pppoe_log_rx_msg(struct nss_pppoe_msg *npm) + { + if (npm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", npm); ++ nss_warning("%px: Invalid response\n", npm); + return; + } + + if (npm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (npm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", npm, npm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", npm, npm->cm.type, + nss_pppoe_log_message_types_str[npm->cm.type], + npm->cm.response, nss_cmn_response_str[npm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + npm, npm->cm.type, nss_pppoe_log_message_types_str[npm->cm.type], + npm->cm.response, nss_cmn_response_str[npm->cm.response]); + +--- a/nss_pptp.c ++++ b/nss_pptp.c +@@ -184,12 +184,12 @@ static void nss_pptp_handler(struct nss_ + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_PPTP_MSG_MAX) { +- nss_warning("%p: received invalid message %d for PPTP interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for PPTP interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_pptp_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -235,7 +235,7 @@ static void nss_pptp_handler(struct nss_ + * call pptp tunnel callback + */ + if (!cb) { +- nss_warning("%p: Event received for pptp tunnel interface %d before registration", nss_ctx, ncm->interface); ++ nss_warning("%px: Event received for pptp tunnel interface %d before registration", nss_ctx, ncm->interface); + return; + } + +@@ -259,12 +259,12 @@ static nss_tx_status_t nss_pptp_tx_msg(s + * Sanity check the message + */ + if (!nss_is_dynamic_interface(ncm->interface)) { +- nss_warning("%p: tx request for non dynamic interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for non dynamic interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_PPTP_MSG_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -322,7 +322,7 @@ nss_tx_status_t nss_pptp_tx_msg_sync(str + + status = nss_pptp_tx_msg(nss_ctx, msg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: pptp_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: pptp_tx_msg failed\n", nss_ctx); + up(&pptp_pvt.sem); + return status; + } +@@ -330,7 +330,7 @@ nss_tx_status_t nss_pptp_tx_msg_sync(str + ret = wait_for_completion_timeout(&pptp_pvt.complete, msecs_to_jiffies(NSS_PPTP_TX_TIMEOUT)); + + if (!ret) { +- nss_warning("%p: PPTP msg tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: PPTP msg tx failed due to timeout\n", nss_ctx); + pptp_pvt.response = NSS_TX_FAILURE; + } + +@@ -345,7 +345,7 @@ nss_tx_status_t nss_pptp_tx_msg_sync(str + */ + nss_tx_status_t nss_pptp_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb) + { +- nss_trace("%p: pptp If Tx packet, id:%d, data=%p", nss_ctx, if_num, skb->data); ++ nss_trace("%px: pptp If Tx packet, id:%d, data=%px", nss_ctx, if_num, skb->data); + + return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); + } +--- a/nss_pptp_log.c ++++ b/nss_pptp_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -38,7 +38,7 @@ static int8_t *nss_pptp_log_message_type + static void nss_pptp_log_configure_msg(struct nss_pptp_msg *npm) + { + struct nss_pptp_session_configure_msg *npcm __maybe_unused = &npm->msg.session_configure_msg; +- nss_trace("%p: NSS PPTP Session Configure message\n" ++ nss_trace("%px: NSS PPTP Session Configure message\n" + "PPTP Source Call ID: %x\n" + "PPTP Destination Call ID: %x\n" + "PPTP Source IP: %pI4\n" +@@ -55,7 +55,7 @@ static void nss_pptp_log_configure_msg(s + static void nss_pptp_log_deconfigure_msg(struct nss_pptp_msg *npm) + { + struct nss_pptp_session_deconfigure_msg *npdm __maybe_unused = &npm->msg.session_deconfigure_msg; +- nss_trace("%p: NSS PPTP Session Configure message \n" ++ nss_trace("%px: NSS PPTP Session Configure message \n" + "PPTP Source Call ID: %x\n", + npdm, npdm->src_call_id); + } +@@ -82,7 +82,7 @@ static void nss_pptp_log_verbose(struct + break; + + default: +- nss_trace("%p: Invalid message type\n", npm); ++ nss_trace("%px: Invalid message type\n", npm); + break; + } + } +@@ -94,11 +94,11 @@ static void nss_pptp_log_verbose(struct + void nss_pptp_log_tx_msg(struct nss_pptp_msg *npm) + { + if (npm->cm.type >= NSS_PPTP_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", npm); ++ nss_warning("%px: Invalid message type\n", npm); + return; + } + +- nss_info("%p: type[%d]:%s\n", npm, npm->cm.type, nss_pptp_log_message_types_str[npm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", npm, npm->cm.type, nss_pptp_log_message_types_str[npm->cm.type]); + nss_pptp_log_verbose(npm); + } + +@@ -109,18 +109,18 @@ void nss_pptp_log_tx_msg(struct nss_pptp + void nss_pptp_log_rx_msg(struct nss_pptp_msg *npm) + { + if (npm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", npm); ++ nss_warning("%px: Invalid response\n", npm); + return; + } + + if (npm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (npm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", npm, npm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", npm, npm->cm.type, + nss_pptp_log_message_types_str[npm->cm.type], + npm->cm.response, nss_cmn_response_str[npm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + npm, npm->cm.type, nss_pptp_log_message_types_str[npm->cm.type], + npm->cm.response, nss_cmn_response_str[npm->cm.response]); + +--- a/nss_profiler.c ++++ b/nss_profiler.c +@@ -32,23 +32,23 @@ static void nss_profiler_rx_msg_handler( + nss_profiler_callback_t cb = nss_ctx->nss_top->profiler_callback[nss_ctx->id]; + + if (ncm->type >= NSS_PROFILER_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return; + } + + if (ncm->type <= NSS_PROFILER_FLOWCTRL_MSG) { + if (ncm->len > sizeof(pm->payload.pcmdp)) { +- nss_warning("%p: reply for cmd %d size is wrong %d : %d\n", nss_ctx, ncm->type, ncm->len, ncm->interface); ++ nss_warning("%px: reply for cmd %d size is wrong %d : %d\n", nss_ctx, ncm->type, ncm->len, ncm->interface); + return; + } + } else if (ncm->type <= NSS_PROFILER_DEBUG_REPLY_MSG) { + if (ncm->len > sizeof(pm->payload.pdm)) { +- nss_warning("%p: reply for debug %d is too big %d\n", nss_ctx, ncm->type, ncm->len); ++ nss_warning("%px: reply for debug %d is too big %d\n", nss_ctx, ncm->type, ncm->len); + return; + } + } else if (ncm->type <= NSS_PROFILER_COUNTERS_MSG) { + if (ncm->len < (sizeof(pm->payload.pcmdp) - (PROFILE_MAX_APP_COUNTERS - pm->payload.pcmdp.num_counters) * sizeof(pm->payload.pcmdp.counters[0])) || ncm->len > sizeof(pm->payload.pcmdp)) { +- nss_warning("%p: %d params data is too big %d : %d\n", nss_ctx, ncm->type, ncm->len, ncm->interface); ++ nss_warning("%px: %d params data is too big %d : %d\n", nss_ctx, ncm->type, ncm->len, ncm->interface); + return; + } + } +@@ -57,7 +57,7 @@ static void nss_profiler_rx_msg_handler( + * status per request callback + */ + if (ncm->response != NSS_CMN_RESPONSE_NOTIFY && ncm->cb) { +- nss_info("%p: reply CB %p for %d %d\n", nss_ctx, (void *)ncm->cb, ncm->type, ncm->response); ++ nss_info("%px: reply CB %px for %d %d\n", nss_ctx, (void *)ncm->cb, ncm->type, ncm->response); + cb = (nss_profiler_callback_t)ncm->cb; + } + +@@ -65,7 +65,7 @@ static void nss_profiler_rx_msg_handler( + * sample related callback + */ + if (!cb || !ctx) { +- nss_warning("%p: Event received for profiler interface before registration", nss_ctx); ++ nss_warning("%px: Event received for profiler interface before registration", nss_ctx); + return; + } + +@@ -84,22 +84,22 @@ nss_tx_status_t nss_profiler_if_tx_buf(v + struct nss_profiler_data_msg *pdm = (struct nss_profiler_data_msg *)buf; + nss_tx_status_t ret; + +- nss_trace("%p: Profiler If Tx, buf=%p", nss_ctx, buf); ++ nss_trace("%px: Profiler If Tx, buf=%px", nss_ctx, buf); + + if (sizeof(npm->payload) < len) { +- nss_warning("%p: (%u)Bad message length(%u)", nss_ctx, NSS_PROFILER_INTERFACE, len); ++ nss_warning("%px: (%u)Bad message length(%u)", nss_ctx, NSS_PROFILER_INTERFACE, len); + return NSS_TX_FAILURE_TOO_LARGE; + } + + if (NSS_NBUF_PAYLOAD_SIZE < (len + sizeof(npm->cm))) { +- nss_warning("%p: (%u)Message length(%u) is larger than payload size (%u)", ++ nss_warning("%px: (%u)Message length(%u) is larger than payload size (%u)", + nss_ctx, NSS_PROFILER_INTERFACE, (uint32_t)(len + sizeof(npm->cm)), NSS_NBUF_PAYLOAD_SIZE); + return NSS_TX_FAILURE_TOO_LARGE; + } + + npm = kzalloc(sizeof(*npm), GFP_KERNEL); + if (!npm) { +- nss_warning("%p: Failed to allocate memory for message\n", nss_ctx); ++ nss_warning("%px: Failed to allocate memory for message\n", nss_ctx); + return NSS_TX_FAILURE; + } + +@@ -153,8 +153,10 @@ void nss_profiler_release_dma(struct nss + + ctrl = nss_ctx->meminfo_ctx.sdma_ctrl; + +- if (ctrl && ctrl->consumer[0].ring.kp) ++ if (ctrl && ctrl->consumer[0].ring.kp) { + kfree(ctrl->consumer[0].ring.kp); ++ ctrl->consumer[0].ring.kp = NULL; ++ } + } + EXPORT_SYMBOL(nss_profiler_release_dma); + +@@ -166,7 +168,7 @@ bool nss_profile_dma_register_cb(struct + void (*cb)(void*), void *arg) + { + struct nss_profile_sdma_ctrl *ctrl = (struct nss_profile_sdma_ctrl *)nss_ctx->meminfo_ctx.sdma_ctrl; +- nss_info("%p dma_register_cb %d: %p %p\n", ctrl, id, cb, arg); ++ nss_info("%px dma_register_cb %d: %px %px\n", ctrl, id, cb, arg); + if (!ctrl) + return false; + +@@ -198,10 +200,12 @@ EXPORT_SYMBOL(nss_profile_dma_deregister + struct nss_profile_sdma_ctrl *nss_profile_dma_get_ctrl(struct nss_ctx_instance *nss_ctx) + { + struct nss_profile_sdma_ctrl *ctrl = nss_ctx->meminfo_ctx.sdma_ctrl; +- if (ctrl) { +- dmac_inv_range(ctrl, &ctrl->cidx); +- dsb(sy); ++ if (!ctrl) { ++ return ctrl; + } ++ ++ dmac_inv_range(ctrl, &ctrl->cidx); ++ dsb(sy); + return ctrl; + } + EXPORT_SYMBOL(nss_profile_dma_get_ctrl); +@@ -233,7 +237,7 @@ void nss_profiler_notify_unregister(nss_ + { + nss_assert(core_id < NSS_CORE_MAX); + +- nss_core_register_handler(&nss_top_main.nss[core_id], NSS_PROFILER_INTERFACE, NULL, NULL); ++ nss_core_unregister_handler(&nss_top_main.nss[core_id], NSS_PROFILER_INTERFACE); + nss_top_main.profiler_callback[core_id] = NULL; + nss_top_main.profiler_ctx[core_id] = NULL; + } +--- a/nss_project.c ++++ b/nss_project.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2017-2018, 2020, 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. +@@ -81,7 +81,7 @@ static void nss_project_wt_stats_enable_ + return; + } + +- nss_info("%p: Received response ACK for worker thread stats enable msg.\n", nss_ctx); ++ nss_info("%px: Received response ACK for worker thread stats enable msg.\n", nss_ctx); + + /* + * If statistics have already been allocated, nothing else to do. +@@ -93,7 +93,7 @@ static void nss_project_wt_stats_enable_ + stats_temp = nss_project_alloc_wt_stats(stats_enable->worker_thread_count, + stats_enable->irq_count); + if (unlikely(!stats_temp)) { +- nss_warning("%p: Unable to allocate worker thread statistics.\n", nss_ctx); ++ nss_warning("%px: Unable to allocate worker thread statistics.\n", nss_ctx); + return; + } + +@@ -116,7 +116,7 @@ static nss_tx_status_t nss_project_wt_st + + npm = kzalloc(sizeof(*npm), GFP_KERNEL); + if (!npm) { +- nss_warning("%p: Failed to allocate buffer for message\n", nss_ctx); ++ nss_warning("%px: Failed to allocate buffer for message\n", nss_ctx); + return NSS_TX_FAILURE; + } + +@@ -147,17 +147,17 @@ static void nss_project_wt_stats_update( + int i; + + if (unlikely(!nss_ctx->wt_stats)) { +- nss_warning("%p: Worker thread statistics not yet allocated.\n", nss_ctx); ++ nss_warning("%px: Worker thread statistics not yet allocated.\n", nss_ctx); + return; + } + + if (unlikely(stats_notify->threadno >= nss_ctx->worker_thread_count)) { +- nss_warning("%p: Invalid WT number %d\n", nss_ctx, stats_notify->threadno); ++ nss_warning("%px: Invalid WT number %d\n", nss_ctx, stats_notify->threadno); + return; + } + + if (unlikely(stats_notify->stats_written > NSS_PROJECT_IRQS_PER_MESSAGE)) { +- nss_warning("%p: Invalid worker thread stats written count %d\n", ++ nss_warning("%px: Invalid worker thread stats written count %d\n", + nss_ctx, stats_notify->stats_written); + return; + } +@@ -165,7 +165,7 @@ static void nss_project_wt_stats_update( + wt_stats = &(nss_ctx->wt_stats[stats_notify->threadno]); + + if (unlikely(!wt_stats->irq_stats)) { +- nss_warning("%p: Worker thread statistics not allocated for thread %d\n", ++ nss_warning("%px: Worker thread statistics not allocated for thread %d\n", + nss_ctx, stats_notify->threadno); + return; + } +@@ -174,7 +174,7 @@ static void nss_project_wt_stats_update( + for (i = 0; i < stats_notify->stats_written; ++i) { + int irq = stats_notify->stats[i].irq; + if (unlikely(irq >= nss_ctx->irq_count)) { +- nss_warning("%p: Invalid IRQ number %d\n", nss_ctx, irq); ++ nss_warning("%px: Invalid IRQ number %d\n", nss_ctx, irq); + continue; + } + +@@ -197,12 +197,12 @@ static void nss_project_msg_handler(stru + * Sanity checks on message + */ + if (npm->cm.type >= NSS_PROJECT_MSG_MAX) { +- nss_warning("%p: message type out of range: %d\n", nss_ctx, npm->cm.type); ++ nss_warning("%px: message type out of range: %d\n", nss_ctx, npm->cm.type); + return; + } + + if (nss_cmn_get_msg_len(&(npm->cm)) > sizeof(struct nss_project_msg)) { +- nss_warning("%p: message length is invalid: %d\n", nss_ctx, nss_cmn_get_msg_len(&(npm->cm))); ++ nss_warning("%px: message length is invalid: %d\n", nss_ctx, nss_cmn_get_msg_len(&(npm->cm))); + return; + } + +--- a/nss_pvxlan.c ++++ b/nss_pvxlan.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -84,13 +84,13 @@ static bool nss_pvxlan_hdl_instance_free + h = nss_pvxlan_hdl[if_num - NSS_DYNAMIC_IF_START]; + if (!h) { + spin_unlock(&nss_pvxlan_spinlock); +- nss_warning("%p: Instance does not exist: %d", nss_ctx, if_num); ++ nss_warning("%px: Instance does not exist: %d", nss_ctx, if_num); + return false; + } + + if (h->if_num != if_num) { + spin_unlock(&nss_pvxlan_spinlock); +- nss_warning("%p: Not correct if_num: %d", nss_ctx, if_num); ++ nss_warning("%px: Not correct if_num: %d", nss_ctx, if_num); + return false; + } + +@@ -114,7 +114,7 @@ static bool nss_pvxlan_hdl_instance_allo + */ + h = kzalloc(sizeof(struct nss_pvxlan_handle), GFP_ATOMIC); + if (!h) { +- nss_warning("%p: no memory for allocating PVxLAN handle instance for interface : %d", nss_ctx, if_num); ++ nss_warning("%px: no memory for allocating PVxLAN handle instance for interface : %d", nss_ctx, if_num); + return false; + } + h->if_num = if_num; +@@ -123,7 +123,7 @@ static bool nss_pvxlan_hdl_instance_allo + if (nss_pvxlan_hdl[if_num - NSS_DYNAMIC_IF_START] != NULL) { + spin_unlock(&nss_pvxlan_spinlock); + kfree(h); +- nss_warning("%p: The handle has been taken by another thread :%d", nss_ctx, if_num); ++ nss_warning("%px: The handle has been taken by another thread :%d", nss_ctx, if_num); + return false; + } + +@@ -175,12 +175,12 @@ static void nss_pvxlan_msg_handler(struc + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_PVXLAN_MSG_TYPE_MAX) { +- nss_warning("%p: received invalid message %d for PVXLAN interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for PVXLAN interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_pvxlan_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -196,7 +196,6 @@ static void nss_pvxlan_msg_handler(struc + break; + } + +- + /* + * Update the callback and app_data for NOTIFY messages. + */ +@@ -218,7 +217,7 @@ static void nss_pvxlan_msg_handler(struc + * Do we have a callback + */ + if (!cb) { +- nss_trace("%p: cb is null for interface %d", nss_ctx, ncm->interface); ++ nss_trace("%px: cb is null for interface %d", nss_ctx, ncm->interface); + return; + } + +@@ -265,14 +264,14 @@ nss_tx_status_t nss_pvxlan_tx_msg_sync(s + + status = nss_pvxlan_tx_msg(nss_ctx, nvxm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: pvxlan_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: pvxlan_tx_msg failed\n", nss_ctx); + up(&pvxlan_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&pvxlan_pvt.complete, msecs_to_jiffies(NSS_PVXLAN_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: pvxlan tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: pvxlan tx sync failed due to timeout\n", nss_ctx); + pvxlan_pvt.response = NSS_TX_FAILURE; + } + +@@ -311,7 +310,7 @@ bool nss_pvxlan_unregister(uint32_t if_n + + nss_ctx = nss_pvxlan_get_ctx(); + if (!nss_pvxlan_verify_if_num(if_num)) { +- nss_warning("%p: data unregister received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: data unregister received for invalid interface %d", nss_ctx, if_num); + return false; + } + +@@ -350,19 +349,19 @@ struct nss_ctx_instance *nss_pvxlan_regi + + nss_ctx = nss_pvxlan_get_ctx(); + if (!nss_pvxlan_verify_if_num(if_num)) { +- nss_warning("%p: data register received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: data register received for invalid interface %d", nss_ctx, if_num); + return NULL; + } + + core_status = nss_core_register_handler(nss_ctx, if_num, nss_pvxlan_msg_handler, NULL); + if (core_status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: nss core register handler failed for if_num:%d with error :%d", nss_ctx, if_num, core_status); ++ nss_warning("%px: nss core register handler failed for if_num:%d with error :%d", nss_ctx, if_num, core_status); + return NULL; + } + + if (!nss_pvxlan_hdl_instance_alloc(nss_ctx, if_num, notify_cb, (void *)netdev)) { + nss_core_unregister_handler(nss_ctx, if_num); +- nss_warning("%p: couldn't allocate handle instance for if_num:%d", nss_ctx, if_num); ++ nss_warning("%px: couldn't allocate handle instance for if_num:%d", nss_ctx, if_num); + return NULL; + } + +@@ -380,7 +379,7 @@ struct nss_ctx_instance *nss_pvxlan_regi + spin_unlock_bh(&nss_pvxlan_tunnel_stats_debug_lock); + + if (i == NSS_PVXLAN_MAX_INTERFACES) { +- nss_warning("%p: No available debug stats instance :%d", nss_ctx, if_num); ++ nss_warning("%px: No available debug stats instance :%d", nss_ctx, if_num); + nss_pvxlan_hdl_instance_free(nss_ctx, if_num); + nss_core_unregister_handler(nss_ctx, if_num); + return NULL; +@@ -402,7 +401,7 @@ int nss_pvxlan_ifnum_with_core_id(int if + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (!nss_is_dynamic_interface(if_num)) { +- nss_warning("%p: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); ++ nss_warning("%px: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); + return 0; + } + return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); +--- a/nss_pvxlan_log.c ++++ b/nss_pvxlan_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -58,10 +58,10 @@ static int8_t *nss_pvxlan_log_error_resp + */ + static void nss_pvxlan_log_rule_msg(struct nss_pvxlan_rule_msg *npvrm) + { +- nss_trace("%p: NSS PVXLAN Rule message \n" +- "Encap Rule Src IP: %p\n" ++ nss_trace("%px: NSS PVXLAN Rule message \n" ++ "Encap Rule Src IP: %px\n" + "Encap Rule Src Port: %d\n" +- "Encap Rule Dst Ip: %p\n" ++ "Encap Rule Dst Ip: %px\n" + "Encap Rule Dst Port: %d\n" + "RPS: %d\n" + "Flags: %x\n" +@@ -81,7 +81,7 @@ static void nss_pvxlan_log_rule_msg(stru + */ + static void nss_pvxlan_log_mac_msg(struct nss_pvxlan_mac_msg *npvcm) + { +- nss_trace("%p: NSS PVXLAN MAC message \n" ++ nss_trace("%px: NSS PVXLAN MAC message \n" + "PVxLAN Mac Addr: %x : %x : %x" + "PVxLAN Flags: %u\n" + "PVxLAN VNet ID: %u\n" +@@ -121,7 +121,7 @@ static void nss_pvxlan_log_rule_uncfg_ms + static void nss_pvxlan_log_enable_msg(struct nss_pvxlan_msg *npvm) + { + struct nss_pvxlan_tunnel_state_msg *npvrm __maybe_unused = &npvm->msg.enable; +- nss_trace("%p: NSS PVXLAN Tunnel state message: Enable \n", npvrm); ++ nss_trace("%px: NSS PVXLAN Tunnel state message: Enable \n", npvrm); + } + + /* +@@ -130,7 +130,7 @@ static void nss_pvxlan_log_enable_msg(st + */ + static void nss_pvxlan_log_disable_msg(struct nss_pvxlan_msg *npvm) + { +- nss_trace("%p: NSS PVXLAN Tunnel state message: Disable \n", npvm); ++ nss_trace("%px: NSS PVXLAN Tunnel state message: Disable \n", npvm); + } + + /* +@@ -188,7 +188,7 @@ static void nss_pvxlan_log_verbose(struc + break; + + default: +- nss_trace("%p: Invalid message type\n", npvm); ++ nss_trace("%px: Invalid message type\n", npvm); + break; + } + } +@@ -200,11 +200,11 @@ static void nss_pvxlan_log_verbose(struc + void nss_pvxlan_log_tx_msg(struct nss_pvxlan_msg *npvm) + { + if (npvm->cm.type >= NSS_PVXLAN_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", npvm); ++ nss_warning("%px: Invalid message type\n", npvm); + return; + } + +- nss_info("%p: type[%d]:%s\n", npvm, npvm->cm.type, nss_pvxlan_log_message_types_str[npvm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", npvm, npvm->cm.type, nss_pvxlan_log_message_types_str[npvm->cm.type]); + nss_pvxlan_log_verbose(npvm); + } + +@@ -215,26 +215,26 @@ void nss_pvxlan_log_tx_msg(struct nss_pv + void nss_pvxlan_log_rx_msg(struct nss_pvxlan_msg *npvm) + { + if (npvm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", npvm); ++ nss_warning("%px: Invalid response\n", npvm); + return; + } + + if (npvm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (npvm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", npvm, npvm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", npvm, npvm->cm.type, + nss_pvxlan_log_message_types_str[npvm->cm.type], + npvm->cm.response, nss_cmn_response_str[npvm->cm.response]); + goto verbose; + } + + if (npvm->cm.error >= NSS_PVXLAN_ERROR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + npvm, npvm->cm.type, nss_pvxlan_log_message_types_str[npvm->cm.type], + npvm->cm.response, nss_cmn_response_str[npvm->cm.response], + npvm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + npvm, npvm->cm.type, nss_pvxlan_log_message_types_str[npvm->cm.type], + npvm->cm.response, nss_cmn_response_str[npvm->cm.response], + npvm->cm.error, nss_pvxlan_log_error_response_types_str[npvm->cm.error]); +--- a/nss_pvxlan_stats.c ++++ b/nss_pvxlan_stats.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -166,7 +166,7 @@ void nss_pvxlan_stats_sync(struct nss_ct + + if (!s) { + spin_unlock_bh(&nss_pvxlan_tunnel_stats_debug_lock); +- nss_warning("%p: Tunnel not found: %u", nss_ctx, if_num); ++ nss_warning("%px: Tunnel not found: %u", nss_ctx, if_num); + return; + } + +--- a/nss_qrfs.c ++++ b/nss_qrfs.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2017-2020, 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. +@@ -52,7 +52,7 @@ static void nss_qrfs_msg_handler(struct + nss_qrfs_log_rx_msg(nqm); + + if (!nss_qrfs_verify_if_num(ncm->interface)) { +- nss_warning("%p: invalid interface %d for QRFS\n", nss_ctx, ncm->interface); ++ nss_warning("%px: invalid interface %d for QRFS\n", nss_ctx, ncm->interface); + return; + } + +@@ -60,12 +60,12 @@ static void nss_qrfs_msg_handler(struct + * Is this a valid request/response? + */ + if (ncm->type >= NSS_QRFS_MSG_MAX) { +- nss_warning("%p: invalid message %d for QRFS\n", nss_ctx, ncm->type); ++ nss_warning("%px: invalid message %d for QRFS\n", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_qrfs_msg)) { +- nss_warning("%p: message length is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: message length is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -128,7 +128,7 @@ static bool nss_qrfs_get_flow_keys(struc + + res = skb_flow_dissect(skb, &keys); + if (!res) { +- nss_warning("%p: failed to get flow keys\n", nss_ctx); ++ nss_warning("%px: failed to get flow keys\n", nss_ctx); + return res; + } + +@@ -146,7 +146,7 @@ static bool nss_qrfs_get_flow_keys(struc + nqfrm->ip_version = 6; + ip6hdr = (struct ipv6hdr *)skb_network_header(skb); + if (!ip6hdr) { +- nss_warning("%p: failed to get IPv6 address\n", nss_ctx); ++ nss_warning("%px: failed to get IPv6 address\n", nss_ctx); + return false; + } + +@@ -164,7 +164,7 @@ static bool nss_qrfs_get_flow_keys(struc + + res = skb_flow_dissect_flow_keys(skb, &keys, 0); + if (!res) { +- nss_warning("%p: failed to get flow keys\n", nss_ctx); ++ nss_warning("%px: failed to get flow keys\n", nss_ctx); + return res; + } + +@@ -197,19 +197,19 @@ static void nss_qrfs_flow_add_msg_callba + struct nss_qrfs_flow_rule_msg *nqfrm; + + if (nqm->cm.type != NSS_QRFS_MSG_FLOW_ADD) { +- nss_warning("%p: invalid flow response message %d\n", nss_ctx, nqm->cm.type); ++ nss_warning("%px: invalid flow response message %d\n", nss_ctx, nqm->cm.type); + return; + } + + nqfrm = &nqm->msg.flow_add; + + if ((nqfrm->ip_version != 4) && (nqfrm->ip_version != 6)) { +- nss_warning("%p: invalid IP version %d\n", nss_ctx, nqfrm->ip_version); ++ nss_warning("%px: invalid IP version %d\n", nss_ctx, nqfrm->ip_version); + return; + } + + if (nqm->cm.response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p: flow add configuration error: %d for NSS core %d\n", ++ nss_warning("%px: flow add configuration error: %d for NSS core %d\n", + nss_ctx, nqm->cm.error, nss_ctx->id); + } + } +@@ -224,19 +224,19 @@ static void nss_qrfs_flow_delete_msg_cal + struct nss_qrfs_flow_rule_msg *nqfrm; + + if (nqm->cm.type != NSS_QRFS_MSG_FLOW_DELETE) { +- nss_warning("%p: invalid flow response message %d\n", nss_ctx, nqm->cm.type); ++ nss_warning("%px: invalid flow response message %d\n", nss_ctx, nqm->cm.type); + return; + } + + nqfrm = &nqm->msg.flow_delete; + + if ((nqfrm->ip_version != 4) && (nqfrm->ip_version != 6)) { +- nss_warning("%p: invalid IP version %d\n", nss_ctx, nqfrm->ip_version); ++ nss_warning("%px: invalid IP version %d\n", nss_ctx, nqfrm->ip_version); + return; + } + + if (nqm->cm.response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p: flow delete configuration error: %d for NSS core %d\n", ++ nss_warning("%px: flow delete configuration error: %d for NSS core %d\n", + nss_ctx, nqm->cm.error, nss_ctx->id); + } + } +@@ -267,12 +267,12 @@ static nss_tx_status_t nss_qrfs_tx_msg(s + * Sanity check the message + */ + if (!nss_qrfs_verify_if_num(ncm->interface)) { +- nss_warning("%p: interface is not QRFS interface: %d\n", nss_ctx, ncm->interface); ++ nss_warning("%px: interface is not QRFS interface: %d\n", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_QRFS_MSG_MAX) { +- nss_warning("%p: message type is out of range: %d\n", nss_ctx, ncm->type); ++ nss_warning("%px: message type is out of range: %d\n", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -405,7 +405,7 @@ nss_tx_status_t nss_qrfs_set_flow_rule(s + } + + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: failed to send flow rule to NSS core %d\n", nss_ctx, i); ++ nss_warning("%px: failed to send flow rule to NSS core %d\n", nss_ctx, i); + return NSS_TX_FAILURE; + } + } +--- a/nss_qrfs_log.c ++++ b/nss_qrfs_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -54,7 +54,7 @@ static int8_t *nss_qrfs_log_error_respon + */ + static void nss_qrfs_log_flow_rule_msg(struct nss_qrfs_flow_rule_msg *nqfm) + { +- nss_trace("%p: NSS QRFS Flow Rule Message:\n" ++ nss_trace("%px: NSS QRFS Flow Rule Message:\n" + "QRFS Source Port: %d\n" + "QRFS Destination Port: %d\n" + "QRFS IP Version: %d\n" +@@ -86,7 +86,7 @@ static void nss_qrfs_log_flow_rule_msg(s + */ + static void nss_qrfs_log_mac_rule_msg(struct nss_qrfs_mac_rule_msg *nqmm) + { +- nss_trace("%p: NSS QRFS MAC Rule Message:\n" ++ nss_trace("%px: NSS QRFS MAC Rule Message:\n" + "QRFS MAC: %pM\n" + "QRFS CPU ID: %d\n" + "QRFS Physical Interface Number: %d\n", +@@ -118,7 +118,7 @@ static void nss_qrfs_log_verbose(struct + break; + + default: +- nss_warning("%p: Invalid message type\n", nqm); ++ nss_warning("%px: Invalid message type\n", nqm); + break; + } + } +@@ -130,11 +130,11 @@ static void nss_qrfs_log_verbose(struct + void nss_qrfs_log_tx_msg(struct nss_qrfs_msg *nqm) + { + if (nqm->cm.type >= NSS_QRFS_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", nqm); ++ nss_warning("%px: Invalid message type\n", nqm); + return; + } + +- nss_info("%p: type[%d]:%s\n", nqm, nqm->cm.type, nss_qrfs_log_message_types_str[nqm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nqm, nqm->cm.type, nss_qrfs_log_message_types_str[nqm->cm.type]); + nss_qrfs_log_verbose(nqm); + } + +@@ -145,26 +145,26 @@ void nss_qrfs_log_tx_msg(struct nss_qrfs + void nss_qrfs_log_rx_msg(struct nss_qrfs_msg *nqm) + { + if (nqm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nqm); ++ nss_warning("%px: Invalid response\n", nqm); + return; + } + + if (nqm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nqm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nqm, nqm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nqm, nqm->cm.type, + nss_qrfs_log_message_types_str[nqm->cm.type], + nqm->cm.response, nss_cmn_response_str[nqm->cm.response]); + goto verbose; + } + + if (nqm->cm.error >= NSS_QRFS_ERROR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + nqm, nqm->cm.type, nss_qrfs_log_message_types_str[nqm->cm.type], + nqm->cm.response, nss_cmn_response_str[nqm->cm.response], + nqm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + nqm, nqm->cm.type, nss_qrfs_log_message_types_str[nqm->cm.type], + nqm->cm.response, nss_cmn_response_str[nqm->cm.response], + nqm->cm.error, nss_qrfs_log_error_response_types_str[nqm->cm.error]); +--- a/nss_qvpn.c ++++ b/nss_qvpn.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -41,7 +41,7 @@ static bool nss_qvpn_verify_if_num(uint3 + if_type = nss_dynamic_interface_get_type(nss_qvpn_get_context(), if_num); + if ((if_type != NSS_DYNAMIC_INTERFACE_TYPE_QVPN_INNER) && + (if_type != NSS_DYNAMIC_INTERFACE_TYPE_QVPN_OUTER)) { +- nss_warning("%p: if_num = %u interface type returned is %d\n", nss_qvpn_get_context(), if_num, if_type); ++ nss_warning("%px: if_num = %u interface type returned is %d\n", nss_qvpn_get_context(), if_num, if_type); + return false; + } + +@@ -94,12 +94,12 @@ static void nss_qvpn_handler(struct nss_ + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_QVPN_MSG_TYPE_MAX) { +- nss_warning("%p: received invalid message %d for qvpn interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for qvpn interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_qvpn_msg)) { +- nss_warning("%p: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -122,7 +122,7 @@ static void nss_qvpn_handler(struct nss_ + * to the same callback/app_data. + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_top_main.if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; + } + +@@ -131,7 +131,7 @@ static void nss_qvpn_handler(struct nss_ + */ + cb = (nss_qvpn_msg_callback_t)ncm->cb; + if (unlikely(!cb)) { +- nss_trace("%p: rx handler unregistered for i/f: %u\n", nss_ctx, ncm->interface); ++ nss_trace("%px: rx handler unregistered for i/f: %u\n", nss_ctx, ncm->interface); + return; + } + +@@ -187,12 +187,12 @@ nss_tx_status_t nss_qvpn_tx_msg(struct n + * Sanity check the message + */ + if (!nss_qvpn_verify_if_num(ncm->interface)) { +- nss_warning("%p: tx request for interface that is not a qvpn: %u\n", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for interface that is not a qvpn: %u\n", nss_ctx, ncm->interface); + return NSS_TX_FAILURE_BAD_PARAM; + } + + if (ncm->type >= NSS_QVPN_MSG_TYPE_MAX) { +- nss_warning("%p: message type out of range: %d\n", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d\n", nss_ctx, ncm->type); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -219,12 +219,12 @@ nss_tx_status_t nss_qvpn_tx_msg_sync(str + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (len > sizeof(nqm.msg)) { +- nss_warning("%p: Incorrect message length=%u for type %d and if_num=%u\n", nss_ctx, len, type, if_num); ++ nss_warning("%px: Incorrect message length=%u for type %d and if_num=%u\n", nss_ctx, len, type, if_num); + return NSS_TX_FAILURE_TOO_LARGE; + } + + if (!resp) { +- nss_warning("%p: Invalid input, resp=NULL\n", nss_ctx); ++ nss_warning("%px: Invalid input, resp=NULL\n", nss_ctx); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -235,13 +235,13 @@ nss_tx_status_t nss_qvpn_tx_msg_sync(str + + status = nss_qvpn_tx_msg(nss_ctx, &nqm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: qvpn_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: qvpn_tx_msg failed\n", nss_ctx); + goto done; + } + + ret = wait_for_completion_timeout(&qvpn_pvt.complete, msecs_to_jiffies(NSS_QVPN_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: qvpn msg tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: qvpn msg tx failed due to timeout\n", nss_ctx); + status = NSS_TX_FAILURE_SYNC_TIMEOUT; + goto done; + } +@@ -267,7 +267,7 @@ EXPORT_SYMBOL(nss_qvpn_tx_msg_sync); + nss_tx_status_t nss_qvpn_tx_buf(struct nss_ctx_instance *nss_ctx, uint32_t if_num, struct sk_buff *skb) + { + if (!nss_qvpn_verify_if_num(if_num)) { +- nss_warning("%p: tx request for interface that is not a qvpn: %u\n", nss_ctx, if_num); ++ nss_warning("%px: tx request for interface that is not a qvpn: %u\n", nss_ctx, if_num); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -294,13 +294,18 @@ struct nss_ctx_instance *nss_qvpn_regist + struct net_device *netdev, uint32_t features, void *app_ctx) + { + struct nss_ctx_instance *nss_ctx = nss_qvpn_get_context(); ++ uint32_t status; + + nss_assert(nss_ctx); + nss_assert(nss_qvpn_verify_if_num(if_num)); + + nss_core_register_subsys_dp(nss_ctx, if_num, qvpn_data_callback, NULL, app_ctx, netdev, features); + nss_core_register_handler(nss_ctx, if_num, nss_qvpn_handler, app_ctx); +- nss_top_main.if_rx_msg_callback[if_num] = qvpn_event_callback; ++ status = nss_core_register_msg_handler(nss_ctx, if_num, qvpn_event_callback); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to register handler for interface %d with NSS core\n", nss_ctx, if_num); ++ return NULL; ++ } + + set_bit(if_num, qvpn_pvt.if_map); + return nss_ctx; +@@ -314,15 +319,24 @@ EXPORT_SYMBOL(nss_qvpn_register_if); + void nss_qvpn_unregister_if(uint32_t if_num) + { + struct nss_ctx_instance *nss_ctx = nss_qvpn_get_context(); ++ uint32_t status; + + nss_assert(nss_qvpn_verify_if_num(if_num)); + + clear_bit(if_num, qvpn_pvt.if_map); + + nss_core_unregister_subsys_dp(nss_ctx, if_num); +- nss_core_unregister_handler(nss_ctx, if_num); ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Failed to unregister handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); ++ return; ++ } + +- nss_top_main.if_rx_msg_callback[if_num] = NULL; ++ status = nss_core_unregister_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Failed to unregister handler for IPsec NSS I/F:%u\n", nss_ctx, if_num); ++ return; ++ } + } + EXPORT_SYMBOL(nss_qvpn_unregister_if); + +@@ -336,7 +350,7 @@ int nss_qvpn_ifnum_with_core_id(int if_n + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + if (nss_qvpn_verify_if_num(if_num) == false) { +- nss_info("%p: if_num: %u is not QVPN interface\n", nss_ctx, if_num); ++ nss_info("%px: if_num: %u is not QVPN interface\n", nss_ctx, if_num); + return 0; + } + return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); +--- a/nss_qvpn_log.c ++++ b/nss_qvpn_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -69,10 +69,10 @@ static int8_t *nss_qvpn_log_error_respon + static void nss_qvpn_log_tun_config_msg(struct nss_qvpn_msg *ncm) + { + struct nss_qvpn_tunnel_config_msg *nqtcm __maybe_unused = &ncm->msg.tunnel_config; +- nss_trace("%p: NSS QVPN tunnel config message \n" ++ nss_trace("%px: NSS QVPN tunnel config message \n" + "Sibling interface: %d" + "Total number of commands: %d" +- "Commands: %p" ++ "Commands: %px" + "Source IP: %x:%x:%x:%x\n" + "Source Port: %d\n" + "Destination IP: %x:%x:%x:%x\n" +@@ -86,8 +86,8 @@ static void nss_qvpn_log_tun_config_msg( + "VPN header head size: %d\n" + "VPN header head offset: %d\n" + "VPN header tail size: %d\n" +- "VPN header head: %p\n" +- "VPN header tail: %p\n", ++ "VPN header head: %px\n" ++ "VPN header tail: %px\n", + nqtcm, + nqtcm->sibling_if, + nqtcm->total_cmds, +@@ -115,7 +115,7 @@ static void nss_qvpn_log_tun_config_msg( + */ + static void nss_qvpn_log_tun_deconfig_msg(struct nss_qvpn_msg *ncm) + { +- nss_trace("%p: NSS QVPN deconfigure message \n", ncm); ++ nss_trace("%px: NSS QVPN deconfigure message \n", ncm); + } + + /* +@@ -125,9 +125,9 @@ static void nss_qvpn_log_tun_deconfig_ms + static void nss_qvpn_log_crypto_key_add_msg(struct nss_qvpn_msg *ncm) + { + struct nss_qvpn_crypto_key_add_msg *nqckam __maybe_unused = &ncm->msg.key_add; +- nss_trace("%p: NSS QVPN crypto key add message \n" ++ nss_trace("%px: NSS QVPN crypto key add message \n" + "Crypto index: %d\n" +- "Crypto session ID: %p", ++ "Crypto session ID: %px", + nqckam, + nqckam->crypto_idx, + nqckam->session_id); +@@ -140,9 +140,9 @@ static void nss_qvpn_log_crypto_key_add_ + static void nss_qvpn_log_crypto_key_activate_msg(struct nss_qvpn_msg *ncm) + { + struct nss_qvpn_crypto_key_activate_msg *nqckam __maybe_unused = &ncm->msg.key_activate; +- nss_trace("%p: NSS QVPN crypto key activate message \n" ++ nss_trace("%px: NSS QVPN crypto key activate message \n" + "Crypto index: %d\n" +- "Crypto VPN header head: %p", ++ "Crypto VPN header head: %px", + nqckam, + nqckam->crypto_idx, + nqckam->vpn_hdr_head); +@@ -155,7 +155,7 @@ static void nss_qvpn_log_crypto_key_acti + static void nss_qvpn_log_crypto_key_del_msg(struct nss_qvpn_msg *ncm) + { + struct nss_qvpn_crypto_key_del_msg *nqckdm __maybe_unused = &ncm->msg.key_del; +- nss_trace("%p: NSS QVPN crypto key delete message \n" ++ nss_trace("%px: NSS QVPN crypto key delete message \n" + "Crypto index: %d\n", + nqckdm, + nqckdm->crypto_idx); +@@ -168,7 +168,7 @@ static void nss_qvpn_log_crypto_key_del_ + static void nss_qvpn_log_crypto_key_deactivate_msg(struct nss_qvpn_msg *ncm) + { + struct nss_qvpn_crypto_key_del_msg *nqckdm __maybe_unused = &ncm->msg.key_del; +- nss_trace("%p: NSS QVPN crypto key deactivate message \n" ++ nss_trace("%px: NSS QVPN crypto key deactivate message \n" + "Crypto index: %d\n", + nqckdm, + nqckdm->crypto_idx); +@@ -206,7 +206,7 @@ static void nss_qvpn_log_verbose(struct + break; + + default: +- nss_trace("%p: Invalid message type\n", ncm); ++ nss_trace("%px: Invalid message type\n", ncm); + break; + } + } +@@ -218,11 +218,11 @@ static void nss_qvpn_log_verbose(struct + void nss_qvpn_log_tx_msg(struct nss_qvpn_msg *ncm) + { + if (ncm->cm.type >= NSS_QVPN_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", ncm); ++ nss_warning("%px: Invalid message type\n", ncm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ncm, ncm->cm.type, nss_qvpn_log_message_types_str[ncm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ncm, ncm->cm.type, nss_qvpn_log_message_types_str[ncm->cm.type]); + nss_qvpn_log_verbose(ncm); + } + +@@ -233,26 +233,26 @@ void nss_qvpn_log_tx_msg(struct nss_qvpn + void nss_qvpn_log_rx_msg(struct nss_qvpn_msg *ncm) + { + if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ncm); ++ nss_warning("%px: Invalid response\n", ncm); + return; + } + + if (ncm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ncm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, + nss_qvpn_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response]); + goto verbose; + } + + if (ncm->cm.error >= NSS_QVPN_ERROR_TYPE_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ncm, ncm->cm.type, nss_qvpn_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ncm, ncm->cm.type, nss_qvpn_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error, nss_qvpn_log_error_response_types_str[ncm->cm.error]); +--- a/nss_rmnet_rx.c ++++ b/nss_rmnet_rx.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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 +@@ -70,7 +70,7 @@ static void nss_rmnet_rx_msg_handler(str + * Sanity check the message type + */ + if (ncm->type > NSS_RMNET_RX_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return; + } + +@@ -82,7 +82,7 @@ static void nss_rmnet_rx_msg_handler(str + } + + if (!nss_rmnet_rx_verify_if_num(ncm->interface)) { +- nss_warning("%p: response for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: response for another interface: %d", nss_ctx, ncm->interface); + return; + } + +@@ -91,7 +91,7 @@ static void nss_rmnet_rx_msg_handler(str + spin_lock_bh(&nss_rmnet_rx_lock); + if (!rmnet_rx_handle[if_num]) { + spin_unlock_bh(&nss_rmnet_rx_lock); +- nss_warning("%p: rmnet_rx handle is NULL\n", nss_ctx); ++ nss_warning("%px: rmnet_rx handle is NULL\n", nss_ctx); + return; + } + +@@ -148,7 +148,7 @@ static void nss_rmnet_rx_callback(void * + struct nss_rmnet_rx_pvt *nvip = handle->pvt; + + if (ncm->response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p: rmnet_rx Error response %d\n", handle->nss_ctx, ncm->response); ++ nss_warning("%px: rmnet_rx Error response %d\n", handle->nss_ctx, ncm->response); + nvip->response = NSS_TX_FAILURE; + complete(&nvip->complete); + return; +@@ -174,7 +174,7 @@ static nss_tx_status_t nss_rmnet_rx_tx_m + + status = nss_rmnet_rx_tx_msg(nss_ctx, nvim); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_rmnet_rx_msg failed\n", nss_ctx); ++ nss_warning("%px: nss_rmnet_rx_msg failed\n", nss_ctx); + up(&nwip->sem); + return status; + } +@@ -182,7 +182,7 @@ static nss_tx_status_t nss_rmnet_rx_tx_m + ret = wait_for_completion_timeout(&nwip->complete, + msecs_to_jiffies(NSS_RMNET_RX_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: rmnet_rx tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: rmnet_rx tx failed due to timeout\n", nss_ctx); + nwip->response = NSS_TX_FAILURE; + } + +@@ -219,7 +219,7 @@ static int nss_rmnet_rx_handle_destroy_s + int32_t index_h2n; + + if (!nss_rmnet_rx_verify_if_num(if_num_n2h) || !nss_rmnet_rx_verify_if_num(if_num_h2n)) { +- nss_warning("%p: bad interface numbers %d %d\n", handle->nss_ctx, if_num_n2h, if_num_h2n); ++ nss_warning("%px: bad interface numbers %d %d\n", handle->nss_ctx, if_num_n2h, if_num_h2n); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -228,13 +228,13 @@ static int nss_rmnet_rx_handle_destroy_s + + status = nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status); ++ nss_warning("%px: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status); + return status; + } + + status = nss_dynamic_interface_dealloc_node(if_num_h2n, NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_H2N); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status); ++ nss_warning("%px: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status); + return status; + } + +@@ -260,7 +260,7 @@ static struct nss_rmnet_rx_handle *nss_r + struct nss_rmnet_rx_handle *handle; + + if (!nss_rmnet_rx_verify_if_num(if_num_n2h) || !nss_rmnet_rx_verify_if_num(if_num_h2n)) { +- nss_warning("%p: bad interface numbers %d %d\n", nss_ctx, if_num_n2h, if_num_h2n); ++ nss_warning("%px: bad interface numbers %d %d\n", nss_ctx, if_num_n2h, if_num_h2n); + return NULL; + } + +@@ -270,7 +270,7 @@ static struct nss_rmnet_rx_handle *nss_r + handle = (struct nss_rmnet_rx_handle *)kzalloc(sizeof(struct nss_rmnet_rx_handle), + GFP_KERNEL); + if (!handle) { +- nss_warning("%p: handle memory alloc failed\n", nss_ctx); ++ nss_warning("%px: handle memory alloc failed\n", nss_ctx); + *cmd_rsp = NSS_RMNET_RX_ALLOC_FAILURE; + goto error1; + } +@@ -281,7 +281,7 @@ static struct nss_rmnet_rx_handle *nss_r + handle->pvt = (struct nss_rmnet_rx_pvt *)kzalloc(sizeof(struct nss_rmnet_rx_pvt), + GFP_KERNEL); + if (!handle->pvt) { +- nss_warning("%p: failure allocating memory for nss_rmnet_rx_pvt\n", nss_ctx); ++ nss_warning("%px: failure allocating memory for nss_rmnet_rx_pvt\n", nss_ctx); + *cmd_rsp = NSS_RMNET_RX_ALLOC_FAILURE; + goto error2; + } +@@ -289,7 +289,7 @@ static struct nss_rmnet_rx_handle *nss_r + handle->stats_n2h = (uint64_t *)kzalloc(sizeof(uint64_t) * NSS_RMNET_RX_STATS_MAX, + GFP_KERNEL); + if (!handle->stats_n2h) { +- nss_warning("%p: failure allocating memory for N2H stats\n", nss_ctx); ++ nss_warning("%px: failure allocating memory for N2H stats\n", nss_ctx); + *cmd_rsp = NSS_RMNET_RX_ALLOC_FAILURE; + goto error3; + } +@@ -297,7 +297,7 @@ static struct nss_rmnet_rx_handle *nss_r + handle->stats_h2n = (uint64_t *)kzalloc(sizeof(uint64_t) * NSS_RMNET_RX_STATS_MAX, + GFP_KERNEL); + if (!handle->stats_h2n) { +- nss_warning("%p: failure allocating memory for H2N stats\n", nss_ctx); ++ nss_warning("%px: failure allocating memory for H2N stats\n", nss_ctx); + *cmd_rsp = NSS_RMNET_RX_ALLOC_FAILURE; + goto error4; + } +@@ -337,14 +337,14 @@ static uint32_t nss_rmnet_rx_register_ha + + ret = nss_core_register_handler(nss_ctx, if_num_n2h, nss_rmnet_rx_msg_handler, NULL); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Failed to register message handler for redir_n2h interface %d\n", nss_ctx, if_num_n2h); ++ nss_warning("%px: Failed to register message handler for redir_n2h interface %d\n", nss_ctx, if_num_n2h); + return NSS_RMNET_RX_REG_FAILURE; + } + + ret = nss_core_register_handler(nss_ctx, if_num_h2n, nss_rmnet_rx_msg_handler, NULL); + if (ret != NSS_CORE_STATUS_SUCCESS) { + nss_core_unregister_handler(nss_ctx, if_num_n2h); +- nss_warning("%p: Failed to register message handler for redir_h2n interface %d\n", nss_ctx, if_num_h2n); ++ nss_warning("%px: Failed to register message handler for redir_h2n interface %d\n", nss_ctx, if_num_h2n); + return NSS_RMNET_RX_REG_FAILURE; + } + +@@ -382,14 +382,14 @@ nss_tx_status_t nss_rmnet_rx_destroy_syn + nss_ctx = handle->nss_ctx; + + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: Interface could not be destroyed as core not ready\n", nss_ctx); ++ nss_warning("%px: Interface could not be destroyed as core not ready\n", nss_ctx); + return NSS_TX_FAILURE_NOT_READY; + } + + spin_lock_bh(&nss_top_main.lock); + if (!nss_ctx->subsys_dp_register[if_num_n2h].ndev || !nss_ctx->subsys_dp_register[if_num_h2n].ndev) { + spin_unlock_bh(&nss_top_main.lock); +- nss_warning("%p: Unregister virt interface %d %d: no context\n", nss_ctx, if_num_n2h, if_num_h2n); ++ nss_warning("%px: Unregister virt interface %d %d: no context\n", nss_ctx, if_num_n2h, if_num_h2n); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -402,19 +402,19 @@ nss_tx_status_t nss_rmnet_rx_destroy_syn + + status = nss_rmnet_rx_handle_destroy_sync(handle); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: handle destroy failed for if_num_n2h %d and if_num_h2n %d\n", nss_ctx, if_num_n2h, if_num_h2n); ++ nss_warning("%px: handle destroy failed for if_num_n2h %d and if_num_h2n %d\n", nss_ctx, if_num_n2h, if_num_h2n); + return NSS_TX_FAILURE; + } + + ret = nss_core_unregister_handler(nss_ctx, if_num_n2h); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Not able to unregister handler for redir_n2h interface %d with NSS core\n", nss_ctx, if_num_n2h); ++ nss_warning("%px: Not able to unregister handler for redir_n2h interface %d with NSS core\n", nss_ctx, if_num_n2h); + return NSS_TX_FAILURE_BAD_PARAM; + } + + ret = nss_core_unregister_handler(nss_ctx, if_num_h2n); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Not able to unregister handler for redir_h2n interface %d with NSS core\n", nss_ctx, if_num_h2n); ++ nss_warning("%px: Not able to unregister handler for redir_h2n interface %d with NSS core\n", nss_ctx, if_num_h2n); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -436,26 +436,26 @@ struct nss_rmnet_rx_handle *nss_rmnet_rx + int32_t if_num_n2h, if_num_h2n; + + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: Interface could not be created as core not ready\n", nss_ctx); ++ nss_warning("%px: Interface could not be created as core not ready\n", nss_ctx); + return NULL; + } + + if_num_n2h = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H); + if (if_num_n2h < 0) { +- nss_warning("%p: failure allocating redir_n2h\n", nss_ctx); ++ nss_warning("%px: failure allocating redir_n2h\n", nss_ctx); + return NULL; + } + + if_num_h2n = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_H2N); + if (if_num_h2n < 0) { +- nss_warning("%p: failure allocating redir_h2n\n", nss_ctx); ++ nss_warning("%px: failure allocating redir_h2n\n", nss_ctx); + nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H); + return NULL; + } + + handle = nss_rmnet_rx_handle_create_sync(nss_ctx, if_num_n2h, if_num_h2n, &ret); + if (!handle) { +- nss_warning("%p: rmnet_rx handle creation failed ret %d\n", nss_ctx, ret); ++ nss_warning("%px: rmnet_rx handle creation failed ret %d\n", nss_ctx, ret); + nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H); + nss_dynamic_interface_dealloc_node(if_num_h2n, NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_H2N); + return NULL; +@@ -466,7 +466,7 @@ struct nss_rmnet_rx_handle *nss_rmnet_rx + */ + ret = nss_rmnet_rx_register_handler_sync(nss_ctx, handle); + if (ret != NSS_RMNET_RX_SUCCESS) { +- nss_warning("%p: Registration handler failed reason: %d\n", nss_ctx, ret); ++ nss_warning("%px: Registration handler failed reason: %d\n", nss_ctx, ret); + goto error1; + } + +@@ -481,7 +481,7 @@ struct nss_rmnet_rx_handle *nss_rmnet_rx + + ret = nss_rmnet_rx_tx_msg_sync(handle, &nvim); + if (ret != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_rmnet_rx_tx_msg_sync failed %u\n", nss_ctx, ret); ++ nss_warning("%px: nss_rmnet_rx_tx_msg_sync failed %u\n", nss_ctx, ret); + goto error2; + } + +@@ -492,7 +492,7 @@ struct nss_rmnet_rx_handle *nss_rmnet_rx + + ret = nss_rmnet_rx_tx_msg_sync(handle, &nvim); + if (ret != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_rmnet_rx_tx_msg_sync failed %u\n", nss_ctx, ret); ++ nss_warning("%px: nss_rmnet_rx_tx_msg_sync failed %u\n", nss_ctx, ret); + goto error2; + } + +@@ -544,17 +544,17 @@ nss_tx_status_t nss_rmnet_rx_tx_buf(stru + } + + if (!nss_rmnet_rx_verify_if_num(if_num)) { +- nss_warning("%p: bad interface number %d\n", nss_ctx, if_num); ++ nss_warning("%px: bad interface number %d\n", nss_ctx, if_num); + return NSS_TX_FAILURE_BAD_PARAM; + } + +- nss_trace("%p: RmnetRx packet, if_num:%d, skb:%p", nss_ctx, if_num, skb); ++ nss_trace("%px: RmnetRx packet, if_num:%d, skb:%px", nss_ctx, if_num, skb); + + /* + * Sanity check the SKB to ensure that it's suitable for us + */ + if (unlikely(skb->len <= ETH_HLEN)) { +- nss_warning("%p: Rmnet Rx packet: %p too short", nss_ctx, skb); ++ nss_warning("%px: Rmnet Rx packet: %px too short", nss_ctx, skb); + return NSS_TX_FAILURE_TOO_SHORT; + } + +@@ -580,12 +580,12 @@ nss_tx_status_t nss_rmnet_rx_tx_msg(stru + * Sanity check the message + */ + if (!nss_rmnet_rx_verify_if_num(ncm->interface)) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_RMNET_RX_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -714,7 +714,7 @@ int32_t nss_rmnet_rx_get_ifnum_with_core + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + if (nss_rmnet_rx_verify_if_num(if_num) == false) { +- nss_info("%p: if_num: %u is not RMNET interface\n", nss_ctx, if_num); ++ nss_info("%px: if_num: %u is not RMNET interface\n", nss_ctx, if_num); + return -1; + } + return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); +--- a/nss_rmnet_rx_stats.c ++++ b/nss_rmnet_rx_stats.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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 +@@ -113,13 +113,13 @@ static ssize_t nss_rmnet_rx_stats_read(s + uint64_t *stats_shadow; + char *lbuf = kzalloc(size_al, GFP_KERNEL); + if (unlikely(!lbuf)) { +- nss_warning("%p: Could not allocate memory for local statistics buffer", data); ++ nss_warning("%px: Could not allocate memory for local statistics buffer", data); + return 0; + } + + stats_shadow = kzalloc(NSS_RMNET_RX_STATS_MAX * sizeof(uint64_t), GFP_KERNEL); + if (unlikely(!stats_shadow)) { +- nss_warning("%p: Could not allocate memory for local shadow buffer", data); ++ nss_warning("%px: Could not allocate memory for local shadow buffer", data); + kfree(lbuf); + return 0; + } +@@ -143,7 +143,6 @@ static ssize_t nss_rmnet_rx_stats_read(s + continue; + } + +- + size_wr += nss_stats_print("rmnet_rx", "interface", if_num, + nss_rmnet_rx_stats_str, stats_shadow, NSS_RMNET_RX_STATS_MAX, + lbuf, size_wr, size_al); +--- a/nss_rps.c ++++ b/nss_rps.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2013-2017, 2019 The Linux Foundation. All rights reserved. ++ * Copyright (c) 2013-2017, 2019-2020 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. +@@ -188,12 +188,12 @@ static void nss_rps_cfg_callback(void *a + */ + nss_rps_cfg_pvt.response = NSS_FAILURE; + complete(&nss_rps_cfg_pvt.complete); +- nss_warning("%p: RPS configuration failed : %d\n", nss_ctx, ++ nss_warning("%px: RPS configuration failed : %d\n", nss_ctx, + nnm->cm.error); + return; + } + +- nss_info("%p: RPS configuration succeeded: %d\n", nss_ctx, ++ nss_info("%px: RPS configuration succeeded: %d\n", nss_ctx, + nnm->cm.error); + nss_ctx->rps_en = nnm->msg.rps_cfg.enable; + nss_rps_cfg_pvt.response = NSS_SUCCESS; +@@ -215,12 +215,12 @@ static void nss_rps_pri_map_cfg_callback + */ + nss_rps_cfg_pvt.response = NSS_FAILURE; + complete(&nss_rps_cfg_pvt.complete); +- nss_warning("%p: RPS pri_map configuration failed : %d\n", ++ nss_warning("%px: RPS pri_map configuration failed : %d\n", + app_data, nnm->cm.error); + return; + } + +- nss_info("%p: RPS pri_map configuration succeeded: %d\n", ++ nss_info("%px: RPS pri_map configuration succeeded: %d\n", + app_data, nnm->cm.error); + + nss_rps_cfg_pvt.response = NSS_SUCCESS; +@@ -248,7 +248,7 @@ static nss_tx_status_t nss_rps_cfg(struc + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_tx error setting rps\n", nss_ctx); ++ nss_warning("%px: nss_tx error setting rps\n", nss_ctx); + + up(&nss_rps_cfg_pvt.sem); + return NSS_FAILURE; +@@ -259,7 +259,7 @@ static nss_tx_status_t nss_rps_cfg(struc + */ + ret = wait_for_completion_timeout(&nss_rps_cfg_pvt.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: Waiting for ack timed out\n", nss_ctx); ++ nss_warning("%px: Waiting for ack timed out\n", nss_ctx); + up(&nss_rps_cfg_pvt.sem); + return NSS_FAILURE; + } +@@ -297,7 +297,7 @@ static nss_tx_status_t nss_rps_ipv4_hash + nss_tx_status = nss_ipv4_tx_sync(nss_ctx, &nim); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_tx error setting rps\n", nss_ctx); ++ nss_warning("%px: nss_tx error setting rps\n", nss_ctx); + + up(&nss_rps_cfg_pvt.sem); + return NSS_FAILURE; +@@ -326,7 +326,7 @@ static nss_tx_status_t nss_rps_ipv6_hash + nss_tx_status = nss_ipv6_tx_sync(nss_ctx, &nim); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_tx error setting rps\n", nss_ctx); ++ nss_warning("%px: nss_tx error setting rps\n", nss_ctx); + + up(&nss_rps_cfg_pvt.sem); + return NSS_FAILURE; +@@ -365,7 +365,7 @@ static nss_tx_status_t nss_rps_pri_map_c + nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); + + if (nss_tx_status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_tx error setting rps\n", nss_ctx); ++ nss_warning("%px: nss_tx error setting rps\n", nss_ctx); + + up(&nss_rps_cfg_pvt.sem); + return NSS_FAILURE; +@@ -376,7 +376,7 @@ static nss_tx_status_t nss_rps_pri_map_c + */ + ret = wait_for_completion_timeout(&nss_rps_cfg_pvt.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT)); + if (ret == 0) { +- nss_warning("%p: Waiting for ack timed out\n", nss_ctx); ++ nss_warning("%px: Waiting for ack timed out\n", nss_ctx); + up(&nss_rps_cfg_pvt.sem); + return NSS_FAILURE; + } +@@ -438,7 +438,7 @@ static int nss_rps_cfg_handler(struct ct + * TODO: Flush queues in NSS FW. + */ + if (ret_rps != NSS_SUCCESS) { +- nss_warning("%p: rps enabling failed\n", nss_ctx); ++ nss_warning("%px: rps enabling failed\n", nss_ctx); + nss_rps_config = current_state; + return ret_rps; + } +@@ -474,7 +474,7 @@ static int nss_rps_hash_bitmap_cfg_handl + ret_ipv4 = nss_rps_ipv4_hash_bitmap_cfg(nss_ctx, nss_rps_hash_bitmap); + + if (ret_ipv4 != NSS_SUCCESS) { +- nss_warning("%p: ipv4 hash_bitmap config message failed\n", nss_ctx); ++ nss_warning("%px: ipv4 hash_bitmap config message failed\n", nss_ctx); + nss_rps_hash_bitmap = current_state; + return ret_ipv4; + } +@@ -482,10 +482,10 @@ static int nss_rps_hash_bitmap_cfg_handl + ret_ipv6 = nss_rps_ipv6_hash_bitmap_cfg(nss_ctx, nss_rps_hash_bitmap); + + if (ret_ipv6 != NSS_SUCCESS) { +- nss_warning("%p: ipv6 hash_bitmap config message failed\n", nss_ctx); ++ nss_warning("%px: ipv6 hash_bitmap config message failed\n", nss_ctx); + nss_rps_hash_bitmap = current_state; + if (nss_rps_ipv4_hash_bitmap_cfg(nss_ctx, nss_rps_hash_bitmap != NSS_SUCCESS)) { +- nss_warning("%p: ipv4 and ipv6 have different hash_bitmaps.\n", nss_ctx); ++ nss_warning("%px: ipv4 and ipv6 have different hash_bitmaps.\n", nss_ctx); + } + return ret_ipv6; + } +@@ -526,7 +526,7 @@ static int nss_rps_pri_map_cfg_handler(s + ret_pri_map = nss_rps_pri_map_cfg(nss_ctx, nss_rps_pri_map); + if (ret_pri_map != NSS_SUCCESS) { + nss_rps_pri_map[current_state.pri] = current_state.core; +- nss_warning("%p: pri_map config message failed\n", nss_ctx); ++ nss_warning("%px: pri_map config message failed\n", nss_ctx); + } + + return ret_pri_map; +--- a/nss_shaper.c ++++ b/nss_shaper.c +@@ -23,7 +23,7 @@ + void *nss_shaper_register_shaping(void) + { + if (nss_top_main.shaping_handler_id == (uint8_t)-1) { +- nss_warning("%p: SHAPING IS NOT ENABLED", __func__); ++ nss_warning("%px: SHAPING IS NOT ENABLED", __func__); + return NULL; + } + return (void *)&nss_top_main.nss[nss_top_main.shaping_handler_id]; +@@ -46,7 +46,7 @@ void *nss_shaper_register_shaper_bounce_ + struct nss_top_instance *nss_top = &nss_top_main; + struct nss_shaper_bounce_registrant *reg; + +- nss_info("Shaper bounce interface register: %u, cb: %p, app_data: %p, owner: %p", ++ nss_info("Shaper bounce interface register: %u, cb: %px, app_data: %px, owner: %px", + if_num, cb, app_data, owner); + + /* +@@ -61,7 +61,7 @@ void *nss_shaper_register_shaper_bounce_ + * Shaping enabled? + */ + if (nss_top_main.shaping_handler_id == (uint8_t)-1) { +- nss_warning("%p: SHAPING IS NOT ENABLED", __func__); ++ nss_warning("%px: SHAPING IS NOT ENABLED", __func__); + return NULL; + } + +@@ -69,7 +69,7 @@ void *nss_shaper_register_shaper_bounce_ + * Can we hold the module? + */ + if (!try_module_get(owner)) { +- nss_warning("%p: Unable to hold owner", __func__); ++ nss_warning("%px: Unable to hold owner", __func__); + return NULL; + } + +@@ -151,7 +151,7 @@ void *nss_shaper_register_shaper_bounce_ + struct nss_ctx_instance *nss_ctx; + struct nss_shaper_bounce_registrant *reg; + +- nss_info("Shaper bounce bridge register: %u, cb: %p, app_data: %p, owner: %p", ++ nss_info("Shaper bounce bridge register: %u, cb: %px, app_data: %px, owner: %px", + if_num, cb, app_data, owner); + + /* +@@ -166,7 +166,7 @@ void *nss_shaper_register_shaper_bounce_ + * Shaping enabled? + */ + if (nss_top_main.shaping_handler_id == (uint8_t)-1) { +- nss_warning("%p: SHAPING IS NOT ENABLED", __func__); ++ nss_warning("%px: SHAPING IS NOT ENABLED", __func__); + return NULL; + } + +@@ -174,7 +174,7 @@ void *nss_shaper_register_shaper_bounce_ + * Can we hold the module? + */ + if (!try_module_get(owner)) { +- nss_warning("%p: Unable to hold owner", __func__); ++ nss_warning("%px: Unable to hold owner", __func__); + return NULL; + } + +@@ -277,7 +277,6 @@ nss_tx_status_t nss_shaper_bounce_interf + BUG_ON(false); + } + +- + /* + * Must have existing registrant + */ +@@ -334,7 +333,7 @@ nss_tx_status_t nss_shaper_bounce_bridge + } + spin_unlock_bh(&nss_top->lock); + +- nss_info("%s: Bridge bounce skb: %p, if_num: %u, ctx: %p", __func__, skb, if_num, nss_ctx); ++ nss_info("%s: Bridge bounce skb: %px, if_num: %u, ctx: %px", __func__, skb, if_num, nss_ctx); + status = nss_core_send_buffer(nss_ctx, if_num, skb, NSS_IF_H2N_DATA_QUEUE, + H2N_BUFFER_SHAPER_BOUNCE_BRIDGE, 0); + if (status != NSS_CORE_STATUS_SUCCESS) { +--- a/nss_sjack.c ++++ b/nss_sjack.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014-2018, 2020, 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. +@@ -40,12 +40,12 @@ static void nss_sjack_handler(struct nss + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_SJACK_MAX_MSG_TYPE) { +- nss_warning("%p: received invalid message %d for sjack interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for sjack interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_sjack_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -54,7 +54,7 @@ static void nss_sjack_handler(struct nss + * to the same callback/app_data. + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + } + + /* +@@ -104,12 +104,12 @@ nss_tx_status_t nss_sjack_tx_msg(struct + * Sanity check the message + */ + if (ncm->interface != NSS_SJACK_INTERFACE) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_SJACK_MAX_MSG_TYPE) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -123,13 +123,18 @@ struct nss_ctx_instance *nss_sjack_regis + nss_sjack_msg_callback_t event_callback) + { + struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.sjack_handler_id]; ++ uint32_t status; + + nss_assert(nss_ctx); + nss_assert(if_num == NSS_SJACK_INTERFACE); + + nss_core_register_subsys_dp(nss_ctx, if_num, NULL, NULL, NULL, netdev, 0); + +- nss_top_main.if_rx_msg_callback[if_num] = event_callback; ++ status = nss_core_register_msg_handler(nss_ctx, NSS_SJACK_INTERFACE, event_callback); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to register handler for interface %d with NSS core\n", nss_ctx, if_num); ++ return NULL; ++ } + + return nss_ctx; + } +@@ -140,12 +145,18 @@ struct nss_ctx_instance *nss_sjack_regis + void nss_sjack_unregister_if(uint32_t if_num) + { + struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.sjack_handler_id]; ++ uint32_t status; + + nss_assert(nss_ctx); + nss_assert(if_num == NSS_SJACK_INTERFACE); + + nss_core_unregister_subsys_dp(nss_ctx, if_num); +- nss_top_main.if_rx_msg_callback[if_num] = NULL; ++ ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: Not able to unregister handler for interface %d with NSS core\n", nss_ctx, if_num); ++ return; ++ } + + return; + } +--- a/nss_sjack_log.c ++++ b/nss_sjack_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -38,7 +38,7 @@ static int8_t *nss_sjack_log_message_typ + static void nss_sjack_log_configure_msg(struct nss_sjack_msg *nsm) + { + struct nss_sjack_configure_msg *nscm __maybe_unused = &nsm->msg.configure; +- nss_trace("%p: NSS SJACK Configure message \n" ++ nss_trace("%px: NSS SJACK Configure message \n" + "SJACK Ingress Interface Number: %d\n" + "SJACK Engress Interface Number: %d\n" + "SJACK Tunnel ID: %d\n" +@@ -59,7 +59,7 @@ static void nss_sjack_log_configure_msg( + static void nss_sjack_log_unconfigure_msg(struct nss_sjack_msg *nsm) + { + struct nss_sjack_unconfigure_msg *nsum __maybe_unused = &nsm->msg.unconfigure; +- nss_trace("%p: NSS SJACK UnConfigure message \n" ++ nss_trace("%px: NSS SJACK UnConfigure message \n" + "SJACK Ingress Interface Number: %d\n", + nsum, nsum->ingress_if_num); + } +@@ -86,7 +86,7 @@ static void nss_sjack_log_verbose(struct + break; + + default: +- nss_trace("%p: Invalid message type\n", nsm); ++ nss_trace("%px: Invalid message type\n", nsm); + break; + } + } +@@ -98,11 +98,11 @@ static void nss_sjack_log_verbose(struct + void nss_sjack_log_tx_msg(struct nss_sjack_msg *nsm) + { + if (nsm->cm.type >= NSS_SJACK_MAX_MSG_TYPE) { +- nss_warning("%p: Invalid message type\n", nsm); ++ nss_warning("%px: Invalid message type\n", nsm); + return; + } + +- nss_info("%p: type[%d]:%s\n", nsm, nsm->cm.type, nss_sjack_log_message_types_str[nsm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nsm, nsm->cm.type, nss_sjack_log_message_types_str[nsm->cm.type]); + nss_sjack_log_verbose(nsm); + } + +@@ -113,18 +113,18 @@ void nss_sjack_log_tx_msg(struct nss_sja + void nss_sjack_log_rx_msg(struct nss_sjack_msg *nsm) + { + if (nsm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nsm); ++ nss_warning("%px: Invalid response\n", nsm); + return; + } + + if (nsm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nsm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nsm, nsm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nsm, nsm->cm.type, + nss_sjack_log_message_types_str[nsm->cm.type], + nsm->cm.response, nss_cmn_response_str[nsm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + nsm, nsm->cm.type, nss_sjack_log_message_types_str[nsm->cm.type], + nsm->cm.response, nss_cmn_response_str[nsm->cm.response]); + +--- a/nss_tls.c ++++ b/nss_tls.c +@@ -152,18 +152,18 @@ static void nss_tls_handler(struct nss_c + + NSS_VERIFY_CTX_MAGIC(nss_ctx); + +- nss_trace("%p: handle event for interface num :%u", nss_ctx, ncm->interface); ++ nss_trace("%px: handle event for interface num :%u", nss_ctx, ncm->interface); + + /* + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_TLS_MSG_MAX) { +- nss_warning("%p:Bad message type(%d) for TLS interface %d", nss_ctx, ncm->type, ncm->interface); ++ nss_warning("%px:Bad message type(%d) for TLS interface %d", nss_ctx, ncm->type, ncm->interface); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_tls_msg)) { +- nss_warning("%p:Bad message length(%d)", nss_ctx, ncm->len); ++ nss_warning("%px:Bad message length(%d)", nss_ctx, ncm->len); + return; + } + +@@ -174,7 +174,7 @@ static void nss_tls_handler(struct nss_c + * Update the callback and app_data for NOTIFY messages + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_top_main.if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; + } + +@@ -198,11 +198,11 @@ static void nss_tls_handler(struct nss_c + * Call TLS session callback + */ + if (!cb) { +- nss_warning("%p: No callback for tls session interface %d", nss_ctx, ncm->interface); ++ nss_warning("%px: No callback for tls session interface %d", nss_ctx, ncm->interface); + return; + } + +- nss_trace("%p: calling tlsmgr event handler(%u)", nss_ctx, ncm->interface); ++ nss_trace("%px: calling tlsmgr event handler(%u)", nss_ctx, ncm->interface); + cb(app_data, ncm); + } + +@@ -242,7 +242,7 @@ nss_tx_status_t nss_tls_tx_buf(struct sk + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: tx_data packet dropped as core not ready", nss_ctx); ++ nss_warning("%px: tx_data packet dropped as core not ready", nss_ctx); + return NSS_TX_FAILURE_NOT_READY; + } + +@@ -252,11 +252,11 @@ nss_tx_status_t nss_tls_tx_buf(struct sk + break; + + case NSS_CORE_STATUS_FAILURE_QUEUE: /* queue full condition */ +- nss_warning("%p: H2N queue full for tx_buf", nss_ctx); ++ nss_warning("%px: H2N queue full for tx_buf", nss_ctx); + return NSS_TX_FAILURE_QUEUE; + + default: +- nss_warning("%p: general failure for tx_buf", nss_ctx); ++ nss_warning("%px: general failure for tx_buf", nss_ctx); + return NSS_TX_FAILURE; + } + +@@ -278,12 +278,12 @@ nss_tx_status_t nss_tls_tx_msg(struct ns + struct nss_cmn_msg *ncm = &msg->cm; + + if (ncm->type >= NSS_TLS_MSG_MAX) { +- nss_warning("%p: tls message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: tls message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + + if (!nss_tls_verify_ifnum(nss_ctx, ncm->interface)) { +- nss_warning("%p: tls message interface is bad: %u", nss_ctx, ncm->interface); ++ nss_warning("%px: tls message interface is bad: %u", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + +@@ -312,7 +312,7 @@ nss_tx_status_t nss_tls_tx_msg_sync(stru + * Length of the message should be the based on type + */ + if (len > sizeof(struct nss_tls_msg)) { +- nss_warning("%p: Invalid message length(%u), type (%d), I/F(%u)\n", nss_ctx, len, type, if_num); ++ nss_warning("%px: Invalid message length(%u), type (%d), I/F(%u)\n", nss_ctx, len, type, if_num); + return NSS_TX_FAILURE; + } + +@@ -329,13 +329,13 @@ nss_tx_status_t nss_tls_tx_msg_sync(stru + + status = nss_tls_tx_msg(nss_ctx, local_ntcm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Failed to send message\n", nss_ctx); ++ nss_warning("%px: Failed to send message\n", nss_ctx); + goto done; + } + + ret = wait_for_completion_timeout(&tls_pvt.complete, msecs_to_jiffies(NSS_TLS_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: Failed to receive response, timeout(%d)\n", nss_ctx, ret); ++ nss_warning("%px: Failed to receive response, timeout(%d)\n", nss_ctx, ret); + status = NSS_TX_FAILURE_NOT_READY; + goto done; + } +@@ -363,7 +363,6 @@ done: + } + EXPORT_SYMBOL(nss_tls_tx_msg_sync); + +- + /* + * nss_tls_notify_register() + * Register a handler for notification from NSS firmware. +@@ -377,11 +376,16 @@ struct nss_ctx_instance *nss_tls_notify_ + + ret = nss_core_register_handler(nss_ctx, if_num, nss_tls_handler, app_data); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: unable to register event handler for interface(%u)", nss_ctx, if_num); ++ nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); + return NULL; + } + +- nss_top_main.if_rx_msg_callback[if_num] = ev_cb; ++ ret = nss_core_register_msg_handler(nss_ctx, if_num, ev_cb); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_core_unregister_handler(nss_ctx, if_num); ++ nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); ++ return NULL; ++ } + + return nss_ctx; + } +@@ -398,13 +402,17 @@ void nss_tls_notify_unregister(uint32_t + + BUG_ON(!nss_ctx); + +- ret = nss_core_unregister_handler(nss_ctx, if_num); ++ ret = nss_core_unregister_msg_handler(nss_ctx, if_num); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: unable to un register event handler for interface(%u)", nss_ctx, if_num); ++ nss_warning("%px: unable to un register event handler for interface(%u)", nss_ctx, if_num); + return; + } + +- nss_top_main.if_rx_msg_callback[if_num] = NULL; ++ ret = nss_core_unregister_handler(nss_ctx, if_num); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: unable to un register event handler for interface(%u)", nss_ctx, if_num); ++ return; ++ } + + return; + } +@@ -426,12 +434,12 @@ struct nss_ctx_instance *nss_tls_registe + uint32_t ret; + + if (!nss_tls_verify_ifnum(nss_ctx, if_num)) { +- nss_warning("%p: TLS Interface is not dynamic:%u", nss_ctx, if_num); ++ nss_warning("%px: TLS Interface is not dynamic:%u", nss_ctx, if_num); + return NULL; + } + + if (nss_ctx->subsys_dp_register[if_num].ndev) { +- nss_warning("%p: Cannot find free slot for TLS NSS I/F:%u", nss_ctx, if_num); ++ nss_warning("%px: Cannot find free slot for TLS NSS I/F:%u", nss_ctx, if_num); + return NULL; + } + +@@ -440,11 +448,16 @@ struct nss_ctx_instance *nss_tls_registe + + ret = nss_core_register_handler(nss_ctx, if_num, nss_tls_handler, app_data); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: unable to register event handler for interface(%u)", nss_ctx, if_num); ++ nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); + return NULL; + } + +- nss_top_main.if_rx_msg_callback[if_num] = ev_cb; ++ ret = nss_core_register_msg_handler(nss_ctx, if_num, ev_cb); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_core_unregister_handler(nss_ctx, if_num); ++ nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); ++ return NULL; ++ } + + /* + * Atomically set the bitmap for the interface number +@@ -461,9 +474,10 @@ EXPORT_SYMBOL(nss_tls_register_if); + void nss_tls_unregister_if(uint32_t if_num) + { + struct nss_ctx_instance *nss_ctx = nss_tls_get_context(); ++ uint32_t ret; + + if (!nss_ctx->subsys_dp_register[if_num].ndev) { +- nss_warning("%p: Cannot find registered netdev for TLS NSS I/F:%u", nss_ctx, if_num); ++ nss_warning("%px: Cannot find registered netdev for TLS NSS I/F:%u", nss_ctx, if_num); + return; + } + +@@ -472,8 +486,13 @@ void nss_tls_unregister_if(uint32_t if_n + */ + clear_bit(if_num, tls_pvt.if_map); + ++ ret = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (ret != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: unable to un register event handler for interface(%u)", nss_ctx, if_num); ++ return; ++ } ++ + nss_core_unregister_handler(nss_ctx, if_num); +- nss_top_main.if_rx_msg_callback[if_num] = NULL; + + nss_core_unregister_subsys_dp(nss_ctx, if_num); + } +--- a/nss_tls_log.c ++++ b/nss_tls_log.c +@@ -63,7 +63,7 @@ static int8_t *nss_tls_log_error_respons + */ + static void nss_tls_node_config_msg(struct nss_tls_msg *ntm) + { +- nss_trace("%p: NSS TLS Node Configure Message:\n" ++ nss_trace("%px: NSS TLS Node Configure Message:\n" + "TLS Interface: %d\n", ntm, ntm->cm.interface); + } + +@@ -74,7 +74,7 @@ static void nss_tls_node_config_msg(stru + static void nss_tls_ctx_config_msg(struct nss_tls_msg *ntm) + { + struct nss_tls_ctx_config *ntccm __maybe_unused = &ntm->msg.ctx_cfg; +- nss_trace("%p: NSS TLS Context Configure Message:\n" ++ nss_trace("%px: NSS TLS Context Configure Message:\n" + "TLS Except if_num: %d\n", + ntccm, ntccm->except_ifnum); + } +@@ -86,7 +86,7 @@ static void nss_tls_ctx_config_msg(struc + static void nss_tls_cipher_update_msg(struct nss_tls_msg *ntm) + { + struct nss_tls_cipher_update *ntcum __maybe_unused = &ntm->msg.cipher_update; +- nss_trace("%p: NSS TLS Cipher Update message\n" ++ nss_trace("%px: NSS TLS Cipher Update message\n" + "TLS crypto index: %d\n", + ntcum, ntcum->crypto_idx); + } +@@ -111,7 +111,7 @@ static void nss_tls_log_verbose(struct n + break; + + default: +- nss_warning("%p: Invalid message type\n", ntm); ++ nss_warning("%px: Invalid message type\n", ntm); + break; + } + } +@@ -123,11 +123,11 @@ static void nss_tls_log_verbose(struct n + void nss_tls_log_tx_msg(struct nss_tls_msg *ntm) + { + if (ntm->cm.type >= NSS_TLS_MSG_MAX) { +- nss_warning("%p: Invalid message type\n", ntm); ++ nss_warning("%px: Invalid message type\n", ntm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ntm, ntm->cm.type, nss_tls_log_message_types_str[ntm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ntm, ntm->cm.type, nss_tls_log_message_types_str[ntm->cm.type]); + nss_tls_log_verbose(ntm); + } + +@@ -138,26 +138,26 @@ void nss_tls_log_tx_msg(struct nss_tls_m + void nss_tls_log_rx_msg(struct nss_tls_msg *ntm) + { + if (ntm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ntm); ++ nss_warning("%px: Invalid response\n", ntm); + return; + } + + if (ntm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ntm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, + nss_tls_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); + goto verbose; + } + + if (ntm->cm.error >= NSS_TLS_ERROR_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ntm, ntm->cm.type, nss_tls_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response], + ntm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ntm, ntm->cm.type, nss_tls_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response], + ntm->cm.error, nss_tls_log_error_response_types_str[ntm->cm.error]); +--- a/nss_trustsec_tx.c ++++ b/nss_trustsec_tx.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016-2018, 2020 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. +@@ -31,7 +31,7 @@ static struct nss_trustsec_tx_pvt { + + /* + * nss_trustsec_tx_handler() +- * Handle NSS -> HLOS messages for trustsec_tx ++ * Handle NSS -> HLOS messages for trustsec_tx + */ + static void nss_trustsec_tx_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, + __attribute__((unused))void *app_data) +@@ -49,13 +49,13 @@ static void nss_trustsec_tx_handler(stru + /* + * Is this a valid request/response packet? + */ +- if (ncm->type >= NSS_TRUSTSEC_TX_MAX_MSG_TYPE) { +- nss_warning("%p: received invalid message %d for trustsec_tx interface", nss_ctx, ncm->type); ++ if (ncm->type >= NSS_TRUSTSEC_TX_MSG_MAX) { ++ nss_warning("%px: received invalid message %d for trustsec_tx interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_trustsec_tx_msg)) { +- nss_warning("%p: message size incorrect: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: message size incorrect: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -65,7 +65,7 @@ static void nss_trustsec_tx_handler(stru + nss_core_log_msg_failures(nss_ctx, ncm); + + switch (ncm->type) { +- case NSS_TRUSTSEC_TX_STATS_SYNC_MSG: ++ case NSS_TRUSTSEC_TX_MSG_STATS_SYNC: + /* + * Update trustsec_tx statistics. + */ +@@ -78,7 +78,7 @@ static void nss_trustsec_tx_handler(stru + * to the same callback/app_data. + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].ndev; + } + +@@ -99,7 +99,7 @@ static void nss_trustsec_tx_handler(stru + + /* + * nss_trustsec_tx_msg() +- * Transmit a trustsec_tx message to NSSFW ++ * Transmit a trustsec_tx message to NSSFW + */ + nss_tx_status_t nss_trustsec_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_trustsec_tx_msg *msg) + { +@@ -114,12 +114,12 @@ nss_tx_status_t nss_trustsec_tx_msg(stru + * Sanity check the message + */ + if (ncm->interface != NSS_TRUSTSEC_TX_INTERFACE) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + +- if (ncm->type > NSS_TRUSTSEC_TX_MAX_MSG_TYPE) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ if (ncm->type > NSS_TRUSTSEC_TX_MSG_MAX) { ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -160,14 +160,14 @@ nss_tx_status_t nss_trustsec_tx_msg_sync + + status = nss_trustsec_tx_msg(nss_ctx, msg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_trustsec_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: nss_trustsec_tx_msg failed\n", nss_ctx); + up(&ttx.sem); + return status; + } + + ret = wait_for_completion_timeout(&ttx.complete, msecs_to_jiffies(NSS_TRUSTSEC_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: trustsec_tx tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: trustsec_tx tx failed due to timeout\n", nss_ctx); + ttx.response = NSS_TX_FAILURE; + } + +@@ -200,28 +200,55 @@ void nss_trustsec_tx_msg_init(struct nss + EXPORT_SYMBOL(nss_trustsec_tx_msg_init); + + /* ++ * nss_trustsec_tx_update_nexthop() ++ */ ++nss_tx_status_t nss_trustsec_tx_update_nexthop(uint32_t src, uint32_t dest, uint16_t sgt) ++{ ++ struct nss_ctx_instance *ctx = nss_trustsec_tx_get_ctx(); ++ struct nss_trustsec_tx_msg ttx_msg = {{0}}; ++ struct nss_trustsec_tx_update_nexthop_msg *ttxunh; ++ nss_tx_status_t status; ++ ++ ttxunh = &ttx_msg.msg.upd_nexthop; ++ ttxunh->src = src; ++ ttxunh->dest = dest; ++ ttxunh->sgt = sgt; ++ ++ nss_trustsec_tx_msg_init(&ttx_msg, NSS_TRUSTSEC_TX_INTERFACE, NSS_TRUSTSEC_TX_MSG_UPDATE_NEXTHOP, ++ sizeof(*ttxunh), NULL, NULL); ++ ++ BUG_ON(in_atomic()); ++ status = nss_trustsec_tx_msg_sync(ctx, &ttx_msg); ++ if (status != NSS_TX_SUCCESS) { ++ nss_warning("%px: configure trustsec_tx failed: %d\n", ctx, status); ++ } ++ ++ return status; ++} ++EXPORT_SYMBOL(nss_trustsec_tx_update_nexthop); ++ ++/* + * nss_trustsec_tx_configure_sgt() + */ + nss_tx_status_t nss_trustsec_tx_configure_sgt(uint32_t src, uint32_t dest, uint16_t sgt) + { + struct nss_ctx_instance *ctx = nss_trustsec_tx_get_ctx(); +- struct nss_trustsec_tx_msg ttx_msg; ++ struct nss_trustsec_tx_msg ttx_msg = {{0}}; + struct nss_trustsec_tx_configure_msg *ttxcfg; + nss_tx_status_t status; + +- memset(&ttx_msg, 0, sizeof(struct nss_trustsec_tx_msg)); + ttxcfg = &ttx_msg.msg.configure; + ttxcfg->src = src; + ttxcfg->dest = dest; + ttxcfg->sgt = sgt; + +- nss_trustsec_tx_msg_init(&ttx_msg, NSS_TRUSTSEC_TX_INTERFACE, NSS_TRUSTSEC_TX_CONFIGURE_MSG, +- sizeof(struct nss_trustsec_tx_configure_msg), +- NULL, NULL); ++ nss_trustsec_tx_msg_init(&ttx_msg, NSS_TRUSTSEC_TX_INTERFACE, NSS_TRUSTSEC_TX_MSG_CONFIGURE, ++ sizeof(*ttxcfg), NULL, NULL); + ++ BUG_ON(in_atomic()); + status = nss_trustsec_tx_msg_sync(ctx, &ttx_msg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: configure trustsec_tx failed: %d\n", ctx, status); ++ nss_warning("%px: configure trustsec_tx failed: %d\n", ctx, status); + } + + return status; +@@ -234,22 +261,21 @@ EXPORT_SYMBOL(nss_trustsec_tx_configure_ + nss_tx_status_t nss_trustsec_tx_unconfigure_sgt(uint32_t src, uint16_t sgt) + { + struct nss_ctx_instance *ctx = nss_trustsec_tx_get_ctx(); +- struct nss_trustsec_tx_msg ttx_msg; ++ struct nss_trustsec_tx_msg ttx_msg = {{0}}; + struct nss_trustsec_tx_unconfigure_msg *ttxucfg; + nss_tx_status_t status; + +- memset(&ttx_msg, 0, sizeof(struct nss_trustsec_tx_msg)); + ttxucfg = &ttx_msg.msg.unconfigure; + ttxucfg->src = src; + ttxucfg->sgt = sgt; + +- nss_trustsec_tx_msg_init(&ttx_msg, NSS_TRUSTSEC_TX_INTERFACE, NSS_TRUSTSEC_TX_UNCONFIGURE_MSG, +- sizeof(struct nss_trustsec_tx_unconfigure_msg), +- NULL, NULL); ++ nss_trustsec_tx_msg_init(&ttx_msg, NSS_TRUSTSEC_TX_INTERFACE, NSS_TRUSTSEC_TX_MSG_UNCONFIGURE, ++ sizeof(*ttxucfg), NULL, NULL); + ++ BUG_ON(in_atomic()); + status = nss_trustsec_tx_msg_sync(ctx, &ttx_msg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: unconfigure trustsec_tx failed: %d\n", ctx, status); ++ nss_warning("%px: unconfigure trustsec_tx failed: %d\n", ctx, status); + } + + return status; +--- a/nss_trustsec_tx_log.c ++++ b/nss_trustsec_tx_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020 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. +@@ -25,10 +25,11 @@ + * nss_trustsec_tx_log_message_types_str + * TRUSTSEC_TX message strings + */ +-static int8_t *nss_trustsec_tx_log_message_types_str[NSS_TRUSTSEC_TX_MAX_MSG_TYPE] __maybe_unused = { ++static int8_t *nss_trustsec_tx_log_message_types_str[NSS_TRUSTSEC_TX_MSG_MAX] __maybe_unused = { + "TRUSTSEC_TX Configure Message", + "TRUSTSEC_TX Unconfigure Message", + "TRUSTSEC_TX Stats Sync", ++ "TRUSTSEC_TX Update next Hop", + }; + + /* +@@ -40,6 +41,7 @@ static int8_t *nss_trustsec_tx_log_error + "TRUSTSEC_TX Reconfigure Source Interface" + "TRUSTSEC_TX Destination Interface Not Found", + "TRUSTSEC_TX Not Configured", ++ "TRUSTSEC_TX SGT Mismatch", + "TRUSTSEC_TX Unknown Error", + }; + +@@ -50,7 +52,7 @@ static int8_t *nss_trustsec_tx_log_error + static void nss_trustsec_tx_log_configure_msg(struct nss_trustsec_tx_msg *ntm) + { + struct nss_trustsec_tx_configure_msg *ntcm __maybe_unused = &ntm->msg.configure; +- nss_trace("%p: NSS TRUSTSEC_TX Configure Message:\n" ++ nss_trace("%px: NSS TRUSTSEC_TX Configure Message:\n" + "TRUSTSEC_TX Source: %d\n" + "TRUSTSEC_TX Destination: %d\n" + "TRUSTSEC_TX Security Group Tag: %d\n", +@@ -65,35 +67,54 @@ static void nss_trustsec_tx_log_configur + static void nss_trustsec_tx_log_unconfigure_msg(struct nss_trustsec_tx_msg *ntm) + { + struct nss_trustsec_tx_unconfigure_msg *ntcm __maybe_unused = &ntm->msg.unconfigure; +- nss_trace("%p: NSS TRUSTSEC_TX Unconfigure Message:\n" ++ nss_trace("%px: NSS TRUSTSEC_TX Unconfigure Message:\n" + "TRUSTSEC_TX Source: %d\n" + "TRUSTSEC_TX Security Group Tag: %d\n", + ntcm, ntcm->src, ntcm->sgt); + } + + /* ++ * nss_trustsec_tx_log_update_nexthop_msg() ++ * Log NSS TRUSTSEC_TX update nexthop message. ++ */ ++static void nss_trustsec_tx_log_update_nexthop_msg(struct nss_trustsec_tx_msg *ntm) ++{ ++ struct nss_trustsec_tx_update_nexthop_msg *ntunm __maybe_unused = &ntm->msg.upd_nexthop; ++ nss_trace("%px: NSS TRUSTSEC_TX Update Next Hop Message:\n" ++ "TRUSTSEC_TX Source: %d\n" ++ "TRUSTSEC_TX Destination: %d\n" ++ "TRUSTSEC_TX Security Group Tag: %d\n", ++ ntunm, ntunm->src, ++ ntunm->dest, ntunm->sgt); ++} ++ ++/* + * nss_trustsec_tx_log_verbose() + * Log message contents. + */ + static void nss_trustsec_tx_log_verbose(struct nss_trustsec_tx_msg *ntm) + { + switch (ntm->cm.type) { +- case NSS_TRUSTSEC_TX_CONFIGURE_MSG: ++ case NSS_TRUSTSEC_TX_MSG_CONFIGURE: + nss_trustsec_tx_log_configure_msg(ntm); + break; + +- case NSS_TRUSTSEC_TX_UNCONFIGURE_MSG: ++ case NSS_TRUSTSEC_TX_MSG_UNCONFIGURE: + nss_trustsec_tx_log_unconfigure_msg(ntm); + break; + +- case NSS_TRUSTSEC_TX_STATS_SYNC_MSG: ++ case NSS_TRUSTSEC_TX_MSG_UPDATE_NEXTHOP: ++ nss_trustsec_tx_log_update_nexthop_msg(ntm); ++ break; ++ ++ case NSS_TRUSTSEC_TX_MSG_STATS_SYNC: + /* + * No log for valid stats message. + */ + break; + + default: +- nss_warning("%p: Invalid message type\n", ntm); ++ nss_warning("%px: Invalid message type\n", ntm); + break; + } + } +@@ -104,12 +125,12 @@ static void nss_trustsec_tx_log_verbose( + */ + void nss_trustsec_tx_log_tx_msg(struct nss_trustsec_tx_msg *ntm) + { +- if (ntm->cm.type >= NSS_TRUSTSEC_TX_MAX_MSG_TYPE) { +- nss_warning("%p: Invalid message type\n", ntm); ++ if (ntm->cm.type >= NSS_TRUSTSEC_TX_MSG_MAX) { ++ nss_warning("%px: Invalid message type\n", ntm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ntm, ntm->cm.type, nss_trustsec_tx_log_message_types_str[ntm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ntm, ntm->cm.type, nss_trustsec_tx_log_message_types_str[ntm->cm.type]); + nss_trustsec_tx_log_verbose(ntm); + } + +@@ -120,26 +141,26 @@ void nss_trustsec_tx_log_tx_msg(struct n + void nss_trustsec_tx_log_rx_msg(struct nss_trustsec_tx_msg *ntm) + { + if (ntm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ntm); ++ nss_warning("%px: Invalid response\n", ntm); + return; + } + + if (ntm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ntm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, + nss_trustsec_tx_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); + goto verbose; + } + + if (ntm->cm.error >= NSS_TRUSTSEC_TX_ERR_UNKNOWN) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ntm, ntm->cm.type, nss_trustsec_tx_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response], + ntm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ntm, ntm->cm.type, nss_trustsec_tx_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response], + ntm->cm.error, nss_trustsec_tx_log_error_response_types_str[ntm->cm.error]); +--- a/nss_tstamp.c ++++ b/nss_tstamp.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2015-2020, 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. +@@ -80,7 +80,6 @@ static bool nss_tstamp_verify_if_num(uin + return (if_num == NSS_TSTAMP_TX_INTERFACE) || (if_num == NSS_TSTAMP_RX_INTERFACE); + } + +- + /* + * nss_tstamp_interface_handler() + * Handle NSS -> HLOS messages for TSTAMP Statistics +@@ -92,7 +91,7 @@ static void nss_tstamp_interface_handler + nss_tstamp_msg_callback_t cb; + + if (!nss_tstamp_verify_if_num(ncm->interface)) { +- nss_warning("%p: invalid interface %d for tstamp_tx", nss_ctx, ncm->interface); ++ nss_warning("%px: invalid interface %d for tstamp_tx", nss_ctx, ncm->interface); + return; + } + +@@ -100,12 +99,12 @@ static void nss_tstamp_interface_handler + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_TSTAMP_MSG_TYPE_MAX) { +- nss_warning("%p: received invalid message %d for tstamp", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for tstamp", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_tstamp_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -119,7 +118,7 @@ static void nss_tstamp_interface_handler + nss_tstamp_stats_sync(nss_ctx, &ntm->msg.stats, ncm->interface); + break; + default: +- nss_warning("%p: Unknown message type %d", ++ nss_warning("%px: Unknown message type %d", + nss_ctx, ncm->type); + return; + } +@@ -208,7 +207,7 @@ static struct net_device *nss_tstamp_get + break; + + default: +- nss_warning("%p:could not get dev for the skb\n", skb); ++ nss_warning("%px:could not get dev for the skb\n", skb); + return NULL; + } + +@@ -322,7 +321,7 @@ nss_tx_status_t nss_tstamp_tx_buf(struct + char *align_data; + uint32_t hdr_sz; + +- nss_trace("%p: Tstamp If Tx packet, id:%d, data=%p", nss_ctx, NSS_TSTAMP_RX_INTERFACE, skb->data); ++ nss_trace("%px: Tstamp If Tx packet, id:%d, data=%px", nss_ctx, NSS_TSTAMP_RX_INTERFACE, skb->data); + + /* + * header size + alignment size +@@ -340,7 +339,7 @@ nss_tx_status_t nss_tstamp_tx_buf(struct + if (skb->end - skb->tail >= extra_head) + extra_tail = -extra_head; + if (pskb_expand_head(skb, extra_head, extra_tail, GFP_KERNEL)) { +- nss_trace("%p: expand head room failed", nss_ctx); ++ nss_trace("%px: expand head room failed", nss_ctx); + return NSS_TX_FAILURE; + } + } +@@ -356,7 +355,6 @@ nss_tx_status_t nss_tstamp_tx_buf(struct + } + EXPORT_SYMBOL(nss_tstamp_tx_buf); + +- + /* + * nss_tstamp_register_netdev() + * register dummy netdevice for tstamp interface +--- a/nss_tun6rd.c ++++ b/nss_tun6rd.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014-2018, 2020, 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. +@@ -39,12 +39,12 @@ static void nss_tun6rd_handler(struct ns + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_TUN6RD_MAX) { +- nss_warning("%p: received invalid message %d for Tun6RD interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for Tun6RD interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_tun6rd_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -78,7 +78,7 @@ static void nss_tun6rd_handler(struct ns + * call 6rd tunnel callback + */ + if (!ctx) { +- nss_warning("%p: Event received for 6rd tunnel interface %d before registration", nss_ctx, ncm->interface); ++ nss_warning("%px: Event received for 6rd tunnel interface %d before registration", nss_ctx, ncm->interface); + return; + } + +@@ -102,12 +102,12 @@ nss_tx_status_t nss_tun6rd_tx(struct nss + * Sanity check the message + */ + if (!nss_is_dynamic_interface(ncm->interface)) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_TUN6RD_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +--- a/nss_tun6rd_log.c ++++ b/nss_tun6rd_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018-2020, 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. +@@ -38,7 +38,7 @@ static int8_t *nss_tun6rd_log_message_ty + static void nss_tun6rd_log_attach_pnode_msg(struct nss_tun6rd_msg *ntm) + { + struct nss_tun6rd_attach_tunnel_msg *ntam __maybe_unused = &ntm->msg.tunnel; +- nss_trace("%p: NSS TUN6RD Attach Tunnel message \n" ++ nss_trace("%px: NSS TUN6RD Attach Tunnel message \n" + "TUN6RD Source Address: %pI4\n" + "TUN6RD Destination Address: %pI4\n" + "TUN6RD Type of Service: %d\n" +@@ -56,7 +56,7 @@ static void nss_tun6rd_log_attach_pnode_ + static void nss_tun6rd_log_set_peer_msg(struct nss_tun6rd_msg *ntm) + { + struct nss_tun6rd_set_peer_msg *ntspm __maybe_unused = &ntm->msg.peer; +- nss_trace("%p: NSS TUN6RD Set Peer message \n" ++ nss_trace("%px: NSS TUN6RD Set Peer message \n" + "TUN6RD IPv6 Address: %pI6\n" + "TUN6RD Destination: %pI4\n", + ntspm, ntspm->ipv6_address, +@@ -85,7 +85,7 @@ static void nss_tun6rd_log_verbose(struc + break; + + default: +- nss_trace("%p: Invalid message type\n", ntm); ++ nss_trace("%px: Invalid message type\n", ntm); + break; + } + } +@@ -97,11 +97,11 @@ static void nss_tun6rd_log_verbose(struc + void nss_tun6rd_log_tx_msg(struct nss_tun6rd_msg *ntm) + { + if (ntm->cm.type >= NSS_TUN6RD_MAX) { +- nss_warning("%p: Invalid message type\n", ntm); ++ nss_warning("%px: Invalid message type\n", ntm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ntm, ntm->cm.type, nss_tun6rd_log_message_types_str[ntm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ntm, ntm->cm.type, nss_tun6rd_log_message_types_str[ntm->cm.type]); + nss_tun6rd_log_verbose(ntm); + } + +@@ -112,18 +112,18 @@ void nss_tun6rd_log_tx_msg(struct nss_tu + void nss_tun6rd_log_rx_msg(struct nss_tun6rd_msg *ntm) + { + if (ntm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ntm); ++ nss_warning("%px: Invalid response\n", ntm); + return; + } + + if (ntm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ntm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, + nss_tun6rd_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + ntm, ntm->cm.type, nss_tun6rd_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); + +--- a/nss_tunipip6.c ++++ b/nss_tunipip6.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014-2018, 2020, 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. +@@ -17,6 +17,19 @@ + #include "nss_tx_rx_common.h" + #include "nss_tunipip6_log.h" + ++#define NSS_TUNIPIP6_TX_TIMEOUT 3000 ++ ++/* ++ * Data structure used to handle sync message. ++ */ ++static struct nss_tunipip6_pvt { ++ struct semaphore sem; /* Semaphore structure. */ ++ struct completion complete; /* Completion structure. */ ++ int response; /* Response from FW. */ ++ void *cb; /* Original cb for msgs. */ ++ void *app_data; /* Original app_data for msgs. */ ++} tunipip6_pvt; ++ + /* + * nss_tunipip6_verify_if_num + * Verify the interface is a valid interface +@@ -57,12 +70,12 @@ static void nss_tunipip6_handler(struct + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_TUNIPIP6_MAX) { +- nss_warning("%p: received invalid message %d for DS-Lite interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for DS-Lite interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_tunipip6_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -96,7 +109,7 @@ static void nss_tunipip6_handler(struct + * call ipip6 tunnel callback + */ + if (!ctx) { +- nss_warning("%p: Event received for DS-Lite tunnel interface %d before registration", nss_ctx, ncm->interface); ++ nss_warning("%px: Event received for DS-Lite tunnel interface %d before registration", nss_ctx, ncm->interface); + return; + } + +@@ -120,12 +133,12 @@ nss_tx_status_t nss_tunipip6_tx(struct n + * Sanity check the message + */ + if (!nss_tunipip6_verify_if_num(ncm->interface)) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_TUNIPIP6_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -134,6 +147,60 @@ nss_tx_status_t nss_tunipip6_tx(struct n + EXPORT_SYMBOL(nss_tunipip6_tx); + + /* ++ * nss_tunipip6_callback() ++ * Callback to handle the completion of NSS->HLOS messages. ++ */ ++static void nss_tunipip6_callback(void *app_data, struct nss_tunipip6_msg *nclm) ++{ ++ tunipip6_pvt.response = NSS_TX_SUCCESS; ++ tunipip6_pvt.cb = NULL; ++ tunipip6_pvt.app_data = NULL; ++ ++ if (nclm->cm.response != NSS_CMN_RESPONSE_ACK) { ++ nss_warning("%px: tunipip6 Error response %d Error: %d\n", app_data, nclm->cm.response, nclm->cm.error); ++ tunipip6_pvt.response = nclm->cm.response; ++ } ++ ++ /* ++ * Write memory barrier. ++ */ ++ smp_wmb(); ++ complete(&tunipip6_pvt.complete); ++} ++ ++/* ++ * nss_tunipip6_tx_sync() ++ * Transmit a tunipip6 message to NSSFW synchronously. ++ */ ++nss_tx_status_t nss_tunipip6_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *msg) ++{ ++ nss_tx_status_t status; ++ int ret; ++ ++ down(&tunipip6_pvt.sem); ++ msg->cm.cb = (nss_ptr_t)nss_tunipip6_callback; ++ msg->cm.app_data = (nss_ptr_t)NULL; ++ ++ status = nss_tunipip6_tx(nss_ctx, msg); ++ if (status != NSS_TX_SUCCESS) { ++ nss_warning("%px: tunipip6_tx_msg failed\n", nss_ctx); ++ up(&tunipip6_pvt.sem); ++ return status; ++ } ++ ++ ret = wait_for_completion_timeout(&tunipip6_pvt.complete, msecs_to_jiffies(NSS_TUNIPIP6_TX_TIMEOUT)); ++ if (!ret) { ++ nss_warning("%px: tunipip6 tx sync failed due to timeout\n", nss_ctx); ++ tunipip6_pvt.response = NSS_TX_FAILURE; ++ } ++ ++ status = tunipip6_pvt.response; ++ up(&tunipip6_pvt.sem); ++ return status; ++} ++EXPORT_SYMBOL(nss_tunipip6_tx_sync); ++ ++/* + * ********************************** + * Register/Unregister/Miscellaneous APIs + * ********************************** +@@ -197,6 +264,8 @@ void nss_tunipip6_register_handler() + struct nss_ctx_instance *nss_ctx = nss_tunipip6_get_context(); + + nss_core_register_handler(nss_ctx, NSS_TUNIPIP6_INTERFACE, nss_tunipip6_handler, NULL); ++ sema_init(&tunipip6_pvt.sem, 1); ++ init_completion(&tunipip6_pvt.complete); + } + + /* +--- a/nss_tunipip6_log.c ++++ b/nss_tunipip6_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -26,47 +26,63 @@ + * NSS TUNIPIP6 message strings + */ + static int8_t *nss_tunipip6_log_message_types_str[NSS_TUNIPIP6_MAX] __maybe_unused = { +- "TUNIPIP6 Interface Create", ++ "TUNIPIP6 Encap Interface Create", ++ "TUNIPIP6 Decap Interface Create", + "TUNIPIP6 Stats", ++ "TUNIPIP6 FMR add", ++ "TUNIPIP6 FMR delete", ++ "TUNIPIP6 FMR flush", ++ "TUNIPIP6 BMR add", ++ "TUNIPIP6 BMR delete", + }; + + /* ++ * nss_tunipip6_log_map_rule() ++ * Log NSS TUNIPIP6 map rule. ++ */ ++static void nss_tunipip6_log_map_rule(struct nss_tunipip6_msg *ntm) ++{ ++ struct nss_tunipip6_map_rule *nmr __maybe_unused = &ntm->msg.map_rule; ++ nss_trace("%px: NSS TUNIPIP6 Interface Create message \n" ++ "TUNIPIP6 Map Rule IPv6 prefix: %pI6\n" ++ "TUNIPIP6 Map Rule IPv6 prefix length: %d\n" ++ "TUNIPIP6 Map Rule IPv4 prefix: %pI4\n" ++ "TUNIPIP6 Map Rule IPv4 prefix length: %d\n" ++ "TUNIPIP6 Map Rule IPv6 suffix: %pI6\n" ++ "TUNIPIP6 Map Rule IPv6 suffix length: %d\n" ++ "TUNIPIP6 Map Rule EA length: %d\n" ++ "TUNIPIP6 Map Rule PSID offset: %d\n", ++ nmr, nmr->ip6_prefix, ++ nmr->ip6_prefix_len,&nmr->ip4_prefix, ++ nmr->ip4_prefix_len, nmr->ip6_suffix, ++ nmr->ip6_suffix_len, nmr->ea_len, ++ nmr->psid_offset); ++} ++ ++/* + * nss_tunipip6_log_if_create_msg() + * Log NSS TUNIPIP6 Interface Create + */ + static void nss_tunipip6_log_if_create_msg(struct nss_tunipip6_msg *ntm) + { + struct nss_tunipip6_create_msg *ntcm __maybe_unused = &ntm->msg.tunipip6_create; - int32_t i; -- int count; -- char *lbuf; -- -- ifmap = nss_dtls_cmn_ifmap_get(); -- count = bitmap_weight(ifmap, NSS_MAX_NET_INTERFACES); -- if (count) { -- size_al = size_al * count; -- } -- -- lbuf = vzalloc(size_al); -- if (unlikely(!lbuf)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return -ENOMEM; -- } -- -- stats_shadow = vzalloc(NSS_DTLS_CMN_CTX_STATS_MAX * 8); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- vfree(lbuf); -- return -ENOMEM; -- } -- +- nss_trace("%p: NSS TUNIPIP6 Interface Create message \n" ++ nss_trace("%px: NSS TUNIPIP6 Interface Create message \n" + "TUNIPIP6 Source Address: %pI6\n" + "TUNIPIP6 Destination Address: %pI6\n" + "TUNIPIP6 Flow Label: %d\n" + "TUNIPIP6 Flags: %d\n" + "TUNIPIP6 Hop Limit: %d\n" + "TUNIPIP6 Draft03 Specification: %d\n" +- "TUNIPIP6 FMR Number: %d\n", ++ "TUNIPIP6 TTL inherit: %s\n" ++ "TUNIPIP6 TOS inherit: %s\n" ++ "TUNIPIP6 Frag ID Update: %s\n", + ntcm, ntcm->saddr, + ntcm->daddr, ntcm->flowlabel, + ntcm->flags, ntcm->hop_limit, +- ntcm->draft03, ntcm->fmr_number); - /* -- * Common node stats for each DTLS dynamic interface. +- * Continuation of the log. - */ -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "dtls_cmn stats", NSS_STATS_SINGLE_CORE); -- for_each_set_bit(if_num, ifmap, NSS_MAX_NET_INTERFACES) { -- -- type = nss_dynamic_interface_get_type(nss_ctx, if_num); -- if ((type != NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_INNER) && -- (type != NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_OUTER)) { -- continue; -- } -- -- spin_lock_bh(&nss_dtls_cmn_stats_lock); -- for (i = 0; i < NSS_DTLS_CMN_CTX_STATS_MAX; i++) { -- stats_shadow[i] = nss_dtls_cmn_ctx_stats[if_num][i]; -- } -- spin_unlock_bh(&nss_dtls_cmn_stats_lock); -- -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n%s if_num:%03u\n", -- nss_dtls_cmn_stats_iface_type(type), if_num); -- size_wr += nss_stats_print("dtls_cmn", NULL, NSS_STATS_SINGLE_INSTANCE, nss_dtls_cmn_ctx_stats_str, -- stats_shadow, NSS_DTLS_CMN_CTX_STATS_MAX, lbuf, size_wr, size_al); +- for (i = 0; i < NSS_TUNIPIP6_MAX_FMR_NUMBER; i++) { +- nss_trace("TUNIPIP6 FMR[%d] IPv6 Prefix: %pI6\n" +- "TUNIPIP6 FMR[%d] IPv4 Prefix: %pI4\n" +- "TUNIPIP6 FMR[%d] IPv6 Prefix Length: %d\n" +- "TUNIPIP6 FMR[%d] IPv4 Prefix Length: %d\n" +- "TUNIPIP6 FMR[%d] Embedded Address Length: %d\n" +- "TUNIPIP6 FMR[%d] offset: %d", +- i, ntcm->fmr[i].ip6_prefix, +- i, &ntcm->fmr[i].ip4_prefix, +- i, ntcm->fmr[i].ip6_prefix_len, +- i, ntcm->fmr[i].ip4_prefix_len, +- i, ntcm->fmr[i].ea_len, +- i, ntcm->fmr[i].offset); - } ++ ntcm->draft03, ++ ntcm->ttl_inherit ? "true":"false", ++ ntcm->tos_inherit ? "true":"false", ++ ntcm->frag_id_update ? "true":"false"); + } + + /* +@@ -87,8 +103,17 @@ static void nss_tunipip6_log_verbose(str + */ + break; + ++ case NSS_TUNIPIP6_BMR_RULE_ADD: ++ case NSS_TUNIPIP6_BMR_RULE_DEL: ++ case NSS_TUNIPIP6_FMR_RULE_ADD: ++ case NSS_TUNIPIP6_FMR_RULE_DEL: ++ nss_tunipip6_log_map_rule(ntm); ++ break; ++ case NSS_TUNIPIP6_FMR_RULE_FLUSH: ++ nss_trace("%px: FMR rule flush.\n", ntm); ++ break; + default: +- nss_trace("%p: Invalid message type\n", ntm); ++ nss_trace("%px: Invalid message type\n", ntm); + break; + } + } +@@ -100,11 +125,11 @@ static void nss_tunipip6_log_verbose(str + void nss_tunipip6_log_tx_msg(struct nss_tunipip6_msg *ntm) + { + if (ntm->cm.type >= NSS_TUNIPIP6_MAX) { +- nss_warning("%p: Invalid message type\n", ntm); ++ nss_warning("%px: Invalid message type\n", ntm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ntm, ntm->cm.type, nss_tunipip6_log_message_types_str[ntm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ntm, ntm->cm.type, nss_tunipip6_log_message_types_str[ntm->cm.type]); + nss_tunipip6_log_verbose(ntm); + } + +@@ -115,18 +140,18 @@ void nss_tunipip6_log_tx_msg(struct nss_ + void nss_tunipip6_log_rx_msg(struct nss_tunipip6_msg *ntm) + { + if (ntm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ntm); ++ nss_warning("%px: Invalid response\n", ntm); + return; + } + + if (ntm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ntm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, + nss_tunipip6_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + ntm, ntm->cm.type, nss_tunipip6_log_message_types_str[ntm->cm.type], + ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); + +--- a/nss_tx_msg_sync.c ++++ b/nss_tx_msg_sync.c +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018-2020, 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 +@@ -101,7 +101,7 @@ static nss_tx_status_t nss_tx_msg_sync_i + status = tx_msg_async_with_size(nss_ctx, ncm, msg_buf_size); + + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Tx msg async failed\n", nss_ctx); ++ nss_warning("%px: Tx msg async failed\n", nss_ctx); + return status; + } + +@@ -110,7 +110,7 @@ static nss_tx_status_t nss_tx_msg_sync_i + */ + ret = wait_for_completion_timeout(&sync_data->complete, msecs_to_jiffies(timeout)); + if (!ret) { +- nss_warning("%p: Tx msg sync timeout\n", nss_ctx); ++ nss_warning("%px: Tx msg sync timeout\n", nss_ctx); + return NSS_TX_FAILURE_SYNC_TIMEOUT; + } + +@@ -144,7 +144,7 @@ nss_tx_status_t nss_tx_msg_sync(struct n + * Check Tx msg async API + */ + if (!unlikely(tx_msg_async)) { +- nss_warning("%p: missing Tx msg async API\n", nss_ctx); ++ nss_warning("%px: missing Tx msg async API\n", nss_ctx); + return NSS_TX_FAILURE_SYNC_BAD_PARAM; + } + +@@ -178,7 +178,7 @@ nss_tx_status_t nss_tx_msg_sync_with_siz + * Check Tx msg async API + */ + if (!unlikely(tx_msg_async_with_size)) { +- nss_warning("%p: missing Tx msg async API\n", nss_ctx); ++ nss_warning("%px: missing Tx msg async API\n", nss_ctx); + return NSS_TX_FAILURE_SYNC_BAD_PARAM; + } + +--- a/nss_unaligned.c ++++ b/nss_unaligned.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2017-2020, 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. +@@ -57,12 +57,12 @@ static void nss_unaligned_msg_handler(st + * Sanity checks on message + */ + if (um->cm.type >= NSS_UNALIGNED_MSG_MAX) { +- nss_warning("%p: message type out of range: %d\n", nss_ctx, um->cm.type); ++ nss_warning("%px: message type out of range: %d\n", nss_ctx, um->cm.type); + return; + } + + if (nss_cmn_get_msg_len(&(um->cm)) > sizeof(struct nss_unaligned_msg)) { +- nss_warning("%p: message length is invalid: %d\n", nss_ctx, nss_cmn_get_msg_len(&(um->cm))); ++ nss_warning("%px: message length is invalid: %d\n", nss_ctx, nss_cmn_get_msg_len(&(um->cm))); + return; + } + +--- a/nss_unaligned_log.c ++++ b/nss_unaligned_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -43,7 +43,7 @@ static void nss_unaligned_log_verbose(st + break; + + default: +- nss_trace("%p: Invalid message type\n", um); ++ nss_trace("%px: Invalid message type\n", um); + break; + } + } +@@ -55,18 +55,18 @@ static void nss_unaligned_log_verbose(st + void nss_unaligned_log_rx_msg(struct nss_unaligned_msg *um) + { + if (um->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", um); ++ nss_warning("%px: Invalid response\n", um); + return; + } + + if (um->cm.response == NSS_CMN_RESPONSE_NOTIFY || (um->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", um, um->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", um, um->cm.type, + nss_unaligned_log_message_types_str[um->cm.type], + um->cm.response, nss_cmn_response_str[um->cm.response]); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", + um, um->cm.type, nss_unaligned_log_message_types_str[um->cm.type], + um->cm.response, nss_cmn_response_str[um->cm.response]); + +--- a/nss_virt_if.c ++++ b/nss_virt_if.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014-2020, 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. +@@ -77,7 +77,7 @@ static void nss_virt_if_msg_handler(stru + * Sanity check the message type + */ + if (ncm->type > NSS_VIRT_IF_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return; + } + +@@ -89,7 +89,7 @@ static void nss_virt_if_msg_handler(stru + } + + if (!nss_virt_if_verify_if_num(ncm->interface)) { +- nss_warning("%p: response for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: response for another interface: %d", nss_ctx, ncm->interface); + return; + } + +@@ -98,7 +98,7 @@ static void nss_virt_if_msg_handler(stru + spin_lock_bh(&nss_virt_if_lock); + if (!nss_virt_if_handle_t[if_num]) { + spin_unlock_bh(&nss_virt_if_lock); +- nss_warning("%p: virt_if handle is NULL\n", nss_ctx); ++ nss_warning("%px: virt_if handle is NULL\n", nss_ctx); + return; + } + +@@ -121,7 +121,7 @@ static void nss_virt_if_msg_handler(stru + * to the same callback/app_data. + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].ndev; + } + +@@ -149,7 +149,7 @@ static void nss_virt_if_callback(void *a + struct nss_virt_if_pvt *nvip = handle->pvt; + + if (ncm->response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p: virt_if Error response %d\n", handle->nss_ctx, ncm->response); ++ nss_warning("%px: virt_if Error response %d\n", handle->nss_ctx, ncm->response); + nvip->response = NSS_TX_FAILURE; + complete(&nvip->complete); + return; +@@ -175,7 +175,7 @@ static nss_tx_status_t nss_virt_if_tx_ms + + status = nss_virt_if_tx_msg(nss_ctx, nvim); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_virt_if_msg failed\n", nss_ctx); ++ nss_warning("%px: nss_virt_if_msg failed\n", nss_ctx); + up(&nwip->sem); + return status; + } +@@ -183,7 +183,7 @@ static nss_tx_status_t nss_virt_if_tx_ms + ret = wait_for_completion_timeout(&nwip->complete, + msecs_to_jiffies(NSS_VIRT_IF_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: virt_if tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: virt_if tx failed due to timeout\n", nss_ctx); + nwip->response = NSS_TX_FAILURE; + } + +@@ -220,7 +220,7 @@ static int nss_virt_if_handle_destroy_sy + int32_t index_h2n; + + if (!nss_virt_if_verify_if_num(if_num_n2h) || !nss_virt_if_verify_if_num(if_num_h2n)) { +- nss_warning("%p: bad interface numbers %d %d\n", handle->nss_ctx, if_num_n2h, if_num_h2n); ++ nss_warning("%px: bad interface numbers %d %d\n", handle->nss_ctx, if_num_n2h, if_num_h2n); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -229,13 +229,13 @@ static int nss_virt_if_handle_destroy_sy + + status = nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status); ++ nss_warning("%px: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status); + return status; + } + + status = nss_dynamic_interface_dealloc_node(if_num_h2n, NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status); ++ nss_warning("%px: Dynamic interface destroy failed status %d\n", handle->nss_ctx, status); + return status; + } + +@@ -261,7 +261,7 @@ static struct nss_virt_if_handle *nss_vi + struct nss_virt_if_handle *handle; + + if (!nss_virt_if_verify_if_num(if_num_n2h) || !nss_virt_if_verify_if_num(if_num_h2n)) { +- nss_warning("%p: bad interface numbers %d %d\n", nss_ctx, if_num_n2h, if_num_h2n); ++ nss_warning("%px: bad interface numbers %d %d\n", nss_ctx, if_num_n2h, if_num_h2n); + return NULL; + } + +@@ -271,7 +271,7 @@ static struct nss_virt_if_handle *nss_vi + handle = (struct nss_virt_if_handle *)kzalloc(sizeof(struct nss_virt_if_handle), + GFP_KERNEL); + if (!handle) { +- nss_warning("%p: handle memory alloc failed\n", nss_ctx); ++ nss_warning("%px: handle memory alloc failed\n", nss_ctx); + *cmd_rsp = NSS_VIRT_IF_ALLOC_FAILURE; + goto error1; + } +@@ -282,7 +282,7 @@ static struct nss_virt_if_handle *nss_vi + handle->pvt = (struct nss_virt_if_pvt *)kzalloc(sizeof(struct nss_virt_if_pvt), + GFP_KERNEL); + if (!handle->pvt) { +- nss_warning("%p: failure allocating memory for nss_virt_if_pvt\n", nss_ctx); ++ nss_warning("%px: failure allocating memory for nss_virt_if_pvt\n", nss_ctx); + *cmd_rsp = NSS_VIRT_IF_ALLOC_FAILURE; + goto error2; + } +@@ -318,14 +318,14 @@ static uint32_t nss_virt_if_register_han + + ret = nss_core_register_handler(nss_ctx, if_num_n2h, nss_virt_if_msg_handler, NULL); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Failed to register message handler for redir_n2h interface %d\n", nss_ctx, if_num_n2h); ++ nss_warning("%px: Failed to register message handler for redir_n2h interface %d\n", nss_ctx, if_num_n2h); + return NSS_VIRT_IF_CORE_FAILURE; + } + + ret = nss_core_register_handler(nss_ctx, if_num_h2n, nss_virt_if_msg_handler, NULL); + if (ret != NSS_CORE_STATUS_SUCCESS) { + nss_core_unregister_handler(nss_ctx, if_num_n2h); +- nss_warning("%p: Failed to register message handler for redir_h2n interface %d\n", nss_ctx, if_num_h2n); ++ nss_warning("%px: Failed to register message handler for redir_h2n interface %d\n", nss_ctx, if_num_h2n); + return NSS_VIRT_IF_CORE_FAILURE; + } + +@@ -354,26 +354,26 @@ struct nss_virt_if_handle *nss_virt_if_c + int32_t if_num_n2h, if_num_h2n; + + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: Interface could not be created as core not ready\n", nss_ctx); ++ nss_warning("%px: Interface could not be created as core not ready\n", nss_ctx); + return NULL; + } + + if_num_n2h = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H); + if (if_num_n2h < 0) { +- nss_warning("%p: failure allocating redir_n2h\n", nss_ctx); ++ nss_warning("%px: failure allocating redir_n2h\n", nss_ctx); + return NULL; + } + + if_num_h2n = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N); + if (if_num_h2n < 0) { +- nss_warning("%p: failure allocating redir_h2n\n", nss_ctx); ++ nss_warning("%px: failure allocating redir_h2n\n", nss_ctx); + nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H); + return NULL; + } + + handle = nss_virt_if_handle_create_sync(nss_ctx, if_num_n2h, if_num_h2n, &ret); + if (!handle) { +- nss_warning("%p: virt_if handle creation failed ret %d\n", nss_ctx, ret); ++ nss_warning("%px: virt_if handle creation failed ret %d\n", nss_ctx, ret); + nss_dynamic_interface_dealloc_node(if_num_n2h, NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H); + nss_dynamic_interface_dealloc_node(if_num_h2n, NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N); + return NULL; +@@ -384,7 +384,7 @@ struct nss_virt_if_handle *nss_virt_if_c + */ + ret = nss_virt_if_register_handler_sync(nss_ctx, handle); + if (ret != NSS_VIRT_IF_SUCCESS) { +- nss_warning("%p: Registration handler failed reason: %d\n", nss_ctx, ret); ++ nss_warning("%px: Registration handler failed reason: %d\n", nss_ctx, ret); + goto error1; + } + +@@ -399,7 +399,7 @@ struct nss_virt_if_handle *nss_virt_if_c + + ret = nss_virt_if_tx_msg_sync(handle, &nvim); + if (ret != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_virt_if_tx_msg_sync failed %u\n", nss_ctx, ret); ++ nss_warning("%px: nss_virt_if_tx_msg_sync failed %u\n", nss_ctx, ret); + goto error2; + } + +@@ -409,7 +409,7 @@ struct nss_virt_if_handle *nss_virt_if_c + + ret = nss_virt_if_tx_msg_sync(handle, &nvim); + if (ret != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_virt_if_tx_msg_sync failed %u\n", nss_ctx, ret); ++ nss_warning("%px: nss_virt_if_tx_msg_sync failed %u\n", nss_ctx, ret); + goto error2; + } + +@@ -483,14 +483,14 @@ nss_tx_status_t nss_virt_if_destroy_sync + nss_ctx = handle->nss_ctx; + + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: Interface could not be destroyed as core not ready\n", nss_ctx); ++ nss_warning("%px: Interface could not be destroyed as core not ready\n", nss_ctx); + return NSS_TX_FAILURE_NOT_READY; + } + + spin_lock_bh(&nss_top_main.lock); + if (!nss_ctx->subsys_dp_register[if_num_n2h].ndev || !nss_ctx->subsys_dp_register[if_num_h2n].ndev) { + spin_unlock_bh(&nss_top_main.lock); +- nss_warning("%p: Unregister virt interface %d %d: no context\n", nss_ctx, if_num_n2h, if_num_h2n); ++ nss_warning("%px: Unregister virt interface %d %d: no context\n", nss_ctx, if_num_n2h, if_num_h2n); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -503,19 +503,19 @@ nss_tx_status_t nss_virt_if_destroy_sync + + status = nss_virt_if_handle_destroy_sync(handle); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: handle destroy failed for if_num_n2h %d and if_num_h2n %d\n", nss_ctx, if_num_n2h, if_num_h2n); ++ nss_warning("%px: handle destroy failed for if_num_n2h %d and if_num_h2n %d\n", nss_ctx, if_num_n2h, if_num_h2n); + return NSS_TX_FAILURE; + } + + ret = nss_core_unregister_handler(nss_ctx, if_num_n2h); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Not able to unregister handler for redir_n2h interface %d with NSS core\n", nss_ctx, if_num_n2h); ++ nss_warning("%px: Not able to unregister handler for redir_n2h interface %d with NSS core\n", nss_ctx, if_num_n2h); + return NSS_TX_FAILURE_BAD_PARAM; + } + + ret = nss_core_unregister_handler(nss_ctx, if_num_h2n); + if (ret != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Not able to unregister handler for redir_h2n interface %d with NSS core\n", nss_ctx, if_num_h2n); ++ nss_warning("%px: Not able to unregister handler for redir_h2n interface %d with NSS core\n", nss_ctx, if_num_h2n); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -543,17 +543,17 @@ nss_tx_status_t nss_virt_if_tx_buf(struc + } + + if (!nss_virt_if_verify_if_num(if_num)) { +- nss_warning("%p: bad interface number %d\n", nss_ctx, if_num); ++ nss_warning("%px: bad interface number %d\n", nss_ctx, if_num); + return NSS_TX_FAILURE_BAD_PARAM; + } + +- nss_trace("%p: Virtual Rx packet, if_num:%d, skb:%p", nss_ctx, if_num, skb); ++ nss_trace("%px: Virtual Rx packet, if_num:%d, skb:%px", nss_ctx, if_num, skb); + + /* + * Sanity check the SKB to ensure that it's suitable for us + */ + if (unlikely(skb->len <= ETH_HLEN)) { +- nss_warning("%p: Virtual Rx packet: %p too short", nss_ctx, skb); ++ nss_warning("%px: Virtual Rx packet: %px too short", nss_ctx, skb); + return NSS_TX_FAILURE_TOO_SHORT; + } + +@@ -564,7 +564,8 @@ nss_tx_status_t nss_virt_if_tx_buf(struc + put_cpu(); + skb_set_queue_mapping(skb, cpu); + +- return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER); ++ return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER | ++ H2N_BIT_FLAG_BUFFER_REUSABLE); + } + EXPORT_SYMBOL(nss_virt_if_tx_buf); + +@@ -579,12 +580,12 @@ nss_tx_status_t nss_virt_if_tx_msg(struc + * Sanity check the message + */ + if (!nss_virt_if_verify_if_num(ncm->interface)) { +- nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type > NSS_VIRT_IF_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -656,6 +657,7 @@ void nss_virt_if_register(struct nss_vir + { + struct nss_ctx_instance *nss_ctx; + int32_t if_num; ++ uint32_t status; + + if (!handle) { + nss_warning("handle is NULL\n"); +@@ -673,7 +675,11 @@ void nss_virt_if_register(struct nss_vir + if_num = handle->if_num_n2h; + + nss_core_register_subsys_dp(nss_ctx, if_num, data_callback, NULL, NULL, netdev, (uint32_t)netdev->features); +- nss_top_main.if_rx_msg_callback[if_num] = NULL; ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: unable to unregister event handler for interface(%u)", nss_ctx, if_num); ++ return; ++ } + } + EXPORT_SYMBOL(nss_virt_if_register); + +@@ -684,6 +690,7 @@ void nss_virt_if_unregister(struct nss_v + { + struct nss_ctx_instance *nss_ctx; + int32_t if_num; ++ uint32_t status; + + if (!handle) { + nss_warning("handle is NULL\n"); +@@ -702,7 +709,11 @@ void nss_virt_if_unregister(struct nss_v + + nss_core_unregister_subsys_dp(nss_ctx, if_num); + +- nss_top_main.if_rx_msg_callback[if_num] = NULL; ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: unable to unregister event handler for interface(%u)", nss_ctx, if_num); ++ return; ++ } + } + EXPORT_SYMBOL(nss_virt_if_unregister); + +--- a/nss_vlan.c ++++ b/nss_vlan.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2017-2018, 2020, 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. +@@ -76,12 +76,12 @@ static void nss_vlan_handler(struct nss_ + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_VLAN_MSG_TYPE_MAX) { +- nss_warning("%p: received invalid message %d for vlan interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for vlan interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_vlan_msg)) { +- nss_warning("%p: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -154,12 +154,12 @@ nss_tx_status_t nss_vlan_tx_msg(struct n + * Sanity check the message + */ + if (!nss_vlan_verify_if_num(ncm->interface)) { +- nss_warning("%p: tx request for interface that is not a vlan: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for interface that is not a vlan: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_VLAN_MSG_TYPE_MAX) { +- nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -185,14 +185,14 @@ nss_tx_status_t nss_vlan_tx_msg_sync(str + + status = nss_vlan_tx_msg(nss_ctx, nvm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: vlan_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: vlan_tx_msg failed\n", nss_ctx); + up(&vlan_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&vlan_pvt.complete, msecs_to_jiffies(NSS_VLAN_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: vlan msg tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: vlan msg tx failed due to timeout\n", nss_ctx); + vlan_pvt.response = NSS_TX_FAILURE; + } + +@@ -228,7 +228,7 @@ nss_tx_status_t nss_vlan_tx_set_mtu_msg( + } + + if (nss_vlan_verify_if_num(vlan_if_num) == false) { +- nss_warning("%p: received invalid interface %d", nss_ctx, vlan_if_num); ++ nss_warning("%px: received invalid interface %d", nss_ctx, vlan_if_num); + return NSS_TX_FAILURE; + } + +@@ -258,7 +258,7 @@ nss_tx_status_t nss_vlan_tx_set_mac_addr + } + + if (nss_vlan_verify_if_num(vlan_if_num) == false) { +- nss_warning("%p: received invalid interface %d", nss_ctx, vlan_if_num); ++ nss_warning("%px: received invalid interface %d", nss_ctx, vlan_if_num); + return NSS_TX_FAILURE; + } + +@@ -286,7 +286,7 @@ nss_tx_status_t nss_vlan_tx_vsi_attach_m + } + + if (nss_vlan_verify_if_num(vlan_if_num) == false) { +- nss_warning("%p: received invalid interface %d\n", nss_ctx, vlan_if_num); ++ nss_warning("%px: received invalid interface %d\n", nss_ctx, vlan_if_num); + return NSS_TX_FAILURE; + } + +@@ -313,7 +313,7 @@ nss_tx_status_t nss_vlan_tx_vsi_detach_m + } + + if (nss_vlan_verify_if_num(vlan_if_num) == false) { +- nss_warning("%p: received invalid interface %d\n", nss_ctx, vlan_if_num); ++ nss_warning("%px: received invalid interface %d\n", nss_ctx, vlan_if_num); + return NSS_TX_FAILURE; + } + +@@ -340,7 +340,7 @@ nss_tx_status_t nss_vlan_tx_add_tag_msg( + } + + if (nss_vlan_verify_if_num(vlan_if_num) == false) { +- nss_warning("%p: received invalid interface %d\n", nss_ctx, vlan_if_num); ++ nss_warning("%px: received invalid interface %d\n", nss_ctx, vlan_if_num); + return NSS_TX_FAILURE; + } + +--- a/nss_vlan_log.c ++++ b/nss_vlan_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -44,7 +44,7 @@ static int8_t *nss_vlan_log_error_respon + static void nss_vlan_log_add_tag_msg(struct nss_vlan_msg *nvm) + { + struct nss_vlan_msg_add_tag *nvtm __maybe_unused = &nvm->msg.add_tag; +- nss_trace("%p: NSS VLAN Add Tag Message:\n" ++ nss_trace("%px: NSS VLAN Add Tag Message:\n" + "VLAN Tag: %d\n" + "VLAN Next Hop: %d\n" + "VLAN Interface Number: %d\n", +@@ -64,7 +64,7 @@ static void nss_vlan_log_verbose(struct + break; + + default: +- nss_warning("%p: Invalid message type\n", nvm); ++ nss_warning("%px: Invalid message type\n", nvm); + break; + } + } +@@ -76,11 +76,11 @@ static void nss_vlan_log_verbose(struct + void nss_vlan_log_tx_msg(struct nss_vlan_msg *nvm) + { + if (nvm->cm.type >= NSS_VLAN_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", nvm); ++ nss_warning("%px: Invalid message type\n", nvm); + return; + } + +- nss_info("%p: type[%d]:%s\n", nvm, nvm->cm.type, nss_vlan_log_message_types_str[nvm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nvm, nvm->cm.type, nss_vlan_log_message_types_str[nvm->cm.type]); + nss_vlan_log_verbose(nvm); + } + +@@ -91,26 +91,26 @@ void nss_vlan_log_tx_msg(struct nss_vlan + void nss_vlan_log_rx_msg(struct nss_vlan_msg *nvm) + { + if (nvm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nvm); ++ nss_warning("%px: Invalid response\n", nvm); + return; + } + + if (nvm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nvm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nvm, nvm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nvm, nvm->cm.type, + nss_vlan_log_message_types_str[nvm->cm.type], + nvm->cm.response, nss_cmn_response_str[nvm->cm.response]); + goto verbose; + } + + if (nvm->cm.error >= NSS_VLAN_ERROR_TYPE_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + nvm, nvm->cm.type, nss_vlan_log_message_types_str[nvm->cm.type], + nvm->cm.response, nss_cmn_response_str[nvm->cm.response], + nvm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + nvm, nvm->cm.type, nss_vlan_log_message_types_str[nvm->cm.type], + nvm->cm.response, nss_cmn_response_str[nvm->cm.response], + nvm->cm.error, nss_vlan_log_error_response_types_str[nvm->cm.error]); +--- a/nss_vxlan.c ++++ b/nss_vxlan.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -95,12 +95,12 @@ static void nss_vxlan_msg_handler(struct + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_VXLAN_MSG_TYPE_MAX) { +- nss_warning("%p: received invalid message %d for vxlan interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for vxlan interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_vxlan_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -122,7 +122,7 @@ static void nss_vxlan_msg_handler(struct + * Update the callback for NOTIFY messages + */ + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + } + + cb = (nss_vxlan_msg_callback_t)ncm->cb; +@@ -131,7 +131,7 @@ static void nss_vxlan_msg_handler(struct + * Do we have a callback? + */ + if (!cb) { +- nss_trace("%p: cb is null for interface %d\n", nss_ctx, ncm->interface); ++ nss_trace("%px: cb is null for interface %d\n", nss_ctx, ncm->interface); + return; + } + +@@ -147,12 +147,12 @@ nss_tx_status_t nss_vxlan_tx_msg(struct + struct nss_cmn_msg *ncm = &nvm->cm; + + if (!nss_vxlan_verify_if_num(ncm->interface)) { +- nss_warning("%p: wrong interface number %u\n", nss_ctx, nvm->cm.interface); ++ nss_warning("%px: wrong interface number %u\n", nss_ctx, nvm->cm.interface); + return NSS_TX_FAILURE_BAD_PARAM; + } + + if (ncm->type >= NSS_VXLAN_MSG_TYPE_MAX) { +- nss_warning("%p: wrong message type %u\n", nss_ctx, ncm->type); ++ nss_warning("%px: wrong message type %u\n", nss_ctx, ncm->type); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -183,14 +183,14 @@ nss_tx_status_t nss_vxlan_tx_msg_sync(st + + status = nss_vxlan_tx_msg(nss_ctx, nvm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: vxlan_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: vxlan_tx_msg failed\n", nss_ctx); + up(&nss_vxlan_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&nss_vxlan_pvt.complete, msecs_to_jiffies(NSS_VXLAN_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: vxlan tx sync failed due to timeout\n", nss_ctx); ++ nss_warning("%px: vxlan tx sync failed due to timeout\n", nss_ctx); + nss_vxlan_pvt.response = NSS_TX_FAILURE; + } + +@@ -221,7 +221,7 @@ bool nss_vxlan_unregister_if(uint32_t if + + nss_ctx = nss_vxlan_get_ctx(); + if (!nss_vxlan_verify_if_num(if_num)) { +- nss_warning("%p: data unregister received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: data unregister received for invalid interface %d", nss_ctx, if_num); + return false; + } + +@@ -247,19 +247,25 @@ struct nss_ctx_instance *nss_vxlan_regis + + nss_ctx = nss_vxlan_get_ctx(); + if (!nss_vxlan_verify_if_num(if_num)) { +- nss_warning("%p: data register received for invalid interface %d", nss_ctx, if_num); ++ nss_warning("%px: data register received for invalid interface %d", nss_ctx, if_num); + return NULL; + } + + core_status = nss_core_register_handler(nss_ctx, if_num, nss_vxlan_msg_handler, NULL); + if (core_status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: nss core register handler failed for if_num:%d with error :%d", nss_ctx, if_num, core_status); ++ nss_warning("%px: nss core register handler failed for if_num:%d with error :%d", nss_ctx, if_num, core_status); ++ return NULL; ++ } ++ ++ core_status = nss_core_register_msg_handler(nss_ctx, if_num, notify_cb); ++ if (core_status != NSS_CORE_STATUS_SUCCESS) { ++ nss_core_unregister_handler(nss_ctx, if_num); ++ nss_warning("%px: nss core register handler failed for if_num:%d with error :%d", nss_ctx, if_num, core_status); + return NULL; + } + + nss_core_register_subsys_dp(nss_ctx, if_num, data_cb, NULL, NULL, netdev, features); + nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, type); +- nss_top_main.if_rx_msg_callback[if_num] = (nss_if_rx_msg_callback_t)notify_cb; + return nss_ctx; + } + EXPORT_SYMBOL(nss_vxlan_register_if); +@@ -275,7 +281,7 @@ int nss_vxlan_ifnum_with_core_id(int if_ + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (!nss_vxlan_verify_if_num(if_num)) { +- nss_warning("%p: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); ++ nss_warning("%px: Invalid if_num: %d, must be a dynamic interface\n", nss_ctx, if_num); + return 0; + } + return NSS_INTERFACE_NUM_APPEND_COREID(nss_ctx, if_num); +@@ -304,7 +310,7 @@ void nss_vxlan_init() + uint32_t core_status; + struct nss_ctx_instance *nss_ctx = nss_vxlan_get_ctx(); + if (!nss_ctx) { +- nss_warning("%p: VxLAN is not registered", nss_ctx); ++ nss_warning("%px: VxLAN is not registered", nss_ctx); + return; + } + +@@ -314,7 +320,7 @@ void nss_vxlan_init() + core_status = nss_core_register_handler(nss_ctx, NSS_VXLAN_INTERFACE, nss_vxlan_msg_handler, NULL); + + if (core_status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: nss core register handler failed for if_num:%d with error :%d", nss_ctx, NSS_VXLAN_INTERFACE, core_status); ++ nss_warning("%px: nss core register handler failed for if_num:%d with error :%d", nss_ctx, NSS_VXLAN_INTERFACE, core_status); + } + + } +--- a/nss_vxlan_log.c ++++ b/nss_vxlan_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2019-2020, 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. +@@ -70,7 +70,7 @@ static int8_t *nss_vxlan_log_error_respo + */ + static void nss_vxlan_log_rule_msg(struct nss_vxlan_rule_msg *nvrm) + { +- nss_trace("%p: NSS VXLAN Rule message \n" ++ nss_trace("%px: NSS VXLAN Rule message \n" + "VxLAN Tunnel Flags: %x\n" + "VNET ID: %u\n" + "Flowlabel: %u\n" +@@ -95,9 +95,9 @@ static void nss_vxlan_log_rule_msg(struc + */ + static void nss_vxlan_log_mac_msg(struct nss_vxlan_mac_msg *nvmm) + { +- nss_trace("%p: NSS VXLAN MAC message \n" +- "Encap Rule Src IP: %p\n" +- "Encap Rule Dst Ip: %p\n" ++ nss_trace("%px: NSS VXLAN MAC message \n" ++ "Encap Rule Src IP: %px\n" ++ "Encap Rule Dst Ip: %px\n" + "Vxlan VNet ID: %u\n" + "Vxlan Mac Addr: %pM", + nvmm, +@@ -133,7 +133,7 @@ static void nss_vxlan_log_rule_destroy_m + */ + static void nss_vxlan_log_enable_msg(struct nss_vxlan_msg *nvm) + { +- nss_trace("%p: NSS VXLAN Tunnel state message: Enable \n", nvm); ++ nss_trace("%px: NSS VXLAN Tunnel state message: Enable \n", nvm); + } + + /* +@@ -142,7 +142,7 @@ static void nss_vxlan_log_enable_msg(str + */ + static void nss_vxlan_log_disable_msg(struct nss_vxlan_msg *nvm) + { +- nss_trace("%p: NSS VXLAN Tunnel state message: Disable \n", nvm); ++ nss_trace("%px: NSS VXLAN Tunnel state message: Disable \n", nvm); + } + + /* +@@ -201,7 +201,7 @@ static void nss_vxlan_log_verbose(struct + break; + + default: +- nss_trace("%p: Invalid message type\n", nvm); ++ nss_trace("%px: Invalid message type\n", nvm); + break; + } + } +@@ -213,11 +213,11 @@ static void nss_vxlan_log_verbose(struct + void nss_vxlan_log_tx_msg(struct nss_vxlan_msg *nvm) + { + if (nvm->cm.type >= NSS_VXLAN_MSG_TYPE_MAX) { +- nss_warning("%p: Invalid message type\n", nvm); ++ nss_warning("%px: Invalid message type\n", nvm); + return; + } + +- nss_info("%p: type[%d]:%s\n", nvm, nvm->cm.type, nss_vxlan_log_message_types_str[nvm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nvm, nvm->cm.type, nss_vxlan_log_message_types_str[nvm->cm.type]); + nss_vxlan_log_verbose(nvm); + } + +@@ -228,26 +228,26 @@ void nss_vxlan_log_tx_msg(struct nss_vxl + void nss_vxlan_log_rx_msg(struct nss_vxlan_msg *nvm) + { + if (nvm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nvm); ++ nss_warning("%px: Invalid response\n", nvm); + return; + } + + if (nvm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nvm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nvm, nvm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nvm, nvm->cm.type, + nss_vxlan_log_message_types_str[nvm->cm.type], + nvm->cm.response, nss_cmn_response_str[nvm->cm.response]); + goto verbose; + } + + if (nvm->cm.error >= NSS_VXLAN_ERROR_TYPE_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + nvm, nvm->cm.type, nss_vxlan_log_message_types_str[nvm->cm.type], + nvm->cm.response, nss_cmn_response_str[nvm->cm.response], + nvm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + nvm, nvm->cm.type, nss_vxlan_log_message_types_str[nvm->cm.type], + nvm->cm.response, nss_cmn_response_str[nvm->cm.response], + nvm->cm.error, nss_vxlan_log_error_response_types_str[nvm->cm.error]); +--- a/nss_wifi.c ++++ b/nss_wifi.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2015-2018, 2020, 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. +@@ -37,7 +37,7 @@ static void nss_wifi_handler(struct nss_ + void *ctx; + nss_wifi_msg_callback_t cb; + +- nss_info("%p: NSS ->HLOS message for wifi\n", nss_ctx); ++ nss_info("%px: NSS ->HLOS message for wifi\n", nss_ctx); + + BUG_ON(((ncm->interface < NSS_WIFI_INTERFACE0) || (ncm->interface > NSS_WIFI_INTERFACE2))); + +@@ -50,12 +50,12 @@ static void nss_wifi_handler(struct nss_ + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_WIFI_MAX_MSG) { +- nss_warning("%p: received invalid message %d for wifi interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for wifi interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_wifi_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -88,7 +88,7 @@ static void nss_wifi_handler(struct nss_ + * Do we have a call back + */ + if (!ncm->cb) { +- nss_info("%p: cb null for wifi interface %d", nss_ctx, ncm->interface); ++ nss_info("%px: cb null for wifi interface %d", nss_ctx, ncm->interface); + return; + } + +@@ -102,7 +102,7 @@ static void nss_wifi_handler(struct nss_ + * call wifi msg callback + */ + if (!ctx) { +- nss_warning("%p: Event received for wifi interface %d before registration", nss_ctx, ncm->interface); ++ nss_warning("%px: Event received for wifi interface %d before registration", nss_ctx, ncm->interface); + return; + } + +@@ -123,7 +123,7 @@ nss_tx_status_t nss_wifi_tx_msg(struct n + nss_wifi_log_tx_msg(msg); + + if (ncm->type > NSS_WIFI_MAX_MSG) { +- nss_warning("%p: wifi message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: wifi message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -149,7 +149,7 @@ struct nss_ctx_instance *nss_register_wi + nss_assert(nss_ctx); + nss_assert((if_num >= NSS_MAX_VIRTUAL_INTERFACES) && (if_num < NSS_MAX_NET_INTERFACES)); + +- nss_info("%p: nss_register_wifi_if if_num %d wifictx %p", nss_ctx, if_num, netdev); ++ nss_info("%px: nss_register_wifi_if if_num %d wifictx %px", nss_ctx, if_num, netdev); + + nss_core_register_subsys_dp(nss_ctx, if_num, wifi_callback, wifi_ext_callback, NULL, netdev, features); + +--- a/nss_wifi_if.c ++++ b/nss_wifi_if.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2015-2020, 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. +@@ -56,18 +56,18 @@ static void nss_wifi_if_msg_handler(stru + * Sanity check the message type + */ + if (ncm->type >= NSS_WIFI_IF_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d", ++ nss_warning("%px: message type out of range: %d", + nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_wifi_if_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + + if (!NSS_IS_IF_TYPE(DYNAMIC, ncm->interface)) { +- nss_warning("%p: response for another interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: response for another interface: %d", nss_ctx, ncm->interface); + return; + } + +@@ -81,7 +81,7 @@ static void nss_wifi_if_msg_handler(stru + spin_lock_bh(&wifi_if_lock); + if (!wifi_handle[if_num]) { + spin_unlock_bh(&wifi_if_lock); +- nss_warning("%p: wifi_if handle is NULL\n", nss_ctx); ++ nss_warning("%px: wifi_if handle is NULL\n", nss_ctx); + return; + } + +@@ -156,7 +156,7 @@ static void nss_wifi_if_callback(void *a + struct nss_wifi_if_pvt *nwip = handle->pvt; + + if (ncm->response != NSS_CMN_RESPONSE_ACK) { +- nss_warning("%p: wifi_if Error response %d\n", ++ nss_warning("%px: wifi_if Error response %d\n", + handle->nss_ctx, ncm->response); + nwip->response = NSS_TX_FAILURE; + complete(&nwip->complete); +@@ -176,7 +176,7 @@ nss_tx_status_t nss_wifi_if_tx_msg(struc + struct nss_cmn_msg *ncm = &nwim->cm; + + if (ncm->type > NSS_WIFI_IF_MAX_MSG_TYPES) { +- nss_warning("%p: message type out of range: %d\n", nss_ctx, ncm->type); ++ nss_warning("%px: message type out of range: %d\n", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -199,7 +199,7 @@ static nss_tx_status_t nss_wifi_if_tx_ms + + status = nss_wifi_if_tx_msg(nss_ctx, nwim); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_wifi_if_msg failed\n", nss_ctx); ++ nss_warning("%px: nss_wifi_if_msg failed\n", nss_ctx); + up(&nwip->sem); + return status; + } +@@ -207,7 +207,7 @@ static nss_tx_status_t nss_wifi_if_tx_ms + ret = wait_for_completion_timeout(&nwip->complete, + msecs_to_jiffies(NSS_WIFI_IF_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: wifi_if tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: wifi_if tx failed due to timeout\n", nss_ctx); + nwip->response = NSS_TX_FAILURE; + } + +@@ -243,7 +243,7 @@ static int nss_wifi_if_handle_destroy(st + + status = nss_dynamic_interface_dealloc_node(if_num, NSS_DYNAMIC_INTERFACE_TYPE_WIFI); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Dynamic interface destroy failed status %d\n", nss_ctx, status); ++ nss_warning("%px: Dynamic interface destroy failed status %d\n", nss_ctx, status); + return status; + } + +@@ -266,7 +266,7 @@ static struct nss_wifi_if_handle *nss_wi + + if_num = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_WIFI); + if (if_num < 0) { +- nss_warning("%p:failure allocating wifi if\n", nss_ctx); ++ nss_warning("%px:failure allocating wifi if\n", nss_ctx); + *cmd_rsp = NSS_WIFI_IF_DYNAMIC_IF_FAILURE; + return NULL; + } +@@ -276,7 +276,7 @@ static struct nss_wifi_if_handle *nss_wi + handle = (struct nss_wifi_if_handle *)kzalloc(sizeof(struct nss_wifi_if_handle), + GFP_KERNEL); + if (!handle) { +- nss_warning("%p: handle memory alloc failed\n", nss_ctx); ++ nss_warning("%px: handle memory alloc failed\n", nss_ctx); + *cmd_rsp = NSS_WIFI_IF_ALLOC_FAILURE; + goto error1; + } +@@ -286,7 +286,7 @@ static struct nss_wifi_if_handle *nss_wi + handle->pvt = (struct nss_wifi_if_pvt *)kzalloc(sizeof(struct nss_wifi_if_pvt), + GFP_KERNEL); + if (!handle->pvt) { +- nss_warning("%p: failure allocating memory for nss_wifi_if_pvt\n", nss_ctx); ++ nss_warning("%px: failure allocating memory for nss_wifi_if_pvt\n", nss_ctx); + *cmd_rsp = NSS_WIFI_IF_ALLOC_FAILURE; + goto error2; + } +@@ -335,20 +335,20 @@ struct nss_wifi_if_handle *nss_wifi_if_c + struct nss_wifi_if_handle *handle = NULL; + + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: Interface could not be created as core not ready\n", nss_ctx); ++ nss_warning("%px: Interface could not be created as core not ready\n", nss_ctx); + return NULL; + } + + handle = nss_wifi_if_handle_create(nss_ctx, &ret); + if (!handle) { +- nss_warning("%p:wifi_if handle creation failed ret %d\n", nss_ctx, ret); ++ nss_warning("%px:wifi_if handle creation failed ret %d\n", nss_ctx, ret); + return NULL; + } + + /* Initializes the semaphore and also sets the msg handler for if_num */ + ret = nss_wifi_if_register_handler(handle); + if (ret != NSS_WIFI_IF_SUCCESS) { +- nss_warning("%p: Registration handler failed reason: %d\n", nss_ctx, ret); ++ nss_warning("%px: Registration handler failed reason: %d\n", nss_ctx, ret); + goto error; + } + +@@ -361,7 +361,7 @@ struct nss_wifi_if_handle *nss_wifi_if_c + + ret = nss_wifi_if_tx_msg_sync(handle, &nwim); + if (ret != NSS_TX_SUCCESS) { +- nss_warning("%p: nss_wifi_if_tx_msg_sync failed %u\n", nss_ctx, ret); ++ nss_warning("%px: nss_wifi_if_tx_msg_sync failed %u\n", nss_ctx, ret); + goto error; + } + +@@ -397,14 +397,14 @@ nss_tx_status_t nss_wifi_if_destroy_sync + struct nss_ctx_instance *nss_ctx = handle->nss_ctx; + + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: Interface could not be destroyed as core not ready\n", nss_ctx); ++ nss_warning("%px: Interface could not be destroyed as core not ready\n", nss_ctx); + return NSS_TX_FAILURE_NOT_READY; + } + + spin_lock_bh(&nss_top_main.lock); + if (!nss_ctx->subsys_dp_register[if_num].ndev) { + spin_unlock_bh(&nss_top_main.lock); +- nss_warning("%p: Unregister wifi interface %d: no context\n", nss_ctx, if_num); ++ nss_warning("%px: Unregister wifi interface %d: no context\n", nss_ctx, if_num); + return NSS_TX_FAILURE_BAD_PARAM; + } + +@@ -500,7 +500,7 @@ nss_tx_status_t nss_wifi_if_tx_buf(struc + * Sanity check the SKB to ensure that it's suitable for us + */ + if (unlikely(skb->len <= ETH_HLEN)) { +- nss_warning("%p: Rx packet: %p too short", nss_ctx, skb); ++ nss_warning("%px: Rx packet: %px too short", nss_ctx, skb); + return NSS_TX_FAILURE_TOO_SHORT; + } + +@@ -514,4 +514,3 @@ nss_tx_status_t nss_wifi_if_tx_buf(struc + return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER); + } + EXPORT_SYMBOL(nss_wifi_if_tx_buf); - -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- vfree(lbuf); -- vfree(stats_shadow); +--- a/nss_wifi_log.c ++++ b/nss_wifi_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -110,7 +110,7 @@ static void nss_wifi_log_init_msg(struct + { + struct nss_wifi_init_msg *nwim __maybe_unused = &ncm->msg.initmsg; + +- nss_trace("%p: NSS WIFI Init Message:\n" ++ nss_trace("%px: NSS WIFI Init Message:\n" + "WIFI Radio ID: %d\n" + "WIFI PCI Memory Address: %x\n" + "WIFI Target Type: %d\n" +@@ -177,7 +177,7 @@ static void nss_wifi_log_init_msg(struct + static void nss_wifi_log_stop_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_stop_msg *nwsm __maybe_unused = &ncm->msg.stopmsg; +- nss_trace("%p: NSS WIFI Init Message:\n" ++ nss_trace("%px: NSS WIFI Init Message:\n" + "WIFI Radio ID: %d\n", + nwsm, nwsm->radio_id); + } +@@ -189,7 +189,7 @@ static void nss_wifi_log_stop_msg(struct + static void nss_wifi_log_reset_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_reset_msg *nwrm __maybe_unused = &ncm->msg.resetmsg; +- nss_trace("%p: NSS WIFI Init Message:\n" ++ nss_trace("%px: NSS WIFI Init Message:\n" + "WIFI Radio ID: %d\n", + nwrm, nwrm->radio_id); + } +@@ -201,7 +201,7 @@ static void nss_wifi_log_reset_msg(struc + static void nss_wifi_log_htt_init_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_htt_init_msg *nwim __maybe_unused = &ncm->msg.httinitmsg; +- nss_trace("%p: NSS WIFI HTT Init Message:\n" ++ nss_trace("%px: NSS WIFI HTT Init Message:\n" + "WIFI Radio ID: %d\n" + "WIFI Ring Size: %d\n" + "WIFI Fill Level: %d\n" +@@ -222,7 +222,7 @@ static void nss_wifi_log_htt_init_msg(st + static void nss_wifi_log_tx_init_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_tx_init_msg *nwim __maybe_unused = &ncm->msg.pdevtxinitmsg; +- nss_trace("%p: NSS WIFI HTT Init Message:\n" ++ nss_trace("%px: NSS WIFI HTT Init Message:\n" + "WIFI Radio ID: %d\n" + "WIFI Number of Descriptor Pools Allocated: %d\n" + "WIFI TX Descriptor Array: %x\n" +@@ -246,10 +246,10 @@ static void nss_wifi_log_tx_init_msg(str + static void nss_wifi_log_rawsend_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_rawsend_msg *nwrm __maybe_unused = &ncm->msg.rawmsg; +- nss_trace("%p: NSS WIFI RAW Send Message:\n" ++ nss_trace("%px: NSS WIFI RAW Send Message:\n" + "WIFI Radio ID: %d\n" + "WIFI Size of Raw Data: %d\n" +- "WIFI Raw Data: %p", ++ "WIFI Raw Data: %px", + nwrm, nwrm->radio_id, + nwrm->len, nwrm->array); + } +@@ -261,10 +261,10 @@ static void nss_wifi_log_rawsend_msg(str + static void nss_wifi_log_mgmtsend_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_mgmtsend_msg *nwmm __maybe_unused = &ncm->msg.mgmtmsg; +- nss_trace("%p: NSS WIFI Management Send Message:\n" ++ nss_trace("%px: NSS WIFI Management Send Message:\n" + "WIFI Descriptor ID: %d\n" + "WIFI Size of Management Data: %d\n" +- "WIFI Management Data: %p", ++ "WIFI Management Data: %px", + nwmm, nwmm->desc_id, + nwmm->len, nwmm->array); + } +@@ -276,7 +276,7 @@ static void nss_wifi_log_mgmtsend_msg(st + static void nss_wifi_log_wds_peer_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_wds_peer_msg *nwmm __maybe_unused = &ncm->msg.pdevwdspeermsg; +- nss_trace("%p: NSS WIFI WDS Peer Message:\n" ++ nss_trace("%px: NSS WIFI WDS Peer Message:\n" + "WIFI Dest MAC: %pM\n" + "WIFI Peer MAC: %pM\n", + nwmm, nwmm->dest_mac, +@@ -290,7 +290,7 @@ static void nss_wifi_log_wds_peer_msg(st + static void nss_wifi_log_peer_freelist_append_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_peer_freelist_append_msg *nwpm __maybe_unused = &ncm->msg.peer_freelist_append; +- nss_trace("%p: NSS WIFI Create/Append Freelist Message:\n" ++ nss_trace("%px: NSS WIFI Create/Append Freelist Message:\n" + "WIFI Starting Address of Peer Freelist Pool: %x\n" + "WIFI Length of freelist pool: %d\n" + "WIFI Number of Peers supported in freelist pool: %d\n", +@@ -305,7 +305,7 @@ static void nss_wifi_log_peer_freelist_a + static void nss_wifi_log_rx_reorder_array_freelist_append_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_rx_reorder_array_freelist_append_msg *nwpm __maybe_unused = &ncm->msg.rx_reorder_array_freelist_append; +- nss_trace("%p: NSS WIFI RX Reorder Array Freelist Message:\n" ++ nss_trace("%px: NSS WIFI RX Reorder Array Freelist Message:\n" + "WIFI Starting Address of TIDQ Freelist Pool: %x\n" + "WIFI Length of TIDQ freelist pool: %d\n" + "WIFI Number of Rx reorder array entries supported in freelist pool: %d\n", +@@ -320,7 +320,7 @@ static void nss_wifi_log_rx_reorder_arra + static void nss_wifi_log_set_filter_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_monitor_set_filter_msg *nwfm __maybe_unused = &ncm->msg.monitor_filter_msg; +- nss_trace("%p: NSS WIFI Set Filter Message:\n" ++ nss_trace("%px: NSS WIFI Set Filter Message:\n" + "WIFI Filter Type: %dn", + nwfm, nwfm->filter_type); + } +@@ -332,7 +332,7 @@ static void nss_wifi_log_set_filter_msg( + static void nss_wifi_log_peer_activity_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_bs_peer_activity *nwpm __maybe_unused = &ncm->msg.peer_activity; +- nss_trace("%p: NSS WIFI Get Active Peer Message:\n" ++ nss_trace("%px: NSS WIFI Get Active Peer Message:\n" + "WIFI Number of Entries in Peer ID Array: %d\n" + "WIFI PEER ID: %d\n", + nwpm, nwpm->nentries, +@@ -346,7 +346,7 @@ static void nss_wifi_log_peer_activity_m + static void nss_wifi_log_rx_vow_extstats_set_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_rx_vow_extstats_set_msg *nwpm __maybe_unused = &ncm->msg.vow_extstats_msg; +- nss_trace("%p: NSS WIFI VoW Extended Statistics Set Message:\n" ++ nss_trace("%px: NSS WIFI VoW Extended Statistics Set Message:\n" + "WIFI VoW Extended Statistics Enable:: %d\n", + nwpm, nwpm->vow_extstats_en); + } +@@ -358,7 +358,7 @@ static void nss_wifi_log_rx_vow_extstats + static void nss_wifi_log_pktlog_cfg_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_pktlog_cfg_msg *nwpm __maybe_unused = &ncm->msg.pcm_msg; +- nss_trace("%p: NSS WIFI Packet Log Configuration Message:\n" ++ nss_trace("%px: NSS WIFI Packet Log Configuration Message:\n" + "WIFI Packet Log Enable: %d\n" + "WIFI PAcket Log buffer Size: %d\n" + "WIFI Size of packet log header: %d\n" +@@ -375,7 +375,7 @@ static void nss_wifi_log_pktlog_cfg_msg( + static void nss_wifi_log_enable_perpkt_txstats_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_enable_perpkt_txstats_msg *nwpm __maybe_unused = &ncm->msg.ept_msg; +- nss_trace("%p: NSS WIFI Enable TX Stats Message:\n" ++ nss_trace("%px: NSS WIFI Enable TX Stats Message:\n" + "WIFI TX Stats Enable Flag: %d\n", + nwpm, nwpm->perpkt_txstats_flag); + } +@@ -387,7 +387,7 @@ static void nss_wifi_log_enable_perpkt_t + static void nss_wifi_log_override_tos_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_igmp_mld_override_tos_msg *nwpm __maybe_unused = &ncm->msg.wigmpmldtm_msg; +- nss_trace("%p: NSS WIFI Override TOS Message:\n" ++ nss_trace("%px: NSS WIFI Override TOS Message:\n" + "WIFI enable TID override Flag: %d\n" + "WIFI Value of TID to be overriden: %d\n", + nwpm, nwpm->igmp_mld_ovride_tid_en, +@@ -401,7 +401,7 @@ static void nss_wifi_log_override_tos_ms + static void nss_wifi_log_ol_stats_cfg_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_ol_stats_cfg_msg *nwpm __maybe_unused = &ncm->msg.scm_msg; +- nss_trace("%p: NSS WIFI Enable/Disable Offload Stats Message:\n" ++ nss_trace("%px: NSS WIFI Enable/Disable Offload Stats Message:\n" + "WIFI enable/disable offload stats config: %d\n", + nwpm, nwpm->stats_cfg); + } +@@ -413,7 +413,7 @@ static void nss_wifi_log_ol_stats_cfg_ms + static void nss_wifi_log_tx_queue_cfg_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_tx_queue_cfg_msg *nwpm __maybe_unused = &ncm->msg.wtxqcm; +- nss_trace("%p: NSS WIFI TX Queue Config Message:\n" ++ nss_trace("%px: NSS WIFI TX Queue Config Message:\n" + "WIFI TX Queue Size: %d\n" + "WIFI TX Queue Range: %d\n", + nwpm, nwpm->size, nwpm->range); +@@ -426,7 +426,7 @@ static void nss_wifi_log_tx_queue_cfg_ms + static void nss_wifi_log_tx_min_threshold_cfg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_tx_min_threshold_cfg_msg *nwpm __maybe_unused = &ncm->msg.wtx_min_threshold_cm; +- nss_trace("%p: NSS WIFI TX Queue Min Threshold Config Message:\n" ++ nss_trace("%px: NSS WIFI TX Queue Min Threshold Config Message:\n" + "WIFI TX Queue Min Threshold Value: %d\n", + nwpm, nwpm->min_threshold); + } +@@ -438,7 +438,7 @@ static void nss_wifi_log_tx_min_threshol + static void nss_wifi_log_dbdc_process_enable_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_dbdc_process_enable_msg *nwpm __maybe_unused = &ncm->msg.dbdcpe_msg; +- nss_trace("%p: NSS WIFI DBDC repeater process configuration:\n" ++ nss_trace("%px: NSS WIFI DBDC repeater process configuration:\n" + "WIFI DBDC Process Enable Flag: %d\n", + nwpm, nwpm->dbdc_process_enable); + } +@@ -450,7 +450,7 @@ static void nss_wifi_log_dbdc_process_en + static void nss_wifi_log_primary_radio_set_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_primary_radio_set_msg *nwpm __maybe_unused = &ncm->msg.wprs_msg; +- nss_trace("%p: NSS WIFI Primary Radio Set Message:\n" ++ nss_trace("%px: NSS WIFI Primary Radio Set Message:\n" + "WIFI Current Radio as Primary Radio Enable/Disable Flag: %d\n", + nwpm, nwpm->flag); + } +@@ -462,7 +462,7 @@ static void nss_wifi_log_primary_radio_s + static void nss_wifi_log_force_client_mcast_traffic_set_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_force_client_mcast_traffic_set_msg *nwpm __maybe_unused = &ncm->msg.wfcmts_msg; +- nss_trace("%p: NSS WIFI Force Multicat Traffic for Radio Message:\n" ++ nss_trace("%px: NSS WIFI Force Multicat Traffic for Radio Message:\n" + "WIFI Radio Multicast Traffic Flag: %d\n", + nwpm, nwpm->flag); + } +@@ -474,7 +474,7 @@ static void nss_wifi_log_force_client_mc + static void nss_wifi_log_store_other_pdev_stavap_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_store_other_pdev_stavap_msg *nwpm __maybe_unused = &ncm->msg.wsops_msg; +- nss_trace("%p: NSS WIFI Store Other Radio Station VAP Message:\n" ++ nss_trace("%px: NSS WIFI Store Other Radio Station VAP Message:\n" + "WIFI Station VAP Interface Number: %d\n", + nwpm, nwpm->stavap_ifnum); + } +@@ -486,7 +486,7 @@ static void nss_wifi_log_store_other_pde + static void nss_wifi_log_sta_kickout_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_sta_kickout_msg *nwpm __maybe_unused = &ncm->msg.sta_kickout_msg; +- nss_trace("%p: NSS WIFI Station Kickout Message:\n" ++ nss_trace("%px: NSS WIFI Station Kickout Message:\n" + "WIFI PEER ID: %d\n", + nwpm, nwpm->peer_id); + } +@@ -498,8 +498,8 @@ static void nss_wifi_log_sta_kickout_msg + static void nss_wifi_log_wnm_peer_rx_activity(struct nss_wifi_msg *ncm) + { + struct nss_wifi_wnm_peer_rx_activity_msg *nwpm __maybe_unused = &ncm->msg.wprm; +- nss_trace("%p: NSS WIFI RX Active State Information of Peer:\n" +- "WIFI Peer ID: %p\n" ++ nss_trace("%px: NSS WIFI RX Active State Information of Peer:\n" ++ "WIFI Peer ID: %px\n" + "WIFI Number of Entries: %d\n", + nwpm, nwpm->peer_id, nwpm->nentries); + } +@@ -511,7 +511,7 @@ static void nss_wifi_log_wnm_peer_rx_act + static void nss_wifi_log_wds_extn_peer_cfg_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_wds_extn_peer_cfg_msg *nwpm __maybe_unused = &ncm->msg.wpeercfg; +- nss_trace("%p: NSS WIFI Extension Enabled Configuraion Message:\n" ++ nss_trace("%px: NSS WIFI Extension Enabled Configuraion Message:\n" + "WIFI Peer MAC Address: %pM\n" + "WIFI WDS Flags: %d\n" + "WIFI Peer ID: %d\n", +@@ -526,7 +526,7 @@ static void nss_wifi_log_wds_extn_peer_c + static void nss_wifi_log_tx_capture_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_tx_capture_msg *nwpm __maybe_unused = &ncm->msg.tx_capture_msg; +- nss_trace("%p: NSS WIFI Enable TX Capture Message:\n" ++ nss_trace("%px: NSS WIFI Enable TX Capture Message:\n" + "WIFI TX Capture Enable Flag: %d\n", + nwpm, nwpm->tx_capture_enable); + } +@@ -538,7 +538,7 @@ static void nss_wifi_log_tx_capture_msg( + static void nss_wifi_log_always_primary_set_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_always_primary_set_msg *nwpm __maybe_unused = &ncm->msg.waps_msg; +- nss_trace("%p: NSS WIFI Always Set Current Radio Primary Message:\n" ++ nss_trace("%px: NSS WIFI Always Set Current Radio Primary Message:\n" + "WIFI Always Set Flag: %d\n", + nwpm, nwpm->flag); + } +@@ -550,7 +550,7 @@ static void nss_wifi_log_always_primary_ + static void nss_wifi_log_cmd_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_cmd_msg *nwpm __maybe_unused = &ncm->msg.wcmdm; +- nss_trace("%p: NSS WIFI PDEV Command Message:\n" ++ nss_trace("%px: NSS WIFI PDEV Command Message:\n" + "WIFI Type of Command: %d\n" + "WIFI Value of Command: %d\n", + nwpm, nwpm->cmd, nwpm->value); +@@ -563,7 +563,7 @@ static void nss_wifi_log_cmd_msg(struct + static void nss_wifi_log_enable_ol_statsv2_msg(struct nss_wifi_msg *ncm) + { + struct nss_wifi_enable_ol_statsv2 *nwpm __maybe_unused = &ncm->msg.wesh_msg; +- nss_trace("%p: NSS WIFI Enable Version 2 of TX/RX Stats:\n" ++ nss_trace("%px: NSS WIFI Enable Version 2 of TX/RX Stats:\n" + "WIFI Enable Version 2 Stats: %d\n", + nwpm, nwpm->enable_ol_statsv2); + } +@@ -577,7 +577,7 @@ static void nss_wifi_log_enable_ol_peer_ + struct nss_wifi_ol_peer_time_msg *nwpm __maybe_unused = &ncm->msg.wopt_msg; + int32_t i; + +- nss_trace("%p: NSS WIFI Enable Per PEer Stats to Host:\n" ++ nss_trace("%px: NSS WIFI Enable Per PEer Stats to Host:\n" + "WIFI Number of Peers: %d\n" + "WIFI Peed ID: %d\n", + nwpm, nwpm->npeers, +@@ -750,7 +750,7 @@ static void nss_wifi_log_verbose(struct + break; + + default: +- nss_warning("%p: Invalid message type\n", ncm); ++ nss_warning("%px: Invalid message type\n", ncm); + break; + } + } +@@ -762,11 +762,11 @@ static void nss_wifi_log_verbose(struct + void nss_wifi_log_tx_msg(struct nss_wifi_msg *ncm) + { + if (ncm->cm.type >= NSS_WIFI_MAX_MSG) { +- nss_warning("%p: Invalid message type\n", ncm); ++ nss_warning("%px: Invalid message type\n", ncm); + return; + } + +- nss_info("%p: type[%d]:%s\n", ncm, ncm->cm.type, nss_wifi_log_message_types_str[ncm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", ncm, ncm->cm.type, nss_wifi_log_message_types_str[ncm->cm.type]); + nss_wifi_log_verbose(ncm); + } + +@@ -777,26 +777,26 @@ void nss_wifi_log_tx_msg(struct nss_wifi + void nss_wifi_log_rx_msg(struct nss_wifi_msg *ncm) + { + if (ncm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", ncm); ++ nss_warning("%px: Invalid response\n", ncm); + return; + } + + if (ncm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ncm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", ncm, ncm->cm.type, + nss_wifi_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response]); + goto verbose; + } + + if (ncm->cm.error >= NSS_WIFI_EMSG_MAX) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + ncm, ncm->cm.type, nss_wifi_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + ncm, ncm->cm.type, nss_wifi_log_message_types_str[ncm->cm.type], + ncm->cm.response, nss_cmn_response_str[ncm->cm.response], + ncm->cm.error, nss_wifi_log_error_response_types_str[ncm->cm.error]); +--- a/nss_wifi_mac_db.c ++++ b/nss_wifi_mac_db.c +@@ -52,7 +52,7 @@ static void nss_wifi_mac_db_handler(stru + void *ctx; + nss_wifi_mac_db_msg_callback_t cb; + +- nss_info("%p: NSS->HLOS message for wifi_mac_db\n", nss_ctx); ++ nss_info("%px: NSS->HLOS message for wifi_mac_db\n", nss_ctx); + + /* + * The interface number shall be wifi_mac_db soc interface or wifi_mac_db radio interface +@@ -63,12 +63,12 @@ static void nss_wifi_mac_db_handler(stru + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_WIFI_MAC_DB_MAX_MSG) { +- nss_warning("%p: Received invalid message %d for wifi_mac_db interface", nss_ctx, ncm->type); ++ nss_warning("%px: Received invalid message %d for wifi_mac_db interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_wifi_mac_db_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -89,7 +89,7 @@ static void nss_wifi_mac_db_handler(stru + * Do we have a call back + */ + if (!ncm->cb) { +- nss_info("%p: cb null for wifi_mac_db interface %d", nss_ctx, ncm->interface); ++ nss_info("%px: cb null for wifi_mac_db interface %d", nss_ctx, ncm->interface); + return; + } + +@@ -103,7 +103,7 @@ static void nss_wifi_mac_db_handler(stru + * call wifi_mac_db msg callback + */ + if (!ctx) { +- nss_warning("%p: Event received for wifi_mac_db interface %d before registration", nss_ctx, ncm->interface); ++ nss_warning("%px: Event received for wifi_mac_db interface %d before registration", nss_ctx, ncm->interface); + return; + } + +@@ -122,7 +122,7 @@ nss_tx_status_t nss_wifi_mac_db_tx_msg(s + struct nss_cmn_msg *ncm = &msg->cm; + + if (ncm->type >= NSS_WIFI_MAC_DB_MAX_MSG) { +- nss_warning("%p: wifi_mac_db message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: wifi_mac_db message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -130,7 +130,7 @@ nss_tx_status_t nss_wifi_mac_db_tx_msg(s + * The interface number shall be one of the wifi_mac_db soc interfaces + */ + if ((ncm->interface != NSS_WIFI_MAC_DB_INTERFACE)) { +- nss_warning("%p: tx request for interface that is not a wifi_mac_db: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: tx request for interface that is not a wifi_mac_db: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + +@@ -159,7 +159,7 @@ struct nss_ctx_instance *nss_register_wi + */ + nss_assert(if_num == NSS_WIFI_MAC_DB_INTERFACE); + +- nss_info("%p: nss_register_wifi_mac_db_if if_num:%d wifi_mac_db_dev:%p", nss_ctx, if_num, netdev); ++ nss_info("%px: nss_register_wifi_mac_db_if if_num:%d wifi_mac_db_dev:%px", nss_ctx, if_num, netdev); + + nss_core_register_subsys_dp(nss_ctx, if_num, wifi_mac_db_callback, NULL, NULL, netdev, features); + +--- a/nss_wifi_stats.c ++++ b/nss_wifi_stats.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2016-2017, 2019 The Linux Foundation. All rights reserved. ++ * Copyright (c) 2016-2017, 2019-2020 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. +@@ -167,7 +167,7 @@ void nss_wifi_stats_sync(struct nss_ctx_ + uint8_t i = 0; + + if (radio_id >= NSS_MAX_WIFI_RADIO_INTERFACES) { +- nss_warning("%p: invalid interface: %d", nss_ctx, interface); ++ nss_warning("%px: invalid interface: %d", nss_ctx, interface); + return; + } + +--- a/nss_wifi_vdev.c ++++ b/nss_wifi_vdev.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2015-2020, 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. +@@ -24,7 +24,7 @@ static void nss_wifi_vdev_handler(struct + { + nss_wifi_vdev_msg_callback_t cb; + +- nss_info("%p: NSS->HLOS message for wifi vdev on interface:%d", nss_ctx, ncm->interface); ++ nss_info("%px: NSS->HLOS message for wifi vdev on interface:%d", nss_ctx, ncm->interface); + + BUG_ON(((ncm->interface < NSS_DYNAMIC_IF_START) || (ncm->interface >= (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES)))); + +@@ -32,12 +32,12 @@ static void nss_wifi_vdev_handler(struct + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_WIFI_VDEV_MAX_MSG) { +- nss_warning("%p: received invalid message %d for wifi vdev interface", nss_ctx, ncm->type); ++ nss_warning("%px: received invalid message %d for wifi vdev interface", nss_ctx, ncm->type); + return; + } + + if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_wifi_vdev_msg)) { +- nss_warning("%p: Length of message %d is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm), (int)sizeof(struct nss_wifi_vdev_msg)); ++ nss_warning("%px: Length of message %d is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm), (int)sizeof(struct nss_wifi_vdev_msg)); + return; + } + +@@ -50,13 +50,13 @@ static void nss_wifi_vdev_handler(struct + * callback + */ + if (!nss_ctx->subsys_dp_register[ncm->interface].ndev) { +- nss_warning("%p: Event received wifi vdev interface %d before registration", nss_ctx, ncm->interface); ++ nss_warning("%px: Event received wifi vdev interface %d before registration", nss_ctx, ncm->interface); + return; + + } + + if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { +- ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface]; ++ ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); + ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].ndev; + } + +@@ -90,7 +90,7 @@ nss_tx_status_t nss_wifi_vdev_base_tx_ms + { + struct nss_cmn_msg *ncm = &msg->cm; + +- nss_trace("%p: Sending wifi vdev message on interface :%d", nss_ctx, ncm->interface); ++ nss_trace("%px: Sending wifi vdev message on interface :%d", nss_ctx, ncm->interface); + + /* + * Sanity checks on the message +@@ -100,12 +100,12 @@ nss_tx_status_t nss_wifi_vdev_base_tx_ms + * The interface number shall be wifi vdev base vap + */ + if (ncm->interface != NSS_VAP_INTERFACE) { +- nss_warning("%p: wifi vdev base tx request not on wifi vdev vap: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: wifi vdev base tx request not on wifi vdev vap: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_WIFI_VDEV_MAX_MSG) { +- nss_warning("%p: wifi vdev base message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: wifi vdev base message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -121,7 +121,7 @@ nss_tx_status_t nss_wifi_vdev_tx_msg(str + { + struct nss_cmn_msg *ncm = &msg->cm; + +- nss_trace("%p: Sending wifi vdev message on interface :%d", nss_ctx, ncm->interface); ++ nss_trace("%px: Sending wifi vdev message on interface :%d", nss_ctx, ncm->interface); + + /* + * Sanity checks on the message +@@ -131,12 +131,12 @@ nss_tx_status_t nss_wifi_vdev_tx_msg(str + * Interface shall be of dynamic interface type + */ + if ((ncm->interface < NSS_DYNAMIC_IF_START) || (ncm->interface >= (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES))) { +- nss_warning("%p: wifi vdev tx request for invalid interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: wifi vdev tx request for invalid interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_WIFI_VDEV_MAX_MSG) { +- nss_warning("%p: wifi vdev message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: wifi vdev message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -157,31 +157,31 @@ nss_tx_status_t nss_wifi_vdev_tx_msg_ext + NSS_VERIFY_CTX_MAGIC(nss_ctx); + + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: wifi vdev message dropped as core not ready", nss_ctx); ++ nss_warning("%px: wifi vdev message dropped as core not ready", nss_ctx); + return NSS_TX_FAILURE_NOT_READY; + } + + nm = (struct nss_wifi_vdev_msg *) os_buf->data; + ncm = &nm->cm; + +- nss_trace("%p: Sending wifi vdev message on interface :%d", nss_ctx, ncm->interface); ++ nss_trace("%px: Sending wifi vdev message on interface :%d", nss_ctx, ncm->interface); + + /* + * Interface shall be of dynamic interface type + */ + if ((ncm->interface < NSS_DYNAMIC_IF_START) || (ncm->interface >= (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES))) { +- nss_warning("%p: wifi vdev tx request for invalid interface: %d", nss_ctx, ncm->interface); ++ nss_warning("%px: wifi vdev tx request for invalid interface: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + + if (ncm->type >= NSS_WIFI_VDEV_MAX_MSG) { +- nss_warning("%p: wifi vdev message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: wifi vdev message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + + status = nss_core_send_buffer(nss_ctx, 0, os_buf, NSS_IF_H2N_CMD_QUEUE, H2N_BUFFER_CTRL, H2N_BIT_FLAG_BUFFER_REUSABLE); + if (status != NSS_CORE_STATUS_SUCCESS) { +- nss_warning("%p: Unable to enqueue 'wifi vdev message'", nss_ctx); ++ nss_warning("%px: Unable to enqueue 'wifi vdev message'", nss_ctx); + return NSS_TX_FAILURE; + } + +@@ -215,7 +215,7 @@ nss_tx_status_t nss_wifi_vdev_set_next_h + struct nss_wifi_vdev_set_next_hop_msg *next_hop_msg = NULL; + + if (!wifivdevmsg) { +- nss_warning("%p: Unable to allocate next hop message", ctx); ++ nss_warning("%px: Unable to allocate next hop message", ctx); + return NSS_TX_FAILURE; + } + +@@ -226,7 +226,7 @@ nss_tx_status_t nss_wifi_vdev_set_next_h + + status = nss_wifi_vdev_tx_msg(ctx, wifivdevmsg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to send next hop message", ctx); ++ nss_warning("%px: Unable to send next hop message", ctx); + } + + kfree(wifivdevmsg); +@@ -244,7 +244,7 @@ nss_tx_status_t nss_wifi_vdev_base_set_n + struct nss_wifi_vdev_set_next_hop_msg *next_hop_msg = NULL; + + if (!wifivdevmsg) { +- nss_warning("%p: Unable to allocate next hop message", ctx); ++ nss_warning("%px: Unable to allocate next hop message", ctx); + return NSS_TX_FAILURE; + } + +@@ -255,7 +255,7 @@ nss_tx_status_t nss_wifi_vdev_base_set_n + + status = nss_wifi_vdev_base_tx_msg(ctx, wifivdevmsg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to send next hop message", ctx); ++ nss_warning("%px: Unable to send next hop message", ctx); + } + + kfree(wifivdevmsg); +@@ -273,7 +273,7 @@ nss_tx_status_t nss_wifi_vdev_set_peer_n + struct nss_wifi_vdev_set_peer_next_hop_msg *peer_next_hop_msg = NULL; + + if (!wifivdevmsg) { +- nss_warning("%p: Unable to allocate next hop message", ctx); ++ nss_warning("%px: Unable to allocate next hop message", ctx); + return NSS_TX_FAILURE; + } + +@@ -286,7 +286,7 @@ nss_tx_status_t nss_wifi_vdev_set_peer_n + + status = nss_wifi_vdev_tx_msg(ctx, wifivdevmsg); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: Unable to send peer next hop message", ctx); ++ nss_warning("%px: Unable to send peer next hop message", ctx); + } + + kfree(wifivdevmsg); +@@ -307,7 +307,7 @@ bool nss_wifi_vdev_set_dp_type(struct ns + nss_assert((if_num >= NSS_DYNAMIC_IF_START) && (if_num < (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES))); + + if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { +- nss_warning("%p: Vap interface dp type could not be set as core is not initialized\n", nss_ctx); ++ nss_warning("%px: Vap interface dp type could not be set as core is not initialized\n", nss_ctx); + return false; + } + +@@ -337,11 +337,17 @@ uint32_t nss_register_wifi_vdev_if(struc + struct net_device *netdev, + uint32_t features) + { ++ uint32_t status; ++ + nss_assert((if_num >= NSS_DYNAMIC_IF_START) && (if_num < (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES))); + + nss_core_register_subsys_dp(nss_ctx, if_num, vdev_data_callback, vdev_ext_data_callback, NULL, netdev, features); + +- nss_top_main.if_rx_msg_callback[if_num] = vdev_event_callback; ++ status = nss_core_register_msg_handler(nss_ctx, if_num, vdev_event_callback); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: unable to register event handler for interface(%u)", nss_ctx, if_num); ++ return status; ++ } + + nss_core_register_handler(nss_ctx, if_num, nss_wifi_vdev_handler, NULL); + +@@ -355,13 +361,18 @@ EXPORT_SYMBOL(nss_register_wifi_vdev_if) + void nss_unregister_wifi_vdev_if(uint32_t if_num) + { + struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; ++ uint32_t status; + + nss_assert(nss_ctx); + nss_assert((if_num >= NSS_DYNAMIC_IF_START) && (if_num < (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES))); + + nss_core_unregister_subsys_dp(nss_ctx, if_num); + +- nss_top_main.if_rx_msg_callback[if_num] = NULL; ++ status = nss_core_unregister_msg_handler(nss_ctx, if_num); ++ if (status != NSS_CORE_STATUS_SUCCESS) { ++ nss_warning("%px: unable to unregister event handler for interface(%u)", nss_ctx, if_num); ++ return; ++ } + + nss_core_unregister_handler(nss_ctx, if_num); + } +--- a/nss_wifili.c ++++ b/nss_wifili.c +@@ -43,15 +43,18 @@ static void nss_wifili_handler(struct ns + void *ctx; + nss_wifili_msg_callback_t cb; + +- nss_info("%p: NSS->HLOS message for wifili\n", nss_ctx); ++ nss_info("%px: NSS->HLOS message for wifili\n", nss_ctx); + + /* + * The interface number shall be wifili soc interface or wifili radio interface + */ + BUG_ON((nss_is_dynamic_interface(ncm->interface)) + || ((ncm->interface != NSS_WIFILI_INTERNAL_INTERFACE) ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE0) +- && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE1))); ++ && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE1) ++#endif ++ )); + + /* + * Trace messages. +@@ -62,12 +65,13 @@ static void nss_wifili_handler(struct ns + * Is this a valid request/response packet? + */ + if (ncm->type >= NSS_WIFILI_MAX_MSG) { +- nss_warning("%p: Received invalid message %d for wifili interface", nss_ctx, ncm->type); ++ nss_warning("%px: Received invalid message %d for wifili interface", nss_ctx, ncm->type); + return; + } + +- if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_wifili_msg)) { +- nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); ++ if ((nss_cmn_get_msg_len(ncm) > sizeof(struct nss_wifili_msg)) && ++ ntm->cm.type != NSS_WIFILI_PEER_EXT_STATS_MSG) { ++ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); + return; + } + +@@ -101,7 +105,7 @@ static void nss_wifili_handler(struct ns + * Do we have a call back + */ + if (!ncm->cb) { +- nss_info("%p: cb null for wifili interface %d", nss_ctx, ncm->interface); ++ nss_info("%px: cb null for wifili interface %d", nss_ctx, ncm->interface); + return; + } + +@@ -115,7 +119,7 @@ static void nss_wifili_handler(struct ns + * call wifili msg callback + */ + if (!ctx) { +- nss_warning("%p: Event received for wifili interface %d before registration", nss_ctx, ncm->interface); ++ nss_warning("%px: Event received for wifili interface %d before registration", nss_ctx, ncm->interface); + return; + } + +@@ -163,7 +167,7 @@ nss_tx_status_t nss_wifili_tx_msg(struct + nss_wifili_log_tx_msg(msg); + + if (ncm->type >= NSS_WIFILI_MAX_MSG) { +- nss_warning("%p: wifili message type out of range: %d", nss_ctx, ncm->type); ++ nss_warning("%px: wifili message type out of range: %d", nss_ctx, ncm->type); + return NSS_TX_FAILURE; + } + +@@ -171,9 +175,14 @@ nss_tx_status_t nss_wifili_tx_msg(struct + * The interface number shall be one of the wifili soc interfaces + */ + if ((ncm->interface != NSS_WIFILI_INTERNAL_INTERFACE) ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE0) +- && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE1)) { +- nss_warning("%p: tx request for interface that is not a wifili: %d", nss_ctx, ncm->interface); ++ && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE1)) ++#else ++ ) ++#endif ++ { ++ nss_warning("%px: tx request for interface that is not a wifili: %d", nss_ctx, ncm->interface); + return NSS_TX_FAILURE; + } + +@@ -199,14 +208,14 @@ nss_tx_status_t nss_wifili_tx_msg_sync(s + + status = nss_wifili_tx_msg(nss_ctx, nvm); + if (status != NSS_TX_SUCCESS) { +- nss_warning("%p: wifili_tx_msg failed\n", nss_ctx); ++ nss_warning("%px: wifili_tx_msg failed\n", nss_ctx); + up(&wifili_pvt.sem); + return status; + } + + ret = wait_for_completion_timeout(&wifili_pvt.complete, msecs_to_jiffies(NSS_WIFILI_TX_TIMEOUT)); + if (!ret) { +- nss_warning("%p: wifili msg tx failed due to timeout\n", nss_ctx); ++ nss_warning("%px: wifili msg tx failed due to timeout\n", nss_ctx); + wifili_pvt.response = NSS_TX_FAILURE; + } + +@@ -229,6 +238,7 @@ EXPORT_SYMBOL(nss_wifili_get_context); + * nss_get_available_wifili_external_if() + * Check and return the available external interface + */ ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + uint32_t nss_get_available_wifili_external_if(void) + { + struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; +@@ -244,12 +254,12 @@ uint32_t nss_get_available_wifili_extern + return NSS_WIFILI_EXTERNAL_INTERFACE1; + } + +- nss_warning("%p: No available external intefaces\n", nss_ctx); ++ nss_warning("%px: No available external intefaces\n", nss_ctx); + + return NSS_MAX_NET_INTERFACES; + } + EXPORT_SYMBOL(nss_get_available_wifili_external_if); - -- return bytes_read; --} ++#endif + /* + * nss_wifili_msg_init() + * Initialize nss_wifili_msg. +@@ -283,7 +293,7 @@ struct nss_ctx_instance *nss_register_wi + || (if_num == NSS_WIFILI_EXTERNAL_INTERFACE0) + || (if_num == NSS_WIFILI_EXTERNAL_INTERFACE1)); + +- nss_info("nss_register_wifili_if if_num %d wifictx %p", if_num, netdev); ++ nss_info("nss_register_wifili_if if_num %d wifictx %px", if_num, netdev); + + nss_core_register_subsys_dp(nss_ctx, if_num, wifili_callback, wifili_ext_callback, NULL, netdev, features); + +@@ -326,7 +336,7 @@ struct nss_ctx_instance *nss_register_wi + * The interface number shall be wifili radio dynamic interface + */ + nss_assert(nss_is_dynamic_interface(if_num)); +- nss_info("nss_register_wifili_if if_num %d wifictx %p", if_num, netdev); ++ nss_info("nss_register_wifili_if if_num %d wifictx %px", if_num, netdev); + + nss_core_register_subsys_dp(nss_ctx, if_num, wifili_callback, wifili_ext_callback, NULL, netdev, features); + +@@ -361,9 +371,10 @@ void nss_wifili_register_handler(void) + + nss_info("nss_wifili_register_handler"); + nss_core_register_handler(nss_ctx, NSS_WIFILI_INTERNAL_INTERFACE, nss_wifili_handler, NULL); ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + nss_core_register_handler(nss_ctx, NSS_WIFILI_EXTERNAL_INTERFACE0, nss_wifili_handler, NULL); + nss_core_register_handler(nss_ctx, NSS_WIFILI_EXTERNAL_INTERFACE1, nss_wifili_handler, NULL); - --/* -- * nss_dtls_cmn_stats_ops. -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(dtls_cmn); -- --/* -- * nss_dtls_cmn_stats_dentry_create() -- * Create dtls common statistics debug entry. -- */ --void nss_dtls_cmn_stats_dentry_create(void) --{ -- nss_stats_create_dentry("dtls_cmn", &nss_dtls_cmn_stats_ops); --} -- --/* -- * nss_dtls_cmn_stats_sync() -- * Update dtls common node statistics. -- */ --void nss_dtls_cmn_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm) --{ -- struct nss_dtls_cmn_msg *ndcm = (struct nss_dtls_cmn_msg *)ncm; -- struct nss_dtls_cmn_ctx_stats *ndccs = &ndcm->msg.stats; -- uint64_t *ctx_stats; -- uint32_t *msg_stats; -- uint16_t i = 0; -- -- spin_lock_bh(&nss_dtls_cmn_stats_lock); -- -- msg_stats = (uint32_t *)ndccs; -- ctx_stats = nss_dtls_cmn_ctx_stats[ncm->interface]; -- -- for (i = 0; i < NSS_DTLS_CMN_CTX_STATS_MAX; i++, ctx_stats++, msg_stats++) { -- *ctx_stats += *msg_stats; -- } -- -- spin_unlock_bh(&nss_dtls_cmn_stats_lock); --} -- --/* -- * nss_dtls_cmn_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_dtls_cmn_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_dtls_cmn_stats_notification *dtls_cmn_stats; -- -- dtls_cmn_stats = kmalloc(sizeof(struct nss_dtls_cmn_stats_notification), GFP_ATOMIC); -- if (!dtls_cmn_stats) { -- nss_warning("Unable to allocate memory for stats notification\n"); -- return; -- } -- -- spin_lock_bh(&nss_dtls_cmn_stats_lock); -- dtls_cmn_stats->core_id = nss_ctx->id; -- dtls_cmn_stats->if_num = if_num; -- memcpy(dtls_cmn_stats->stats_ctx, nss_dtls_cmn_ctx_stats[if_num], sizeof(dtls_cmn_stats->stats_ctx)); -- spin_unlock_bh(&nss_dtls_cmn_stats_lock); -- -- atomic_notifier_call_chain(&nss_dtls_cmn_stats_notifier, NSS_STATS_EVENT_NOTIFY, dtls_cmn_stats); -- kfree(dtls_cmn_stats); --} -- --/* -- * nss_dtls_cmn_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_dtls_cmn_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_dtls_cmn_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_dtls_cmn_stats_unregister_notifier); -- --/* -- * nss_dtls_cmn_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_dtls_cmn_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_dtls_cmn_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_dtls_cmn_stats_register_notifier); ---- a/nss_dtls_cmn_stats.h -+++ /dev/null -@@ -1,26 +0,0 @@ --/* -- **************************************************************************** -- * Copyright (c) 2020-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. -- **************************************************************************** -- */ -- --#ifndef __NSS_DTLS_CMN_STATS_H --#define __NSS_DTLS_CMN_STATS_H -- --#include -- --extern void nss_dtls_cmn_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); --extern void nss_dtls_cmn_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm); --extern void nss_dtls_cmn_stats_dentry_create(void); -- --#endif /* __NSS_DTLS_CMN_STATS_H */ ---- a/nss_dtls_cmn_strings.c -+++ /dev/null -@@ -1,128 +0,0 @@ --/* -- **************************************************************************** -- * Copyright (c) 2020, 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_strings.h" --#include "nss_dtls_cmn_strings.h" -- --/* -- * nss_dtls_cmn_ctx_stats_str -- * dtls common ctx statistics strings. -- */ --struct nss_stats_info nss_dtls_cmn_ctx_stats_str[NSS_DTLS_CMN_CTX_STATS_MAX] = { -- {"rx_pkts", NSS_STATS_TYPE_COMMON}, -- {"rx_byts", NSS_STATS_TYPE_COMMON}, -- {"tx_pkts", NSS_STATS_TYPE_COMMON}, -- {"tx_byts", NSS_STATS_TYPE_COMMON}, -- {"rx_queue[0]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[1]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[2]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[3]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_single_rec", NSS_STATS_TYPE_SPECIAL}, -- {"rx_multi_rec", NSS_STATS_TYPE_SPECIAL}, -- {"fail_crypto_resource", NSS_STATS_TYPE_DROP}, -- {"fail_crypto_enqueue", NSS_STATS_TYPE_DROP}, -- {"fail_headroom", NSS_STATS_TYPE_DROP}, -- {"fail_tailroom", NSS_STATS_TYPE_DROP}, -- {"fail_ver", NSS_STATS_TYPE_DROP}, -- {"fail_epoch", NSS_STATS_TYPE_DROP}, -- {"fail_dtls_record", NSS_STATS_TYPE_DROP}, -- {"fail_capwap", NSS_STATS_TYPE_DROP}, -- {"fail_replay", NSS_STATS_TYPE_DROP}, -- {"fail_replay_dup", NSS_STATS_TYPE_DROP}, -- {"fail_replay_win", NSS_STATS_TYPE_DROP}, -- {"fail_queue", NSS_STATS_TYPE_DROP}, -- {"fail_queue_nexthop", NSS_STATS_TYPE_DROP}, -- {"fail_pbuf_alloc", NSS_STATS_TYPE_DROP}, -- {"fail_pbuf_linear", NSS_STATS_TYPE_DROP}, -- {"fail_pbuf_stats", NSS_STATS_TYPE_DROP}, -- {"fail_pbuf_align", NSS_STATS_TYPE_DROP}, -- {"fail_ctx_active", NSS_STATS_TYPE_DROP}, -- {"fail_hwctx_active", NSS_STATS_TYPE_DROP}, -- {"fail_cipher", NSS_STATS_TYPE_EXCEPTION}, -- {"fail_auth", NSS_STATS_TYPE_EXCEPTION}, -- {"fail_seq_ovf", NSS_STATS_TYPE_DROP}, -- {"fail_blk_len", NSS_STATS_TYPE_DROP}, -- {"fail_hash_len", NSS_STATS_TYPE_DROP}, -- {"len_error", NSS_STATS_TYPE_DROP}, -- {"token_error", NSS_STATS_TYPE_DROP}, -- {"bypass_error", NSS_STATS_TYPE_DROP}, -- {"config_error", NSS_STATS_TYPE_DROP}, -- {"algo_error", NSS_STATS_TYPE_DROP}, -- {"hash_ovf_error", NSS_STATS_TYPE_DROP}, -- {"ttl_error", NSS_STATS_TYPE_DROP}, -- {"csum_error", NSS_STATS_TYPE_DROP}, -- {"timeout_error", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[0]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[1]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[2]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[3]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[4]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[5]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[6]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[7]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[8]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[9]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[10]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[11]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[12]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[13]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[14]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[15]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[16]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[17]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[18]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[19]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[20]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[21]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[22]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[23]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[24]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[25]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[26]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[27]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[28]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[29]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[30]", NSS_STATS_TYPE_DROP}, -- {"fail_cle_[31]", NSS_STATS_TYPE_DROP}, -- {"seq_low", NSS_STATS_TYPE_SPECIAL}, -- {"seq_high", NSS_STATS_TYPE_SPECIAL}, -- {"epoch", NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_dtls_cmn_ctx_stats_str_strings_read() -- * Read dtls common ctx statistics names -- */ --static ssize_t nss_dtls_cmn_ctx_stats_str_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_dtls_cmn_ctx_stats_str, NSS_DTLS_CMN_CTX_STATS_MAX); --} -- --/* -- * nss_dtls_cmn_ctx_stats_str_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(dtls_cmn_ctx_stats_str); -- --/* -- * nss_dtls_cmn_strings_dentry_create() -- * Create dtls common statistics strings debug entry. -- */ --void nss_dtls_cmn_strings_dentry_create(void) --{ -- nss_strings_create_dentry("dtls_cmn_ctx_stats_str", &nss_dtls_cmn_ctx_stats_str_strings_ops); --} ---- a/nss_dtls_cmn_strings.h -+++ /dev/null -@@ -1,25 +0,0 @@ --/* -- **************************************************************************** -- * Copyright (c) 2020, 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. -- **************************************************************************** -- */ -- --#ifndef __NSS_DTLS_CMN_STRINGS_H --#define __NSS_DTLS_CMN_STRINGS_H -- --#include "nss_dtls_cmn_stats.h" -- --extern struct nss_stats_info nss_dtls_cmn_ctx_stats_str[NSS_DTLS_CMN_CTX_STATS_MAX]; --extern void nss_dtls_cmn_strings_dentry_create(void); -- --#endif /* __NSS_DTLS_CMN_STRINGS_H */ ++#endif + nss_wifili_stats_dentry_create(); + nss_wifili_strings_dentry_create(); + +--- a/nss_wifili_log.c ++++ b/nss_wifili_log.c +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2018, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2018, 2020, 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. +@@ -157,7 +157,7 @@ static void nss_wifili_log_init_msg(stru + { + struct nss_wifili_init_msg *nwim __maybe_unused = &nwm->msg.init; + int32_t i; +- nss_trace("%p: NSS WIFILI Init Message:\n" ++ nss_trace("%px: NSS WIFILI Init Message:\n" + "WIFILI HAL Source Ring Base Address: %x\n" + "WIFILI HAL Source Ring Shadow Read Pointer Address: %x\n" + "WIFILI HAL Source Ring Shadow Write Pointer Address: %x\n" +@@ -210,7 +210,7 @@ static void nss_wifili_log_init_msg(stru + static void nss_wifili_log_pdev_init_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_pdev_init_msg *nwim __maybe_unused = &nwm->msg.pdevmsg; +- nss_trace("%p: NSS WIFILI PDEV Init Message:\n" ++ nss_trace("%px: NSS WIFILI PDEV Init Message:\n" + "WIFILI Radio ID: %x\n" + "WIFILI MAC Hardware Mode: %d\n" + "WIFILI Lower MAC ID: %x\n", +@@ -230,7 +230,7 @@ static void nss_wifili_log_pdev_init_msg + static void nss_wifili_log_pdev_deinit_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_pdev_deinit_msg *nwim __maybe_unused = &nwm->msg.pdevdeinit; +- nss_trace("%p: NSS WIFILI PDEV Deinit Message:\n" ++ nss_trace("%px: NSS WIFILI PDEV Deinit Message:\n" + "WIFILI Interface Number: %d\n", + nwim, nwim->ifnum); + } +@@ -242,7 +242,7 @@ static void nss_wifili_log_pdev_deinit_m + static void nss_wifili_log_peer_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_peer_msg *nwim __maybe_unused = &nwm->msg.peermsg; +- nss_trace("%p: NSS WIFILI Peer Message:\n" ++ nss_trace("%px: NSS WIFILI Peer Message:\n" + "WIFILI Peer MAC Address: %pM\n" + "WIFILI VAP ID: %d\n" + "WIFILI Peed ID: %d\n" +@@ -262,7 +262,7 @@ static void nss_wifili_log_peer_msg(stru + static void nss_wifili_log_peer_freelist_append_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_peer_freelist_append_msg *nwim __maybe_unused = &nwm->msg.peer_freelist_append; +- nss_trace("%p: NSS WIFILI Peer Memory Request Message:\n" ++ nss_trace("%px: NSS WIFILI Peer Memory Request Message:\n" + "WIFILI Starting Address of Freelist: %x\n" + "WIFILI Length: %d\n" + "WIFILI Maximum number of peer entries supported in pool: %d\n", +@@ -277,7 +277,7 @@ static void nss_wifili_log_peer_freelist + static void nss_wifili_log_wds_peer_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_wds_peer_msg *nwim __maybe_unused = &nwm->msg.wdspeermsg; +- nss_trace("%p: NSS WIFILI WDS Peer Message:\n" ++ nss_trace("%px: NSS WIFILI WDS Peer Message:\n" + "WIFILI Destination MAC: %pM\n" + "WIFILI Peer MAC: %pM\n", + nwim, nwim->dest_mac, nwim->peer_mac); +@@ -290,7 +290,7 @@ static void nss_wifili_log_wds_peer_msg( + static void nss_wifili_log_wds_active_info_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_wds_active_info_msg *nwim __maybe_unused = &nwm->msg.wdsinfomsg; +- nss_trace("%p: NSS WIFILI WDS Active Info Message:\n" ++ nss_trace("%px: NSS WIFILI WDS Active Info Message:\n" + "WIFILI Number OF Entries: %d\n" + "WIFILI Hardware AST Index: %d\n", + nwim, nwim->nentries, nwim->info[0].ast_idx); +@@ -303,7 +303,7 @@ static void nss_wifili_log_wds_active_in + static void nss_wifili_log_stats_cfg_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_stats_cfg_msg *nwim __maybe_unused = &nwm->msg.scm; +- nss_trace("%p: NSS WIFILI Stats Config Message:\n" ++ nss_trace("%px: NSS WIFILI Stats Config Message:\n" + "WIFILI Enable/Disable Config: %d\n", + nwim, nwim->cfg); + } +@@ -315,7 +315,7 @@ static void nss_wifili_log_stats_cfg_msg + static void nss_wifili_log_reo_tidq_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_reo_tidq_msg *nwim __maybe_unused = &nwm->msg.reotidqmsg; +- nss_trace("%p: NSS WIFILI reo tidq setup Message:\n" ++ nss_trace("%px: NSS WIFILI reo tidq setup Message:\n" + "WIFILI Traffic Identification Value: %d\n" + "WIFILI Peer ID: %d\n", + nwim, nwim->tid, nwim->peer_id); +@@ -328,7 +328,7 @@ static void nss_wifili_log_reo_tidq_msg( + static void nss_wifili_log_radio_cfg_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_radio_cfg_msg *nwim __maybe_unused = &nwm->msg.radiocfgmsg; +- nss_trace("%p: NSS WIFILI Radio Command Message:\n" ++ nss_trace("%px: NSS WIFILI Radio Command Message:\n" + "WIFILI Radio Interface Number %d\n", + nwim, nwim->radio_if_num); + } +@@ -340,7 +340,7 @@ static void nss_wifili_log_radio_cfg_msg + static void nss_wifili_log_wds_extn_peer_cfg_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_wds_extn_peer_cfg_msg *nwim __maybe_unused = &nwm->msg.wpeercfg; +- nss_trace("%p: NSS WIFILI WDS vendor extension configuration message:\n" ++ nss_trace("%px: NSS WIFILI WDS vendor extension configuration message:\n" + "WIFILI Peer MAC Addr: %pM\n" + "WIFILI WDS Flags: %d\n" + "WIFILI Peer ID: %d\n", +@@ -355,7 +355,7 @@ static void nss_wifili_log_wds_extn_peer + static void nss_wifili_log_soc_linkdesc_buf_info_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_soc_linkdesc_buf_info_msg *nwim __maybe_unused = &nwm->msg.linkdescinfomsg; +- nss_trace("%p: NSS WIFILI Link descriptor buffer address information:\n" ++ nss_trace("%px: NSS WIFILI Link descriptor buffer address information:\n" + "WIFILI Link Descriptor Low Address: %x\n" + "WIFILI Link Descriptor High Address: %x\n", + nwim, nwim->buffer_addr_low, +@@ -370,7 +370,7 @@ static void nss_wifili_log_peer_security + { + struct nss_wifili_peer_security_type_msg *nwim __maybe_unused = &nwm->msg.securitymsg; + int32_t i; +- nss_trace("%p: NSS WIFILI Peer Security Message:\n" ++ nss_trace("%px: NSS WIFILI Peer Security Message:\n" + "WIFILI Peer ID: %d\n" + "WIFILI Packet Type: %d\n" + "WIFILI Security Type: %d\n", +@@ -392,7 +392,7 @@ static void nss_wifili_log_peer_security + static void nss_wifili_log_peer_nawds_enable_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_peer_nawds_enable_msg *nwim __maybe_unused = &nwm->msg.nawdsmsg; +- nss_trace("%p: NSS WIFILI NAWDS enable for peer:\n" ++ nss_trace("%px: NSS WIFILI NAWDS enable for peer:\n" + "WIFILI Peer ID: %d\n" + "WIFILI Enable NAWDS: %d\n", + nwim, nwim->peer_id, nwim->is_nawds); +@@ -405,7 +405,7 @@ static void nss_wifili_log_peer_nawds_en + static void nss_wifili_log_dbdc_repeater_set_msg(struct nss_wifili_msg *nwm) + { + struct nss_wifili_dbdc_repeater_set_msg *nwim __maybe_unused = &nwm->msg.dbdcrptrmsg; +- nss_trace("%p: NSS WIFILI DBDC Repeater Enable Message:\n" ++ nss_trace("%px: NSS WIFILI DBDC Repeater Enable Message:\n" + "WIFILI DBDC Enable Flag: %d\n", + nwim, nwim->is_dbdc_en); + } +@@ -497,7 +497,7 @@ static void nss_wifili_log_verbose(struc + break; + + default: +- nss_warning("%p: Invalid message type\n", nwm); ++ nss_warning("%px: Invalid message type\n", nwm); + break; + } + } +@@ -509,11 +509,11 @@ static void nss_wifili_log_verbose(struc + void nss_wifili_log_tx_msg(struct nss_wifili_msg *nwm) + { + if (nwm->cm.type >= NSS_WIFILI_MAX_MSG) { +- nss_warning("%p: Invalid message type\n", nwm); ++ nss_warning("%px: Invalid message type\n", nwm); + return; + } + +- nss_info("%p: type[%d]:%s\n", nwm, nwm->cm.type, nss_wifili_log_message_types_str[nwm->cm.type]); ++ nss_info("%px: type[%d]:%s\n", nwm, nwm->cm.type, nss_wifili_log_message_types_str[nwm->cm.type]); + nss_wifili_log_verbose(nwm); + } + +@@ -524,26 +524,26 @@ void nss_wifili_log_tx_msg(struct nss_wi + void nss_wifili_log_rx_msg(struct nss_wifili_msg *nwm) + { + if (nwm->cm.response >= NSS_CMN_RESPONSE_LAST) { +- nss_warning("%p: Invalid response\n", nwm); ++ nss_warning("%px: Invalid response\n", nwm); + return; + } + + if (nwm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nwm->cm.response == NSS_CMN_RESPONSE_ACK)) { +- nss_info("%p: type[%d]:%s, response[%d]:%s\n", nwm, nwm->cm.type, ++ nss_info("%px: type[%d]:%s, response[%d]:%s\n", nwm, nwm->cm.type, + nss_wifili_log_message_types_str[nwm->cm.type], + nwm->cm.response, nss_cmn_response_str[nwm->cm.response]); + goto verbose; + } + + if (nwm->cm.error >= NSS_WIFILI_EMSG_UNKNOWN) { +- nss_warning("%p: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", ++ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", + nwm, nwm->cm.type, nss_wifili_log_message_types_str[nwm->cm.type], + nwm->cm.response, nss_cmn_response_str[nwm->cm.response], + nwm->cm.error); + goto verbose; + } + +- nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", ++ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", + nwm, nwm->cm.type, nss_wifili_log_message_types_str[nwm->cm.type], + nwm->cm.response, nss_cmn_response_str[nwm->cm.response], + nwm->cm.error, nss_wifili_log_error_response_types_str[nwm->cm.error]); +--- a/nss_wifili_stats.c ++++ b/nss_wifili_stats.c +@@ -248,6 +248,7 @@ void nss_wifili_stats_sync(struct nss_ct + nwss->soc_maxpdev = NSS_WIFILI_MAX_PDEV_NUM_MSG; + break; + ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + case NSS_WIFILI_EXTERNAL_INTERFACE0: + nwss = &soc_stats[1]; + nwss->soc_maxpdev = NSS_WIFILI_SOC_ATTACHED_MAX_PDEV_NUM; +@@ -257,9 +258,10 @@ void nss_wifili_stats_sync(struct nss_ct + nwss = &soc_stats[2]; + nwss->soc_maxpdev = NSS_WIFILI_SOC_ATTACHED_MAX_PDEV_NUM; + break; ++#endif + + default: +- nss_warning("%p: Invalid wifili interface\n", nss_ctx); ++ nss_warning("%px: Invalid wifili interface\n", nss_ctx); + return; + } + +@@ -436,6 +438,7 @@ void nss_wifili_stats_sync(struct nss_ct + /* + * update wbm ring stats + */ ++ stats->stats_wbm[NSS_WIFILI_STATS_WBM_IE_LOCAL_ALLOC_FAIL] += devstats->rxwbm_stats.invalid_buf_mgr; + stats->stats_wbm[NSS_WIFILI_STATS_WBM_SRC_DMA] += devstats->rxwbm_stats.err_src_rxdma; + stats->stats_wbm[NSS_WIFILI_STATS_WBM_SRC_DMA_CODE_INV] += devstats->rxwbm_stats.err_src_rxdma_code_inv; + stats->stats_wbm[NSS_WIFILI_STATS_WBM_SRC_REO] += devstats->rxwbm_stats.err_src_reo; +@@ -459,7 +462,7 @@ void nss_wifili_stats_notify(struct nss_ + + wifili_stats = kzalloc(sizeof(struct nss_wifili_stats_notification), GFP_KERNEL); + if (!wifili_stats) { +- nss_warning("%p: Failed to allocate memory for wifili stats\n", nss_ctx); ++ nss_warning("%px: Failed to allocate memory for wifili stats\n", nss_ctx); + return; + } + +@@ -469,6 +472,7 @@ void nss_wifili_stats_notify(struct nss_ + index = 0; + break; + ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + case NSS_WIFILI_EXTERNAL_INTERFACE0: + index = 1; + break; +@@ -476,9 +480,10 @@ void nss_wifili_stats_notify(struct nss_ + case NSS_WIFILI_EXTERNAL_INTERFACE1: + index = 2; + break; ++#endif + + default: +- nss_warning("%p: Invalid wifili interface\n", nss_ctx); ++ nss_warning("%px: Invalid wifili interface\n", nss_ctx); + goto done; + } + wifili_stats->if_num = if_num; +--- a/nss_wifili_strings.c ++++ b/nss_wifili_strings.c +@@ -138,6 +138,7 @@ struct nss_stats_info nss_wifili_strings + * wifili wbm ring stats + */ + struct nss_stats_info nss_wifili_strings_stats_wbm[NSS_WIFILI_STATS_WBM_MAX] = { ++ {"wbm_ie_local_alloc_fail" , NSS_STATS_TYPE_ERROR}, + {"wbm_src_dma" , NSS_STATS_TYPE_SPECIAL}, + {"wbm_src_dma_code_inv" , NSS_STATS_TYPE_SPECIAL}, + {"wbm_src_reo" , NSS_STATS_TYPE_SPECIAL}, +--- a/exports/nss_cmn.h ++++ b/exports/nss_cmn.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2014, 2016-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2014, 2016-2020, 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. +@@ -27,6 +27,11 @@ + * @{ + */ + ++/* ++ * Interface Number 1 Valid 7 Core 8 Type 16 Index ++ */ ++typedef int32_t nss_if_num_t; ++ + /** + * @struct nss_ctx_instance + * Forward declaration for structure that contains instance data for each +--- a/exports/nss_dynamic_interface.h ++++ b/exports/nss_dynamic_interface.h +@@ -22,6 +22,8 @@ + #ifndef __NSS_DYNAMIC_INTERFACE_H + #define __NSS_DYNAMIC_INTERFACE_H + ++#include "nss_fw_version.h" ++ + /** + * @addtogroup nss_dynamic_interface_subsystem + * @{ +@@ -57,7 +59,11 @@ enum nss_dynamic_interface_type { + NSS_DYNAMIC_INTERFACE_TYPE_BRIDGE, + NSS_DYNAMIC_INTERFACE_TYPE_VLAN, + NSS_DYNAMIC_INTERFACE_TYPE_RESERVED_3, ++#if (NSS_FW_VERSION_CODE <= NSS_FW_VERSION(11,0)) ++ NSS_DYNAMIC_INTERFACE_TYPE_WIFILI, ++#else + NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_INTERNAL, ++#endif + NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_INNER, + NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_OUTER, + NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INNER, +@@ -94,16 +100,20 @@ enum nss_dynamic_interface_type { + NSS_DYNAMIC_INTERFACE_TYPE_IGS, + NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_US, + NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_DS, ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_INNER, + NSS_DYNAMIC_INTERFACE_TYPE_VXLAN_OUTER, + NSS_DYNAMIC_INTERFACE_TYPE_MATCH, ++#endif + NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_N2H, + NSS_DYNAMIC_INTERFACE_TYPE_RMNET_RX_H2N, ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_EXTERNAL0, + NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_EXTERNAL1, + NSS_DYNAMIC_INTERFACE_TYPE_TLS_INNER, + NSS_DYNAMIC_INTERFACE_TYPE_TLS_OUTER, + NSS_DYNAMIC_INTERFACE_TYPE_MIRROR, ++#endif + NSS_DYNAMIC_INTERFACE_TYPE_MAX + }; + +--- a/exports/nss_ipv4.h ++++ b/exports/nss_ipv4.h +@@ -26,6 +26,8 @@ + #include "nss_stats_public.h" + #endif + ++#include "nss_fw_version.h" ++ + /** + * @addtogroup nss_ipv4_subsystem + * @{ +@@ -734,8 +736,10 @@ enum nss_ipv4_exception_events { + NSS_IPV4_EXCEPTION_EVENT_MC_PBUF_ALLOC_FAILURE, + NSS_IPV4_EXCEPTION_EVENT_PPPOE_BRIDGE_NO_ICME, + NSS_IPV4_EXCEPTION_EVENT_PPPOE_NO_SESSION, ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + NSS_IPV4_EXCEPTION_EVENT_ICMP_IPV4_GRE_HEADER_INCOMPLETE, + NSS_IPV4_EXCEPTION_EVENT_ICMP_IPV4_ESP_HEADER_INCOMPLETE, ++#endif + NSS_IPV4_EXCEPTION_EVENT_MAX + }; + +--- /dev/null ++++ b/exports/nss_fw_version.h +@@ -0,0 +1,11 @@ ++#ifndef __NSS_FW_VERSION_H ++#define __NSS_FW_VERSION_H ++ ++#define NSS_FW_VERSION_MAJOR 11 ++#define NSS_FW_VERSION_MINOR 0 ++ ++#define NSS_FW_VERSION(a,b) (((a) << 8) + (b)) ++ ++#define NSS_FW_VERSION_CODE NSS_FW_VERSION(NSS_FW_VERSION_MAJOR, NSS_FW_VERSION_MINOR) ++ ++#endif /* __NSS_FW_VERSION_H */ +--- a/nss_hlos_if.h ++++ b/nss_hlos_if.h +@@ -1,6 +1,6 @@ + /* + ************************************************************************** +- * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2013-2019, 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. +@@ -33,7 +33,11 @@ + */ + #if defined (NSS_MEM_PROFILE_LOW) + #define NSS_DEFAULT_NUM_CONN 512 /* Default number of connections for IPv4 and IPv6 each, for low memory profile */ ++#if defined (NSS_DRV_IPV6_ENABLE) + #define NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6 1024 /* MAX Connection shared between IPv4 and IPv6 for low memory profile */ ++#else ++#define NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6 512 /* MAX Connection for IPv4 for low memory profile */ ++#endif + #define NSS_LOW_MEM_EMPTY_POOL_BUF_SZ 4096 /* Default empty buffer pool size for low profile */ + #elif defined (NSS_MEM_PROFILE_MEDIUM) + #define NSS_DEFAULT_NUM_CONN 2048 /* Default number of connections for IPv4 and IPv6 each, for medium memory profile */ --- a/nss_dynamic_interface_stats.c +++ b/nss_dynamic_interface_stats.c -@@ -26,10 +26,10 @@ - const char *nss_dynamic_interface_type_names[NSS_DYNAMIC_INTERFACE_TYPE_MAX] = { - "NSS_DYNAMIC_INTERFACE_TYPE_NONE", - "NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR", -- "NSS_DYNAMIC_INTERFACE_TYPE_RESERVED_5", -+ "NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP", - "NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_INNER", - "NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER", -- "NSS_DYNAMIC_INTERFACE_TYPE_RESERVED", -+ "NSS_DYNAMIC_INTERFACE_TYPE_WIFI", - "NSS_DYNAMIC_INTERFACE_TYPE_VAP", - "NSS_DYNAMIC_INTERFACE_TYPE_RESERVED_0", - "NSS_DYNAMIC_INTERFACE_TYPE_PPPOE", @@ -43,7 +43,11 @@ const char *nss_dynamic_interface_type_n "NSS_DYNAMIC_INTERFACE_TYPE_BRIDGE", "NSS_DYNAMIC_INTERFACE_TYPE_VLAN", @@ -9672,7 +19777,7 @@ "NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_INNER", "NSS_DYNAMIC_INTERFACE_TYPE_MAP_T_OUTER", "NSS_DYNAMIC_INTERFACE_TYPE_GRE_TUNNEL_INNER", -@@ -80,15 +84,22 @@ const char *nss_dynamic_interface_type_n +@@ -80,13 +84,22 @@ const char *nss_dynamic_interface_type_n "NSS_DYNAMIC_INTERFACE_TYPE_IGS", "NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_US", "NSS_DYNAMIC_INTERFACE_TYPE_CLMAP_DS", @@ -9686,8 +19791,6 @@ +#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) "NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_EXTERNAL0", "NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_EXTERNAL1", -- "NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_HOST_INNER", -- "NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_OUTER", +#endif +#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,1)) + "NSS_DYNAMIC_INTERFACE_TYPE_TLS_INNER", @@ -9697,7998 +19800,6 @@ }; /* ---- a/nss_edma_lite.c -+++ /dev/null -@@ -1,243 +0,0 @@ --/* -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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. -- */ -- --/* -- * nss_edma_lite.c -- * NSS EDMA APIs -- */ --#include "nss_edma_lite_stats.h" --#include "nss_edma_lite_strings.h" --#include -- --/* -- ********************************** -- Rx APIs -- ********************************** -- */ --static bool is_map_configured = false; -- --/* -- * nss_edma_lite_interface_handler() -- * Handle NSS -> HLOS messages for EDMA node -- */ --static void nss_edma_lite_interface_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) --{ -- struct nss_edma_lite_msg *nelm = (struct nss_edma_lite_msg *)ncm; -- nss_edma_lite_msg_callback_t cb; -- -- /* -- * Is this a valid request/response packet? -- */ -- if (nelm->cm.type >= NSS_EDMA_LITE_MSG_TYPE_MAX) { -- nss_warning("%px: received invalid message %d for edma_lite interface", nss_ctx, nelm->cm.type); -- return; -- } -- -- /* -- * Handle different types of messages -- */ -- switch (nelm->cm.type) { -- case NSS_EDMA_LITE_MSG_NODE_STATS_SYNC: -- nss_edma_lite_node_stats_sync(nss_ctx, &nelm->msg.node_stats); -- break; -- case NSS_EDMA_LITE_MSG_RING_STATS_SYNC: -- nss_edma_lite_ring_stats_sync(nss_ctx, &nelm->msg.ring_stats); -- break; -- case NSS_EDMA_LITE_MSG_ERR_STATS_SYNC: -- nss_edma_lite_err_stats_sync(nss_ctx, &nelm->msg.err_stats); -- break; -- default: -- if (ncm->response != NSS_CMN_RESPONSE_ACK) { -- /* -- * Check response -- */ -- nss_info("%px: Received response %d for type %d, interface %d", -- nss_ctx, ncm->response, ncm->type, ncm->interface); -- } -- } -- -- /* -- * Update the callback and app_data for NOTIFY messages, edma_lite sends all notify messages -- * to the same callback/app_data. -- */ -- if (nelm->cm.response == NSS_CMN_RESPONSE_NOTIFY) { -- ncm->cb = (nss_ptr_t)nss_ctx->edma_lite_callback; -- ncm->app_data = (nss_ptr_t)nss_ctx->edma_lite_ctx; -- } -- -- /* -- * Do we have a callback? -- */ -- if (!ncm->cb) { -- return; -- } -- -- /* -- * Callback -- */ -- cb = (nss_edma_lite_msg_callback_t)ncm->cb; -- cb((void *)ncm->app_data, nelm); --} -- --/* -- * nss_edma_lite_msg_cfg_map_callback() -- */ --static void nss_edma_lite_msg_cfg_map_callback(void *app_data, struct nss_edma_lite_msg *nelm) --{ -- struct nss_ctx_instance *nss_ctx __attribute__((unused)) = (struct nss_ctx_instance *)app_data; -- if (nelm->cm.response != NSS_CMN_RESPONSE_ACK) { -- nss_warning("%px: nss edma_lite_map configuration failed: %d for NSS core %d\n", -- nss_ctx, nelm->cm.error, nss_ctx->id); -- return; -- } -- -- /* TODO: SHould we protect this with some lock */ -- if (nelm->cm.type == NSS_EDMA_LITE_MSG_TYPE_RING_MAP) { -- is_map_configured = true; -- } -- -- nss_info("%px: nss edma_lite_map configuration succeeded for NSS core %d\n", nss_ctx, nss_ctx->id); --} -- --/* -- * nss_edma_lite_tx_msg() -- * Transmit an EDMA lite config message to the FW with a specified size. -- */ --nss_tx_status_t nss_edma_lite_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_edma_lite_msg *nelm) --{ -- struct nss_cmn_msg *ncm = &nelm->cm; -- -- if (ncm->type >= NSS_EDMA_LITE_MSG_TYPE_MAX) { -- nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); -- return NSS_TX_FAILURE; -- } -- -- return nss_core_send_cmd(nss_ctx, nelm, sizeof(*nelm), NSS_NBUF_PAYLOAD_SIZE); --} --EXPORT_SYMBOL(nss_edma_lite_tx_msg); -- --bool nss_edma_lite_is_configured(void) --{ -- return is_map_configured; --} --EXPORT_SYMBOL(nss_edma_lite_is_configured); -- --/* -- * nss_edma_lite_msg_cfg_map() -- * Send ring number to EDMA lite. -- */ --nss_tx_status_t nss_edma_lite_msg_cfg_map(struct nss_ctx_instance *nss_ctx) --{ -- int32_t status; -- struct nss_edma_lite_msg nelm; -- struct nss_edma_lite_ring_map *cfg_map; -- uint32_t txdesc_num, txcmpl_num, rxfill_num, rxdesc_num; -- -- nss_edma_lite_msg_init(&nelm, NSS_EDMA_LITE_INTERFACE, NSS_EDMA_LITE_MSG_TYPE_RING_MAP, -- sizeof(struct nss_edma_lite_ring_map), nss_edma_lite_msg_cfg_map_callback, (void *)nss_ctx); -- -- /* -- * Invoke DP API to get point offload information -- */ -- nss_dp_point_offload_info_get(&txdesc_num, &txcmpl_num, &rxfill_num, &rxdesc_num); -- -- cfg_map = &nelm.msg.map; -- cfg_map->txdesc_num = txdesc_num; -- cfg_map->txcmpl_num = txcmpl_num; -- cfg_map->rxfill_num = rxfill_num; -- cfg_map->rxdesc_num = rxdesc_num; -- -- status = nss_edma_lite_tx_msg(nss_ctx, &nelm); -- if (unlikely(status != NSS_TX_SUCCESS)) { -- return status; -- } -- -- return NSS_TX_SUCCESS; --} -- --/* -- * nss_edma_lite_msg_init() -- * Initialize EDMA LITE message. -- */ --void nss_edma_lite_msg_init(struct nss_edma_lite_msg *nelm, uint16_t if_num, uint32_t type, uint32_t len, -- nss_edma_lite_msg_callback_t cb, void *app_data) --{ -- nss_cmn_msg_init(&nelm->cm, if_num, type, len, (void *)cb, app_data); --} --EXPORT_SYMBOL(nss_edma_lite_msg_init); -- --/* -- * nss_edma_lite_notify_register() -- * Register to received EDMA events. -- */ --void nss_edma_lite_notify_register(nss_edma_lite_msg_callback_t cb, void *app_data) --{ -- struct nss_ctx_instance *nss_ctx; -- int i = 0; -- -- for (i = 0; i < NSS_MAX_CORES; i++) { -- int id = nss_top_main.edma_lite_handler_id[i]; -- if (id >= 0) { -- nss_ctx = &nss_top_main.nss[id]; -- nss_ctx->edma_lite_callback = cb; -- nss_ctx->edma_lite_ctx = app_data; -- } -- } --} --EXPORT_SYMBOL(nss_edma_lite_notify_register); -- --/* -- * nss_edma_lite_notify_unregister() -- * Unregister to received EDMA events. -- */ --void nss_edma_lite_notify_unregister(void) --{ -- struct nss_ctx_instance *nss_ctx; -- int i = 0; -- -- for (i = 0; i < NSS_MAX_CORES; i++) { -- int id = nss_top_main.edma_lite_handler_id[i]; -- if (id >= 0) { -- nss_ctx = &nss_top_main.nss[id]; -- nss_ctx->edma_lite_callback = NULL; -- } -- } --} --EXPORT_SYMBOL(nss_edma_lite_notify_unregister); -- --/* -- * nss_edma_lite_enabled() -- */ --bool nss_edma_lite_enabled(struct nss_ctx_instance *nss_ctx) --{ -- int id = nss_top_main.edma_lite_handler_id[nss_ctx->id]; -- if (id == nss_ctx->id) -- return true; -- -- return false; --} --EXPORT_SYMBOL(nss_edma_lite_enabled); -- --/* -- * nss_edma_lite_register_handler() -- */ --void nss_edma_lite_register_handler(struct nss_ctx_instance *nss_ctx) --{ -- nss_core_register_handler(nss_ctx, NSS_EDMA_LITE_INTERFACE, nss_edma_lite_interface_handler, NULL); -- -- nss_edma_lite_stats_dentry_create(); -- nss_edma_lite_strings_dentry_create(); --} ---- a/nss_edma_lite_stats.c -+++ /dev/null -@@ -1,579 +0,0 @@ --/* -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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. -- */ -- --/* -- * nss_edma_lite_stats.c -- * NSS EDMA statistics APIs -- */ -- --#include "nss_edma_lite_stats.h" --#include "nss_edma_lite_strings.h" -- --/* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_edma_lite_stats_notifier); -- --struct nss_edma_lite_stats edma_stats; -- --/* -- ********************************** -- EDMA statistics APIs -- ********************************** -- */ -- --/* -- * nss_edma_lite_node_stats_read() -- * Read EDMA node stats -- */ --static ssize_t nss_edma_lite_node_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- int32_t i; -- -- /* -- * max output lines = #stats + start tag line + end tag line + three blank lines -- */ -- uint32_t max_output_lines = (NSS_STATS_NODE_MAX + 2) + 3; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- size_t size_wr = 0; -- ssize_t bytes_read = 0; -- uint64_t *stats_shadow; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(lbuf == NULL)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -- -- stats_shadow = kzalloc(NSS_STATS_NODE_MAX * sizeof(uint64_t), GFP_KERNEL); -- if (unlikely(stats_shadow == NULL)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "edma", NSS_STATS_SINGLE_CORE); -- -- /* -- * Common node stats -- */ -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Node stats:\n\n"); -- spin_lock_bh(&nss_top_main.stats_lock); -- -- for (i = 0; (i < NSS_STATS_NODE_MAX); i++) -- stats_shadow[i] = edma_stats.node_stats[i]; -- -- spin_unlock_bh(&nss_top_main.stats_lock); -- size_wr += nss_stats_print("edma_node", NULL, NSS_STATS_SINGLE_INSTANCE -- , nss_edma_lite_strings_stats_node -- , stats_shadow -- , NSS_STATS_NODE_MAX -- , lbuf, size_wr, size_al); -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- kfree(lbuf); -- kfree(stats_shadow); -- -- return bytes_read; --} -- --/* -- * nss_edma_lite_txring_stats_read() -- * Read EDMA Tx ring stats -- */ --static ssize_t nss_edma_lite_txring_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- int32_t i = 0; -- -- /* -- * max output lines = #stats + start tag line + end tag line + three blank lines -- */ -- uint32_t max_output_lines = (NSS_EDMA_LITE_STATS_TX_MAX + 2) + 3; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- size_t size_wr = 0; -- ssize_t bytes_read = 0; -- uint64_t *stats_shadow; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(lbuf == NULL)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -- -- stats_shadow = kzalloc(NSS_EDMA_LITE_STATS_TX_MAX * sizeof(uint64_t), GFP_KERNEL); -- if (unlikely(stats_shadow == NULL)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- -- size_wr = scnprintf(lbuf, size_al, "edma Tx ring stats start:\n\n"); -- -- /* -- * Tx ring stats -- */ -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Tx ring stats:\n\n"); -- spin_lock_bh(&nss_top_main.stats_lock); -- for (i = 0; (i < NSS_EDMA_LITE_STATS_TX_MAX); i++) -- stats_shadow[i] = edma_stats.tx_stats[i]; -- -- spin_unlock_bh(&nss_top_main.stats_lock); -- -- size_wr += nss_stats_print("edma_tx_ring", NULL, NSS_STATS_SINGLE_INSTANCE -- , nss_edma_lite_strings_stats_tx -- , stats_shadow -- , NSS_EDMA_LITE_STATS_TX_MAX -- , lbuf, size_wr, size_al); -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- kfree(lbuf); -- kfree(stats_shadow); -- -- return bytes_read; --} -- --/* -- * nss_edma_lite_rxring_stats_read() -- * Read EDMA rxring stats -- */ --static ssize_t nss_edma_lite_rxring_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- int32_t i= 0; -- -- /* -- * max output lines = #stats + start tag line + end tag line + three blank lines -- */ -- uint32_t max_output_lines = (NSS_EDMA_LITE_STATS_RX_MAX + 2) + 3; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- size_t size_wr = 0; -- ssize_t bytes_read = 0; -- uint64_t *stats_shadow; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(lbuf == NULL)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -- -- stats_shadow = kzalloc(NSS_EDMA_LITE_STATS_RX_MAX * sizeof(uint64_t), GFP_KERNEL); -- if (unlikely(stats_shadow == NULL)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- -- /* -- * RX ring stats -- */ -- spin_lock_bh(&nss_top_main.stats_lock); -- for (i = 0; (i < NSS_EDMA_LITE_STATS_RX_MAX); i++) -- stats_shadow[i] = edma_stats.rx_stats[i]; -- -- spin_unlock_bh(&nss_top_main.stats_lock); -- size_wr += nss_stats_print("edma_rx_ring", NULL, NSS_STATS_SINGLE_INSTANCE -- , nss_edma_lite_strings_stats_rx -- , stats_shadow -- , NSS_EDMA_LITE_STATS_RX_MAX -- , lbuf, size_wr, size_al); -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- kfree(lbuf); -- kfree(stats_shadow); -- -- return bytes_read; --} -- --/* -- * nss_edma_lite_txcmplring_stats_read() -- * Read EDMA txcmplring stats -- */ --static ssize_t nss_edma_lite_txcmplring_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- int32_t i = 0; -- -- /* -- * max output lines = #stats + start tag line + end tag line + three blank lines -- */ -- uint32_t max_output_lines = (NSS_EDMA_LITE_STATS_TXCMPL_MAX + 2) + 3; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- size_t size_wr = 0; -- ssize_t bytes_read = 0; -- uint64_t *stats_shadow; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(lbuf == NULL)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -- -- stats_shadow = kzalloc(NSS_EDMA_LITE_STATS_TXCMPL_MAX * sizeof(uint64_t), GFP_KERNEL); -- if (unlikely(stats_shadow == NULL)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- -- size_wr = scnprintf(lbuf, size_al, "edma Tx cmpl ring stats start:\n\n"); -- -- /* -- * Tx cmpl ring stats -- */ -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Tx cmpl ring stats:\n\n"); -- spin_lock_bh(&nss_top_main.stats_lock); -- for (i = 0; (i < NSS_EDMA_LITE_STATS_TXCMPL_MAX); i++) -- stats_shadow[i] = edma_stats.txcmpl_stats[i]; -- -- spin_unlock_bh(&nss_top_main.stats_lock); -- size_wr += nss_stats_print("edma_tx_cmpl_ring", NULL, NSS_STATS_SINGLE_INSTANCE -- , nss_edma_lite_strings_stats_txcmpl -- , stats_shadow -- , NSS_EDMA_LITE_STATS_TXCMPL_MAX -- , lbuf, size_wr, size_al); -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nedma Tx cmpl ring stats end\n\n"); -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- kfree(lbuf); -- kfree(stats_shadow); -- -- return bytes_read; --} -- --/* -- * nss_edma_lite_rxfillring_stats_read() -- * Read EDMA rxfillring stats -- */ --static ssize_t nss_edma_lite_rxfillring_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- int32_t i = 0; -- -- /* -- * max output lines = #stats + start tag line + end tag line + three blank lines -- */ -- uint32_t max_output_lines = (NSS_EDMA_LITE_STATS_RXFILL_MAX + 2) + 3; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- size_t size_wr = 0; -- ssize_t bytes_read = 0; -- uint64_t *stats_shadow; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(lbuf == NULL)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -- -- stats_shadow = kzalloc(NSS_EDMA_LITE_STATS_RXFILL_MAX * sizeof(uint64_t), GFP_KERNEL); -- if (unlikely(stats_shadow == NULL)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- -- size_wr = scnprintf(lbuf, size_al, "edma Rx fill ring stats start:\n\n"); -- -- /* -- * Rx fill ring stats -- */ -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "Rx fill ring stats:\n\n"); -- spin_lock_bh(&nss_top_main.stats_lock); -- for (i = 0; i < NSS_EDMA_LITE_STATS_RXFILL_MAX; i++) { -- stats_shadow[i] = edma_stats.rxfill_stats[i]; -- } -- -- spin_unlock_bh(&nss_top_main.stats_lock); -- size_wr += nss_stats_print("edma_rx_fill_ring", NULL -- , NSS_STATS_SINGLE_INSTANCE -- , nss_edma_lite_strings_stats_rxfill -- , stats_shadow -- , NSS_EDMA_LITE_STATS_RXFILL_MAX -- , lbuf, size_wr, size_al); -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- kfree(lbuf); -- kfree(stats_shadow); -- -- return bytes_read; --} -- --/* -- * nss_edma_lite_err_stats_read() -- * Read EDMA err stats -- */ --static ssize_t nss_edma_lite_err_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- int32_t i; -- -- /* -- * max output lines = #stats + start tag line + end tag line + three blank lines -- */ -- uint32_t max_output_lines = (NSS_EDMA_LITE_ERR_STATS_MAX + 2) + 3; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- size_t size_wr = 0; -- ssize_t bytes_read = 0; -- uint64_t *stats_shadow; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(lbuf == NULL)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -- -- stats_shadow = kzalloc(NSS_EDMA_LITE_ERR_STATS_MAX * sizeof(uint64_t), GFP_KERNEL); -- if (unlikely(stats_shadow == NULL)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- -- size_wr = scnprintf(lbuf, size_al, "edma error stats start:\n\n"); -- -- /* -- * Common node stats -- */ -- spin_lock_bh(&nss_top_main.stats_lock); -- -- for (i = 0; (i < NSS_EDMA_LITE_ERR_STATS_MAX); i++) -- stats_shadow[i] = edma_stats.err[i]; -- -- spin_unlock_bh(&nss_top_main.stats_lock); -- size_wr += nss_stats_print("edma_err", NULL, NSS_STATS_SINGLE_INSTANCE -- , nss_edma_lite_strings_stats_err_map -- , stats_shadow -- , NSS_EDMA_LITE_ERR_STATS_MAX -- , lbuf, size_wr, size_al); -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- kfree(lbuf); -- kfree(stats_shadow); -- -- return bytes_read; --} -- --/* -- * edma_node_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(edma_lite_node); -- --/* -- * edma_txring_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(edma_lite_txring); -- --/* -- * edma_rxring_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(edma_lite_rxring); -- --/* -- * edma_txcmplring_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(edma_lite_txcmplring); -- --/* -- * edma_rxfillring_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(edma_lite_rxfillring); -- --/* -- * edma_err_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(edma_lite_err); -- --/* -- * nss_edma_lite_stats_dentry_create() -- * Create edma statistics debug entry. -- */ --void nss_edma_lite_stats_dentry_create(void) --{ -- struct dentry *edma_d = NULL; -- struct dentry *edma_rings_dir_d = NULL; -- struct dentry *edma_tx_d = NULL; -- struct dentry *edma_rx_d = NULL; -- struct dentry *edma_txcmpl_d = NULL; -- struct dentry *edma_rxfill_d = NULL; -- struct dentry *edma_err_stats_d = NULL; -- struct dentry *edma_node_stats_d = NULL; -- -- edma_d = debugfs_create_dir("edma_lite", nss_top_main.stats_dentry); -- if (unlikely(edma_d == NULL)) { -- nss_warning("Failed to create qca-nss-drv/stats/edma directory"); -- return; -- } -- -- /* -- * edma node stats -- */ -- edma_node_stats_d = debugfs_create_file("node_stats", 0400, edma_d, &nss_top_main, &nss_edma_lite_node_stats_ops); -- if (unlikely(edma_node_stats_d == NULL)) { -- nss_warning("Failed to create qca-nss-drv/stats/edma/node_stats file"); -- return; -- } -- -- /* -- * edma error stats -- */ -- edma_err_stats_d = debugfs_create_file("err_stats", 0400, edma_d, &nss_top_main, &nss_edma_lite_err_stats_ops); -- if (unlikely(edma_err_stats_d == NULL)) { -- nss_warning("Failed to create qca-nss-drv/stats/edma/err_stats file"); -- return; -- } -- -- /* -- * edma ring stats -- */ -- edma_rings_dir_d = debugfs_create_dir("rings", edma_d); -- if (unlikely(edma_rings_dir_d == NULL)) { -- nss_warning("Failed to create qca-nss-drv/stats/edma/rings directory"); -- return; -- } -- -- /* -- * edma tx ring stats -- */ -- edma_tx_d = debugfs_create_file("tx", 0400, edma_rings_dir_d, &nss_top_main, &nss_edma_lite_txring_stats_ops); -- if (unlikely(edma_tx_d == NULL)) { -- nss_warning("Failed to create qca-nss-drv/stats/edma/rings/tx file"); -- return; -- } -- -- /* -- * edma rx ring stats -- */ -- edma_rx_d = debugfs_create_file("rx", 0400, edma_rings_dir_d, &nss_top_main, &nss_edma_lite_rxring_stats_ops); -- if (unlikely(edma_rx_d == NULL)) { -- nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rx file"); -- return; -- } -- -- /* -- * edma tx cmpl ring stats -- */ -- edma_txcmpl_d = debugfs_create_file("txcmpl", 0400, edma_rings_dir_d, &nss_top_main, &nss_edma_lite_txcmplring_stats_ops); -- if (unlikely(edma_txcmpl_d == NULL)) { -- nss_warning("Failed to create qca-nss-drv/stats/edma/rings/txcmpl file"); -- return; -- } -- -- /* -- * edma rx fill ring stats -- */ -- edma_rxfill_d = debugfs_create_file("rxfill", 0400, edma_rings_dir_d, &nss_top_main, &nss_edma_lite_rxfillring_stats_ops); -- if (unlikely(edma_rxfill_d == NULL)) { -- nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rxfill file"); -- return; -- } --} -- --/* -- * nss_edma_lite_node_stats_sync() -- * Handle the syncing of EDMA node statistics. -- */ --void nss_edma_lite_node_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_lite_node_stats_sync *nerss) --{ -- int32_t i; -- struct nss_top_instance *nss_top = nss_ctx->nss_top; -- -- spin_lock_bh(&nss_top->stats_lock); -- -- /* -- * edma node stats -- */ -- edma_stats.node_stats[NSS_STATS_NODE_RX_PKTS] += nerss->node_stats.rx_packets; -- edma_stats.node_stats[NSS_STATS_NODE_RX_BYTES] += nerss->node_stats.rx_bytes; -- edma_stats.node_stats[NSS_STATS_NODE_TX_PKTS] += nerss->node_stats.tx_packets; -- edma_stats.node_stats[NSS_STATS_NODE_TX_BYTES] += nerss->node_stats.tx_bytes; -- -- for (i = 0; i < NSS_MAX_NUM_PRI; i++) { -- edma_stats.node_stats[NSS_STATS_NODE_RX_QUEUE_0_DROPPED + i] += nerss->node_stats.rx_dropped[i]; -- } -- -- spin_unlock_bh(&nss_top->stats_lock); --} -- --/* -- * nss_edma_lite_ring_stats_sync() -- * Handle the syncing of EDMA ring statistics. -- */ --void nss_edma_lite_ring_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_lite_ring_stats_sync *nerss) --{ -- struct nss_top_instance *nss_top = nss_ctx->nss_top; -- -- spin_lock_bh(&nss_top->stats_lock); -- -- /* -- * edma tx ring stats -- */ -- edma_stats.tx_stats[NSS_EDMA_LITE_STATS_TX_ERR] += nerss->tx_ring.tx_err; -- edma_stats.tx_stats[NSS_EDMA_LITE_STATS_TX_DROPPED] += nerss->tx_ring.tx_dropped; -- edma_stats.tx_stats[NSS_EDMA_LITE_STATS_TX_DESC] += nerss->tx_ring.desc_cnt; -- -- /* -- * edma rx ring stats -- */ -- edma_stats.rx_stats[NSS_EDMA_LITE_STATS_RX_DESC] += nerss->rx_ring.desc_cnt; -- -- /* -- * edma tx cmpl ring stats -- */ -- edma_stats.txcmpl_stats[NSS_EDMA_LITE_STATS_TXCMPL_DESC] += nerss->txcmpl_ring.desc_cnt; -- -- /* -- * edma rx fill ring stats -- */ -- edma_stats.rxfill_stats[NSS_EDMA_LITE_STATS_RXFILL_DESC] += nerss->rxfill_ring.desc_cnt; -- -- spin_unlock_bh(&nss_top->stats_lock); --} -- --/* -- * nss_edma_lite_err_stats_sync() -- * Handle the syncing of EDMA error statistics. -- */ --void nss_edma_lite_err_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_lite_err_stats_sync *nerss) --{ -- -- struct nss_top_instance *nss_top = nss_ctx->nss_top; -- -- spin_lock_bh(&nss_top->stats_lock); -- edma_stats.err[NSS_EDMA_LITE_ALLOC_FAIL_CNT] += nerss->alloc_fail_cnt; -- spin_unlock_bh(&nss_top->stats_lock); --} -- --/* -- * nss_edma_lite_stats_notify() -- * Calls statistics notifier. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_edma_lite_stats_notify(struct nss_ctx_instance *nss_ctx) --{ -- uint32_t core_id = nss_ctx->id; -- -- atomic_notifier_call_chain(&nss_edma_lite_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&core_id); --} -- --/* -- * nss_edma_lite_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_edma_lite_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_edma_lite_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_edma_lite_stats_register_notifier); -- --/* -- * nss_edma_lite_stats_unregister_notifier() -- * Deregisters stats notifier. -- */ --int nss_edma_lite_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_edma_lite_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_edma_lite_stats_unregister_notifier); ---- a/nss_edma_lite_stats.h -+++ /dev/null -@@ -1,36 +0,0 @@ --/* -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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. -- */ -- --/* -- * nss_edma_lite_stats.h -- * NSS EDMA statistics header file. -- */ -- --#ifndef __NSS_EDMA_LITE_STATS_H --#define __NSS_EDMA_LITE_STATS_H -- --#include "nss_core.h" -- --/* -- * NSS EDMA statistics APIs -- */ --extern void nss_edma_lite_stats_notify(struct nss_ctx_instance *nss_ctx); --extern void nss_edma_lite_node_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_lite_node_stats_sync *nerss); --extern void nss_edma_lite_ring_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_lite_ring_stats_sync *nerss); --extern void nss_edma_lite_err_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_edma_lite_err_stats_sync *nerss); --extern void nss_edma_lite_stats_dentry_create(void); -- --#endif /* __NSS_EDMA_LITE_STATS_H */ ---- a/nss_edma_lite_strings.c -+++ /dev/null -@@ -1,246 +0,0 @@ --/* -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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 --#include "nss_strings.h" -- --/* -- * nss_edma_lite_strings_stats_node -- * EDMA statistics strings. -- */ --struct nss_stats_info nss_edma_lite_strings_stats_node[NSS_STATS_NODE_MAX] = { -- {"rx_pkts" , NSS_STATS_TYPE_COMMON}, -- {"rx_byts" , NSS_STATS_TYPE_COMMON}, -- {"tx_pkts" , NSS_STATS_TYPE_COMMON}, -- {"tx_byts" , NSS_STATS_TYPE_COMMON}, -- {"rx_queue[0]_drops" , NSS_STATS_TYPE_DROP}, -- {"rx_queue[1]_drops" , NSS_STATS_TYPE_DROP}, -- {"rx_queue[2]_drops" , NSS_STATS_TYPE_DROP}, -- {"rx_queue[3]_drops" , NSS_STATS_TYPE_DROP} --}; -- --/* -- * nss_edma_lite_node_stats_strings_read() -- * Read EDMA node statistics names. -- */ --static ssize_t nss_edma_lite_node_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_edma_lite_strings_stats_node, NSS_STATS_NODE_MAX); --} -- --/* -- * nss_edma_lite_node_stats_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_lite_node_stats); -- --/* -- * nss_edma_lite_strings_stats_tx -- */ --struct nss_stats_info nss_edma_lite_strings_stats_tx[NSS_EDMA_LITE_STATS_TX_MAX] = { -- {"tx_err" , NSS_STATS_TYPE_ERROR}, -- {"tx_drops" , NSS_STATS_TYPE_DROP}, -- {"desc_cnt" , NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_edma_lite_txring_strings_read() -- * Read EDMA txring names. -- */ --static ssize_t nss_edma_lite_txring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_edma_lite_strings_stats_tx, NSS_EDMA_LITE_STATS_TX_MAX); --} -- --/* -- * edma_txring_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_lite_txring); -- --/* -- * nss_edma_lite_strings_stats_rx -- */ --struct nss_stats_info nss_edma_lite_strings_stats_rx[NSS_EDMA_LITE_STATS_RX_MAX] = { -- {"desc_cnt" , NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_edma_lite_rxring_strings_read() -- * Read EDMA rxring names. -- */ --static ssize_t nss_edma_lite_rxring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_edma_lite_strings_stats_rx, NSS_EDMA_LITE_STATS_RX_MAX); --} -- --/* -- * edma_rxring_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_lite_rxring); -- --/* -- * nss_edma_lite_strings_stats_txcmpl -- */ --struct nss_stats_info nss_edma_lite_strings_stats_txcmpl[NSS_EDMA_LITE_STATS_TXCMPL_MAX] = { -- {"desc_cnt" , NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_edma_lite_txcmplring_strings_read() -- * Read EDMA txcmplring names. -- */ --static ssize_t nss_edma_lite_txcmplring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_edma_lite_strings_stats_txcmpl, NSS_EDMA_LITE_STATS_TXCMPL_MAX); --} -- --/* -- * edma_txcmplring_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_lite_txcmplring); -- --/* -- * nss_edma_lite_strings_stats_rxfill -- */ --struct nss_stats_info nss_edma_lite_strings_stats_rxfill[NSS_EDMA_LITE_STATS_RXFILL_MAX] = { -- {"desc_cnt" , NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_edma_lite_rxfillring_strings_read() -- * Read EDMA rxfillring names. -- */ --static ssize_t nss_edma_lite_rxfillring_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_edma_lite_strings_stats_rxfill, NSS_EDMA_LITE_STATS_RXFILL_MAX); --} -- --/* -- * edma_rxfillring_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_lite_rxfillring); -- --/* -- * nss_edma_lite_strings_stats_err_map -- */ --struct nss_stats_info nss_edma_lite_strings_stats_err_map[NSS_EDMA_LITE_ERR_STATS_MAX] = { -- {"alloc_fail_cnt" , NSS_STATS_TYPE_ERROR}, -- {"unknown_pkt_cnt" , NSS_STATS_TYPE_ERROR}, --}; -- --/* -- * nss_edma_lite_err_strings_read() -- * Read EDMA error names. -- */ --static ssize_t nss_edma_lite_err_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_edma_lite_strings_stats_err_map, NSS_EDMA_LITE_ERR_STATS_MAX); --} -- --/* -- * edma_err_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(edma_lite_err); -- --/* -- * nss_edma_lite_strings_dentry_create() -- * Create EDMA statistics strings debug entry. -- */ --void nss_edma_lite_strings_dentry_create(void) --{ -- struct dentry *edma_d; -- struct dentry *edma_rings_dir_d; -- struct dentry *file_d; -- -- if (!nss_top_main.strings_dentry) { -- nss_warning("qca-nss-drv/strings is not present"); -- return; -- } -- -- edma_d = debugfs_create_dir("edma", nss_top_main.strings_dentry); -- if (!edma_d) { -- nss_warning("Failed to create qca-nss-drv/strings/edma directory"); -- return; -- } -- -- /* -- * edma node stats -- */ -- file_d = debugfs_create_file("node_stats", 0400, edma_d, &nss_top_main, &nss_edma_lite_node_stats_strings_ops); -- if (!file_d) { -- nss_warning("Failed to create qca-nss-drv/strings/edma/node_stats file"); -- goto fail; -- } -- -- /* -- * edma error stats -- */ -- file_d = debugfs_create_file("err_stats", 0400, edma_d, &nss_top_main, &nss_edma_lite_err_strings_ops); -- if (!file_d) { -- nss_warning("Failed to create qca-nss-drv/strings/edma/err_stats file"); -- goto fail; -- } -- -- /* -- * edma ring stats -- */ -- edma_rings_dir_d = debugfs_create_dir("rings", edma_d); -- if (!edma_rings_dir_d) { -- nss_warning("Failed to create qca-nss-drv/strings/edma/rings directory"); -- goto fail; -- } -- -- /* -- * edma tx ring stats -- */ -- file_d = debugfs_create_file("tx", 0400, edma_rings_dir_d, &nss_top_main, &nss_edma_lite_txring_strings_ops); -- if (!file_d) { -- nss_warning("Failed to create qca-nss-drv/strings/edma/rings/tx file"); -- goto fail; -- } -- -- /* -- * edma rx ring stats -- */ -- file_d = debugfs_create_file("rx", 0400, edma_rings_dir_d, &nss_top_main, &nss_edma_lite_rxring_strings_ops); -- if (!file_d) { -- nss_warning("Failed to create qca-nss-drv/strings/edma/rings/rx file"); -- goto fail; -- } -- -- /* -- * edma tx cmpl ring stats -- */ -- file_d = debugfs_create_file("txcmpl", 0400, edma_rings_dir_d, &nss_top_main, &nss_edma_lite_txcmplring_strings_ops); -- if (!file_d) { -- nss_warning("Failed to create qca-nss-drv/strings/edma/rings/txcmpl file"); -- goto fail; -- } -- -- /* -- * edma rx fill ring stats -- */ -- file_d = debugfs_create_file("rxfill", 0400, edma_rings_dir_d, &nss_top_main, &nss_edma_lite_rxfillring_strings_ops); -- if (!file_d) { -- nss_warning("Failed to create qca-nss-drv/strings/edma/rings/rxfill file"); -- goto fail; -- } -- -- return; --fail: -- debugfs_remove_recursive(edma_d); --} ---- a/nss_edma_lite_strings.h -+++ /dev/null -@@ -1,28 +0,0 @@ --/* -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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. -- */ -- --#ifndef __NSS_EDMA_LITE_LITE_STRINGS_H --#define __NSS_EDMA_LITE_LITE_STRINGS_H -- --extern struct nss_stats_info nss_edma_lite_strings_stats_node[NSS_STATS_NODE_MAX]; --extern struct nss_stats_info nss_edma_lite_strings_stats_tx[NSS_EDMA_LITE_STATS_TX_MAX]; --extern struct nss_stats_info nss_edma_lite_strings_stats_rx[NSS_EDMA_LITE_STATS_RX_MAX]; --extern struct nss_stats_info nss_edma_lite_strings_stats_txcmpl[NSS_EDMA_LITE_STATS_TXCMPL_MAX]; --extern struct nss_stats_info nss_edma_lite_strings_stats_rxfill[NSS_EDMA_LITE_STATS_RXFILL_MAX]; --extern struct nss_stats_info nss_edma_lite_strings_stats_err_map[NSS_EDMA_LITE_ERR_STATS_MAX]; --extern void nss_edma_lite_strings_dentry_create(void); -- --#endif /* __NSS_EDMA_LITE_STRINGS_H */ ---- a/nss_edma_stats.c -+++ b/nss_edma_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2020, 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. -@@ -732,7 +732,6 @@ void nss_edma_metadata_ring_stats_sync(s - edma_stats.rx_stats[i][NSS_EDMA_STATS_RX_DESC] += nerss->rx_ring[i].desc_cnt; - edma_stats.rx_stats[i][NSS_EDMA_STATS_RX_QOS_ERR] += nerss->rx_ring[i].qos_err; - edma_stats.rx_stats[i][NSS_EDMA_STATS_RX_SRC_PORT_INVALID] += nerss->rx_ring[i].rx_src_port_invalid; -- edma_stats.rx_stats[i][NSS_EDMA_STATS_RX_SRC_IF_INVALID] += nerss->rx_ring[i].rx_src_if_invalid; - } - - /* ---- a/nss_edma_strings.c -+++ b/nss_edma_strings.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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. -@@ -78,8 +78,7 @@ struct nss_stats_info nss_edma_strings_s - {"rx_csum_err" , NSS_STATS_TYPE_ERROR}, - {"desc_cnt" , NSS_STATS_TYPE_SPECIAL}, - {"qos_err" , NSS_STATS_TYPE_DROP}, -- {"rx_src_port_invalid" , NSS_STATS_TYPE_DROP}, -- {"rx_src_interface_invalid" , NSS_STATS_TYPE_DROP} -+ {"rx_src_port_invalid" , NSS_STATS_TYPE_DROP} - }; - - /* ---- a/nss_freq.c -+++ b/nss_freq.c -@@ -299,12 +299,7 @@ void nss_freq_scale_frequency(struct nss - - if (nss_runtime_samples.freq_scale_rate_limit_down++ >= NSS_FREQUENCY_SCALE_RATE_LIMIT_DOWN) { - minimum = nss_runtime_samples.freq_scale[index].minimum; -- -- /* -- * Check if we need to lower the frequency. For some SoC like IPQ50xx, low frequency -- * is not supported. So check if the next lower frequency is configured before shifting down -- */ -- if ((nss_runtime_samples.average < minimum) && (index > 0) && nss_runtime_samples.freq_scale[index - 1].maximum) { -+ if ((nss_runtime_samples.average < minimum) && (index > 0)) { - nss_runtime_samples.freq_scale_index--; - nss_runtime_samples.freq_scale_ready = 0; - ---- a/nss_gre.c -+++ b/nss_gre.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2020, 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. -@@ -17,7 +17,6 @@ - #include "nss_tx_rx_common.h" - #include "nss_gre_stats.h" - #include "nss_gre_log.h" --#include "nss_gre_strings.h" - - #define NSS_GRE_TX_TIMEOUT 3000 /* 3 Seconds */ - -@@ -116,13 +115,11 @@ static void nss_gre_msg_handler(struct n - /* - * debug stats embedded in stats msg - */ -- nss_gre_stats_session_sync(nss_ctx, &ntm->msg.sstats, ncm->interface); -- nss_gre_stats_session_notify(nss_ctx, ncm->interface); -+ nss_gre_stats_session_debug_sync(nss_ctx, &ntm->msg.sstats, ncm->interface); - break; - - case NSS_GRE_MSG_BASE_STATS: -- nss_gre_stats_base_sync(nss_ctx, &ntm->msg.bstats); -- nss_gre_stats_base_notify(nss_ctx); -+ nss_gre_stats_base_debug_sync(nss_ctx, &ntm->msg.bstats); - break; - - default: -@@ -407,5 +404,4 @@ void nss_gre_register_handler(void) - init_completion(&nss_gre_pvt.complete); - nss_core_register_handler(nss_ctx, NSS_GRE_INTERFACE, nss_gre_msg_handler, NULL); - nss_gre_stats_dentry_create(); -- nss_gre_strings_dentry_create(); - } ---- a/nss_gre_redir.c -+++ b/nss_gre_redir.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2020, 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. -@@ -16,7 +16,6 @@ - - #include "nss_tx_rx_common.h" - #include "nss_gre_redir_stats.h" --#include "nss_gre_redir_strings.h" - #include "nss_gre_redir_log.h" - #define NSS_GRE_REDIR_TX_TIMEOUT 3000 /* 3 Seconds */ - -@@ -32,9 +31,14 @@ static struct { - } nss_gre_redir_pvt; - - /* -+ * Spinlock to update tunnel stats. -+ */ -+static DEFINE_SPINLOCK(nss_gre_redir_stats_lock); -+ -+/* - * Array to hold tunnel stats along with if_num - */ --struct nss_gre_redir_tunnel_stats tun_stats[NSS_GRE_REDIR_MAX_INTERFACES]; -+static struct nss_gre_redir_tunnel_stats tun_stats[NSS_GRE_REDIR_MAX_INTERFACES]; - - /* - * nss_gre_callback() -@@ -55,7 +59,7 @@ static void nss_gre_redir_msg_sync_callb - * nss_gre_redir_verify_ifnum() - * Verify interface type. - */ --bool nss_gre_redir_verify_ifnum(uint32_t if_num) -+static bool nss_gre_redir_verify_ifnum(uint32_t if_num) - { - uint32_t type; - -@@ -69,6 +73,92 @@ bool nss_gre_redir_verify_ifnum(uint32_t - } - - /* -+ * nss_gre_redir_tunnel_update_stats() -+ * Update gre_redir tunnel stats. -+ */ -+static void nss_gre_redir_tunnel_update_stats(struct nss_ctx_instance *nss_ctx, int if_num, struct nss_gre_redir_stats_sync_msg *ngss) -+{ -+ int i, j; -+ uint32_t type; -+ struct net_device *dev; -+ -+ type = nss_dynamic_interface_get_type(nss_ctx, if_num); -+ dev = nss_cmn_get_interface_dev(nss_ctx, if_num); -+ if (!dev) { -+ nss_warning("%px: Unable to find net device for the interface %d\n", nss_ctx, if_num); -+ return; -+ } -+ -+ if (!nss_gre_redir_verify_ifnum(if_num)) { -+ nss_warning("%px: Unknown type for interface %d\n", nss_ctx, if_num); -+ return; -+ } -+ -+ spin_lock_bh(&nss_gre_redir_stats_lock); -+ for (i = 0; i < NSS_GRE_REDIR_MAX_INTERFACES; i++) { -+ if (tun_stats[i].dev == dev) { -+ break; -+ } -+ } -+ -+ if (i == NSS_GRE_REDIR_MAX_INTERFACES) { -+ nss_warning("%px: Unable to find tunnel stats instance for interface %d\n", nss_ctx, if_num); -+ return; -+ } -+ -+ nss_assert(tun_stats[i].ref_count); -+ switch (type) { -+ case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_HOST_INNER: -+ case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_OFFL_INNER: -+ case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_SJACK_INNER: -+ tun_stats[i].node_stats.tx_packets += ngss->node_stats.tx_packets; -+ tun_stats[i].node_stats.tx_bytes += ngss->node_stats.tx_bytes; -+ tun_stats[i].sjack_tx_packets += ngss->sjack_rx_packets; -+ tun_stats[i].encap_sg_alloc_drop += ngss->encap_sg_alloc_drop; -+ tun_stats[i].tx_dropped += nss_cmn_rx_dropped_sum(&(ngss->node_stats)); -+ for (j = 0; j < NSS_GRE_REDIR_MAX_RADIO; j++) { -+ tun_stats[i].offl_tx_pkts[j] += ngss->offl_rx_pkts[j]; -+ } -+ -+ break; -+ -+ case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_OUTER: -+ tun_stats[i].node_stats.rx_packets += ngss->node_stats.rx_packets; -+ tun_stats[i].node_stats.rx_bytes += ngss->node_stats.rx_bytes; -+ tun_stats[i].sjack_rx_packets += ngss->sjack_rx_packets; -+ tun_stats[i].decap_fail_drop += ngss->decap_fail_drop; -+ tun_stats[i].decap_split_drop += ngss->decap_split_drop; -+ tun_stats[i].split_sg_alloc_fail += ngss->split_sg_alloc_fail; -+ tun_stats[i].split_linear_copy_fail += ngss->split_linear_copy_fail; -+ tun_stats[i].split_not_enough_tailroom += ngss->split_not_enough_tailroom; -+ tun_stats[i].decap_eapol_frames += ngss->decap_eapol_frames; -+ tun_stats[i].node_stats.rx_dropped[0] += nss_cmn_rx_dropped_sum(&(ngss->node_stats)); -+ for (j = 0; j < NSS_GRE_REDIR_MAX_RADIO; j++) { -+ tun_stats[i].offl_rx_pkts[j] += ngss->offl_rx_pkts[j]; -+ } -+ -+ break; -+ -+ case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_US: -+ tun_stats[i].exception_us_rx += ngss->node_stats.rx_packets; -+ tun_stats[i].exception_us_tx += ngss->node_stats.tx_packets; -+ break; -+ -+ case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_DS: -+ tun_stats[i].exception_ds_rx += ngss->node_stats.rx_packets; -+ tun_stats[i].exception_ds_tx += ngss->node_stats.tx_packets; -+ tun_stats[i].exception_ds_invalid_dst_drop += ngss->exception_ds_invalid_dst_drop; -+ tun_stats[i].exception_ds_inv_appid += ngss->exception_ds_inv_appid; -+ tun_stats[i].headroom_unavail += ngss->headroom_unavail; -+ tun_stats[i].tx_completion_success += ngss->tx_completion_success; -+ tun_stats[i].tx_completion_drop += ngss->tx_completion_drop; -+ break; -+ } -+ -+ spin_unlock_bh(&nss_gre_redir_stats_lock); -+} -+ -+/* - * nss_gre_redir_handler() - * Handle NSS -> HLOS messages for GRE tunnel. - */ -@@ -109,7 +199,7 @@ static void nss_gre_redir_msg_handler(st - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data; -+ ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; - } - - /* -@@ -119,8 +209,7 @@ static void nss_gre_redir_msg_handler(st - - switch (ncm->type) { - case NSS_GRE_REDIR_RX_STATS_SYNC_MSG: -- nss_gre_redir_stats_sync(nss_ctx, ncm->interface, &ngrm->msg.stats_sync); -- nss_gre_redir_stats_notify(nss_ctx, ncm->interface); -+ nss_gre_redir_tunnel_update_stats(nss_ctx, ncm->interface, &ngrm->msg.stats_sync); - break; - } - -@@ -452,6 +541,24 @@ nss_tx_status_t nss_gre_redir_configure_ - EXPORT_SYMBOL(nss_gre_redir_configure_outer_node); - - /* -+ * nss_gre_redir_get_stats() -+ * Get gre_redir tunnel stats. -+ */ -+bool nss_gre_redir_get_stats(int index, struct nss_gre_redir_tunnel_stats *stats) -+{ -+ spin_lock_bh(&nss_gre_redir_stats_lock); -+ if (tun_stats[index].ref_count == 0) { -+ spin_unlock_bh(&nss_gre_redir_stats_lock); -+ return false; -+ } -+ -+ memcpy(stats, &tun_stats[index], sizeof(struct nss_gre_redir_tunnel_stats)); -+ spin_unlock_bh(&nss_gre_redir_stats_lock); -+ return true; -+} -+EXPORT_SYMBOL(nss_gre_redir_get_stats); -+ -+/* - * nss_gre_redir_tx_msg() - * Transmit a GRE message to NSS FW. - */ -@@ -668,6 +775,4 @@ void nss_gre_redir_register_handler(void - nss_warning("%px: Not able to register handler for gre_redir base interface with NSS core\n", nss_ctx); - return; - } -- -- nss_gre_redir_strings_dentry_create(); - } ---- a/nss_gre_redir_lag_ds.c -+++ b/nss_gre_redir_lag_ds.c -@@ -1,6 +1,6 @@ - /* -- **************************************************************************** -- * Copyright (c) 2018, 2020-2021, The Linux Foundation. All rights reserved. -+ ************************************************************************** -+ * Copyright (c) 2018, 2020, 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. -@@ -11,18 +11,17 @@ - * 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_tx_rx_common.h" --#include "nss_gre_redir_lag.h" - #include "nss_gre_redir_lag_ds_stats.h" - #include "nss_gre_redir_lag_ds_log.h" --#include "nss_gre_redir_lag_ds_strings.h" - - #define NSS_GRE_REDIR_LAG_DS_TX_TIMEOUT 3000 /* 3 Seconds */ - --struct nss_gre_redir_lag_ds_tun_stats tun_ds_stats[NSS_GRE_REDIR_LAG_MAX_NODE]; -+static struct nss_gre_redir_lag_ds_tun_stats tun_stats[NSS_GRE_REDIR_LAG_MAX_NODE]; -+static DEFINE_SPINLOCK(nss_gre_redir_lag_ds_stats_lock); - - /* - * Private data structure -@@ -65,11 +64,11 @@ static void nss_gre_redir_lag_ds_callbac - * nss_gre_redir_lag_ds_get_node_idx() - * Returns index of statistics context. - */ --bool nss_gre_redir_lag_ds_get_node_idx(uint32_t ifnum, uint32_t *idx) -+static inline bool nss_gre_redir_lag_ds_get_node_idx(uint32_t ifnum, uint32_t *idx) - { - uint32_t node_idx; - for (node_idx = 0; node_idx < NSS_GRE_REDIR_LAG_MAX_NODE; node_idx++) { -- if ((tun_ds_stats[node_idx].valid) && (tun_ds_stats[node_idx].ifnum == ifnum)) { -+ if ((tun_stats[node_idx].valid) && (tun_stats[node_idx].ifnum == ifnum)) { - *idx = node_idx; - return true; - } -@@ -79,10 +78,37 @@ bool nss_gre_redir_lag_ds_get_node_idx(u - } - - /* -+ * nss_gre_redir_lag_ds_update_sync_stats() -+ * Update synchonized statistics. -+ */ -+static void nss_gre_redir_lag_ds_update_sync_stats(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_ds_sync_stats_msg *ngss, uint32_t ifnum) -+{ -+ int idx, j; -+ -+ spin_lock_bh(&nss_gre_redir_lag_ds_stats_lock); -+ if (!nss_gre_redir_lag_ds_get_node_idx(ifnum, &idx)) { -+ spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); -+ nss_warning("%px: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); -+ return; -+ } -+ -+ tun_stats[idx].tx_packets += ngss->node_stats.tx_packets; -+ tun_stats[idx].tx_bytes += ngss->node_stats.tx_bytes; -+ tun_stats[idx].rx_packets += ngss->node_stats.rx_packets; -+ tun_stats[idx].rx_bytes += ngss->node_stats.rx_bytes; -+ for (j = 0; j < NSS_MAX_NUM_PRI; j++) { -+ tun_stats[idx].rx_dropped[j] += ngss->node_stats.rx_dropped[j]; -+ } -+ tun_stats[idx].dst_invalid += ngss->ds_stats.dst_invalid; -+ tun_stats[idx].exception_cnt += ngss->ds_stats.exception_cnt; -+ spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); -+} -+ -+/* - * nss_gre_redir_lag_ds_verify_ifnum() - * Verify interface type. - */ --bool nss_gre_redir_lag_ds_verify_ifnum(uint32_t if_num) -+static bool nss_gre_redir_lag_ds_verify_ifnum(uint32_t if_num) - { - return nss_dynamic_interface_get_type(nss_gre_redir_lag_ds_get_context(), if_num) == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_DS; - } -@@ -121,7 +147,7 @@ static void nss_gre_redir_lag_ds_msg_han - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data; -+ ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; - } - - /* -@@ -136,8 +162,7 @@ static void nss_gre_redir_lag_ds_msg_han - - switch (ncm->type) { - case NSS_GRE_REDIR_LAG_DS_STATS_SYNC_MSG: -- nss_gre_redir_lag_ds_stats_sync(nss_ctx, &ngrm->msg.ds_sync_stats, ncm->interface); -- nss_gre_redir_lag_ds_stats_notify(nss_ctx, ncm->interface); -+ nss_gre_redir_lag_ds_update_sync_stats(nss_ctx, &ngrm->msg.ds_sync_stats, ncm->interface); - break; - } - -@@ -192,7 +217,7 @@ static enum nss_gre_redir_lag_err_types - return NSS_GRE_REDIR_LAG_ERR_STATS_INDEX_NOT_FOUND; - } - -- tun_ds_stats[idx].valid = false; -+ tun_stats[idx].valid = false; - spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); - return NSS_GRE_REDIR_LAG_SUCCESS; - } -@@ -233,9 +258,9 @@ static struct nss_ctx_instance *nss_gre_ - nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, type); - spin_lock_bh(&nss_gre_redir_lag_ds_stats_lock); - for (i = 0; i < NSS_GRE_REDIR_LAG_MAX_NODE; i++) { -- if (!tun_ds_stats[i].valid) { -- tun_ds_stats[i].ifnum = if_num; -- tun_ds_stats[i].valid = true; -+ if (!tun_stats[i].valid) { -+ tun_stats[i].ifnum = if_num; -+ tun_stats[i].valid = true; - break; - } - } -@@ -256,6 +281,26 @@ struct nss_ctx_instance *nss_gre_redir_l - EXPORT_SYMBOL(nss_gre_redir_lag_ds_get_context); - - /* -+ * nss_gre_redir_lag_ds_get_cmn_stats() -+ * Get statistics for downstream LAG node. -+ */ -+bool nss_gre_redir_lag_ds_get_cmn_stats(struct nss_gre_redir_lag_ds_tun_stats *cmn_stats, uint32_t index) -+{ -+ if (index >= NSS_GRE_REDIR_LAG_MAX_NODE) { -+ return false; -+ } -+ -+ spin_lock_bh(&nss_gre_redir_lag_ds_stats_lock); -+ if (!tun_stats[index].valid) { -+ spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); -+ return false; -+ } -+ memcpy((void *)cmn_stats, (void *)&tun_stats[index], sizeof(*cmn_stats)); -+ spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); -+ return true; -+} -+ -+/* - * nss_gre_redir_lag_ds_tx_msg() - * Transmit a gre message to NSS. - */ -@@ -396,7 +441,6 @@ void nss_gre_redir_lag_ds_register_handl - return; - } - -- nss_gre_redir_lag_ds_strings_dentry_create(); - nss_gre_redir_lag_ds_pvt.cb = NULL; - nss_gre_redir_lag_ds_pvt.app_data = NULL; - sema_init(&nss_gre_redir_lag_ds_pvt.sem, 1); ---- a/nss_gre_redir_lag_ds_stats.c -+++ b/nss_gre_redir_lag_ds_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019, 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. -@@ -17,38 +17,69 @@ - #include "nss_core.h" - #include "nss_gre_redir_lag.h" - #include "nss_gre_redir_lag_ds_stats.h" --#include "nss_gre_redir_lag_ds_strings.h" - - /* -- * Declare atomic notifier data structure for statistics. -+ * nss_gre_redir_lag_ds_stats_str -+ * GRE REDIR LAG DS common statistics strings. - */ --ATOMIC_NOTIFIER_HEAD(nss_gre_redir_lag_ds_stats_notifier); -+static uint8_t *nss_gre_redir_lag_ds_stats_str[NSS_GRE_REDIR_LAG_DS_STATS_MAX] = { -+ "rx_packets", -+ "rx_bytes", -+ "tx_packets", -+ "tx_bytes", -+ "rx_queue_0_dropped", -+ "rx_queue_1_dropped", -+ "rx_queue_2_dropped", -+ "rx_queue_3_dropped", -+ "dst_invalid", -+ "exception_packets" -+}; -+ -+/* -+ * nss_gre_redir_lag_ds_tunnel_stats() -+ * Make a row for GRE_REDIR LAG DS stats. -+ */ -+static ssize_t nss_gre_redir_lag_ds_cmn_stats_read_entry(char *line, int len, int type, struct nss_gre_redir_lag_ds_tun_stats *s) -+{ -+ uint64_t tcnt = 0; -+ -+ switch (type) { -+ case NSS_STATS_NODE_RX_PKTS: -+ tcnt = s->rx_packets; -+ return snprintf(line, len, "Common node stats start:\n\n%s = %llu\n", nss_gre_redir_lag_ds_stats_str[type], tcnt); -+ case NSS_STATS_NODE_RX_BYTES: -+ tcnt = s->rx_bytes; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_ds_stats_str[type], tcnt); -+ case NSS_STATS_NODE_TX_PKTS: -+ tcnt = s->tx_packets; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_ds_stats_str[type], tcnt); -+ case NSS_STATS_NODE_TX_BYTES: -+ tcnt = s->tx_bytes; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_ds_stats_str[type], tcnt); -+ case NSS_STATS_NODE_RX_QUEUE_0_DROPPED: -+ tcnt = s->rx_dropped[0]; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_ds_stats_str[type], tcnt); -+#if (NSS_MAX_NUM_PRI > 1) -+ case NSS_STATS_NODE_RX_QUEUE_1_DROPPED: -+ tcnt = s->rx_dropped[1]; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_ds_stats_str[type], tcnt); -+ case NSS_STATS_NODE_RX_QUEUE_2_DROPPED: -+ tcnt = s->rx_dropped[2]; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_ds_stats_str[type], tcnt); -+ case NSS_STATS_NODE_RX_QUEUE_3_DROPPED: -+ tcnt = s->rx_dropped[3]; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_ds_stats_str[type], tcnt); -+#endif -+ case NSS_GRE_REDIR_LAG_DS_STATS_DST_INVALID: -+ tcnt = s->dst_invalid; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_ds_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_DS_STATS_EXCEPTION_PKT: -+ tcnt = s->exception_cnt; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_ds_stats_str[type], tcnt); - --/* -- * Spinlock to protect GRE redirect lag ds statistics update/read -- */ --DEFINE_SPINLOCK(nss_gre_redir_lag_ds_stats_lock); -- --extern struct nss_gre_redir_lag_ds_tun_stats tun_ds_stats[NSS_GRE_REDIR_LAG_MAX_NODE]; -- --/* -- * nss_gre_redir_lag_ds_stats_get() -- * Get statistics for downstream LAG node. -- */ --bool nss_gre_redir_lag_ds_stats_get(struct nss_gre_redir_lag_ds_tun_stats *cmn_stats, uint32_t index) --{ -- if (index >= NSS_GRE_REDIR_LAG_MAX_NODE) -- return false; -- -- spin_lock_bh(&nss_gre_redir_lag_ds_stats_lock); -- if (!tun_ds_stats[index].valid) { -- spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); -- return false; -+ default: -+ return 0; - } -- -- memcpy((void *)cmn_stats, (void *)&tun_ds_stats[index], sizeof(*cmn_stats)); -- spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); -- return true; - } - - /* -@@ -57,45 +88,47 @@ bool nss_gre_redir_lag_ds_stats_get(stru - */ - static ssize_t nss_gre_redir_lag_ds_cmn_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) - { -- /* -- * Max output lines = #stats + -- * few blank lines for banner printing + Number of Extra outputlines -- * for future reference to add new stats -- */ -- uint32_t max_output_lines = NSS_GRE_REDIR_LAG_DS_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -+ ssize_t bytes_read = 0; - struct nss_stats_data *data = fp->private_data; - struct nss_gre_redir_lag_ds_tun_stats stats; -- ssize_t bytes_read = 0; -- size_t size_wr = 0; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(!lbuf)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -+ size_t bytes; -+ char line[80]; -+ int start; - - while (data->index < NSS_GRE_REDIR_LAG_MAX_NODE) { -- if (nss_gre_redir_lag_ds_stats_get(&stats, data->index)) { -+ if (nss_gre_redir_lag_ds_get_cmn_stats(&stats, data->index)) { - break; - } - - data->index++; - } - -- if (data->index >= NSS_GRE_REDIR_LAG_MAX_NODE) { -- kfree(lbuf); -+ if (data->index == NSS_GRE_REDIR_LAG_MAX_NODE) { - return 0; - } - -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "gre_redir_lag_ds stats", NSS_STATS_SINGLE_CORE); -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nTunnel stats for %03u\n", stats.ifnum); -- size_wr += nss_stats_print("gre_redir_lag_ds", NULL, NSS_STATS_SINGLE_INSTANCE, nss_gre_redir_lag_ds_strings_stats, -- &stats.rx_packets, NSS_GRE_REDIR_LAG_DS_STATS_MAX, lbuf, size_wr, size_al); -+ bytes = snprintf(line, sizeof(line), "\nTunnel stats for \n"); -+ if (copy_to_user(ubuf, line, bytes) != 0) { -+ return -EFAULT; -+ } -+ -+ bytes_read += bytes; -+ start = NSS_STATS_NODE_RX_PKTS; -+ while (bytes_read < sz && start < NSS_GRE_REDIR_LAG_DS_STATS_MAX) { -+ bytes = nss_gre_redir_lag_ds_cmn_stats_read_entry(line, sizeof(line), start, &stats); -+ -+ if ((bytes_read + bytes) > sz) -+ break; -+ -+ if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { -+ return -EFAULT; -+ } -+ -+ bytes_read += bytes; -+ start++; -+ } - -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - data->index++; -- kfree(lbuf); - return bytes_read; - } - -@@ -128,84 +161,3 @@ struct dentry *nss_gre_redir_lag_ds_stat - - return cmn_stats; - } -- --/* -- * nss_gre_redir_lag_ds_stats_sync() -- * Update synchonized statistics. -- */ --void nss_gre_redir_lag_ds_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_ds_sync_stats_msg *ngss, uint32_t ifnum) --{ -- int idx, j; -- -- spin_lock_bh(&nss_gre_redir_lag_ds_stats_lock); -- if (!nss_gre_redir_lag_ds_get_node_idx(ifnum, &idx)) { -- spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); -- nss_warning("%px: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); -- return; -- } -- -- tun_ds_stats[idx].tx_packets += ngss->node_stats.tx_packets; -- tun_ds_stats[idx].tx_bytes += ngss->node_stats.tx_bytes; -- tun_ds_stats[idx].rx_packets += ngss->node_stats.rx_packets; -- tun_ds_stats[idx].rx_bytes += ngss->node_stats.rx_bytes; -- for (j = 0; j < NSS_MAX_NUM_PRI; j++) { -- tun_ds_stats[idx].rx_dropped[j] += ngss->node_stats.rx_dropped[j]; -- } -- -- tun_ds_stats[idx].dst_invalid += ngss->ds_stats.dst_invalid; -- tun_ds_stats[idx].exception_cnt += ngss->ds_stats.exception_cnt; -- spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); --} -- --/* -- * nss_gre_redir_lag_ds_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_gre_redir_lag_ds_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_gre_redir_lag_ds_stats_notification *stats_notify; -- int idx; -- -- stats_notify = kzalloc(sizeof(struct nss_gre_redir_lag_ds_stats_notification), GFP_ATOMIC); -- if (!stats_notify) { -- nss_warning("Unable to allocate memory for stats notification\n"); -- return; -- } -- -- spin_lock_bh(&nss_gre_redir_lag_ds_stats_lock); -- if (!nss_gre_redir_lag_ds_get_node_idx(if_num, &idx)) { -- spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); -- nss_warning("%px: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); -- kfree(stats_notify); -- return; -- } -- -- stats_notify->core_id = nss_ctx->id; -- stats_notify->if_num = if_num; -- memcpy(&(stats_notify->stats_ctx), &(tun_ds_stats[idx]), sizeof(stats_notify->stats_ctx)); -- spin_unlock_bh(&nss_gre_redir_lag_ds_stats_lock); -- atomic_notifier_call_chain(&nss_gre_redir_lag_ds_stats_notifier, NSS_STATS_EVENT_NOTIFY, stats_notify); -- kfree(stats_notify); --} -- --/* -- * nss_gre_redir_lag_ds_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_gre_redir_lag_ds_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_gre_redir_lag_ds_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_redir_lag_ds_stats_unregister_notifier); -- --/* -- * nss_gre_redir_lag_ds_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_gre_redir_lag_ds_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_gre_redir_lag_ds_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_redir_lag_ds_stats_register_notifier); ---- a/nss_gre_redir_lag_ds_stats.h -+++ b/nss_gre_redir_lag_ds_stats.h -@@ -1,6 +1,6 @@ - /* -- ************************************************************************** -- * Copyright (c) 2018, 2021, The Linux Foundation. All rights reserved. -+ ****************************************************************************** -+ * Copyright (c) 2018, 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. -@@ -11,18 +11,20 @@ - * 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. -- * ************************************************************************ -+ * **************************************************************************** - */ - - #ifndef __NSS_GRE_REDIR_LAG_DS_STATS_H__ - #define __NSS_GRE_REDIR_LAG_DS_STATS_H__ - --extern spinlock_t nss_gre_redir_lag_ds_stats_lock; --extern void nss_gre_redir_lag_ds_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); --extern bool nss_gre_redir_lag_ds_verify_ifnum(uint32_t if_num); --extern bool nss_gre_redir_lag_ds_get_node_idx(uint32_t ifnum, uint32_t *idx); --extern void nss_gre_redir_lag_ds_stats_sync(struct nss_ctx_instance *nss_ctx, -- struct nss_gre_redir_lag_ds_sync_stats_msg *ngss, uint32_t ifnum); --extern struct dentry *nss_gre_redir_lag_ds_stats_dentry_create(void); -+/* -+ * GRE redirect LAG downstream statistics -+ */ -+enum nss_gre_redir_lag_ds_stats_types { -+ NSS_GRE_REDIR_LAG_DS_STATS_DST_INVALID = NSS_STATS_NODE_MAX, -+ NSS_GRE_REDIR_LAG_DS_STATS_EXCEPTION_PKT, -+ NSS_GRE_REDIR_LAG_DS_STATS_MAX, -+}; - -+extern struct dentry *nss_gre_redir_lag_ds_stats_dentry_create(void); - #endif ---- a/nss_gre_redir_lag_ds_strings.c -+++ /dev/null -@@ -1,60 +0,0 @@ --/* -- *************************************************************************** -- * Copyright (c) 2020-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_strings.h" --#include "nss_gre_redir_lag_ds_strings.h" -- --/* -- * nss_gre_redir_lag_ds_strings_stats -- * GRE REDIR LAG DS common statistics strings. -- */ --struct nss_stats_info nss_gre_redir_lag_ds_strings_stats[NSS_GRE_REDIR_LAG_DS_STATS_MAX] = { -- {"rx_packets", NSS_STATS_TYPE_COMMON}, -- {"rx_bytes", NSS_STATS_TYPE_COMMON}, -- {"tx_packets", NSS_STATS_TYPE_COMMON}, -- {"tx_bytes", NSS_STATS_TYPE_COMMON}, -- {"rx_dropped_0", NSS_STATS_TYPE_DROP}, -- {"rx_dropped_1", NSS_STATS_TYPE_DROP}, -- {"rx_dropped_2", NSS_STATS_TYPE_DROP}, -- {"rx_dropped_3", NSS_STATS_TYPE_DROP}, -- {"dst_invalid", NSS_STATS_TYPE_EXCEPTION}, -- {"exception_packets", NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_gre_redir_lag_ds_strings_read() -- * Read gre_redir_lag_ds statistics names -- */ --static ssize_t nss_gre_redir_lag_ds_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_gre_redir_lag_ds_strings_stats, NSS_GRE_REDIR_LAG_DS_STATS_MAX); --} -- --/* -- * nss_gre_redir_lag_ds_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(gre_redir_lag_ds); -- --/* -- * nss_gre_redir_lag_ds_strings_dentry_create() -- * Create gre_redir_lag_ds statistics strings debug entry. -- */ --void nss_gre_redir_lag_ds_strings_dentry_create(void) --{ -- nss_strings_create_dentry("gre_redir_lag_ds", &nss_gre_redir_lag_ds_strings_ops); --} ---- a/nss_gre_redir_lag_ds_strings.h -+++ /dev/null -@@ -1,25 +0,0 @@ --/* -- *************************************************************************** -- * Copyright (c) 2020-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. -- *************************************************************************** -- */ -- --#ifndef __NSS_GRE_REDIR_LAG_DS_STRINGS_H --#define __NSS_GRE_REDIR_LAG_DS_STRINGS_H -- --#include "nss_gre_redir_lag_ds_stats.h" -- --extern struct nss_stats_info nss_gre_redir_lag_ds_strings_stats[NSS_GRE_REDIR_LAG_DS_STATS_MAX]; --extern void nss_gre_redir_lag_ds_strings_dentry_create(void); -- --#endif /* __NSS_GRE_REDIR_LAG_DS_STRINGS_H */ ---- a/nss_gre_redir_lag_us.c -+++ b/nss_gre_redir_lag_us.c -@@ -1,6 +1,6 @@ - /* -- **************************************************************************** -- * Copyright (c) 2018, 2020-2021, The Linux Foundation. All rights reserved. -+ ************************************************************************** -+ * Copyright (c) 2018, 2020, 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. -@@ -11,19 +11,39 @@ - * 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_tx_rx_common.h" - #include "nss_gre_redir_lag_us_stats.h" - #include "nss_gre_redir_lag_us_log.h" --#include "nss_gre_redir_lag_us_strings.h" - - #define NSS_GRE_REDIR_LAG_US_TX_TIMEOUT 3000 /* 3 Seconds */ - #define NSS_GRE_REDIR_LAG_US_STATS_SYNC_PERIOD msecs_to_jiffies(4000) - #define NSS_GRE_REDIR_LAG_US_STATS_SYNC_UDELAY 4000 - --struct nss_gre_redir_lag_us_cmn_ctx cmn_ctx; -+/* -+ * nss_gre_redir_lag_us_pvt_sync_stats -+ * Hash statistics synchronization context. -+ */ -+struct nss_gre_redir_lag_us_pvt_sync_stats { -+ struct delayed_work nss_gre_redir_lag_us_work; /**< Delayed work per LAG US node. */ -+ struct nss_gre_redir_lag_us_msg db_sync_msg; /**< Hash statistics message. */ -+ struct nss_gre_redir_lag_us_tunnel_stats tun_stats; /**< GRE redirect LAG common statistics. */ -+ nss_gre_redir_lag_us_msg_callback_t cb; /**< Callback for hash query message. */ -+ void *app_data; /**< app_data for hash query message. */ -+ uint32_t ifnum; /**< NSS interface number. */ -+ bool valid; /**< Valid flag. */ -+}; -+ -+/* -+ * Common context for stats update. -+ */ -+static struct nss_gre_redir_lag_us_cmn_ctx { -+ spinlock_t nss_gre_redir_lag_us_stats_lock; /**< Spin lock. */ -+ struct workqueue_struct *nss_gre_redir_lag_us_wq; /**< Work queue. */ -+ struct nss_gre_redir_lag_us_pvt_sync_stats stats_ctx[NSS_GRE_REDIR_LAG_MAX_NODE]; -+} cmn_ctx; - - /* - * Sync response context. -@@ -63,6 +83,61 @@ static void nss_gre_redir_lag_us_callbac - } - - /* -+ * nss_gre_redir_lag_us_get_node_idx() -+ * Returns index of statistics context. -+ */ -+static bool nss_gre_redir_lag_us_get_node_idx(uint32_t ifnum, uint32_t *idx) -+{ -+ uint32_t node_idx; -+ for (node_idx = 0; node_idx < NSS_GRE_REDIR_LAG_MAX_NODE; node_idx++) { -+ if ((cmn_ctx.stats_ctx[node_idx].valid) && (cmn_ctx.stats_ctx[node_idx].ifnum == ifnum)) { -+ *idx = node_idx; -+ return true; -+ } -+ } -+ -+ return false; -+} -+ -+/* -+ * nss_gre_redir_lag_us_update_sync_stats() -+ * Update synchonized statistics. -+ */ -+static void nss_gre_redir_lag_us_update_sync_stats(struct nss_ctx_instance *nss_ctx, struct nss_gre_redir_lag_us_cmn_sync_stats_msg *ngss, -+ uint32_t ifnum) -+{ -+ int idx, j; -+ -+ spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -+ if (!nss_gre_redir_lag_us_get_node_idx(ifnum, &idx)) { -+ spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -+ nss_warning("%px: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); -+ return; -+ } -+ -+ cmn_ctx.stats_ctx[idx].tun_stats.tx_packets += ngss->node_stats.tx_packets; -+ cmn_ctx.stats_ctx[idx].tun_stats.tx_bytes += ngss->node_stats.tx_bytes; -+ cmn_ctx.stats_ctx[idx].tun_stats.rx_packets += ngss->node_stats.rx_packets; -+ cmn_ctx.stats_ctx[idx].tun_stats.rx_bytes += ngss->node_stats.rx_bytes; -+ for (j = 0; j < NSS_MAX_NUM_PRI; j++) { -+ cmn_ctx.stats_ctx[idx].tun_stats.rx_dropped[j] += ngss->node_stats.rx_dropped[j]; -+ } -+ cmn_ctx.stats_ctx[idx].tun_stats.us_stats.amsdu_pkts += ngss->us_stats.amsdu_pkts; -+ cmn_ctx.stats_ctx[idx].tun_stats.us_stats.amsdu_pkts_enqueued += ngss->us_stats.amsdu_pkts_enqueued; -+ cmn_ctx.stats_ctx[idx].tun_stats.us_stats.amsdu_pkts_exceptioned += ngss->us_stats.amsdu_pkts_exceptioned; -+ cmn_ctx.stats_ctx[idx].tun_stats.us_stats.exceptioned += ngss->us_stats.exceptioned; -+ cmn_ctx.stats_ctx[idx].tun_stats.us_stats.freed += ngss->us_stats.freed; -+ cmn_ctx.stats_ctx[idx].tun_stats.db_stats.add_attempt += ngss->db_stats.add_attempt; -+ cmn_ctx.stats_ctx[idx].tun_stats.db_stats.add_success += ngss->db_stats.add_success; -+ cmn_ctx.stats_ctx[idx].tun_stats.db_stats.add_fail_table_full += ngss->db_stats.add_fail_table_full; -+ cmn_ctx.stats_ctx[idx].tun_stats.db_stats.add_fail_exists += ngss->db_stats.add_fail_exists; -+ cmn_ctx.stats_ctx[idx].tun_stats.db_stats.del_attempt += ngss->db_stats.del_attempt; -+ cmn_ctx.stats_ctx[idx].tun_stats.db_stats.del_success += ngss->db_stats.del_success; -+ cmn_ctx.stats_ctx[idx].tun_stats.db_stats.del_fail_not_found += ngss->db_stats.del_fail_not_found; -+ spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -+} -+ -+/* - * nss_gre_redir_lag_us_hash_update_stats_req() - * Update query hash message's index for next request. - */ -@@ -92,14 +167,25 @@ static void nss_gre_redir_lag_us_hash_up - * If more hash entries are to be fetched from FW, queue work with delay of one eighth of - * the polling period. Else, schedule work with a delay of polling period. - */ -- if (cmn_ctx.stats_ctx[idx].db_sync_msg.msg.hash_stats.db_entry_idx) -+ if (cmn_ctx.stats_ctx[idx].db_sync_msg.msg.hash_stats.db_entry_idx) { - sync_delay = NSS_GRE_REDIR_LAG_US_STATS_SYNC_PERIOD / 8; -+ } - -- queue_delayed_work(cmn_ctx.nss_gre_redir_lag_us_wq, &(cmn_ctx.stats_ctx[idx].nss_gre_redir_lag_us_work), sync_delay); -+ queue_delayed_work(cmn_ctx.nss_gre_redir_lag_us_wq, &(cmn_ctx.stats_ctx[idx].nss_gre_redir_lag_us_work), -+ sync_delay); - spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); - } - - /* -+ * nss_gre_redir_lag_us_verify_ifnum() -+ * Verify interface type. -+ */ -+static bool nss_gre_redir_lag_us_verify_ifnum(uint32_t if_num) -+{ -+ return nss_dynamic_interface_get_type(nss_gre_redir_lag_us_get_context(), if_num) == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US; -+} -+ -+/* - * nss_gre_redir_lag_us_handler() - * Handle NSS -> HLOS messages for gre tunnel - */ -@@ -138,7 +224,7 @@ static void nss_gre_redir_lag_us_msg_han - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data; -+ ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; - } - - /* -@@ -148,8 +234,7 @@ static void nss_gre_redir_lag_us_msg_han - - switch (ncm->type) { - case NSS_GRE_REDIR_LAG_US_CMN_STATS_SYNC_MSG: -- nss_gre_redir_lag_us_stats_sync(nss_ctx, &ngrm->msg.us_sync_stats, ncm->interface); -- nss_gre_redir_lag_us_stats_notify(nss_ctx, ncm->interface); -+ nss_gre_redir_lag_us_update_sync_stats(nss_ctx, &ngrm->msg.us_sync_stats, ncm->interface); - break; - - case NSS_GRE_REDIR_LAG_US_DB_HASH_NODE_MSG: -@@ -429,32 +514,6 @@ static struct nss_ctx_instance *nss_gre_ - } - - /* -- * nss_gre_redir_lag_us_get_node_idx() -- * Returns index of statistics context. -- */ --bool nss_gre_redir_lag_us_get_node_idx(uint32_t ifnum, uint32_t *idx) --{ -- uint32_t node_idx; -- for (node_idx = 0; node_idx < NSS_GRE_REDIR_LAG_MAX_NODE; node_idx++) { -- if ((cmn_ctx.stats_ctx[node_idx].valid) && (cmn_ctx.stats_ctx[node_idx].ifnum == ifnum)) { -- *idx = node_idx; -- return true; -- } -- } -- -- return false; --} -- --/* -- * nss_gre_redir_lag_us_verify_ifnum() -- * Verify interface type. -- */ --bool nss_gre_redir_lag_us_verify_ifnum(uint32_t if_num) --{ -- return nss_dynamic_interface_get_type(nss_gre_redir_lag_us_get_context(), if_num) == NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_LAG_US; --} -- --/* - * nss_gre_redir_lag_us_get_context() - * Retrieve context for GRE redirect LAG upstream node. - */ -@@ -547,6 +606,29 @@ bool nss_gre_redir_lag_us_configure_node - EXPORT_SYMBOL(nss_gre_redir_lag_us_configure_node); - - /* -+ * nss_gre_redir_lag_us_get_cmn_stats() -+ * Common upstream statistics. -+ */ -+bool nss_gre_redir_lag_us_get_cmn_stats(struct nss_gre_redir_lag_us_tunnel_stats *cmn_stats, uint32_t index) -+{ -+ if (index >= NSS_GRE_REDIR_LAG_MAX_NODE) { -+ nss_warning("Index is out of valid range %u\n", index); -+ return false; -+ } -+ -+ spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -+ if (!cmn_ctx.stats_ctx[index].valid) { -+ spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -+ nss_warning("Common context not found for the index %u\n", index); -+ return false; -+ } -+ -+ memcpy((void *)cmn_stats, (void *)&(cmn_ctx.stats_ctx[index].tun_stats), sizeof(*cmn_stats)); -+ spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -+ return true; -+} -+ -+/* - * nss_gre_redir_lag_us_tx_msg() - * Transmit a GRE LAG message to NSS firmware asynchronously. - */ -@@ -656,7 +738,6 @@ void nss_gre_redir_lag_us_register_handl - return; - } - -- nss_gre_redir_lag_us_strings_dentry_create(); - nss_gre_redir_lag_us_sync_ctx.cb = NULL; - nss_gre_redir_lag_us_sync_ctx.app_data = NULL; - sema_init(&nss_gre_redir_lag_us_sync_ctx.sem, 1); ---- a/nss_gre_redir_lag_us_stats.c -+++ b/nss_gre_redir_lag_us_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019, 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. -@@ -17,39 +17,109 @@ - #include "nss_core.h" - #include "nss_gre_redir_lag.h" - #include "nss_gre_redir_lag_us_stats.h" --#include "nss_gre_redir_lag_us_strings.h" -- --#define NSS_GRE_REDIR_LAG_US_STATS_SYNC_PERIOD msecs_to_jiffies(4000) --#define NSS_GRE_REDIR_LAG_US_STATS_SYNC_UDELAY 4000 -- --/* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_gre_redir_lag_us_stats_notifier); -- --extern struct nss_gre_redir_lag_us_cmn_ctx cmn_ctx; - - /* -- * nss_gre_redir_lag_us_stats_get -- * Get the common upstream statistics. -+ * nss_gre_redir_lag_us_stats_str -+ * GRE REDIR LAG US common statistics strings. - */ --bool nss_gre_redir_lag_us_stats_get(struct nss_gre_redir_lag_us_tunnel_stats *cmn_stats, uint32_t index) --{ -- if (index >= NSS_GRE_REDIR_LAG_MAX_NODE) { -- nss_warning("Index is out of valid range %u\n", index); -- return false; -- } -- -- spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -- if (!cmn_ctx.stats_ctx[index].valid) { -- spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -- nss_warning("Common context not found for the index %u\n", index); -- return false; -+static uint8_t *nss_gre_redir_lag_us_stats_str[NSS_GRE_REDIR_LAG_US_STATS_MAX] = { -+ "rx_packets", -+ "rx_bytes", -+ "tx_packets", -+ "tx_bytes", -+ "rx_queue_0_dropped", -+ "rx_queue_1_dropped", -+ "rx_queue_2_dropped", -+ "rx_queue_3_dropped", -+ "Amsdu pkts", -+ "Amsdu pkts enqueued", -+ "Amsdu pkts exceptioned", -+ "Exceptioned", -+ "Freed", -+ "add attempt", -+ "add success", -+ "add fail table full", -+ "add fail exists", -+ "del attempt", -+ "del success", -+ "del fail not found", -+}; -+ -+/* -+ * nss_gre_redir_lag_us_tunnel_stats() -+ * Make a row for GRE_REDIR LAG US stats. -+ */ -+static ssize_t nss_gre_redir_lag_us_cmn_stats_read_entry(char *line, int len, int type, struct nss_gre_redir_lag_us_tunnel_stats *s) -+{ -+ uint64_t tcnt = 0; -+ -+ switch (type) { -+ case NSS_STATS_NODE_RX_PKTS: -+ tcnt = s->rx_packets; -+ return snprintf(line, len, "Common node stats start:\n\n%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_STATS_NODE_RX_BYTES: -+ tcnt = s->rx_bytes; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_STATS_NODE_TX_PKTS: -+ tcnt = s->tx_packets; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_STATS_NODE_TX_BYTES: -+ tcnt = s->tx_bytes; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_STATS_NODE_RX_QUEUE_0_DROPPED: -+ tcnt = s->rx_dropped[0]; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+#if (NSS_MAX_NUM_PRI > 1) -+ case NSS_STATS_NODE_RX_QUEUE_1_DROPPED: -+ tcnt = s->rx_dropped[1]; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_STATS_NODE_RX_QUEUE_2_DROPPED: -+ tcnt = s->rx_dropped[2]; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_STATS_NODE_RX_QUEUE_3_DROPPED: -+ tcnt = s->rx_dropped[3]; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+#endif -+ case NSS_GRE_REDIR_LAG_US_STATS_AMSDU_PKTS: -+ tcnt = s->us_stats.amsdu_pkts; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_US_STATS_AMSDU_PKTS_ENQUEUED: -+ tcnt = s->us_stats.amsdu_pkts_enqueued; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_US_STATS_AMSDU_PKTS_EXCEPTIONED: -+ tcnt = s->us_stats.amsdu_pkts_exceptioned; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_US_STATS_EXCEPTIONED: -+ tcnt = s->us_stats.exceptioned; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_US_STATS_FREED: -+ tcnt = s->us_stats.freed; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_US_STATS_ADD_ATTEMPT: -+ tcnt = s->db_stats.add_attempt; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_US_STATS_ADD_SUCCESS: -+ tcnt = s->db_stats.add_success; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_US_STATS_ADD_FAIL_TABLE_FULL: -+ tcnt = s->db_stats.add_fail_table_full; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_US_STATS_ADD_FAIL_EXISTS: -+ tcnt = s->db_stats.add_fail_exists; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_US_STATS_DEL_ATTEMPT: -+ tcnt = s->db_stats.del_attempt; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_US_STATS_DEL_SUCCESS: -+ tcnt = s->db_stats.del_success; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ case NSS_GRE_REDIR_LAG_US_STATS_DEL_FAIL_NOT_FOUND: -+ tcnt = s->db_stats.del_fail_not_found; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_lag_us_stats_str[type], tcnt); -+ default: -+ nss_warning("Unknown tunnel stats type.\n"); -+ return 0; - } -- -- memcpy((void *)cmn_stats, (void *)&(cmn_ctx.stats_ctx[index].tun_stats), sizeof(*cmn_stats)); -- spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -- return true; - } - - /* -@@ -58,26 +128,15 @@ bool nss_gre_redir_lag_us_stats_get(stru - */ - static ssize_t nss_gre_redir_lag_us_cmn_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) - { -- /* -- * Max output lines = #stats + -- * few blank lines for banner printing + Number of Extra outputlines -- * for future reference to add new stats -- */ -- uint32_t max_output_lines = NSS_GRE_REDIR_LAG_US_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -+ ssize_t bytes_read = 0; - struct nss_stats_data *data = fp->private_data; - struct nss_gre_redir_lag_us_tunnel_stats stats; -- ssize_t bytes_read = 0; -- size_t size_wr = 0; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(!lbuf)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -+ size_t bytes; -+ char line[80]; -+ int start; - - while (data->index < NSS_GRE_REDIR_LAG_MAX_NODE) { -- if (nss_gre_redir_lag_us_stats_get(&stats, data->index)) { -+ if (nss_gre_redir_lag_us_get_cmn_stats(&stats, data->index)) { - break; - } - -@@ -85,17 +144,31 @@ static ssize_t nss_gre_redir_lag_us_cmn_ - } - - if (data->index == NSS_GRE_REDIR_LAG_MAX_NODE) { -- kfree(lbuf); - return 0; - } - -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "gre_redir_lag_us stats", NSS_STATS_SINGLE_CORE); -- size_wr += nss_stats_print("gre_redir_lag_us", NULL, NSS_STATS_SINGLE_INSTANCE, nss_gre_redir_lag_us_strings_stats, -- &stats.rx_packets, NSS_GRE_REDIR_LAG_US_STATS_MAX, lbuf, size_wr, size_al); -+ bytes = snprintf(line, sizeof(line), "\nTunnel stats"); -+ if (copy_to_user(ubuf, line, bytes) != 0) { -+ return -EFAULT; -+ } -+ -+ bytes_read += bytes; -+ start = NSS_STATS_NODE_RX_PKTS; -+ while (bytes_read < sz && start <= NSS_GRE_REDIR_LAG_US_STATS_DEL_FAIL_NOT_FOUND) { -+ bytes = nss_gre_redir_lag_us_cmn_stats_read_entry(line, sizeof(line), start, &stats); -+ if ((bytes_read + bytes) > sz) { -+ break; -+ } -+ -+ if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { -+ return -EFAULT; -+ } -+ -+ bytes_read += bytes; -+ start++; -+ } - -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - data->index++; -- kfree(lbuf); - return bytes_read; - } - -@@ -128,99 +201,3 @@ struct dentry *nss_gre_redir_lag_us_stat - - return cmn_stats; - } -- --/* -- * nss_gre_redir_lag_us_stats_sync() -- * Update synchonized statistics. -- */ --void nss_gre_redir_lag_us_stats_sync(struct nss_ctx_instance *nss_ctx, -- struct nss_gre_redir_lag_us_cmn_sync_stats_msg *ngss, uint32_t ifnum) --{ -- int idx, j; -- struct nss_gre_redir_lag_us_tunnel_stats *node_stats; -- -- spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -- if (!nss_gre_redir_lag_us_get_node_idx(ifnum, &idx)) { -- spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -- nss_warning("%px: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); -- return; -- } -- -- node_stats = &cmn_ctx.stats_ctx[idx].tun_stats; -- -- node_stats->tx_packets += ngss->node_stats.tx_packets; -- node_stats->tx_bytes += ngss->node_stats.tx_bytes; -- node_stats->rx_packets += ngss->node_stats.rx_packets; -- node_stats->rx_bytes += ngss->node_stats.rx_bytes; -- for (j = 0; j < NSS_MAX_NUM_PRI; j++) { -- node_stats->rx_dropped[j] += ngss->node_stats.rx_dropped[j]; -- } -- -- node_stats->us_stats.amsdu_pkts += ngss->us_stats.amsdu_pkts; -- node_stats->us_stats.amsdu_pkts_enqueued += ngss->us_stats.amsdu_pkts_enqueued; -- node_stats->us_stats.amsdu_pkts_exceptioned += ngss->us_stats.amsdu_pkts_exceptioned; -- node_stats->us_stats.exceptioned += ngss->us_stats.exceptioned; -- node_stats->us_stats.freed += ngss->us_stats.freed; -- node_stats->db_stats.add_attempt += ngss->db_stats.add_attempt; -- node_stats->db_stats.add_success += ngss->db_stats.add_success; -- node_stats->db_stats.add_fail_table_full += ngss->db_stats.add_fail_table_full; -- node_stats->db_stats.add_fail_exists += ngss->db_stats.add_fail_exists; -- node_stats->db_stats.del_attempt += ngss->db_stats.del_attempt; -- node_stats->db_stats.del_success += ngss->db_stats.del_success; -- node_stats->db_stats.del_fail_not_found += ngss->db_stats.del_fail_not_found; -- spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); --} -- --/* -- * nss_gre_redir_lag_us_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_gre_redir_lag_us_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_gre_redir_lag_us_stats_notification *stats_notify; -- int idx; -- -- stats_notify = kzalloc(sizeof(struct nss_gre_redir_lag_us_stats_notification), GFP_ATOMIC); -- if (!stats_notify) { -- nss_warning("Unable to allocate memory for stats notification\n"); -- return; -- } -- -- spin_lock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -- if (!nss_gre_redir_lag_us_get_node_idx(if_num, &idx)) { -- spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -- nss_warning("%px: Unable to update hash stats msg. Stats context not found.\n", nss_ctx); -- kfree(stats_notify); -- return; -- } -- -- stats_notify->core_id = nss_ctx->id; -- stats_notify->if_num = if_num; -- memcpy(&(stats_notify->stats_ctx), &(cmn_ctx.stats_ctx[idx].tun_stats), sizeof(stats_notify->stats_ctx)); -- spin_unlock_bh(&cmn_ctx.nss_gre_redir_lag_us_stats_lock); -- atomic_notifier_call_chain(&nss_gre_redir_lag_us_stats_notifier, NSS_STATS_EVENT_NOTIFY, stats_notify); -- kfree(stats_notify); --} -- --/* -- * nss_gre_redir_lag_us_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_gre_redir_lag_us_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_gre_redir_lag_us_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_redir_lag_us_stats_unregister_notifier); -- --/* -- * nss_gre_redir_lag_us_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_gre_redir_lag_us_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_gre_redir_lag_us_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_redir_lag_us_stats_register_notifier); -- ---- a/nss_gre_redir_lag_us_stats.h -+++ b/nss_gre_redir_lag_us_stats.h -@@ -1,6 +1,6 @@ - /* - ****************************************************************************** -- * Copyright (c) 2018, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2018, 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. -@@ -18,33 +18,23 @@ - #define __NSS_GRE_REDIR_LAG_US_STATS_H__ - - /* -- * nss_gre_redir_lag_us_pvt_sync_stats -- * Hash statistics synchronization context. -+ * GRE redirect LAG upstream statistics - */ --struct nss_gre_redir_lag_us_pvt_sync_stats { -- struct delayed_work nss_gre_redir_lag_us_work; /**< Delayed work per LAG US node. */ -- struct nss_gre_redir_lag_us_msg db_sync_msg; /**< Hash statistics message. */ -- struct nss_gre_redir_lag_us_tunnel_stats tun_stats; /**< GRE redirect LAG common statistics. */ -- nss_gre_redir_lag_us_msg_callback_t cb; /**< Callback for hash query message. */ -- void *app_data; /**< app_data for hash query message. */ -- uint32_t ifnum; /**< NSS interface number. */ -- bool valid; /**< Valid flag. */ -+enum nss_gre_redir_lag_us_stats_types { -+ NSS_GRE_REDIR_LAG_US_STATS_AMSDU_PKTS = NSS_STATS_NODE_MAX, -+ NSS_GRE_REDIR_LAG_US_STATS_AMSDU_PKTS_ENQUEUED, -+ NSS_GRE_REDIR_LAG_US_STATS_AMSDU_PKTS_EXCEPTIONED, -+ NSS_GRE_REDIR_LAG_US_STATS_EXCEPTIONED, -+ NSS_GRE_REDIR_LAG_US_STATS_FREED, -+ NSS_GRE_REDIR_LAG_US_STATS_ADD_ATTEMPT, -+ NSS_GRE_REDIR_LAG_US_STATS_ADD_SUCCESS, -+ NSS_GRE_REDIR_LAG_US_STATS_ADD_FAIL_TABLE_FULL, -+ NSS_GRE_REDIR_LAG_US_STATS_ADD_FAIL_EXISTS, -+ NSS_GRE_REDIR_LAG_US_STATS_DEL_ATTEMPT, -+ NSS_GRE_REDIR_LAG_US_STATS_DEL_SUCCESS, -+ NSS_GRE_REDIR_LAG_US_STATS_DEL_FAIL_NOT_FOUND, -+ NSS_GRE_REDIR_LAG_US_STATS_MAX, - }; - --/* -- * Common context for stats update. -- */ --struct nss_gre_redir_lag_us_cmn_ctx { -- struct workqueue_struct *nss_gre_redir_lag_us_wq; /**< Work queue. */ -- spinlock_t nss_gre_redir_lag_us_stats_lock; /**< Spin lock. */ -- struct nss_gre_redir_lag_us_pvt_sync_stats stats_ctx[NSS_GRE_REDIR_LAG_MAX_NODE]; --}; -- --extern void nss_gre_redir_lag_us_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); --extern bool nss_gre_redir_lag_us_get_node_idx(uint32_t ifnum, uint32_t *idx); --extern bool nss_gre_redir_lag_us_verify_ifnum(uint32_t if_num); --extern void nss_gre_redir_lag_us_stats_sync(struct nss_ctx_instance *nss_ctx, -- struct nss_gre_redir_lag_us_cmn_sync_stats_msg *ngss, uint32_t ifnum); - extern struct dentry *nss_gre_redir_lag_us_stats_dentry_create(void); -- - #endif ---- a/nss_gre_redir_lag_us_strings.c -+++ /dev/null -@@ -1,71 +0,0 @@ --/* -- *************************************************************************** -- * Copyright (c) 2020-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_strings.h" --#include "nss_gre_redir_lag_us_strings.h" -- --/* -- * nss_gre_redir_lag_us_strings_stats -- * GRE REDIR LAG US common statistics strings. -- */ --struct nss_stats_info nss_gre_redir_lag_us_strings_stats[NSS_GRE_REDIR_LAG_US_STATS_MAX] = { -- {"rx_packets", NSS_STATS_TYPE_COMMON}, -- {"rx_bytes", NSS_STATS_TYPE_COMMON}, -- {"tx_packets", NSS_STATS_TYPE_COMMON}, -- {"tx_bytes", NSS_STATS_TYPE_COMMON}, -- {"rx_dropped_0", NSS_STATS_TYPE_DROP}, -- {"rx_dropped_1", NSS_STATS_TYPE_DROP}, -- {"rx_dropped_2", NSS_STATS_TYPE_DROP}, -- {"rx_dropped_3", NSS_STATS_TYPE_DROP}, -- {"Amsdu pkts", NSS_STATS_TYPE_SPECIAL}, -- {"Amsdu pkts enqueued", NSS_STATS_TYPE_SPECIAL}, -- {"Amsdu pkts exceptioned", NSS_STATS_TYPE_EXCEPTION}, -- {"Exceptioned", NSS_STATS_TYPE_EXCEPTION}, -- {"Freed", NSS_STATS_TYPE_SPECIAL}, -- {"add attempt", NSS_STATS_TYPE_SPECIAL}, -- {"add success", NSS_STATS_TYPE_SPECIAL}, -- {"add fail table full", NSS_STATS_TYPE_SPECIAL}, -- {"add fail exists", NSS_STATS_TYPE_SPECIAL}, -- {"del attempt", NSS_STATS_TYPE_SPECIAL}, -- {"del success", NSS_STATS_TYPE_SPECIAL}, -- {"del fail not found", NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_gre_redir_lag_us_strings_read() -- * Read gre_redir_lag_us statistics names -- */ --static ssize_t nss_gre_redir_lag_us_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_gre_redir_lag_us_strings_stats, NSS_GRE_REDIR_LAG_US_STATS_MAX); --} -- --/* -- * nss_gre_redir_lag_us_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(gre_redir_lag_us); -- --/* -- * nss_gre_redir_lag_us_strings_dentry_create() -- * Create gre_redir_lag_us statistics strings debug entry. -- */ --void nss_gre_redir_lag_us_strings_dentry_create(void) --{ -- nss_strings_create_dentry("gre_redir_lag_us", &nss_gre_redir_lag_us_strings_ops); --} -- ---- a/nss_gre_redir_lag_us_strings.h -+++ /dev/null -@@ -1,25 +0,0 @@ --/* -- *************************************************************************** -- * Copyright (c) 2020-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. -- *************************************************************************** -- */ -- --#ifndef __NSS_GRE_REDIR_LAG_US_STRINGS_H --#define __NSS_GRE_REDIR_LAG_US_STRINGS_H -- --#include "nss_gre_redir_lag_us_stats.h" -- --extern struct nss_stats_info nss_gre_redir_lag_us_strings_stats[NSS_GRE_REDIR_LAG_US_STATS_MAX]; --extern void nss_gre_redir_lag_us_strings_dentry_create(void); -- --#endif /* __NSS_GRE_REDIR_LAG_US_STRINGS_H */ ---- a/nss_gre_redir_mark.c -+++ b/nss_gre_redir_mark.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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. -@@ -15,7 +15,6 @@ - */ - - #include "nss_tx_rx_common.h" --#include "nss_gre_redir_mark_strings.h" - #include "nss_gre_redir_mark_stats.h" - #include "nss_gre_redir_mark_log.h" - #define NSS_GRE_REDIR_MARK_TX_TIMEOUT 3000 /* 3 Seconds */ -@@ -30,6 +29,16 @@ static struct { - } nss_gre_redir_mark_pvt; - - /* -+ * Spinlock to update GRE redir mark stats. -+ */ -+static DEFINE_SPINLOCK(nss_gre_redir_mark_stats_lock); -+ -+/* -+ * Global GRE redir mark stats structure. -+ */ -+static struct nss_gre_redir_mark_stats gre_mark_stats; -+ -+/* - * nss_gre_redir_mark_msg_sync_callback() - * Callback to handle the completion of HLOS-->NSS messages. - */ -@@ -45,6 +54,54 @@ static void nss_gre_redir_mark_msg_sync_ - } - - /* -+ * nss_gre_redir_mark_stats_sync() -+ * Update GRE redir mark stats. -+ */ -+static void nss_gre_redir_mark_stats_sync(struct nss_ctx_instance *nss_ctx, int if_num, struct nss_gre_redir_mark_stats_sync_msg *ngss) -+{ -+ struct net_device *dev; -+ dev = nss_cmn_get_interface_dev(nss_ctx, if_num); -+ if (!dev) { -+ nss_warning("%px: Unable to find net device for the interface %d\n", nss_ctx, if_num); -+ return; -+ } -+ -+ if (if_num != NSS_GRE_REDIR_MARK_INTERFACE) { -+ nss_warning("%px: Unknown type for interface %d\n", nss_ctx, if_num); -+ return; -+ } -+ -+ /* -+ * Update the stats in exclusive mode to prevent the read from the process -+ * context through debug fs. -+ */ -+ spin_lock_bh(&nss_gre_redir_mark_stats_lock); -+ -+ /* -+ * Update the common node stats -+ */ -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_TX_PKTS] += ngss->node_stats.tx_packets; -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_TX_BYTES] += ngss->node_stats.tx_bytes; -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_RX_PKTS] += ngss->node_stats.rx_packets; -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_RX_BYTES] += ngss->node_stats.rx_bytes; -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_RX_DROPS] += nss_cmn_rx_dropped_sum(&(ngss->node_stats)); -+ -+ /* -+ * Update the GRE redir mark specific stats -+ */ -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_HLOS_MAGIC_FAILED] += ngss->hlos_magic_fail; -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_INV_DST_IF_DROPS] += ngss->invalid_dst_drop; -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE] += ngss->dst_enqueue_success; -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE_DROPS] += ngss->dst_enqueue_drop; -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_INV_APPID] += ngss->inv_appid; -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_HEADROOM_UNAVAILABLE] += ngss->headroom_unavail; -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_SUCCESS] += ngss->tx_completion_success; -+ gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_DROPS] += ngss->tx_completion_drop; -+ -+ spin_unlock_bh(&nss_gre_redir_mark_stats_lock); -+} -+ -+/* - * nss_gre_redir_mark_handler() - * Handle NSS to HLOS messages for GRE redir mark - */ -@@ -80,7 +137,6 @@ static void nss_gre_redir_mark_handler(s - - if (ncm->type == NSS_GRE_REDIR_MARK_STATS_SYNC_MSG) { - nss_gre_redir_mark_stats_sync(nss_ctx, ncm->interface, &ngrm->msg.stats_sync); -- nss_gre_redir_mark_stats_notify(nss_ctx, ncm->interface); - } - - /* -@@ -105,6 +161,28 @@ static void nss_gre_redir_mark_handler(s - } - - /* -+ * nss_gre_redir_mark_get_stats() -+ * Get gre_redir tunnel stats. -+ */ -+bool nss_gre_redir_mark_get_stats(void *stats_mem) -+{ -+ struct nss_gre_redir_mark_stats *stats = (struct nss_gre_redir_mark_stats *)stats_mem; -+ if (!stats) { -+ nss_warning("No memory to copy GRE redir mark stats"); -+ return false; -+ } -+ -+ /* -+ * Copy the GRE redir mark stats in the memory. -+ */ -+ spin_lock_bh(&nss_gre_redir_mark_stats_lock); -+ memcpy(stats, &gre_mark_stats, sizeof(struct nss_gre_redir_mark_stats)); -+ spin_unlock_bh(&nss_gre_redir_mark_stats_lock); -+ return true; -+} -+EXPORT_SYMBOL(nss_gre_redir_mark_get_stats); -+ -+/* - * nss_gre_redir_mark_reg_cb() - * Configure a callback on VAP. - */ -@@ -262,7 +340,7 @@ bool nss_gre_redir_mark_unregister_if(ui - return false; - } - -- nss_ctx->nss_rx_interface_handlers[if_num].msg_cb = NULL; -+ nss_ctx->nss_rx_interface_handlers[nss_ctx->id][if_num].msg_cb = NULL; - return true; - } - EXPORT_SYMBOL(nss_gre_redir_mark_unregister_if); -@@ -326,7 +404,6 @@ void nss_gre_redir_mark_register_handler - return; - } - -- nss_gre_redir_mark_strings_dentry_create(); - sema_init(&nss_gre_redir_mark_pvt.sem, 1); - init_completion(&nss_gre_redir_mark_pvt.complete); - ---- a/nss_gre_redir_mark_stats.c -+++ b/nss_gre_redir_mark_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019, 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. -@@ -18,64 +18,95 @@ - #include "nss_stats.h" - #include "nss_gre_redir_mark.h" - #include "nss_gre_redir_mark_stats.h" --#include "nss_gre_redir_mark_strings.h" - - #define NSS_GRE_REDIR_MARK_STATS_STR_LEN 50 - #define NSS_GRE_REDIR_MARK_STATS_LEN ((NSS_GRE_REDIR_MARK_STATS_MAX + 7 ) * NSS_GRE_REDIR_MARK_STATS_STR_LEN) -- --/* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_gre_redir_mark_stats_notifier); -- - /* -- * Spinlock to protect GRE redirect mark statistics update/read -+ * nss_gre_redir_mark_stats_str -+ * GRE redir mark statistics string - */ --DEFINE_SPINLOCK(nss_gre_redir_mark_stats_lock); -- --/* -- * Global GRE redirect mark stats structure. -- */ --struct nss_gre_redir_mark_stats gre_mark_stats; -- --/* -- * nss_gre_redir_mark_stats_get() -- * Get gre_redir tunnel stats. -- */ --bool nss_gre_redir_mark_stats_get(struct nss_gre_redir_mark_stats *stats_mem) --{ -- if (!stats_mem) { -- nss_warning("No memory to copy GRE redir mark stats"); -- return false; -+static int8_t *nss_gre_redir_mark_stats_str[NSS_GRE_REDIR_MARK_STATS_MAX] = { -+ "TX Packets", -+ "TX Bytes", -+ "RX Packets", -+ "RX Bytes", -+ "RX Drops", -+ "HLOS Magic Failed", -+ "Tx Inv_dst_if Drops", -+ "Tx Dst_if Enqueue", -+ "Tx Dst_if Enqueue Drops", -+ "Invalid Appid", -+ "Headroom Unavailable", -+ "Tx Completion Host Enqueue Success", -+ "Tx Completion Host Enqueue Drops", -+}; -+ -+/* -+ * nss_gre_redir_mark_stats_cpy() -+ * Fill the stats. -+ */ -+static ssize_t nss_gre_redir_mark_stats_cpy(char *lbuf, int len, int i, struct nss_gre_redir_mark_stats *s) -+{ -+ uint64_t tcnt = 0; -+ -+ switch (i) { -+ case NSS_GRE_REDIR_MARK_STATS_TX_PKTS: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_TX_PKTS]; -+ return scnprintf(lbuf, len, "Common node stats start:\n\n%s = %llu\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_TX_BYTES: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_TX_BYTES]; -+ return scnprintf(lbuf, len, "%s = %llu\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_RX_PKTS: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_RX_PKTS]; -+ return scnprintf(lbuf, len, "%s = %llu\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_RX_BYTES: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_RX_BYTES]; -+ return scnprintf(lbuf, len, "%s = %llu\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_RX_DROPS: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_RX_DROPS]; -+ return scnprintf(lbuf, len, "%s = %llu\nCommon node stats end.\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_HLOS_MAGIC_FAILED: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_HLOS_MAGIC_FAILED]; -+ return scnprintf(lbuf, len, "Offload stats start:\n\n%s = %llu\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_INV_DST_IF_DROPS: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_INV_DST_IF_DROPS]; -+ return scnprintf(lbuf, len, "%s = %llu\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE]; -+ return scnprintf(lbuf, len, "%s = %llu\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE_DROPS: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE_DROPS]; -+ return scnprintf(lbuf, len, "%s = %llu\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_INV_APPID: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_INV_APPID]; -+ return scnprintf(lbuf, len, "%s = %llu\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_HEADROOM_UNAVAILABLE: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_HEADROOM_UNAVAILABLE]; -+ return scnprintf(lbuf, len, "%s = %llu\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_SUCCESS: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_SUCCESS]; -+ return scnprintf(lbuf, len, "%s = %llu\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_DROPS: -+ tcnt = s->stats[NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_DROPS]; -+ return scnprintf(lbuf, len, "%s = %llu\nOffload stats end.\n", nss_gre_redir_mark_stats_str[i], tcnt); -+ default: -+ nss_warning("Unknown stats type %d.\n", i); -+ return 0; - } -- -- /* -- * Copy the GRE redir mark stats in the memory. -- */ -- spin_lock_bh(&nss_gre_redir_mark_stats_lock); -- memcpy(stats_mem, &gre_mark_stats, sizeof(struct nss_gre_redir_mark_stats)); -- spin_unlock_bh(&nss_gre_redir_mark_stats_lock); -- return true; - } --EXPORT_SYMBOL(nss_gre_redir_mark_stats_get); - --/** -+/* - * nss_gre_redir_mark_stats_read() - * READ GRE redir mark stats. - */ - static ssize_t nss_gre_redir_mark_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) - { -- /* -- * Max output lines = #stats + -- * few blank lines for banner printing + Number of Extra outputlines -- * for future reference to add new stats -- */ -- uint32_t max_output_lines = NSS_GRE_REDIR_MARK_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - struct nss_gre_redir_mark_stats stats; - size_t size_wr = 0; -+ int start, end; - ssize_t bytes_read = 0; - bool isthere; -+ size_t size_al = ((NSS_GRE_REDIR_MARK_STATS_MAX + 7 ) * NSS_GRE_REDIR_MARK_STATS_STR_LEN); - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(!lbuf)) { -@@ -86,16 +117,21 @@ static ssize_t nss_gre_redir_mark_stats_ - /* - * If GRE redir mark does not exists, then (isthere) will be false. - */ -- isthere = nss_gre_redir_mark_stats_get(&stats); -+ isthere = nss_gre_redir_mark_get_stats((void*)&stats); - if (!isthere) { - nss_warning("Could not get GRE redirect stats"); - kfree(lbuf); - return 0; - } - -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "gre_redir_mark stats", NSS_STATS_SINGLE_CORE); -- size_wr += nss_stats_print("gre_redir_mark", NULL, NSS_STATS_SINGLE_INSTANCE, nss_gre_redir_mark_strings_stats, -- stats.stats, NSS_GRE_REDIR_MARK_STATS_MAX, lbuf, size_wr, size_al); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nGRE redir mark stats\n"); -+ -+ start = NSS_GRE_REDIR_MARK_STATS_TX_PKTS; -+ end = NSS_GRE_REDIR_MARK_STATS_MAX; -+ while (start < end) { -+ size_wr += nss_gre_redir_mark_stats_cpy(lbuf + size_wr, size_al - size_wr, start, &stats); -+ start++; -+ } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - -@@ -125,106 +161,3 @@ struct dentry *nss_gre_redir_mark_stats_ - - return gre_redir_mark; - } -- --/* -- * nss_gre_redir_mark_stats_sync() -- * Update GRE redir mark stats. -- */ --void nss_gre_redir_mark_stats_sync(struct nss_ctx_instance *nss_ctx, int if_num, struct nss_gre_redir_mark_stats_sync_msg *ngss) --{ -- int i; -- struct net_device *dev; -- dev = nss_cmn_get_interface_dev(nss_ctx, if_num); -- if (!dev) { -- nss_warning("%px: Unable to find net device for the interface %d\n", nss_ctx, if_num); -- return; -- } -- -- if (if_num != NSS_GRE_REDIR_MARK_INTERFACE) { -- nss_warning("%px: Unknown type for interface %d\n", nss_ctx, if_num); -- return; -- } -- -- /* -- * Update the stats in exclusive mode to prevent the read from the process -- * context through debug fs. -- */ -- spin_lock_bh(&nss_gre_redir_mark_stats_lock); -- -- /* -- * Update the common node stats -- */ -- gre_mark_stats.stats[NSS_STATS_NODE_TX_PKTS] += ngss->node_stats.tx_packets; -- gre_mark_stats.stats[NSS_STATS_NODE_TX_BYTES] += ngss->node_stats.tx_bytes; -- gre_mark_stats.stats[NSS_STATS_NODE_RX_PKTS] += ngss->node_stats.rx_packets; -- gre_mark_stats.stats[NSS_STATS_NODE_RX_BYTES] += ngss->node_stats.rx_bytes; -- for (i = 0; i < NSS_MAX_NUM_PRI; i++) { -- gre_mark_stats.stats[NSS_STATS_NODE_RX_QUEUE_0_DROPPED + i] += ngss->node_stats.rx_dropped[i]; -- } -- -- /* -- * Update the GRE redir mark specific stats -- */ -- gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_HLOS_MAGIC_FAILED] += ngss->hlos_magic_fail; -- gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_INV_DST_IF_DROPS] += ngss->invalid_dst_drop; -- gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE] += ngss->dst_enqueue_success; -- gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE_DROPS] += ngss->dst_enqueue_drop; -- gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_INV_APPID] += ngss->inv_appid; -- gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_HEADROOM_UNAVAILABLE] += ngss->headroom_unavail; -- gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_SUCCESS] += ngss->tx_completion_success; -- gre_mark_stats.stats[NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_DROPS] += ngss->tx_completion_drop; -- -- spin_unlock_bh(&nss_gre_redir_mark_stats_lock); --} -- --/* -- * nss_gre_redir_mark_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_gre_redir_mark_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_gre_redir_mark_stats_notification *stats_notify; -- -- stats_notify = kzalloc(sizeof(struct nss_gre_redir_mark_stats_notification), GFP_ATOMIC); -- if (!stats_notify) { -- nss_warning("Unable to allocate memory for stats notification\n"); -- return; -- } -- -- if (if_num != NSS_GRE_REDIR_MARK_INTERFACE) { -- nss_warning("%px: Unknown type for interface %d\n", nss_ctx, if_num); -- kfree(stats_notify); -- return; -- } -- -- spin_lock_bh(&nss_gre_redir_mark_stats_lock); -- stats_notify->core_id = nss_ctx->id; -- stats_notify->if_num = if_num; -- memcpy(stats_notify->stats_ctx, gre_mark_stats.stats, sizeof(stats_notify->stats_ctx)); -- spin_unlock_bh(&nss_gre_redir_mark_stats_lock); -- -- atomic_notifier_call_chain(&nss_gre_redir_mark_stats_notifier, NSS_STATS_EVENT_NOTIFY, stats_notify); -- kfree(stats_notify); --} -- --/* -- * nss_gre_redir_mark_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_gre_redir_mark_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_gre_redir_mark_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_redir_mark_stats_unregister_notifier); -- --/* -- * nss_gre_redir_mark_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_gre_redir_mark_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_gre_redir_mark_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_redir_mark_stats_register_notifier); ---- a/nss_gre_redir_mark_stats.h -+++ b/nss_gre_redir_mark_stats.h -@@ -1,6 +1,6 @@ - /* - ****************************************************************************** -- * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019, 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. -@@ -18,6 +18,26 @@ - #define __NSS_GRE_REDIR_MARK_STATS_H__ - - /* -+ * GRE REDIR statistics types -+ */ -+enum nss_gre_redir_mark_stats_types { -+ NSS_GRE_REDIR_MARK_STATS_TX_PKTS, -+ NSS_GRE_REDIR_MARK_STATS_TX_BYTES, -+ NSS_GRE_REDIR_MARK_STATS_RX_PKTS, -+ NSS_GRE_REDIR_MARK_STATS_RX_BYTES, -+ NSS_GRE_REDIR_MARK_STATS_RX_DROPS, -+ NSS_GRE_REDIR_MARK_STATS_HLOS_MAGIC_FAILED, -+ NSS_GRE_REDIR_MARK_STATS_INV_DST_IF_DROPS, -+ NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE, -+ NSS_GRE_REDIR_MARK_STATS_DST_IF_ENQUEUE_DROPS, -+ NSS_GRE_REDIR_MARK_STATS_INV_APPID, -+ NSS_GRE_REDIR_MARK_STATS_HEADROOM_UNAVAILABLE, -+ NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_SUCCESS, -+ NSS_GRE_REDIR_MARK_STATS_TX_COMPLETION_DROPS, -+ NSS_GRE_REDIR_MARK_STATS_MAX -+}; -+ -+/* - * NSS core stats -- for H2N/N2H gre_redir_mark debug stats - */ - struct nss_gre_redir_mark_stats { -@@ -27,9 +47,6 @@ struct nss_gre_redir_mark_stats { - /* - * NSS GRE REDIR Mark statistics APIs - */ --extern void nss_gre_redir_mark_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); --extern void nss_gre_redir_mark_stats_sync(struct nss_ctx_instance *nss_ctx, int if_num, -- struct nss_gre_redir_mark_stats_sync_msg *ngss); - extern struct dentry *nss_gre_redir_mark_stats_dentry_create(void); - - #endif /* __NSS_GRE_REDIR_MARK_STATS_H__ */ ---- a/nss_gre_redir_mark_strings.c -+++ /dev/null -@@ -1,66 +0,0 @@ --/* -- *************************************************************************** -- * Copyright (c) 2020-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_strings.h" --#include "nss_gre_redir_mark_strings.h" -- --/* -- * nss_gre_redir_mark_strings_stats -- * GRE redir mark statistics string -- */ --struct nss_stats_info nss_gre_redir_mark_strings_stats[NSS_GRE_REDIR_MARK_STATS_MAX] = { -- {"rx Packets", NSS_STATS_TYPE_COMMON}, -- {"rx Bytes", NSS_STATS_TYPE_COMMON}, -- {"tx Packets", NSS_STATS_TYPE_COMMON}, -- {"tx Bytes", NSS_STATS_TYPE_COMMON}, -- {"rx_dropped_0", NSS_STATS_TYPE_DROP}, -- {"rx_dropped_1", NSS_STATS_TYPE_DROP}, -- {"rx_dropped_2", NSS_STATS_TYPE_DROP}, -- {"rx_dropped_3", NSS_STATS_TYPE_DROP}, -- {"HLOS Magic Failed", NSS_STATS_TYPE_SPECIAL}, -- {"tx Inv_dst_if Drops", NSS_STATS_TYPE_DROP}, -- {"tx Dst_if Enqueue", NSS_STATS_TYPE_SPECIAL}, -- {"tx Dst_if Enqueue Drops", NSS_STATS_TYPE_DROP}, -- {"Invalid Appid", NSS_STATS_TYPE_SPECIAL}, -- {"Headroom Unavailable", NSS_STATS_TYPE_EXCEPTION}, -- {"tx Completion Host Enqueue Success", NSS_STATS_TYPE_SPECIAL}, -- {"tx Completion Host Enqueue Drops", NSS_STATS_TYPE_DROP} --}; -- --/* -- * nss_gre_redir_mark_strings_read() -- * Read gre_redir_mark statistics names -- */ --static ssize_t nss_gre_redir_mark_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_gre_redir_mark_strings_stats, NSS_GRE_REDIR_MARK_STATS_MAX); --} -- --/* -- * nss_gre_redir_mark_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(gre_redir_mark); -- --/* -- * nss_gre_redir_mark_strings_dentry_create() -- * Create gre_redir_mark statistics strings debug entry. -- */ --void nss_gre_redir_mark_strings_dentry_create(void) --{ -- nss_strings_create_dentry("gre_redir_mark", &nss_gre_redir_mark_strings_ops); --} ---- a/nss_gre_redir_mark_strings.h -+++ /dev/null -@@ -1,25 +0,0 @@ --/* -- **************************************************************************** -- * Copyright (c) 2020-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. -- **************************************************************************** -- */ -- --#ifndef __NSS_GRE_REDIR_MARK_STRINGS_H --#define __NSS_GRE_REDIR_MARK_STRINGS_H -- --#include "nss_gre_redir_mark_stats.h" -- --extern struct nss_stats_info nss_gre_redir_mark_strings_stats[NSS_GRE_REDIR_MARK_STATS_MAX]; --extern void nss_gre_redir_mark_strings_dentry_create(void); -- --#endif /* __NSS_GRE_REDIR_MARK_STRINGS_H */ ---- a/nss_gre_redir_stats.c -+++ b/nss_gre_redir_stats.c -@@ -1,6 +1,6 @@ - /* -- **************************************************************************** -- * Copyright (c) 2017-2019, 2021, The Linux Foundation. All rights reserved. -+ ************************************************************************** -+ * Copyright (c) 2017-2019, 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. -@@ -11,46 +11,146 @@ - * 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_core.h" - #include "nss_gre_redir.h" - #include "nss_gre_redir_stats.h" --#include "nss_gre_redir_strings.h" - - /* -- * Declare atomic notifier data structure for statistics. -+ * nss_gre_redir_stats_str -+ * GRE REDIR statistics string - */ --ATOMIC_NOTIFIER_HEAD(nss_gre_redir_stats_notifier); -+static int8_t *nss_gre_redir_stats_str[NSS_GRE_REDIR_STATS_MAX] = { -+ "TX Packets", -+ "TX Bytes", -+ "TX Drops", -+ "RX Packets", -+ "RX Bytes", -+ "RX Drops", -+ "TX Sjack Packets", -+ "RX Sjack packets", -+ "TX Offload Packets", -+ "RX Offload Packets", -+ "US exception RX Packets", -+ "US exception TX Packets", -+ "DS exception RX Packets", -+ "DS exception TX Packets", -+ "Encap SG alloc drop", -+ "Decap fail drop", -+ "Decap split drop", -+ "Split SG alloc fail", -+ "Split linear copy fail", -+ "Split not enough tailroom", -+ "Exception ds invalid dst", -+ "Decap eapol frames", -+ "Exception ds invalid appid", -+ "Headroom Unavailable", -+ "Exception ds Tx completion Success", -+ "Exception ds Tx completion drop" -+}; - - /* -- * Spinlock to protect GRE redirect statistics update/read -+ * nss_gre_redir_stats() -+ * Make a row for GRE_REDIR stats. - */ --DEFINE_SPINLOCK(nss_gre_redir_stats_lock); -- --/* -- * Array to hold tunnel stats along with if_num -- */ --extern struct nss_gre_redir_tunnel_stats tun_stats[NSS_GRE_REDIR_MAX_INTERFACES]; -- --/* -- * nss_gre_redir_stats_get() -- * Get GRE redirect tunnel stats. -- */ --bool nss_gre_redir_stats_get(int index, struct nss_gre_redir_tunnel_stats *stats) -+static ssize_t nss_gre_redir_stats(char *line, int len, int i, struct nss_gre_redir_tunnel_stats *s) - { -- spin_lock_bh(&nss_gre_redir_stats_lock); -- if (tun_stats[index].ref_count == 0) { -- spin_unlock_bh(&nss_gre_redir_stats_lock); -- return false; -+ char name[40]; -+ uint64_t tcnt = 0; -+ int j = 0; -+ -+ switch (i) { -+ case NSS_GRE_REDIR_STATS_TX_PKTS: -+ tcnt = s->node_stats.tx_packets; -+ return snprintf(line, len, "Common node stats start:\n\n%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_TX_BYTES: -+ tcnt = s->node_stats.tx_bytes; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_TX_DROPS: -+ tcnt = s->tx_dropped; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_RX_PKTS: -+ tcnt = s->node_stats.rx_packets; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_RX_BYTES: -+ tcnt = s->node_stats.rx_bytes; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_RX_DROPS: -+ tcnt = s->node_stats.rx_dropped[0]; -+ return snprintf(line, len, "%s = %llu\nCommon node stats end.\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_SJACK_TX_PKTS: -+ tcnt = s->sjack_tx_packets; -+ return snprintf(line, len, "Offload stats start:\n\n%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_OFFLOAD_TX_PKTS: -+ for (j = 0; j < NSS_GRE_REDIR_MAX_RADIO; j++) { -+ scnprintf(name, sizeof(name), "TX offload pkts for radio %d", j); -+ tcnt += snprintf(line + tcnt, len - tcnt, "%s = %llu\n", name, s->offl_tx_pkts[j]); -+ } -+ return tcnt; -+ case NSS_GRE_REDIR_STATS_SJACK_RX_PKTS: -+ tcnt = s->sjack_rx_packets; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_OFFLOAD_RX_PKTS: -+ for (j = 0; j < NSS_GRE_REDIR_MAX_RADIO; j++) { -+ scnprintf(name, sizeof(name), "RX offload pkts for radio %d", j); -+ tcnt += snprintf(line + tcnt, len - tcnt, "%s = %llu\n", name, s->offl_rx_pkts[j]); -+ } -+ return tcnt; -+ case NSS_GRE_REDIR_STATS_EXCEPTION_US_RX_PKTS: -+ tcnt = s->exception_us_rx; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_EXCEPTION_US_TX_PKTS: -+ tcnt = s->exception_us_tx; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_EXCEPTION_DS_RX_PKTS: -+ tcnt = s->exception_ds_rx; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_EXCEPTION_DS_TX_PKTS: -+ tcnt = s->exception_ds_tx; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_ENCAP_SG_ALLOC_DROP: -+ tcnt = s->encap_sg_alloc_drop; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_DECAP_FAIL_DROP: -+ tcnt = s->decap_fail_drop; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_DECAP_SPLIT_DROP: -+ tcnt = s->decap_split_drop; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_SPLIT_SG_ALLOC_FAIL: -+ tcnt = s->split_sg_alloc_fail; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_SPLIT_LINEAR_COPY_FAIL: -+ tcnt = s->split_linear_copy_fail; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_SPLIT_NOT_ENOUGH_TAILROOM: -+ tcnt = s->split_not_enough_tailroom; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_EXCEPTION_DS_INVALID_DST_DROP: -+ tcnt = s->exception_ds_invalid_dst_drop; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_DECAP_EAPOL_FRAMES: -+ tcnt = s->decap_eapol_frames; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_EXCEPTION_DS_INV_APPID: -+ tcnt = s->exception_ds_inv_appid; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_HEADROOM_UNAVAILABLE: -+ tcnt = s->headroom_unavail; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_TX_COMPLETION_SUCCESS: -+ tcnt = s->tx_completion_success; -+ return snprintf(line, len, "%s = %llu\n", nss_gre_redir_stats_str[i], tcnt); -+ case NSS_GRE_REDIR_STATS_TX_COMPLETION_DROP: -+ tcnt = s->tx_completion_drop; -+ return snprintf(line, len, "%s = %llu\nOffload stats end.\n", nss_gre_redir_stats_str[i], tcnt); -+ default: -+ nss_warning("Unknown stats type %d.\n", i); -+ return 0; - } -- -- memcpy(stats, &tun_stats[index], sizeof(struct nss_gre_redir_tunnel_stats)); -- spin_unlock_bh(&nss_gre_redir_stats_lock); -- return true; - } --EXPORT_SYMBOL(nss_gre_redir_stats_get); - - /* - * nss_gre_redir_stats_read() -@@ -58,25 +158,14 @@ EXPORT_SYMBOL(nss_gre_redir_stats_get); - */ - static ssize_t nss_gre_redir_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) - { -- /* -- * Max output lines = #stats + -- * few blank lines for banner printing + Number of Extra outputlines -- * for future reference to add new stats -- */ -- uint32_t max_output_lines = NSS_GRE_REDIR_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines * NSS_GRE_REDIR_MAX_INTERFACES; - struct nss_stats_data *data = fp->private_data; -- struct nss_gre_redir_tunnel_stats stats; - ssize_t bytes_read = 0; -- size_t size_wr = 0; -+ struct nss_gre_redir_tunnel_stats stats; -+ size_t bytes; -+ char line[80 * NSS_GRE_REDIR_MAX_RADIO]; -+ int start, end; - int index = 0; - -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(!lbuf)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -- - if (data) { - index = data->index; - } -@@ -85,7 +174,6 @@ static ssize_t nss_gre_redir_stats_read( - * If we are done accomodating all the GRE_REDIR tunnels. - */ - if (index >= NSS_GRE_REDIR_MAX_INTERFACES) { -- kfree(lbuf); - return 0; - } - -@@ -95,23 +183,48 @@ static ssize_t nss_gre_redir_stats_read( - /* - * If gre_redir tunnel does not exists, then isthere will be false. - */ -- isthere = nss_gre_redir_stats_get(index, &stats); -+ isthere = nss_gre_redir_get_stats(index, &stats); - if (!isthere) { - continue; - } - -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "gre_redir stats", NSS_STATS_SINGLE_CORE); -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nTunnel stats for %s\n", stats.dev->name); -- size_wr += nss_stats_print("gre_redir", NULL, NSS_STATS_SINGLE_INSTANCE, nss_gre_redir_strings_stats, -- &stats.tstats.rx_packets, NSS_GRE_REDIR_STATS_MAX, lbuf, size_wr, size_al); -+ bytes = snprintf(line, sizeof(line), "\nTunnel stats for %s\n", stats.dev->name); -+ if ((bytes_read + bytes) > sz) { -+ break; -+ } -+ -+ if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { -+ bytes_read = -EFAULT; -+ goto fail; -+ } -+ bytes_read += bytes; -+ start = NSS_GRE_REDIR_STATS_TX_PKTS; -+ end = NSS_GRE_REDIR_STATS_MAX; -+ while (bytes_read < sz && start < end) { -+ bytes = nss_gre_redir_stats(line, sizeof(line), start, &stats); -+ -+ if ((bytes_read + bytes) > sz) -+ break; -+ -+ if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { -+ bytes_read = -EFAULT; -+ goto fail; -+ } -+ -+ bytes_read += bytes; -+ start++; -+ } -+ } -+ -+ if (bytes_read > 0) { -+ *ppos = bytes_read; - } - -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - if (data) { - data->index = index; - } - -- kfree(lbuf); -+fail: - return bytes_read; - } - -@@ -145,168 +258,3 @@ struct dentry *nss_gre_redir_stats_dentr - - return gre_redir; - } -- --/* -- * nss_gre_redir_stats_sync() -- * Update gre_redir tunnel stats. -- */ --void nss_gre_redir_stats_sync(struct nss_ctx_instance *nss_ctx, int if_num, struct nss_gre_redir_stats_sync_msg *ngss) --{ -- int i, j; -- uint32_t type; -- struct net_device *dev; -- struct nss_gre_redir_tun_stats *node_stats; -- -- type = nss_dynamic_interface_get_type(nss_ctx, if_num); -- dev = nss_cmn_get_interface_dev(nss_ctx, if_num); -- if (!dev) { -- nss_warning("%px: Unable to find net device for the interface %d\n", nss_ctx, if_num); -- return; -- } -- -- if (!nss_gre_redir_verify_ifnum(if_num)) { -- nss_warning("%px: Unknown type for interface %d\n", nss_ctx, if_num); -- return; -- } -- -- spin_lock_bh(&nss_gre_redir_stats_lock); -- for (i = 0; i < NSS_GRE_REDIR_MAX_INTERFACES; i++) { -- if (tun_stats[i].dev == dev) { -- break; -- } -- } -- -- if (i == NSS_GRE_REDIR_MAX_INTERFACES) { -- nss_warning("%px: Unable to find tunnel stats instance for interface %d\n", nss_ctx, if_num); -- spin_unlock_bh(&nss_gre_redir_stats_lock); -- return; -- } -- -- nss_assert(tun_stats[i].ref_count); -- node_stats = &tun_stats[i].tstats; -- switch (type) { -- case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_HOST_INNER: -- case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_WIFI_OFFL_INNER: -- case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_SJACK_INNER: -- node_stats->tx_packets += ngss->node_stats.tx_packets; -- node_stats->tx_bytes += ngss->node_stats.tx_bytes; -- node_stats->sjack_tx_packets += ngss->sjack_rx_packets; -- node_stats->encap_sg_alloc_drop += ngss->encap_sg_alloc_drop; -- node_stats->tx_dropped += nss_cmn_rx_dropped_sum(&(ngss->node_stats)); -- for (j = 0; j < NSS_GRE_REDIR_MAX_RADIO; j++) { -- node_stats->offl_tx_pkts[j] += ngss->offl_rx_pkts[j]; -- } -- -- break; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_OUTER: -- node_stats->rx_packets += ngss->node_stats.rx_packets; -- node_stats->rx_bytes += ngss->node_stats.rx_bytes; -- node_stats->sjack_rx_packets += ngss->sjack_rx_packets; -- node_stats->decap_fail_drop += ngss->decap_fail_drop; -- node_stats->decap_split_drop += ngss->decap_split_drop; -- node_stats->split_sg_alloc_fail += ngss->split_sg_alloc_fail; -- node_stats->split_linear_copy_fail += ngss->split_linear_copy_fail; -- node_stats->split_not_enough_tailroom += ngss->split_not_enough_tailroom; -- node_stats->decap_eapol_frames += ngss->decap_eapol_frames; -- for (j = 0; j < NSS_MAX_NUM_PRI; j++) { -- node_stats->rx_dropped[j] += ngss->node_stats.rx_dropped[j]; -- } -- -- for (j = 0; j < NSS_GRE_REDIR_MAX_RADIO; j++) { -- node_stats->offl_rx_pkts[j] += ngss->offl_rx_pkts[j]; -- } -- -- break; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_US: -- node_stats->exception_us_rx += ngss->node_stats.rx_packets; -- node_stats->exception_us_tx += ngss->node_stats.tx_packets; -- break; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_GRE_REDIR_EXCEPTION_DS: -- node_stats->exception_ds_rx += ngss->node_stats.rx_packets; -- node_stats->exception_ds_tx += ngss->node_stats.tx_packets; -- node_stats->exception_ds_invalid_dst_drop += ngss->exception_ds_invalid_dst_drop; -- node_stats->exception_ds_inv_appid += ngss->exception_ds_inv_appid; -- node_stats->headroom_unavail += ngss->headroom_unavail; -- node_stats->tx_completion_success += ngss->tx_completion_success; -- node_stats->tx_completion_drop += ngss->tx_completion_drop; -- break; -- } -- -- spin_unlock_bh(&nss_gre_redir_stats_lock); --} -- --/* -- * nss_gre_redir_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_gre_redir_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_gre_redir_stats_notification *stats_notify; -- struct net_device *dev; -- int i; -- -- stats_notify = kzalloc(sizeof(struct nss_gre_redir_stats_notification), GFP_ATOMIC); -- if (!stats_notify) { -- nss_warning("Unable to allocate memory for stats notification\n"); -- return; -- } -- -- dev = nss_cmn_get_interface_dev(nss_ctx, if_num); -- if (!dev) { -- nss_warning("%px: Unable to find net device for the interface %d\n", nss_ctx, if_num); -- kfree(stats_notify); -- return; -- } -- -- if (!nss_gre_redir_verify_ifnum(if_num)) { -- nss_warning("%px: Unknown type for interface %d\n", nss_ctx, if_num); -- kfree(stats_notify); -- return; -- } -- -- spin_lock_bh(&nss_gre_redir_stats_lock); -- for (i = 0; i < NSS_GRE_REDIR_MAX_INTERFACES; i++) { -- if (tun_stats[i].dev == dev) { -- break; -- } -- } -- -- if (i == NSS_GRE_REDIR_MAX_INTERFACES) { -- nss_warning("%px: Unable to find tunnel stats instance for interface %d\n", nss_ctx, if_num); -- spin_unlock_bh(&nss_gre_redir_stats_lock); -- kfree(stats_notify); -- return; -- } -- -- stats_notify->core_id = nss_ctx->id; -- stats_notify->if_num = if_num; -- memcpy(&(stats_notify->stats_ctx), &(tun_stats[i]), sizeof(stats_notify->stats_ctx)); -- spin_unlock_bh(&nss_gre_redir_stats_lock); -- atomic_notifier_call_chain(&nss_gre_redir_stats_notifier, NSS_STATS_EVENT_NOTIFY, stats_notify); -- kfree(stats_notify); --} -- --/* -- * nss_gre_redir_stats_unregister_notifier() -- * Degisters statistics notifier. -- */ --int nss_gre_redir_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_gre_redir_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_redir_stats_unregister_notifier); -- --/* -- * nss_gre_redir_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_gre_redir_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_gre_redir_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_redir_stats_register_notifier); ---- a/nss_gre_redir_stats.h -+++ b/nss_gre_redir_stats.h -@@ -1,6 +1,6 @@ - /* - ****************************************************************************** -- * Copyright (c) 2017-2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2019, 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. -@@ -18,13 +18,41 @@ - #define __NSS_GRE_REDIR_STATS_H__ - - /* -+ * GRE REDIR statistics -+ */ -+enum nss_gre_redir_stats_types { -+ NSS_GRE_REDIR_STATS_TX_PKTS, -+ NSS_GRE_REDIR_STATS_TX_BYTES, -+ NSS_GRE_REDIR_STATS_TX_DROPS, -+ NSS_GRE_REDIR_STATS_RX_PKTS, -+ NSS_GRE_REDIR_STATS_RX_BYTES, -+ NSS_GRE_REDIR_STATS_RX_DROPS, -+ NSS_GRE_REDIR_STATS_SJACK_TX_PKTS, -+ NSS_GRE_REDIR_STATS_SJACK_RX_PKTS, -+ NSS_GRE_REDIR_STATS_OFFLOAD_TX_PKTS, -+ NSS_GRE_REDIR_STATS_OFFLOAD_RX_PKTS, -+ NSS_GRE_REDIR_STATS_EXCEPTION_US_RX_PKTS, -+ NSS_GRE_REDIR_STATS_EXCEPTION_US_TX_PKTS, -+ NSS_GRE_REDIR_STATS_EXCEPTION_DS_RX_PKTS, -+ NSS_GRE_REDIR_STATS_EXCEPTION_DS_TX_PKTS, -+ NSS_GRE_REDIR_STATS_ENCAP_SG_ALLOC_DROP, -+ NSS_GRE_REDIR_STATS_DECAP_FAIL_DROP, -+ NSS_GRE_REDIR_STATS_DECAP_SPLIT_DROP, -+ NSS_GRE_REDIR_STATS_SPLIT_SG_ALLOC_FAIL, -+ NSS_GRE_REDIR_STATS_SPLIT_LINEAR_COPY_FAIL, -+ NSS_GRE_REDIR_STATS_SPLIT_NOT_ENOUGH_TAILROOM, -+ NSS_GRE_REDIR_STATS_EXCEPTION_DS_INVALID_DST_DROP, -+ NSS_GRE_REDIR_STATS_DECAP_EAPOL_FRAMES, -+ NSS_GRE_REDIR_STATS_EXCEPTION_DS_INV_APPID, -+ NSS_GRE_REDIR_STATS_HEADROOM_UNAVAILABLE, -+ NSS_GRE_REDIR_STATS_TX_COMPLETION_SUCCESS, -+ NSS_GRE_REDIR_STATS_TX_COMPLETION_DROP, -+ NSS_GRE_REDIR_STATS_MAX -+}; -+ -+/* - * NSS GRE REDIR statistics APIs - */ --extern spinlock_t nss_gre_redir_stats_lock; --extern bool nss_gre_redir_verify_ifnum(uint32_t if_num); --extern void nss_gre_redir_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); --extern void nss_gre_redir_stats_sync(struct nss_ctx_instance *nss_ctx, int if_num, -- struct nss_gre_redir_stats_sync_msg *ngss); - extern struct dentry *nss_gre_redir_stats_dentry_create(void); - - #endif /* __NSS_GRE_REDIR_STATS_H__ */ ---- a/nss_gre_redir_strings.c -+++ /dev/null -@@ -1,87 +0,0 @@ --/* -- *************************************************************************** -- * Copyright (c) 2020-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_strings.h" --#include "nss_gre_redir_strings.h" -- --/* -- * nss_gre_redir_strings_stats -- * GRE redirect statistics string. -- */ --struct nss_stats_info nss_gre_redir_strings_stats[NSS_GRE_REDIR_STATS_MAX] = { -- {"RX Packets", NSS_STATS_TYPE_COMMON}, -- {"RX Bytes", NSS_STATS_TYPE_COMMON}, -- {"TX Packets", NSS_STATS_TYPE_COMMON}, -- {"TX Bytes", NSS_STATS_TYPE_COMMON}, -- {"RX Drops_[0]", NSS_STATS_TYPE_DROP}, -- {"RX Drops_[1]", NSS_STATS_TYPE_DROP}, -- {"RX Drops_[2]", NSS_STATS_TYPE_DROP}, -- {"RX Drops_[3]", NSS_STATS_TYPE_DROP}, -- {"TX Drops", NSS_STATS_TYPE_DROP}, -- {"RX Sjack Packets", NSS_STATS_TYPE_SPECIAL}, -- {"TX Sjack packets", NSS_STATS_TYPE_SPECIAL}, -- {"RX Offload Packets_[0]", NSS_STATS_TYPE_SPECIAL}, -- {"RX Offload Packets_[1]", NSS_STATS_TYPE_SPECIAL}, -- {"RX Offload Packets_[2]", NSS_STATS_TYPE_SPECIAL}, -- {"RX Offload Packets_[3]", NSS_STATS_TYPE_SPECIAL}, -- {"RX Offload Packets_[4]", NSS_STATS_TYPE_SPECIAL}, -- {"TX Offload Packets_[0]", NSS_STATS_TYPE_SPECIAL}, -- {"TX Offload Packets_[1]", NSS_STATS_TYPE_SPECIAL}, -- {"TX Offload Packets_[2]", NSS_STATS_TYPE_SPECIAL}, -- {"TX Offload Packets_[3]", NSS_STATS_TYPE_SPECIAL}, -- {"TX Offload Packets_[4]", NSS_STATS_TYPE_SPECIAL}, -- {"US exception RX Packets", NSS_STATS_TYPE_EXCEPTION}, -- {"US exception TX Packets", NSS_STATS_TYPE_EXCEPTION}, -- {"DS exception RX Packets", NSS_STATS_TYPE_EXCEPTION}, -- {"DS exception TX Packets", NSS_STATS_TYPE_EXCEPTION}, -- {"Encap SG alloc drop", NSS_STATS_TYPE_DROP}, -- {"Decap fail drop", NSS_STATS_TYPE_DROP}, -- {"Decap split drop", NSS_STATS_TYPE_SPECIAL}, -- {"Split SG alloc fail", NSS_STATS_TYPE_SPECIAL}, -- {"Split linear copy fail", NSS_STATS_TYPE_SPECIAL}, -- {"Split not enough tailroom", NSS_STATS_TYPE_EXCEPTION}, -- {"Exception ds invalid dst", NSS_STATS_TYPE_SPECIAL}, -- {"Decap eapol frames", NSS_STATS_TYPE_SPECIAL}, -- {"Exception ds invalid appid", NSS_STATS_TYPE_EXCEPTION}, -- {"Headroom Unavailable", NSS_STATS_TYPE_EXCEPTION}, -- {"Exception ds Tx completion Success", NSS_STATS_TYPE_SPECIAL}, -- {"Exception ds Tx completion drop", NSS_STATS_TYPE_DROP} --}; -- --/* -- * nss_gre_redir_strings_read() -- * Read GRE redirect statistics names. -- */ --static ssize_t nss_gre_redir_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_gre_redir_strings_stats, NSS_GRE_REDIR_STATS_MAX); --} -- --/* -- * nss_gre_redir_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(gre_redir); -- --/* -- * nss_gre_redir_strings_dentry_create() -- * Create GRE redirect statistics strings debug entry. -- */ --void nss_gre_redir_strings_dentry_create(void) --{ -- nss_strings_create_dentry("gre_redir", &nss_gre_redir_strings_ops); --} ---- a/nss_gre_redir_strings.h -+++ /dev/null -@@ -1,25 +0,0 @@ --/* -- *************************************************************************** -- * Copyright (c) 2020-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. -- *************************************************************************** -- */ -- --#ifndef __NSS_GRE_REDIR_STRINGS_H --#define __NSS_GRE_REDIR_STRINGS_H -- --#include "nss_gre_redir_stats.h" -- --extern struct nss_stats_info nss_gre_redir_strings_stats[NSS_GRE_REDIR_STATS_MAX]; --extern void nss_gre_redir_strings_dentry_create(void); -- --#endif /* __NSS_GRE_REDIR_STRINGS_H */ ---- a/nss_gre_stats.c -+++ b/nss_gre_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2019, 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. -@@ -21,38 +21,77 @@ - */ - - #include "nss_tx_rx_common.h" --#include "nss_gre.h" - #include "nss_gre_stats.h" --#include "nss_gre_strings.h" - - /* -- * Declare atomic notifier data structure for statistics. -+ * Data structures to store GRE nss debug stats - */ --ATOMIC_NOTIFIER_HEAD(nss_gre_stats_notifier); -+static DEFINE_SPINLOCK(nss_gre_stats_lock); -+static struct nss_gre_stats_session_debug session_debug_stats[NSS_GRE_MAX_DEBUG_SESSION_STATS]; -+static struct nss_gre_stats_base_debug base_debug_stats; - - /* -- * Data structures to store GRE nss debug stats -+ * nss_gre_stats_base_debug_str -+ * GRE debug statistics strings for base types - */ --static DEFINE_SPINLOCK(nss_gre_stats_lock); --static struct nss_gre_stats_session session_stats[NSS_GRE_MAX_DEBUG_SESSION_STATS]; --static struct nss_gre_stats_base base_stats; -+struct nss_stats_info nss_gre_stats_base_debug_str[NSS_GRE_STATS_BASE_DEBUG_MAX] = { -+ {"base_rx_pkts" ,NSS_STATS_TYPE_COMMON}, -+ {"base_rx_drops" ,NSS_STATS_TYPE_DROP}, -+ {"base_exp_eth_hdr_missing" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_eth_type_non_ip" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_ip_unknown_protocol" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_ip_header_incomplete" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_ip_bad_total_length" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_ip_bad_checksum" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_ip_datagram_incomplete" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_ip_fragment" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_ip_options_incomplete" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_ip_with_options" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_ipv6_unknown_protocol" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_ipv6_header_incomplete" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_unknown_session" ,NSS_STATS_TYPE_EXCEPTION}, -+ {"base_exp_node_inactive" ,NSS_STATS_TYPE_EXCEPTION} -+}; -+ -+/* -+ * nss_gre_stats_session_debug_str -+ * GRE debug statistics strings for sessions -+ */ -+struct nss_stats_info nss_gre_stats_session_debug_str[NSS_GRE_STATS_SESSION_DEBUG_MAX] = { -+ {"session_pbuf_alloc_fail" , NSS_STATS_TYPE_ERROR}, -+ {"session_decap_forward_enqueue_fail" , NSS_STATS_TYPE_DROP}, -+ {"session_encap_forward_enqueue_fail" , NSS_STATS_TYPE_DROP}, -+ {"session_decap_tx_forwarded" , NSS_STATS_TYPE_SPECIAL}, -+ {"session_encap_rx_received" , NSS_STATS_TYPE_SPECIAL}, -+ {"session_encap_rx_drops" , NSS_STATS_TYPE_DROP}, -+ {"session_encap_rx_linear_fail" , NSS_STATS_TYPE_DROP}, -+ {"session_exp_rx_key_error" , NSS_STATS_TYPE_EXCEPTION}, -+ {"session_exp_rx_seq_error" , NSS_STATS_TYPE_EXCEPTION}, -+ {"session_exp_rx_cs_error" , NSS_STATS_TYPE_EXCEPTION}, -+ {"session_exp_rx_flag_mismatch" , NSS_STATS_TYPE_EXCEPTION}, -+ {"session_exp_rx_malformed" , NSS_STATS_TYPE_EXCEPTION}, -+ {"session_exp_rx_invalid_protocol" , NSS_STATS_TYPE_EXCEPTION}, -+ {"session_exp_rx_no_headroom" , NSS_STATS_TYPE_EXCEPTION} -+}; - - /* - * GRE statistics APIs - */ - - /* -- * nss_gre_stats_session_unregister() -- * Unregister debug statistic for GRE session. -+ * nss_gre_stats_session_register() -+ * Register debug statistic for GRE session. - */ --void nss_gre_stats_session_unregister(uint32_t if_num) -+void nss_gre_stats_session_register(uint32_t if_num, struct net_device *netdev) - { - int i; - - spin_lock_bh(&nss_gre_stats_lock); - for (i = 0; i < NSS_GRE_MAX_DEBUG_SESSION_STATS; i++) { -- if (session_stats[i].if_num == if_num) { -- memset(&session_stats[i], 0, sizeof(struct nss_gre_stats_session)); -+ if (!session_debug_stats[i].valid) { -+ session_debug_stats[i].valid = true; -+ session_debug_stats[i].if_num = if_num; -+ session_debug_stats[i].if_index = netdev->ifindex; - break; - } - } -@@ -60,19 +99,17 @@ void nss_gre_stats_session_unregister(ui - } - - /* -- * nss_gre_stats_session_register() -- * Register debug statistic for GRE session. -+ * nss_gre_stats_session_unregister() -+ * Unregister debug statistic for GRE session. - */ --void nss_gre_stats_session_register(uint32_t if_num, struct net_device *netdev) -+void nss_gre_stats_session_unregister(uint32_t if_num) - { - int i; - - spin_lock_bh(&nss_gre_stats_lock); - for (i = 0; i < NSS_GRE_MAX_DEBUG_SESSION_STATS; i++) { -- if (!session_stats[i].valid) { -- session_stats[i].valid = true; -- session_stats[i].if_num = if_num; -- session_stats[i].if_index = netdev->ifindex; -+ if (session_debug_stats[i].if_num == if_num) { -+ memset(&session_debug_stats[i], 0, sizeof(struct nss_gre_stats_session_debug)); - break; - } - } -@@ -80,25 +117,25 @@ void nss_gre_stats_session_register(uint - } - - /* -- * nss_gre_stats_session_sync() -+ * nss_gre_stats_session_debug_sync() - * debug statistics sync for GRE session. - */ --void nss_gre_stats_session_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_session_stats_msg *sstats, uint16_t if_num) -+void nss_gre_stats_session_debug_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_session_stats_msg *sstats, uint16_t if_num) - { - int i, j; - enum nss_dynamic_interface_type interface_type = nss_dynamic_interface_get_type(nss_ctx, if_num); - - spin_lock_bh(&nss_gre_stats_lock); - for (i = 0; i < NSS_GRE_MAX_DEBUG_SESSION_STATS; i++) { -- if (session_stats[i].if_num == if_num) { -- for (j = 0; j < NSS_GRE_SESSION_DEBUG_MAX; j++) { -- session_stats[i].stats[j] += sstats->stats[j]; -+ if (session_debug_stats[i].if_num == if_num) { -+ for (j = 0; j < NSS_GRE_STATS_SESSION_DEBUG_MAX; j++) { -+ session_debug_stats[i].stats[j] += sstats->stats[j]; - } - - if (interface_type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_INNER) { -- session_stats[i].stats[NSS_GRE_SESSION_ENCAP_RX_RECEIVED] += sstats->node_stats.rx_packets; -+ session_debug_stats[i].stats[NSS_GRE_STATS_SESSION_ENCAP_RX_RECEIVED] += sstats->node_stats.rx_packets; - } else if (interface_type == NSS_DYNAMIC_INTERFACE_TYPE_GRE_OUTER) { -- session_stats[i].stats[NSS_GRE_SESSION_DECAP_TX_FORWARDED] += sstats->node_stats.tx_packets; -+ session_debug_stats[i].stats[NSS_GRE_STATS_SESSION_DECAP_TX_FORWARDED] += sstats->node_stats.tx_packets; - } - break; - } -@@ -107,38 +144,38 @@ void nss_gre_stats_session_sync(struct n - } - - /* -- * nss_gre_stats_base_sync() -+ * nss_gre_stats_base_debug_sync() - * Debug statistics sync for GRE base node. - */ --void nss_gre_stats_base_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_base_stats_msg *bstats) -+void nss_gre_stats_base_debug_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_base_stats_msg *bstats) - { - int i; - - spin_lock_bh(&nss_gre_stats_lock); -- for (i = 0; i < NSS_GRE_BASE_DEBUG_MAX; i++) { -- base_stats.stats[i] += bstats->stats[i]; -+ for (i = 0; i < NSS_GRE_STATS_BASE_DEBUG_MAX; i++) { -+ base_debug_stats.stats[i] += bstats->stats[i]; - } - spin_unlock_bh(&nss_gre_stats_lock); - } - - /* -- * nss_gre_stats_session_get() -+ * nss_gre_stats_session_debug_get() - * Get GRE session debug statistics. - */ --static void nss_gre_stats_session_get(void *stats_mem, int size) -+static void nss_gre_stats_session_debug_get(void *stats_mem, int size) - { -- struct nss_gre_stats_session *stats = (struct nss_gre_stats_session *)stats_mem; -+ struct nss_gre_stats_session_debug *stats = (struct nss_gre_stats_session_debug *)stats_mem; - int i; - -- if (!stats || (size < (sizeof(struct nss_gre_stats_session) * NSS_GRE_MAX_DEBUG_SESSION_STATS))) { -+ if (!stats || (size < (sizeof(struct nss_gre_stats_session_debug) * NSS_GRE_MAX_DEBUG_SESSION_STATS))) { - nss_warning("No memory to copy gre stats"); - return; - } - - spin_lock_bh(&nss_gre_stats_lock); - for (i = 0; i < NSS_GRE_MAX_DEBUG_SESSION_STATS; i++) { -- if (session_stats[i].valid) { -- memcpy(stats, &session_stats[i], sizeof(struct nss_gre_stats_session)); -+ if (session_debug_stats[i].valid) { -+ memcpy(stats, &session_debug_stats[i], sizeof(struct nss_gre_stats_session_debug)); - stats++; - } - } -@@ -146,25 +183,25 @@ static void nss_gre_stats_session_get(vo - } - - /* -- * nss_gre_stats_base_get() -+ * nss_gre_stats_base_debug_get() - * Get GRE debug base statistics. - */ --static void nss_gre_stats_base_get(void *stats_mem, int size) -+static void nss_gre_stats_base_debug_get(void *stats_mem, int size) - { -- struct nss_gre_stats_base *stats = (struct nss_gre_stats_base *)stats_mem; -+ struct nss_gre_stats_base_debug *stats = (struct nss_gre_stats_base_debug *)stats_mem; - - if (!stats) { - nss_warning("No memory to copy GRE base stats\n"); - return; - } - -- if (size < sizeof(struct nss_gre_stats_base)) { -+ if (size < sizeof(struct nss_gre_stats_base_debug)) { - nss_warning("Not enough memory to copy GRE base stats\n"); - return; - } - - spin_lock_bh(&nss_gre_stats_lock); -- memcpy(stats, &base_stats, sizeof(struct nss_gre_stats_base)); -+ memcpy(stats, &base_debug_stats, sizeof(struct nss_gre_stats_base_debug)); - spin_unlock_bh(&nss_gre_stats_lock); - } - -@@ -176,15 +213,15 @@ static ssize_t nss_gre_stats_read(struct - { - uint32_t max_output_lines = 2 /* header & footer for base debug stats */ - + 2 /* header & footer for session debug stats */ -- + NSS_GRE_BASE_DEBUG_MAX /* Base debug */ -- + NSS_GRE_MAX_DEBUG_SESSION_STATS * (NSS_GRE_SESSION_DEBUG_MAX + 2) /*session stats */ -+ + NSS_GRE_STATS_BASE_DEBUG_MAX /* Base debug */ -+ + NSS_GRE_MAX_DEBUG_SESSION_STATS * (NSS_GRE_STATS_SESSION_DEBUG_MAX + 2) /*session stats */ - + 2; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - size_t size_wr = 0; - ssize_t bytes_read = 0; - struct net_device *dev; -- struct nss_gre_stats_session *sstats; -- struct nss_gre_stats_base *bstats; -+ struct nss_gre_stats_session_debug *sstats; -+ struct nss_gre_stats_base_debug *bstats; - int id; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); -@@ -193,14 +230,14 @@ static ssize_t nss_gre_stats_read(struct - return 0; - } - -- bstats = kzalloc(sizeof(struct nss_gre_stats_base), GFP_KERNEL); -+ bstats = kzalloc(sizeof(struct nss_gre_stats_base_debug), GFP_KERNEL); - if (unlikely(!bstats)) { - nss_warning("Could not allocate memory for base debug statistics buffer"); - kfree(lbuf); - return 0; - } - -- sstats = kzalloc(sizeof(struct nss_gre_stats_session) * NSS_GRE_MAX_DEBUG_SESSION_STATS, GFP_KERNEL); -+ sstats = kzalloc(sizeof(struct nss_gre_stats_session_debug) * NSS_GRE_MAX_DEBUG_SESSION_STATS, GFP_KERNEL); - if (unlikely(!sstats)) { - nss_warning("Could not allocate memory for base debug statistics buffer"); - kfree(lbuf); -@@ -213,18 +250,18 @@ static ssize_t nss_gre_stats_read(struct - /* - * Get all base stats - */ -- nss_gre_stats_base_get((void *)bstats, sizeof(struct nss_gre_stats_base)); -+ nss_gre_stats_base_debug_get((void *)bstats, sizeof(struct nss_gre_stats_base_debug)); - - size_wr += nss_stats_print("gre", NULL, NSS_STATS_SINGLE_INSTANCE -- , nss_gre_strings_base_stats -+ , nss_gre_stats_base_debug_str - , bstats->stats -- , NSS_GRE_BASE_DEBUG_MAX -+ , NSS_GRE_STATS_BASE_DEBUG_MAX - , lbuf, size_wr, size_al); - - /* - * Get all session stats - */ -- nss_gre_stats_session_get(sstats, sizeof(struct nss_gre_stats_session) * NSS_GRE_MAX_DEBUG_SESSION_STATS); -+ nss_gre_stats_session_debug_get(sstats, sizeof(struct nss_gre_stats_session_debug) * NSS_GRE_MAX_DEBUG_SESSION_STATS); - - for (id = 0; id < NSS_GRE_MAX_DEBUG_SESSION_STATS; id++) { - -@@ -243,9 +280,9 @@ static ssize_t nss_gre_stats_read(struct - (sstats + id)->if_num); - } - size_wr += nss_stats_print("gre_session", NULL, id -- , nss_gre_strings_session_stats -+ , nss_gre_stats_session_debug_str - , (sstats + id)->stats -- , NSS_GRE_SESSION_DEBUG_MAX -+ , NSS_GRE_STATS_SESSION_DEBUG_MAX - , lbuf, size_wr, size_al); - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - } -@@ -272,67 +309,3 @@ void nss_gre_stats_dentry_create(void) - nss_stats_create_dentry("gre", &nss_gre_stats_ops); - } - --/* -- * nss_gre_stats_base_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_gre_stats_base_notify(struct nss_ctx_instance *nss_ctx) --{ -- struct nss_gre_base_stats_notification gre_stats; -- -- spin_lock_bh(&nss_gre_stats_lock); -- gre_stats.core_id = nss_ctx->id; -- memcpy(gre_stats.stats_base_ctx, base_stats.stats, sizeof(gre_stats.stats_base_ctx)); -- spin_unlock_bh(&nss_gre_stats_lock); -- -- atomic_notifier_call_chain(&nss_gre_stats_notifier, NSS_STATS_EVENT_NOTIFY, &gre_stats); --} -- --/* -- * nss_gre_stats_session_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_gre_stats_session_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_gre_session_stats_notification gre_stats; -- int i; -- -- spin_lock_bh(&nss_gre_stats_lock); -- for (i = 0; i < NSS_GRE_MAX_DEBUG_SESSION_STATS; i++) { -- if (session_stats[i].if_num != if_num) { -- continue; -- } -- -- memcpy(gre_stats.stats_session_ctx, session_stats[i].stats, sizeof(gre_stats.stats_session_ctx)); -- gre_stats.core_id = nss_ctx->id; -- gre_stats.if_num = if_num; -- spin_unlock_bh(&nss_gre_stats_lock); -- atomic_notifier_call_chain(&nss_gre_stats_notifier, NSS_STATS_EVENT_NOTIFY, &gre_stats); -- return; -- } -- spin_unlock_bh(&nss_gre_stats_lock); --} -- --/* -- * nss_gre_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_gre_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_gre_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_stats_unregister_notifier); -- --/* -- * nss_gre_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_gre_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_gre_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_stats_register_notifier); ---- a/nss_gre_stats.h -+++ b/nss_gre_stats.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017, 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. -@@ -22,32 +22,72 @@ - #ifndef __NSS_GRE_STATS_H - #define __NSS_GRE_STATS_H - --#include -+/* -+ * GRE base debug statistics types -+ */ -+enum nss_gre_stats_base_debug_types { -+ NSS_GRE_STATS_BASE_RX_PACKETS, /**< Rx packet count. */ -+ NSS_GRE_STATS_BASE_RX_DROPPED, /**< Rx dropped count. */ -+ NSS_GRE_STATS_BASE_EXP_ETH_HDR_MISSING, /**< Ethernet header missing. */ -+ NSS_GRE_STATS_BASE_EXP_ETH_TYPE_NON_IP, /**< Not IPV4 or IPV6 packet. */ -+ NSS_GRE_STATS_BASE_EXP_IP_UNKNOWN_PROTOCOL, /**< Unknown protocol. */ -+ NSS_GRE_STATS_BASE_EXP_IP_HEADER_INCOMPLETE, /**< Bad IP header. */ -+ NSS_GRE_STATS_BASE_EXP_IP_BAD_TOTAL_LENGTH, /**< Invalid IP packet length. */ -+ NSS_GRE_STATS_BASE_EXP_IP_BAD_CHECKSUM, /**< Bad packet checksum. */ -+ NSS_GRE_STATS_BASE_EXP_IP_DATAGRAM_INCOMPLETE, /**< Bad packet. */ -+ NSS_GRE_STATS_BASE_EXP_IP_FRAGMENT, /**< IP fragment. */ -+ NSS_GRE_STATS_BASE_EXP_IP_OPTIONS_INCOMPLETE, /**< Invalid IP options. */ -+ NSS_GRE_STATS_BASE_EXP_IP_WITH_OPTIONS, /**< IP packet with options. */ -+ NSS_GRE_STATS_BASE_EXP_IPV6_UNKNOWN_PROTOCOL, /**< Unknown protocol. */ -+ NSS_GRE_STATS_BASE_EXP_IPV6_HEADER_INCOMPLETE, /**< Incomplete IPV6 header. */ -+ NSS_GRE_STATS_BASE_EXP_GRE_UNKNOWN_SESSION, /**< Unknown GRE session. */ -+ NSS_GRE_STATS_BASE_EXP_GRE_NODE_INACTIVE, /**< GRE node inactive. */ -+ NSS_GRE_STATS_BASE_DEBUG_MAX, /**< GRE base error max. */ -+}; - - /* - * GRE base debug statistics - */ --struct nss_gre_stats_base { -- uint64_t stats[NSS_GRE_BASE_DEBUG_MAX]; /**< GRE debug statistics. */ -+struct nss_gre_stats_base_debug { -+ uint64_t stats[NSS_GRE_STATS_BASE_DEBUG_MAX]; /**< GRE debug statistics. */ -+}; -+ -+/* -+ * GRE session debug statistics types -+ */ -+enum nss_gre_stats_session_debug_types { -+ NSS_GRE_STATS_SESSION_PBUF_ALLOC_FAIL, /**< Pbuf alloc failure. */ -+ NSS_GRE_STATS_SESSION_DECAP_FORWARD_ENQUEUE_FAIL, /**< Rx forward enqueue failure. */ -+ NSS_GRE_STATS_SESSION_ENCAP_FORWARD_ENQUEUE_FAIL, /**< Tx forward enqueue failure. */ -+ NSS_GRE_STATS_SESSION_DECAP_TX_FORWARDED, /**< Packets forwarded after decap. */ -+ NSS_GRE_STATS_SESSION_ENCAP_RX_RECEIVED, /**< Packets received for encap. */ -+ NSS_GRE_STATS_SESSION_ENCAP_RX_DROPPED, /**< Packets dropped while enqueue for encap. */ -+ NSS_GRE_STATS_SESSION_ENCAP_RX_LINEAR_FAIL, /**< Packets dropped during encap linearization. */ -+ NSS_GRE_STATS_SESSION_EXP_RX_KEY_ERROR, /**< Rx KEY error. */ -+ NSS_GRE_STATS_SESSION_EXP_RX_SEQ_ERROR, /**< Rx sequence number error. */ -+ NSS_GRE_STATS_SESSION_EXP_RX_CS_ERROR, /**< Rx checksum error. */ -+ NSS_GRE_STATS_SESSION_EXP_RX_FLAG_MISMATCH, /**< Rx flag mismatch. */ -+ NSS_GRE_STATS_SESSION_EXP_RX_MALFORMED, /**< Rx malformed packet. */ -+ NSS_GRE_STATS_SESSION_EXP_RX_INVALID_PROTOCOL, /**< Rx invalid protocol. */ -+ NSS_GRE_STATS_SESSION_EXP_RX_NO_HEADROOM, /**< Rx no headroom. */ -+ NSS_GRE_STATS_SESSION_DEBUG_MAX, /**< Session debug max. */ - }; - - /* - * GRE session debug statistics - */ --struct nss_gre_stats_session { -- uint64_t stats[NSS_GRE_SESSION_DEBUG_MAX]; /**< Session debug statistics. */ -- int32_t if_index; /**< Netdevice's ifindex. */ -- uint32_t if_num; /**< NSS interface number. */ -- bool valid; /**< Is node valid ? */ -+struct nss_gre_stats_session_debug { -+ uint64_t stats[NSS_GRE_STATS_SESSION_DEBUG_MAX]; /**< Session debug statistics. */ -+ int32_t if_index; /**< Netdevice's ifindex. */ -+ uint32_t if_num; /**< NSS interface number. */ -+ bool valid; /**< Is node valid ? */ - }; - - /* - * GRE statistics APIs - */ --extern void nss_gre_stats_base_notify(struct nss_ctx_instance *nss_ctx); --extern void nss_gre_stats_session_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); --extern void nss_gre_stats_session_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_session_stats_msg *sstats, uint16_t if_num); --extern void nss_gre_stats_base_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_base_stats_msg *bstats); -+extern void nss_gre_stats_session_debug_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_session_stats_msg *sstats, uint16_t if_num); -+extern void nss_gre_stats_base_debug_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_base_stats_msg *bstats); - extern void nss_gre_stats_session_register(uint32_t if_num, struct net_device *netdev); - extern void nss_gre_stats_session_unregister(uint32_t if_num); - extern void nss_gre_stats_dentry_create(void); ---- a/nss_gre_strings.c -+++ /dev/null -@@ -1,124 +0,0 @@ --/* -- *************************************************************************** -- * Copyright (c) 2020-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_strings.h" --#include "nss_gre_strings.h" -- --/* -- * nss_gre_strings_base_stats -- * GRE debug statistics strings for base types -- */ --struct nss_stats_info nss_gre_strings_base_stats[NSS_GRE_BASE_DEBUG_MAX] = { -- {"base_rx_pkts", NSS_STATS_TYPE_COMMON}, -- {"base_rx_drops", NSS_STATS_TYPE_DROP}, -- {"base_exp_eth_hdr_missing", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_eth_type_non_ip", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_ip_unknown_protocol", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_ip_header_incomplete", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_ip_bad_total_length", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_ip_bad_checksum", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_ip_datagram_incomplete", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_ip_fragment", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_ip_options_incomplete", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_ip_with_options", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_ipv6_unknown_protocol", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_ipv6_header_incomplete", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_unknown_session", NSS_STATS_TYPE_EXCEPTION}, -- {"base_exp_node_inactive", NSS_STATS_TYPE_EXCEPTION} --}; -- --/* -- * nss_gre_base_strings_read() -- * Read GRE base debug statistics names -- */ --static ssize_t nss_gre_base_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_gre_strings_base_stats, NSS_GRE_BASE_DEBUG_MAX); --} -- --/* -- * nss_gre_base_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(gre_base); -- --/* -- * nss_gre_strings_session_stats -- * GRE debug statistics strings for sessions -- */ --struct nss_stats_info nss_gre_strings_session_stats[NSS_GRE_SESSION_DEBUG_MAX] = { -- {"session_pbuf_alloc_fail", NSS_STATS_TYPE_ERROR}, -- {"session_decap_forward_enqueue_fail", NSS_STATS_TYPE_DROP}, -- {"session_encap_forward_enqueue_fail", NSS_STATS_TYPE_DROP}, -- {"session_decap_tx_forwarded", NSS_STATS_TYPE_SPECIAL}, -- {"session_encap_rx_received", NSS_STATS_TYPE_SPECIAL}, -- {"session_encap_rx_drops", NSS_STATS_TYPE_DROP}, -- {"session_encap_rx_linear_fail", NSS_STATS_TYPE_DROP}, -- {"session_exp_rx_key_error", NSS_STATS_TYPE_EXCEPTION}, -- {"session_exp_rx_seq_error", NSS_STATS_TYPE_EXCEPTION}, -- {"session_exp_rx_cs_error", NSS_STATS_TYPE_EXCEPTION}, -- {"session_exp_rx_flag_mismatch", NSS_STATS_TYPE_EXCEPTION}, -- {"session_exp_rx_malformed", NSS_STATS_TYPE_EXCEPTION}, -- {"session_exp_rx_invalid_protocol", NSS_STATS_TYPE_EXCEPTION}, -- {"session_exp_rx_no_headroom", NSS_STATS_TYPE_EXCEPTION} --}; -- --/* -- * nss_gre_session_strings_read() -- * Read GRE session debug statistics names -- */ --static ssize_t nss_gre_session_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_gre_strings_session_stats, NSS_GRE_SESSION_DEBUG_MAX); --} -- --/* -- * nss_gre_session_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(gre_session); -- --/* -- * nss_gre_strings_dentry_create() -- * Create gre statistics strings debug entry. -- */ --void nss_gre_strings_dentry_create(void) --{ -- struct dentry *gre_d = NULL; -- -- if (!nss_top_main.strings_dentry) { -- nss_warning("qca-nss-drv/strings is not present"); -- return; -- } -- -- gre_d = debugfs_create_dir("gre", nss_top_main.strings_dentry); -- if (!gre_d) { -- nss_warning("Failed to create qca-nss-drv/strings/gre directory"); -- return; -- } -- -- if (!debugfs_create_file("gre_base", 0400, gre_d, &nss_top_main, &nss_gre_base_strings_ops)) { -- nss_warning("Failed to create qca-nss-drv/strings/gre/gre_base file"); -- debugfs_remove_recursive(gre_d); -- return; -- } -- -- if (!debugfs_create_file("gre_session", 0400, gre_d, &nss_top_main, &nss_gre_session_strings_ops)) { -- nss_warning("Failed to create qca-nss-drv/strings/gre/gre_session file"); -- debugfs_remove_recursive(gre_d); -- return; -- } --} ---- a/nss_gre_strings.h -+++ /dev/null -@@ -1,26 +0,0 @@ --/* -- **************************************************************************** -- * Copyright (c) 2020-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. -- **************************************************************************** -- */ -- --#ifndef __NSS_GRE_STRINGS_H --#define __NSS_GRE_STRINGS_H -- --#include "nss_gre_stats.h" -- --extern struct nss_stats_info nss_gre_strings_base_stats[NSS_GRE_BASE_DEBUG_MAX]; --extern struct nss_stats_info nss_gre_strings_session_stats[NSS_GRE_SESSION_DEBUG_MAX]; --extern void nss_gre_strings_dentry_create(void); -- --#endif /* __NSS_GRE_STRINGS_H */ ---- a/nss_gre_tunnel.c -+++ b/nss_gre_tunnel.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2020, 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. -@@ -17,7 +17,6 @@ - #include "nss_tx_rx_common.h" - #include "nss_gre_tunnel_stats.h" - #include "nss_gre_tunnel_log.h" --#include "nss_gre_tunnel_strings.h" - - #define NSS_GRE_TUNNEL_TX_TIMEOUT 3000 /* 3 Seconds */ - -@@ -90,7 +89,6 @@ static void nss_gre_tunnel_handler(struc - switch (ngtm->cm.type) { - case NSS_GRE_TUNNEL_MSG_STATS: - nss_gre_tunnel_stats_session_sync(nss_ctx, &ngtm->msg.stats, ncm->interface); -- nss_gre_tunnel_stats_notify(nss_ctx, ncm->interface); - break; - } - -@@ -320,16 +318,16 @@ struct nss_ctx_instance *nss_gre_tunnel_ - - BUG_ON(!nss_gre_tunnel_verify_if_num(if_num)); - -- spin_lock_bh(&nss_gre_tunnel_stats_lock); -+ spin_lock_bh(&nss_gre_tunnel_stats_session_debug_lock); - for (i = 0; i < NSS_MAX_GRE_TUNNEL_SESSIONS; i++) { -- if (!session_stats[i].valid) { -- session_stats[i].valid = true; -- session_stats[i].if_num = if_num; -- session_stats[i].if_index = netdev->ifindex; -+ if (!nss_gre_tunnel_session_debug_stats[i].valid) { -+ nss_gre_tunnel_session_debug_stats[i].valid = true; -+ nss_gre_tunnel_session_debug_stats[i].if_num = if_num; -+ nss_gre_tunnel_session_debug_stats[i].if_index = netdev->ifindex; - break; - } - } -- spin_unlock_bh(&nss_gre_tunnel_stats_lock); -+ spin_unlock_bh(&nss_gre_tunnel_stats_session_debug_lock); - - if (i == NSS_MAX_GRE_TUNNEL_SESSIONS) { - nss_warning("%px: Cannot find free slot for GRE Tunnel session stats, I/F:%u\n", nss_ctx, if_num); -@@ -338,9 +336,9 @@ struct nss_ctx_instance *nss_gre_tunnel_ - - if (nss_ctx->subsys_dp_register[if_num].ndev) { - nss_warning("%px: Cannot find free slot for GRE Tunnel NSS I/F:%u\n", nss_ctx, if_num); -- session_stats[i].valid = false; -- session_stats[i].if_num = 0; -- session_stats[i].if_index = 0; -+ nss_gre_tunnel_session_debug_stats[i].valid = false; -+ nss_gre_tunnel_session_debug_stats[i].if_num = 0; -+ nss_gre_tunnel_session_debug_stats[i].if_index = 0; - return NULL; - } - -@@ -349,7 +347,6 @@ struct nss_ctx_instance *nss_gre_tunnel_ - nss_top_main.gre_tunnel_msg_callback = ev_cb; - nss_core_register_handler(nss_ctx, if_num, nss_gre_tunnel_handler, app_ctx); - nss_gre_tunnel_stats_dentry_create(); -- nss_gre_tunnel_strings_dentry_create(); - - return nss_ctx; - } -@@ -366,15 +363,15 @@ void nss_gre_tunnel_unregister_if(uint32 - - BUG_ON(!nss_gre_tunnel_verify_if_num(if_num)); - -- spin_lock_bh(&nss_gre_tunnel_stats_lock); -+ spin_lock_bh(&nss_gre_tunnel_stats_session_debug_lock); - for (i = 0; i < NSS_MAX_GRE_TUNNEL_SESSIONS; i++) { -- if (session_stats[i].if_num == if_num) { -- memset(&session_stats[i], 0, -- sizeof(struct nss_gre_tunnel_stats_session)); -+ if (nss_gre_tunnel_session_debug_stats[i].if_num == if_num) { -+ memset(&nss_gre_tunnel_session_debug_stats[i], 0, -+ sizeof(struct nss_gre_tunnel_stats_session_debug)); - break; - } - } -- spin_unlock_bh(&nss_gre_tunnel_stats_lock); -+ spin_unlock_bh(&nss_gre_tunnel_stats_session_debug_lock); - - if (i == NSS_MAX_GRE_TUNNEL_SESSIONS) { - nss_warning("%px: Cannot find debug stats for GRE Tunnel session: %d\n", nss_ctx, if_num); ---- a/nss_gre_tunnel_stats.c -+++ b/nss_gre_tunnel_stats.c -@@ -1,6 +1,6 @@ - /* -- **************************************************************************** -- * Copyright (c) 2017, 2020-2021, The Linux Foundation. All rights reserved. -+ ************************************************************************** -+ * Copyright (c) 2017, 2020, 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. -@@ -11,25 +11,48 @@ - * 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_tx_rx_common.h" --#include "nss_gre_tunnel.h" - #include "nss_gre_tunnel_stats.h" --#include "nss_gre_tunnel_strings.h" - --/* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_gre_tunnel_stats_notifier); -+DEFINE_SPINLOCK(nss_gre_tunnel_stats_session_debug_lock); -+struct nss_gre_tunnel_stats_session_debug nss_gre_tunnel_session_debug_stats[NSS_MAX_GRE_TUNNEL_SESSIONS]; - - /* -- * Spinlock to protect gre tunnel statistics update/read -+ * nss_gre_tunnel_stats_session_debug_str -+ * GRE Tunnel statistics strings for nss session stats - */ --DEFINE_SPINLOCK(nss_gre_tunnel_stats_lock); -- --struct nss_gre_tunnel_stats_session session_stats[NSS_MAX_GRE_TUNNEL_SESSIONS]; -+static int8_t *nss_gre_tunnel_stats_session_debug_str[NSS_GRE_TUNNEL_STATS_SESSION_MAX] = { -+ "RX_PKTS", -+ "TX_PKTS", -+ "RX_QUEUE_0_DROPPED", -+ "RX_QUEUE_1_DROPPED", -+ "RX_QUEUE_2_DROPPED", -+ "RX_QUEUE_3_DROPPED", -+ "RX_MALFORMED", -+ "RX_INVALID_PROT", -+ "DECAP_QUEUE_FULL", -+ "RX_SINGLE_REC_DGRAM", -+ "RX_INVALID_REC_DGRAM", -+ "BUFFER_ALLOC_FAIL", -+ "BUFFER_COPY_FAIL", -+ "OUTFLOW_QUEUE_FULL", -+ "TX_DROPPED_HROOM", -+ "RX_CBUFFER_ALLOC_FAIL", -+ "RX_CENQUEUE_FAIL", -+ "RX_DECRYPT_DONE", -+ "RX_FORWARD_ENQUEUE_FAIL", -+ "TX_CBUFFER_ALLOC_FAIL", -+ "TX_CENQUEUE_FAIL", -+ "TX_DROPPED_TROOM", -+ "TX_FORWARD_ENQUEUE_FAIL", -+ "TX_CIPHER_DONE", -+ "CRYPTO_NOSUPP", -+ "RX_DROPPED_MH_VERSION", -+ "RX_UNALIGNED_PKT", -+}; - - /* - * nss_gre_tunnel_stats_session_sync() -@@ -39,20 +62,20 @@ void nss_gre_tunnel_stats_session_sync(s - uint16_t if_num) - { - int i; -- struct nss_gre_tunnel_stats_session *s = NULL; -+ struct nss_gre_tunnel_stats_session_debug *s = NULL; - - NSS_VERIFY_CTX_MAGIC(nss_ctx); - -- spin_lock_bh(&nss_gre_tunnel_stats_lock); -+ spin_lock_bh(&nss_gre_tunnel_stats_session_debug_lock); - for (i = 0; i < NSS_MAX_GRE_TUNNEL_SESSIONS; i++) { -- if (session_stats[i].if_num == if_num) { -- s = &session_stats[i]; -+ if (nss_gre_tunnel_session_debug_stats[i].if_num == if_num) { -+ s = &nss_gre_tunnel_session_debug_stats[i]; - break; - } - } - - if (!s) { -- spin_unlock_bh(&nss_gre_tunnel_stats_lock); -+ spin_unlock_bh(&nss_gre_tunnel_stats_session_debug_lock); - nss_warning("%px: Session not found: %u", nss_ctx, if_num); - return; - } -@@ -95,14 +118,14 @@ void nss_gre_tunnel_stats_session_sync(s - #endif - } - -- spin_unlock_bh(&nss_gre_tunnel_stats_lock); -+ spin_unlock_bh(&nss_gre_tunnel_stats_session_debug_lock); - } - - /* -- * nss_gre_tunnel_stats_session_get() -+ * nss_gre_tunnel_stats_session_debug_get() - * Get session GRE Tunnel statitics. - */ --static void nss_gre_tunnel_stats_session_get(struct nss_gre_tunnel_stats_session *stats) -+static void nss_gre_tunnel_stats_session_debug_get(struct nss_gre_tunnel_stats_session_debug *stats) - { - int i; - -@@ -111,15 +134,15 @@ static void nss_gre_tunnel_stats_session - return; - } - -- spin_lock_bh(&nss_gre_tunnel_stats_lock); -+ spin_lock_bh(&nss_gre_tunnel_stats_session_debug_lock); - for (i = 0; i < NSS_MAX_GRE_TUNNEL_SESSIONS; i++) { -- if (session_stats[i].valid) { -- memcpy(stats, &session_stats[i], -- sizeof(struct nss_gre_tunnel_stats_session)); -+ if (nss_gre_tunnel_session_debug_stats[i].valid) { -+ memcpy(stats, &nss_gre_tunnel_session_debug_stats[i], -+ sizeof(struct nss_gre_tunnel_stats_session_debug)); - stats++; - } - } -- spin_unlock_bh(&nss_gre_tunnel_stats_lock); -+ spin_unlock_bh(&nss_gre_tunnel_stats_session_debug_lock); - } - - /* -@@ -134,10 +157,9 @@ static ssize_t nss_gre_tunnel_stats_read - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - size_t size_wr = 0; - ssize_t bytes_read = 0; -- uint64_t *stats_shadow; - struct net_device *dev; - int id, i; -- struct nss_gre_tunnel_stats_session *gre_tunnel_session_stats = NULL; -+ struct nss_gre_tunnel_stats_session_debug *gre_tunnel_session_stats = NULL; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); - if (unlikely(lbuf == NULL)) { -@@ -145,31 +167,24 @@ static ssize_t nss_gre_tunnel_stats_read - return 0; - } - -- stats_shadow = kzalloc(NSS_CRYPTO_CMN_RESP_ERROR_MAX * 8, GFP_KERNEL); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- -- gre_tunnel_session_stats = kzalloc((sizeof(struct nss_gre_tunnel_stats_session) -+ gre_tunnel_session_stats = kzalloc((sizeof(struct nss_gre_tunnel_stats_session_debug) - * NSS_MAX_GRE_TUNNEL_SESSIONS), GFP_KERNEL); - if (unlikely(gre_tunnel_session_stats == NULL)) { - nss_warning("Could not allocate memory for populating GRE Tunnel stats"); - kfree(lbuf); -- kfree(stats_shadow); - return 0; - } - - /* - * Get all stats - */ -- nss_gre_tunnel_stats_session_get(gre_tunnel_session_stats); -+ nss_gre_tunnel_stats_session_debug_get(gre_tunnel_session_stats); - - /* - * Session stats - */ -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "GRE tunnel stats", NSS_STATS_SINGLE_CORE); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\nGRE Tunnel session stats start:\n\n"); - - for (id = 0; id < NSS_MAX_GRE_TUNNEL_SESSIONS; id++) { - if (!gre_tunnel_session_stats[id].valid) -@@ -188,33 +203,34 @@ static ssize_t nss_gre_tunnel_stats_read - gre_tunnel_session_stats[id].if_num); - } - -- size_wr += nss_stats_print("gre_tunnel", NULL, NSS_STATS_SINGLE_INSTANCE, -- nss_gre_tunnel_strings_stats, gre_tunnel_session_stats[id].stats, -- NSS_GRE_TUNNEL_STATS_SESSION_MAX, lbuf, size_wr, size_al); -+ for (i = 0; i < NSS_GRE_TUNNEL_STATS_SESSION_MAX; i++) { -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\t%s = %llu\n", -+ nss_gre_tunnel_stats_session_debug_str[i], -+ gre_tunnel_session_stats[id].stats[i]); -+ } - - /* - * Print crypto resp err stats. - * TODO: We are not printing with the right enum string for crypto. This - * is intentional since we atleast want to see some stats for now. - */ -- spin_lock_bh(&nss_gre_tunnel_stats_lock); - for (i = 0; i < NSS_CRYPTO_CMN_RESP_ERROR_MAX; i++) { -- stats_shadow[i] = gre_tunnel_session_stats[id].stats[NSS_GRE_TUNNEL_STATS_SESSION_MAX + i]; -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\t%s = %llu\n", -+ nss_gre_tunnel_stats_session_debug_str[i], -+ gre_tunnel_session_stats[id].stats[NSS_GRE_TUNNEL_STATS_SESSION_MAX + i]); - } - -- spin_unlock_bh(&nss_gre_tunnel_stats_lock); -- size_wr += nss_stats_print("gre_tunnel", NULL, NSS_STATS_SINGLE_INSTANCE, -- nss_gre_tunnel_strings_stats, stats_shadow, -- NSS_CRYPTO_CMN_RESP_ERROR_MAX, lbuf, size_wr, size_al); -- - size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - } - -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\nGRE Tunnel session stats end\n"); - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(gre_tunnel_session_stats); - kfree(lbuf); -- kfree(stats_shadow); - return bytes_read; - } - -@@ -231,52 +247,3 @@ void nss_gre_tunnel_stats_dentry_create( - { - nss_stats_create_dentry("gre_tunnel", &nss_gre_tunnel_stats_ops); - } -- --/* -- * nss_gre_tunnel_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_gre_tunnel_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_gre_tunnel_stats_notification gre_tunnel_stats; -- struct nss_gre_tunnel_stats_session *s = NULL; -- int i; -- -- spin_lock_bh(&nss_gre_tunnel_stats_lock); -- for (i = 0; i < NSS_MAX_GRE_TUNNEL_SESSIONS; i++) { -- if (session_stats[i].if_num != if_num) { -- continue; -- } -- -- s = &session_stats[i]; -- gre_tunnel_stats.core_id = nss_ctx->id; -- gre_tunnel_stats.if_num = if_num; -- memcpy(gre_tunnel_stats.stats_ctx, s->stats, sizeof(gre_tunnel_stats.stats_ctx)); -- spin_unlock_bh(&nss_gre_tunnel_stats_lock); -- atomic_notifier_call_chain(&nss_gre_tunnel_stats_notifier, NSS_STATS_EVENT_NOTIFY, &gre_tunnel_stats); -- return; -- } -- spin_unlock_bh(&nss_gre_tunnel_stats_lock); --} -- --/* -- * nss_gre_tunnel_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_gre_tunnel_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_gre_tunnel_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_tunnel_stats_unregister_notifier); -- --/* -- * nss_gre_tunnel_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_gre_tunnel_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_gre_tunnel_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_gre_tunnel_stats_register_notifier); ---- a/nss_gre_tunnel_stats.h -+++ b/nss_gre_tunnel_stats.h -@@ -1,6 +1,6 @@ - /* - ****************************************************************************** -- * Copyright (c) 2016-2017, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2017, 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. -@@ -18,26 +18,58 @@ - #define __NSS_GRE_TUNNEL_STATS_H - - /* -+ * GRE Tunnel session debug statistic counters -+ */ -+enum nss_gre_tunnel_stats_session { -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_PKTS, -+ NSS_GRE_TUNNEL_STATS_SESSION_TX_PKTS, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_QUEUE_0_DROPPED, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_QUEUE_1_DROPPED, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_QUEUE_2_DROPPED, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_QUEUE_3_DROPPED, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_MALFORMED, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_INVALID_PROT, -+ NSS_GRE_TUNNEL_STATS_SESSION_DECAP_QUEUE_FULL, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_SINGLE_REC_DGRAM, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_INVALID_REC_DGRAM, -+ NSS_GRE_TUNNEL_STATS_SESSION_BUFFER_ALLOC_FAIL, -+ NSS_GRE_TUNNEL_STATS_SESSION_BUFFER_COPY_FAIL, -+ NSS_GRE_TUNNEL_STATS_SESSION_OUTFLOW_QUEUE_FULL, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_DROPPED_HROOM, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_CBUFFER_ALLOC_FAIL, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_CENQUEUE_FAIL, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_DECRYPT_DONE, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_FORWARD_ENQUEUE_FAIL, -+ NSS_GRE_TUNNEL_STATS_SESSION_TX_CBUFFER_ALLOC_FAIL, -+ NSS_GRE_TUNNEL_STATS_SESSION_TX_CENQUEUE_FAIL, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_DROPPED_TROOM, -+ NSS_GRE_TUNNEL_STATS_SESSION_TX_FORWARD_ENQUEUE_FAIL, -+ NSS_GRE_TUNNEL_STATS_SESSION_TX_CIPHER_DONE, -+ NSS_GRE_TUNNEL_STATS_SESSION_CRYPTO_NOSUPP, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_DROPPED_MH_VERSION, -+ NSS_GRE_TUNNEL_STATS_SESSION_RX_UNALIGNED_PKT, -+ NSS_GRE_TUNNEL_STATS_SESSION_MAX, -+}; -+ -+/* - * GRE Tunnel session debug statistics - */ --struct nss_gre_tunnel_stats_session { -+struct nss_gre_tunnel_stats_session_debug { - uint64_t stats[NSS_GRE_TUNNEL_STATS_SESSION_MAX + NSS_CRYPTO_CMN_RESP_ERROR_MAX]; -- /* GRE tunnel statistics */ -- int32_t if_index; /* Interface index */ -- uint32_t if_num; /* NSS interface number */ -+ int32_t if_index; -+ uint32_t if_num; /* nss interface number */ - bool valid; - }; - - /* - * Data structures to store GRE Tunnel nss debug stats - */ --extern spinlock_t nss_gre_tunnel_stats_lock; --extern struct nss_gre_tunnel_stats_session session_stats[NSS_MAX_GRE_TUNNEL_SESSIONS]; -+extern spinlock_t nss_gre_tunnel_stats_session_debug_lock; -+extern struct nss_gre_tunnel_stats_session_debug nss_gre_tunnel_session_debug_stats[NSS_MAX_GRE_TUNNEL_SESSIONS]; - - /* - * GRE Tunnel statistics APIs - */ --extern void nss_gre_tunnel_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); - extern void nss_gre_tunnel_stats_session_sync(struct nss_ctx_instance *nss_ctx, struct nss_gre_tunnel_stats *stats_msg, uint16_t if_num); - extern void nss_gre_tunnel_stats_dentry_create(void); - ---- a/nss_gre_tunnel_strings.c -+++ /dev/null -@@ -1,77 +0,0 @@ --/* -- **************************************************************************** -- * Copyright (c) 2020-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_strings.h" --#include "nss_gre_tunnel_strings.h" -- --/* -- * nss_gre_tunnel_strings_stats -- * GRE Tunnel statistics strings for nss session stats -- */ --struct nss_stats_info nss_gre_tunnel_strings_stats[NSS_GRE_TUNNEL_STATS_SESSION_MAX] = { -- {"rx_pkts", NSS_STATS_TYPE_COMMON}, -- {"tx_pkts", NSS_STATS_TYPE_COMMON}, -- {"rx_queue_0_dropped", NSS_STATS_TYPE_DROP}, -- {"rx_queue_1_dropped", NSS_STATS_TYPE_DROP}, -- {"rx_queue_2_dropped", NSS_STATS_TYPE_DROP}, -- {"rx_queue_3_dropped", NSS_STATS_TYPE_DROP}, -- {"rx_malformed", NSS_STATS_TYPE_SPECIAL}, -- {"rx_invalid_prot", NSS_STATS_TYPE_SPECIAL}, -- {"decap_queue_full", NSS_STATS_TYPE_SPECIAL}, -- {"rx_single_rec_dgram", NSS_STATS_TYPE_SPECIAL}, -- {"rx_invalid_rec_dgram", NSS_STATS_TYPE_SPECIAL}, -- {"buffer_alloc_fail", NSS_STATS_TYPE_SPECIAL}, -- {"buffer_copy_fail", NSS_STATS_TYPE_SPECIAL}, -- {"outflow_queue_full", NSS_STATS_TYPE_SPECIAL}, -- {"tx_dropped_hroom", NSS_STATS_TYPE_DROP}, -- {"rx_cbuffer_alloc_fail", NSS_STATS_TYPE_SPECIAL}, -- {"rx_cenqueue_fail", NSS_STATS_TYPE_SPECIAL}, -- {"rx_decrypt_done", NSS_STATS_TYPE_SPECIAL}, -- {"rx_forward_enqueue_fail", NSS_STATS_TYPE_SPECIAL}, -- {"tx_cbuffer_alloc_fail", NSS_STATS_TYPE_SPECIAL}, -- {"tx_cenqueue_fail", NSS_STATS_TYPE_SPECIAL}, -- {"rx_dropped_troom", NSS_STATS_TYPE_DROP}, -- {"tx_forward_enqueue_fail", NSS_STATS_TYPE_SPECIAL}, -- {"tx_cipher_done", NSS_STATS_TYPE_SPECIAL}, -- {"crypto_nosupp", NSS_STATS_TYPE_SPECIAL}, -- {"rx_dropped_mh_version", NSS_STATS_TYPE_SPECIAL}, -- {"rx_unaligned_pkt", NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_gre_tunnel_strings_read() -- * Read gre_tunnel session debug statistics names -- */ --static ssize_t nss_gre_tunnel_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_gre_tunnel_strings_stats, NSS_GRE_TUNNEL_STATS_SESSION_MAX); --} -- --/* -- * nss_gre_tunnel_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(gre_tunnel); -- --/* -- * nss_gre_tunnel_strings_dentry_create() -- * Create gre_tunnel statistics strings debug entry. -- */ --void nss_gre_tunnel_strings_dentry_create(void) --{ -- nss_strings_create_dentry("gre_tunnel", &nss_gre_tunnel_strings_ops); --} ---- a/nss_gre_tunnel_strings.h -+++ /dev/null -@@ -1,25 +0,0 @@ --/* -- **************************************************************************** -- * Copyright (c) 2020-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. -- **************************************************************************** -- */ -- --#ifndef __NSS_GRE_TUNNEL_STRINGS_H --#define __NSS_GRE_TUNNEL_STRINGS_H -- --#include "nss_gre_tunnel_stats.h" -- --extern struct nss_stats_info nss_gre_tunnel_strings_stats[NSS_GRE_TUNNEL_STATS_SESSION_MAX]; --extern void nss_gre_tunnel_strings_dentry_create(void); -- --#endif /* __NSS_GRE_TUNNEL_STRINGS_H */ ---- a/nss_hal/fsm9010/nss_hal_pvt.c -+++ b/nss_hal/fsm9010/nss_hal_pvt.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2015-2020, 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. -@@ -145,13 +145,12 @@ static struct nss_platform_data *__nss_h - npd->nphys = res_nphys.start; - npd->vphys = res_vphys.start; - -- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); -+ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); - if (!npd->nmap) { - nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); - goto out; - } - -- nss_assert(npd->vphys); - npd->vmap = ioremap_cache(npd->vphys, resource_size(&res_vphys)); - if (!npd->vmap) { - nss_info_always("%px: nss%d: ioremap() fail for vphys\n", nss_ctx, nss_ctx->id); ---- a/nss_hal/include/nss_hal.h -+++ b/nss_hal/include/nss_hal.h -@@ -1,12 +1,9 @@ - /* - ************************************************************************** - * Copyright (c) 2013, 2016-2020 The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 -@@ -52,9 +49,6 @@ extern struct nss_hal_ops nss_hal_ipq50x - #if defined(NSS_HAL_FSM9010_SUPPORT) - extern struct nss_hal_ops nss_hal_fsm9010_ops; - #endif --#if defined(NSS_HAL_IPQ95XX_SUPPORT) --extern struct nss_hal_ops nss_hal_ipq95xx_ops; --#endif - - #define NSS_HAL_SUPPORTED_INTERRUPTS (NSS_N2H_INTR_EMPTY_BUFFER_QUEUE | \ - NSS_N2H_INTR_DATA_QUEUE_0 | \ ---- a/nss_hal/include/nss_regs.h -+++ b/nss_hal/include/nss_regs.h -@@ -1,12 +1,9 @@ - /* - ************************************************************************** - * Copyright (c) 2013, 2015-2017, 2019-2020, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 -@@ -41,26 +38,16 @@ - #define NSS_REGS_C2C_INTR_CLR_OFFSET 0x001c - #define NSS_REGS_N2H_INTR_STATUS_OFFSET 0x0020 - #define NSS_REGS_N2H_INTR_SET_OFFSET 0x0024 -- --#if defined(NSS_HAL_IPQ95XX_SUPPORT) --#define NSS_REGS_CORE_INT_STAT0_ENABLE_OFFSET 0x0028 --#define NSS_REGS_CORE_INT_STAT1_ENABLE_OFFSET 0x002c --#define NSS_REGS_CORE_INT_STAT2_ENABLE_OFFSET 0x0030 --#define NSS_REGS_CORE_INT_STAT3_ENABLE_OFFSET 0x0034 --#elif defined(NSS_HAL_FSM9010_SUPPORT) || defined(NSS_HAL_IPQ806X_SUPPORT) - #define NSS_REGS_N2H_INTR_CLR_OFFSET 0x0028 - #define NSS_REGS_N2H_INTR_MASK_OFFSET 0x002c - #define NSS_REGS_N2H_INTR_MASK_SET_OFFSET 0x0030 - #define NSS_REGS_N2H_INTR_MASK_CLR_OFFSET 0x0034 --#endif -- - #define NSS_REGS_CORE_INT_STAT0_TYPE_OFFSET 0x0038 - #define NSS_REGS_CORE_INT_STAT1_TYPE_OFFSET 0x003c - #define NSS_REGS_CORE_INT_STAT2_TYPE_OFFSET 0x0040 - #define NSS_REGS_CORE_INT_STAT3_TYPE_OFFSET 0x0044 - #define NSS_REGS_CORE_IFETCH_RANGE_OFFSET 0x0048 - -- - /* - * FPB register offsets - */ ---- a/nss_hal/ipq60xx/nss_hal_pvt.c -+++ b/nss_hal/ipq60xx/nss_hal_pvt.c -@@ -207,13 +207,13 @@ static struct nss_platform_data *__nss_h - npd->nphys = res_nphys.start; - npd->qgic_phys = res_qgic_phys.start; - -- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); -+ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); - if (!npd->nmap) { - nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); - goto out; - } - -- npd->qgic_map = ioremap_nocache(npd->qgic_phys, resource_size(&res_qgic_phys)); -+ npd->qgic_map = ioremap(npd->qgic_phys, resource_size(&res_qgic_phys)); - if (!npd->qgic_map) { - nss_info_always("%px: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); - goto out; -@@ -433,13 +433,13 @@ static int __nss_hal_common_reset(struct - - of_node_put(cmn); - -- nss_misc_reset = ioremap_nocache(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); -+ nss_misc_reset = ioremap(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); - if (!nss_misc_reset) { - pr_err("%px: ioremap fail for nss_misc_reset\n", nss_dev); - return -EFAULT; - } - -- nss_misc_reset_flag = ioremap_nocache(res_nss_misc_reset_flag.start, resource_size(&res_nss_misc_reset_flag)); -+ nss_misc_reset_flag = ioremap(res_nss_misc_reset_flag.start, resource_size(&res_nss_misc_reset_flag)); - if (!nss_misc_reset_flag) { - pr_err("%px: ioremap fail for nss_misc_reset_flag\n", nss_dev); - return -EFAULT; ---- a/nss_hal/ipq806x/nss_hal_pvt.c -+++ b/nss_hal/ipq806x/nss_hal_pvt.c -@@ -458,7 +458,7 @@ static struct nss_platform_data *__nss_h - npd->nphys = res_nphys.start; - npd->vphys = res_vphys.start; - -- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); -+ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); - if (!npd->nmap) { - nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); - goto out; -@@ -711,7 +711,7 @@ static int __nss_hal_common_reset(struct - } - of_node_put(cmn); - -- fpb_base = ioremap_nocache(res_nss_fpb_base.start, resource_size(&res_nss_fpb_base)); -+ fpb_base = ioremap(res_nss_fpb_base.start, resource_size(&res_nss_fpb_base)); - if (!fpb_base) { - pr_err("%px: ioremap fail for nss_fpb_base\n", nss_dev); - return -EFAULT; ---- a/nss_hal/ipq807x/nss_hal_pvt.c -+++ b/nss_hal/ipq807x/nss_hal_pvt.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2020, 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. -@@ -234,20 +234,19 @@ static struct nss_platform_data *__nss_h - npd->vphys = res_vphys.start; - npd->qgic_phys = res_qgic_phys.start; - -- npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys)); -+ npd->nmap = ioremap(npd->nphys, resource_size(&res_nphys)); - if (!npd->nmap) { - nss_info_always("%px: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id); - goto out; - } - -- nss_assert(npd->vphys); - npd->vmap = ioremap_cache(npd->vphys, resource_size(&res_vphys)); - if (!npd->vmap) { - nss_info_always("%px: nss%d: ioremap() fail for vphys\n", nss_ctx, nss_ctx->id); - goto out; - } - -- npd->qgic_map = ioremap_nocache(npd->qgic_phys, resource_size(&res_qgic_phys)); -+ npd->qgic_map = ioremap(npd->qgic_phys, resource_size(&res_qgic_phys)); - if (!npd->qgic_map) { - nss_info_always("%px: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id); - goto out; -@@ -467,7 +466,7 @@ static int __nss_hal_common_reset(struct - } - of_node_put(cmn); - -- nss_misc_reset = ioremap_nocache(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); -+ nss_misc_reset = ioremap(res_nss_misc_reset.start, resource_size(&res_nss_misc_reset)); - if (!nss_misc_reset) { - pr_err("%px: ioremap fail for nss_misc_reset\n", nss_dev); - return -EFAULT; ---- a/nss_hal/nss_hal.c -+++ b/nss_hal/nss_hal.c -@@ -1,12 +1,9 @@ - /* - ************************************************************************** - * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 -@@ -27,17 +24,13 @@ - #include - #include - #include -+#include - - #include "nss_hal.h" - #include "nss_arch.h" - #include "nss_core.h" - #include "nss_tx_rx_common.h" --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - #include "nss_data_plane.h" --#endif --#ifdef NSS_DATA_PLANE_LITE_SUPPORT --#include "nss_data_plane_lite.h" --#endif - #if (NSS_PM_SUPPORT == 1) - #include "nss_pm.h" - #endif -@@ -81,9 +74,9 @@ int nss_hal_firmware_load(struct nss_ctx - } - - -- load_mem = ioremap_nocache(npd->load_addr, nss_fw->size); -+ load_mem = ioremap(npd->load_addr, nss_fw->size); - if (!load_mem) { -- nss_info_always("%px: ioremap_nocache failed: %x", nss_ctx, npd->load_addr); -+ nss_info_always("%px: ioremap failed: %x", nss_ctx, npd->load_addr); - release_firmware(nss_fw); - return rc; - } -@@ -95,6 +88,7 @@ int nss_hal_firmware_load(struct nss_ctx - return 0; - } - -+ - /* - * nss_hal_dt_parse_features() - */ -@@ -105,14 +99,12 @@ void nss_hal_dt_parse_features(struct de - */ - npd->bridge_enabled = of_property_read_bool(np, "qcom,bridge-enabled"); - npd->capwap_enabled = of_property_read_bool(np, "qcom,capwap-enabled"); -- npd->clmap_enabled = of_property_read_bool(np, "qcom,clmap-enabled"); - npd->crypto_enabled = of_property_read_bool(np, "qcom,crypto-enabled"); - npd->dtls_enabled = of_property_read_bool(np, "qcom,dtls-enabled"); - npd->gre_enabled = of_property_read_bool(np, "qcom,gre-enabled"); - npd->gre_redir_enabled = of_property_read_bool(np, "qcom,gre-redir-enabled"); - npd->gre_tunnel_enabled = of_property_read_bool(np, "qcom,gre_tunnel_enabled"); - npd->gre_redir_mark_enabled = of_property_read_bool(np, "qcom,gre-redir-mark-enabled"); -- npd->igs_enabled = of_property_read_bool(np, "qcom,igs-enabled"); - npd->ipsec_enabled = of_property_read_bool(np, "qcom,ipsec-enabled"); - npd->ipv4_enabled = of_property_read_bool(np, "qcom,ipv4-enabled"); - npd->ipv4_reasm_enabled = of_property_read_bool(np, "qcom,ipv4-reasm-enabled"); -@@ -126,25 +118,19 @@ void nss_hal_dt_parse_features(struct de - npd->pptp_enabled = of_property_read_bool(np, "qcom,pptp-enabled"); - npd->portid_enabled = of_property_read_bool(np, "qcom,portid-enabled"); - npd->pvxlan_enabled = of_property_read_bool(np, "qcom,pvxlan-enabled"); -+ npd->clmap_enabled = of_property_read_bool(np, "qcom,clmap-enabled"); - npd->qvpn_enabled = of_property_read_bool(np, "qcom,qvpn-enabled"); - npd->rmnet_rx_enabled = of_property_read_bool(np, "qcom,rmnet_rx-enabled"); - npd->shaping_enabled = of_property_read_bool(np, "qcom,shaping-enabled"); -- npd->tls_enabled = of_property_read_bool(np, "qcom,tls-enabled"); - npd->tstamp_enabled = of_property_read_bool(np, "qcom,tstamp-enabled"); - npd->turbo_frequency = of_property_read_bool(np, "qcom,turbo-frequency"); - npd->tun6rd_enabled = of_property_read_bool(np, "qcom,tun6rd-enabled"); - npd->tunipip6_enabled = of_property_read_bool(np, "qcom,tunipip6-enabled"); - npd->vlan_enabled = of_property_read_bool(np, "qcom,vlan-enabled"); -- npd->vxlan_enabled = of_property_read_bool(np, "qcom,vxlan-enabled"); - npd->wlanredirect_enabled = of_property_read_bool(np, "qcom,wlanredirect-enabled"); - npd->wifioffload_enabled = of_property_read_bool(np, "qcom,wlan-dataplane-offload-enabled"); -- npd->match_enabled = of_property_read_bool(np, "qcom,match-enabled"); -- npd->mirror_enabled = of_property_read_bool(np, "qcom,mirror-enabled"); -- npd->udp_st_enabled = of_property_read_bool(np, "qcom,udp-st-enabled"); -- npd->edma_lite_enabled = of_property_read_bool(np, "qcom,edma-lite-enabled"); -- npd->trustsec_enabled = of_property_read_bool(np, "qcom,trustsec-enabled"); -+ npd->igs_enabled = of_property_read_bool(np, "qcom,igs-enabled"); - } -- - /* - * nss_hal_clean_up_irq() - */ -@@ -365,7 +351,6 @@ int nss_hal_probe(struct platform_device - } - #endif - --#ifdef NSS_DRV_IPV4_ENABLE - if (npd->ipv4_enabled == NSS_FEATURE_ENABLED) { - nss_top->ipv4_handler_id = nss_dev->id; - nss_ipv4_register_handler(); -@@ -374,15 +359,10 @@ int nss_hal_probe(struct platform_device - nss_top->edma_handler_id = nss_dev->id; - nss_edma_register_handler(); - #endif -- --#ifdef NSS_DRV_ETH_RX_ENABLE - nss_eth_rx_register_handler(nss_ctx); --#endif -- - #ifdef NSS_DRV_LAG_ENABLE - nss_lag_register_handler(); - #endif -- - #ifdef NSS_DRV_TRUSTSEC_ENABLE - nss_top->trustsec_tx_handler_id = nss_dev->id; - nss_trustsec_tx_register_handler(); -@@ -393,25 +373,15 @@ int nss_hal_probe(struct platform_device - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_N2H] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_GENERIC_REDIR_H2N] = nss_dev->id; - } --#endif -- --#ifdef NSS_DRV_TRUSTSEC_RX_ENABLE -- if (npd->trustsec_enabled == NSS_FEATURE_ENABLED) { -- nss_top->trustsec_rx_handler_id = nss_dev->id; -- nss_trustsec_rx_register_handler(); -- -- nss_top->trustsec_tx_handler_id = nss_dev->id; -- nss_trustsec_tx_register_handler(); -- } --#endif - -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,3)) - #ifdef NSS_DRV_CAPWAP_ENABLE - if (npd->capwap_enabled == NSS_FEATURE_ENABLED) { - nss_top->capwap_handler_id = nss_dev->id; -- nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_OUTER] = nss_dev->id; -- nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP_HOST_INNER] = nss_dev->id; -+ nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_CAPWAP] = nss_dev->id; - } - #endif -+#endif - - #ifdef NSS_DRV_IPV4_REASM_ENABLE - if (npd->ipv4_reasm_enabled == NSS_FEATURE_ENABLED) { -@@ -441,7 +411,7 @@ int nss_hal_probe(struct platform_device - */ - if (npd->crypto_enabled == NSS_FEATURE_ENABLED) { - nss_top->crypto_handler_id = nss_dev->id; --#if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) || defined(NSS_HAL_IPQ50XX_SUPPORT) || defined(NSS_HAL_IPQ95XX_SUPPORT) -+#if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) || defined(NSS_HAL_IPQ50XX_SUPPORT) - nss_crypto_cmn_register_handler(); - #else - nss_top->crypto_enabled = 1; -@@ -513,7 +483,7 @@ int nss_hal_probe(struct platform_device - #ifdef NSS_DRV_DTLS_ENABLE - if (npd->dtls_enabled == NSS_FEATURE_ENABLED) { - nss_top->dtls_handler_id = nss_dev->id; --#if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) || defined(NSS_HAL_IPQ50XX_SUPPORT) || defined(NSS_HAL_IPQ95XX_SUPPORT) -+#if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) || defined(NSS_HAL_IPQ50XX_SUPPORT) - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_INNER] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_DTLS_CMN_OUTER] = nss_dev->id; - nss_dtls_cmn_register_handler(); -@@ -588,33 +558,24 @@ int nss_hal_probe(struct platform_device - } - #endif - --#ifdef NSS_DRV_WIFIOFFLOAD_ENABLE -+#ifdef NSS_DRV_WIFI_ENABLE - if (npd->wifioffload_enabled == NSS_FEATURE_ENABLED) { - nss_top->wifi_handler_id = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_VAP] = nss_dev->id; - nss_wifi_register_handler(); - nss_wifili_register_handler(); --#ifdef NSS_DRV_WIFI_EXT_VDEV_ENABLE -- nss_wifi_ext_vdev_register_handler(); --#endif -+#if (NSS_FW_VERSION_CODE <= NSS_FW_VERSION(11,0)) -+ nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFILI] = nss_dev->id; -+#else - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_INTERNAL] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_EXTERNAL0] = nss_dev->id; - nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFILI_EXTERNAL1] = nss_dev->id; -- nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFI_EXT_VDEV_WDS] = nss_dev->id; -- nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFI_EXT_VDEV_VLAN] = nss_dev->id; -- nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER] = nss_dev->id; -- nss_top->dynamic_interface_table[NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER] = nss_dev->id; -- - /* - * Register wifi mac database when offload enabled - */ - nss_top->wmdb_handler_id = nss_dev->id; - nss_wifi_mac_db_register_handler(); -- -- /* -- * Initialize wifili thread scheme database -- */ -- nss_wifili_thread_scheme_db_init(nss_dev->id); -+#endif - } - #endif - -@@ -701,6 +662,7 @@ int nss_hal_probe(struct platform_device - } - #endif - -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,1)) - #ifdef NSS_DRV_TLS_ENABLE - #if defined(NSS_HAL_IPQ807x_SUPPORT) || defined(NSS_HAL_IPQ60XX_SUPPORT) - if (npd->tls_enabled == NSS_FEATURE_ENABLED) { -@@ -711,7 +673,6 @@ int nss_hal_probe(struct platform_device - } - #endif - #endif -- - #ifdef NSS_DRV_MIRROR_ENABLE - if (npd->mirror_enabled == NSS_FEATURE_ENABLED) { - nss_top->mirror_handler_id = nss_dev->id; -@@ -719,14 +680,7 @@ int nss_hal_probe(struct platform_device - nss_mirror_register_handler(); - nss_info("%d: NSS mirror is enabled", nss_dev->id); - } -- - #endif -- --#ifdef NSS_DRV_UDP_ST_ENABLE -- if (npd->udp_st_enabled == NSS_FEATURE_ENABLED) { -- nss_top->udp_st_handler_id = nss_dev->id; -- nss_udp_st_register_handler(nss_ctx); -- } - #endif - - if (nss_ctx->id == 0) { -@@ -740,19 +694,8 @@ int nss_hal_probe(struct platform_device - nss_freq_init_cpu_usage(); - #endif - --#ifdef NSS_DRV_LSO_RX_ENABLE - nss_lso_rx_register_handler(nss_ctx); --#endif -- } -- --#ifdef NSS_DRV_EDMA_LITE_ENABLE -- if (npd->edma_lite_enabled == NSS_FEATURE_ENABLED) { -- nss_top->edma_lite_handler_id[nss_ctx->id] = nss_ctx->id; -- nss_edma_lite_register_handler(nss_ctx); -- } else { -- nss_top->edma_lite_handler_id[nss_ctx->id] = -1; - } --#endif - - nss_top->frequency_handler_id = nss_dev->id; - -@@ -798,7 +741,7 @@ int nss_hal_probe(struct platform_device - nss_hal_enable_interrupt(nss_ctx, nss_ctx->int_ctx[i].shift_factor, NSS_HAL_SUPPORTED_INTERRUPTS); - } - -- nss_info_always("%px: All resources initialized and nss core%d has been brought out of reset", nss_ctx, nss_dev->id); -+ nss_info("%px: All resources initialized and nss core%d has been brought out of reset", nss_ctx, nss_dev->id); - goto out; - - err_register_irq: -@@ -851,13 +794,7 @@ int nss_hal_remove(struct platform_devic - /* - * nss-drv is exiting, unregister and restore host data plane - */ --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - nss_top->data_plane_ops->data_plane_unregister(); --#endif -- --#ifdef NSS_DATA_PLANE_LITE_SUPPORT -- nss_data_plane_lite_unregister(); --#endif - - #if (NSS_FABRIC_SCALING_SUPPORT == 1) - fab_scaling_unregister(nss_core0_clk); ---- a/nss_if.c -+++ b/nss_if.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2016, 2018-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2016, 2018-2020, 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. -@@ -160,10 +160,10 @@ nss_tx_status_t nss_if_tx_buf(struct nss - } - - /* -- * nss_if_tx_msg_with_size() -- * Transmit a message to the specific interface on this core with a specified size. -+ * nss_if_tx_msg() -+ * Transmit a message to the specific interface on this core. - */ --nss_tx_status_t nss_if_tx_msg_with_size(struct nss_ctx_instance *nss_ctx, struct nss_if_msg *nim, uint32_t size) -+nss_tx_status_t nss_if_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_if_msg *nim) - { - struct nss_cmn_msg *ncm = &nim->cm; - struct net_device *dev; -@@ -198,19 +198,7 @@ nss_tx_status_t nss_if_tx_msg_with_size( - return NSS_TX_FAILURE_BAD_PARAM; - } - -- return nss_core_send_cmd(nss_ctx, nim, sizeof(*nim), size); --} --EXPORT_SYMBOL(nss_if_tx_msg_with_size); -- --/* -- * nss_if_tx_msg() -- * Transmit a message to the specific interface on this core. -- */ --nss_tx_status_t nss_if_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_if_msg *nim) --{ -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- return nss_if_tx_msg_with_size(nss_ctx, nim, NSS_NBUF_PAYLOAD_SIZE); -+ return nss_core_send_cmd(nss_ctx, nim, sizeof(*nim), NSS_NBUF_PAYLOAD_SIZE); - } - - /* -@@ -277,90 +265,6 @@ nss_tx_status_t nss_if_set_nexthop(struc - } - EXPORT_SYMBOL(nss_if_set_nexthop); - --/* -- * nss_if_change_mtu() -- * Change the MTU of the interface. -- */ --nss_tx_status_t nss_if_change_mtu(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num, uint16_t mtu) --{ -- struct nss_if_msg nim; -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- nss_trace("%px: NSS If MTU will be changed to %u, of NSS if num: %u\n", nss_ctx, mtu, if_num); -- -- nss_cmn_msg_init(&nim.cm, if_num, NSS_IF_MTU_CHANGE, -- sizeof(struct nss_if_mtu_change), nss_if_callback, NULL); -- -- nim.msg.mtu_change.min_buf_size = mtu; -- -- return nss_if_msg_sync(nss_ctx, &nim); --} --EXPORT_SYMBOL(nss_if_change_mtu); -- --/* -- * nss_if_change_mac_addr() -- * Change the MAC address of the interface. -- */ --nss_tx_status_t nss_if_change_mac_addr(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num, uint8_t *mac_addr) --{ -- struct nss_if_msg nim; -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- nss_trace("%px: NSS If MAC address will be changed to %s, of NSS if num: %u\n", nss_ctx, mac_addr, if_num); -- -- nss_cmn_msg_init(&nim.cm, if_num, NSS_IF_MAC_ADDR_SET, -- sizeof(struct nss_if_mac_address_set), nss_if_callback, NULL); -- -- memcpy(nim.msg.mac_address_set.mac_addr, mac_addr, ETH_ALEN); -- -- return nss_if_msg_sync(nss_ctx, &nim); --} --EXPORT_SYMBOL(nss_if_change_mac_addr); -- --/* -- * nss_if_vsi_unassign() -- * API to send VSI detach message to NSS FW. -- */ --nss_tx_status_t nss_if_vsi_unassign(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num, uint32_t vsi) --{ -- struct nss_if_msg nim; -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- nss_trace("%px: VSI to be unassigned is %u\n", nss_ctx, vsi); -- -- nss_cmn_msg_init(&nim.cm, if_num, NSS_IF_VSI_UNASSIGN, -- sizeof(struct nss_if_vsi_unassign), nss_if_callback, NULL); -- -- nim.msg.vsi_unassign.vsi = vsi; -- -- return nss_if_msg_sync(nss_ctx, &nim); --} --EXPORT_SYMBOL(nss_if_vsi_unassign); -- --/* -- * nss_if_vsi_assign() -- * API to send VSI attach message to NSS FW. -- */ --nss_tx_status_t nss_if_vsi_assign(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num, uint32_t vsi) --{ -- struct nss_if_msg nim; -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- nss_trace("%px: VSI to be assigned is %u\n", nss_ctx, vsi); -- -- nss_cmn_msg_init(&nim.cm, if_num, NSS_IF_VSI_ASSIGN, -- sizeof(struct nss_if_vsi_assign), nss_if_callback, NULL); -- -- nim.msg.vsi_assign.vsi = vsi; -- -- return nss_if_msg_sync(nss_ctx, &nim); --} --EXPORT_SYMBOL(nss_if_vsi_assign); -- - EXPORT_SYMBOL(nss_if_tx_msg); - EXPORT_SYMBOL(nss_if_register); - EXPORT_SYMBOL(nss_if_unregister); ---- a/nss_igs.c -+++ b/nss_igs.c -@@ -14,14 +14,12 @@ - ************************************************************************** - */ - --#include "nss_tx_rx_common.h" --#include "nss_igs_stats.h" -- --#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) - #ifdef CONFIG_NET_CLS_ACT - #include - #endif --#endif -+ -+#include "nss_tx_rx_common.h" -+#include "nss_igs_stats.h" - - static struct module *nss_igs_module; - ---- a/nss_init.c -+++ b/nss_init.c -@@ -1,12 +1,9 @@ - /* - ************************************************************************** - * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 -@@ -27,12 +24,7 @@ - #include "nss_pm.h" - #endif - #include "nss_tx_rx_common.h" --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - #include "nss_data_plane.h" --#endif --#ifdef NSS_DATA_PLANE_LITE_SUPPORT --#include "nss_data_plane_lite.h" --#endif - #include "nss_capwap.h" - #include "nss_strings.h" - -@@ -641,24 +633,10 @@ static struct ctl_table_header *nss_dev_ - */ - static int __init nss_init(void) - { --#if defined(NSS_DRV_POINT_OFFLOAD) -- struct device_node *pof = NULL; --#endif -- -- - #if (NSS_DT_SUPPORT == 1) - struct device_node *cmn = NULL; - #endif -- --#if defined(NSS_DRV_POINT_OFFLOAD) -- pof = of_find_node_by_name(NULL, "reg_update"); -- if ((!pof) || (!of_property_read_bool(pof, "ubi_core_enable"))) { -- nss_info_always("UBI is not enabled. Disable qca-nss-drv\n"); -- return 0; -- } --#endif -- --nss_info("Init NSS driver"); -+ nss_info("Init NSS driver"); - - #if (NSS_DT_SUPPORT == 1) - /* -@@ -677,18 +655,14 @@ nss_info("Init NSS driver"); - #if defined(NSS_HAL_IPQ806X_SUPPORT) - if (of_machine_is_compatible("qcom,ipq8064") || of_machine_is_compatible("qcom,ipq8062")) { - nss_top_main.hal_ops = &nss_hal_ipq806x_ops; --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops; --#endif - nss_top_main.num_nss = 2; - } - #endif - #if defined(NSS_HAL_IPQ807x_SUPPORT) - if (of_machine_is_compatible("qcom,ipq807x") || of_machine_is_compatible("qcom,ipq8074")) { - nss_top_main.hal_ops = &nss_hal_ipq807x_ops; --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - nss_top_main.data_plane_ops = &nss_data_plane_ops; --#endif - #if defined(NSS_MEM_PROFILE_LOW) - nss_top_main.num_nss = 1; - #else -@@ -699,35 +673,21 @@ nss_info("Init NSS driver"); - #if defined(NSS_HAL_IPQ60XX_SUPPORT) - if (of_machine_is_compatible("qcom,ipq6018")) { - nss_top_main.hal_ops = &nss_hal_ipq60xx_ops; --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - nss_top_main.data_plane_ops = &nss_data_plane_ops; --#endif - nss_top_main.num_nss = 1; - } - #endif - #if defined(NSS_HAL_IPQ50XX_SUPPORT) - if (of_machine_is_compatible("qcom,ipq5018")) { - nss_top_main.hal_ops = &nss_hal_ipq50xx_ops; --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - nss_top_main.data_plane_ops = &nss_data_plane_ops; --#endif - nss_top_main.num_nss = 1; - } - #endif -- --#if defined(NSS_HAL_IPQ95XX_SUPPORT) -- if (of_machine_is_compatible("qcom,ipq9574-emulation") || of_machine_is_compatible("qcom,ipq9574")) { -- nss_top_main.hal_ops = &nss_hal_ipq95xx_ops; -- nss_top_main.num_nss = 1; -- } --#endif -- - #if defined(NSS_HAL_FSM9010_SUPPORT) - if (of_machine_is_compatible("qcom,fsm9010")) { - nss_top_main.hal_ops = &nss_hal_fsm9010_ops; --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops; --#endif - nss_top_main.num_nss = 1; - } - #endif -@@ -740,9 +700,7 @@ nss_info("Init NSS driver"); - * For banana, only ipq806x is supported - */ - nss_top_main.hal_ops = &nss_hal_ipq806x_ops; --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - nss_top_main.data_plane_ops = &nss_data_plane_gmac_ops; --#endif - nss_top_main.num_nss = 2; - - #endif /* NSS_DT_SUPPORT */ -@@ -751,20 +709,11 @@ nss_info("Init NSS driver"); - /* - * Initialize data_plane workqueue - */ -- --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - if (nss_data_plane_init_delay_work()) { - nss_warning("Error initializing nss_data_plane_workqueue\n"); - return -EFAULT; - } --#endif - --#ifdef NSS_DATA_PLANE_LITE_SUPPORT -- if (nss_data_plane_lite_init_delay_work()){ -- nss_warning("Error initializing nss_data_plane_lite_workqueue\n"); -- return -EFAULT; -- } --#endif - /* - * Enable spin locks - */ -@@ -790,9 +739,7 @@ nss_info("Init NSS driver"); - /* - * Registering sysctl for ipv4/6 specific config. - */ --#ifdef NSS_DRV_IPV4_ENABLE - nss_ipv4_register_sysctl(); --#endif - #ifdef NSS_DRV_IPV6_ENABLE - nss_ipv6_register_sysctl(); - #endif -@@ -828,13 +775,12 @@ nss_info("Init NSS driver"); - */ - nss_project_register_sysctl(); - -+#ifdef NSS_DRV_PPPOE_ENABLE - /* - * Registering sysctl for pppoe specific config. - */ --#ifdef NSS_DRV_PPPOE_ENABLE - nss_pppoe_register_sysctl(); - #endif -- - /* - * Setup Runtime Sample values - */ -@@ -928,13 +874,6 @@ nss_info("Init NSS driver"); - #endif - - /* -- * Init Wi-Fi mesh -- */ --#ifdef NSS_DRV_WIFI_MESH_ENABLE -- nss_wifi_mesh_init(); --#endif -- -- /* - * Register platform_driver - */ - return platform_driver_register(&nss_driver); -@@ -968,20 +907,18 @@ static void __exit nss_cleanup(void) - nss_c2c_tx_unregister_sysctl(); - #endif - -+#ifdef NSS_DRV_PPPOE_ENABLE - /* - * Unregister pppoe specific sysctl - */ --#ifdef NSS_DRV_PPPOE_ENABLE - nss_pppoe_unregister_sysctl(); - #endif - - /* - * Unregister ipv4/6 specific sysctl and free allocated to connection tables - */ --#ifdef NSS_DRV_IPV4_ENABLE - nss_ipv4_unregister_sysctl(); - nss_ipv4_free_conn_tables(); --#endif - - #ifdef NSS_DRV_IPV6_ENABLE - nss_ipv6_unregister_sysctl(); -@@ -989,14 +926,7 @@ static void __exit nss_cleanup(void) - #endif - - nss_project_unregister_sysctl(); -- --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - nss_data_plane_destroy_delay_work(); --#endif -- --#ifdef NSS_DATA_PLANE_LITE_SUPPORT -- nss_data_plane_lite_destroy_delay_work(); --#endif - - /* - * cleanup ppe on supported platform ---- a/nss_ipsec_cmn.c -+++ b/nss_ipsec_cmn.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2018-2020, 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. -@@ -19,11 +19,11 @@ - #include "nss_ipsec_cmn.h" - #include "nss_ppe.h" - #include "nss_ipsec_cmn_log.h" --#include "nss_ipsec_cmn_stats.h" --#include "nss_ipsec_cmn_strings.h" - - #define NSS_IPSEC_CMN_TX_TIMEOUT 3000 /* 3 Seconds */ - #define NSS_IPSEC_CMN_INTERFACE_MAX_LONG BITS_TO_LONGS(NSS_MAX_NET_INTERFACES) -+#define NSS_IPSEC_CMN_STATS_MAX_LINES (NSS_STATS_NODE_MAX + 32) -+#define NSS_IPSEC_CMN_STATS_SIZE_PER_IF (NSS_STATS_MAX_STR_LENGTH * NSS_IPSEC_CMN_STATS_MAX_LINES) - - /* - * Private data structure for handling synchronous messaging. -@@ -36,6 +36,104 @@ static struct nss_ipsec_cmn_pvt { - } ipsec_cmn_pvt; - - /* -+ * nss_ipsec_cmn_stats_sync() -+ * Update ipsec_cmn node statistics. -+ */ -+static void nss_ipsec_cmn_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm) -+{ -+ struct nss_ipsec_cmn_msg *nicm = (struct nss_ipsec_cmn_msg *)ncm; -+ struct nss_top_instance *nss_top = nss_ctx->nss_top; -+ struct nss_cmn_node_stats *msg_stats = &nicm->msg.ctx_sync.stats.cmn_stats; -+ uint64_t *if_stats; -+ int8_t i; -+ -+ spin_lock_bh(&nss_top->stats_lock); -+ -+ /* -+ * Update common node stats, -+ * Note: DTLS only supports a single queue for RX -+ */ -+ if_stats = nss_top->stats_node[ncm->interface]; -+ if_stats[NSS_STATS_NODE_RX_PKTS] += msg_stats->rx_packets; -+ if_stats[NSS_STATS_NODE_RX_BYTES] += msg_stats->rx_bytes; -+ -+ for (i = 0; i < NSS_MAX_NUM_PRI; i++) { -+ if_stats[NSS_STATS_NODE_RX_QUEUE_0_DROPPED + i] += msg_stats->rx_dropped[i]; -+ } -+ -+ if_stats[NSS_STATS_NODE_TX_PKTS] += msg_stats->tx_packets; -+ if_stats[NSS_STATS_NODE_TX_BYTES] += msg_stats->tx_bytes; -+ -+ spin_unlock_bh(&nss_top->stats_lock); -+} -+ -+/* -+ * nss_ipsec_cmn_stats_read() -+ * Read ipsec_cmn node statistics. -+ */ -+static ssize_t nss_ipsec_cmn_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -+{ -+ struct nss_ctx_instance *nss_ctx = nss_ipsec_cmn_get_context(); -+ enum nss_dynamic_interface_type type; -+ ssize_t bytes_read = 0; -+ size_t len = 0, size; -+ uint32_t if_num; -+ char *buf; -+ -+ size = NSS_IPSEC_CMN_STATS_SIZE_PER_IF * bitmap_weight(ipsec_cmn_pvt.if_map, NSS_MAX_NET_INTERFACES); -+ -+ buf = kzalloc(size, GFP_KERNEL); -+ if (!buf) { -+ nss_warning("Could not allocate memory for local statistics buffer\n"); -+ return 0; -+ } -+ -+ len += nss_stats_banner(buf, len, size, "ipsec_cmn", NSS_STATS_SINGLE_CORE); -+ -+ /* -+ * Common node stats for each IPSEC dynamic interface. -+ */ -+ for_each_set_bit(if_num, ipsec_cmn_pvt.if_map, NSS_MAX_NET_INTERFACES) { -+ -+ type = nss_dynamic_interface_get_type(nss_ctx, if_num); -+ switch (type) { -+ case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_INNER: -+ len += scnprintf(buf + len, size - len, "\nInner if_num:%03u", if_num); -+ break; -+ -+ case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_INNER: -+ len += scnprintf(buf + len, size - len, "\nMetadata inner if_num:%03u", if_num); -+ break; -+ -+ case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_OUTER: -+ len += scnprintf(buf + len, size - len, "\nOuter if_num:%03u", if_num); -+ break; -+ -+ case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_OUTER: -+ len += scnprintf(buf + len, size - len, "\nMetadata outer if_num:%03u", if_num); -+ break; -+ -+ default: -+ len += scnprintf(buf + len, size - len, "\nUnknown(%d) if_num:%03u", type, if_num); -+ break; -+ } -+ -+ len += scnprintf(buf + len, size - len, "\n-------------------\n"); -+ len += nss_stats_fill_common_stats(if_num, NSS_STATS_SINGLE_INSTANCE, buf, len, size - len, "ipsec_cmn"); -+ } -+ -+ bytes_read = simple_read_from_buffer(ubuf, sz, ppos, buf, len); -+ kfree(buf); -+ -+ return bytes_read; -+} -+ -+/* -+ * nss_ipsec_cmn_stats_ops -+ */ -+NSS_STATS_DECLARE_FILE_OPERATIONS(ipsec_cmn) -+ -+/* - * nss_ipsec_cmn_verify_ifnum() - * Verify if the interface number is a IPsec interface. - */ -@@ -91,10 +189,8 @@ static void nss_ipsec_cmn_msg_handler(st - return; - } - -- if (ncm->type == NSS_IPSEC_CMN_MSG_TYPE_CTX_SYNC) { -+ if (ncm->type == NSS_IPSEC_CMN_MSG_TYPE_CTX_SYNC) - nss_ipsec_cmn_stats_sync(nss_ctx, ncm); -- nss_ipsec_cmn_stats_notify(nss_ctx, ncm->interface); -- } - - /* - * Update the callback and app_data for NOTIFY messages, ipsec_cmn sends all notify messages -@@ -102,7 +198,7 @@ static void nss_ipsec_cmn_msg_handler(st - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data; -+ ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; - } - - /* -@@ -151,15 +247,6 @@ static void nss_ipsec_cmn_sync_resp(void - } - - /* -- * nss_ipsec_cmn_ifmap_get() -- * Return IPsec common active interfaces map. -- */ --unsigned long *nss_ipsec_cmn_ifmap_get(void) --{ -- return ipsec_cmn_pvt.if_map; --} -- --/* - * nss_ipsec_cmn_get_context() - * Retrieve context for IPSEC redir. - */ -@@ -335,10 +422,8 @@ struct nss_ctx_instance *nss_ipsec_cmn_r - return NULL; - } - --#ifdef NSS_DRV_PPE_ENABLE - if (features & NSS_IPSEC_CMN_FEATURE_INLINE_ACCEL) - nss_ppe_tx_ipsec_add_intf_msg(nss_ipsec_cmn_get_ifnum_with_coreid(if_num)); --#endif - - /* - * Registering handler for sending tunnel interface msgs to NSS. -@@ -520,6 +605,5 @@ void nss_ipsec_cmn_register_handler(void - { - sema_init(&ipsec_cmn_pvt.sem, 1); - init_completion(&ipsec_cmn_pvt.complete); -- nss_ipsec_cmn_stats_dentry_create(); -- nss_ipsec_cmn_strings_dentry_create(); -+ nss_stats_create_dentry("ipsec_cmn", &nss_ipsec_cmn_stats_ops); - } ---- a/nss_ipsec_cmn_stats.c -+++ /dev/null -@@ -1,219 +0,0 @@ --/* -- *************************************************************************** -- * 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_core.h" --#include "nss_ipsec_cmn.h" --#include "nss_ipsec_cmn_stats.h" --#include "nss_ipsec_cmn_strings.h" -- --/* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_ipsec_cmn_stats_notifier); -- --/* -- * Spinlock to protect IPsec common statistics update/read -- */ --DEFINE_SPINLOCK(nss_ipsec_cmn_stats_lock); -- --unsigned long *nss_ipsec_cmn_ifmap_get(void); --const char *nss_ipsec_cmn_stats_iface_type(enum nss_dynamic_interface_type type); -- --/* -- * nss_ipsec_cmn_stats -- * ipsec common statistics -- */ --uint64_t nss_ipsec_cmn_stats[NSS_MAX_NET_INTERFACES][NSS_IPSEC_CMN_STATS_MAX]; -- --/* -- * nss_ipsec_cmn_stats_read() -- * Read ipsec_cmn node statistics. -- */ --static ssize_t nss_ipsec_cmn_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- /* -- * Max output lines = #stats + -- * few blank lines for banner printing + Number of Extra outputlines -- * for future reference to add new stats -- */ -- uint32_t max_output_lines = NSS_IPSEC_CMN_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- struct nss_ctx_instance *nss_ctx = nss_ipsec_cmn_get_context(); -- enum nss_dynamic_interface_type type; -- unsigned long *ifmap; -- uint64_t *stats_shadow; -- ssize_t bytes_read = 0; -- size_t size_wr = 0; -- uint32_t if_num; -- int32_t i; -- int count; -- char *lbuf; -- -- ifmap = nss_ipsec_cmn_ifmap_get(); -- count = bitmap_weight(ifmap, NSS_MAX_NET_INTERFACES); -- if (count) { -- size_al = size_al * count; -- } -- -- lbuf = vzalloc(size_al); -- if (unlikely(!lbuf)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return -ENOMEM; -- } -- -- stats_shadow = vzalloc(NSS_IPSEC_CMN_STATS_MAX * 8); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- vfree(lbuf); -- return -ENOMEM; -- } -- -- /* -- * Common node stats for each IPSEC dynamic interface. -- */ -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "ipsec_cmn stats", NSS_STATS_SINGLE_CORE); -- for_each_set_bit(if_num, ifmap, NSS_MAX_NET_INTERFACES) { -- -- type = nss_dynamic_interface_get_type(nss_ctx, if_num); -- if ((type < NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_INNER) || -- (type > NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_REDIRECT)) { -- continue; -- } -- -- spin_lock_bh(&nss_ipsec_cmn_stats_lock); -- for (i = 0; i < NSS_IPSEC_CMN_STATS_MAX; i++) { -- stats_shadow[i] = nss_ipsec_cmn_stats[if_num][i]; -- } -- spin_unlock_bh(&nss_ipsec_cmn_stats_lock); -- -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n%s if_num:%03u\n", -- nss_ipsec_cmn_stats_iface_type(type), if_num); -- size_wr += nss_stats_print("ipsec_cmn", NULL, NSS_STATS_SINGLE_INSTANCE, nss_ipsec_cmn_strings_stats, -- stats_shadow, NSS_IPSEC_CMN_STATS_MAX, lbuf, size_wr, size_al); -- } -- -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- vfree(lbuf); -- vfree(stats_shadow); -- -- return bytes_read; --} -- --/* -- * nss_ipsec_cmn_stats_ops. -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(ipsec_cmn); -- --/* -- * nss_ipsec_cmn_stats_sync() -- * Update ipsec_cmn node statistics. -- */ --void nss_ipsec_cmn_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm) --{ -- struct nss_ipsec_cmn_msg *nicm = (struct nss_ipsec_cmn_msg *)ncm; -- struct nss_ipsec_cmn_ctx_stats *ndccs = &nicm->msg.ctx_sync.stats; -- uint64_t *ctx_stats; -- uint32_t *msg_stats; -- uint16_t i = 0; -- -- spin_lock_bh(&nss_ipsec_cmn_stats_lock); -- -- msg_stats = (uint32_t *)ndccs; -- ctx_stats = nss_ipsec_cmn_stats[ncm->interface]; -- -- for (i = 0; i < NSS_IPSEC_CMN_STATS_MAX; i++, ctx_stats++, msg_stats++) { -- *ctx_stats += *msg_stats; -- } -- -- spin_unlock_bh(&nss_ipsec_cmn_stats_lock); --} -- --/* -- * nss_ipsec_cmn_stats_iface_type() -- * Return a string for each interface type. -- */ --const char *nss_ipsec_cmn_stats_iface_type(enum nss_dynamic_interface_type type) --{ -- switch (type) { -- case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_INNER: -- return "ipsec_cmn_inner"; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_INNER: -- return "ipsec_cmn_mdata_inner"; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_OUTER: -- return "ipsec_cmn_outer"; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_MDATA_OUTER: -- return "ipsec_cmn_mdata_outer"; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_IPSEC_CMN_REDIRECT: -- return "ipsec_cmn_redirect"; -- -- default: -- return "invalid_interface"; -- } --} -- --/* -- * nss_ipsec_cmn_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_ipsec_cmn_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_ipsec_cmn_stats_notification ipsec_cmn_stats; -- -- spin_lock_bh(&nss_ipsec_cmn_stats_lock); -- ipsec_cmn_stats.core_id = nss_ctx->id; -- ipsec_cmn_stats.if_num = if_num; -- memcpy(ipsec_cmn_stats.stats_ctx, nss_ipsec_cmn_stats[if_num], sizeof(ipsec_cmn_stats.stats_ctx)); -- spin_unlock_bh(&nss_ipsec_cmn_stats_lock); -- -- atomic_notifier_call_chain(&nss_ipsec_cmn_stats_notifier, NSS_STATS_EVENT_NOTIFY, &ipsec_cmn_stats); --} -- --/* -- * nss_ipsec_cmn_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_ipsec_cmn_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_ipsec_cmn_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_ipsec_cmn_stats_unregister_notifier); -- --/* -- * nss_ipsec_cmn_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_ipsec_cmn_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_ipsec_cmn_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_ipsec_cmn_stats_register_notifier); -- --/* -- * nss_ipsec_cmn_stats_dentry_create() -- * Create ipsec common statistics debug entry. -- */ --void nss_ipsec_cmn_stats_dentry_create(void) --{ -- nss_stats_create_dentry("ipsec_cmn", &nss_ipsec_cmn_stats_ops); --} ---- a/nss_ipsec_cmn_stats.h -+++ /dev/null -@@ -1,28 +0,0 @@ --/* -- *************************************************************************** -- * 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. -- *************************************************************************** -- */ -- --#ifndef __NSS_IPSEC_CMN_STATS_H --#define __NSS_IPSEC_CMN_STATS_H -- --#include -- --extern void nss_ipsec_cmn_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); --extern void nss_ipsec_cmn_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm); --extern void nss_ipsec_cmn_stats_dentry_create(void); -- --#endif /* __NSS_IPSEC_CMN_STATS_H */ ---- a/nss_ipsec_cmn_strings.c -+++ /dev/null -@@ -1,82 +0,0 @@ --/* -- *************************************************************************** -- * 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_strings.h" --#include "nss_ipsec_cmn_strings.h" -- --/* -- * nss_ipsec_cmn_strings_stats -- * ipsec common statistics strings. -- */ --struct nss_stats_info nss_ipsec_cmn_strings_stats[NSS_IPSEC_CMN_STATS_MAX] = { -- {"rx_pkts", NSS_STATS_TYPE_COMMON}, -- {"rx_byts", NSS_STATS_TYPE_COMMON}, -- {"tx_pkts", NSS_STATS_TYPE_COMMON}, -- {"tx_byts", NSS_STATS_TYPE_COMMON}, -- {"rx_queue[0]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[1]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[2]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[3]_drops", NSS_STATS_TYPE_DROP}, -- {"fail_headroom", NSS_STATS_TYPE_DROP}, -- {"fail_tailroom", NSS_STATS_TYPE_DROP}, -- {"fail_replay", NSS_STATS_TYPE_DROP}, -- {"fail_replay_dup", NSS_STATS_TYPE_DROP}, -- {"fail_replay_win", NSS_STATS_TYPE_DROP}, -- {"fail_pbuf_crypto", NSS_STATS_TYPE_DROP}, -- {"fail_queue", NSS_STATS_TYPE_DROP}, -- {"fail_queue_crypto", NSS_STATS_TYPE_DROP}, -- {"fail_queue_nexthop", NSS_STATS_TYPE_DROP}, -- {"fail_pbuf_alloc", NSS_STATS_TYPE_DROP}, -- {"fail_pbuf_linear", NSS_STATS_TYPE_DROP}, -- {"fail_pbuf_stats", NSS_STATS_TYPE_DROP}, -- {"fail_pbuf_align", NSS_STATS_TYPE_DROP}, -- {"fail_cipher", NSS_STATS_TYPE_EXCEPTION}, -- {"fail_auth", NSS_STATS_TYPE_EXCEPTION}, -- {"fail_seq_ovf", NSS_STATS_TYPE_DROP}, -- {"fail_blk_len", NSS_STATS_TYPE_DROP}, -- {"fail_hash_len", NSS_STATS_TYPE_DROP}, -- {"fail_transform", NSS_STATS_TYPE_DROP}, -- {"fail_crypto", NSS_STATS_TYPE_DROP}, -- {"fail_cle", NSS_STATS_TYPE_DROP}, -- {"is_stopped", NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_ipsec_cmn_strings_read() -- * Read ipsec common statistics names -- */ --static ssize_t nss_ipsec_cmn_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_ipsec_cmn_strings_stats, NSS_IPSEC_CMN_STATS_MAX); --} -- --/* -- * nss_ipsec_cmn_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(ipsec_cmn); -- --/* -- * nss_ipsec_cmn_strings_dentry_create() -- * Create ipsec common statistics strings debug entry. -- */ --void nss_ipsec_cmn_strings_dentry_create(void) --{ -- nss_strings_create_dentry("ipsec_cmn", &nss_ipsec_cmn_strings_ops); --} ---- a/nss_ipsec_cmn_strings.h -+++ /dev/null -@@ -1,27 +0,0 @@ --/* -- *************************************************************************** -- * 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. -- *************************************************************************** -- */ -- --#ifndef __NSS_IPSEC_CMN_STRINGS_H --#define __NSS_IPSEC_CMN_STRINGS_H -- --#include "nss_ipsec_cmn_stats.h" -- --extern struct nss_stats_info nss_ipsec_cmn_strings_stats[NSS_IPSEC_CMN_STATS_MAX]; --extern void nss_ipsec_cmn_strings_dentry_create(void); -- --#endif /* __NSS_IPSEC_CMN_STRINGS_H */ ---- a/nss_ipv4.c -+++ b/nss_ipv4.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2013-2020, 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. -@@ -70,20 +70,6 @@ static inline void nss_ipv4_dscp_map_usa - } - - /* -- * nss_ipv4_get_total_conn_count() -- * Returns the sum of IPv4 and IPv6 connections. -- */ --static uint32_t nss_ipv4_get_total_conn_count(int ipv4_num_conn) --{ -- --#ifdef NSS_DRV_IPV6_ENABLE -- return ipv4_num_conn + nss_ipv6_conn_cfg; --#else -- return ipv4_num_conn; --#endif --} -- --/* - * nss_ipv4_rx_msg_handler() - * Handle NSS -> HLOS messages for IPv4 bridge/route - */ -@@ -438,7 +424,7 @@ static int nss_ipv4_conn_cfg_process(str - - nss_info("%px: IPv4 supported connections: %d\n", nss_ctx, conn); - -- nss_ipv4_ct_info.ce_mem = __get_free_pages(GFP_ATOMIC | __GFP_NOWARN | __GFP_ZERO, -+ nss_ipv4_ct_info.ce_mem = __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, - get_order(nss_ipv4_ct_info.ce_table_size)); - if (!nss_ipv4_ct_info.ce_mem) { - nss_warning("%px: Memory allocation failed for IPv4 Connections: %d\n", -@@ -447,7 +433,7 @@ static int nss_ipv4_conn_cfg_process(str - goto fail; - } - -- nss_ipv4_ct_info.cme_mem = __get_free_pages(GFP_ATOMIC | __GFP_NOWARN | __GFP_ZERO, -+ nss_ipv4_ct_info.cme_mem = __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, - get_order(nss_ipv4_ct_info.cme_table_size)); - if (!nss_ipv4_ct_info.ce_mem) { - nss_warning("%px: Memory allocation failed for IPv4 Connections: %d\n", -@@ -546,8 +532,7 @@ int nss_ipv4_update_conn_count(int ipv4_ - * Min. value should be at least 256 connections. This is the - * minimum connections we will support for each of them. - */ -- sum_of_conn = nss_ipv4_get_total_conn_count(ipv4_num_conn); -- -+ sum_of_conn = ipv4_num_conn + nss_ipv6_conn_cfg; - if ((ipv4_num_conn & NSS_NUM_CONN_QUANTA_MASK) || - (sum_of_conn > NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6) || - (ipv4_num_conn < NSS_MIN_NUM_CONN)) { ---- a/nss_ipv4_log.c -+++ b/nss_ipv4_log.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016, 2018, 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016, 2018, 2020, 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. -@@ -88,9 +88,7 @@ static void nss_ipv4_log_rule_create_msg - "flow_qos_tag: %x (%u)\n" - "return_qos_tag: %x (%u)\n" - "flow_dscp: %x\n" -- "return_dscp: %x\n" -- "flow_mirror_ifnum: %u\n" -- "return_mirror_ifnum: %u\n", -+ "return_dscp: %x\n", - nim, - nircm->tuple.protocol, - nircm->conn_rule.flow_mtu, -@@ -116,9 +114,7 @@ static void nss_ipv4_log_rule_create_msg - nircm->qos_rule.flow_qos_tag, nircm->qos_rule.flow_qos_tag, - nircm->qos_rule.return_qos_tag, nircm->qos_rule.return_qos_tag, - nircm->dscp_rule.flow_dscp, -- nircm->dscp_rule.return_dscp, -- nircm->mirror_rule.flow_ifnum, -- nircm->mirror_rule.return_ifnum); -+ nircm->dscp_rule.return_dscp); - } - - /* ---- a/nss_ipv4_stats.c -+++ b/nss_ipv4_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2017, 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2017, 2019-2020, 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. -@@ -177,9 +177,6 @@ void nss_ipv4_stats_node_sync(struct nss - nss_ipv4_stats[NSS_IPV4_STATS_MC_CONNECTION_DESTROY_REQUESTS] += nins->ipv4_mc_connection_destroy_requests; - nss_ipv4_stats[NSS_IPV4_STATS_MC_CONNECTION_DESTROY_MISSES] += nins->ipv4_mc_connection_destroy_misses; - nss_ipv4_stats[NSS_IPV4_STATS_MC_CONNECTION_FLUSHES] += nins->ipv4_mc_connection_flushes; -- nss_ipv4_stats[NSS_IPV4_STATS_CONNECTION_CREATE_INVALID_MIRROR_IFNUM] += nins->ipv4_connection_create_invalid_mirror_ifnum; -- nss_ipv4_stats[NSS_IPV4_STATS_CONNECTION_CREATE_INVALID_MIRROR_IFTYPE] += nins->ipv4_connection_create_invalid_mirror_iftype; -- nss_ipv4_stats[NSS_IPV4_STATS_MIRROR_FAILURES] += nins->ipv4_mirror_failures; - - for (i = 0; i < NSS_IPV4_EXCEPTION_EVENT_MAX; i++) { - nss_ipv4_exception_stats[i] += nins->exception_events[i]; ---- a/nss_ipv4_strings.c -+++ b/nss_ipv4_strings.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -106,10 +106,10 @@ struct nss_stats_info nss_ipv4_strings_e - {"mc_pbuf_alloc_failure" , NSS_STATS_TYPE_EXCEPTION}, - {"pppoe_bridge_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"pppoe_no_session" , NSS_STATS_TYPE_DROP}, -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - {"icmp_ipv4_gre_hdr_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_ipv4_esp_hdr_incomplete" , NSS_STATS_TYPE_EXCEPTION}, -- {"emesh_prio_mismatch" , NSS_STATS_TYPE_EXCEPTION}, -- {"mc_ucast_dmac_failure" , NSS_STATS_TYPE_EXCEPTION}, -+#endif - }; - - /* -@@ -137,10 +137,7 @@ struct nss_stats_info nss_ipv4_strings_s - {"mc_create_invalid_interface" , NSS_STATS_TYPE_SPECIAL}, - {"mc_destroy_requests" , NSS_STATS_TYPE_SPECIAL}, - {"mc_destroy_misses" , NSS_STATS_TYPE_SPECIAL}, -- {"mc_flushes" , NSS_STATS_TYPE_SPECIAL}, -- {"mirror_invalid_ifnum_conn_create_req" , NSS_STATS_TYPE_SPECIAL}, -- {"mirror_invalid_iftype_conn_create_req" , NSS_STATS_TYPE_SPECIAL}, -- {"mirror_failures" , NSS_STATS_TYPE_SPECIAL}, -+ {"mc_flushes" , NSS_STATS_TYPE_SPECIAL} - }; - - /* ---- a/nss_ipv6.c -+++ b/nss_ipv6.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2020, 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. -@@ -428,7 +428,7 @@ static int nss_ipv6_conn_cfg_process(str - - nss_info("%px: IPv6 supported connections: %d\n", nss_ctx, conn); - -- nss_ipv6_ct_info.ce_mem = __get_free_pages(GFP_ATOMIC | __GFP_NOWARN | __GFP_ZERO, -+ nss_ipv6_ct_info.ce_mem = __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, - get_order(nss_ipv6_ct_info.ce_table_size)); - if (!nss_ipv6_ct_info.ce_mem) { - nss_warning("%px: Memory allocation failed for IPv6 Connections: %d\n", -@@ -440,7 +440,7 @@ static int nss_ipv6_conn_cfg_process(str - nss_ctx, - conn); - -- nss_ipv6_ct_info.cme_mem = __get_free_pages(GFP_ATOMIC | __GFP_NOWARN | __GFP_ZERO, -+ nss_ipv6_ct_info.cme_mem = __get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, - get_order(nss_ipv6_ct_info.cme_table_size)); - if (!nss_ipv6_ct_info.cme_mem) { - nss_warning("%px: Memory allocation failed for IPv6 Connections: %d\n", ---- a/nss_ipv6_log.c -+++ b/nss_ipv6_log.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016, 2018, 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016, 2018, 2020, 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. -@@ -103,9 +103,7 @@ static void nss_ipv6_log_rule_create_msg - "flow_qos_tag: %x (%u)\n" - "return_qos_tag: %x (%u)\n" - "flow_dscp: %x\n" -- "return_dscp: %x\n" -- "flow_mirror_ifnum: %u\n" -- "return_mirror_ifnum: %u\n", -+ "return_dscp: %x\n", - nim, - nircm->tuple.protocol, - nircm->conn_rule.flow_mtu, -@@ -129,9 +127,7 @@ static void nss_ipv6_log_rule_create_msg - nircm->qos_rule.flow_qos_tag, nircm->qos_rule.flow_qos_tag, - nircm->qos_rule.return_qos_tag, nircm->qos_rule.return_qos_tag, - nircm->dscp_rule.flow_dscp, -- nircm->dscp_rule.return_dscp, -- nircm->mirror_rule.flow_ifnum, -- nircm->mirror_rule.return_ifnum); -+ nircm->dscp_rule.return_dscp); - } - - /* ---- a/nss_ipv6_stats.c -+++ b/nss_ipv6_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2017, 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2017, 2019-2020, 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. -@@ -180,9 +180,6 @@ void nss_ipv6_stats_node_sync(struct nss - nss_ipv6_stats[NSS_IPV6_STATS_MC_CONNECTION_DESTROY_REQUESTS] += nins->ipv6_mc_connection_destroy_requests; - nss_ipv6_stats[NSS_IPV6_STATS_MC_CONNECTION_DESTROY_MISSES] += nins->ipv6_mc_connection_destroy_misses; - nss_ipv6_stats[NSS_IPV6_STATS_MC_CONNECTION_FLUSHES] += nins->ipv6_mc_connection_flushes; -- nss_ipv6_stats[NSS_IPV6_STATS_CONNECTION_CREATE_INVALID_MIRROR_IFNUM] += nins->ipv6_connection_create_invalid_mirror_ifnum; -- nss_ipv6_stats[NSS_IPV6_STATS_CONNECTION_CREATE_INVALID_MIRROR_IFTYPE] += nins->ipv6_connection_create_invalid_mirror_iftype; -- nss_ipv6_stats[NSS_IPV6_STATS_MIRROR_FAILURES] += nins->ipv6_mirror_failures; - - for (i = 0; i < NSS_IPV6_EXCEPTION_EVENT_MAX; i++) { - nss_ipv6_exception_stats[i] += nins->exception_events[i]; ---- a/nss_ipv6_strings.c -+++ b/nss_ipv6_strings.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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 -@@ -81,12 +81,14 @@ struct nss_stats_info nss_ipv6_strings_e - {"tunipip6_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, - {"pppoe_bridge_no_icme" , NSS_STATS_TYPE_EXCEPTION}, - {"dont_frag_set" , NSS_STATS_TYPE_EXCEPTION}, -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - {"reassembly_not_supported" , NSS_STATS_TYPE_EXCEPTION}, - {"pppoe_no_session" , NSS_STATS_TYPE_DROP}, - {"icmp_gre_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, - {"icmp_esp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, -- {"emesh_prio_mismatch" , NSS_STATS_TYPE_EXCEPTION}, -- {"mc_ucast_dmac_failure" , NSS_STATS_TYPE_EXCEPTION}, -+#else -+ {"pppoe_no_session" , NSS_STATS_TYPE_DROP}, -+#endif - }; - - /* -@@ -115,10 +117,7 @@ struct nss_stats_info nss_ipv6_strings_s - {"mc_create_invalid_interface" ,NSS_STATS_TYPE_SPECIAL}, - {"mc_destroy_requests" ,NSS_STATS_TYPE_SPECIAL}, - {"mc_destroy_misses" ,NSS_STATS_TYPE_SPECIAL}, -- {"mc_flushes" ,NSS_STATS_TYPE_SPECIAL}, -- {"mirror_invalid_ifnum_conn_create_req" ,NSS_STATS_TYPE_SPECIAL}, -- {"mirror_invalid_iftype_conn_create_req" ,NSS_STATS_TYPE_SPECIAL}, -- {"mirror_failures" ,NSS_STATS_TYPE_SPECIAL}, -+ {"mc_flushes" ,NSS_STATS_TYPE_SPECIAL} - }; - - /* ---- a/nss_map_t_stats.c -+++ b/nss_map_t_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017,2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017,2019-2020, 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. -@@ -60,7 +60,7 @@ static ssize_t nss_map_t_stats_read(stru - for (id = 0; id < NSS_MAX_MAP_T_DYNAMIC_INTERFACES; id++) { - - if (!map_t_instance_stats[id].valid) { -- continue; -+ break; - } - - dev = dev_get_by_index(&init_net, map_t_instance_stats[id].if_index); ---- a/nss_match.c -+++ b/nss_match.c -@@ -1,6 +1,6 @@ - /* - *************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -23,7 +23,6 @@ - #include "nss_tx_rx_common.h" - #include "nss_match_log.h" - #include "nss_match_stats.h" --#include "nss_match_strings.h" - - #define NSS_MATCH_TX_TIMEOUT 1000 /* 1 Seconds */ - -@@ -149,7 +148,6 @@ static void nss_match_handler(struct nss - * Update common node statistics - */ - nss_match_stats_sync(nss_ctx, nem); -- nss_match_stats_notify(nss_ctx, nem->cm.interface); - } - - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { -@@ -211,10 +209,10 @@ nss_tx_status_t nss_match_msg_tx_sync(st - EXPORT_SYMBOL(nss_match_msg_tx_sync); - - /* -- * nss_match_unregister_instance() -- * Unregisters match instance. -+ * nss_match_register_instance() -+ * Registers match instance. - */ --bool nss_match_unregister_instance(int if_num) -+struct nss_ctx_instance *nss_match_register_instance(int if_num, nss_match_msg_sync_callback_t notify_cb) - { - struct nss_ctx_instance *nss_ctx; - uint32_t status; -@@ -224,27 +222,32 @@ bool nss_match_unregister_instance(int i - - if (!nss_match_verify_if_num(if_num)) { - nss_warning("%px: Incorrect interface number: %d", nss_ctx, if_num); -- return false; -+ return NULL; - } - -- nss_core_unregister_handler(nss_ctx, if_num); -- status = nss_core_unregister_msg_handler(nss_ctx, if_num); -+ nss_core_register_handler(nss_ctx, if_num, nss_match_handler, NULL); -+ status = nss_core_register_msg_handler(nss_ctx, if_num, (nss_if_rx_msg_callback_t)notify_cb); - if (status != NSS_CORE_STATUS_SUCCESS) { -- nss_warning("%px: Not able to unregister handler for interface %d with NSS core\n", nss_ctx, if_num); -- return false; -+ nss_warning("%px: Not able to register handler for interface %d with NSS core\n", nss_ctx, if_num); -+ return NULL; - } - -- nss_match_ifnum_delete(if_num); -+ if (!nss_match_ifnum_add(if_num)) { -+ nss_warning("%px: Unable to add match inteface : %u\n", nss_ctx, if_num); -+ nss_core_unregister_handler(nss_ctx, if_num); -+ nss_core_unregister_msg_handler(nss_ctx, if_num); -+ return NULL; -+ } - -- return true; -+ return nss_ctx; - } --EXPORT_SYMBOL(nss_match_unregister_instance); -+EXPORT_SYMBOL(nss_match_register_instance); - - /* -- * nss_match_register_instance() -- * Registers match instance. -+ * nss_match_unregister_instance() -+ * Unregisters match instance. - */ --struct nss_ctx_instance *nss_match_register_instance(int if_num, nss_match_msg_sync_callback_t notify_cb) -+bool nss_match_unregister_instance(int if_num) - { - struct nss_ctx_instance *nss_ctx; - uint32_t status; -@@ -254,26 +257,21 @@ struct nss_ctx_instance *nss_match_regis - - if (!nss_match_verify_if_num(if_num)) { - nss_warning("%px: Incorrect interface number: %d", nss_ctx, if_num); -- return NULL; -+ return false; - } - -- nss_core_register_handler(nss_ctx, if_num, nss_match_handler, NULL); -- status = nss_core_register_msg_handler(nss_ctx, if_num, (nss_if_rx_msg_callback_t)notify_cb); -+ nss_core_unregister_handler(nss_ctx, if_num); -+ status = nss_core_unregister_msg_handler(nss_ctx, if_num); - if (status != NSS_CORE_STATUS_SUCCESS) { -- nss_warning("%px: Not able to register handler for interface %d with NSS core\n", nss_ctx, if_num); -- return NULL; -+ nss_warning("%px: Not able to unregister handler for interface %d with NSS core\n", nss_ctx, if_num); -+ return false; - } - -- if (!nss_match_ifnum_add(if_num)) { -- nss_warning("%px: Unable to add match inteface : %u\n", nss_ctx, if_num); -- nss_core_unregister_handler(nss_ctx, if_num); -- nss_core_unregister_msg_handler(nss_ctx, if_num); -- return NULL; -- } -+ nss_match_ifnum_delete(if_num); - -- return nss_ctx; -+ return true; - } --EXPORT_SYMBOL(nss_match_register_instance); -+EXPORT_SYMBOL(nss_match_unregister_instance); - - /* - * nss_match_msg_init() -@@ -293,7 +291,6 @@ EXPORT_SYMBOL(nss_match_msg_init); - void nss_match_init() - { - nss_match_stats_dentry_create(); -- nss_match_strings_dentry_create(); - sema_init(&match_pvt.sem, 1); - init_completion(&match_pvt.complete); - } ---- a/nss_match_stats.c -+++ b/nss_match_stats.c -@@ -1,6 +1,6 @@ - /* - *************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -23,123 +23,21 @@ - #include "nss_stats.h" - #include - #include "nss_match_stats.h" --#include "nss_match_strings.h" - - #define NSS_MATCH_STATS_SIZE_PER_IF (NSS_STATS_MAX_STR_LENGTH * NSS_STATS_NODE_MAX) - /* Total number of statistics per match interface. */ - - int match_ifnum[NSS_MATCH_INSTANCE_MAX] = {0}; --uint64_t nss_match_stats[NSS_MATCH_INSTANCE_MAX][NSS_MATCH_STATS_MAX]; - static DEFINE_SPINLOCK(nss_match_stats_lock); - - /* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_match_stats_notifier); -- --/* -- * nss_match_stats_read() -- * Read match node statiistics. -- */ --static ssize_t nss_match_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- /* -- * Max output lines = #stats + -- * few blank lines for banner printing + Number of Extra outputlines -- * for future reference to add new stats -- */ -- uint32_t max_output_lines = NSS_MATCH_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines * NSS_MATCH_INSTANCE_MAX; -- ssize_t bytes_read = 0; -- size_t size_wr = 0; -- uint32_t if_num; -- int index; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(!lbuf)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -- -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "match stats", NSS_STATS_SINGLE_CORE); -- -- /* -- * Common node stats for each match dynamic interface. -- */ -- for (index = 0; index < NSS_MATCH_INSTANCE_MAX; index++) { -- -- spin_lock_bh(&nss_match_stats_lock); -- if_num = match_ifnum[index]; -- spin_unlock_bh(&nss_match_stats_lock); -- -- if (if_num) { -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nMatch node if_num:%03u", if_num); -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n ---------------------- \n"); -- size_wr += nss_stats_print("match", NULL, NSS_STATS_SINGLE_INSTANCE, nss_match_strings_stats, -- nss_match_stats[index], NSS_MATCH_STATS_MAX, lbuf, size_wr, size_al); -- continue; -- } -- } -- -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- kfree(lbuf); -- return bytes_read; --} -- -- --/* -- * nss_match_stats_sync() -- * Update match common node statistics. -- */ --void nss_match_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_match_msg *nmm) --{ -- struct nss_match_stats_sync *ndccs = &nmm->msg.stats; -- uint64_t *ctx_stats; -- uint32_t *msg_stats; -- uint32_t if_num; -- uint16_t i = 0; -- int index; -- -- for (index = 0; index < NSS_MATCH_INSTANCE_MAX; index++) { -- spin_lock_bh(&nss_match_stats_lock); -- if_num = match_ifnum[index]; -- spin_unlock_bh(&nss_match_stats_lock); -- -- if (if_num == nmm->cm.interface) { -- break; -- } -- } -- -- if (index == NSS_MATCH_INSTANCE_MAX) { -- nss_warning("Invalid Match index\n"); -- return; -- } -- -- spin_lock_bh(&nss_match_stats_lock); -- msg_stats = (uint32_t *)ndccs; -- ctx_stats = nss_match_stats[index]; -- -- for (i = 0; i < NSS_MATCH_STATS_MAX; i++, ctx_stats++, msg_stats++) { -- *ctx_stats += *msg_stats; -- } -- -- spin_unlock_bh(&nss_match_stats_lock); --} -- --/* -- * nss_match_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(match) -- --/* - * nss_match_ifnum_add() -- * Add match node interface ID. - */ - bool nss_match_ifnum_add(int if_num) - { - int index = 0; - -- spin_lock_bh(&nss_match_stats_lock); -+ spin_lock(&nss_match_stats_lock); - - for (index = 0; index < NSS_MATCH_INSTANCE_MAX; index++) { - if (match_ifnum[index]) { -@@ -148,23 +46,22 @@ bool nss_match_ifnum_add(int if_num) - - match_ifnum[index] = if_num; - -- spin_unlock_bh(&nss_match_stats_lock); -+ spin_unlock(&nss_match_stats_lock); - return true; - } - -- spin_unlock_bh(&nss_match_stats_lock); -+ spin_unlock(&nss_match_stats_lock); - return false; - } - - /* - * nss_match_ifnum_delete() -- * Delete match node interface ID. - */ - bool nss_match_ifnum_delete(int if_num) - { - int index = 0; - -- spin_lock_bh(&nss_match_stats_lock); -+ spin_lock(&nss_match_stats_lock); - - for (index = 0; index < NSS_MATCH_INSTANCE_MAX; index++) { - if (match_ifnum[index] != if_num) { -@@ -173,67 +70,91 @@ bool nss_match_ifnum_delete(int if_num) - - match_ifnum[index] = 0; - -- spin_unlock_bh(&nss_match_stats_lock); -+ spin_unlock(&nss_match_stats_lock); - return true; - } - -- spin_unlock_bh(&nss_match_stats_lock); -+ spin_unlock(&nss_match_stats_lock); - return false; - } - -+ - /* -- * nss_match_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -+ * nss_match_stats_read() -+ * Read match node statiistics. - */ --void nss_match_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) -+static ssize_t nss_match_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) - { -- struct nss_match_stats_notification match_stats; -- uint32_t interface; -- int index; -+ ssize_t bytes_read = 0; -+ uint32_t index, if_num; -+ char *lbuf; -+ size_t size_al = NSS_MATCH_STATS_SIZE_PER_IF * NSS_MATCH_INSTANCE_MAX; -+ size_t size_wr = 0; - -- match_stats.core_id = nss_ctx->id; -- match_stats.if_num = if_num; -+ lbuf = kzalloc(size_al, GFP_KERNEL); -+ if (!lbuf) { -+ nss_warning("Could not allocate memory for local statistics buffer\n"); -+ return 0; -+ } - -+ size_wr += nss_stats_banner(lbuf, size_wr, size_al, "match", NSS_STATS_SINGLE_CORE); -+ -+ /* -+ * Common node stats for each match dynamic interface. -+ */ - for (index = 0; index < NSS_MATCH_INSTANCE_MAX; index++) { -+ - spin_lock_bh(&nss_match_stats_lock); -- interface = match_ifnum[index]; -+ if_num = match_ifnum[index]; - spin_unlock_bh(&nss_match_stats_lock); - -- if (interface == if_num) { -- break; -+ if (if_num) { -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nMatch node if_num:%03u", if_num); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n ---------------------- \n"); -+ size_wr += nss_stats_fill_common_stats(if_num, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "match"); -+ continue; - } - } - -- if (index == NSS_MATCH_INSTANCE_MAX) { -- nss_warning("Invalid Match index\n"); -- return; -- } -- -- spin_lock_bh(&nss_match_stats_lock); -- memcpy(match_stats.stats_ctx, nss_match_stats[index], sizeof(match_stats.stats_ctx)); -- spin_unlock_bh(&nss_match_stats_lock); -- atomic_notifier_call_chain(&nss_match_stats_notifier, NSS_STATS_EVENT_NOTIFY, &match_stats); -+ bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -+ kfree(lbuf); -+ return bytes_read; - } - -+ - /* -- * nss_match_stats_unregister_notifier() -- * Deregisters statistics notifier. -+ * nss_match_stats_sync() -+ * Update match common node statistics. - */ --int nss_match_stats_unregister_notifier(struct notifier_block *nb) -+void nss_match_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_match_msg *nmm) - { -- return atomic_notifier_chain_unregister(&nss_match_stats_notifier, nb); -+ struct nss_top_instance *nss_top = nss_ctx->nss_top; -+ struct nss_match_stats_sync *msg_stats = &nmm->msg.stats; -+ uint64_t *if_stats; -+ int index; -+ -+ spin_lock_bh(&nss_top->stats_lock); -+ -+ /* -+ * Update common node stats -+ */ -+ if_stats = nss_top->stats_node[nmm->cm.interface]; -+ if_stats[NSS_STATS_NODE_RX_PKTS] += msg_stats->p_stats.rx_packets; -+ if_stats[NSS_STATS_NODE_RX_BYTES] += msg_stats->p_stats.rx_bytes; -+ if_stats[NSS_STATS_NODE_TX_PKTS] += msg_stats->p_stats.tx_packets; -+ if_stats[NSS_STATS_NODE_TX_BYTES] += msg_stats->p_stats.tx_bytes; -+ -+ for (index = 0; index < NSS_MAX_NUM_PRI; index++) { -+ if_stats[NSS_STATS_NODE_RX_QUEUE_0_DROPPED + index] += msg_stats->p_stats.rx_dropped[index]; -+ } -+ -+ spin_unlock_bh(&nss_top->stats_lock); - } - - /* -- * nss_match_stats_register_notifier() -- * Registers statistics notifier. -+ * nss_match_stats_ops - */ --int nss_match_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_match_stats_notifier, nb); --} -+NSS_STATS_DECLARE_FILE_OPERATIONS(match) - - /* - * nss_match_stats_dentry_create() ---- a/nss_match_stats.h -+++ b/nss_match_stats.h -@@ -1,6 +1,6 @@ - /* - *************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -19,63 +19,9 @@ - #ifndef __NSS_MATCH_STATS_H__ - #define __NSS_MATCH_STATS_H__ - --/** -- * nss_match_stats_types -- * Match statistics types. -- */ --enum nss_match_stats_types { -- NSS_MATCH_STATS_HIT_COUNT_0 = NSS_STATS_NODE_MAX, -- /**< Hit count of rule ID 1. */ -- NSS_MATCH_STATS_HIT_COUNT_1, /**< Hit count of rule ID 2. */ -- NSS_MATCH_STATS_HIT_COUNT_2, /**< Hit count of rule ID 3. */ -- NSS_MATCH_STATS_HIT_COUNT_3, /**< Hit count of rule ID 4. */ -- NSS_MATCH_STATS_HIT_COUNT_4, /**< Hit count of rule ID 5. */ -- NSS_MATCH_STATS_HIT_COUNT_5, /**< Hit count of rule ID 6. */ -- NSS_MATCH_STATS_HIT_COUNT_6, /**< Hit count of rule ID 7. */ -- NSS_MATCH_STATS_HIT_COUNT_7, /**< Hit count of rule ID 8. */ -- NSS_MATCH_STATS_HIT_COUNT_8, /**< Hit count of rule ID 9. */ -- NSS_MATCH_STATS_HIT_COUNT_9, /**< Hit count of rule ID 10. */ -- NSS_MATCH_STATS_HIT_COUNT_10, /**< Hit count of rule ID 11. */ -- NSS_MATCH_STATS_HIT_COUNT_11, /**< Hit count of rule ID 12. */ -- NSS_MATCH_STATS_HIT_COUNT_12, /**< Hit count of rule ID 13. */ -- NSS_MATCH_STATS_HIT_COUNT_13, /**< Hit count of rule ID 14. */ -- NSS_MATCH_STATS_HIT_COUNT_14, /**< Hit count of rule ID 15. */ -- NSS_MATCH_STATS_HIT_COUNT_15, /**< Hit count of rule ID 16. */ -- NSS_MATCH_STATS_HIT_COUNT_16, /**< Hit count of rule ID 17. */ -- NSS_MATCH_STATS_HIT_COUNT_17, /**< Hit count of rule ID 18. */ -- NSS_MATCH_STATS_HIT_COUNT_18, /**< Hit count of rule ID 19. */ -- NSS_MATCH_STATS_HIT_COUNT_19, /**< Hit count of rule ID 20. */ -- NSS_MATCH_STATS_HIT_COUNT_20, /**< Hit count of rule ID 21. */ -- NSS_MATCH_STATS_HIT_COUNT_21, /**< Hit count of rule ID 22. */ -- NSS_MATCH_STATS_HIT_COUNT_22, /**< Hit count of rule ID 23. */ -- NSS_MATCH_STATS_HIT_COUNT_23, /**< Hit count of rule ID 24. */ -- NSS_MATCH_STATS_HIT_COUNT_24, /**< Hit count of rule ID 25. */ -- NSS_MATCH_STATS_HIT_COUNT_25, /**< Hit count of rule ID 26. */ -- NSS_MATCH_STATS_HIT_COUNT_26, /**< Hit count of rule ID 27. */ -- NSS_MATCH_STATS_HIT_COUNT_27, /**< Hit count of rule ID 28. */ -- NSS_MATCH_STATS_HIT_COUNT_28, /**< Hit count of rule ID 29. */ -- NSS_MATCH_STATS_HIT_COUNT_29, /**< Hit count of rule ID 30. */ -- NSS_MATCH_STATS_HIT_COUNT_30, /**< Hit count of rule ID 31. */ -- NSS_MATCH_STATS_HIT_COUNT_31, /**< Hit count of rule ID 32. */ -- NSS_MATCH_STATS_MAX, /**< Maximum statistics type. */ --}; -- --/** -- * nss_match_stats_notification -- * Match transmission statistics structure. -- */ --struct nss_match_stats_notification { -- uint64_t stats_ctx[NSS_MATCH_STATS_MAX]; /**< Context transmission statistics. */ -- uint32_t core_id; /**< Core ID. */ -- uint32_t if_num; /**< Interface number. */ --}; -- - extern bool nss_match_ifnum_add(int if_num); - extern bool nss_match_ifnum_delete(int if_num); --extern void nss_match_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); - extern void nss_match_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_match_msg *nmm); - extern void nss_match_stats_dentry_create(void); --extern int nss_match_stats_unregister_notifier(struct notifier_block *nb); --extern int nss_match_stats_register_notifier(struct notifier_block *nb); - - #endif /* __NSS_MATCH_STATS_H__ */ ---- a/nss_match_strings.c -+++ /dev/null -@@ -1,92 +0,0 @@ --/* -- *************************************************************************** -- * 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_strings.h" --#include "nss_match_strings.h" -- --/* -- * nss_match_strings_stats -- * match statistics strings. -- */ --struct nss_stats_info nss_match_strings_stats[NSS_MATCH_STATS_MAX] = { -- {"rx_pkts", NSS_STATS_TYPE_COMMON}, -- {"rx_byts", NSS_STATS_TYPE_COMMON}, -- {"tx_pkts", NSS_STATS_TYPE_COMMON}, -- {"tx_byts", NSS_STATS_TYPE_COMMON}, -- {"rx_queue[0]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[1]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[2]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[3]_drops", NSS_STATS_TYPE_DROP}, -- {"hit_count[0]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[1]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[2]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[3]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[4]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[5]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[6]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[7]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[8]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[9]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[10]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[11]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[12]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[13]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[14]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[15]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[16]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[17]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[18]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[19]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[20]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[21]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[22]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[23]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[24]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[25]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[26]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[27]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[28]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[29]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[30]", NSS_STATS_TYPE_SPECIAL}, -- {"hit_count[31]", NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_match_stats_strings_read() -- * Read match statistics names -- */ --static ssize_t nss_match_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_match_strings_stats, NSS_MATCH_STATS_MAX); --} -- --/* -- * nss_match_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(match); -- --/* -- * nss_match_strings_dentry_create() -- * Create match statistics strings debug entry. -- */ --void nss_match_strings_dentry_create(void) --{ -- nss_strings_create_dentry("match", &nss_match_strings_ops); --} ---- a/nss_match_strings.h -+++ /dev/null -@@ -1,27 +0,0 @@ --/* -- *************************************************************************** -- * 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. -- *************************************************************************** -- */ -- --#ifndef __NSS_MATCH_STRINGS_H --#define __NSS_MATCH_STRINGS_H -- --#include "nss_match_stats.h" -- --extern struct nss_stats_info nss_match_strings_stats[NSS_MATCH_STATS_MAX]; --extern void nss_match_strings_dentry_create(void); -- --#endif /* __NSS_MATCH_STRINGS_H */ ---- a/nss_meminfo.c -+++ b/nss_meminfo.c -@@ -735,7 +735,7 @@ bool nss_meminfo_init(struct nss_ctx_ins - /* - * meminfo_start is the label where the start address of meminfo map is stored. - */ -- meminfo_start = (uint32_t *)ioremap_nocache(nss_ctx->load + NSS_MEMINFO_MAP_START_OFFSET, -+ meminfo_start = (uint32_t *)ioremap(nss_ctx->load + NSS_MEMINFO_MAP_START_OFFSET, - NSS_MEMINFO_RESERVE_AREA_SIZE); - if (!meminfo_start) { - nss_info_always("%px: cannot remap meminfo start\n", nss_ctx); ---- a/nss_mirror.c -+++ b/nss_mirror.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -18,7 +18,6 @@ - - #include "nss_tx_rx_common.h" - #include "nss_mirror_stats.h" --#include "nss_mirror_strings.h" - #include "nss_mirror_log.h" - - #define NSS_MIRROR_TX_TIMEOUT 3000 /* 3 Seconds */ -@@ -90,7 +89,6 @@ static void nss_mirror_handler(struct ns - * Debug stats embedded in stats msg. - */ - nss_mirror_stats_sync(nss_ctx, nmm, ncm->interface); -- nss_mirror_stats_notify(nss_ctx, ncm->interface); - break; - } - -@@ -292,5 +290,4 @@ void nss_mirror_register_handler(void) - init_completion(&nss_mirror_pvt.complete); - - nss_mirror_stats_dentry_create(); -- nss_mirror_strings_dentry_create(); - } ---- a/nss_mirror_stats.c -+++ b/nss_mirror_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -18,19 +18,28 @@ - - #include "nss_stats.h" - #include "nss_core.h" --#include "nss_mirror.h" - #include "nss_mirror_stats.h" --#include "nss_mirror_strings.h" - - static struct nss_mirror_stats_debug_instance *stats_db[NSS_MAX_MIRROR_DYNAMIC_INTERFACES]; - /* Mirror stats data structure. */ - - /* -- * Atomic notifier data structure for statistics -+ * Data structures to store mirror interface stats. - */ --ATOMIC_NOTIFIER_HEAD(nss_mirror_stats_notifier); -+static DEFINE_SPINLOCK(nss_mirror_stats_debug_lock); - --static DEFINE_SPINLOCK(nss_mirror_stats_lock); -+/* -+ * nss_mirror_stats_str -+ * Mirror statistics strings for nss session stats. -+ */ -+struct nss_stats_info nss_mirror_stats_str[NSS_MIRROR_STATS_MAX] = { -+ {"MIRROR_STATS_PKTS" , NSS_STATS_TYPE_SPECIAL}, -+ {"MIRROR_STATS_BYTES" , NSS_STATS_TYPE_SPECIAL}, -+ {"MIRROR_STATS_TX_FAIL" , NSS_STATS_TYPE_DROP}, -+ {"MIRROR_STATS_DEST_LOOKUP_FAIL" , NSS_STATS_TYPE_DROP}, -+ {"MIRROR_STATS_MEM_ALLOC_FAIL" , NSS_STATS_TYPE_ERROR}, -+ {"MIRROR_STATS_COPY_FAIL" , NSS_STATS_TYPE_ERROR}, -+}; - - /* - * nss_mirror_stats_get() -@@ -46,7 +55,7 @@ static void nss_mirror_stats_get(void *s - return; - } - -- spin_lock_bh(&nss_mirror_stats_lock); -+ spin_lock_bh(&nss_mirror_stats_debug_lock); - for (i = 0; i < NSS_MAX_MIRROR_DYNAMIC_INTERFACES; i++) { - - /* -@@ -62,7 +71,7 @@ static void nss_mirror_stats_get(void *s - } - } - } -- spin_unlock_bh(&nss_mirror_stats_lock); -+ spin_unlock_bh(&nss_mirror_stats_debug_lock); - } - - /* -@@ -106,7 +115,7 @@ static ssize_t nss_mirror_stats_read(str - * Get all stats - */ - nss_mirror_stats_get((void *)mirror_shadow_stats, mirror_active_instances); -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "mirror stats", NSS_STATS_SINGLE_CORE); -+ size_wr += nss_stats_banner(lbuf, size_wr, size_al, "mirror", NSS_STATS_SINGLE_CORE); - - /* - * Session stats -@@ -128,12 +137,13 @@ static ssize_t nss_mirror_stats_read(str - /* - * Mirror interface exception stats. - */ -- size_wr += nss_stats_print("mirror", "mirror exception stats", -+ size_wr += nss_stats_print("mirror", "mirror exception stats start", - id, -- nss_mirror_strings_stats, -+ nss_mirror_stats_str, - mirror_shadow_stats[id].stats, - NSS_MIRROR_STATS_MAX, - lbuf, size_wr, size_al); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - } - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); -@@ -156,7 +166,7 @@ void nss_mirror_stats_sync(struct nss_ct - struct nss_cmn_node_stats *node_stats_ptr = &stats_msg->node_stats; - uint32_t *mirror_stats_ptr = (uint32_t *)&stats_msg->mirror_stats; - -- spin_lock_bh(&nss_mirror_stats_lock); -+ spin_lock_bh(&nss_mirror_stats_debug_lock); - for (i = 0; i < NSS_MAX_MIRROR_DYNAMIC_INTERFACES; i++) { - if (!stats_db[i] || (stats_db[i]->if_num != if_num)) { - continue; -@@ -168,16 +178,16 @@ void nss_mirror_stats_sync(struct nss_ct - */ - stats_db[i]->stats[j] += mirror_stats_ptr[j]; - } -- spin_unlock_bh(&nss_mirror_stats_lock); -+ spin_unlock_bh(&nss_mirror_stats_debug_lock); - goto sync_cmn_stats; - } - -- spin_unlock_bh(&nss_mirror_stats_lock); - nss_warning("Invalid mirror stats sync message received for %d interface\n", if_num); -+ spin_unlock_bh(&nss_mirror_stats_debug_lock); - return; - - sync_cmn_stats: -- spin_lock_bh(&nss_mirror_stats_lock); -+ spin_lock_bh(&nss_top->stats_lock); - - /* - * Sync common stats. -@@ -192,7 +202,7 @@ sync_cmn_stats: - node_stats_ptr->rx_dropped[i]; - } - -- spin_unlock_bh(&nss_mirror_stats_lock); -+ spin_unlock_bh(&nss_top->stats_lock); - } - - /* -@@ -212,7 +222,7 @@ void nss_mirror_stats_reset(uint32_t if_ - /* - * Reset mirror stats. - */ -- spin_lock_bh(&nss_mirror_stats_lock); -+ spin_lock_bh(&nss_mirror_stats_debug_lock); - for (i = 0; i < NSS_MAX_MIRROR_DYNAMIC_INTERFACES; i++) { - if (!stats_db[i] || (stats_db[i]->if_num != if_num)) { - continue; -@@ -222,7 +232,7 @@ void nss_mirror_stats_reset(uint32_t if_ - stats_db[i] = NULL; - break; - } -- spin_unlock_bh(&nss_mirror_stats_lock); -+ spin_unlock_bh(&nss_mirror_stats_debug_lock); - - if (mirror_debug_instance) { - vfree(mirror_debug_instance); -@@ -245,7 +255,7 @@ int nss_mirror_stats_init(uint32_t if_nu - return -1; - } - -- spin_lock_bh(&nss_mirror_stats_lock); -+ spin_lock_bh(&nss_mirror_stats_debug_lock); - for (i = 0; i < NSS_MAX_MIRROR_DYNAMIC_INTERFACES; i++) { - if (stats_db[i] != NULL) { - continue; -@@ -254,10 +264,10 @@ int nss_mirror_stats_init(uint32_t if_nu - stats_db[i] = mirror_debug_instance; - stats_db[i]->if_num = if_num; - stats_db[i]->if_index = netdev->ifindex; -- spin_unlock_bh(&nss_mirror_stats_lock); -+ spin_unlock_bh(&nss_mirror_stats_debug_lock); - return 0; - } -- spin_unlock_bh(&nss_mirror_stats_lock); -+ spin_unlock_bh(&nss_mirror_stats_debug_lock); - vfree(mirror_debug_instance); - return -1; - } -@@ -275,50 +285,3 @@ void nss_mirror_stats_dentry_create(void - { - nss_stats_create_dentry("mirror", &nss_mirror_stats_ops); - } -- --/* -- * nss_mirror_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_mirror_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_mirror_stats_notification mirror_stats; -- int i; -- -- spin_lock_bh(&nss_mirror_stats_lock); -- for (i = 0; i < NSS_MAX_MIRROR_DYNAMIC_INTERFACES; i++) { -- if (!stats_db[i] || (stats_db[i]->if_num != if_num)) { -- continue; -- } -- -- memcpy(mirror_stats.stats_ctx, stats_db[i]->stats, sizeof(mirror_stats.stats_ctx)); -- mirror_stats.core_id = nss_ctx->id; -- mirror_stats.if_num = if_num; -- spin_unlock_bh(&nss_mirror_stats_lock); -- atomic_notifier_call_chain(&nss_mirror_stats_notifier, NSS_STATS_EVENT_NOTIFY, &mirror_stats); -- return; -- } -- spin_unlock_bh(&nss_mirror_stats_lock); --} -- --/* -- * nss_mirror_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_mirror_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_mirror_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_mirror_stats_unregister_notifier); -- --/* -- * nss_mirror_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_mirror_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_mirror_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_mirror_stats_register_notifier); ---- a/nss_mirror_stats.h -+++ b/nss_mirror_stats.h -@@ -1,6 +1,6 @@ - /* - ****************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -25,6 +25,20 @@ - extern atomic_t nss_mirror_num_instances; - - /* -+ * nss_mirror_stats -+ * Mirror interface debug statistics. -+ */ -+enum nss_mirror_stats { -+ NSS_MIRROR_STATS_PKTS, /* Number of packets exceptioned to host. */ -+ NSS_MIRROR_STATS_BYTES, /* Number of bytes exceptioned to host. */ -+ NSS_MIRROR_STATS_TX_SEND_FAIL, /* Transmit send failures. */ -+ NSS_MIRROR_STATS_DEST_LOOKUP_FAIL, /* Destination lookup failures. */ -+ NSS_MIRROR_STATS_MEM_ALLOC_FAIL, /* Memory allocation failures. */ -+ NSS_MIRROR_STATS_COPY_FAIL, /* Copy failures. */ -+ NSS_MIRROR_STATS_MAX /* Maximum statistics count. */ -+}; -+ -+/* - * nss_mirror_stats_debug_instance - * Stucture for H2N/N2H mirror interface debug stats. - */ -@@ -34,11 +48,29 @@ struct nss_mirror_stats_debug_instance { - uint32_t if_num; /* Mirror instance NSS interface number */ - }; - -+/* -+ * nss_mirror_stats_sync() -+ * API to sync statistics for mirror interface. -+ */ - extern void nss_mirror_stats_sync(struct nss_ctx_instance *nss_ctx, - struct nss_mirror_msg *nmm, uint16_t if_num); -+ -+/* -+ * nss_mirror_stats_reset() -+ * API to reset the mirror interface stats. -+ */ - extern void nss_mirror_stats_reset(uint32_t if_num); -+ -+/* -+ * nss_mirror_stats_init() -+ * API to initialize mirror debug instance statistics. -+ */ - extern int nss_mirror_stats_init(uint32_t if_num, struct net_device *netdev); -+ -+/* -+ * nss_mirror_stats_dentry_create() -+ * Create mirror interface statistics debug entry. -+ */ - extern void nss_mirror_stats_dentry_create(void); --extern void nss_mirror_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); - - #endif /* __NSS_MIRROR_STATS_H */ ---- a/nss_mirror_strings.c -+++ /dev/null -@@ -1,58 +0,0 @@ --/* -- *************************************************************************** -- * 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_strings.h" --#include "nss_mirror_strings.h" -- --/* -- * nss_mirror_strings_stats -- * Mirror statistics strings for nss session stats. -- */ --struct nss_stats_info nss_mirror_strings_stats[NSS_MIRROR_STATS_MAX] = { -- {"pkts", NSS_STATS_TYPE_SPECIAL}, -- {"bytes", NSS_STATS_TYPE_SPECIAL}, -- {"tx_fail", NSS_STATS_TYPE_DROP}, -- {"dest_lookup_fail", NSS_STATS_TYPE_DROP}, -- {"mem_alloc_fail", NSS_STATS_TYPE_ERROR}, -- {"copy_fail", NSS_STATS_TYPE_ERROR}, --}; -- --/* -- * nss_mirror_strings_read() -- * Read mirror statistics names -- */ --static ssize_t nss_mirror_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_mirror_strings_stats, NSS_MIRROR_STATS_MAX); --} -- --/* -- * nss_mirror_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(mirror); -- --/* -- * nss_mirror_strings_dentry_create() -- * Create mirror statistics strings debug entry. -- */ --void nss_mirror_strings_dentry_create(void) --{ -- nss_strings_create_dentry("mirror", &nss_mirror_strings_ops); --} ---- a/nss_mirror_strings.h -+++ /dev/null -@@ -1,27 +0,0 @@ --/* -- *************************************************************************** -- * 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. -- *************************************************************************** -- */ -- --#ifndef __NSS_MIRROR_STRINGS_H --#define __NSS_MIRROR_STRINGS_H -- --#include "nss_mirror_stats.h" -- --extern struct nss_stats_info nss_mirror_strings_stats[NSS_MIRROR_STATS_MAX]; --extern void nss_mirror_strings_dentry_create(void); -- --#endif /* __NSS_MIRROR_STRINGS_H */ ---- a/nss_n2h.c -+++ b/nss_n2h.c -@@ -33,12 +33,6 @@ - #define NSS_N2H_DEFAULT_EMPTY_POOL_BUF_SZ 8192 - #define NSS_N2H_TX_TIMEOUT 3000 /* 3 Seconds */ - --/* -- * Allocate shaper pool memory in multiple chunk of PAGE_SIZE -- */ --#define NSS_N2H_MIN_QOS_MEM_POOL_SZ 1 --#define NSS_N2H_QOS_MEM_POOL_SZ_MB(size) (size * 1024 * 1024) -- - int nss_n2h_empty_pool_buf_cfg[NSS_MAX_CORES] __read_mostly = {-1, -1}; - int nss_n2h_empty_paged_pool_buf_cfg[NSS_MAX_CORES] __read_mostly = {-1, -1}; - int nss_n2h_water_mark[NSS_MAX_CORES][2] __read_mostly = {{-1, -1}, {-1, -1} }; -@@ -50,7 +44,6 @@ int nss_n2h_core0_add_buf_pool_size __re - int nss_n2h_core1_add_buf_pool_size __read_mostly; - int nss_n2h_queue_limit[NSS_MAX_CORES] __read_mostly = {NSS_DEFAULT_QUEUE_LIMIT, NSS_DEFAULT_QUEUE_LIMIT}; - int nss_n2h_host_bp_config[NSS_MAX_CORES] __read_mostly; --int nss_n2h_shaper_pool_size_cfg __read_mostly; - - struct nss_n2h_registered_data { - nss_n2h_msg_callback_t n2h_callback; -@@ -67,9 +60,6 @@ static struct nss_n2h_cfg_pvt nss_n2h_q_ - static struct nss_n2h_cfg_pvt nss_n2h_q_lim_pvt; - static struct nss_n2h_cfg_pvt nss_n2h_host_bp_cfg_pvt; - --static uint32_t nss_n2h_shaper_pool_cfg_num_pages; --static nss_tx_status_t nss_n2h_cfg_shaper_pool(struct nss_ctx_instance *nss_ctx) --; - /* - * nss_n2h_interface_handler() - * Handle NSS -> HLOS messages for N2H node -@@ -995,24 +985,6 @@ static int nss_n2h_wifi_payloads_handler - } - - /* -- * nss_n2h_get_qos_mem_size_cfg_handler() -- * Gets the QoS memory pool size -- */ --static int nss_n2h_get_qos_mem_size_cfg_handler(struct ctl_table *ctl, -- int write, void __user *buffer, -- size_t *lenp, loff_t *ppos) --{ -- int ret = NSS_FAILURE; -- -- if (!write) { -- nss_n2h_shaper_pool_size_cfg = NSS_N2H_QOS_MEM_POOL_SZ_MB(nss_core_get_qos_mem_size()); -- } -- -- ret = proc_dointvec(ctl, write, buffer, lenp, ppos); -- return ret; --} -- --/* - * nss_n2h_update_queue_config_callback() - * Callback to handle the completion of queue config command - */ -@@ -1734,13 +1706,6 @@ static struct ctl_table nss_n2h_table_si - .mode = 0644, - .proc_handler = &nss_n2h_host_bp_cfg_core0_handler, - }, -- { -- .procname = "qos_mem_size", -- .data = &nss_n2h_shaper_pool_size_cfg, -- .maxlen = sizeof(int), -- .mode = 0644, -- .proc_handler = &nss_n2h_get_qos_mem_size_cfg_handler, -- }, - - { } - }; -@@ -1894,13 +1859,6 @@ static struct ctl_table nss_n2h_table_mu - .mode = 0644, - .proc_handler = &nss_n2h_host_bp_cfg_core1_handler, - }, -- { -- .procname = "qos_mem_size", -- .data = &nss_n2h_shaper_pool_size_cfg, -- .maxlen = sizeof(int), -- .mode = 0644, -- .proc_handler = &nss_n2h_get_qos_mem_size_cfg_handler, -- }, - { } - }; - -@@ -1977,113 +1935,6 @@ nss_tx_status_t nss_n2h_cfg_empty_pool_s - return nss_tx_status; - } - --static inline void nss_n2h_shaper_pool_free(struct nss_n2h_shaper_mem_cfg_msg *nnsmcm, int num_blks) --{ -- int blk_count; -- for (blk_count = 0; blk_count < num_blks; blk_count++) { -- kfree((void *)nnsmcm->pool_vaddr[blk_count]); -- } --} -- --/* -- * nss_n2h_cfg_qos_mem_size_callback() -- * Call back function for QoS memory pool size configuration -- */ --static void nss_n2h_cfg_qos_mem_size_callback(void *app_data, struct nss_n2h_msg *nnm) --{ -- struct nss_ctx_instance *nss_ctx __maybe_unused = (struct nss_ctx_instance *)app_data; -- struct nss_n2h_shaper_mem_cfg_msg *nnsmcm = &nnm->msg.shaper_mem_cfg; -- nnsmcm->num_blks = ntohl(nnsmcm->num_blks); -- -- if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) { -- nss_warning("%px: Shaper pool configuration failed with error: %d\n", nss_ctx, nnm->cm.error); -- nss_n2h_shaper_pool_free(nnsmcm, nnsmcm->num_blks); -- return; -- } -- -- nss_core_update_qos_mem_size(nss_core_get_qos_mem_size() + (PAGE_SIZE * nnsmcm->num_blks)); -- nss_n2h_cfg_shaper_pool(nss_ctx); -- nss_info("%px: shaper pool configuration success\n", nss_ctx); --} -- --/* -- * nss_n2h_cfg_shaper_pool() -- * Config QoS memory pool in NSS FW -- */ --static nss_tx_status_t nss_n2h_cfg_shaper_pool(struct nss_ctx_instance *nss_ctx) --{ -- struct nss_n2h_msg nnm; -- struct nss_n2h_shaper_mem_cfg_msg *nnsmcm; -- nss_tx_status_t nss_tx_status; -- int blk_count; -- -- if (!nss_n2h_shaper_pool_cfg_num_pages) { -- return NSS_TX_SUCCESS; -- } -- -- memset(&nnm, 0, sizeof(struct nss_n2h_msg)); -- nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE, -- NSS_TX_METADATA_TYPE_N2H_SHAPER_POOL_CFG, -- sizeof(struct nss_n2h_shaper_mem_cfg_msg), -- nss_n2h_cfg_qos_mem_size_callback, -- (void *)nss_ctx); -- -- nnsmcm = &nnm.msg.shaper_mem_cfg; -- -- for (blk_count = 0; blk_count < MAX_PAGES_PER_MSG; blk_count++) { -- void *kern_addr = kzalloc(PAGE_SIZE, GFP_ATOMIC); -- if (!kern_addr) { -- nss_warning("%px: memory allocation failed for shaper pool", nss_ctx); -- return NSS_TX_FAILURE; -- } -- -- kmemleak_not_leak(kern_addr); -- nnsmcm->pool_vaddr[blk_count] = (nss_ptr_t)kern_addr; -- nnsmcm->pool_addr[blk_count] = dma_map_single(nss_ctx->dev, kern_addr, PAGE_SIZE, DMA_TO_DEVICE); -- } -- -- nnsmcm->mem_blk_size = htonl(PAGE_SIZE); -- nnsmcm->num_blks = htonl(blk_count); -- nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm); -- -- if (nss_tx_status != NSS_TX_SUCCESS) { -- nss_n2h_shaper_pool_free(nnsmcm, blk_count); -- nss_warning("%px: nss_tx error setting shaper pool\n", nss_ctx); -- return NSS_TX_FAILURE; -- } -- -- nss_n2h_shaper_pool_cfg_num_pages--; -- return NSS_TX_SUCCESS; --} -- --/* -- * nss_n2h_cfg_qos_mem_size() -- * Config QoS memory pool size -- */ --nss_tx_status_t nss_n2h_cfg_qos_mem_size(struct nss_ctx_instance *nss_ctx, uint32_t pool_sz) --{ -- nss_info("%px: update QoS memory pool size: %dMB\n", -- nss_ctx, pool_sz); -- -- if (!pool_sz) { -- nss_info("%px: No extra memory allocated for QoS memory pool", -- nss_ctx); -- return NSS_TX_SUCCESS; -- } -- -- if (pool_sz < NSS_N2H_MIN_QOS_MEM_POOL_SZ) { -- nss_warning("%px: pool size: %d is less than minimum value allowed: %d", -- nss_ctx, pool_sz, NSS_N2H_MIN_QOS_MEM_POOL_SZ); -- return NSS_TX_FAILURE; -- } -- -- nss_n2h_shaper_pool_cfg_num_pages = ALIGN(NSS_N2H_QOS_MEM_POOL_SZ_MB(pool_sz), PAGE_SIZE)/(PAGE_SIZE * MAX_PAGES_PER_MSG); -- -- nss_info("%px: shaper pool size:%d bytes\n", nss_ctx, NSS_N2H_QOS_MEM_POOL_SZ_MB(pool_sz)); -- -- return nss_n2h_cfg_shaper_pool(nss_ctx); --} -- - /* - * nss_n2h_paged_buf_pool_init() - * Sends a command down to NSS to initialize paged buffer pool ---- a/nss_n2h_stats.c -+++ b/nss_n2h_stats.c -@@ -38,7 +38,7 @@ static ssize_t nss_n2h_stats_read(struct - * Max output lines = #stats + few blank lines for banner printing + - * Number of Extra outputlines for future reference to add new stats - */ -- uint32_t max_output_lines = (NSS_N2H_STATS_MAX + 3) * NSS_MAX_CORES + NSS_STATS_EXTRA_OUTPUT_LINES; -+ uint32_t max_output_lines = (NSS_N2H_STATS_MAX + 3) * 2 + 5; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - size_t size_wr = 0; - ssize_t bytes_read = 0; --- a/nss_n2h_strings.c +++ b/nss_n2h_strings.c @@ -38,14 +38,14 @@ struct nss_stats_info nss_n2h_strings_st @@ -17710,10622 +19821,171 @@ {"payload_alloc_fails" , NSS_STATS_TYPE_SPECIAL}, {"payload_free_count" , NSS_STATS_TYPE_SPECIAL}, {"h2n_control_pkts" , NSS_STATS_TYPE_SPECIAL}, ---- a/nss_phys_if.h -+++ b/nss_phys_if.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2020, 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. -@@ -70,12 +70,6 @@ struct nss_phys_if_estats { - uint32_t gmac_worst_case_ticks; /**< Worst case iteration of the GMAC in ticks */ - uint32_t gmac_iterations; /**< Number of iterations around the GMAC */ - uint32_t tx_pause_frames; /**< Number of pause frames sent by the GMAC */ -- -- /* -- * On IPQ50xx, we rely on the SSDK to pull the mmc stats. -- * The FAL layer does not do this on IPQ806x. -- */ --#if defined(NSS_HAL_IPQ806X_SUPPORT) - uint32_t mmc_rx_overflow_errors; - /**< Number of RX overflow errors */ - uint32_t mmc_rx_watchdog_timeout_errors; -@@ -100,7 +94,6 @@ struct nss_phys_if_estats { - uint32_t mmc_tx_single_col; /* Number of single collisions */ - uint32_t mmc_tx_multiple_col; /* Number of multiple collisions */ - uint32_t mmc_tx_octets_gb; /* Number of good/bad octets sent*/ --#endif - }; - - /** ---- a/nss_ppe.c -+++ b/nss_ppe.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2018, 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2018, 2020, 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. -@@ -16,7 +16,6 @@ - - #include "nss_ppe.h" - #include "nss_ppe_stats.h" --#include "nss_ppe_strings.h" - - DEFINE_SPINLOCK(nss_ppe_stats_lock); - -@@ -272,7 +271,6 @@ static void nss_ppe_handler(struct nss_c - * session debug stats embeded in session stats msg - */ - nss_ppe_stats_sync(nss_ctx, &msg->msg.stats, ncm->interface); -- nss_ppe_stats_notify(nss_ctx, ncm->interface); - return; - } - -@@ -311,7 +309,6 @@ void nss_ppe_register_handler(void) - - if (nss_ppe_debug_stats.valid) { - nss_ppe_stats_dentry_create(); -- nss_ppe_strings_dentry_create(); - } - } - -@@ -357,7 +354,7 @@ void nss_ppe_init(void) - /* - * Get the PPE base address - */ -- ppe_pvt.ppe_base = ioremap_nocache(PPE_BASE_ADDR, PPE_REG_SIZE); -+ ppe_pvt.ppe_base = ioremap(PPE_BASE_ADDR, PPE_REG_SIZE); - if (!ppe_pvt.ppe_base) { - nss_warning("DRV can't get PPE base address\n"); - return; ---- a/nss_ppe_stats.c -+++ b/nss_ppe_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2020, 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. -@@ -17,12 +17,6 @@ - #include "nss_core.h" - #include "nss_ppe.h" - #include "nss_ppe_stats.h" --#include "nss_ppe_strings.h" -- --/* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_ppe_stats_notifier); - - static uint8_t ppe_cc_nonexception[NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_MAX] = { - NSS_PPE_STATS_CPU_CODE_EXP_FAKE_L2_PROT_ERR, -@@ -109,10 +103,371 @@ static uint8_t ppe_cc_nonexception[NSS_P - }; - - /* -- * nss_ppe_stats_str_sc_type -- * PPE service-code stats type -+ * nss_ppe_stats_str_conn -+ * PPE statistics strings for nss flow stats -+ */ -+static int8_t *nss_ppe_stats_str_conn[NSS_PPE_STATS_CONN_MAX] = { -+ "v4 routed flows", -+ "v4 bridge flows", -+ "v4 conn create req", -+ "v4 conn create fail", -+ "v4 conn destroy req", -+ "v4 conn destroy fail", -+ "v4 conn MC create req", -+ "v4 conn MC create fail", -+ "v4 conn MC update req", -+ "v4 conn MC update fail", -+ "v4 conn MC delete req", -+ "v4 conn MC delete fail", -+ "v4 conn unknown if", -+ -+ "v6 routed flows", -+ "v6 bridge flows", -+ "v6 conn create req", -+ "v6 conn create fail", -+ "v6 conn destroy req", -+ "v6 conn destroy fail", -+ "v6 conn MC create req", -+ "v6 conn MC create fail", -+ "v6 conn MC update req", -+ "v6 conn MC update fail", -+ "v6 conn MC delete req", -+ "v6 conn MC delete fail", -+ "v6 conn unknown if", -+ -+ "conn fail - vp full", -+ "conn fail - nexthop full", -+ "conn fail - flow full", -+ "conn fail - host full", -+ "conn fail - pub-ip full", -+ "conn fail - port not setup", -+ "conn fail - rw fifo full", -+ "conn fail - flow cmd failure", -+ "conn fail - unknown proto", -+ "conn fail - ppe not responding", -+ "conn fail - CE opaque invalid", -+ "conn fail - fqg full" -+}; -+ -+/* -+ * nss_ppe_stats_str_l3 -+ * PPE statistics strings for nss debug stats -+ */ -+static int8_t *nss_ppe_stats_str_l3[NSS_PPE_STATS_L3_MAX] = { -+ "PPE L3 dbg reg 0", -+ "PPE L3 dbg reg 1", -+ "PPE L3 dbg reg 2", -+ "PPE L3 dbg reg 3", -+ "PPE L3 dbg reg 4", -+ "PPE L3 dbg reg port", -+}; -+ -+/* -+ * nss_ppe_stats_str_code -+ * PPE statistics strings for nss debug stats -+ */ -+static int8_t *nss_ppe_stats_str_code[NSS_PPE_STATS_CODE_MAX] = { -+ "PPE CPU_CODE", -+ "PPE DROP_CODE", -+}; -+ -+/* -+ * nss_ppe_stats_str_dc -+ * PPE statistics strings for drop code - */ --static int8_t *nss_ppe_stats_str_sc_type[NSS_PPE_SC_MAX] = { -+static int8_t *nss_ppe_stats_str_dc[NSS_PPE_STATS_DROP_CODE_MAX] = { -+ "PPE_DROP_CODE_NONE", -+ "PPE_DROP_CODE_EXP_UNKNOWN_L2_PORT", -+ "PPE_DROP_CODE_EXP_PPPOE_WRONG_VER_TYPE", -+ "PPE_DROP_CODE_EXP_PPPOE_WRONG_CODE", -+ "PPE_DROP_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT", -+ "PPE_DROP_CODE_EXP_IPV4_WRONG_VER", -+ "PPE_DROP_CODE_EXP_IPV4_SMALL_IHL", -+ "PPE_DROP_CODE_EXP_IPV4_WITH_OPTION", -+ "PPE_DROP_CODE_EXP_IPV4_HDR_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_IPV4_BAD_TOTAL_LEN", -+ "PPE_DROP_CODE_EXP_IPV4_DATA_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_IPV4_FRAG", -+ "PPE_DROP_CODE_EXP_IPV4_PING_OF_DEATH", -+ "PPE_DROP_CODE_EXP_IPV4_SNALL_TTL", -+ "PPE_DROP_CODE_EXP_IPV4_UNK_IP_PROT", -+ "PPE_DROP_CODE_EXP_IPV4_CHECKSUM_ERR", -+ "PPE_DROP_CODE_EXP_IPV4_INV_SIP", -+ "PPE_DROP_CODE_EXP_IPV4_INV_DIP", -+ "PPE_DROP_CODE_EXP_IPV4_LAND_ATTACK", -+ "PPE_DROP_CODE_EXP_IPV4_AH_HDR_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_IPV4_AH_HDR_CROSS_BORDER", -+ "PPE_DROP_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_IPV6_WRONG_VER", -+ "PPE_DROP_CODE_EXP_IPV6_HDR_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_IPV6_BAD_PAYLOAD_LEN", -+ "PPE_DROP_CODE_EXP_IPV6_DATA_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_IPV6_WITH_EXT_HDR", -+ "PPE_DROP_CODE_EXP_IPV6_SMALL_HOP_LIMIT", -+ "PPE_DROP_CODE_EXP_IPV6_INV_SIP", -+ "PPE_DROP_CODE_EXP_IPV6_INV_DIP", -+ "PPE_DROP_CODE_EXP_IPV6_LAND_ATTACK", -+ "PPE_DROP_CODE_EXP_IPV6_FRAG", -+ "PPE_DROP_CODE_EXP_IPV6_PING_OF_DEATH", -+ "PPE_DROP_CODE_EXP_IPV6_WITH_MORE_EXT_HDR", -+ "PPE_DROP_CODE_EXP_IPV6_UNK_LAST_NEXT_HDR", -+ "PPE_DROP_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_IPV6_MOBILITY_HDR_CROSS_BORDER", -+ "PPE_DROP_CODE_EXP_IPV6_AH_HDR_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_IPV6_AH_HDR_CROSS_BORDER", -+ "PPE_DROP_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_IPV6_ESP_HDR_CROSS_BORDER", -+ "PPE_DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_IPV6_OTHER_EXT_HDR_CROSS_BORDER", -+ "PPE_DROP_CODE_EXP_TCP_HDR_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_TCP_HDR_CROSS_BORDER", -+ "PPE_DROP_CODE_EXP_TCP_SMAE_SP_DP", -+ "PPE_DROP_CODE_EXP_TCP_SMALL_DATA_OFFSET", -+ "PPE_DROP_CODE_EXP_TCP_FLAGS_0", -+ "PPE_DROP_CODE_EXP_TCP_FLAGS_1", -+ "PPE_DROP_CODE_EXP_TCP_FLAGS_2", -+ "PPE_DROP_CODE_EXP_TCP_FLAGS_3", -+ "PPE_DROP_CODE_EXP_TCP_FLAGS_4", -+ "PPE_DROP_CODE_EXP_TCP_FLAGS_5", -+ "PPE_DROP_CODE_EXP_TCP_FLAGS_6", -+ "PPE_DROP_CODE_EXP_TCP_FLAGS_7", -+ "PPE_DROP_CODE_EXP_TCP_CHECKSUM_ERR", -+ "PPE_DROP_CODE_EXP_UDP_HDR_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_UDP_HDR_CROSS_BORDER", -+ "PPE_DROP_CODE_EXP_UDP_SMAE_SP_DP", -+ "PPE_DROP_CODE_EXP_UDP_BAD_LEN", -+ "PPE_DROP_CODE_EXP_UDP_DATA_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_UDP_CHECKSUM_ERR", -+ "PPE_DROP_CODE_EXP_UDP_LITE_HDR_INCOMPLETE", -+ "PPE_DROP_CODE_EXP_UDP_LITE_HDR_CROSS_BORDER", -+ "PPE_DROP_CODE_EXP_UDP_LITE_SMAE_SP_DP", -+ "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_1_TO_7", -+ "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_TOO_LONG", -+ "PPE_DROP_CODE_EXP_UDP_LITE_CSM_COV_CROSS_BORDER", -+ "PPE_DROP_CODE_EXP_UDP_LITE_CHECKSUM_ERR", -+ "PPE_DROP_CODE_L3_MC_BRIDGE_ACTION", -+ "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ACTION", -+ "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_NAT_ERROR", -+ "PPE_DROP_CODE_L3_ROUTE_ACTION", -+ "PPE_DROP_CODE_L3_NO_ROUTE_ACTION", -+ "PPE_DROP_CODE_L3_NO_ROUTE_NH_INVALID_ACTION", -+ "PPE_DROP_CODE_L3_NO_ROUTE_PREHEAD_ACTION", -+ "PPE_DROP_CODE_L3_BRIDGE_ACTION", -+ "PPE_DROP_CODE_L3_FLOW_ACTION", -+ "PPE_DROP_CODE_L3_FLOW_MISS_ACTION", -+ "PPE_DROP_CODE_L2_EXP_MRU_FAIL", -+ "PPE_DROP_CODE_L2_EXP_MTU_FAIL", -+ "PPE_DROP_CODE_L3_EXP_IP_PREFIX_BC", -+ "PPE_DROP_CODE_L3_EXP_MTU_FAIL", -+ "PPE_DROP_CODE_L3_EXP_MRU_FAIL", -+ "PPE_DROP_CODE_L3_EXP_ICMP_RDT", -+ "PPE_DROP_CODE_FAKE_MAC_HEADER_ERR", -+ "PPE_DROP_CODE_L3_EXP_IP_RT_TTL_ZERO", -+ "PPE_DROP_CODE_L3_FLOW_SERVICE_CODE_LOOP", -+ "PPE_DROP_CODE_L3_FLOW_DE_ACCELEARTE", -+ "PPE_DROP_CODE_L3_EXP_FLOW_SRC_IF_CHK_FAIL", -+ "PPE_DROP_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH", -+ "PPE_DROP_CODE_L3_EXP_MTU_DF_FAIL", -+ "PPE_DROP_CODE_L3_EXP_PPPOE_MULTICAST", -+ "PPE_DROP_CODE_IPV4_SG_UNKNOWN", -+ "PPE_DROP_CODE_IPV6_SG_UNKNOWN", -+ "PPE_DROP_CODE_ARP_SG_UNKNOWN", -+ "PPE_DROP_CODE_ND_SG_UNKNOWN", -+ "PPE_DROP_CODE_IPV4_SG_VIO", -+ "PPE_DROP_CODE_IPV6_SG_VIO", -+ "PPE_DROP_CODE_ARP_SG_VIO", -+ "PPE_DROP_CODE_ND_SG_VIO", -+ "PPE_DROP_CODE_L2_NEW_MAC_ADDRESS", -+ "PPE_DROP_CODE_L2_HASH_COLLISION", -+ "PPE_DROP_CODE_L2_STATION_MOVE", -+ "PPE_DROP_CODE_L2_LEARN_LIMIT", -+ "PPE_DROP_CODE_L2_SA_LOOKUP_ACTION", -+ "PPE_DROP_CODE_L2_DA_LOOKUP_ACTION", -+ "PPE_DROP_CODE_APP_CTRL_ACTION", -+ "PPE_DROP_CODE_IN_VLAN_FILTER_ACTION", -+ "PPE_DROP_CODE_IN_VLAN_XLT_MISS", -+ "PPE_DROP_CODE_EG_VLAN_FILTER_DROP", -+ "PPE_DROP_CODE_ACL_PRE_ACTION", -+ "PPE_DROP_CODE_ACL_POST_ACTION", -+ "PPE_DROP_CODE_MC_BC_SA", -+ "PPE_DROP_CODE_NO_DESTINATION", -+ "PPE_DROP_CODE_STG_IN_FILTER", -+ "PPE_DROP_CODE_STG_EG_FILTER", -+ "PPE_DROP_CODE_SOURCE_FILTER_FAIL", -+ "PPE_DROP_CODE_TRUNK_SEL_FAIL", -+ "PPE_DROP_CODE_TX_EN_FAIL", -+ "PPE_DROP_CODE_VLAN_TAG_FMT", -+ "PPE_DROP_CODE_CRC_ERR", -+ "PPE_DROP_CODE_PAUSE_FRAME", -+ "PPE_DROP_CODE_PROMISC", -+ "PPE_DROP_CODE_ISOLATION", -+ "PPE_DROP_CODE_MGMT_APP", -+ "PPE_DROP_CODE_FAKE_L2_PROT_ERR", -+ "PPE_DROP_CODE_POLICER", -+}; -+ -+/* -+ * nss_ppe_stats_str_cc -+ * PPE statistics strings for cpu code -+ */ -+static int8_t *nss_ppe_stats_str_cc[NSS_PPE_STATS_CPU_CODE_MAX] = { -+ "PPE_CPU_CODE_FORWARDING", -+ "PPE_CPU_CODE_EXP_UNKNOWN_L2_PROT", -+ "PPE_CPU_CODE_EXP_PPPOE_WRONG_VER_TYPE", -+ "PPE_CPU_CODE_EXP_WRONG_CODE", -+ "PPE_CPU_CODE_EXP_PPPOE_UNSUPPORTED_PPP_PROT", -+ "PPE_CPU_CODE_EXP_WRONG_VER", -+ "PPE_CPU_CODE_EXP_SMALL_IHL", -+ "PPE_CPU_CODE_EXP_WITH_OPTION", -+ "PPE_CPU_CODE_EXP_HDR_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_IPV4_BAD_TOTAL_LEN", -+ "PPE_CPU_CODE_EXP_DATA_INCOMPLETE", -+ "PPE_CPU_CODE_IPV4_FRAG", -+ "PPE_CPU_CODE_EXP_IPV4_PING_OF_DEATH", -+ "PPE_CPU_CODE_EXP_SNALL_TTL", -+ "PPE_CPU_CODE_EXP_IPV4_UNK_IP_PROT", -+ "PPE_CPU_CODE_EXP_CHECKSUM_ERR", -+ "PPE_CPU_CODE_EXP_INV_SIP", -+ "PPE_CPU_CODE_EXP_INV_DIP", -+ "PPE_CPU_CODE_EXP_LAND_ATTACK", -+ "PPE_CPU_CODE_EXP_IPV4_AH_HDR_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_IPV4_AH_CROSS_BORDER", -+ "PPE_CPU_CODE_EXP_IPV4_ESP_HDR_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_WRONG_VER", -+ "PPE_CPU_CODE_EXP_HDR_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_IPV6_BAD_PAYLOAD_LEN", -+ "PPE_CPU_CODE_EXP_DATA_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_IPV6_WITH_EXT_HDR", -+ "PPE_CPU_CODE_EXP_IPV6_SMALL_HOP_LIMIT", -+ "PPE_CPU_CODE_EXP_INV_SIP", -+ "PPE_CPU_CODE_EXP_INV_DIP", -+ "PPE_CPU_CODE_EXP_LAND_ATTACK", -+ "PPE_CPU_CODE_IPV6_FRAG", -+ "PPE_CPU_CODE_EXP_IPV6_PING_OF_DEATH", -+ "PPE_CPU_CODE_EXP_IPV6_WITH_EXT_HDR", -+ "PPE_CPU_CODE_EXP_IPV6_UNK_NEXT_HDR", -+ "PPE_CPU_CODE_EXP_IPV6_MOBILITY_HDR_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_IPV6_MOBILITY_CROSS_BORDER", -+ "PPE_CPU_CODE_EXP_IPV6_AH_HDR_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_IPV6_AH_CROSS_BORDER", -+ "PPE_CPU_CODE_EXP_IPV6_ESP_HDR_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_IPV6_ESP_CROSS_BORDER", -+ "PPE_CPU_CODE_EXP_IPV6_OTHER_HDR_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_IPV6_OTHER_EXT_CROSS_BORDER", -+ "PPE_CPU_CODE_EXP_HDR_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_TCP_HDR_CROSS_BORDER", -+ "PPE_CPU_CODE_EXP_TCP_SMAE_SP_DP", -+ "PPE_CPU_CODE_EXP_TCP_SMALL_DATA_OFFSET", -+ "PPE_CPU_CODE_EXP_FLAGS_0", -+ "PPE_CPU_CODE_EXP_FLAGS_1", -+ "PPE_CPU_CODE_EXP_FLAGS_2", -+ "PPE_CPU_CODE_EXP_FLAGS_3", -+ "PPE_CPU_CODE_EXP_FLAGS_4", -+ "PPE_CPU_CODE_EXP_FLAGS_5", -+ "PPE_CPU_CODE_EXP_FLAGS_6", -+ "PPE_CPU_CODE_EXP_FLAGS_7", -+ "PPE_CPU_CODE_EXP_CHECKSUM_ERR", -+ "PPE_CPU_CODE_EXP_HDR_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_UDP_HDR_CROSS_BORDER", -+ "PPE_CPU_CODE_EXP_UDP_SMAE_SP_DP", -+ "PPE_CPU_CODE_EXP_BAD_LEN", -+ "PPE_CPU_CODE_EXP_DATA_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_CHECKSUM_ERR", -+ "PPE_CPU_CODE_EXP_UDP_LITE_HDR_INCOMPLETE", -+ "PPE_CPU_CODE_EXP_UDP_LITE_CROSS_BORDER", -+ "PPE_CPU_CODE_EXP_UDP_LITE_SP_DP", -+ "PPE_CPU_CODE_EXP_UDP_LITE_CSM_COV_TO_7", -+ "PPE_CPU_CODE_EXP_UDP_LITE_CSM_TOO_LONG", -+ "PPE_CPU_CODE_EXP_UDP_LITE_CSM_CROSS_BORDER", -+ "PPE_CPU_CODE_EXP_UDP_LITE_CHECKSUM_ERR", -+ "PPE_CPU_CODE_EXP_FAKE_L2_PROT_ERR", -+ "PPE_CPU_CODE_EXP_FAKE_MAC_HEADER_ERR", -+ "PPE_CPU_CODE_BITMAP_MAX", -+ "PPE_CPU_CODE_L2_MRU_FAIL", -+ "PPE_CPU_CODE_L2_MTU_FAIL", -+ "PPE_CPU_CODE_L3_EXP_IP_PREFIX_BC", -+ "PPE_CPU_CODE_L3_MTU_FAIL", -+ "PPE_CPU_CODE_L3_MRU_FAIL", -+ "PPE_CPU_CODE_L3_ICMP_RDT", -+ "PPE_CPU_CODE_L3_EXP_IP_RT_TO_ME", -+ "PPE_CPU_CODE_L3_EXP_IP_TTL_ZERO", -+ "PPE_CPU_CODE_L3_FLOW_SERVICE_CODE_LOOP", -+ "PPE_CPU_CODE_L3_DE_ACCELERATE", -+ "PPE_CPU_CODE_L3_EXP_FLOW_SRC_CHK_FAIL", -+ "PPE_CPU_CODE_L3_FLOW_SYNC_TOGGLE_MISMATCH", -+ "PPE_CPU_CODE_L3_EXP_MTU_DF_FAIL", -+ "PPE_CPU_CODE_L3_PPPOE_MULTICAST", -+ "PPE_CPU_CODE_MGMT_OFFSET", -+ "PPE_CPU_CODE_MGMT_EAPOL", -+ "PPE_CPU_CODE_PPPOE_DIS", -+ "PPE_CPU_CODE_MGMT_IGMP", -+ "PPE_CPU_CODE_ARP_REQ", -+ "PPE_CPU_CODE_ARP_REP", -+ "PPE_CPU_CODE_MGMT_DHCPv4", -+ "PPE_CPU_CODE_MGMT_MLD", -+ "PPE_CPU_CODE_MGMT_NS", -+ "PPE_CPU_CODE_MGMT_NA", -+ "PPE_CPU_CODE_MGMT_DHCPv6", -+ "PPE_CPU_CODE_PTP_OFFSET", -+ "PPE_CPU_CODE_PTP_SYNC", -+ "PPE_CPU_CODE_FOLLOW_UP", -+ "PPE_CPU_CODE_DELAY_REQ", -+ "PPE_CPU_CODE_DELAY_RESP", -+ "PPE_CPU_CODE_PDELAY_REQ", -+ "PPE_CPU_CODE_PDELAY_RESP", -+ "PPE_CPU_CODE_PTP_PDELAY_RESP_FOLLOW_UP", -+ "PPE_CPU_CODE_PTP_ANNOUNCE", -+ "PPE_CPU_CODE_PTP_MANAGEMENT", -+ "PPE_CPU_CODE_PTP_SIGNALING", -+ "PPE_CPU_CODE_PTP_RSV_MSG", -+ "PPE_CPU_CODE_SG_UNKNOWN", -+ "PPE_CPU_CODE_SG_UNKNOWN", -+ "PPE_CPU_CODE_SG_UNKNOWN", -+ "PPE_CPU_CODE_SG_UNKNOWN", -+ "PPE_CPU_CODE_SG_VIO", -+ "PPE_CPU_CODE_SG_VIO", -+ "PPE_CPU_CODE_SG_VIO", -+ "PPE_CPU_CODE_SG_VIO", -+ "PPE_CPU_CODE_L3_ROUTING_IP_TO_ME", -+ "PPE_CPU_CODE_L3_SNAT_ACTION", -+ "PPE_CPU_CODE_L3_DNAT_ACTION", -+ "PPE_CPU_CODE_L3_RT_ACTION", -+ "PPE_CPU_CODE_L3_BR_ACTION", -+ "PPE_CPU_CODE_L3_BRIDGE_ACTION", -+ "PPE_CPU_CODE_L3_ROUTE_PREHEAD_RT_ACTION", -+ "PPE_CPU_CODE_L3_ROUTE_PREHEAD_SNAPT_ACTION", -+ "PPE_CPU_CODE_L3_ROUTE_PREHEAD_DNAPT_ACTION", -+ "PPE_CPU_CODE_L3_ROUTE_PREHEAD_SNAT_ACTION", -+ "PPE_CPU_CODE_L3_ROUTE_PREHEAD_DNAT_ACTION", -+ "PPE_CPU_CODE_L3_NO_ROUTE_NAT_ACTION", -+ "PPE_CPU_CODE_L3_NO_ROUTE_NAT_ERROR", -+ "PPE_CPU_CODE_ROUTE_ACTION", -+ "PPE_CPU_CODE_L3_ROUTE_ACTION", -+ "PPE_CPU_CODE_L3_NO_ROUTE_INVALID_ACTION", -+ "PPE_CPU_CODE_L3_NO_ROUTE_PREHEAD_ACTION", -+ "PPE_CPU_CODE_BRIDGE_ACTION", -+ "PPE_CPU_CODE_FLOW_ACTION", -+ "PPE_CPU_CODE_L3_MISS_ACTION", -+ "PPE_CPU_CODE_L2_MAC_ADDRESS", -+ "PPE_CPU_CODE_HASH_COLLISION", -+ "PPE_CPU_CODE_STATION_MOVE", -+ "PPE_CPU_CODE_LEARN_LIMIT", -+ "PPE_CPU_CODE_L2_LOOKUP_ACTION", -+ "PPE_CPU_CODE_L2_LOOKUP_ACTION", -+ "PPE_CPU_CODE_CTRL_ACTION", -+ "PPE_CPU_CODE_IN_FILTER_ACTION", -+ "PPE_CPU_CODE_IN_XLT_MISS", -+ "PPE_CPU_CODE_EG_FILTER_DROP", -+ "PPE_CPU_CODE_PRE_ACTION", -+ "PPE_CPU_CODE_POST_ACTION", -+ "PPE_CPU_CODE_CODE_ACTION", -+}; -+ -+/* -+ * nss_ppe_stats_str_sc -+ * PPE statistics strings for service-code stats -+ */ -+static int8_t *nss_ppe_stats_str_sc[NSS_PPE_SC_MAX] = { - "SC_NONE ", - "SC_BYPASS_ALL ", - "SC_ADV_QOS_BRIDGED", -@@ -135,8 +490,8 @@ void nss_ppe_stats_sync(struct nss_ctx_i - { - uint32_t sc; - spin_lock_bh(&nss_ppe_stats_lock); -- nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_L3_FLOWS] = stats_msg->stats.nss_ppe_v4_l3_flows; -- nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_L2_FLOWS] = stats_msg->stats.nss_ppe_v4_l2_flows; -+ nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_L3_FLOWS] += stats_msg->stats.nss_ppe_v4_l3_flows; -+ nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_L2_FLOWS] += stats_msg->stats.nss_ppe_v4_l2_flows; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_CREATE_REQ] += stats_msg->stats.nss_ppe_v4_create_req; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_CREATE_FAIL] += stats_msg->stats.nss_ppe_v4_create_fail; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_DESTROY_REQ] += stats_msg->stats.nss_ppe_v4_destroy_req; -@@ -149,8 +504,8 @@ void nss_ppe_stats_sync(struct nss_ctx_i - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_MC_DESTROY_FAIL] += stats_msg->stats.nss_ppe_v4_mc_destroy_fail; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V4_UNKNOWN_INTERFACE] += stats_msg->stats.nss_ppe_v4_unknown_interface; - -- nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_L3_FLOWS] = stats_msg->stats.nss_ppe_v6_l3_flows; -- nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_L2_FLOWS] = stats_msg->stats.nss_ppe_v6_l2_flows; -+ nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_L3_FLOWS] += stats_msg->stats.nss_ppe_v6_l3_flows; -+ nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_L2_FLOWS] += stats_msg->stats.nss_ppe_v6_l2_flows; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_CREATE_REQ] += stats_msg->stats.nss_ppe_v6_create_req; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_CREATE_FAIL] += stats_msg->stats.nss_ppe_v6_create_fail; - nss_ppe_debug_stats.conn_stats[NSS_PPE_STATS_V6_DESTROY_REQ] += stats_msg->stats.nss_ppe_v6_destroy_req; -@@ -192,7 +547,7 @@ void nss_ppe_stats_sync(struct nss_ctx_i - * nss_ppe_stats_conn_get() - * Get PPE connection statistics. - */ --static void nss_ppe_stats_conn_get(uint64_t *stats) -+static void nss_ppe_stats_conn_get(uint32_t *stats) - { - if (!stats) { - nss_warning("No memory to copy ppe connection stats"); -@@ -203,7 +558,7 @@ static void nss_ppe_stats_conn_get(uint6 - * Get flow stats - */ - spin_lock_bh(&nss_ppe_stats_lock); -- memcpy(stats, nss_ppe_debug_stats.conn_stats, (sizeof(uint64_t) * NSS_PPE_STATS_CONN_MAX)); -+ memcpy(stats, nss_ppe_debug_stats.conn_stats, (sizeof(uint32_t) * NSS_PPE_STATS_CONN_MAX)); - spin_unlock_bh(&nss_ppe_stats_lock); - } - -@@ -214,7 +569,7 @@ static void nss_ppe_stats_conn_get(uint6 - static void nss_ppe_stats_sc_get(struct nss_ppe_sc_stats_debug *sc_stats) - { - if (!sc_stats) { -- nss_warning("No memory to copy ppe service code stats"); -+ nss_warning("No memory to copy ppe connection stats"); - return; - } - -@@ -370,9 +725,10 @@ static ssize_t nss_ppe_conn_stats_read(s - char *lbuf = NULL; - size_t size_wr = 0; - ssize_t bytes_read = 0; -- uint64_t *stats_shadow; -- uint64_t ppe_stats[NSS_PPE_STATS_CONN_MAX]; -- uint32_t max_output_lines = NSS_PPE_STATS_CONN_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -+ uint32_t ppe_stats[NSS_PPE_STATS_CONN_MAX]; -+ uint32_t max_output_lines = 2 /* header & footer for session stats */ -+ + NSS_PPE_STATS_CONN_MAX /* PPE flow counters */ -+ + 2; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - - lbuf = kzalloc(size_al, GFP_KERNEL); -@@ -381,14 +737,7 @@ static ssize_t nss_ppe_conn_stats_read(s - return 0; - } - -- stats_shadow = kzalloc(NSS_PPE_STATS_CONN_MAX * 8, GFP_KERNEL); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- -- memset(ppe_stats, 0, sizeof(uint64_t) * NSS_PPE_STATS_CONN_MAX); -+ memset(ppe_stats, 0, sizeof(uint32_t) * NSS_PPE_STATS_CONN_MAX); - - /* - * Get all stats -@@ -398,19 +747,20 @@ static ssize_t nss_ppe_conn_stats_read(s - /* - * flow stats - */ -- spin_lock_bh(&nss_ppe_stats_lock); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe flow counters start:\n\n"); -+ - for (i = 0; i < NSS_PPE_STATS_CONN_MAX; i++) { -- stats_shadow[i] = ppe_stats[i]; -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\t%s = %u\n", nss_ppe_stats_str_conn[i], -+ ppe_stats[i]); - } - -- spin_unlock_bh(&nss_ppe_stats_lock); -- size_wr += nss_stats_print("ppe", "ppe flow counters", NSS_STATS_SINGLE_INSTANCE, nss_ppe_stats_str_conn, stats_shadow, -- NSS_PPE_STATS_CONN_MAX, lbuf, size_wr, size_al); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe flow counters end\n"); -+ bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(lbuf); -- kfree(stats_shadow); - return bytes_read; - } - -@@ -425,7 +775,9 @@ static ssize_t nss_ppe_sc_stats_read(str - size_t size_wr = 0; - ssize_t bytes_read = 0; - struct nss_ppe_sc_stats_debug sc_stats[NSS_PPE_SC_MAX]; -- uint32_t max_output_lines = (NSS_PPE_SC_MAX * NSS_PPE_STATS_SERVICE_CODE_MAX) + NSS_STATS_EXTRA_OUTPUT_LINES; -+ uint32_t max_output_lines = 2 /* header & footer for sc stats */ -+ + NSS_PPE_SC_MAX /* PPE service-code counters */ -+ + 2; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - - lbuf = kzalloc(size_al, GFP_KERNEL); -@@ -444,16 +796,20 @@ static ssize_t nss_ppe_sc_stats_read(str - /* - * service code stats - */ -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe service code counters start:\n\n"); - - for (i = 0; i < NSS_PPE_SC_MAX; i++) { -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "ppe service code type: %s\n", -- nss_ppe_stats_str_sc_type[i]); -- size_wr += nss_stats_print("ppe", "ppe service code counters", NSS_STATS_SINGLE_INSTANCE, -- nss_ppe_stats_str_sc, &sc_stats[i].nss_ppe_sc_cb_unregister, -- NSS_PPE_STATS_SERVICE_CODE_MAX, lbuf, size_wr, size_al); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\t%s \tcb_unregister:%llu process_ok:%llu process_fail:%llu\n", -+ nss_ppe_stats_str_sc[i], sc_stats[i].nss_ppe_sc_cb_unregister, -+ sc_stats[i].nss_ppe_sc_cb_success, sc_stats[i].nss_ppe_sc_cb_failure); - } - -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); -+ -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe service code counters end\n"); -+ bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); -+ - kfree(lbuf); - return bytes_read; - } -@@ -468,9 +824,10 @@ static ssize_t nss_ppe_l3_stats_read(str - char *lbuf = NULL; - size_t size_wr = 0; - ssize_t bytes_read = 0; -- uint64_t *stats_shadow; - uint32_t ppe_stats[NSS_PPE_STATS_L3_MAX]; -- uint32_t max_output_lines = NSS_PPE_STATS_L3_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -+ uint32_t max_output_lines = 2 /* header & footer for session stats */ -+ + NSS_PPE_STATS_L3_MAX /* PPE flow counters */ -+ + 2; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - - lbuf = kzalloc(size_al, GFP_KERNEL); -@@ -479,13 +836,6 @@ static ssize_t nss_ppe_l3_stats_read(str - return 0; - } - -- stats_shadow = kzalloc(NSS_PPE_STATS_L3_MAX * 8, GFP_KERNEL); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- - memset(ppe_stats, 0, sizeof(uint32_t) * NSS_PPE_STATS_L3_MAX); - - /* -@@ -496,18 +846,20 @@ static ssize_t nss_ppe_l3_stats_read(str - /* - * flow stats - */ -- spin_lock_bh(&nss_ppe_stats_lock); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe l3 debug stats start:\n\n"); -+ - for (i = 0; i < NSS_PPE_STATS_L3_MAX; i++) { -- stats_shadow[i] = ppe_stats[i]; -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\t%s = 0x%x\n", nss_ppe_stats_str_l3[i], -+ ppe_stats[i]); - } - -- spin_unlock_bh(&nss_ppe_stats_lock); -- size_wr += nss_stats_print("ppe", "ppe l3 debug stats", NSS_STATS_SINGLE_INSTANCE, nss_ppe_stats_str_l3, -- stats_shadow, NSS_PPE_STATS_L3_MAX, lbuf, size_wr, size_al); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); -+ -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe l3 debug stats end\n"); -+ bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(lbuf); -- kfree(stats_shadow); - return bytes_read; - } - -@@ -521,9 +873,10 @@ static ssize_t nss_ppe_code_stats_read(s - char *lbuf = NULL; - size_t size_wr = 0; - ssize_t bytes_read = 0; -- uint64_t *stats_shadow; - uint32_t ppe_stats[NSS_PPE_STATS_CODE_MAX]; -- uint32_t max_output_lines = NSS_PPE_STATS_CODE_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -+ uint32_t max_output_lines = 2 /* header & footer for session stats */ -+ + NSS_PPE_STATS_CODE_MAX /* PPE flow counters */ -+ + 2; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - - lbuf = kzalloc(size_al, GFP_KERNEL); -@@ -532,13 +885,6 @@ static ssize_t nss_ppe_code_stats_read(s - return 0; - } - -- stats_shadow = kzalloc(NSS_PPE_STATS_CODE_MAX * 8, GFP_KERNEL); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- - memset(ppe_stats, 0, sizeof(uint32_t) * NSS_PPE_STATS_CODE_MAX); - - /* -@@ -549,19 +895,20 @@ static ssize_t nss_ppe_code_stats_read(s - /* - * flow stats - */ -- spin_lock_bh(&nss_ppe_stats_lock); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe session stats start:\n\n"); -+ - for (i = 0; i < NSS_PPE_STATS_CODE_MAX; i++) { -- stats_shadow[i] = ppe_stats[i]; -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\t%s = %u\n", nss_ppe_stats_str_code[i], -+ ppe_stats[i]); - } - -- spin_unlock_bh(&nss_ppe_stats_lock); -- size_wr += nss_stats_print("ppe", "ppe session stats", NSS_STATS_SINGLE_INSTANCE, nss_ppe_stats_str_code, stats_shadow, -- NSS_PPE_STATS_CODE_MAX, lbuf, size_wr, size_al); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); - -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe session stats end\n"); -+ bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); - - kfree(lbuf); -- kfree(stats_shadow); - return bytes_read; - } - -@@ -574,13 +921,12 @@ static ssize_t nss_ppe_port_dc_stats_rea - int32_t i; - - /* -- * max output lines = #stats + few blank lines for future reference to add new stats. -+ * max output lines = #stats + 2 start tag line + 2 end tag line + five blank lines - */ -- uint32_t max_output_lines = NSS_PPE_STATS_DROP_CODE_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -+ uint32_t max_output_lines = (NSS_PPE_STATS_DROP_CODE_MAX + 4) + 5; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - size_t size_wr = 0; - ssize_t bytes_read = 0; -- uint64_t *stats_shadow; - struct nss_stats_data *data = fp->private_data; - uint32_t *ppe_stats; - -@@ -597,35 +943,38 @@ static ssize_t nss_ppe_port_dc_stats_rea - return 0; - } - -- stats_shadow = kzalloc((NSS_PPE_STATS_DROP_CODE_MAX) * 8, GFP_KERNEL); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- kfree(ppe_stats); -- return 0; -- } -- - /* - * Get drop code counters for specific port - */ - nss_ppe_port_drop_code_get(ppe_stats, data->edma_id); -+ size_wr = scnprintf(lbuf, size_al, "ppe no drop code stats start:\n\n"); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\t%s = %u\n", nss_ppe_stats_str_dc[0], -+ ppe_stats[0]); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe no drop code stats end\n\n"); - - /* - * Drop code stats - */ -- spin_lock_bh(&nss_ppe_stats_lock); -- for (i = 0; i < NSS_PPE_STATS_DROP_CODE_MAX; i++) { -- stats_shadow[i] = ppe_stats[i]; -- } -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "ppe non-zero drop code stats start:\n\n"); -+ for (i = 1; i < NSS_PPE_STATS_DROP_CODE_MAX; i++) { -+ /* -+ * Print only non-zero stats. -+ */ -+ if (!ppe_stats[i]) { -+ continue; -+ } - -- spin_unlock_bh(&nss_ppe_stats_lock); -- size_wr += nss_stats_print("ppe", "ppe drop code stats", NSS_STATS_SINGLE_INSTANCE, nss_ppe_stats_str_dc, -- stats_shadow, NSS_PPE_STATS_DROP_CODE_MAX, lbuf, size_wr, size_al); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\t%s = %u\n", nss_ppe_stats_str_dc[i], -+ ppe_stats[i]); -+ } -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero drop code stats end\n\n"); - - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(ppe_stats); - kfree(lbuf); -- kfree(stats_shadow); -+ - return bytes_read; - } - -@@ -638,13 +987,12 @@ static ssize_t nss_ppe_exception_cc_stat - int32_t i; - - /* -- * max output lines = #stats + few blank lines for future reference to add new stats. -+ * max output lines = #stats + start tag line + end tag line + three blank lines - */ -- uint32_t max_output_lines = NSS_PPE_STATS_CPU_CODE_EXCEPTION_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -+ uint32_t max_output_lines = (NSS_PPE_STATS_CPU_CODE_EXCEPTION_MAX + 2) + 3; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - size_t size_wr = 0; - ssize_t bytes_read = 0; -- uint64_t *stats_shadow; - uint32_t *ppe_stats; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); -@@ -660,36 +1008,34 @@ static ssize_t nss_ppe_exception_cc_stat - return 0; - } - -- stats_shadow = kzalloc(NSS_PPE_STATS_CPU_CODE_EXCEPTION_MAX * 8, GFP_KERNEL); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- kfree(ppe_stats); -- return 0; -- } -- - /* - * Get CPU code counters for flow specific exceptions - */ - nss_ppe_cpu_code_exception_get(ppe_stats); - -+ size_wr = scnprintf(lbuf, size_al, "ppe non-zero cpu code flow-exception stats start:\n\n"); -+ - /* - * CPU code stats - */ -- spin_lock_bh(&nss_ppe_stats_lock); - for (i = 0; i < NSS_PPE_STATS_CPU_CODE_EXCEPTION_MAX; i++) { -- stats_shadow[i] = ppe_stats[i]; -- } -+ /* -+ * Print only non-zero stats. -+ */ -+ if (!ppe_stats[i]) { -+ continue; -+ } - -- spin_unlock_bh(&nss_ppe_stats_lock); -- size_wr += nss_stats_print("ppe", "ppe cpu code flow-exception stats", NSS_STATS_SINGLE_INSTANCE, -- nss_ppe_stats_str_cc, stats_shadow, NSS_PPE_STATS_CPU_CODE_EXCEPTION_MAX, -- lbuf, size_wr, size_al); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\t%s = %u\n", nss_ppe_stats_str_cc[i], -+ ppe_stats[i]); -+ } - -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero cpu code flow-exception stats end\n\n"); - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(ppe_stats); - kfree(lbuf); -- kfree(stats_shadow); -+ - return bytes_read; - } - -@@ -702,13 +1048,12 @@ static ssize_t nss_ppe_nonexception_cc_s - int32_t i; - - /* -- * max output lines = #stats + few blank lines for future reference to add new stats. -+ * max output lines = #stats + start tag line + end tag line + three blank lines - */ -- uint32_t max_output_lines = NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -+ uint32_t max_output_lines = (NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_MAX + 2) + 3; - size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - size_t size_wr = 0; - ssize_t bytes_read = 0; -- uint64_t *stats_shadow; - uint32_t *ppe_stats; - - char *lbuf = kzalloc(size_al, GFP_KERNEL); -@@ -724,14 +1069,6 @@ static ssize_t nss_ppe_nonexception_cc_s - return 0; - } - -- stats_shadow = kzalloc(NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_MAX * 8, GFP_KERNEL); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- kfree(ppe_stats); -- return 0; -- } -- - /* - * Get CPU code counters for non flow exceptions - */ -@@ -740,20 +1077,23 @@ static ssize_t nss_ppe_nonexception_cc_s - /* - * CPU code stats - */ -- -- spin_lock_bh(&nss_ppe_stats_lock); -+ size_wr = scnprintf(lbuf, size_al, "ppe non-zero cpu code non-flow exception stats start:\n\n"); - for (i = 0; i < NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_MAX; i++) { -- stats_shadow[i] = ppe_stats[i]; -- } -+ /* -+ * Print only non-zero stats. -+ */ -+ if (!ppe_stats[i]) { -+ continue; -+ } - -- spin_unlock_bh(&nss_ppe_stats_lock); -- size_wr += nss_stats_print("ppe", "ppe cpu code non-flow exception stats", NSS_STATS_SINGLE_INSTANCE, -- &nss_ppe_stats_str_cc[NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_START], -- stats_shadow, NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_MAX, lbuf, size_wr, size_al); -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -+ "\t%s = %u\n", nss_ppe_stats_str_cc[i + NSS_PPE_STATS_CPU_CODE_NONEXCEPTION_START], -+ ppe_stats[i]); -+ } - -+ size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\nppe non-zero cpu code non-flow exception stats end\n\n"); - bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); - kfree(ppe_stats); -- kfree(stats_shadow); - kfree(lbuf); - - return bytes_read; -@@ -801,38 +1141,49 @@ void nss_ppe_stats_dentry_create(void) - { - int i; - struct dentry *ppe_dentry = NULL; -+ struct dentry *ppe_conn_d = NULL; -+ struct dentry *ppe_sc_d = NULL; -+ struct dentry *ppe_l3_d = NULL; -+ struct dentry *ppe_ppe_code_d = NULL; - struct dentry *ppe_code_d = NULL; - struct dentry *ppe_drop_d = NULL; -+ struct dentry *ppe_port_dc_d = NULL; - struct dentry *ppe_cpu_d = NULL; -+ struct dentry *ppe_exception_d = NULL; -+ struct dentry *ppe_nonexception_d = NULL; - char file_name[10]; - - ppe_dentry = debugfs_create_dir("ppe", nss_top_main.stats_dentry); -- if (!ppe_dentry) { -+ if (unlikely(ppe_dentry == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe directory"); - return; - } - -- if (!debugfs_create_file("connection", 0400, ppe_dentry, &nss_top_main, &nss_ppe_conn_stats_ops)) { -+ ppe_conn_d = debugfs_create_file("connection", 0400, ppe_dentry, -+ &nss_top_main, &nss_ppe_conn_stats_ops); -+ if (unlikely(ppe_conn_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe/connection file"); -- debugfs_remove_recursive(ppe_dentry); - return; - } - -- if (!debugfs_create_file("sc_stats", 0400, ppe_dentry, &nss_top_main, &nss_ppe_sc_stats_ops)) { -+ ppe_sc_d = debugfs_create_file("sc_stats", 0400, ppe_dentry, -+ &nss_top_main, &nss_ppe_sc_stats_ops); -+ if (unlikely(ppe_sc_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe/sc_stats file"); -- debugfs_remove_recursive(ppe_dentry); - return; - } - -- if (!debugfs_create_file("l3", 0400, ppe_dentry, &nss_top_main, &nss_ppe_l3_stats_ops)) { -- nss_warning("Failed to create qca-nss-drv/stats/ppe/l3 file"); -- debugfs_remove_recursive(ppe_dentry); -+ ppe_l3_d = debugfs_create_file("l3", 0400, ppe_dentry, -+ &nss_top_main, &nss_ppe_l3_stats_ops); -+ if (unlikely(ppe_l3_d == NULL)) { -+ nss_warning("Failed to create qca-nss-drv/stats/ppe/l3 filed"); - return; - } - -- if (!debugfs_create_file("ppe_code", 0400, ppe_dentry, &nss_top_main, &nss_ppe_code_stats_ops)) { -+ ppe_ppe_code_d = debugfs_create_file("ppe_code", 0400, ppe_dentry, -+ &nss_top_main, &nss_ppe_code_stats_ops); -+ if (unlikely(ppe_ppe_code_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe/ppe_code file"); -- debugfs_remove_recursive(ppe_dentry); - return; - } - -@@ -840,31 +1191,33 @@ void nss_ppe_stats_dentry_create(void) - * ppe exception and drop code stats - */ - ppe_code_d = debugfs_create_dir("code", ppe_dentry); -- if (!ppe_code_d) { -+ if (unlikely(ppe_code_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe/code directory"); - return; - } - - ppe_cpu_d = debugfs_create_dir("cpu", ppe_code_d); -- if (!ppe_cpu_d) { -+ if (unlikely(ppe_cpu_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe/code/cpu directory"); - return; - } - -- if (!debugfs_create_file("exception", 0400, ppe_cpu_d, &nss_top_main, &nss_ppe_exception_cc_stats_ops)) { -+ ppe_exception_d = debugfs_create_file("exception", 0400, ppe_cpu_d, -+ &nss_top_main, &nss_ppe_exception_cc_stats_ops); -+ if (unlikely(ppe_exception_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe/code/exception file"); -- debugfs_remove_recursive(ppe_cpu_d); - return; - } - -- if (!debugfs_create_file("non-exception", 0400, ppe_cpu_d, &nss_top_main, &nss_ppe_nonexception_cc_stats_ops)) { -+ ppe_nonexception_d = debugfs_create_file("non-exception", 0400, ppe_cpu_d, -+ &nss_top_main, &nss_ppe_nonexception_cc_stats_ops); -+ if (unlikely(ppe_nonexception_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe/code/non-exception file"); -- debugfs_remove_recursive(ppe_cpu_d); - return; - } - - ppe_drop_d = debugfs_create_dir("drop", ppe_code_d); -- if (!ppe_drop_d) { -+ if (unlikely(ppe_drop_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe/code/drop directory"); - return; - } -@@ -875,51 +1228,11 @@ void nss_ppe_stats_dentry_create(void) - snprintf(file_name, sizeof(file_name), "%d", i); - } - -- if (!debugfs_create_file((i == 0) ? "cpu" : file_name, 0400, ppe_drop_d, -- (void *)(nss_ptr_t)i, &nss_ppe_port_dc_stats_ops)) { -+ ppe_port_dc_d = debugfs_create_file((i == 0) ? "cpu" : file_name, 0400, ppe_drop_d, -+ (void *)(nss_ptr_t)i, &nss_ppe_port_dc_stats_ops); -+ if (unlikely(ppe_port_dc_d == NULL)) { - nss_warning("Failed to create qca-nss-drv/stats/ppe/code/drop/%d file", i); -- debugfs_remove_recursive(ppe_drop_d); - return; - } - } - } -- --/* -- * nss_ppe_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_ppe_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_ppe_stats_notification ppe_stats; -- -- spin_lock_bh(&nss_ppe_stats_lock); -- ppe_stats.core_id = nss_ctx->id; -- ppe_stats.if_num = if_num; -- memcpy(ppe_stats.ppe_stats_conn, nss_ppe_debug_stats.conn_stats, sizeof(ppe_stats.ppe_stats_conn)); -- memcpy(ppe_stats.ppe_stats_sc, nss_ppe_debug_stats.sc_stats, sizeof(ppe_stats.ppe_stats_sc)); -- spin_unlock_bh(&nss_ppe_stats_lock); -- -- atomic_notifier_call_chain(&nss_ppe_stats_notifier, NSS_STATS_EVENT_NOTIFY, &ppe_stats); --} -- --/* -- * nss_ppe_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_ppe_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_ppe_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_ppe_stats_unregister_notifier); -- --/* -- * nss_ppe_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_ppe_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_ppe_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_ppe_stats_register_notifier); ---- a/nss_ppe_stats.h -+++ b/nss_ppe_stats.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2018, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2018, 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. -@@ -22,8 +22,6 @@ - #ifndef __NSS_PPE_STATS_H - #define __NSS_PPE_STATS_H - --#include -- - /* - * NSS PPE connection statistics - */ -@@ -72,16 +70,6 @@ enum nss_ppe_stats_conn { - }; - - /* -- * NSS PPE SC statistics -- */ --enum nss_ppe_stats_service_code { -- NSS_PPE_STATS_SERVICE_CODE_CB_UNREGISTER, -- NSS_PPE_STATS_SERVICE_CODE_PROCESS_OK, -- NSS_PPE_STATS_SERVICE_CODE_PROCESS_FAIL, -- NSS_PPE_STATS_SERVICE_CODE_MAX --}; -- --/* - * NSS PPE L3 statistics - */ - enum nss_ppe_stats_l3 { -@@ -412,7 +400,7 @@ struct nss_ppe_sc_stats_debug { - * NSS PPE statistics - */ - struct nss_ppe_stats_debug { -- uint64_t conn_stats[NSS_PPE_STATS_CONN_MAX]; -+ uint32_t conn_stats[NSS_PPE_STATS_CONN_MAX]; - uint32_t l3_stats[NSS_PPE_STATS_L3_MAX]; - uint32_t code_stats[NSS_PPE_STATS_CODE_MAX]; - struct nss_ppe_sc_stats_debug sc_stats[NSS_PPE_SC_MAX]; -@@ -426,21 +414,9 @@ struct nss_ppe_stats_debug { - */ - extern struct nss_ppe_stats_debug nss_ppe_debug_stats; - --/** -- * nss_ppe_stats_notification -- * PPE transmission statistics structure. -- */ --struct nss_ppe_stats_notification { -- struct nss_ppe_sc_stats_debug ppe_stats_sc[NSS_PPE_SC_MAX]; /* PPE service code stats. */ -- uint64_t ppe_stats_conn[NSS_PPE_STATS_CONN_MAX]; /* PPE connection statistics. */ -- uint32_t core_id; /* Core ID. */ -- uint32_t if_num; /* Interface number. */ --}; -- - /* - * NSS PPE statistics APIs - */ --extern void nss_ppe_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); - extern void nss_ppe_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_ppe_sync_stats_msg *stats_msg, uint16_t if_num); - extern void nss_ppe_stats_dentry_create(void); - ---- a/nss_ppe_strings.c -+++ /dev/null -@@ -1,532 +0,0 @@ --/* -- *************************************************************************** -- * 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; -- } --} ---- a/nss_ppe_strings.h -+++ /dev/null -@@ -1,32 +0,0 @@ --/* -- *************************************************************************** -- * 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. -- *************************************************************************** -- */ -- --#ifndef __NSS_PPE_STRINGS_H --#define __NSS_PPE_STRINGS_H -- --#include "nss_ppe_stats.h" -- --extern struct nss_stats_info nss_ppe_stats_str_conn[NSS_PPE_STATS_CONN_MAX]; --extern struct nss_stats_info nss_ppe_stats_str_sc[NSS_PPE_STATS_SERVICE_CODE_MAX]; --extern struct nss_stats_info nss_ppe_stats_str_l3[NSS_PPE_STATS_L3_MAX]; --extern struct nss_stats_info nss_ppe_stats_str_code[NSS_PPE_STATS_CODE_MAX]; --extern struct nss_stats_info nss_ppe_stats_str_dc[NSS_PPE_STATS_DROP_CODE_MAX]; --extern struct nss_stats_info nss_ppe_stats_str_cc[NSS_PPE_STATS_CPU_CODE_MAX]; --extern void nss_ppe_strings_dentry_create(void); -- --#endif /* __NSS_PPE_STRINGS_H */ ---- a/nss_ppe_vp.c -+++ b/nss_ppe_vp.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -16,19 +16,11 @@ - ************************************************************************** - */ - --/* -- * Header file for qca-ssdk APIs -- */ --#include -- - #include "nss_ppe_vp.h" - #include "nss_ppe_vp_stats.h" - - #define NSS_PPE_VP_TX_TIMEOUT 1000 /* 1 Second */ - --static struct nss_vp_mapping *vp_map[NSS_MAX_DYNAMIC_INTERFACES] = {NULL}; --unsigned char nss_ppe_vp_cmd[NSS_PPE_VP_MAX_CMD_STR] __read_mostly; -- - /* - * Private data structure - */ -@@ -38,25 +30,17 @@ static struct nss_ppe_vp_pvt { - int response; - void *cb; - void *app_data; -- nss_ppe_port_t ppe_port_num; - } ppe_vp_pvt; - -+int nss_ppe_vp_enable __read_mostly = 0; -+int nss_ppe_vp_disable __read_mostly = 0; -+ - DEFINE_SPINLOCK(nss_ppe_vp_stats_lock); --DEFINE_SPINLOCK(nss_ppe_vp_map_lock); - - struct nss_ppe_vp_stats_debug nss_ppe_vp_debug_stats; - static struct dentry *nss_ppe_vp_dentry; - - /* -- * nss_ppe_vp_get_map_index() -- * Get the index of the NSS-VP number mapping array. -- */ --static inline int32_t nss_ppe_vp_get_map_index(nss_if_num_t if_num) --{ -- return (if_num - NSS_DYNAMIC_IF_START); --} -- --/* - * nss_ppe_vp_verify_ifnum() - * Verify PPE VP interface number. - */ -@@ -66,122 +50,12 @@ static inline bool nss_ppe_vp_verify_ifn - } - - /* -- * nss_ppe_vp_map_dealloc() -- * Deallocate memory for the NSS interface number and PPE VP number mapping. -- */ --static inline void nss_ppe_vp_map_dealloc(struct nss_vp_mapping *map) --{ -- vfree(map); --} -- --/* -- * nss_ppe_vp_map_alloc() -- * Allocate memory for the NSS interface number and PPE VP number mapping. -- */ --static inline struct nss_vp_mapping *nss_ppe_vp_map_alloc(void) --{ -- struct nss_vp_mapping *nss_vp_info = vzalloc(sizeof(struct nss_vp_mapping)); -- if (!nss_vp_info) { -- nss_warning("No memory for allocating NSS-VP mapping instance"); -- } -- -- return nss_vp_info; --} -- --/* -- * nss_ppe_vp_proc_help() -- * Print usage information for ppe_vp configure sysctl. -- */ --static void nss_ppe_vp_proc_help(void) --{ -- nss_info_always("== for dynamic interface types read following file =="); -- nss_info_always("/sys/kernel/debug/qca-nss-drv/stats/dynamic_if/type_names"); -- nss_info_always("NSS PPE VP create: echo > /proc/sys/nss/ppe_vp/create"); -- nss_info_always("NSS PPE VP destroy: echo > /proc/sys/nss/ppe_vp/destroy"); --} -- --/* -- * nss_ppe_vp_del_map() -- * Delete mapping between NSS interface number and VP number. -- */ --static bool nss_ppe_vp_del_map(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num) --{ -- int32_t idx; -- nss_ppe_port_t ppe_port_num; -- struct nss_vp_mapping *nss_vp_info; -- uint16_t vp_index; -- -- nss_assert((if_num >= NSS_DYNAMIC_IF_START) && (if_num < (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES))); -- -- idx = nss_ppe_vp_get_map_index(if_num); -- if ((idx < 0) || (idx >= NSS_MAX_DYNAMIC_INTERFACES)) { -- nss_warning("%px: Invalid index. Cannot delete the PPE VP mapping. idx:%u", nss_ctx, idx); -- return false; -- } -- -- spin_lock_bh(&nss_ppe_vp_map_lock); -- nss_vp_info = vp_map[idx]; -- if (!nss_vp_info) { -- spin_unlock_bh(&nss_ppe_vp_map_lock); -- nss_warning("%px: Could not find the vp num in the mapping. NSS if num:%u", nss_ctx, if_num); -- return false; -- } -- -- ppe_port_num = nss_vp_info->ppe_port_num; -- -- nss_ppe_vp_map_dealloc(nss_vp_info); -- vp_map[idx] = NULL; -- spin_unlock_bh(&nss_ppe_vp_map_lock); -- -- /* -- * Clear the PPE VP stats once PPE VP is deleted -- */ -- vp_index = ppe_port_num - NSS_PPE_VP_START; -- spin_lock_bh(&nss_ppe_vp_stats_lock); -- memset(&nss_ppe_vp_debug_stats.vp_stats[vp_index], 0, sizeof(struct nss_ppe_vp_statistics_debug)); -- spin_unlock_bh(&nss_ppe_vp_stats_lock); -- -- nss_info("%px: Deleted NSS interface number and PPE VP number mapping successfully: NSS if num:%u at index:%u", nss_ctx, if_num, idx); -- -- return true; --} -- --/* -- * nss_ppe_vp_add_map() -- * Add mapping between NSS interface number and VP number. -+ * nss_ppe_vp_get_context() -+ * Get NSS context instance for ppe_vp - */ --static bool nss_ppe_vp_add_map(struct nss_ctx_instance *nss_ctx ,nss_if_num_t if_num, struct nss_vp_mapping *nss_vp_info) -+struct nss_ctx_instance *nss_ppe_vp_get_context(void) - { -- uint32_t idx; -- nss_ppe_port_t ppe_port_num; -- -- nss_assert((if_num >= NSS_DYNAMIC_IF_START) && (if_num < (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES))); -- -- if (!nss_vp_info) { -- nss_warning("%px: Received invalid argument.", nss_ctx); -- return false; -- } -- -- idx = nss_ppe_vp_get_map_index(if_num); -- if ((idx < 0) || (idx >= NSS_MAX_DYNAMIC_INTERFACES)) { -- nss_warning("%px: Invalid index. Cannot add the PPE VP mapping. idx:%u", nss_ctx, idx); -- return false; -- } -- -- spin_lock_bh(&nss_ppe_vp_map_lock); -- if (vp_map[idx]) { -- spin_unlock_bh(&nss_ppe_vp_map_lock); -- nss_warning("%px: Mapping exists already. NSS if num:%d index:%u, VP num:%u", nss_ctx, if_num, idx, vp_map[idx]->ppe_port_num); -- return false; -- } -- -- vp_map[idx] = nss_vp_info; -- ppe_port_num = vp_map[idx]->ppe_port_num; -- spin_unlock_bh(&nss_ppe_vp_map_lock); -- -- nss_info("%px: Mapping added successfully. NSS if num:%d index:%u, VP num:%u", nss_ctx, if_num, idx, ppe_port_num); -- -- return true; -+ return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.ppe_handler_id]; - } - - /* -@@ -191,107 +65,21 @@ static bool nss_ppe_vp_add_map(struct ns - static void nss_ppe_vp_callback(void *app_data, struct nss_ppe_vp_msg *npvm) - { - if (npvm->cm.response != NSS_CMN_RESPONSE_ACK) { -- nss_warning("ppe_vp error response %d", npvm->cm.response); -- ppe_vp_pvt.response = NSS_TX_FAILURE; -- complete(&ppe_vp_pvt.complete); -- return; -+ nss_warning("ppe_vp error response %d\n", npvm->cm.response); -+ ppe_vp_pvt.response = npvm->cm.response; - } - -- if (npvm->cm.type == NSS_IF_PPE_PORT_CREATE) { -- ppe_vp_pvt.ppe_port_num = npvm->msg.if_msg.ppe_port_create.ppe_port_num; -- nss_trace("PPE VP callback success VP num: %u", npvm->msg.if_msg.ppe_port_create.ppe_port_num); -- } - ppe_vp_pvt.response = NSS_TX_SUCCESS; -- - complete(&ppe_vp_pvt.complete); - } - - /* -- * nss_ppe_vp_parse_vp_cmd() -- * Parse PPE VP create and destroy message and return the NSS interface number. -- * Command usage: -- * echo /proc/sys/nss/ppe_vp/create> -- * echo ath0 6 > /proc/sys/nss/ppe_vp/create -- * Since ath0 has only one type i.e. ath0 is NSS_DYNAMIC_INTERFACE_TYPE_VAP, the above command can be rewritten as -- * echo ath0 > /proc/sys/nss/ppe_vp/create => Here 6 can be ignored. -- */ --static nss_if_num_t nss_ppe_vp_parse_vp_cmd(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) --{ -- int32_t if_num; -- struct net_device *dev; -- uint32_t dynamic_if_type = (uint32_t)NSS_DYNAMIC_INTERFACE_TYPE_NONE; -- struct nss_ctx_instance *nss_ctx = nss_ppe_vp_get_context(); -- char *pos; -- char cmd_buf[NSS_PPE_VP_MAX_CMD_STR] = {0}, dev_name[NSS_PPE_VP_MAX_CMD_STR] = {0}; -- size_t count = *lenp; -- int ret = proc_dostring(ctl, write, buffer, lenp, ppos); -- -- if (!write) { -- nss_ppe_vp_proc_help(); -- return ret; -- } -- -- if (!nss_ctx) { -- nss_warning("%px: NSS Context not found.", nss_ctx); -- return -ENODEV; -- } -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- if (count >= NSS_PPE_VP_MAX_CMD_STR) { -- nss_ppe_vp_proc_help(); -- nss_warning("%px: Input string too big", nss_ctx); -- return -E2BIG; -- } -- -- if (copy_from_user(cmd_buf, buffer, count)) { -- nss_warning("%px: Cannot copy user's entry to kernel memory", nss_ctx); -- return -EFAULT; -- } -- -- if ((pos = strrchr(cmd_buf, '\n')) != NULL) { -- *pos = '\0'; -- } -- -- if (sscanf(cmd_buf, "%s %u", dev_name, &dynamic_if_type) < 0) { -- nss_warning("%px: PPE VP command parse failed", nss_ctx); -- return -EFAULT; -- } -- -- dev = dev_get_by_name(&init_net, dev_name); -- if (!dev) { -- nss_warning("%px: Cannot find the net device", nss_ctx); -- return -ENODEV; -- } -- -- nss_info("%px: Dynamic interface type: %u", nss_ctx, dynamic_if_type); -- if ((dynamic_if_type < NSS_DYNAMIC_INTERFACE_TYPE_NONE) || (dynamic_if_type >= NSS_DYNAMIC_INTERFACE_TYPE_MAX)) { -- nss_warning("%px: Invalid dynamic interface type: %d", nss_ctx, dynamic_if_type); -- dev_put(dev); -- return -EFAULT; -- } -- -- if_num = nss_cmn_get_interface_number_by_dev_and_type(dev, dynamic_if_type); -- if (if_num < 0) { -- nss_warning("%px: Invalid interface number:%s", nss_ctx, dev_name); -- dev_put(dev); -- return -EFAULT; -- } -- -- nss_info("%px: PPE VP create/destroy for, nss_if_num:%d dev_name:%s dynamic_if_type:%u", nss_ctx, if_num, dev_name, dynamic_if_type); -- dev_put(dev); -- -- return if_num; --} -- --/* - * nss_ppe_vp_tx_msg() - * Transmit a ppe_vp message to NSS FW - */ - nss_tx_status_t nss_ppe_vp_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_ppe_vp_msg *msg) - { - struct nss_cmn_msg *ncm = &msg->cm; -- nss_if_num_t if_num = ncm->interface; - - /* - * Trace messages. -@@ -301,13 +89,13 @@ nss_tx_status_t nss_ppe_vp_tx_msg(struct - /* - * Sanity check the message - */ -- if (!((ncm->type == NSS_IF_PPE_PORT_CREATE) || (ncm->type == NSS_IF_PPE_PORT_DESTROY))) { -- nss_warning("%px: Invalid message type: %d", nss_ctx, ncm->type); -+ if (ncm->type >= NSS_PPE_VP_MSG_MAX) { -+ nss_warning("%px: message type out of range: %d\n", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - -- if (!(if_num >= NSS_DYNAMIC_IF_START && (if_num < (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES)))) { -- nss_warning("%px: invalid interface %d", nss_ctx, ncm->interface); -+ if (!nss_ppe_vp_verify_ifnum(ncm->interface)) { -+ nss_warning("%px: invalid interface %d\n", nss_ctx, ncm->interface); - return NSS_TX_FAILURE; - } - -@@ -324,294 +112,63 @@ nss_tx_status_t nss_ppe_vp_tx_msg_sync(s - int ret = 0; - - down(&ppe_vp_pvt.sem); -+ npvm->cm.cb = (nss_ptr_t)nss_ppe_vp_callback; -+ npvm->cm.app_data = (nss_ptr_t)NULL; - - status = nss_ppe_vp_tx_msg(nss_ctx, npvm); - if (status != NSS_TX_SUCCESS) { -- nss_warning("%px: ppe_tx_msg failed", nss_ctx); -+ nss_warning("%px: ppe_tx_msg failed\n", nss_ctx); - up(&ppe_vp_pvt.sem); - return status; - } - - ret = wait_for_completion_timeout(&ppe_vp_pvt.complete, msecs_to_jiffies(NSS_PPE_VP_TX_TIMEOUT)); - if (!ret) { -- nss_warning("%px: ppe_vp msg tx failed due to timeout", nss_ctx); -+ nss_warning("%px: ppe_vp msg tx failed due to timeout\n", nss_ctx); - ppe_vp_pvt.response = NSS_TX_FAILURE; - } - - status = ppe_vp_pvt.response; - up(&ppe_vp_pvt.sem); -- - return status; - } - - /* -- * nss_ppe_vp_get_context() -- * Get NSS context instance for ppe_vp -- */ --struct nss_ctx_instance *nss_ppe_vp_get_context(void) --{ -- return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.ppe_handler_id]; --} --EXPORT_SYMBOL(nss_ppe_vp_get_context); -- --/* -- * nss_ppe_vp_get_ppe_port_by_nssif() -- * Get vp number for a given NSS interface number. -+ * nss_ppe_vp_tx_config_msg -+ * API to send ppe_vp support configure message to NSS FW - */ --nss_ppe_port_t nss_ppe_vp_get_ppe_port_by_nssif(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num) -+nss_tx_status_t nss_ppe_vp_tx_config_msg(enum nss_dynamic_interface_type type, bool enable) - { -- uint32_t idx; -- nss_ppe_port_t ppe_port_num; -- -- if (!((if_num >= NSS_DYNAMIC_IF_START) && (if_num < (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES)))) { -- nss_warning("%px: NSS invalid nss if num: %u", nss_ctx, if_num); -- return -1; -- } -- -- idx = nss_ppe_vp_get_map_index(if_num); -- if (idx < 0 || idx >= NSS_MAX_DYNAMIC_INTERFACES) { -- nss_warning("%px: NSS invalid index: %d nss if num: %u",nss_ctx, idx, if_num); -- return -1; -- } -- -- spin_lock_bh(&nss_ppe_vp_map_lock); -- if (!vp_map[idx]) { -- spin_unlock_bh(&nss_ppe_vp_map_lock); -- nss_warning("%px: NSS interface and VP mapping is not present for nss if num: %u",nss_ctx, if_num); -- return -1; -- } -- ppe_port_num = vp_map[idx]->ppe_port_num; -- spin_unlock_bh(&nss_ppe_vp_map_lock); -- -- nss_info("%px: VP num %d nss_if: %d",nss_ctx, ppe_port_num, if_num); -- -- return ppe_port_num; --} --EXPORT_SYMBOL(nss_ppe_vp_get_ppe_port_by_nssif); -- --/* -- * nss_ppe_vp_destroy() -- * Destroy PPE virtual port for the given nss interface number. -- */ --nss_tx_status_t nss_ppe_vp_destroy(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num) --{ -- nss_tx_status_t status; -+ struct nss_ctx_instance *nss_ctx = nss_ppe_vp_get_context(); -+ struct nss_ppe_vp_config_msg *npvcm; - struct nss_ppe_vp_msg *npvm; -- uint32_t idx; -- int32_t vsi_id_valid = false; -- int32_t vsi_id; -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- idx = nss_ppe_vp_get_map_index(if_num); -- if (idx < 0 || idx >= NSS_MAX_DYNAMIC_INTERFACES) { -- nss_warning("%px: Cannot destroy PPE VP. Invalid index: %d. nss_if_num: %u", nss_ctx, idx, if_num); -- return -1; -- } -- -- spin_lock_bh(&nss_ppe_vp_map_lock); -- if (vp_map[idx]) { -- vsi_id = vp_map[idx]->vsi_id; -- vsi_id_valid = vp_map[idx]->vsi_id_valid; -- } -- spin_unlock_bh(&nss_ppe_vp_map_lock); -- -- if (vsi_id_valid) { -- /* -- * Send the dettach VSI message to the Firmware. -- */ -- if (nss_if_vsi_unassign(nss_ctx, if_num, vsi_id)) { -- nss_warning("%px: PPE VP destroy failed. Failed to detach VSI to PPE VP interface %d vsi:%d", nss_ctx, if_num, vsi_id); -- return NSS_TX_FAILURE; -- } -- -- if (ppe_vsi_free(NSS_PPE_VP_SWITCH_ID, vsi_id)) { -- nss_warning("%px: PPE VP destroy failed. Failed to free PPE VSI. nss_if:%d vsi:%d", nss_ctx, if_num, vsi_id); -- return NSS_TX_FAILURE; -- } -- -- nss_info("%px: PPE VP VSI detached successfully. VSI ID freed successfully. NSS if num:%u, VSI ID:%u", nss_ctx, if_num, vsi_id); -- } -- -- npvm = kzalloc(sizeof(struct nss_ppe_vp_msg), GFP_KERNEL); -- if (!npvm) { -- nss_warning("%px: Unable to allocate memeory of PPE VP message", nss_ctx); -- return NSS_TX_FAILURE; -- } -- -- nss_trace("%px: PPE_VP will be destroyed for an interface: %d", nss_ctx, if_num); -- -- /* -- * Destroy PPE VP for a dynamic interface. -- */ -- nss_cmn_msg_init(&npvm->cm, if_num, NSS_IF_PPE_PORT_DESTROY, 0, nss_ppe_vp_callback, NULL); -- -- status = nss_ppe_vp_tx_msg_sync(nss_ctx, npvm); -- if (status != NSS_TX_SUCCESS) { -- nss_warning("%px: Unable to send PPE VP destroy message", nss_ctx); -- kfree(npvm); -- return NSS_TX_FAILURE; -- } -- -- kfree(npvm); -- -- /* -- * Delete mapping between the NSS interface number and the VP number. -- */ -- if (!nss_ppe_vp_del_map(nss_ctx, if_num)) { -- nss_warning("%px: Failed to delete the mapping for nss_if:%d", nss_ctx, if_num); -- return NSS_TX_FAILURE; -- } -- -- return status; --} --EXPORT_SYMBOL(nss_ppe_vp_destroy); -- --/* -- * nss_ppe_vp_create() -- * Create PPE virtual port for the given nss interface number. -- */ --nss_tx_status_t nss_ppe_vp_create(struct nss_ctx_instance *nss_ctx, nss_if_num_t if_num) --{ -- uint32_t vsi_id; - nss_tx_status_t status; -- struct nss_ppe_vp_msg *npvm; -- struct nss_vp_mapping *nss_vp_info; -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); - -- /* -- * TODO: No need to create VSI for tunnel interfaces. Only for VAP interfaces VSI is needed. -- * Allocate the VSI for the dynamic interface on which VP will be created. -- */ -- if (ppe_vsi_alloc(NSS_PPE_VP_SWITCH_ID, &vsi_id)) { -- nss_warning("%px, Failed to alloc VSI ID, PPE VP create failed. nss_if:%u", nss_ctx, if_num); -- return NSS_TX_FAILURE; -+ if (type >= NSS_DYNAMIC_INTERFACE_TYPE_MAX) { -+ nss_warning("%px: Dynamic if msg drooped as type is wrong:%d\n", nss_ctx, type); -+ return -1; - } - - npvm = kzalloc(sizeof(struct nss_ppe_vp_msg), GFP_KERNEL); - if (!npvm) { -- nss_warning("%px: Unable to allocate memeory of PPE VP message", nss_ctx); -- goto free_vsi; -+ nss_warning("%px: Unable to allocate message\n", nss_ctx); -+ return -1; - } - -- nss_trace("%px: PPE_VP will be created for an interface: %d", nss_ctx, if_num); -+ nss_cmn_msg_init(&npvm->cm, NSS_PPE_VP_INTERFACE, NSS_PPE_VP_MSG_CONFIG, -+ sizeof(struct nss_ppe_vp_config_msg), NULL, NULL); - -- /* -- * Create PPE VP for a dynamic interface. -- */ -- nss_cmn_msg_init(&npvm->cm, if_num, NSS_IF_PPE_PORT_CREATE, -- sizeof(struct nss_if_ppe_port_create), nss_ppe_vp_callback, NULL); -+ npvcm = &npvm->msg.vp_config; -+ npvcm->type = type; -+ npvcm->vp_enable = enable; - - status = nss_ppe_vp_tx_msg_sync(nss_ctx, npvm); - if (status != NSS_TX_SUCCESS) { -- nss_warning("%px: Unable to send ppe_vp create message", nss_ctx); -- goto free_alloc; -- } -- -- /* -- * Send the attach VSI message to the Firmware. -- */ -- if (nss_if_vsi_assign(nss_ctx, if_num, vsi_id) != NSS_TX_SUCCESS) { -- nss_warning("%px: Failed to attach VSI to PPE VP interface. nss_if:%u vsi:%u", nss_ctx, if_num, vsi_id); -- goto destroy_vp; -- } -- -- nss_vp_info = nss_ppe_vp_map_alloc(); -- if (!nss_vp_info) { -- nss_warning("%px: No memory for allocating NSS-VP mapping instance", nss_ctx); -- goto detach_vsi; -- } -- -- nss_vp_info->vsi_id = vsi_id; -- nss_vp_info->vsi_id_valid = true; -- nss_vp_info->if_num = if_num; -- nss_vp_info->ppe_port_num = ppe_vp_pvt.ppe_port_num; -- -- nss_info("%px: PPE VP allocated VSI ID:%u NSS interface number:%u VP no from Firmware:%u", nss_ctx, vsi_id, if_num, nss_vp_info->ppe_port_num); -- -- /* -- * Add mapping between the NSS interface number and the VP number. -- */ -- if (!nss_ppe_vp_add_map(nss_ctx, if_num, nss_vp_info)) { -- nss_warning("%px: Failed to add mapping for NSS interface number: %d", nss_ctx, if_num); -- goto free_nss_vp_info; -+ nss_warning("%px: Unable to send ppe_vp config message for type:%d\n", nss_ctx, type); - } - - kfree(npvm); -- - return status; -- --free_nss_vp_info: -- nss_ppe_vp_map_dealloc(nss_vp_info); -- --detach_vsi: -- nss_trace("%px: Detaching VSI ID :%u NSS Interface no:%u", nss_ctx, vsi_id, if_num); -- if (nss_if_vsi_unassign(nss_ctx, if_num, vsi_id)) { -- nss_warning("%px: Failed to free PPE VP VSI. nss_if:%u vsi:%u", nss_ctx, if_num, vsi_id); -- } -- --destroy_vp: -- nss_trace("%px: Destroy Vp for NSS Interface num:%u VP num:%u", nss_ctx, if_num, npvm->msg.if_msg.ppe_port_create.ppe_port_num); -- if (nss_ppe_vp_destroy(nss_ctx, if_num)) { -- nss_warning("%px: PPE VP destroy failed, nss_if:%u", nss_ctx, if_num); -- } -- --free_alloc: -- kfree(npvm); -- --free_vsi: -- nss_trace("%px: Free VSI ID :%u NSS Interface no:%u", nss_ctx, vsi_id, if_num); -- if (ppe_vsi_free(NSS_PPE_VP_SWITCH_ID, vsi_id)) { -- nss_warning("%px: Failed to free PPE VP VSI. NSS if num:%u vsi:%u", nss_ctx, if_num, vsi_id); -- } -- -- return NSS_TX_FAILURE; --} --EXPORT_SYMBOL(nss_ppe_vp_create); -- --/* -- * nss_ppe_vp_destroy_notify() -- * Get PPE VP destroy notification from NSS -- */ --static void nss_ppe_vp_destroy_notify(struct nss_ctx_instance *nss_ctx, struct nss_ppe_vp_destroy_notify_msg *destroy_notify) --{ -- nss_if_num_t nss_if_num; -- uint32_t i; -- int32_t vsi_id; -- bool vsi_id_valid = false; -- nss_ppe_port_t ppe_port_num = destroy_notify->ppe_port_num; -- -- /* -- * Find NSS interface number corresponding to the VP num. -- */ -- spin_lock_bh(&nss_ppe_vp_map_lock); -- for (i = 0; i < NSS_MAX_DYNAMIC_INTERFACES; i++) { -- if (vp_map[i] && (ppe_port_num == vp_map[i]->ppe_port_num)) { -- nss_if_num = vp_map[i]->if_num; -- vsi_id = vp_map[i]->vsi_id; -- vsi_id_valid = vp_map[i]->vsi_id_valid; -- break; -- } -- } -- spin_unlock_bh(&nss_ppe_vp_map_lock); -- -- if (i == NSS_MAX_DYNAMIC_INTERFACES) { -- nss_warning("%px: Could not find the NSS interface number mapping for VP number: %u\n", nss_ctx, ppe_port_num); -- return; -- } -- -- /* -- * Delete the nss_if_num to VP num mapping and reset the stats entry for this VP. -- */ -- if (!nss_ppe_vp_del_map(nss_ctx, nss_if_num)) { -- nss_warning("%px: Failed to delete the mapping for nss_if: %d\n", nss_ctx, nss_if_num); -- return; -- } -- -- if (vsi_id_valid && ppe_vsi_free(NSS_PPE_VP_SWITCH_ID, vsi_id)) { -- nss_warning("%px: Failed to free PPE VSI. nss_if: %d vsi: %d\n", nss_ctx, nss_if_num, vsi_id); -- } - } - - /* -@@ -624,48 +181,34 @@ static void nss_ppe_vp_handler(struct ns - nss_ppe_vp_msg_callback_t cb; - void *ctx; - -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- nss_trace("%px ppe_vp msg: %px\n", nss_ctx, msg); -+ nss_trace("nss_ctx: %px ppe_vp msg: %px\n", nss_ctx, msg); - BUG_ON(!nss_ppe_vp_verify_ifnum(ncm->interface)); - - /* -+ * Trace messages. -+ */ -+ nss_ppe_vp_log_rx_msg(msg); -+ -+ /* - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_PPE_VP_MSG_MAX) { -- nss_warning("%px: received invalid message %d for PPE_VP interface", nss_ctx, ncm->type); -+ nss_warning("%px: received invalid message %d for PPE_VP interface\n", nss_ctx, ncm->type); - return; - } - - if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_ppe_vp_msg)) { -- nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); -+ nss_warning("%px: Length of message is greater than required: %d\n", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - -- /* -- * Trace messages. -- */ -- nss_ppe_vp_log_rx_msg(msg); -- - switch (msg->cm.type) { - case NSS_PPE_VP_MSG_SYNC_STATS: - /* - * Per VP stats msg - */ - nss_ppe_vp_stats_sync(nss_ctx, &msg->msg.stats, ncm->interface); -- break; -- -- case NSS_PPE_VP_MSG_DESTROY_NOTIFY: -- /* -- * VP destroy notification -- */ -- nss_ppe_vp_destroy_notify(nss_ctx, &msg->msg.destroy_notify); -- break; -- } -- -- if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { -- ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data; -+ return; - } - - /* -@@ -690,76 +233,83 @@ static void nss_ppe_vp_handler(struct ns - } - - /* -- * nss_ppe_vp_destroy_handler() -- * PPE VP destroy handler. -+ * nss_ppe_vp_proc_help -+ * Print usage information for ppe_vp configure sysctl. - */ --static int nss_ppe_vp_destroy_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -+void nss_ppe_vp_proc_help(void) - { -- struct nss_ctx_instance *nss_ctx = nss_ppe_vp_get_context(); -- int32_t if_num; -- nss_tx_status_t nss_tx_status; -+ printk("== for dynamic interface types read following file ==\n"); -+ printk("/sys/kernel/debug/qca-nss-drv/stats/dynamic_if/type_names\n"); -+} - -- if (!nss_ctx) { -- nss_warning("%px: NSS Context not found.", nss_ctx); -- return -ENODEV; -- } -+/* -+ * nss_ppe_vp_enable_handler -+ * Enable VP support for specfic dynamic interface type. -+ */ -+static int nss_ppe_vp_enable_handler(struct ctl_table *table, int write, void __user *buffer, -+ size_t *lenp, loff_t *ppos) -+{ -+ nss_tx_status_t status; -+ enum nss_dynamic_interface_type type; -+ -+ int ret = proc_dointvec(table, write, buffer, lenp, ppos); -+ if (ret) -+ return ret; - -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -+ nss_info("%s:%d start\n", __func__, __LINE__); - -- if_num = nss_ppe_vp_parse_vp_cmd(ctl, write, buffer, lenp, ppos); -- if (if_num < 0) { -- nss_warning("%px: Invalid interface number: %d", nss_ctx, if_num); -- return -EFAULT; -+ if (!write) { -+ nss_info("print dynamic interface type table\n"); -+ nss_ppe_vp_proc_help(); -+ return ret; - } - -- if (nss_ppe_vp_get_ppe_port_by_nssif(nss_ctx, if_num) < 0) { -- nss_warning("%px: VP is not present for interface: %d", nss_ctx, if_num); -- return -EEXIST; -+ type = nss_ppe_vp_enable; -+ if ((type <= NSS_DYNAMIC_INTERFACE_TYPE_NONE) || (type >= NSS_DYNAMIC_INTERFACE_TYPE_MAX)) { -+ nss_warning("incorrect type: %u", nss_ppe_vp_enable); -+ nss_ppe_vp_proc_help(); -+ return -EINVAL; - } - -- nss_tx_status = nss_ppe_vp_destroy(nss_ctx, if_num); -- if (nss_tx_status != NSS_TX_SUCCESS) { -- nss_warning("%px: Sending message failed, cannot destroy PPE_VP node nss_if: %u", nss_ctx, if_num); -- return -EBUSY; -+ status = nss_ppe_vp_tx_config_msg(type, true); -+ if (status != NSS_TX_SUCCESS) { -+ nss_warning("failed to enable VP support for type: %u", type); -+ return -EINVAL; - } - - return 0; - } - - /* -- * nss_ppe_vp_create_handler() -- * PPE VP create handler. -+ * nss_ppe_vp_disable_handler -+ * Disable VP support for a given dynamic interface type. - */ --static int nss_ppe_vp_create_handler(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) -+static int nss_ppe_vp_disable_handler(struct ctl_table *table, int write, void __user *buffer, -+ size_t *lenp, loff_t *ppos) - { -- int32_t if_num; -- struct nss_ctx_instance *nss_ctx = nss_ppe_vp_get_context(); -- nss_tx_status_t nss_tx_status; -- -- if (!nss_ctx) { -- nss_warning("%px: NSS Context not found.", nss_ctx); -- return -ENODEV; -- } -+ nss_tx_status_t status; -+ enum nss_dynamic_interface_type type; - -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -+ int ret = proc_dointvec(table, write, buffer, lenp, ppos); -+ if (ret) -+ return ret; - -- if_num = nss_ppe_vp_parse_vp_cmd(ctl, write, buffer, lenp, ppos); -- if (if_num < 0) { -- nss_warning("%px: Invalid interface number: %d", nss_ctx, if_num); -- return -EFAULT; -+ if (!write) { -+ nss_ppe_vp_proc_help(); -+ return ret; - } - -- nss_info("%px: NSS interface number: %d", nss_ctx, if_num); -- -- if (nss_ppe_vp_get_ppe_port_by_nssif(nss_ctx, if_num) > 0) { -- nss_warning("%px: VP is already present for nss_if_num: %d", nss_ctx, if_num); -- return -EEXIST; -+ type = nss_ppe_vp_disable; -+ if ((type <= NSS_DYNAMIC_INTERFACE_TYPE_NONE) || (type >= NSS_DYNAMIC_INTERFACE_TYPE_MAX)) { -+ nss_warning("incorrect type: %u", nss_ppe_vp_enable); -+ nss_ppe_vp_proc_help(); -+ return -EINVAL; - } - -- nss_tx_status = nss_ppe_vp_create(nss_ctx, if_num); -- if (nss_tx_status != NSS_TX_SUCCESS) { -- nss_warning("%px: Sending message failed, cannot create PPE VP node for nss_if_num: %u", nss_ctx, if_num); -- return -EBUSY; -+ status = nss_ppe_vp_tx_config_msg(type, false); -+ if (status != NSS_TX_SUCCESS) { -+ nss_warning("failed to disable VP support for type: %u", type); -+ return -EINVAL; - } - - return 0; -@@ -767,18 +317,18 @@ static int nss_ppe_vp_create_handler(str - - static struct ctl_table nss_ppe_vp_table[] = { - { -- .procname = "create", -- .data = &nss_ppe_vp_cmd, -- .maxlen = sizeof(nss_ppe_vp_cmd), -+ .procname = "enable", -+ .data = &nss_ppe_vp_enable, -+ .maxlen = sizeof(int), - .mode = 0644, -- .proc_handler = &nss_ppe_vp_create_handler, -+ .proc_handler = &nss_ppe_vp_enable_handler, - }, - { -- .procname = "destroy", -- .data = &nss_ppe_vp_cmd, -- .maxlen = sizeof(nss_ppe_vp_cmd), -+ .procname = "disable", -+ .data = &nss_ppe_vp_disable, -+ .maxlen = sizeof(int), - .mode = 0644, -- .proc_handler = &nss_ppe_vp_destroy_handler, -+ .proc_handler = &nss_ppe_vp_disable_handler, - }, - { } - }; -@@ -839,7 +389,7 @@ void nss_ppe_vp_register_handler(void) - - nss_ppe_vp_dentry = nss_ppe_vp_stats_dentry_create(); - if (nss_ppe_vp_dentry == NULL) { -- nss_warning("%px: Not able to create debugfs entry", nss_ctx); -+ nss_warning("%px: Not able to create debugfs entry\n", nss_ctx); - return; - } - ---- a/nss_ppe_vp.h -+++ b/nss_ppe_vp.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -30,8 +30,7 @@ - #define NSS_PPE_VP_MAX_NUM 192 - #define NSS_PPE_VP_START 64 - #define NSS_PPE_VP_NODE_STATS_MAX 32 --#define NSS_PPE_VP_SWITCH_ID 0 --#define NSS_PPE_VP_MAX_CMD_STR 200 -+ - - /* - * ppe_vp nss debug stats lock -@@ -44,7 +43,7 @@ extern spinlock_t nss_ppe_vp_stats_lock; - */ - enum nss_ppe_vp_msg_error_type { - NSS_PPE_VP_MSG_ERROR_TYPE_UNKNOWN, /* Unknown message error */ -- PPE_VP_MSG_ERROR_TYPE_INVALID_DI, /* Invalid dynamic interface type */ -+ NSS_PPE_VP_MSG_ERROR_TYPE_INVALID_DI, /* Invalid dynamic interface type error */ - NSS_PPE_VP_MSG_ERROR_TYPE_MAX /* Maximum error type */ - }; - -@@ -53,18 +52,27 @@ enum nss_ppe_vp_msg_error_type { - * Message types for Packet Processing Engine (PPE) requests and responses. - */ - enum nss_ppe_vp_message_types { -+ NSS_PPE_VP_MSG_CONFIG, - NSS_PPE_VP_MSG_SYNC_STATS, -- NSS_PPE_VP_MSG_DESTROY_NOTIFY, - NSS_PPE_VP_MSG_MAX, - }; - - /* -+ * nss_ppe_vp_config_msg -+ * Message to enable/disable VP support for a specific dynamic interface type. -+ */ -+struct nss_ppe_vp_config_msg { -+ enum nss_dynamic_interface_type type; /* Interface type */ -+ bool vp_enable; /* VP support enable */ -+}; -+ -+/* - * nss_ppe_vp_statistics - * Message structure for ppe_vp statistics - */ - struct nss_ppe_vp_statistics { - uint32_t nss_if; /* NSS interface number corresponding to VP */ -- nss_ppe_port_t ppe_port_num; /* VP number */ -+ uint32_t vp_num; /* VP number */ - uint32_t rx_drop; /* Rx drops due to VP node inactive */ - uint32_t tx_drop; /* Tx drops due to VP node inactive */ - uint32_t packet_big_err; /* Number of packets not sent to PPE because packet was too large */ -@@ -83,42 +91,21 @@ struct nss_ppe_vp_sync_stats_msg { - }; - - /* -- * nss_ppe_vp_destroy_notify_msg -- * Message received as part of destroy notification from Firmware to Host. -- */ --struct nss_ppe_vp_destroy_notify_msg { -- nss_ppe_port_t ppe_port_num; /* VP number */ --}; -- --/* - * nss_ppe_vp_msg - * Message for receiving ppe_vp NSS to host messages. - */ - struct nss_ppe_vp_msg { -- struct nss_cmn_msg cm; /* Common message header. */ -+ struct nss_cmn_msg cm; /**< Common message header. */ - - /* - * Payload. - */ - union { -- union nss_if_msgs if_msg; -- /* NSS interface base messages. */ -+ struct nss_ppe_vp_config_msg vp_config; -+ /**< Enable/disable VP support for specific type */ - struct nss_ppe_vp_sync_stats_msg stats; -- /* Synchronization statistics. */ -- struct nss_ppe_vp_destroy_notify_msg destroy_notify; -- /* Information for the VP destroyed in Firmware. */ -- } msg; /* Message payload. */ --}; -- --/* -- * nss_vp_mapping -- * Structure to maintain the one-to-one mapping between the NSS interface number and VP number. -- */ --struct nss_vp_mapping { -- nss_if_num_t if_num; /* NSS interface number. */ -- nss_ppe_port_t ppe_port_num; /* PPE port number corresponding to the NSS interface number. */ -- uint32_t vsi_id; /* VSI ID allocated for NSS interface */ -- bool vsi_id_valid; /* Set to true if vsi_id field has a valid VSI else set to false. */ -+ /**< Synchronization statistics. */ -+ } msg; /**< Message payload. */ - }; - - typedef void (*nss_ppe_vp_msg_callback_t)(void *app_data, struct nss_ppe_vp_msg *msg); ---- a/nss_ppe_vp_log.c -+++ b/nss_ppe_vp_log.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -25,6 +25,15 @@ - #include "nss_ppe_vp.h" - - /* -+ * nss_ppe_vp_log_message_types_str -+ * PPE message strings -+ */ -+static int8_t *nss_ppe_vp_log_message_types_str[NSS_PPE_VP_MSG_MAX] __maybe_unused = { -+ "PPE VP Config", -+ "PPE VP Stats", -+}; -+ -+/* - * nss_ppe_vp_log_error_response_types_str - * Strings for error types for PPE-VP messages - */ -@@ -34,16 +43,15 @@ static int8_t *nss_ppe_vp_log_error_resp - }; - - /* -- * nss_ppe_vp_log_destroy_notify_msg() -- * Log NSS PPE VP destroy notification message. -+ * nss_ppe_vp_log_config_msg() -+ * Log NSS PPE VP configuration message. - */ --static void nss_ppe_vp_log_destroy_notify_msg(struct nss_ppe_vp_msg *npvm) -+static void nss_ppe_vp_log_config_msg(struct nss_ppe_vp_msg *npvm) - { -- struct nss_ppe_vp_destroy_notify_msg *npdnm __maybe_unused = &npvm->msg.destroy_notify; -- -- nss_trace("%px: NSS PPE VP destroy notification message:\n" -- "VP number: %u\n", -- npdnm, npdnm->ppe_port_num); -+ struct nss_ppe_vp_config_msg *npcm __maybe_unused = &npvm->msg.vp_config; -+ nss_trace("%px: NSS PPE VP configuration message:\n" -+ "Dynamic interface type: %d is_vp_support_enable: %d\n", -+ npcm, npcm->type, npcm->vp_enable); - } - - /* -@@ -53,25 +61,8 @@ static void nss_ppe_vp_log_destroy_notif - static void nss_ppe_vp_log_verbose(struct nss_ppe_vp_msg *npvm) - { - switch (npvm->cm.type) { -- -- case NSS_IF_PPE_PORT_CREATE: -- nss_info("%px: PPE interface create message type:%d\n", npvm, npvm->cm.type); -- break; -- -- case NSS_IF_PPE_PORT_DESTROY: -- nss_info("%px: PPE interface destroy message type:%d\n", npvm, npvm->cm.type); -- break; -- -- case NSS_IF_VSI_ASSIGN: -- nss_info("%px: PPE interface VSI assign message type:%d\n", npvm, npvm->cm.type); -- break; -- -- case NSS_IF_VSI_UNASSIGN: -- nss_info("%px: PPE interface VSI unassign message type:%d\n", npvm, npvm->cm.type); -- break; -- -- case NSS_PPE_VP_MSG_DESTROY_NOTIFY: -- nss_ppe_vp_log_destroy_notify_msg(npvm); -+ case NSS_PPE_VP_MSG_CONFIG: -+ nss_ppe_vp_log_config_msg(npvm); - break; - - case NSS_PPE_VP_MSG_SYNC_STATS: -@@ -92,13 +83,12 @@ static void nss_ppe_vp_log_verbose(struc - */ - void nss_ppe_vp_log_tx_msg(struct nss_ppe_vp_msg *npvm) - { -- -- if (!((npvm->cm.type == NSS_IF_PPE_PORT_CREATE) || (npvm->cm.type == NSS_IF_PPE_PORT_DESTROY))) { -+ if (npvm->cm.type >= NSS_PPE_VP_MSG_MAX) { - nss_warning("%px: Invalid message type\n", npvm); - return; - } - -- nss_info("%px: type:%d\n", npvm, npvm->cm.type); -+ nss_info("%px: type[%d]:%s\n", npvm, npvm->cm.type, nss_ppe_vp_log_message_types_str[npvm->cm.type]); - nss_ppe_vp_log_verbose(npvm); - } - -@@ -114,20 +104,23 @@ void nss_ppe_vp_log_rx_msg(struct nss_pp - } - - if (npvm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (npvm->cm.response == NSS_CMN_RESPONSE_ACK)) { -- nss_info("%px: type: %d, response[%d]: %s\n", npvm, npvm->cm.type, -+ nss_info("%px: type[%d]:%s, response[%d]:%s\n", npvm, npvm->cm.type, -+ nss_ppe_vp_log_message_types_str[npvm->cm.type], - npvm->cm.response, nss_cmn_response_str[npvm->cm.response]); - goto verbose; - } - - if (npvm->cm.error >= NSS_PPE_VP_MSG_ERROR_TYPE_MAX) { -- nss_warning("%px: msg failure - type: %d, response[%d]: %s, error[%d]:Invalid error\n", -- npvm, npvm->cm.type, npvm->cm.response, nss_cmn_response_str[npvm->cm.response], -+ nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", -+ npvm, npvm->cm.type, nss_ppe_vp_log_message_types_str[npvm->cm.type], -+ npvm->cm.response, nss_cmn_response_str[npvm->cm.response], - npvm->cm.error); - goto verbose; - } - -- nss_info("%px: msg nack - type: %d, response[%d]: %s, error[%d]: %s\n", -- npvm, npvm->cm.type, npvm->cm.response, nss_cmn_response_str[npvm->cm.response], -+ nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", -+ npvm, npvm->cm.type, nss_ppe_vp_log_message_types_str[npvm->cm.type], -+ npvm->cm.response, nss_cmn_response_str[npvm->cm.response], - npvm->cm.error, nss_ppe_vp_log_error_response_types_str[npvm->cm.error]); - - verbose: ---- a/nss_ppe_vp_stats.c -+++ b/nss_ppe_vp_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -69,7 +69,7 @@ struct nss_stats_info nss_ppe_vp_stats_r - * PPE VP statistics strings - */ - struct nss_stats_info nss_ppe_vp_stats_str[NSS_PPE_VP_STATS_MAX] = { -- {"ppe_port_num" , NSS_STATS_TYPE_SPECIAL}, -+ {"vp_num" , NSS_STATS_TYPE_SPECIAL}, - {"nss_if" , NSS_STATS_TYPE_SPECIAL}, - {"rx_packets" , NSS_STATS_TYPE_COMMON}, - {"rx_bytes" , NSS_STATS_TYPE_COMMON}, -@@ -109,10 +109,17 @@ void nss_ppe_vp_stats_sync(struct nss_ct - count--; - - /* -+ * If nss interface is changed from previous entry, reset the stats. -+ */ -+ vp_index = stats_msg->vp_stats[count].vp_num - NSS_PPE_VP_START; -+ if (nss_ppe_vp_debug_stats.vp_stats[vp_index].nss_if != stats_msg->vp_stats[count].nss_if) { -+ memset(&nss_ppe_vp_debug_stats.vp_stats[vp_index], 0, sizeof(struct nss_ppe_vp_statistics_debug)); -+ } -+ -+ /* - * Update stats in global array - */ -- vp_index = stats_msg->vp_stats[count].ppe_port_num - NSS_PPE_VP_START; -- nss_ppe_vp_debug_stats.vp_stats[vp_index].ppe_port_num = stats_msg->vp_stats[count].ppe_port_num; -+ nss_ppe_vp_debug_stats.vp_stats[vp_index].vp_num = stats_msg->vp_stats[count].vp_num; - nss_ppe_vp_debug_stats.vp_stats[vp_index].nss_if = stats_msg->vp_stats[count].nss_if; - nss_ppe_vp_debug_stats.vp_stats[vp_index].rx_packets += stats_msg->vp_stats[count].stats.rx_packets; - nss_ppe_vp_debug_stats.vp_stats[vp_index].rx_bytes += stats_msg->vp_stats[count].stats.rx_bytes; -@@ -125,8 +132,8 @@ void nss_ppe_vp_stats_sync(struct nss_ct - nss_ppe_vp_debug_stats.vp_stats[vp_index].tx_dropped[i] += stats_msg->vp_stats[count].stats.rx_dropped[i]; - } - -- nss_trace("sync count:%d ppe_port_num %d rx_packets %d tx_packets %d\n", -- count, stats_msg->vp_stats[count].ppe_port_num, -+ nss_trace("sync count:%d vp_num %d rx_packets %d tx_packets %d\n", -+ count, stats_msg->vp_stats[count].vp_num, - stats_msg->vp_stats[count].stats.rx_packets, - stats_msg->vp_stats[count].stats.tx_packets); - } ---- a/nss_ppe_vp_stats.h -+++ b/nss_ppe_vp_stats.h -@@ -28,7 +28,7 @@ - * NSS PPE-VP statistics - */ - struct nss_ppe_vp_statistics_debug { -- uint64_t ppe_port_num; /* VP number */ -+ uint64_t vp_num; /* VP number */ - uint64_t nss_if; /* NSS interface number corresponding to VP */ - uint64_t rx_packets; /* Number of packets received. */ - uint64_t rx_bytes; /* Number of bytes received. */ ---- a/nss_pptp.c -+++ b/nss_pptp.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2015-2020, 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. -@@ -365,7 +365,7 @@ struct nss_ctx_instance *nss_register_pp - int i = 0; - - nss_assert(nss_ctx); -- nss_assert(nss_pptp_verify_if_num(if_num)); -+ nss_assert(nss_pptp_verify_if_num()); - - nss_ctx->subsys_dp_register[if_num].type = type; - ---- a/nss_project.c -+++ b/nss_project.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2018, 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2018, 2020, 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. -@@ -21,9 +21,6 @@ - #include "nss_tx_rx_common.h" - - static int nss_project_wt_stats_enable; --static uint8_t nss_project_pri_mq_map[NSS_PROJECT_PRI_MQ_MAP_MAX_SIZE] = {0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; --module_param_array(nss_project_pri_mq_map, byte, NULL, 0); --MODULE_PARM_DESC(nss_project_pri_mq_map, "Priority to multi-queue mapping"); - - /* - * nss_project_free_wt_stats() -@@ -267,57 +264,6 @@ static int nss_project_wt_stats_handler( - } - - /* -- * nss_project_pri_mq_map_send_cfg() -- * Sends message to firmware to configure priority to multi-queue mapping. -- */ --static nss_tx_status_t nss_project_pri_mq_map_send_cfg(struct nss_ctx_instance *nss_ctx) --{ -- struct nss_project_msg *npm; -- struct nss_cmn_msg *ncm; -- nss_tx_status_t ret; -- -- npm = kzalloc(sizeof(*npm), GFP_ATOMIC); -- if (!npm) { -- nss_warning("%px: Failed to allocate buffer for message\n", nss_ctx); -- return NSS_TX_FAILURE; -- } -- -- /* -- * Populate the message -- */ -- ncm = &npm->cm; -- nss_cmn_msg_init(ncm, NSS_PROJECT_INTERFACE, -- NSS_PROJECT_MSG_SET_QUEUE_PRI_MAP_CFG, -- sizeof(struct nss_project_msg_pri_mq_map_cfg), -- NULL, NULL); -- memcpy(npm->msg.pri_mq_map_cfg.pri_mq_map, nss_project_pri_mq_map, -- sizeof(nss_project_pri_mq_map)); -- ret = nss_core_send_cmd(nss_ctx, npm, sizeof(*npm), NSS_NBUF_PAYLOAD_SIZE); -- kfree(npm); -- return ret; --} -- --/* -- * nss_project_pri_mq_map_configure() -- * API to configure priority to multi-queue mapping. -- */ --nss_tx_status_t nss_project_pri_mq_map_configure(struct nss_ctx_instance *nss_ctx) --{ -- /* -- * Check if multi-queue configuration is enabled. -- */ -- if (!nss_core_is_mq_enabled()) { -- nss_warning("%px: Multi-queue is disabled. Please enable multi-queue before configuring mapping\n", nss_ctx); -- return NSS_TX_FAILURE_NOT_SUPPORTED; -- } -- -- /* -- * Send configuration message to NSS. -- */ -- return nss_project_pri_mq_map_send_cfg(nss_ctx); --} -- --/* - * Tree of ctl_tables used to put the wt_stats proc node in the correct place in - * the file system. Allows the command $ echo 1 > proc/sys/dev/nss/project/wt_stats - * to enable worker thread statistics (echoing 0 into the same target will disable). ---- a/nss_pvxlan.c -+++ b/nss_pvxlan.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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. -@@ -80,22 +80,22 @@ static bool nss_pvxlan_hdl_instance_free - { - struct nss_pvxlan_handle *h; - -- spin_lock_bh(&nss_pvxlan_spinlock); -+ spin_lock(&nss_pvxlan_spinlock); - h = nss_pvxlan_hdl[if_num - NSS_DYNAMIC_IF_START]; - if (!h) { -- spin_unlock_bh(&nss_pvxlan_spinlock); -+ spin_unlock(&nss_pvxlan_spinlock); - nss_warning("%px: Instance does not exist: %d", nss_ctx, if_num); - return false; - } - - if (h->if_num != if_num) { -- spin_unlock_bh(&nss_pvxlan_spinlock); -+ spin_unlock(&nss_pvxlan_spinlock); - nss_warning("%px: Not correct if_num: %d", nss_ctx, if_num); - return false; - } - - nss_pvxlan_hdl[if_num - NSS_DYNAMIC_IF_START] = NULL; -- spin_unlock_bh(&nss_pvxlan_spinlock); -+ spin_unlock(&nss_pvxlan_spinlock); - kfree(h); - return true; - } -@@ -119,9 +119,9 @@ static bool nss_pvxlan_hdl_instance_allo - } - h->if_num = if_num; - -- spin_lock_bh(&nss_pvxlan_spinlock); -+ spin_lock(&nss_pvxlan_spinlock); - if (nss_pvxlan_hdl[if_num - NSS_DYNAMIC_IF_START] != NULL) { -- spin_unlock_bh(&nss_pvxlan_spinlock); -+ spin_unlock(&nss_pvxlan_spinlock); - kfree(h); - nss_warning("%px: The handle has been taken by another thread :%d", nss_ctx, if_num); - return false; -@@ -130,7 +130,7 @@ static bool nss_pvxlan_hdl_instance_allo - h->msg_callback = notify_cb; - h->app_data = app_data; - nss_pvxlan_hdl[if_num - NSS_DYNAMIC_IF_START] = h; -- spin_unlock_bh(&nss_pvxlan_spinlock); -+ spin_unlock(&nss_pvxlan_spinlock); - - return true; - } -@@ -201,13 +201,13 @@ static void nss_pvxlan_msg_handler(struc - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - uint32_t if_num = ncm->interface - NSS_DYNAMIC_IF_START; -- spin_lock_bh(&nss_pvxlan_spinlock); -+ spin_lock(&nss_pvxlan_spinlock); - h = nss_pvxlan_hdl[if_num]; - if (h) { - ncm->cb = (nss_ptr_t)h->msg_callback; - ncm->app_data = (nss_ptr_t)h->app_data; - } -- spin_unlock_bh(&nss_pvxlan_spinlock); -+ spin_unlock(&nss_pvxlan_spinlock); - - } - ---- a/nss_qrfs.c -+++ b/nss_qrfs.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2020, 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. -@@ -415,65 +415,6 @@ nss_tx_status_t nss_qrfs_set_flow_rule(s - EXPORT_SYMBOL(nss_qrfs_set_flow_rule); - - /* -- * nss_qrfs_configure_flow_rule() -- * Configures a QRFS flow rule to NSS firmware -- */ --nss_tx_status_t nss_qrfs_configure_flow_rule(uint32_t *dst_addr, uint32_t *src_addr, uint16_t dst_port, uint16_t src_port, uint32_t version, uint16_t proto, uint16_t cpu, enum nss_qrfs_msg_types type) { -- -- struct nss_qrfs_msg nqm; -- struct nss_qrfs_flow_rule_msg *nqfrm; -- nss_tx_status_t status; -- struct nss_ctx_instance *nss_ctx = NULL; -- nss_qrfs_msg_callback_t cb = NULL; -- int i; -- -- -- memset(&nqm, 0, sizeof(struct nss_qrfs_msg)); -- nss_qrfs_msg_init(&nqm, NSS_QRFS_INTERFACE, type, -- sizeof(struct nss_qrfs_flow_rule_msg), cb, (void *)nss_ctx); -- if (type == NSS_QRFS_MSG_FLOW_ADD) { -- nqfrm = &nqm.msg.flow_add; -- cb = nss_qrfs_flow_add_msg_callback; -- } else if (type == NSS_QRFS_MSG_FLOW_DELETE) { -- nqfrm = &nqm.msg.flow_delete; -- cb = nss_qrfs_flow_delete_msg_callback; -- } else { -- nss_warning("QRFS configure rule failed, not supported message type.\n"); -- return NSS_TX_FAILURE_BAD_PARAM; -- } -- -- -- nqfrm->protocol = proto; -- nqfrm->ip_version = version; -- -- if (version == 4) { -- nqfrm->src_addr[0] = src_addr[0]; -- nqfrm->dst_addr[0] = dst_addr[0]; -- } else { -- memcpy(nqfrm->src_addr, src_addr, sizeof(uint32_t) * 4); -- memcpy(nqfrm->dst_addr, dst_addr, sizeof(uint32_t) * 4); -- } -- -- nqfrm->src_port = src_port; -- nqfrm->dst_port = dst_port; -- nqfrm->cpu = cpu; -- nqfrm->if_num = 0; -- -- for(i = 0; i < NSS_CORE_MAX; i++) { -- nss_ctx = nss_qrfs_get_ctx(i); -- status = nss_qrfs_tx_msg(nss_ctx, &nqm); -- -- if (status) { -- nss_warning("%px: QRFS configure rule failed, error code: %d\n", nss_ctx, status); -- return NSS_TX_FAILURE; -- } -- } -- -- return NSS_TX_SUCCESS; --} --EXPORT_SYMBOL(nss_qrfs_configure_flow_rule); -- --/* - * nss_qrfs_register_handler() - */ - void nss_qrfs_register_handler(struct nss_ctx_instance *nss_ctx) ---- a/nss_qvpn.c -+++ b/nss_qvpn.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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. -@@ -16,11 +16,9 @@ - - #include "nss_tx_rx_common.h" - #include "nss_qvpn_stats.h" --#include "nss_qvpn_strings.h" - #include "nss_qvpn_log.h" - - #define NSS_QVPN_TX_TIMEOUT 1000 /* 1 Second */ --#define NSS_QVPN_INTERFACE_MAX_LONG BITS_TO_LONGS(NSS_MAX_NET_INTERFACES) /**< QVPN interface mapping bits. */ - - /* - * Private data structure -@@ -51,6 +49,36 @@ static bool nss_qvpn_verify_if_num(uint3 - } - - /* -+ * nss_qvpn_tunnel_stats_sync -+ * Update qvpn interface statistics. -+ */ -+static void nss_qvpn_tunnel_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm) -+{ -+ struct nss_qvpn_msg *ndcm = (struct nss_qvpn_msg *)ncm; -+ struct nss_top_instance *nss_top = nss_ctx->nss_top; -+ struct nss_qvpn_stats_sync_msg *msg_stats = &ndcm->msg.stats; -+ uint64_t *if_stats; -+ -+ spin_lock_bh(&nss_top->stats_lock); -+ -+ /* -+ * Update common node stats -+ */ -+ if_stats = nss_top->stats_node[ncm->interface]; -+ if_stats[NSS_STATS_NODE_RX_PKTS] += msg_stats->node_stats.rx_packets; -+ if_stats[NSS_STATS_NODE_RX_BYTES] += msg_stats->node_stats.rx_bytes; -+ if_stats[NSS_STATS_NODE_RX_QUEUE_0_DROPPED] += msg_stats->node_stats.rx_dropped[0]; -+ if_stats[NSS_STATS_NODE_RX_QUEUE_1_DROPPED] += msg_stats->node_stats.rx_dropped[1]; -+ if_stats[NSS_STATS_NODE_RX_QUEUE_2_DROPPED] += msg_stats->node_stats.rx_dropped[2]; -+ if_stats[NSS_STATS_NODE_RX_QUEUE_3_DROPPED] += msg_stats->node_stats.rx_dropped[3]; -+ -+ if_stats[NSS_STATS_NODE_TX_PKTS] += msg_stats->node_stats.tx_packets; -+ if_stats[NSS_STATS_NODE_TX_BYTES] += msg_stats->node_stats.tx_bytes; -+ -+ spin_unlock_bh(&nss_top->stats_lock); -+} -+ -+/* - * nss_qvpn_handler() - * Handle NSS to HLOS messages for QVPN - */ -@@ -86,8 +114,7 @@ static void nss_qvpn_handler(struct nss_ - nss_qvpn_log_rx_msg((struct nss_qvpn_msg *)ncm); - - if (ncm->type == NSS_QVPN_MSG_TYPE_SYNC_STATS) { -- nss_qvpn_stats_tunnel_sync(nss_ctx, ncm); -- nss_qvpn_stats_notify(nss_ctx, ncm->interface); -+ nss_qvpn_tunnel_stats_sync(nss_ctx, ncm); - } - - /* -@@ -96,7 +123,7 @@ static void nss_qvpn_handler(struct nss_ - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data; -+ ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; - } - - /* -@@ -340,5 +367,4 @@ void nss_qvpn_register_handler(void) - sema_init(&qvpn_pvt.sem, 1); - init_completion(&qvpn_pvt.complete); - nss_qvpn_stats_dentry_create(); -- nss_qvpn_strings_dentry_create(); - } ---- a/nss_qvpn_stats.c -+++ b/nss_qvpn_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019, 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. -@@ -16,38 +16,6 @@ - - #include "nss_core.h" - #include --#include "nss_qvpn_stats.h" --#include "nss_qvpn_strings.h" -- --/* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_qvpn_stats_notifier); -- --/* -- * Spinlock to protect qvpn statistics update/read -- */ --DEFINE_SPINLOCK(nss_qvpn_stats_lock); -- --uint64_t nss_qvpn_stats[NSS_MAX_NET_INTERFACES][NSS_STATS_NODE_MAX]; /* to store the qvpn statistics */ -- --/* -- * nss_qvpn_stats_iface_type() -- * Return a string for each interface type. -- */ --static const char *nss_qvpn_stats_iface_type(enum nss_dynamic_interface_type type) --{ -- switch (type) { -- case NSS_DYNAMIC_INTERFACE_TYPE_QVPN_INNER: -- return "qvpn_inner"; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_QVPN_OUTER: -- return "qvpn_outer"; -- -- default: -- return "invalid_interface"; -- } --} - - /* - * nss_qvpn_stats_read() -@@ -55,70 +23,51 @@ static const char *nss_qvpn_stats_iface_ - */ - static ssize_t nss_qvpn_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) - { -- /* -- * Max output lines = #stats + -- * few blank lines for banner printing + Number of Extra outputlines -- * for future reference to add new stats -- */ -- uint32_t max_output_lines = NSS_STATS_NODE_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; - struct nss_ctx_instance *nss_ctx = nss_qvpn_get_context(); - enum nss_dynamic_interface_type type; -- unsigned long *ifmap; -- uint64_t *stats_shadow; - ssize_t bytes_read = 0; -- size_t size_wr = 0; -+ size_t len = 0, size; - uint32_t if_num; -- int32_t i; -- int count; -- char *lbuf; -+ unsigned long *ifmap; -+ char *buf; - - ifmap = nss_qvpn_ifmap_get(); -- count = bitmap_weight(ifmap, NSS_MAX_NET_INTERFACES); -- if (count) { -- size_al = size_al * count; -- } -+ size = NSS_QVPN_STATS_SIZE_PER_IF * bitmap_weight(ifmap, NSS_MAX_NET_INTERFACES); - -- lbuf = vzalloc(size_al); -- if (unlikely(!lbuf)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return -ENOMEM; -- } -- -- stats_shadow = vzalloc(NSS_STATS_NODE_MAX * 8); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- vfree(lbuf); -- return -ENOMEM; -+ buf = kzalloc(size, GFP_KERNEL); -+ if (!buf) { -+ nss_warning("Could not allocate memory for local statistics buffer\n"); -+ return 0; - } - - /* - * Common node stats for each QVPN dynamic interface. - */ -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "qvpn stats", NSS_STATS_SINGLE_CORE); -+ len += nss_stats_banner(buf, len, size, "qvpn", NSS_STATS_SINGLE_CORE); - for_each_set_bit(if_num, ifmap, NSS_MAX_NET_INTERFACES) { -- - type = nss_dynamic_interface_get_type(nss_ctx, if_num); -- if ((type != NSS_DYNAMIC_INTERFACE_TYPE_QVPN_INNER) && -- (type != NSS_DYNAMIC_INTERFACE_TYPE_QVPN_OUTER)) { -- continue; -- } - -- spin_lock_bh(&nss_qvpn_stats_lock); -- for (i = 0; i < NSS_STATS_NODE_MAX; i++) { -- stats_shadow[i] = nss_qvpn_stats[if_num][i]; -+ switch (type) { -+ case NSS_DYNAMIC_INTERFACE_TYPE_QVPN_INNER: -+ len += scnprintf(buf + len, size - len, "\nInner if_num:%03u", if_num); -+ break; -+ -+ case NSS_DYNAMIC_INTERFACE_TYPE_QVPN_OUTER: -+ len += scnprintf(buf + len, size - len, "\nOuter if_num:%03u", if_num); -+ break; -+ -+ default: -+ len += scnprintf(buf + len, size - len, "\nUnknown(%d) if_num:%03u", type, if_num); -+ break; - } -- spin_unlock_bh(&nss_qvpn_stats_lock); - -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n%s if_num:%03u\n", -- nss_qvpn_stats_iface_type(type), if_num); -- size_wr += nss_stats_print("qvpn", NULL, NSS_STATS_SINGLE_INSTANCE, nss_qvpn_strings_stats, -- stats_shadow, NSS_STATS_NODE_MAX, lbuf, size_wr, size_al); -+ len += scnprintf(buf + len, size - len, "\n-------------------\n"); -+ len += nss_stats_fill_common_stats(if_num, NSS_STATS_SINGLE_INSTANCE, buf, len, size - len, "qvpn"); - } - -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- vfree(lbuf); -- vfree(stats_shadow); -+ bytes_read = simple_read_from_buffer(ubuf, sz, ppos, buf, len); -+ kfree(buf); -+ - return bytes_read; - } - -@@ -128,72 +77,6 @@ static ssize_t nss_qvpn_stats_read(struc - NSS_STATS_DECLARE_FILE_OPERATIONS(qvpn) - - /* -- * nss_qvpn_stats_tunnel_sync -- * Update qvpn interface statistics. -- */ --void nss_qvpn_stats_tunnel_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm) --{ -- struct nss_qvpn_msg *ndcm = (struct nss_qvpn_msg *)ncm; -- struct nss_qvpn_stats_sync_msg *msg_stats = &ndcm->msg.stats; -- -- spin_lock_bh(&nss_qvpn_stats_lock); -- -- /* -- * Update common node stats -- */ -- nss_qvpn_stats[ncm->interface][NSS_STATS_NODE_RX_PKTS] += msg_stats->node_stats.rx_packets; -- nss_qvpn_stats[ncm->interface][NSS_STATS_NODE_RX_BYTES] += msg_stats->node_stats.rx_bytes; -- nss_qvpn_stats[ncm->interface][NSS_STATS_NODE_RX_QUEUE_0_DROPPED] += msg_stats->node_stats.rx_dropped[0]; -- nss_qvpn_stats[ncm->interface][NSS_STATS_NODE_RX_QUEUE_1_DROPPED] += msg_stats->node_stats.rx_dropped[1]; -- nss_qvpn_stats[ncm->interface][NSS_STATS_NODE_RX_QUEUE_2_DROPPED] += msg_stats->node_stats.rx_dropped[2]; -- nss_qvpn_stats[ncm->interface][NSS_STATS_NODE_RX_QUEUE_3_DROPPED] += msg_stats->node_stats.rx_dropped[3]; -- -- nss_qvpn_stats[ncm->interface][NSS_STATS_NODE_TX_PKTS] += msg_stats->node_stats.tx_packets; -- nss_qvpn_stats[ncm->interface][NSS_STATS_NODE_TX_BYTES] += msg_stats->node_stats.tx_bytes; -- -- spin_unlock_bh(&nss_qvpn_stats_lock); --} -- --/* -- * nss_qvpn_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_qvpn_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_qvpn_stats_notification qvpn_stats; -- -- spin_lock_bh(&nss_qvpn_stats_lock); -- qvpn_stats.core_id = nss_ctx->id; -- qvpn_stats.if_num = if_num; -- memcpy(qvpn_stats.stats_ctx, nss_qvpn_stats[if_num], sizeof(qvpn_stats.stats_ctx)); -- spin_unlock_bh(&nss_qvpn_stats_lock); -- -- atomic_notifier_call_chain(&nss_qvpn_stats_notifier, NSS_STATS_EVENT_NOTIFY, &qvpn_stats); --} -- --/* -- * nss_qvpn_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_qvpn_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_qvpn_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_qvpn_stats_unregister_notifier); -- --/* -- * nss_qvpn_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_qvpn_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_qvpn_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_qvpn_stats_register_notifier); -- --/* - * nss_qvpn_stats_dentry_create() - * Create QVPN statistics debug entry. - */ ---- a/nss_qvpn_stats.h -+++ b/nss_qvpn_stats.h -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019, 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. -@@ -17,8 +17,10 @@ - #ifndef _NSS_QVPN_STATS_H_ - #define _NSS_QVPN_STATS_H_ - --extern void nss_qvpn_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); --extern void nss_qvpn_stats_tunnel_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm); --extern void nss_qvpn_stats_dentry_create(void); -+/* -+ * nss_qvpn_stats_dentry_create -+ * Creates QVPN interface statistics debug entry. -+ */ -+void nss_qvpn_stats_dentry_create(void); - - #endif /* _NSS_QVPN_STATS_H_ */ ---- a/nss_qvpn_strings.c -+++ /dev/null -@@ -1,60 +0,0 @@ --/* -- ***************************************************************************** -- * 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_strings.h" --#include "nss_qvpn_strings.h" -- --/* -- * nss_qvpn_strings_stats -- * qvpn statistics strings. -- */ --struct nss_stats_info nss_qvpn_strings_stats[NSS_STATS_NODE_MAX] = { -- {"rx_pkts", NSS_STATS_TYPE_COMMON}, -- {"rx_byts", NSS_STATS_TYPE_COMMON}, -- {"tx_pkts", NSS_STATS_TYPE_COMMON}, -- {"tx_byts", NSS_STATS_TYPE_COMMON}, -- {"rx_queue[0]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[1]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[2]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[3]_drops", NSS_STATS_TYPE_DROP} --}; -- --/* -- * nss_qvpn_strings_read() -- * Read qvpn statistics names -- */ --static ssize_t nss_qvpn_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_qvpn_strings_stats, NSS_STATS_NODE_MAX); --} -- --/* -- * nss_qvpn_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(qvpn); -- --/* -- * nss_qvpn_strings_dentry_create() -- * Create qvpn statistics strings debug entry. -- */ --void nss_qvpn_strings_dentry_create(void) --{ -- nss_strings_create_dentry("qvpn", &nss_qvpn_strings_ops); --} ---- a/nss_qvpn_strings.h -+++ /dev/null -@@ -1,27 +0,0 @@ --/* -- **************************************************************************** -- * 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. -- **************************************************************************** -- */ -- --#ifndef __NSS_QVPN_STRINGS_H --#define __NSS_QVPN_STRINGS_H -- --#include "nss_qvpn_stats.h" -- --extern struct nss_stats_info nss_qvpn_strings_stats[NSS_STATS_NODE_MAX]; --extern void nss_qvpn_strings_dentry_create(void); -- --#endif /* __NSS_QVPN_STRINGS_H */ ---- a/nss_rmnet_rx.c -+++ b/nss_rmnet_rx.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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 -@@ -29,7 +29,7 @@ - #define NSS_RMNET_RX_GET_INDEX(if_num) (if_num - NSS_DYNAMIC_IF_START) - - /* -- * Spinlock to protect the global data structure rmnet handle. -+ * Spinlock to protect the global data structure virt_handle. - */ - DEFINE_SPINLOCK(nss_rmnet_rx_lock); - -@@ -243,8 +243,6 @@ static int nss_rmnet_rx_handle_destroy_s - rmnet_rx_handle[index_h2n] = NULL; - spin_unlock_bh(&nss_rmnet_rx_lock); - -- kfree(handle->stats_h2n); -- kfree(handle->stats_n2h); - kfree(handle->pvt); - kfree(handle); - -@@ -527,27 +525,6 @@ error1: - EXPORT_SYMBOL(nss_rmnet_rx_create_sync_nexthop); - - /* -- * nss_rmnet_rx_create() -- * Create rmnet_n2h and rmnet_h2n interfaces with generic next hops and associate it with same netdev. -- * -- * When rmnet and eth_rx is running at the same core, we directly send packets to eth_rx node. -- * When they are running at different cores, the packets needs to arrive eth_rx through C2C. -- */ --struct nss_rmnet_rx_handle *nss_rmnet_rx_create(struct net_device *netdev) --{ -- uint32_t nexthop_n2h = NSS_N2H_INTERFACE; -- uint32_t nexthop_h2n = NSS_C2C_TX_INTERFACE; -- -- if (nss_top_main.rmnet_rx_handler_id == 0) { -- nexthop_h2n = NSS_ETH_RX_INTERFACE; -- } -- -- -- return nss_rmnet_rx_create_sync_nexthop(netdev, nexthop_n2h, nexthop_h2n); --} --EXPORT_SYMBOL(nss_rmnet_rx_create); -- --/* - * nss_rmnet_rx_tx_buf() - * HLOS interface has received a packet which we redirect to the NSS, if appropriate to do so. - */ ---- a/nss_rps.c -+++ b/nss_rps.c -@@ -1,12 +1,9 @@ - /* - ************************************************************************** -- * Copyright (c) 2013-2017, 2019-2021 The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. -- * -+ * Copyright (c) 2013-2017, 2019-2020 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 -@@ -281,7 +278,6 @@ static nss_tx_status_t nss_rps_cfg(struc - return NSS_SUCCESS; - } - --#ifdef NSS_DRV_IPV4_ENABLE - /* - * nss_rps_ipv4_hash_bitmap_cfg() - * Send Message to NSS to configure hash_bitmap. -@@ -310,9 +306,7 @@ static nss_tx_status_t nss_rps_ipv4_hash - up(&nss_rps_cfg_pvt.sem); - return NSS_SUCCESS; - } --#endif - --#ifdef NSS_DRV_IPV6_ENABLE - /* - * nss_rps_ipv6_hash_bitmap_cfg() - * Send Message to NSS to configure hash_bitmap. -@@ -341,7 +335,6 @@ static nss_tx_status_t nss_rps_ipv6_hash - up(&nss_rps_cfg_pvt.sem); - return NSS_SUCCESS; - } --#endif - - /* - * nss_rps_pri_map_cfg() -@@ -461,8 +454,8 @@ static int nss_rps_hash_bitmap_cfg_handl - void __user *buffer, size_t *lenp, loff_t *ppos) - { - struct nss_top_instance *nss_top = &nss_top_main; -- struct nss_ctx_instance *nss_ctx __attribute__((unused)) = &nss_top->nss[0]; -- int ret, current_state; -+ struct nss_ctx_instance *nss_ctx = &nss_top->nss[0]; -+ int ret, ret_ipv4, ret_ipv6, current_state; - - current_state = nss_rps_hash_bitmap; - ret = proc_dointvec(ctl, write, buffer, lenp, ppos); -@@ -476,45 +469,32 @@ static int nss_rps_hash_bitmap_cfg_handl - return ret; - } - --#if !defined(NSS_DRV_IPV4_ENABLE) || !defined(NSS_DRV_IPV6_ENABLE) -- nss_info_always("%px: Feature is not supported\n", nss_ctx); -- return 0; --#else - if (nss_rps_hash_bitmap <= (NSS_RPS_MAX_CORE_HASH_BITMAP)) { - nss_info("Configuring NSS RPS hash_bitmap\n"); --#ifdef NSS_DRV_IPV4_ENABLE -- { -- int ret_ipv4; -- ret_ipv4 = nss_rps_ipv4_hash_bitmap_cfg(nss_ctx, nss_rps_hash_bitmap); -- -- if (ret_ipv4 != NSS_SUCCESS) { -- nss_warning("%px: ipv4 hash_bitmap config message failed\n", nss_ctx); -- nss_rps_hash_bitmap = current_state; -- return ret_ipv4; -- } -+ ret_ipv4 = nss_rps_ipv4_hash_bitmap_cfg(nss_ctx, nss_rps_hash_bitmap); -+ -+ if (ret_ipv4 != NSS_SUCCESS) { -+ nss_warning("%px: ipv4 hash_bitmap config message failed\n", nss_ctx); -+ nss_rps_hash_bitmap = current_state; -+ return ret_ipv4; - } --#endif --#ifdef NSS_DRV_IPV6_ENABLE -- { -- int ret_ipv6; -- ret_ipv6 = nss_rps_ipv6_hash_bitmap_cfg(nss_ctx, nss_rps_hash_bitmap); -- -- if (ret_ipv6 != NSS_SUCCESS) { -- nss_warning("%px: ipv6 hash_bitmap config message failed\n", nss_ctx); -- nss_rps_hash_bitmap = current_state; -- if (nss_rps_ipv4_hash_bitmap_cfg(nss_ctx, nss_rps_hash_bitmap != NSS_SUCCESS)) { -- nss_warning("%px: ipv4 and ipv6 have different hash_bitmaps.\n", nss_ctx); -- } -- return ret_ipv6; -+ -+ ret_ipv6 = nss_rps_ipv6_hash_bitmap_cfg(nss_ctx, nss_rps_hash_bitmap); -+ -+ if (ret_ipv6 != NSS_SUCCESS) { -+ nss_warning("%px: ipv6 hash_bitmap config message failed\n", nss_ctx); -+ nss_rps_hash_bitmap = current_state; -+ if (nss_rps_ipv4_hash_bitmap_cfg(nss_ctx, nss_rps_hash_bitmap != NSS_SUCCESS)) { -+ nss_warning("%px: ipv4 and ipv6 have different hash_bitmaps.\n", nss_ctx); - } -+ return ret_ipv6; - } --#endif -+ - return 0; - } - - nss_info_always("Invalid input value. Valid values are less than %d\n", (NSS_RPS_MAX_CORE_HASH_BITMAP)); - return ret; --#endif - } - - /* nss_rps_pri_map_cfg_handler() ---- a/nss_stats.c -+++ b/nss_stats.c -@@ -1,12 +1,9 @@ - /* - ************************************************************************** - * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 -@@ -392,9 +389,7 @@ void nss_stats_create_dentry(char *name, - /* - * gmac_stats_ops - */ --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - NSS_STATS_DECLARE_FILE_OPERATIONS(gmac); --#endif - - /* - * wt_stats_ops -@@ -449,9 +444,7 @@ void nss_stats_init(void) - /* - * gmac_stats - */ --#ifdef NSS_DATA_PLANE_GENERIC_SUPPORT - nss_stats_create_dentry("gmac", &nss_gmac_stats_ops); --#endif - - /* - * Per-project stats ---- a/nss_tls.c -+++ b/nss_tls.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2020, 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 -@@ -18,10 +18,10 @@ - - #include "nss_tx_rx_common.h" - #include "nss_tls_log.h" --#include "nss_tls_stats.h" --#include "nss_tls_strings.h" - - #define NSS_TLS_INTERFACE_MAX_LONG BITS_TO_LONGS(NSS_MAX_NET_INTERFACES) -+#define NSS_TLS_STATS_MAX_LINES (NSS_STATS_NODE_MAX + 32) -+#define NSS_TLS_STATS_SIZE_PER_IF (NSS_STATS_MAX_STR_LENGTH * NSS_TLS_STATS_MAX_LINES) - #define NSS_TLS_TX_TIMEOUT 3000 /* 3 Seconds */ - - /* -@@ -35,6 +35,93 @@ static struct nss_tls_pvt { - } tls_pvt; - - /* -+ * nss_tls_stats_sync() -+ * Update tls node statistics. -+ */ -+static void nss_tls_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm) -+{ -+ struct nss_tls_msg *ndcm = (struct nss_tls_msg *)ncm; -+ struct nss_top_instance *nss_top = nss_ctx->nss_top; -+ struct nss_tls_ctx_stats *msg_stats = &ndcm->msg.stats; -+ uint64_t *if_stats; -+ int i; -+ -+ spin_lock_bh(&nss_top->stats_lock); -+ -+ /* -+ * Update common node stats, -+ * Note: TLS only supports a single queue for RX -+ */ -+ if_stats = nss_top->stats_node[ncm->interface]; -+ if_stats[NSS_STATS_NODE_RX_PKTS] += msg_stats->pkt.rx_packets; -+ if_stats[NSS_STATS_NODE_RX_BYTES] += msg_stats->pkt.rx_bytes; -+ -+ for (i = 0; i < NSS_MAX_NUM_PRI; i++) -+ if_stats[NSS_STATS_NODE_RX_QUEUE_0_DROPPED + i] += msg_stats->pkt.rx_dropped[i]; -+ -+ if_stats[NSS_STATS_NODE_TX_PKTS] += msg_stats->pkt.tx_packets; -+ if_stats[NSS_STATS_NODE_TX_BYTES] += msg_stats->pkt.tx_bytes; -+ -+ spin_unlock_bh(&nss_top->stats_lock); -+} -+ -+/* -+ * nss_tls_stats_read() -+ * Read tls node statiistics. -+ */ -+static ssize_t nss_tls_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -+{ -+ struct nss_ctx_instance *nss_ctx = nss_tls_get_context(); -+ enum nss_dynamic_interface_type type; -+ ssize_t bytes_read = 0; -+ size_t len = 0, size; -+ uint32_t if_num; -+ char *buf; -+ -+ size = NSS_TLS_STATS_SIZE_PER_IF * bitmap_weight(tls_pvt.if_map, NSS_MAX_NET_INTERFACES); -+ -+ buf = kzalloc(size, GFP_KERNEL); -+ if (!buf) { -+ nss_warning("Could not allocate memory for local statistics buffer"); -+ return 0; -+ } -+ -+ /* -+ * Common node stats for each TLS dynamic interface. -+ */ -+ for_each_set_bit(if_num, tls_pvt.if_map, NSS_MAX_NET_INTERFACES) { -+ type = nss_dynamic_interface_get_type(nss_ctx, if_num); -+ -+ switch (type) { -+ case NSS_DYNAMIC_INTERFACE_TYPE_TLS_INNER: -+ len += scnprintf(buf + len, size - len, "\nInner if_num:%03u", if_num); -+ break; -+ -+ case NSS_DYNAMIC_INTERFACE_TYPE_TLS_OUTER: -+ len += scnprintf(buf + len, size - len, "\nOuter if_num:%03u", if_num); -+ break; -+ -+ default: -+ len += scnprintf(buf + len, size - len, "\nUnknown(%d) if_num:%03u", type, if_num); -+ break; -+ } -+ -+ len += scnprintf(buf + len, size - len, "\n-------------------\n"); -+ len = nss_stats_fill_common_stats(if_num, NSS_STATS_SINGLE_INSTANCE, buf, len, size - len, "tls"); -+ } -+ -+ bytes_read = simple_read_from_buffer(ubuf, sz, ppos, buf, len); -+ kfree(buf); -+ -+ return bytes_read; -+} -+ -+/* -+ * nss_tls_stats_ops -+ */ -+NSS_STATS_DECLARE_FILE_OPERATIONS(tls) -+ -+/* - * nss_tls_verify_ifnum() - * Verify if the interface number is a TLS interface. - */ -@@ -80,17 +167,15 @@ static void nss_tls_handler(struct nss_c - return; - } - -- if (ncm->type == NSS_TLS_MSG_TYPE_CTX_SYNC) { -+ if (ncm->type == NSS_TLS_MSG_TYPE_CTX_SYNC) - nss_tls_stats_sync(nss_ctx, ncm); -- nss_tls_stats_notify(nss_ctx, ncm->interface); -- } - - /* - * Update the callback and app_data for NOTIFY messages - */ - if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { - ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[ncm->interface].app_data; -+ ncm->app_data = (nss_ptr_t)nss_ctx->nss_rx_interface_handlers[nss_ctx->id][ncm->interface].app_data; - } - - /* -@@ -144,15 +229,6 @@ static void nss_tls_sync_resp(void *app_ - } - - /* -- * nss_tls_ifmap_get() -- * Return TLS active interfaces map. -- */ --unsigned long *nss_tls_ifmap_get(void) --{ -- return tls_pvt.if_map; --} -- --/* - * nss_tls_tx_buf() - * Transmit buffer over TLS interface - */ -@@ -470,6 +546,5 @@ void nss_tls_register_handler(void) - { - sema_init(&tls_pvt.sem, 1); - init_completion(&tls_pvt.complete); -- nss_tls_stats_dentry_create(); -- nss_tls_strings_dentry_create(); -+ nss_stats_create_dentry("tls", &nss_tls_stats_ops); - } ---- a/nss_tls_stats.c -+++ /dev/null -@@ -1,206 +0,0 @@ --/* -- ****************************************************************************** -- * 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_core.h" --#include "nss_tls.h" --#include "nss_tls_stats.h" --#include "nss_tls_strings.h" -- --/* -- * Declare atomic notifier data structure for statistics. -- */ --ATOMIC_NOTIFIER_HEAD(nss_tls_stats_notifier); -- --/* -- * Spinlock to protect tls statistics update/read -- */ --DEFINE_SPINLOCK(nss_tls_stats_lock); -- --uint64_t nss_tls_stats[NSS_MAX_NET_INTERFACES][NSS_TLS_STATS_MAX]; -- --/* -- * nss_tls_stats_iface_type() -- * Return a string for each interface type. -- */ --static const char *nss_tls_stats_iface_type(enum nss_dynamic_interface_type type) --{ -- switch (type) { -- case NSS_DYNAMIC_INTERFACE_TYPE_TLS_INNER: -- return "tls_inner"; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_TLS_OUTER: -- return "tls_outer"; -- -- default: -- return "invalid_interface"; -- } --} -- --/* -- * nss_tls_stats_read() -- * Read tls node statiistics. -- */ --static ssize_t nss_tls_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- /* -- * Max output lines = #stats + -- * few blank lines for banner printing + Number of Extra outputlines -- * for future reference to add new stats -- */ -- uint32_t max_output_lines = NSS_TLS_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- struct nss_ctx_instance *nss_ctx = nss_tls_get_context(); -- enum nss_dynamic_interface_type type; -- unsigned long *ifmap; -- uint64_t *stats_shadow; -- ssize_t bytes_read = 0; -- size_t size_wr = 0; -- uint32_t if_num; -- int32_t i; -- int count; -- char *lbuf; -- -- ifmap = nss_tls_ifmap_get(); -- count = bitmap_weight(ifmap, NSS_MAX_NET_INTERFACES); -- if (count) { -- size_al = size_al * count; -- } -- -- lbuf = vzalloc(size_al); -- if (unlikely(!lbuf)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return -ENOMEM; -- } -- -- stats_shadow = vzalloc(NSS_TLS_STATS_MAX * 8); -- if (unlikely(!stats_shadow)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- vfree(lbuf); -- return -ENOMEM; -- } -- -- /* -- * Common node stats for each TLS dynamic interface. -- */ -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "tls stats", NSS_STATS_SINGLE_CORE); -- for_each_set_bit(if_num, ifmap, NSS_MAX_NET_INTERFACES) { -- -- type = nss_dynamic_interface_get_type(nss_ctx, if_num); -- if ((type != NSS_DYNAMIC_INTERFACE_TYPE_TLS_INNER) && -- (type != NSS_DYNAMIC_INTERFACE_TYPE_TLS_OUTER)) { -- continue; -- } -- -- spin_lock_bh(&nss_tls_stats_lock); -- for (i = 0; i < NSS_TLS_STATS_MAX; i++) { -- stats_shadow[i] = nss_tls_stats[if_num][i]; -- } -- spin_unlock_bh(&nss_tls_stats_lock); -- -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n%s if_num:%03u\n", -- nss_tls_stats_iface_type(type), if_num); -- size_wr += nss_stats_print("tls", NULL, NSS_STATS_SINGLE_INSTANCE, nss_tls_strings_stats, -- stats_shadow, NSS_TLS_STATS_MAX, lbuf, size_wr, size_al); -- } -- -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- vfree(lbuf); -- vfree(stats_shadow); -- return bytes_read; --} -- --/* -- * nss_tls_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(tls); -- --/* -- * nss_tls_stats_dentry_create() -- * Create tls statistics debug entry. -- */ --void nss_tls_stats_dentry_create(void) --{ -- nss_stats_create_dentry("tls", &nss_tls_stats_ops); --} -- --/* -- * nss_tls_stats_sync() -- * Update tls node statistics. -- */ --void nss_tls_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm) --{ -- struct nss_tls_msg *ndcm = (struct nss_tls_msg *)ncm; -- struct nss_tls_ctx_stats *ndccs = &ndcm->msg.stats; -- uint64_t *ctx_stats; -- uint32_t *msg_stats; -- int i; -- -- spin_lock_bh(&nss_tls_stats_lock); -- -- /* -- * Update common node stats, -- * Note: TLS only supports a single queue for RX -- */ -- msg_stats = (uint32_t *)ndccs; -- ctx_stats = nss_tls_stats[ncm->interface]; -- -- for (i = 0; i < NSS_TLS_STATS_MAX; i++, ctx_stats++, msg_stats++) { -- *ctx_stats += *msg_stats; -- } -- -- spin_unlock_bh(&nss_tls_stats_lock); --} -- --/* -- * nss_tls_stats_notify() -- * Sends notifications to all the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_tls_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num) --{ -- struct nss_tls_stats_notification tls_stats; -- -- spin_lock_bh(&nss_tls_stats_lock); -- tls_stats.core_id = nss_ctx->id; -- tls_stats.if_num = if_num; -- memcpy(tls_stats.stats_ctx, nss_tls_stats[if_num], sizeof(tls_stats.stats_ctx)); -- spin_unlock_bh(&nss_tls_stats_lock); -- -- atomic_notifier_call_chain(&nss_tls_stats_notifier, NSS_STATS_EVENT_NOTIFY, &tls_stats); --} -- --/* -- * nss_tls_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_tls_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_tls_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_tls_stats_unregister_notifier); -- --/* -- * nss_tls_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_tls_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_tls_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_tls_stats_register_notifier); ---- a/nss_tls_stats.h -+++ /dev/null -@@ -1,28 +0,0 @@ --/* -- ****************************************************************************** -- * 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. -- ****************************************************************************** -- */ -- --#ifndef __NSS_TLS_STATS_H --#define __NSS_TLS_STATS_H -- --#include -- --extern void nss_tls_stats_notify(struct nss_ctx_instance *nss_ctx, uint32_t if_num); --extern void nss_tls_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm); --extern void nss_tls_stats_dentry_create(void); -- --#endif /* __NSS_TLS_STATS_H */ ---- a/nss_tls_strings.c -+++ /dev/null -@@ -1,88 +0,0 @@ --/* -- ****************************************************************************** -- * 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_strings.h" --#include "nss_tls_strings.h" -- --/* -- * nss_tls_strings_stats -- * tls statistics strings. -- */ --struct nss_stats_info nss_tls_strings_stats[NSS_TLS_STATS_MAX] = { -- {"rx_pkts", NSS_STATS_TYPE_COMMON}, -- {"rx_byts", NSS_STATS_TYPE_COMMON}, -- {"tx_pkts", NSS_STATS_TYPE_COMMON}, -- {"tx_byts", NSS_STATS_TYPE_COMMON}, -- {"rx_queue[0]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[1]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[2]_drops", NSS_STATS_TYPE_DROP}, -- {"rx_queue[3]_drops", NSS_STATS_TYPE_DROP}, -- {"single_rec", NSS_STATS_TYPE_SPECIAL}, -- {"multi_rec", NSS_STATS_TYPE_SPECIAL}, -- {"tx_inval_reqs", NSS_STATS_TYPE_SPECIAL}, -- {"rx_ccs_rec", NSS_STATS_TYPE_SPECIAL}, -- {"fail_ccs", NSS_STATS_TYPE_ERROR}, -- {"eth_node_deactive", NSS_STATS_TYPE_SPECIAL}, -- {"crypto_alloc_success", NSS_STATS_TYPE_SPECIAL}, -- {"crypto_free_req", NSS_STATS_TYPE_SPECIAL}, -- {"crypto_free_success", NSS_STATS_TYPE_SPECIAL}, -- {"fail_crypto_alloc", NSS_STATS_TYPE_EXCEPTION}, -- {"fail_crypto_lookup", NSS_STATS_TYPE_EXCEPTION}, -- {"fail_req_alloc", NSS_STATS_TYPE_ERROR}, -- {"fail_pbuf_stats", NSS_STATS_TYPE_ERROR}, -- {"fail_ctx_active", NSS_STATS_TYPE_ERROR}, -- {"hw_len_error", NSS_STATS_TYPE_ERROR}, -- {"hw_token_error", NSS_STATS_TYPE_ERROR}, -- {"hw_bypass_error", NSS_STATS_TYPE_ERROR}, -- {"hw_crypto_error", NSS_STATS_TYPE_ERROR}, -- {"hw_hash_error", NSS_STATS_TYPE_ERROR}, -- {"hw_config_error", NSS_STATS_TYPE_ERROR}, -- {"hw_algo_error", NSS_STATS_TYPE_ERROR}, -- {"hw_hash_ovf_error", NSS_STATS_TYPE_ERROR}, -- {"hw_auth_error", NSS_STATS_TYPE_ERROR}, -- {"hw_pad_verify_error", NSS_STATS_TYPE_ERROR}, -- {"hw_timeout_error", NSS_STATS_TYPE_ERROR}, -- {"no_desc_in", NSS_STATS_TYPE_EXCEPTION}, -- {"no_desc_out", NSS_STATS_TYPE_EXCEPTION}, -- {"no_reqs", NSS_STATS_TYPE_EXCEPTION} --}; -- --/* -- * nss_tls_strings_read() -- * Read tls statistics names -- */ --static ssize_t nss_tls_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_tls_strings_stats, NSS_TLS_STATS_MAX); --} -- --/* -- * nss_tls_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(tls); -- --/* -- * nss_tls_strings_dentry_create() -- * Create tls statistics strings debug entry. -- */ --void nss_tls_strings_dentry_create(void) --{ -- nss_strings_create_dentry("tls", &nss_tls_strings_ops); --} ---- a/nss_trustsec_rx.c -+++ /dev/null -@@ -1,214 +0,0 @@ --/* -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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_tx_rx_common.h" --#include "nss_trustsec_rx_stats.h" --#include "nss_trustsec_rx_log.h" -- --#define NSS_TRUSTSEC_RX_TIMEOUT 3000 /* 3 Seconds */ -- --/* -- * Private data structure for trustsec_rx interface -- */ --static struct nss_trustsec_rx_pvt { -- struct semaphore sem; -- struct completion complete; -- int response; --} ttx; -- --/* -- * nss_trustsec_rx_handler() -- * Handle NSS -> HLOS messages for trustsec_rx -- */ --static void nss_trustsec_rx_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, -- __attribute__((unused))void *app_data) --{ -- nss_trustsec_rx_msg_callback_t cb; -- struct nss_trustsec_rx_msg *msg = (struct nss_trustsec_rx_msg *)ncm; -- -- BUG_ON(ncm->interface != NSS_TRUSTSEC_RX_INTERFACE); -- -- /* -- * Trace messages. -- */ -- nss_trustsec_rx_log_rx_msg(msg); -- -- /* -- * Is this a valid request/response packet? -- */ -- if (ncm->type >= NSS_TRUSTSEC_RX_MSG_MAX) { -- nss_warning("%px: received invalid message %d for trustsec_rx interface", nss_ctx, ncm->type); -- return; -- } -- -- if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_trustsec_rx_msg)) { -- nss_warning("%px: message size incorrect: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); -- return; -- } -- -- /* -- * Log failures -- */ -- nss_core_log_msg_failures(nss_ctx, ncm); -- -- switch (ncm->type) { -- case NSS_TRUSTSEC_RX_MSG_STATS_SYNC: -- /* -- * Update trustsec_rx statistics. -- */ -- nss_trustsec_rx_stats_sync(nss_ctx, &msg->msg.stats_sync); -- break; -- } -- -- /* -- * Update the callback and app_data for NOTIFY messages, trustsec_rx sends all notify messages -- * to the same callback/app_data. -- */ -- if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { -- ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].ndev; -- } -- -- /* -- * Do we have a call back -- */ -- if (!ncm->cb) { -- return; -- } -- -- /* -- * callback -- */ -- cb = (nss_trustsec_rx_msg_callback_t)ncm->cb; -- -- cb((void *)ncm->app_data, msg); --} -- --/* -- * nss_trustsec_rx_msg() -- * Transmit a trustsec_rx message to NSSFW -- */ --static nss_tx_status_t nss_trustsec_rx_msg(struct nss_ctx_instance *nss_ctx, struct nss_trustsec_rx_msg *msg) --{ -- struct nss_cmn_msg *ncm = &msg->cm; -- -- /* -- * Trace messages. -- */ -- nss_trustsec_rx_log_tx_msg(msg); -- -- /* -- * Sanity check the message -- */ -- if (ncm->interface != NSS_TRUSTSEC_RX_INTERFACE) { -- nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); -- return NSS_TX_FAILURE; -- } -- -- if (ncm->type > NSS_TRUSTSEC_RX_MSG_MAX) { -- nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); -- return NSS_TX_FAILURE; -- } -- -- return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); --} -- --/* -- * nss_trustsec_rx_callback -- * Callback to handle the completion of NSS ->HLOS messages. -- */ --static void nss_trustsec_rx_callback(void *app_data, struct nss_trustsec_rx_msg *msg) --{ -- if (msg->cm.response != NSS_CMN_RESPONSE_ACK) { -- nss_warning("trustsec_rx error response %d\n", msg->cm.response); -- ttx.response = NSS_TX_FAILURE; -- complete(&ttx.complete); -- return; -- } -- -- ttx.response = NSS_TX_SUCCESS; -- complete(&ttx.complete); --} -- --/* -- * nss_trustsec_rx_msg_sync() -- * Send a message to trustsec_rx interface & wait for the response. -- */ --nss_tx_status_t nss_trustsec_rx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_trustsec_rx_msg *msg) --{ -- nss_tx_status_t status; -- int ret = 0; -- -- down(&ttx.sem); -- -- msg->cm.cb = (nss_ptr_t)nss_trustsec_rx_callback; -- msg->cm.app_data = (nss_ptr_t)NULL; -- -- status = nss_trustsec_rx_msg(nss_ctx, msg); -- if (status != NSS_TX_SUCCESS) { -- nss_warning("%px: nss_trustsec_rx_msg failed\n", nss_ctx); -- up(&ttx.sem); -- return status; -- } -- -- ret = wait_for_completion_timeout(&ttx.complete, msecs_to_jiffies(NSS_TRUSTSEC_RX_TIMEOUT)); -- if (!ret) { -- nss_warning("%px: trustsec_rx tx failed due to timeout\n", nss_ctx); -- ttx.response = NSS_TX_FAILURE; -- } -- -- status = ttx.response; -- up(&ttx.sem); -- -- return status; --} --EXPORT_SYMBOL(nss_trustsec_rx_msg_sync); -- --/* -- * nss_trustsec_rx_get_ctx() -- * Return a TrustSec TX NSS context. -- */ --struct nss_ctx_instance *nss_trustsec_rx_get_ctx() --{ -- return &nss_top_main.nss[nss_top_main.trustsec_rx_handler_id]; --} --EXPORT_SYMBOL(nss_trustsec_rx_get_ctx); -- --/* -- * nss_trustsec_rx_msg_init() -- * Initialize trustsec_rx message. -- */ --void nss_trustsec_rx_msg_init(struct nss_trustsec_rx_msg *msg, uint16_t if_num, uint32_t type, uint32_t len, -- nss_trustsec_rx_msg_callback_t cb, void *app_data) --{ -- nss_cmn_msg_init(&msg->cm, if_num, type, len, (void *)cb, app_data); --} --EXPORT_SYMBOL(nss_trustsec_rx_msg_init); -- --/* -- * nss_trustsec_rx_register_handler() -- * Registering handler for sending msg to trustsec_rx node on NSS. -- */ --void nss_trustsec_rx_register_handler(void) --{ -- struct nss_ctx_instance *nss_ctx = nss_trustsec_rx_get_ctx(); -- -- nss_core_register_handler(nss_ctx, NSS_TRUSTSEC_RX_INTERFACE, nss_trustsec_rx_handler, NULL); -- -- nss_trustsec_rx_stats_dentry_create(); -- -- sema_init(&ttx.sem, 1); -- init_completion(&ttx.complete); --} ---- a/nss_trustsec_rx_log.c -+++ /dev/null -@@ -1,220 +0,0 @@ --/* -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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. -- */ -- --/* -- * nss_trustsec_rx_log.c -- * NSS TRUSTSEC_RX logger file. -- */ -- --#include "nss_core.h" -- --/* -- * nss_trustsec_rx_log_message_types_str -- * TRUSTSEC_RX message strings -- */ --static int8_t *nss_trustsec_rx_log_message_types_str[NSS_TRUSTSEC_RX_MSG_MAX] __maybe_unused = { -- "TRUSTSEC_RX Configure Message", -- "TRUSTSEC_RX Unconfigure Message", -- "TRUSTSEC_RX Stats Sync", -- "TRUSTSEC_RX Config vp num Message", -- "TRUSTSEC_RX Unconfig vp num Message", --}; -- --/* -- * nss_trustsec_rx_log_error_response_types_str -- * Strings for error types for TRUSTSEC_RX messages -- */ --static int8_t *nss_trustsec_rx_log_error_response_types_str[NSS_TRUSTSEC_RX_ERR_MAX] __maybe_unused = { -- "TRUSTSEC_RX No error", -- "TRUSTSEC_RX Destination interface is not found", -- "TRUSTSEC_RX IP version is incorrect", -- "TRUSTSEC_RX Entry already exist", -- "TRUSTSEC_RX IP rule cannot be added", -- "TRUSTSEC_RX Entry cannot be found", -- "TRUSTSEC_RX source interface is not configured", -- "TRUSTSEC_RX Unknown trustsec message", -- "TRUSTSEC_RX configure vp number failed", -- "TRUSTSEC_RX unconfigure vp number failed", --}; -- --/* -- * nss_trustsec_rx_log_config_vp_msg -- * Log NSS TrustSec Rx configure vp message -- */ --static void nss_trustsec_rx_log_config_vp_msg(struct nss_trustsec_rx_msg *ntm) --{ -- struct nss_trustsec_rx_vp_msg *vpm __maybe_unused = &ntm->msg.cfg; -- nss_trace("%px: NSS trustsec_rx message: Configure VP\n" -- "VP number: %u\n", -- vpm, -- vpm->num); --} -- --/* -- * nss_trustsec_rx_log_unconfig_vp_msg -- * Log NSS TrustSec Rx uncfg vp message -- */ --static void nss_trustsec_rx_log_unconfig_vp_msg(struct nss_trustsec_rx_msg *ntm) --{ -- struct nss_trustsec_rx_vp_msg *vpm __maybe_unused = &ntm->msg.uncfg; -- nss_trace("%px: NSS trustsec_rx message: Unconfigure VP\n" -- "VP number: %u\n", -- vpm, -- vpm->num); --} -- --/* -- * nss_trustsec_rx_log_configure_msg() -- * Log NSS TRUSTSEC_RX configure message. -- */ --static void nss_trustsec_rx_log_configure_msg(struct nss_trustsec_rx_msg *ntm) --{ -- struct nss_trustsec_rx_configure_msg *cfg __maybe_unused = &ntm->msg.configure; -- nss_trace("%px: NSS trustsec_rx message: Config\n" -- "IP version: %u\n", -- cfg, -- cfg->ip_version); -- -- if (cfg->ip_version == NSS_TRUSTSEC_RX_FLAG_IPV4) { -- nss_trace("Src IP: %pI4\n" -- "Dest IP: %pI4\n", -- &(cfg->src_ip.ip.ipv4), -- &(cfg->dest_ip.ip.ipv4)); -- } else { -- nss_trace("Src IP: %pI6\n" -- "Dest IP: %pI6\n", -- &(cfg->src_ip.ip.ipv6), -- &(cfg->dest_ip.ip.ipv6)); -- } -- -- nss_trace("Src Port: %u\n Dest Port: %u\n\n", -- cfg->src_port, cfg->dest_port); -- nss_trace("%px: Destination interface number: %u", cfg, cfg->dest); --} -- --/* -- * nss_trustsec_rx_log_unconfigure_msg() -- * Log NSS TRUSTSEC_RX unconfigure message. -- */ --static void nss_trustsec_rx_log_unconfigure_msg(struct nss_trustsec_rx_msg *ntm) --{ -- struct nss_trustsec_rx_unconfigure_msg *uncfg __maybe_unused = &ntm->msg.unconfigure; -- nss_trace("%px: NSS trustsec_rx message: Unconfig\n" -- "IP version: %u\n", -- uncfg, -- uncfg->ip_version); -- -- if (uncfg->ip_version == NSS_TRUSTSEC_RX_FLAG_IPV4) { -- nss_trace("Src IP: %pI4\n" -- "Dest IP: %pI4\n", -- &(uncfg->src_ip.ip.ipv4), -- &(uncfg->dest_ip.ip.ipv4)); -- } else { -- nss_trace("Src IP: %pI6\n" -- "Dest IP: %pI6\n", -- &(uncfg->src_ip.ip.ipv6), -- &(uncfg->dest_ip.ip.ipv6)); -- } -- -- nss_trace("Src Port: %u\n Dest Port: %u\n\n", -- uncfg->src_port, uncfg->dest_port); -- nss_trace("%px: Destination interface number: %u", uncfg, uncfg->dest); --} -- --/* -- * nss_trustsec_rx_log_verbose() -- * Log message contents. -- */ --static void nss_trustsec_rx_log_verbose(struct nss_trustsec_rx_msg *ntm) --{ -- switch (ntm->cm.type) { -- case NSS_TRUSTSEC_RX_MSG_CONFIGURE: -- nss_trustsec_rx_log_configure_msg(ntm); -- break; -- -- case NSS_TRUSTSEC_RX_MSG_UNCONFIGURE: -- nss_trustsec_rx_log_unconfigure_msg(ntm); -- break; -- -- case NSS_TRUSTSEC_RX_MSG_STATS_SYNC: -- /* -- * No log for valid stats message. -- */ -- break; -- -- case NSS_TRUSTSEC_RX_MSG_CONFIG_VP: -- nss_trustsec_rx_log_config_vp_msg(ntm); -- break; -- -- case NSS_TRUSTSEC_RX_MSG_UNCONFIG_VP: -- nss_trustsec_rx_log_unconfig_vp_msg(ntm); -- break; -- -- default: -- nss_warning("%px: Invalid message type\n", ntm); -- break; -- } --} -- --/* -- * nss_trustsec_rx_log_tx_msg() -- * Log messages transmitted to FW. -- */ --void nss_trustsec_rx_log_tx_msg(struct nss_trustsec_rx_msg *ntm) --{ -- if (ntm->cm.type >= NSS_TRUSTSEC_RX_MSG_MAX) { -- nss_warning("%px: Invalid message type\n", ntm); -- return; -- } -- -- nss_info("%px: type[%d]:%s\n", ntm, ntm->cm.type, nss_trustsec_rx_log_message_types_str[ntm->cm.type]); -- nss_trustsec_rx_log_verbose(ntm); --} -- --/* -- * nss_trustsec_rx_log_rx_msg() -- * Log messages received from FW. -- */ --void nss_trustsec_rx_log_rx_msg(struct nss_trustsec_rx_msg *ntm) --{ -- if (ntm->cm.response >= NSS_CMN_RESPONSE_LAST) { -- nss_warning("%px: Invalid response\n", ntm); -- return; -- } -- -- if (ntm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ntm->cm.response == NSS_CMN_RESPONSE_ACK)) { -- nss_info("%px: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, -- nss_trustsec_rx_log_message_types_str[ntm->cm.type], -- ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); -- goto verbose; -- } -- -- if (ntm->cm.error >= NSS_TRUSTSEC_RX_ERR_UNKNOWN) { -- nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", -- ntm, ntm->cm.type, nss_trustsec_rx_log_message_types_str[ntm->cm.type], -- ntm->cm.response, nss_cmn_response_str[ntm->cm.response], -- ntm->cm.error); -- goto verbose; -- } -- -- nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", -- ntm, ntm->cm.type, nss_trustsec_rx_log_message_types_str[ntm->cm.type], -- ntm->cm.response, nss_cmn_response_str[ntm->cm.response], -- ntm->cm.error, nss_trustsec_rx_log_error_response_types_str[ntm->cm.error]); -- --verbose: -- nss_trustsec_rx_log_verbose(ntm); --} ---- a/nss_trustsec_rx_log.h -+++ /dev/null -@@ -1,37 +0,0 @@ --/* -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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. -- */ -- --#ifndef __NSS_TRUSTSEC_RX_LOG_H__ --#define __NSS_TRUSTSEC_RX_LOG_H__ -- --/* -- * nss_trustsec_rx_log.h -- * NSS TRUSTSEC_RX Log Header File -- */ -- --/* -- * nss_trustsec_rx_log_tx_msg -- * Logs a trustsec_rx message that is sent to the NSS firmware. -- */ --void nss_trustsec_rx_log_tx_msg(struct nss_trustsec_rx_msg *msg); -- --/* -- * nss_trustsec_rx_log_rx_msg -- * Logs a trustsec_rx message that is received from the NSS firmware. -- */ --void nss_trustsec_rx_log_rx_msg(struct nss_trustsec_rx_msg *msg); -- --#endif /* __NSS_TRUSTSEC_RX_LOG_H__ */ ---- a/nss_trustsec_rx_stats.c -+++ /dev/null -@@ -1,148 +0,0 @@ --/* -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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_tx_rx_common.h" --#include "nss_trustsec_rx_stats.h" -- --/* -- * nss_trustsec_rx_stats_str -- * Trustsec TX statistics strings. -- */ -- --struct nss_stats_info nss_trustsec_rx_stats_str[NSS_TRUSTSEC_RX_STATS_MAX] = { -- {"Unknown ethernet type", NSS_STATS_TYPE_ERROR}, -- {"Unknown packet" , NSS_STATS_TYPE_ERROR}, -- {"Unknown destination" , NSS_STATS_TYPE_ERROR}, -- {"IP parse failed" , NSS_STATS_TYPE_ERROR}, -- {"Wrong L4 type" , NSS_STATS_TYPE_ERROR}, --}; -- --/* -- * trustsec_rx_stats -- * Trustsec RX statistics. -- */ --uint64_t trustsec_rx_stats[NSS_TRUSTSEC_RX_STATS_MAX]; -- --/* -- * Trustsec RX statistics APIs -- */ -- --/* -- * nss_trustsec_rx_stats_sync() -- * Update trustsec_rx node statistics. -- */ --void nss_trustsec_rx_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_trustsec_rx_stats_sync_msg *ntsm) --{ -- struct nss_top_instance *nss_top = nss_ctx->nss_top; -- int j; -- -- spin_lock_bh(&nss_top->stats_lock); -- -- /* -- * Update common node stats -- */ -- nss_top->stats_node[NSS_TRUSTSEC_RX_INTERFACE][NSS_STATS_NODE_RX_PKTS] += ntsm->node_stats.rx_packets; -- nss_top->stats_node[NSS_TRUSTSEC_RX_INTERFACE][NSS_STATS_NODE_RX_BYTES] += ntsm->node_stats.rx_bytes; -- nss_top->stats_node[NSS_TRUSTSEC_RX_INTERFACE][NSS_STATS_NODE_TX_PKTS] += ntsm->node_stats.tx_packets; -- nss_top->stats_node[NSS_TRUSTSEC_RX_INTERFACE][NSS_STATS_NODE_TX_BYTES] += ntsm->node_stats.tx_bytes; -- -- for (j = 0; j < NSS_MAX_NUM_PRI; j++) { -- nss_top->stats_node[NSS_TRUSTSEC_RX_INTERFACE][NSS_STATS_NODE_RX_QUEUE_0_DROPPED + j] += ntsm->node_stats.rx_dropped[j]; -- } -- -- /* -- * Update trustsec node stats -- */ -- trustsec_rx_stats[NSS_TRUSTSEC_RX_STATS_UNKNOWN_ETH_TYPE] += ntsm->unknown_eth_type; -- trustsec_rx_stats[NSS_TRUSTSEC_RX_STATS_UNKNOWN_PKT] += ntsm->unknown_pkt; -- trustsec_rx_stats[NSS_TRUSTSEC_RX_STATS_UNKNOWN_DEST] += ntsm->unknown_dest; -- trustsec_rx_stats[NSS_TRUSTSEC_RX_STATS_IP_PARSE_FAILED] += ntsm->ip_parse_failed; -- trustsec_rx_stats[NSS_TRUSTSEC_RX_STATS_WRONG_L4_TYPE] += ntsm->wrong_l4_type; -- -- spin_unlock_bh(&nss_top->stats_lock); --} -- --/* -- * nss_trustsec_rx_stats_read() -- * Read trustsec_rx statiistics. -- */ --static ssize_t nss_trustsec_rx_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- int32_t i; -- -- /* -- * Max output lines = #stats + few blank lines for banner printing + -- * Number of Extra outputlines for future reference to add new stats. -- */ -- uint32_t max_output_lines = NSS_STATS_NODE_MAX + NSS_TRUSTSEC_RX_STATS_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- size_t size_wr = 0; -- ssize_t bytes_read = 0; -- uint64_t *stats_shadow; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(lbuf == NULL)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -- -- stats_shadow = kzalloc(NSS_STATS_NODE_MAX * 8, GFP_KERNEL); -- if (unlikely(stats_shadow == NULL)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "trustsec_rx", NSS_STATS_SINGLE_CORE); -- -- /* -- * Common node stats -- */ -- size_wr += nss_stats_fill_common_stats(NSS_TRUSTSEC_RX_INTERFACE, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "trustsec_rx"); -- -- /* -- * TrustSec TX node stats -- */ -- spin_lock_bh(&nss_top_main.stats_lock); -- for (i = 0; (i < NSS_TRUSTSEC_RX_STATS_MAX); i++) { -- stats_shadow[i] = trustsec_rx_stats[i]; -- } -- -- spin_unlock_bh(&nss_top_main.stats_lock); -- size_wr += nss_stats_print("trustsec_rx", NULL, NSS_STATS_SINGLE_INSTANCE -- , nss_trustsec_rx_stats_str -- , stats_shadow -- , NSS_TRUSTSEC_RX_STATS_MAX -- , lbuf, size_wr, size_al); -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- kfree(lbuf); -- kfree(stats_shadow); -- -- return bytes_read; --} -- --/* -- * nss_trustsec_rx_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(trustsec_rx) -- --/* -- * nss_trustsec_rx_stats_dentry_create() -- * Create trustsec_rx statistics debug entry. -- */ --void nss_trustsec_rx_stats_dentry_create(void) --{ -- nss_stats_create_dentry("trustsec_rx", &nss_trustsec_rx_stats_ops); --} ---- a/nss_trustsec_rx_stats.h -+++ /dev/null -@@ -1,47 +0,0 @@ --/* -- * Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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. -- */ --/* -- * nss_trustsec_rx_stats.h -- * NSS TRUSTSEC RX statistics header file. -- */ -- --#ifndef __NSS_TRUSTSEC_RX_STATS_H --#define __NSS_TRUSTSEC_RX_STATS_H -- --/* -- * Trustsec TX statistics -- */ --enum nss_trustsec_rx_stats { -- NSS_TRUSTSEC_RX_STATS_UNKNOWN_ETH_TYPE, -- /* Number of packets with unknown ethernet type */ -- NSS_TRUSTSEC_RX_STATS_UNKNOWN_PKT, -- /* Number of packets with unknown IP packet*/ -- NSS_TRUSTSEC_RX_STATS_UNKNOWN_DEST, -- /* Number of packets with unknown destination */ -- NSS_TRUSTSEC_RX_STATS_IP_PARSE_FAILED, -- /* Number of packets with IP parse failed */ -- NSS_TRUSTSEC_RX_STATS_WRONG_L4_TYPE, -- /* Number of packets with wrong L4 type */ -- NSS_TRUSTSEC_RX_STATS_MAX --}; -- --/* -- * Trustsec TX statistics APIs -- */ --extern void nss_trustsec_rx_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_trustsec_rx_stats_sync_msg *ntsm); --extern void nss_trustsec_rx_stats_dentry_create(void); -- --#endif /* __NSS_TRUSTSEC_RX_STATS_H */ ---- a/nss_tunipip6.c -+++ b/nss_tunipip6.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2014-2018, 2020, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2014-2018, 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. -@@ -16,20 +16,6 @@ - - #include "nss_tx_rx_common.h" - #include "nss_tunipip6_log.h" --#include "nss_tunipip6_stats.h" -- --#define NSS_TUNIPIP6_TX_TIMEOUT 3000 -- --/* -- * Data structure used to handle sync message. -- */ --static struct nss_tunipip6_pvt { -- struct semaphore sem; /* Semaphore structure. */ -- struct completion complete; /* Completion structure. */ -- int response; /* Response from FW. */ -- void *cb; /* Original cb for msgs. */ -- void *app_data; /* Original app_data for msgs. */ --} tunipip6_pvt; - - /* - * nss_tunipip6_verify_if_num -@@ -71,24 +57,15 @@ static void nss_tunipip6_handler(struct - * Is this a valid request/response packet? - */ - if (ncm->type >= NSS_TUNIPIP6_MAX) { -- nss_warning("%px: received invalid message %d for DS-Lite interface", nss_ctx, ncm->type); -+ nss_warning("%p: received invalid message %d for DS-Lite interface", nss_ctx, ncm->type); - return; - } - - if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_tunipip6_msg)) { -- nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); -+ nss_warning("%p: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } - -- switch (ntm->cm.type) { -- case NSS_TUNIPIP6_STATS_SYNC: -- /* -- * Sync common node stats. -- */ -- nss_tunipip6_stats_sync(nss_ctx, ntm); -- break; -- } -- - /* - * Update the callback and app_data for NOTIFY messages, tunipip6 sends all notify messages - * to the same callback/app_data. -@@ -119,7 +96,7 @@ static void nss_tunipip6_handler(struct - * call ipip6 tunnel callback - */ - if (!ctx) { -- nss_warning("%px: Event received for DS-Lite tunnel interface %d before registration", nss_ctx, ncm->interface); -+ nss_warning("%p: Event received for DS-Lite tunnel interface %d before registration", nss_ctx, ncm->interface); - return; - } - -@@ -143,12 +120,12 @@ nss_tx_status_t nss_tunipip6_tx(struct n - * Sanity check the message - */ - if (!nss_tunipip6_verify_if_num(ncm->interface)) { -- nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); -+ nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface); - return NSS_TX_FAILURE; - } - - if (ncm->type > NSS_TUNIPIP6_MAX) { -- nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); -+ nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type); - return NSS_TX_FAILURE; - } - -@@ -157,60 +134,6 @@ nss_tx_status_t nss_tunipip6_tx(struct n - EXPORT_SYMBOL(nss_tunipip6_tx); - - /* -- * nss_tunipip6_callback() -- * Callback to handle the completion of NSS->HLOS messages. -- */ --static void nss_tunipip6_callback(void *app_data, struct nss_tunipip6_msg *nclm) --{ -- tunipip6_pvt.response = NSS_TX_SUCCESS; -- tunipip6_pvt.cb = NULL; -- tunipip6_pvt.app_data = NULL; -- -- if (nclm->cm.response != NSS_CMN_RESPONSE_ACK) { -- nss_warning("%px: tunipip6 Error response %d Error: %d\n", app_data, nclm->cm.response, nclm->cm.error); -- tunipip6_pvt.response = nclm->cm.response; -- } -- -- /* -- * Write memory barrier. -- */ -- smp_wmb(); -- complete(&tunipip6_pvt.complete); --} -- --/* -- * nss_tunipip6_tx_sync() -- * Transmit a tunipip6 message to NSSFW synchronously. -- */ --nss_tx_status_t nss_tunipip6_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *msg) --{ -- nss_tx_status_t status; -- int ret; -- -- down(&tunipip6_pvt.sem); -- msg->cm.cb = (nss_ptr_t)nss_tunipip6_callback; -- msg->cm.app_data = (nss_ptr_t)NULL; -- -- status = nss_tunipip6_tx(nss_ctx, msg); -- if (status != NSS_TX_SUCCESS) { -- nss_warning("%px: tunipip6_tx_msg failed\n", nss_ctx); -- up(&tunipip6_pvt.sem); -- return status; -- } -- -- ret = wait_for_completion_timeout(&tunipip6_pvt.complete, msecs_to_jiffies(NSS_TUNIPIP6_TX_TIMEOUT)); -- if (!ret) { -- nss_warning("%px: tunipip6 tx sync failed due to timeout\n", nss_ctx); -- tunipip6_pvt.response = NSS_TX_FAILURE; -- } -- -- status = tunipip6_pvt.response; -- up(&tunipip6_pvt.sem); -- return status; --} --EXPORT_SYMBOL(nss_tunipip6_tx_sync); -- --/* - * ********************************** - * Register/Unregister/Miscellaneous APIs - * ********************************** -@@ -250,7 +173,6 @@ void nss_unregister_tunipip6_if(uint32_t - nss_assert(nss_ctx); - nss_assert(nss_tunipip6_verify_if_num(if_num)); - -- nss_stats_reset_common_stats(if_num); - nss_core_unregister_handler(nss_ctx, if_num); - nss_core_unregister_subsys_dp(nss_ctx, if_num); - -@@ -275,9 +197,6 @@ void nss_tunipip6_register_handler() - struct nss_ctx_instance *nss_ctx = nss_tunipip6_get_context(); - - nss_core_register_handler(nss_ctx, NSS_TUNIPIP6_INTERFACE, nss_tunipip6_handler, NULL); -- nss_tunipip6_stats_dentry_create(); -- sema_init(&tunipip6_pvt.sem, 1); -- init_completion(&tunipip6_pvt.complete); - } - - /* ---- a/nss_tunipip6_log.c -+++ b/nss_tunipip6_log.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2018, 2020, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2018, 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. -@@ -26,83 +26,47 @@ - * NSS TUNIPIP6 message strings - */ - static int8_t *nss_tunipip6_log_message_types_str[NSS_TUNIPIP6_MAX] __maybe_unused = { -- "TUNIPIP6 Encap Interface Create", -- "TUNIPIP6 Decap Interface Create", -+ "TUNIPIP6 Interface Create", - "TUNIPIP6 Stats", -- "TUNIPIP6 FMR add", -- "TUNIPIP6 FMR delete", -- "TUNIPIP6 FMR flush", -- "TUNIPIP6 BMR add", -- "TUNIPIP6 BMR delete", - }; - - /* -- * nss_tunipip6_log_error_types_str -- * Strings for error types for TUNIPIP6 messages -- */ --static char *nss_tunipip6_log_error_types_str[NSS_TUNIPIP6_ERROR_MAX] __maybe_unused = { -- "TUNIPIP6 maximum tunnel reached", -- "TUNIPIP6 tunnel already exists", -- "TUNIPIP6 configuration parameters are incorrect", -- "TUNIPIP6 FMR already exists ", -- "TUNIPIP6 no FMR configured", -- "TUNIPIP6 FMR table is full", -- "TUNIPIP6 invalid FMR", -- "TUNIPIP6 BMR already exists", -- "TUNIPIP6 no BMR configured", -- "TUNIPIP6 memory allocation for FMR failed", -- "TUNIPIP6 unknown error", --}; -- --/* -- * nss_tunipip6_log_map_rule() -- * Log NSS TUNIPIP6 map rule. -- */ --static void nss_tunipip6_log_map_rule(struct nss_tunipip6_msg *ntm) --{ -- struct nss_tunipip6_map_rule *nmr __maybe_unused = &ntm->msg.map_rule; -- nss_trace("%px: NSS TUNIPIP6 Interface Create message \n" -- "TUNIPIP6 Map Rule IPv6 prefix: %pI6\n" -- "TUNIPIP6 Map Rule IPv6 prefix length: %d\n" -- "TUNIPIP6 Map Rule IPv4 prefix: %pI4\n" -- "TUNIPIP6 Map Rule IPv4 prefix length: %d\n" -- "TUNIPIP6 Map Rule IPv6 suffix: %pI6\n" -- "TUNIPIP6 Map Rule IPv6 suffix length: %d\n" -- "TUNIPIP6 Map Rule EA length: %d\n" -- "TUNIPIP6 Map Rule PSID offset: %d\n", -- nmr, nmr->ip6_prefix, -- nmr->ip6_prefix_len,&nmr->ip4_prefix, -- nmr->ip4_prefix_len, nmr->ip6_suffix, -- nmr->ip6_suffix_len, nmr->ea_len, -- nmr->psid_offset); --} -- --/* - * nss_tunipip6_log_if_create_msg() - * Log NSS TUNIPIP6 Interface Create - */ - static void nss_tunipip6_log_if_create_msg(struct nss_tunipip6_msg *ntm) - { - struct nss_tunipip6_create_msg *ntcm __maybe_unused = &ntm->msg.tunipip6_create; -- nss_trace("%px: NSS TUNIPIP6 Interface Create message \n" -+ int32_t i; -+ nss_trace("%p: NSS TUNIPIP6 Interface Create message \n" - "TUNIPIP6 Source Address: %pI6\n" - "TUNIPIP6 Destination Address: %pI6\n" - "TUNIPIP6 Flow Label: %d\n" - "TUNIPIP6 Flags: %d\n" - "TUNIPIP6 Hop Limit: %d\n" - "TUNIPIP6 Draft03 Specification: %d\n" -- "TUNIPIP6 TTL inherit: %u\n" -- "TUNIPIP6 TOS inherit: %u\n" -- "TUNIPIP6 Frag ID Update: %u\n" -- "TUNIPIP6 Max FMR: %u\n", -+ "TUNIPIP6 FMR Number: %d\n", - ntcm, ntcm->saddr, - ntcm->daddr, ntcm->flowlabel, - ntcm->flags, ntcm->hop_limit, -- ntcm->draft03, -- ntcm->ttl_inherit, -- ntcm->tos_inherit, -- ntcm->frag_id_update, -- ntcm->fmr_max); -+ ntcm->draft03, ntcm->fmr_number); -+ /* -+ * Continuation of the log. -+ */ -+ for (i = 0; i < NSS_TUNIPIP6_MAX_FMR_NUMBER; i++) { -+ nss_trace("TUNIPIP6 FMR[%d] IPv6 Prefix: %pI6\n" -+ "TUNIPIP6 FMR[%d] IPv4 Prefix: %pI4\n" -+ "TUNIPIP6 FMR[%d] IPv6 Prefix Length: %d\n" -+ "TUNIPIP6 FMR[%d] IPv4 Prefix Length: %d\n" -+ "TUNIPIP6 FMR[%d] Embedded Address Length: %d\n" -+ "TUNIPIP6 FMR[%d] offset: %d", -+ i, ntcm->fmr[i].ip6_prefix, -+ i, &ntcm->fmr[i].ip4_prefix, -+ i, ntcm->fmr[i].ip6_prefix_len, -+ i, ntcm->fmr[i].ip4_prefix_len, -+ i, ntcm->fmr[i].ea_len, -+ i, ntcm->fmr[i].offset); -+ } - } - - /* -@@ -117,23 +81,14 @@ static void nss_tunipip6_log_verbose(str - nss_tunipip6_log_if_create_msg(ntm); - break; - -- case NSS_TUNIPIP6_STATS_SYNC: -+ case NSS_TUNIPIP6_RX_STATS_SYNC: - /* - * No log for valid stats message. - */ - break; - -- case NSS_TUNIPIP6_BMR_RULE_ADD: -- case NSS_TUNIPIP6_BMR_RULE_DEL: -- case NSS_TUNIPIP6_FMR_RULE_ADD: -- case NSS_TUNIPIP6_FMR_RULE_DEL: -- nss_tunipip6_log_map_rule(ntm); -- break; -- case NSS_TUNIPIP6_FMR_RULE_FLUSH: -- nss_trace("%px: FMR rule flush.\n", ntm); -- break; - default: -- nss_trace("%px: Invalid message type\n", ntm); -+ nss_trace("%p: Invalid message type\n", ntm); - break; - } - } -@@ -145,11 +100,11 @@ static void nss_tunipip6_log_verbose(str - void nss_tunipip6_log_tx_msg(struct nss_tunipip6_msg *ntm) - { - if (ntm->cm.type >= NSS_TUNIPIP6_MAX) { -- nss_warning("%px: Invalid message type\n", ntm); -+ nss_warning("%p: Invalid message type\n", ntm); - return; - } - -- nss_info("%px: type[%d]:%s\n", ntm, ntm->cm.type, nss_tunipip6_log_message_types_str[ntm->cm.type]); -+ nss_info("%p: type[%d]:%s\n", ntm, ntm->cm.type, nss_tunipip6_log_message_types_str[ntm->cm.type]); - nss_tunipip6_log_verbose(ntm); - } - -@@ -160,29 +115,20 @@ void nss_tunipip6_log_tx_msg(struct nss_ - void nss_tunipip6_log_rx_msg(struct nss_tunipip6_msg *ntm) - { - if (ntm->cm.response >= NSS_CMN_RESPONSE_LAST) { -- nss_warning("%px: Invalid response\n", ntm); -+ nss_warning("%p: Invalid response\n", ntm); - return; - } - - if (ntm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (ntm->cm.response == NSS_CMN_RESPONSE_ACK)) { -- nss_info("%px: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, -+ nss_info("%p: type[%d]:%s, response[%d]:%s\n", ntm, ntm->cm.type, - nss_tunipip6_log_message_types_str[ntm->cm.type], - ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); - goto verbose; - } - -- if (ntm->cm.error >= NSS_TUNIPIP6_ERROR_MAX) { -- nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", -- ntm, ntm->cm.type, nss_tunipip6_log_message_types_str[ntm->cm.type], -- ntm->cm.response, nss_cmn_response_str[ntm->cm.response], -- ntm->cm.error); -- goto verbose; -- } -- -- nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", -+ nss_info("%p: msg nack - type[%d]:%s, response[%d]:%s\n", - ntm, ntm->cm.type, nss_tunipip6_log_message_types_str[ntm->cm.type], -- ntm->cm.response, nss_cmn_response_str[ntm->cm.response], -- ntm->cm.error, nss_tunipip6_log_error_types_str[ntm->cm.error]); -+ ntm->cm.response, nss_cmn_response_str[ntm->cm.response]); - - verbose: - nss_tunipip6_log_verbose(ntm); ---- a/nss_tunipip6_stats.c -+++ /dev/null -@@ -1,124 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2020, 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_core.h" --#include "nss_tunipip6.h" --#include "nss_stats.h" --#include "nss_tunipip6_stats.h" -- --#define NSS_TUNIPIP6_STATS_MAX_LINES (NSS_STATS_NODE_MAX + 32) -- /**< Maximum number of lines for tunipip6 statistics dump. */ --#define NSS_TUNIPIP6_STATS_SIZE_PER_IF (NSS_STATS_MAX_STR_LENGTH * NSS_TUNIPIP6_STATS_MAX_LINES) -- /**< Total number of statistics per tunipip6 interface. */ -- --/* -- * nss_tunipip6_stats_read() -- * Read tunipip6 common node statistics -- */ --static ssize_t nss_tunipip6_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- struct nss_ctx_instance *nss_ctx = nss_tunipip6_get_context(); -- enum nss_dynamic_interface_type type; -- ssize_t bytes_read = 0; -- size_t len = 0, size; -- uint32_t if_num; -- char *buf; -- -- /* -- * Allocate memory for NSS_TUNIPIP6_TUNNEL_MAX tunnels and one -- * static interface. -- */ -- size = NSS_TUNIPIP6_STATS_SIZE_PER_IF * (NSS_TUNIPIP6_TUNNEL_MAX << 1) + 1; -- buf = vzalloc(size); -- if (!buf) { -- nss_warning("tunipip6: Could not allocate memory for local statistics buffer\n"); -- return 0; -- } -- -- len += nss_stats_banner(buf, len, size, "tunipip6", NSS_STATS_SINGLE_CORE); -- -- len += scnprintf(buf + len, size - len, "\nBase node if_num:%03u", NSS_TUNIPIP6_INTERFACE); -- len += scnprintf(buf + len, size - len, "\n-------------------\n"); -- len += nss_stats_fill_common_stats(NSS_TUNIPIP6_INTERFACE, NSS_STATS_SINGLE_INSTANCE, buf, len, size - len, "tunipip6"); -- -- /* -- * Common node stats for each tunipip6 dynamic interface. -- */ -- for (if_num = NSS_DYNAMIC_IF_START; if_num < NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES; if_num++) { -- type = nss_dynamic_interface_get_type(nss_ctx, if_num); -- switch (type) { -- case NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_INNER: -- len += scnprintf(buf + len, size - len, "\nInner if_num:%03u", if_num); -- break; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_TUNIPIP6_OUTER: -- len += scnprintf(buf + len, size - len, "\nOuter if_num:%03u", if_num); -- break; -- -- default: -- continue; -- } -- -- len += scnprintf(buf + len, size - len, "\n-------------------\n"); -- len += nss_stats_fill_common_stats(if_num, NSS_STATS_SINGLE_INSTANCE, buf, len, size - len, "tunipip6"); -- } -- -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, buf, len); -- vfree(buf); -- return bytes_read; --} -- --/* -- * nss_tunipip6_stats_sync() -- * Update tunipip6 common node statistics. -- */ --void nss_tunipip6_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *ntm) --{ -- struct nss_top_instance *nss_top = nss_ctx->nss_top; -- struct nss_tunipip6_stats_sync_msg *msg_stats = &ntm->msg.stats; -- uint64_t i, *dest; -- uint32_t *src; -- -- spin_lock_bh(&nss_top->stats_lock); -- -- /* -- * Update common node stats -- */ -- dest = nss_top->stats_node[ntm->cm.interface]; -- src = &msg_stats->node_stats.rx_packets; -- for (i = NSS_STATS_NODE_RX_PKTS; i <= NSS_STATS_NODE_RX_QUEUE_3_DROPPED; i++) { -- *dest++ = *src++; -- } -- -- spin_unlock_bh(&nss_top->stats_lock); -- --} -- --/* -- * nss_tunipip6_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(tunipip6) -- --/* -- * nss_tunipip6_stats_dentry_create() -- * Create tunipip6 statistics debug entry. -- */ --void nss_tunipip6_stats_dentry_create(void) --{ -- nss_stats_create_dentry("tunipip6", &nss_tunipip6_stats_ops); --} ---- a/nss_tunipip6_stats.h -+++ /dev/null -@@ -1,34 +0,0 @@ --/* -- ****************************************************************************** -- * Copyright (c) 2020, 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. -- * **************************************************************************** -- */ -- --#ifndef __NSS_TUNIPIP6_STATS_H --#define __NSS_TUNIPIP6_STATS_H -- --/* -- * nss_tunipip6_stats_dentry_create() -- * Creates tunipip6 interface statistics debug entry. -- */ --void nss_tunipip6_stats_dentry_create(void); -- --/* -- * nss_tunipip6_stats_sync() -- * Update tunipip6 common node statistics. -- */ --void nss_tunipip6_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_tunipip6_msg *ntm); -- --#endif /* __NSS_TUNIPIP6_STATS_H */ --- a/nss_tx_rx_common.h +++ b/nss_tx_rx_common.h -@@ -92,15 +92,13 @@ extern void nss_dtls_cmn_register_handle - extern void nss_tls_register_handler(void); - extern void nss_gre_tunnel_register_handler(void); - extern void nss_trustsec_tx_register_handler(void); --extern void nss_trustsec_rx_register_handler(void); - extern void nss_wifili_register_handler(void); +@@ -96,7 +96,9 @@ extern void nss_wifili_register_handler( extern void nss_ppe_register_handler(void); extern void nss_gre_redir_mark_register_handler(void); extern void nss_ppe_vp_register_handler(void); +#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) extern void nss_wifi_mac_db_register_handler(void); --extern void nss_wifi_ext_vdev_register_handler(void); --extern void nss_wifili_thread_scheme_db_init(uint8_t core_id); --extern void nss_wifi_mesh_init(void); +#endif /* * nss_if_msg_handler() ---- a/nss_udp_st.c -+++ /dev/null -@@ -1,238 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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. -- ************************************************************************** -- */ -- --/* -- * nss_udp_st.c -- * NSS UDP_ST APIs -- */ -- --#include "nss_core.h" --#include "nss_udp_st_stats.h" --#include "nss_udp_st_strings.h" --#include "nss_udp_st_log.h" -- --#define NSS_UDP_ST_TX_MSG_TIMEOUT 1000 /* 1 sec timeout for udp_st messages */ -- --/* -- * Private data structure for udp_st configuration -- */ --struct nss_udp_st_pvt { -- struct semaphore sem; /* Semaphore structure */ -- struct completion complete; /* completion structure */ -- int response; /* Response from FW */ -- void *cb; /* Original cb for sync msgs */ -- void *app_data; /* Original app_data for sync msgs */ --} nss_udp_st_pvt; -- --/* -- * nss_udp_st_msg_handler() -- * Handle NSS -> HLOS messages for UDP_ST node -- */ --static void nss_udp_st_msg_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, __attribute__((unused))void *app_data) --{ -- struct nss_udp_st_msg *num = (struct nss_udp_st_msg *)ncm; -- nss_udp_st_msg_callback_t cb; -- -- /* -- * Is this a valid message type? -- */ -- if (num->cm.type >= NSS_UDP_ST_MAX_MSG_TYPES) { -- nss_warning("%px: received invalid message %d for udp_st interface", nss_ctx, num->cm.type); -- return; -- } -- -- /* -- * Log messages. -- */ -- nss_udp_st_log_rx_msg(num); -- -- switch (num->cm.type) { -- case NSS_UDP_ST_STATS_SYNC_MSG: -- /* -- * Update driver statistics and send stats notifications to the registered modules. -- */ -- nss_udp_st_stats_sync(nss_ctx, &num->msg.stats); -- break; -- -- case NSS_UDP_ST_RESET_STATS_MSG: -- /* -- * This is a response to the statistics reset message. -- */ -- nss_udp_st_stats_reset(NSS_UDP_ST_INTERFACE); -- break; -- default: -- if (ncm->response != NSS_CMN_RESPONSE_ACK) { -- /* -- * Check response. -- */ -- nss_info("%px: Received response %d for type %d, interface %d", -- nss_ctx, ncm->response, ncm->type, ncm->interface); -- } -- } -- -- /* -- * Return for NOTIFY messages because there is no notifier functions. -- */ -- if (num->cm.response == NSS_CMN_RESPONSE_NOTIFY) { -- return; -- } -- -- /* -- * Do we have a callback? -- */ -- if (!ncm->cb) { -- return; -- } -- -- /* -- * Callback -- */ -- cb = (nss_udp_st_msg_callback_t)ncm->cb; -- cb((void *)ncm->app_data, num); --} -- --/* -- * nss_udp_st_tx_sync_callback() -- * Callback to handle the completion of synchronous tx messages. -- */ --static void nss_udp_st_tx_sync_callback(void *app_data, struct nss_udp_st_msg *num) --{ -- nss_udp_st_msg_callback_t callback = (nss_udp_st_msg_callback_t)nss_udp_st_pvt.cb; -- void *data = nss_udp_st_pvt.app_data; -- -- nss_udp_st_pvt.cb = NULL; -- nss_udp_st_pvt.app_data = NULL; -- -- if (num->cm.response != NSS_CMN_RESPONSE_ACK) { -- nss_warning("udp_st error response %d\n", num->cm.response); -- nss_udp_st_pvt.response = NSS_TX_FAILURE; -- } else { -- nss_udp_st_pvt.response = NSS_TX_SUCCESS; -- } -- -- if (callback) { -- callback(data, num); -- } -- -- complete(&nss_udp_st_pvt.complete); --} -- --/* -- * nss_udp_st_tx() -- * Transmit a udp_st message to the FW. -- * -- * This API should not be called from interrupt or softirq context. -- */ --nss_tx_status_t nss_udp_st_tx(struct nss_ctx_instance *nss_ctx, struct nss_udp_st_msg *num) --{ -- struct nss_cmn_msg *ncm = &num->cm; -- -- /* -- * Sanity check the message -- */ -- if (ncm->interface != NSS_UDP_ST_INTERFACE) { -- nss_warning("%px: tx request for another interface: %d", nss_ctx, ncm->interface); -- return NSS_TX_FAILURE; -- } -- -- if (ncm->type >= NSS_UDP_ST_MAX_MSG_TYPES) { -- nss_warning("%px: message type out of range: %d", nss_ctx, ncm->type); -- return NSS_TX_FAILURE; -- } -- -- /* -- * Trace messages. -- */ -- nss_udp_st_log_tx_msg(num); -- -- return nss_core_send_cmd(nss_ctx, num, sizeof(*num), NSS_NBUF_PAYLOAD_SIZE); --} --EXPORT_SYMBOL(nss_udp_st_tx); -- --/* -- * nss_udp_st_tx_sync() -- * Transmit a synchronous udp_st message to the FW. -- * -- * This API should not be called from interrupt or softirq context. -- */ --nss_tx_status_t nss_udp_st_tx_sync(struct nss_ctx_instance *nss_ctx, struct nss_udp_st_msg *num) --{ -- nss_tx_status_t status; -- int ret = 0; -- -- down(&nss_udp_st_pvt.sem); -- nss_udp_st_pvt.cb = (void *)num->cm.cb; -- nss_udp_st_pvt.app_data = (void *)num->cm.app_data; -- -- num->cm.cb = (nss_ptr_t)nss_udp_st_tx_sync_callback; -- num->cm.app_data = (nss_ptr_t)NULL; -- -- status = nss_udp_st_tx(nss_ctx, num); -- if (status != NSS_TX_SUCCESS) { -- nss_warning("%px: nss udp_st msg tx failed\n", nss_ctx); -- up(&nss_udp_st_pvt.sem); -- return status; -- } -- -- ret = wait_for_completion_timeout(&nss_udp_st_pvt.complete, msecs_to_jiffies(NSS_UDP_ST_TX_MSG_TIMEOUT)); -- if (!ret) { -- nss_warning("%px: udp_st tx sync failed due to timeout\n", nss_ctx); -- nss_udp_st_pvt.response = NSS_TX_FAILURE; -- } -- -- status = nss_udp_st_pvt.response; -- up(&nss_udp_st_pvt.sem); -- return status; --} --EXPORT_SYMBOL(nss_udp_st_tx_sync); -- --/* -- * nss_udp_st_msg_init() -- * Initialize udp_st message. -- */ --void nss_udp_st_msg_init(struct nss_udp_st_msg *num, uint16_t if_num, uint32_t type, uint32_t len, -- nss_udp_st_msg_callback_t cb, void *app_data) --{ -- nss_cmn_msg_init(&num->cm, if_num, type, len, (void *)cb, app_data); --} --EXPORT_SYMBOL(nss_udp_st_msg_init); -- --/* -- * nss_udp_st_register_handler() -- */ --void nss_udp_st_register_handler(struct nss_ctx_instance *nss_ctx) --{ -- nss_core_register_handler(nss_ctx, NSS_UDP_ST_INTERFACE, nss_udp_st_msg_handler, NULL); -- -- nss_udp_st_stats_dentry_create(); -- nss_udp_st_strings_dentry_create(); -- -- sema_init(&nss_udp_st_pvt.sem, 1); -- init_completion(&nss_udp_st_pvt.complete); --} -- --/* -- * nss_udp_st_get_mgr() -- * -- */ --struct nss_ctx_instance *nss_udp_st_get_mgr(void) --{ -- return (void *)&nss_top_main.nss[nss_top_main.udp_st_handler_id]; --} --EXPORT_SYMBOL(nss_udp_st_get_mgr); ---- a/nss_udp_st_log.c -+++ /dev/null -@@ -1,297 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2020, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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. -- ************************************************************************** -- */ -- --/* -- * nss_udp_st_log.c -- * NSS UDP Speedtest logger file. -- */ -- --#include "nss_core.h" -- --/* -- * nss_udp_st_log_message_types_str -- * udp_st message strings -- */ --static int8_t *nss_udp_st_log_message_types_str[NSS_UDP_ST_MAX_MSG_TYPES] __maybe_unused = { -- "UDP_ST Start Msg", -- "UDP_ST Stop Msg", -- "UDP_ST Configure Rule Msg", -- "UDP_ST Unconfigure Rule Msg", -- "UDP_ST Stats Sync Msg", -- "UDP_ST TX Create Msg", -- "UDP_ST TX Destroy Msg", -- "UDP_ST TX Update Rate Msg", -- "UDP_ST RX Mode Set Msg", -- "UDP_ST Time Sync Msg", -- "UDP_ST Reset Stats Msg", --}; -- --/* -- * nss_udp_st_log_error_response_types_str -- * Strings for error types for udp_st messages -- */ --static int8_t *nss_udp_st_log_error_response_types_str[NSS_UDP_ST_ERROR_MAX] __maybe_unused = { -- "UDP_ST No Error", -- "UDP_ST Incorrect Rate", -- "UDP_ST Incorrect Buffer Size", -- "UDP_ST Memory Failure", -- "UDP_ST Incorrect State", -- "UDP_ST Incorrect Flags", -- "UDP_ST Entry Exist", -- "UDP_ST Entry Add Failed", -- "UDP_ST Entry Not Exist", -- "UDP_ST Wrong Start Msg Type", -- "UDP_ST Wrong Stop Msg Type", -- "UDP_ST Too Many Users", -- "UDP_ST Unknown Msg Type", -- "UDP_ST Pbuf Alloc Failure", -- "UDP_ST Pbuf Size Failure", -- "UDP_ST Drop Queue", -- "UDP_ST Timer call missed", -- "UDP_ST Encap Entry Lookup Failed", --}; -- --/* -- * nss_udp_st_log_tx_create_destroy_msg() -- * Log NSS udp_st Tx create/destroy message. -- */ --static void nss_udp_st_log_tx_create_destroy_msg(struct nss_udp_st_msg *num, uint8_t *msg_type) --{ -- struct nss_udp_st_tx_create *create __maybe_unused = &num->msg.create; -- nss_trace("%px: NSS udp_st message: %s\n" -- "Rate: %u\n" -- "Buffer Size: %u\n" -- "DSCP: %u\n" -- "Mode: %d\n" -- "Timestamp: %llu", -- create, -- msg_type, -- create->rate, -- create->buffer_size, -- create->dscp, -- create->mode, -- create->timestamp); --} -- --/* -- * nss_udp_st_log_uncfg_rule_msg() -- * Log NSS udp_st unconfig rule message. -- */ --static void nss_udp_st_log_uncfg_rule_msg(struct nss_udp_st_msg *num) --{ -- struct nss_udp_st_cfg *uncfg __maybe_unused = &num->msg.uncfg; -- nss_trace("%px: NSS udp_st message: Unconfig\n" -- "IP version: %u\n", -- uncfg, -- uncfg->ip_version); -- -- if (uncfg->ip_version == NSS_UDP_ST_FLAG_IPV4) { -- nss_trace("Src IP: %pI4\n" -- "Dest IP: %pI4\n", -- &(uncfg->src_ip.ip.ipv4), -- &(uncfg->dest_ip.ip.ipv4)); -- } else { -- nss_trace("Src IP: %pI6\n" -- "Dest IP: %pI6\n", -- &(uncfg->src_ip.ip.ipv6), -- &(uncfg->dest_ip.ip.ipv6)); -- } -- -- nss_trace("Src Port: %u\n Dest Port: %u\n Type: %u\n", -- uncfg->src_port, uncfg->dest_port, uncfg->type); --} -- --/* -- * nss_udp_st_log_tx_update_rate_msg() -- * Log NSS udp_st udpate Tx rate message. -- */ --static void nss_udp_st_log_tx_update_rate_msg(struct nss_udp_st_msg *num) --{ -- struct nss_udp_st_tx_update_rate *update_rate __maybe_unused = &num->msg.update_rate; -- nss_trace("%px: NSS udp_st message: Update Tx Rate\n" -- "Rate : %u\n", -- update_rate, -- update_rate->rate); --} -- --/* -- * nss_udp_st_log_rx_mode_set_msg() -- * Log NSS udp_st Rx mode set message. -- */ --static void nss_udp_st_log_rx_mode_set_msg(struct nss_udp_st_msg *num) --{ -- struct nss_udp_st_rx_mode *mode __maybe_unused = &num->msg.mode; -- nss_trace("%px: NSS udp_st message: Rx mode set\n" -- "Mode : %u\n" -- "Timestamp : %llu\n", -- mode, -- mode->mode, -- mode->timestamp); --} -- --/* -- * nss_udp_st_log_cfg_rule_msg() -- * Log NSS udp_st config rule message. -- */ --static void nss_udp_st_log_cfg_rule_msg(struct nss_udp_st_msg *num) --{ -- struct nss_udp_st_cfg *cfg __maybe_unused = &num->msg.cfg; -- nss_trace("%px: NSS udp_st message: Config\n" -- "IP version: %u\n", -- cfg, -- cfg->ip_version); -- -- if (cfg->ip_version == NSS_UDP_ST_FLAG_IPV4) { -- nss_trace("Src IP: %pI4\n" -- "Dest IP: %pI4\n", -- &(cfg->src_ip.ip.ipv4), -- &(cfg->dest_ip.ip.ipv4)); -- } else { -- nss_trace("Src IP: %pI6\n" -- "Dest IP: %pI6\n", -- &(cfg->src_ip.ip.ipv6), -- &(cfg->dest_ip.ip.ipv6)); -- } -- -- nss_trace("Src Port: %u\n Dest Port: %u\n Type: %u\n", -- cfg->src_port, cfg->dest_port, cfg->type); --} -- --/* -- * nss_udp_st_log_stop_msg() -- * Log NSS udp_st stop message. -- */ --static void nss_udp_st_log_stop_msg(struct nss_udp_st_msg *num) --{ -- struct nss_udp_st_stop *stop __maybe_unused = &num->msg.stop; -- nss_trace("%px: NSS udp_st message: Stop\n" -- "Type: %u\n", -- stop, -- stop->type); --} -- --/* -- * nss_udp_st_log_start_msg() -- * Log NSS udp_st start message. -- */ --static void nss_udp_st_log_start_msg(struct nss_udp_st_msg *num) --{ -- struct nss_udp_st_start *start __maybe_unused = &num->msg.start; -- nss_trace("%px: NSS udp_st message: Start\n" -- "Type: %u\n", -- start, -- start->type); --} -- --/* -- * nss_udp_st_log_verbose() -- * Log message contents. -- */ --static void nss_udp_st_log_verbose(struct nss_udp_st_msg *num) --{ -- switch (num->cm.type) { -- case NSS_UDP_ST_START_MSG: -- nss_udp_st_log_start_msg(num); -- break; -- -- case NSS_UDP_ST_STOP_MSG: -- nss_udp_st_log_stop_msg(num); -- break; -- -- case NSS_UDP_ST_CFG_RULE_MSG: -- nss_udp_st_log_cfg_rule_msg(num); -- break; -- -- case NSS_UDP_ST_UNCFG_RULE_MSG: -- nss_udp_st_log_uncfg_rule_msg(num); -- break; -- -- case NSS_UDP_ST_TX_CREATE_MSG: -- nss_udp_st_log_tx_create_destroy_msg(num, "Create"); -- break; -- -- case NSS_UDP_ST_TX_DESTROY_MSG: -- nss_udp_st_log_tx_create_destroy_msg(num, "Destroy"); -- break; -- case NSS_UDP_ST_TX_UPDATE_RATE_MSG: -- nss_udp_st_log_tx_update_rate_msg(num); -- break; -- case NSS_UDP_ST_RX_MODE_SET_MSG: -- nss_udp_st_log_rx_mode_set_msg(num); -- break; -- case NSS_UDP_ST_RESET_STATS_MSG: -- case NSS_UDP_ST_STATS_SYNC_MSG: -- case NSS_UDP_ST_TIME_SYNC_MSG: -- break; -- -- default: -- nss_trace("%px: Invalid message type\n", num); -- break; -- } --} -- --/* -- * nss_udp_st_log_tx_msg() -- * Log messages transmitted to FW. -- */ --void nss_udp_st_log_tx_msg(struct nss_udp_st_msg *num) --{ -- if (num->cm.type >= NSS_UDP_ST_MAX_MSG_TYPES) { -- nss_warning("%px: Invalid message type\n", num); -- return; -- } -- -- nss_info("%px: type[%d]:%s\n", num, num->cm.type, nss_udp_st_log_message_types_str[num->cm.type]); -- nss_udp_st_log_verbose(num); --} -- --/* -- * nss_udp_st_log_rx_msg() -- * Log messages received from FW. -- */ --void nss_udp_st_log_rx_msg(struct nss_udp_st_msg *num) --{ -- if (num->cm.response >= NSS_CMN_RESPONSE_LAST) { -- nss_warning("%px: Invalid response\n", num); -- return; -- } -- -- if (num->cm.response == NSS_CMN_RESPONSE_NOTIFY || (num->cm.response == NSS_CMN_RESPONSE_ACK)) { -- nss_info("%px: type[%d]:%s, response[%d]:%s\n", num, num->cm.type, -- nss_udp_st_log_message_types_str[num->cm.type], -- num->cm.response, nss_cmn_response_str[num->cm.response]); -- goto verbose; -- } -- -- if (num->cm.error >= NSS_UDP_ST_ERROR_MAX) { -- nss_warning("%px: msg failure - type[%d]:%s, response[%d]:%s, error[%d]:Invalid error\n", -- num, num->cm.type, nss_udp_st_log_message_types_str[num->cm.type], -- num->cm.response, nss_cmn_response_str[num->cm.response], -- num->cm.error); -- goto verbose; -- } -- -- nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s, error[%d]:%s\n", -- num, num->cm.type, nss_udp_st_log_message_types_str[num->cm.type], -- num->cm.response, nss_cmn_response_str[num->cm.response], -- num->cm.error, nss_udp_st_log_error_response_types_str[num->cm.error]); -- --verbose: -- nss_udp_st_log_verbose(num); --} ---- a/nss_udp_st_log.h -+++ /dev/null -@@ -1,39 +0,0 @@ --/* -- ****************************************************************************** -- * 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. -- * **************************************************************************** -- */ -- --#ifndef __NSS_UDP_ST_LOG_H__ --#define __NSS_UDP_ST_LOG_H__ -- --/* -- * nss_udp_st_log.h -- * NSS UDP Speedtest Log Header File. -- */ -- --/* -- * nss_udp_st_log_tx_msg -- * Logs a udp_st message that is sent to the NSS firmware. -- */ --void nss_udp_st_log_tx_msg(struct nss_udp_st_msg *num); -- --/* -- * nss_udp_st_log_rx_msg -- * Logs a udp_st message that is received from the NSS firmware. -- */ --void nss_udp_st_log_rx_msg(struct nss_udp_st_msg *num); -- --#endif /* __NSS_UDP_ST_LOG_H__*/ ---- a/nss_udp_st_stats.c -+++ /dev/null -@@ -1,216 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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_core.h" --#include "nss_udp_st_stats.h" --#include "nss_udp_st_strings.h" -- --uint32_t nss_udp_st_errors[NSS_UDP_ST_ERROR_MAX]; --uint32_t nss_udp_st_stats_time[NSS_UDP_ST_TEST_MAX][NSS_UDP_ST_STATS_TIME_MAX]; --uint64_t nss_udp_st_stats_timestamp[NSS_UDP_ST_STATS_TIMESTAMP_MAX]; -- --/* -- * nss_udp_st_stats_read() -- * Read UDP_ST stats. -- */ --static ssize_t nss_udp_st_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- /* -- * Max output lines = #stats * NSS_MAX_CORES + -- * few blank lines for banner printing + Number of Extra outputlines for future reference to add new stats -- */ -- uint32_t max_output_lines = NSS_STATS_NODE_MAX + NSS_UDP_ST_ERROR_MAX + NSS_UDP_ST_STATS_TIMESTAMP_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- size_t size_wr = 0; -- ssize_t bytes_read = 0; -- uint64_t *stats_shadow; -- uint32_t i; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(lbuf == NULL)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -- -- /* -- * Note: The assumption here is that we do not have more than 64 stats. -- */ -- stats_shadow = kzalloc(64 * 8, GFP_KERNEL); -- if (unlikely(stats_shadow == NULL)) { -- nss_warning("Could not allocate memory for local shadow buffer"); -- kfree(lbuf); -- return 0; -- } -- -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "udp_st", NSS_STATS_SINGLE_CORE); -- -- size_wr += nss_stats_fill_common_stats(NSS_UDP_ST_INTERFACE, NSS_STATS_SINGLE_INSTANCE, lbuf, size_wr, size_al, "udp_st"); -- -- /* -- * Error stats -- */ -- spin_lock_bh(&nss_top_main.stats_lock); -- for (i = 0; (i < NSS_UDP_ST_ERROR_MAX); i++) { -- stats_shadow[i] = nss_udp_st_errors[i]; -- } -- spin_unlock_bh(&nss_top_main.stats_lock); -- size_wr += nss_stats_print("udp_st", "udp_st error stats" -- , NSS_STATS_SINGLE_INSTANCE -- , nss_udp_st_strings_error_stats -- , stats_shadow -- , NSS_UDP_ST_ERROR_MAX -- , lbuf, size_wr, size_al); -- -- /* -- * Rx time stats -- */ -- spin_lock_bh(&nss_top_main.stats_lock); -- for (i = 0; (i < NSS_UDP_ST_STATS_TIME_MAX); i++) { -- stats_shadow[i] = nss_udp_st_stats_time[NSS_UDP_ST_TEST_RX][i]; -- } -- spin_unlock_bh(&nss_top_main.stats_lock); -- size_wr += nss_stats_print("udp_st", "udp_st Rx time stats (ms)" -- , NSS_STATS_SINGLE_INSTANCE -- , nss_udp_st_strings_rx_time_stats -- , stats_shadow -- , NSS_UDP_ST_STATS_TIME_MAX -- , lbuf, size_wr, size_al); -- -- /* -- * Tx time stats -- */ -- spin_lock_bh(&nss_top_main.stats_lock); -- for (i = 0; (i < NSS_UDP_ST_STATS_TIME_MAX); i++) { -- stats_shadow[i] = nss_udp_st_stats_time[NSS_UDP_ST_TEST_TX][i]; -- } -- spin_unlock_bh(&nss_top_main.stats_lock); -- size_wr += nss_stats_print("udp_st", "udp_st Tx time stats (ms)" -- , NSS_STATS_SINGLE_INSTANCE -- , nss_udp_st_strings_tx_time_stats -- , stats_shadow -- , NSS_UDP_ST_STATS_TIME_MAX -- , lbuf, size_wr, size_al); -- -- /* -- * Timestamp mode stats. -- */ -- spin_lock_bh(&nss_top_main.stats_lock); -- for (i = 0; (i < NSS_UDP_ST_STATS_TIMESTAMP_MAX); i++) { -- stats_shadow[i] = nss_udp_st_stats_timestamp[i]; -- } -- spin_unlock_bh(&nss_top_main.stats_lock); -- size_wr += nss_stats_print("udp_st", "udp_st timestamp mode stats" -- , NSS_STATS_SINGLE_INSTANCE -- , nss_udp_st_strings_timestamp_stats -- , stats_shadow -- , NSS_UDP_ST_STATS_TIMESTAMP_MAX -- , lbuf, size_wr, size_al); -- -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, strlen(lbuf)); -- kfree(lbuf); -- kfree(stats_shadow); -- -- -- return bytes_read; --} -- --/* -- * nss_udp_st_stats_ops. -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(udp_st); -- --/* -- * nss_udp_st_stats_dentry_create() -- * Create udp_st statistics debug entry. -- */ --void nss_udp_st_stats_dentry_create(void) --{ -- nss_stats_create_dentry("udp_st", &nss_udp_st_stats_ops); --} -- --/* -- * nss_udp_st_stats_reset() -- * Reset the udp_st statistics. -- */ --void nss_udp_st_stats_reset(uint32_t if_num) --{ -- uint32_t i; -- -- /* -- * Reset common node stats. -- */ -- nss_stats_reset_common_stats(if_num); -- -- /* -- * Reset error stats. -- */ -- spin_lock_bh(&nss_top_main.stats_lock); -- for (i = 0; i < NSS_UDP_ST_ERROR_MAX; i++) { -- nss_udp_st_errors[i] = 0; -- } -- -- /* -- * Reset timestamp mode stats. -- */ -- for(i = 0; i < NSS_UDP_ST_STATS_TIMESTAMP_MAX; i++){ -- nss_udp_st_stats_timestamp[i] = 0; -- } -- spin_unlock_bh(&nss_top_main.stats_lock); --} -- --/* -- * nss_udp_st_stats_sync() -- * Handle the syncing of UDP_ST node statistics. -- */ --void nss_udp_st_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_udp_st_stats *nus) --{ -- struct nss_top_instance *nss_top = nss_ctx->nss_top; -- uint32_t i, j; -- -- spin_lock_bh(&nss_top->stats_lock); -- -- nss_top->stats_node[NSS_UDP_ST_INTERFACE][NSS_STATS_NODE_RX_PKTS] += nus->nstats.node_stats.rx_packets; -- nss_top->stats_node[NSS_UDP_ST_INTERFACE][NSS_STATS_NODE_RX_BYTES] += nus->nstats.node_stats.rx_bytes; -- nss_top->stats_node[NSS_UDP_ST_INTERFACE][NSS_STATS_NODE_TX_PKTS] += nus->nstats.node_stats.tx_packets; -- nss_top->stats_node[NSS_UDP_ST_INTERFACE][NSS_STATS_NODE_TX_BYTES] += nus->nstats.node_stats.tx_bytes; -- -- for (i = 0; i < NSS_UDP_ST_ERROR_MAX; i++) { -- nss_udp_st_errors[i] += nus->nstats.errors[i]; -- } -- -- for (i = 0; i < NSS_UDP_ST_TEST_MAX; i++) { -- for (j = 0; j < NSS_UDP_ST_STATS_TIME_MAX; j++) { -- nss_udp_st_stats_time[i][j] = nus->time_stats[i][j]; -- } -- } -- -- nss_udp_st_stats_timestamp[NSS_UDP_ST_STATS_TIMESTAMP_PACKET_LOSS] += nus->tstats[NSS_UDP_ST_STATS_TIMESTAMP_PACKET_LOSS]; -- nss_udp_st_stats_timestamp[NSS_UDP_ST_STATS_TIMESTAMP_OOO_PACKETS] += nus->tstats[NSS_UDP_ST_STATS_TIMESTAMP_OOO_PACKETS]; -- nss_udp_st_stats_timestamp[NSS_UDP_ST_STATS_TIMESTAMP_DELAY_SUM] += nus->tstats[NSS_UDP_ST_STATS_TIMESTAMP_DELAY_SUM]; -- nss_udp_st_stats_timestamp[NSS_UDP_ST_STATS_TIMESTAMP_DELAY_NUM] += nus->tstats[NSS_UDP_ST_STATS_TIMESTAMP_DELAY_NUM]; -- -- /* -- * Maximum and Minimum delay is maintained in fw and we just copy it here as it is. -- */ -- nss_udp_st_stats_timestamp[NSS_UDP_ST_STATS_TIMESTAMP_DELAY_MAX] = nus->tstats[NSS_UDP_ST_STATS_TIMESTAMP_DELAY_MAX]; -- nss_udp_st_stats_timestamp[NSS_UDP_ST_STATS_TIMESTAMP_DELAY_MIN] = nus->tstats[NSS_UDP_ST_STATS_TIMESTAMP_DELAY_MIN]; -- -- nss_udp_st_stats_timestamp[NSS_UDP_ST_STATS_TIMESTAMP_PACKET_LOSS] -= nus->tstats[NSS_UDP_ST_STATS_TIMESTAMP_OOO_PACKETS]; -- spin_unlock_bh(&nss_top->stats_lock); --} ---- a/nss_udp_st_stats.h -+++ /dev/null -@@ -1,36 +0,0 @@ --/* -- ************************************************************************** -- * 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. -- ************************************************************************** -- */ -- --#ifndef __NSS_UDP_ST_STATS_H --#define __NSS_UDP_ST_STATS_H -- --#include -- --/* -- * nss_udp_st_stats.h -- * NSS driver UDP_ST statistics header file. -- */ -- --/* -- * udp_st statistics APIs -- */ --extern void nss_udp_st_stats_reset(uint32_t if_num); --extern void nss_udp_st_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_udp_st_stats *nus); --extern void nss_udp_st_stats_dentry_create(void); -- --#endif /* __NSS_UDP_ST_STATS_H */ ---- a/nss_udp_st_strings.c -+++ /dev/null -@@ -1,185 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 --#include "nss_strings.h" -- --/* -- * nss_udp_st_strings_error_stats -- * Statistics strings for udp_st errors. -- */ --struct nss_stats_info nss_udp_st_strings_error_stats[NSS_UDP_ST_ERROR_MAX] = { -- {"error_none" , NSS_STATS_TYPE_SPECIAL}, -- {"incorrect_rate" , NSS_STATS_TYPE_DROP}, -- {"incorrect_buffer_size" , NSS_STATS_TYPE_DROP}, -- {"memory_failure" , NSS_STATS_TYPE_DROP}, -- {"incorrect_state" , NSS_STATS_TYPE_DROP}, -- {"incorrect_flags" , NSS_STATS_TYPE_DROP}, -- {"entry_exist" , NSS_STATS_TYPE_DROP}, -- {"entry_add_failed" , NSS_STATS_TYPE_DROP}, -- {"entry_not_exist" , NSS_STATS_TYPE_DROP}, -- {"wrong_start_msg_type" , NSS_STATS_TYPE_DROP}, -- {"wrong_stop_msg_type" , NSS_STATS_TYPE_DROP}, -- {"too_many_users" , NSS_STATS_TYPE_DROP}, -- {"unknown_msg_type" , NSS_STATS_TYPE_DROP}, -- {"pb_alloc_failure" , NSS_STATS_TYPE_DROP}, -- {"pb_size_failure" , NSS_STATS_TYPE_DROP}, -- {"drop_queue_failure" , NSS_STATS_TYPE_DROP}, -- {"timer_call_is_missed" , NSS_STATS_TYPE_SPECIAL}, -- {"encap_entry_lookup_failed" ,NSS_STATS_TYPE_DROP}, --}; -- --/* -- * nss_udp_st_strings_rx_time_stats -- * Statistics strings for Rx udp_st time. -- */ --struct nss_stats_info nss_udp_st_strings_rx_time_stats[NSS_UDP_ST_STATS_TIME_MAX] = { -- {"rx_start_time" , NSS_STATS_TYPE_SPECIAL}, -- {"rx_current_time" , NSS_STATS_TYPE_SPECIAL}, -- {"rx_elapsed_time" , NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_udp_st_strings_tx_time_stats -- * Statistics strings for Tx udp_st time. -- */ --struct nss_stats_info nss_udp_st_strings_tx_time_stats[NSS_UDP_ST_STATS_TIME_MAX] = { -- {"tx_start_time" , NSS_STATS_TYPE_SPECIAL}, -- {"tx_current_time" , NSS_STATS_TYPE_SPECIAL}, -- {"tx_elapsed_time" , NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_udp_st_strings_timestamp_stats -- * Statistics strings for timestamp mode stats. -- */ --struct nss_stats_info nss_udp_st_strings_timestamp_stats[NSS_UDP_ST_STATS_TIMESTAMP_MAX] = { -- {"Packet_Lost" , NSS_STATS_TYPE_SPECIAL}, -- {"Out_of_order_packets" , NSS_STATS_TYPE_SPECIAL}, -- {"Delay_sum" , NSS_STATS_TYPE_SPECIAL}, -- {"Delay_num" , NSS_STATS_TYPE_SPECIAL}, -- {"Delay_max" , NSS_STATS_TYPE_SPECIAL}, -- {"Delay_min" , NSS_STATS_TYPE_SPECIAL}, --}; -- --/* -- * nss_udp_st_error_stats_strings_read() -- * Read udp_st error statistics names. -- */ --static ssize_t nss_udp_st_error_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_udp_st_strings_error_stats, NSS_UDP_ST_ERROR_MAX); --} -- --/* -- * nss_udp_st_rx_time_stats_strings_read() -- * Read Rx udp_st time statistics names. -- */ --static ssize_t nss_udp_st_rx_time_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_udp_st_strings_rx_time_stats, NSS_UDP_ST_STATS_TIME_MAX); --} -- --/* -- * nss_udp_st_tx_time_stats_strings_read() -- * Read Tx udp_st time statistics names. -- */ --static ssize_t nss_udp_st_tx_time_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_udp_st_strings_tx_time_stats, NSS_UDP_ST_STATS_TIME_MAX); --} -- --/* -- * nss_udp_st_timestamp_stats_strings_read() -- * Read udp_st timestamp mode statistics names. -- */ --static ssize_t nss_udp_st_timestamp_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_udp_st_strings_timestamp_stats, NSS_UDP_ST_STATS_TIMESTAMP_MAX); --} -- --/* -- * nss_udp_st_error_stats_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(udp_st_error_stats); -- --/* -- * nss_udp_st_rx_time_stats_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(udp_st_rx_time_stats); -- --/* -- * nss_udp_st_tx_time_stats_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(udp_st_tx_time_stats); -- --/* -- * nss_udp_st_timestamp_stats_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(udp_st_timestamp_stats); -- --/* -- * nss_udp_st_strings_dentry_create() -- * Create udp_st statistics strings debug entry. -- */ --void nss_udp_st_strings_dentry_create(void) --{ -- struct dentry *dir_d; -- struct dentry *file_d; -- -- if (!nss_top_main.strings_dentry) { -- nss_warning("qca-nss-drv/strings is not present"); -- return; -- } -- -- dir_d = debugfs_create_dir("udp_st", nss_top_main.strings_dentry); -- if (!dir_d) { -- nss_warning("Failed to create qca-nss-drv/strings/udp_st directory"); -- return; -- } -- -- file_d = debugfs_create_file("error_stats_str", 0400, dir_d, &nss_top_main, &nss_udp_st_error_stats_strings_ops); -- if (!file_d) { -- nss_warning("Failed to create qca-nss-drv/stats/udp_st/error_stats_str file"); -- goto fail; -- } -- -- file_d = debugfs_create_file("rx_time_stats_str", 0400, dir_d, &nss_top_main, &nss_udp_st_rx_time_stats_strings_ops); -- if (!file_d) { -- nss_warning("Failed to create qca-nss-drv/stats/udp_st/rx_time_stats_str file"); -- goto fail; -- } -- -- file_d = debugfs_create_file("tx_time_stats_str", 0400, dir_d, &nss_top_main, &nss_udp_st_tx_time_stats_strings_ops); -- if (!file_d) { -- nss_warning("Failed to create qca-nss-drv/stats/udp_st/tx_time_stats_str file"); -- goto fail; -- } -- -- file_d = debugfs_create_file("timestamp_stats_str", 0400, dir_d, &nss_top_main, &nss_udp_st_timestamp_stats_strings_ops); -- if (!file_d) { -- nss_warning("Failed to create qca-nss-drv/stats/udp_st/timestamp_stats_str file"); -- goto fail; -- } -- return; --fail: -- debugfs_remove_recursive(dir_d); --} ---- a/nss_udp_st_strings.h -+++ /dev/null -@@ -1,29 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2021, The Linux Foundation. All rights reserved. -- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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. -- ************************************************************************** -- */ -- --#ifndef __NSS_UDP_ST_STRINGS_H --#define __NSS_UDP_ST_STRINGS_H -- --extern struct nss_stats_info nss_udp_st_strings_error_stats[NSS_UDP_ST_ERROR_MAX]; --extern struct nss_stats_info nss_udp_st_strings_rx_time_stats[NSS_UDP_ST_STATS_TIME_MAX]; --extern struct nss_stats_info nss_udp_st_strings_tx_time_stats[NSS_UDP_ST_STATS_TIME_MAX]; --extern struct nss_stats_info nss_udp_st_strings_timestamp_stats[NSS_UDP_ST_STATS_TIMESTAMP_MAX]; --extern void nss_udp_st_strings_dentry_create(void); -- --#endif /* __NSS_UDP_ST_STRINGS_H */ ---- a/nss_vxlan.c -+++ b/nss_vxlan.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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. -@@ -226,7 +226,6 @@ bool nss_vxlan_unregister_if(uint32_t if - } - - nss_core_unregister_handler(nss_ctx, if_num); -- nss_core_unregister_msg_handler(nss_ctx, if_num); - nss_core_unregister_subsys_dp(nss_ctx, if_num); - return true; - } ---- a/nss_wifi_ext_vdev.c -+++ /dev/null -@@ -1,338 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2020, 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_tx_rx_common.h" --#include "nss_wifi_ext_vdev_stats.h" --#include "nss_wifi_ext_vdev_log.h" -- --#define NSS_WIFI_EXT_VDEV_TX_TIMEOUT 3000 /* 3 seconds */ -- --/* -- * Private data structure -- */ --static struct nss_wifi_ext_vdev_pvt { -- struct semaphore sem; -- struct completion complete; -- int response; -- void *cb; -- void *app_data; --} wifi_ext_vdev_pvt; -- --/* -- * nss_wifi_ext_vdev_verify_if_num() -- * Verify if_num passed to us. -- */ --static bool nss_wifi_ext_vdev_verify_if_num(uint32_t if_num) --{ -- uint32_t type = nss_dynamic_interface_get_type(nss_wifi_ext_vdev_get_ctx(), if_num); -- -- switch (type) { -- case NSS_DYNAMIC_INTERFACE_TYPE_WIFI_EXT_VDEV_WDS: -- case NSS_DYNAMIC_INTERFACE_TYPE_WIFI_EXT_VDEV_VLAN: -- return true; -- default: -- return false; -- } --} -- --/* -- * nss_wifi_ext_vdev_handler() -- * Handle NSS -> HLOS messages for wifi_ext_vdev -- */ --static void nss_wifi_ext_vdev_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data) --{ -- struct nss_wifi_ext_vdev_msg *nwevm = (struct nss_wifi_ext_vdev_msg *)ncm; -- void *ctx; -- -- nss_wifi_ext_vdev_msg_callback_t cb; -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- BUG_ON(!nss_wifi_ext_vdev_verify_if_num(ncm->interface)); -- -- /* -- * Trace Messages -- */ -- nss_wifi_ext_vdev_log_rx_msg(nwevm); -- -- /* -- * Is this a valid request/response packet? -- */ -- if (ncm->type >= NSS_WIFI_EXT_VDEV_MSG_MAX) { -- nss_warning("%px: received invalid message %d for WiFi extended VAP interface %d", nss_ctx, ncm->type, ncm->interface); -- return; -- } -- -- if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_wifi_ext_vdev_msg)) { -- nss_warning("%px: wifi_ext_vdev message length is invalid: %d", nss_ctx, ncm->len); -- return; -- } -- -- /* -- * Check messages -- */ -- switch (nwevm->cm.type) { -- case NSS_WIFI_EXT_VDEV_MSG_STATS_SYNC: -- nss_wifi_ext_vdev_stats_sync(nss_ctx, &nwevm->msg.stats, ncm->interface); -- break; -- } -- -- /* -- * Update the callback and app_data for NOTIFY messages -- */ -- if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { -- ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)nss_ctx->subsys_dp_register[ncm->interface].app_data; -- } -- -- nss_core_log_msg_failures(nss_ctx, ncm); -- -- /* -- * callback -- */ -- cb = (nss_wifi_ext_vdev_msg_callback_t)ncm->cb; -- ctx = (void *)ncm->app_data; -- -- /* -- * call the callback -- */ -- if (!cb) { -- return; -- } -- -- cb(ctx, ncm); --} -- --/* -- * nss_wifi_ext_vdev_msg_init() -- * Initialize wifi message. -- */ --void nss_wifi_ext_vdev_msg_init(struct nss_wifi_ext_vdev_msg *nim, uint32_t if_num, -- uint32_t type, uint32_t len, -- nss_wifi_ext_vdev_msg_callback_t cb, void *app_data) --{ -- nss_cmn_msg_init(&nim->cm, if_num, type, len, cb, app_data); --} --EXPORT_SYMBOL(nss_wifi_ext_vdev_msg_init); -- --/* -- * nss_wifi_ext_vdev_tx_msg() -- * Transmit a wifi vdev message to NSSFW -- */ --nss_tx_status_t nss_wifi_ext_vdev_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_wifi_ext_vdev_msg *msg) --{ -- struct nss_cmn_msg *ncm = &msg->cm; -- -- /* -- * Trace Messages -- */ -- nss_wifi_ext_vdev_log_tx_msg(msg); -- -- if (ncm->type >= NSS_WIFI_EXT_VDEV_MSG_MAX) { -- nss_warning("%px: wifi vdev message type out of range: %d", nss_ctx, ncm->type); -- return NSS_TX_FAILURE; -- } -- -- BUG_ON(!nss_wifi_ext_vdev_verify_if_num(ncm->interface)); -- -- return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); --} --EXPORT_SYMBOL(nss_wifi_ext_vdev_tx_msg); -- --/* -- * nss_wifi_ext_vdev_callback() -- * Callback to handle the completion of NSS->HLOS messages. -- */ --static void nss_wifi_ext_vdev_callback(void *app_data, struct nss_cmn_msg *ncm) --{ -- nss_wifi_ext_vdev_msg_callback_t callback = (nss_wifi_ext_vdev_msg_callback_t)wifi_ext_vdev_pvt.cb; -- void *data = wifi_ext_vdev_pvt.app_data; -- -- wifi_ext_vdev_pvt.response = NSS_TX_SUCCESS; -- wifi_ext_vdev_pvt.cb = NULL; -- wifi_ext_vdev_pvt.app_data = NULL; -- -- if (ncm->response != NSS_CMN_RESPONSE_ACK) { -- nss_warning("WiFi extension vap Error response %d\n", ncm->response); -- wifi_ext_vdev_pvt.response = NSS_TX_FAILURE; -- } -- -- if (callback) { -- callback(data, ncm); -- } -- complete(&wifi_ext_vdev_pvt.complete); --} -- --/* -- * nss_wifi_ext_vdev_tx_msg() -- * Transmit a WiFi extended virtual interface to NSS firmware synchronously. -- */ --nss_tx_status_t nss_wifi_ext_vdev_tx_msg_sync(struct nss_ctx_instance *nss_ctx, struct nss_wifi_ext_vdev_msg *nwevm) --{ -- nss_tx_status_t status; -- int ret = 0; -- -- down(&wifi_ext_vdev_pvt.sem); -- wifi_ext_vdev_pvt.cb = (void *)nwevm->cm.cb; -- wifi_ext_vdev_pvt.app_data = (void *)nwevm->cm.app_data; -- -- nwevm->cm.cb = (nss_ptr_t)nss_wifi_ext_vdev_callback; -- nwevm->cm.app_data = (nss_ptr_t)NULL; -- -- status = nss_wifi_ext_vdev_tx_msg(nss_ctx, nwevm); -- if (status != NSS_TX_SUCCESS) { -- nss_warning("%px: wifi_ext_vdev_tx_msg failed\n", nss_ctx); -- up(&wifi_ext_vdev_pvt.sem); -- return status; -- } -- -- /* -- * Wait for the acknowledgement -- */ -- ret = wait_for_completion_timeout(&wifi_ext_vdev_pvt.complete, msecs_to_jiffies(NSS_WIFI_EXT_VDEV_TX_TIMEOUT)); -- if (!ret) { -- nss_warning("%px: WiFi extended vap msg tx failed due to timeout\n", nss_ctx); -- wifi_ext_vdev_pvt.response = NSS_TX_FAILURE; -- } -- -- status = wifi_ext_vdev_pvt.response; -- up(&wifi_ext_vdev_pvt.sem); -- return status; --} --EXPORT_SYMBOL(nss_wifi_ext_vdev_tx_msg_sync); -- --/* -- * nss_wifi_ext_vdev_tx_buf -- * Send data packet for vap processing -- */ --nss_tx_status_t nss_wifi_ext_vdev_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *skb, uint32_t if_num) --{ -- BUG_ON(!nss_wifi_ext_vdev_verify_if_num(if_num)); -- -- return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); --} --EXPORT_SYMBOL(nss_wifi_ext_vdev_tx_buf); -- --/* -- * nss_wifi_ext_vdev_set_next_hop() -- * Set the WiFI extended vap next hop. -- */ --nss_tx_status_t nss_wifi_ext_vdev_set_next_hop(struct nss_ctx_instance *ctx, int if_num, int next_hop) --{ -- struct nss_wifi_ext_vdev_msg *nwevm = kzalloc(sizeof(struct nss_wifi_ext_vdev_msg), GFP_KERNEL); -- struct nss_wifi_ext_vdev_set_next_hop_msg *nhm = NULL; -- nss_tx_status_t status; -- -- if (!nwevm) { -- nss_warning("%px: Unable to allocate next hop message", ctx); -- return NSS_TX_FAILURE; -- } -- -- nhm = &nwevm->msg.wnhm; -- -- nhm->if_num = next_hop; -- nss_wifi_ext_vdev_msg_init(nwevm, if_num, NSS_WIFI_EXT_VDEV_SET_NEXT_HOP, -- sizeof(struct nss_wifi_ext_vdev_set_next_hop_msg), NULL, NULL); -- -- status = nss_wifi_ext_vdev_tx_msg(ctx, nwevm); -- if (status != NSS_TX_SUCCESS) { -- nss_warning("%px: Unable to send next hop message", ctx); -- } -- -- kfree(nwevm); -- return status; --} --EXPORT_SYMBOL(nss_wifi_ext_vdev_set_next_hop); -- --/* -- * nss_get_wifi_ext_vdev_ext_context() -- * Return the core ctx which the feature is on -- */ --struct nss_ctx_instance *nss_wifi_ext_vdev_get_ctx(void) --{ -- return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; --} --EXPORT_SYMBOL(nss_wifi_ext_vdev_get_ctx); -- --/* -- * nss_wifi_ext_vdev_register_if() -- */ --struct nss_ctx_instance *nss_wifi_ext_vdev_register_if(uint32_t if_num, -- nss_wifi_ext_vdev_data_callback_t data_callback, -- nss_wifi_ext_vdev_ext_data_callback_t ext_callback, -- nss_wifi_ext_vdev_msg_callback_t event_callback, -- struct net_device *netdev, -- uint32_t features, void *app_data) --{ -- struct nss_ctx_instance *nss_ctx = nss_wifi_ext_vdev_get_ctx(); -- -- BUG_ON(!nss_wifi_ext_vdev_verify_if_num(if_num)); -- -- nss_core_register_subsys_dp(nss_ctx, if_num, data_callback, ext_callback, app_data, netdev, features); -- -- nss_core_register_msg_handler(nss_ctx, if_num, event_callback); -- -- nss_core_register_handler(nss_ctx, if_num, nss_wifi_ext_vdev_handler, app_data); -- -- nss_wifi_ext_vdev_stats_register(if_num, netdev); -- -- return nss_ctx; --} --EXPORT_SYMBOL(nss_wifi_ext_vdev_register_if); -- --/* -- * nss_wifi_ext_vdev_unregister_if() -- */ --bool nss_wifi_ext_vdev_unregister_if(uint32_t if_num) --{ -- struct nss_ctx_instance *nss_ctx = nss_wifi_ext_vdev_get_ctx(); -- struct net_device *netdev; -- -- BUG_ON(!nss_wifi_ext_vdev_verify_if_num(if_num)); -- -- nss_assert(nss_ctx); -- -- netdev = nss_cmn_get_interface_dev(nss_ctx, if_num); -- if (!netdev) { -- nss_warning("%px: Unable to find net device for the interface %d\n", nss_ctx, if_num); -- return false; -- } -- nss_core_unregister_subsys_dp(nss_ctx, if_num); -- -- nss_core_unregister_msg_handler(nss_ctx, if_num); -- -- nss_core_unregister_handler(nss_ctx, if_num); -- -- nss_wifi_ext_vdev_stats_unregister(if_num, netdev); -- return true; --} --EXPORT_SYMBOL(nss_wifi_ext_vdev_unregister_if); -- --/* -- * nss_wifi_ext_vdev_register_handler() -- * Register debugfs handler received on base interface -- */ --void nss_wifi_ext_vdev_register_handler(void) --{ -- struct nss_ctx_instance *nss_ctx = nss_wifi_ext_vdev_get_ctx(); -- -- nss_info("nss_wifi_ext_vdev_handler"); -- sema_init(&wifi_ext_vdev_pvt.sem, 1); -- init_completion(&wifi_ext_vdev_pvt.complete); -- nss_core_register_handler(nss_ctx, NSS_WIFI_EXT_VDEV_INTERFACE, nss_wifi_ext_vdev_handler, NULL); -- nss_wifi_ext_vdev_stats_dentry_create(); --} ---- a/nss_wifi_ext_vdev_log.c -+++ /dev/null -@@ -1,220 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2020, 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. -- ************************************************************************** -- */ -- --/* -- * nss_wifi_ext_vdev_log.c -- * NSS WiFi extended VAP logger file. -- */ -- --#include "nss_core.h" -- --#define NSS_WIFI_EXT_VDEV_LOG_MESSAGE_TYPE_INDEX(type) ((type) - NSS_IF_MAX_MSG_TYPES) -- --/* -- * nss_wifi_ext_vdev_log_message_types_str -- * NSS WiFi extended VAP message strings -- */ --static int8_t *nss_wifi_ext_vdev_log_message_types_str[NSS_WIFI_EXT_VDEV_MSG_MAX] __maybe_unused = { -- "WiFi Common I/F Message", -- "WiFi Extendev VAP configure", -- "WiFi Extendev VAP configure wds", -- "WiFi Extendev VAP configure next hop", -- "WiFi Extendev VAP stats", -- "WiFi Extended VAP configure VLAN" --}; -- --/* -- * nss_wifi_ext_vdev_log_configure_msg() -- * Log NSS WiFi extended vap configure message. -- */ --static void nss_wifi_ext_vdev_log_configure_if_msg(struct nss_wifi_ext_vdev_msg *nwevm) --{ -- struct nss_wifi_ext_vdev_configure_if_msg *cmsg __maybe_unused = &nwevm->msg.cmsg; -- nss_trace("%px: WiFi extended VAP configure message \n" -- "Mac address: %pM\n" -- "Radio interface num: %d\n" -- "Parent VAP interface num: %d\n", -- cmsg, cmsg->mac_addr, cmsg->radio_ifnum, -- cmsg->pvap_ifnum); -- --} -- --/* -- * nss_wifi_ext_vdev_log_wds_msg() -- * Log NSS WiFi extended vap wds message. -- */ --static void nss_wifi_ext_vdev_log_wds_msg(struct nss_wifi_ext_vdev_msg *nwevm) --{ -- struct nss_wifi_ext_vdev_wds_msg *wmsg __maybe_unused = &nwevm->msg.wmsg; -- nss_trace("%px: NSS WiFi extended VAP wds message: \n" -- "WDS sta ID: %d\n" -- "WDS sta macaddr: %pM\n", -- wmsg, wmsg->wds_peer_id, -- wmsg->mac_addr); --} -- --/* -- * nss_wifi_ext_vdev_set_nxt_hop_msg() -- * Set the next hop message. -- */ --static void nss_wifi_ext_vdev_set_nxt_hop_msg(struct nss_wifi_ext_vdev_msg *nwevm) --{ -- struct nss_wifi_ext_vdev_set_next_hop_msg *wnhm __maybe_unused = &nwevm->msg.wnhm; -- nss_trace("%px: NSS WiFi extended vap set next hop message: \n" -- "Next hop if num: %d\n", -- wnhm, wnhm->if_num); -- --} -- --/* -- * nss_wifi_ext_vdev_linkup_msg() -- * Log NSS linkup message. -- */ --static void nss_wifi_ext_vdev_linkup_msg(struct nss_wifi_ext_vdev_msg *nwevm) --{ -- union nss_if_msgs *if_msg __maybe_unused = &nwevm->msg.if_msg; -- nss_trace("%px: NSS WiFi ext linkup message\n", if_msg); --} -- --/* -- * nss_wifi_ext_vdev_linkdown_msg() -- * Log NSS linkdown message. -- */ --static void nss_wifi_ext_vdev_linkdown_msg(struct nss_wifi_ext_vdev_msg *nwevm) --{ -- union nss_if_msgs *if_msg __maybe_unused = &nwevm->msg.if_msg; -- nss_trace("%px: NSS WiFi ext linkdown message\n", if_msg); --} -- --/* -- * nss_wifi_ext_vdev_macaddr_set_msg() -- * Set/Change the mac address -- */ --static void nss_wifi_ext_vdev_macaddr_set_msg(struct nss_wifi_ext_vdev_msg *nwevm) --{ -- union nss_if_msgs *if_msg = &nwevm->msg.if_msg; -- struct nss_if_mac_address_set *nimas __maybe_unused = &if_msg->mac_address_set; -- nss_trace("%px: NSS WiFi ext change mac addr: \n" -- "mac addr %pM\n", -- nimas, nimas->mac_addr); --} -- --/* -- * nss_wifi_ext_vdev_log_vlan_msg() -- * Configure vlan message. -- */ --static void nss_wifi_ext_vdev_log_vlan_msg(struct nss_wifi_ext_vdev_msg *nwevm) --{ -- struct nss_wifi_ext_vdev_vlan_msg *vmsg __maybe_unused = &nwevm->msg.vmsg; -- nss_trace("%px: NSS WiFi extended VAP vlan message: \n" -- "vlan ID %hu\n", -- vmsg, vmsg->vlan_id); --} -- --/* -- * nss_wifi_ext_vdev_log_verbose() -- * Log message contents. -- */ --static void nss_wifi_ext_vdev_log_verbose(struct nss_wifi_ext_vdev_msg *nwevm) --{ -- switch (nwevm->cm.type) { -- case NSS_WIFI_EXT_VDEV_MSG_CONFIGURE_IF: -- nss_wifi_ext_vdev_log_configure_if_msg(nwevm); -- break; -- -- case NSS_WIFI_EXT_VDEV_MSG_CONFIGURE_WDS : -- nss_wifi_ext_vdev_log_wds_msg(nwevm); -- break; -- -- case NSS_WIFI_EXT_VDEV_SET_NEXT_HOP: -- nss_wifi_ext_vdev_set_nxt_hop_msg(nwevm); -- break; -- -- case NSS_WIFI_EXT_VDEV_MSG_STATS_SYNC: -- break; -- -- case NSS_IF_OPEN: -- nss_wifi_ext_vdev_linkup_msg(nwevm); -- break; -- -- case NSS_IF_CLOSE: -- nss_wifi_ext_vdev_linkdown_msg(nwevm); -- break; -- -- case NSS_IF_MAC_ADDR_SET: -- nss_wifi_ext_vdev_macaddr_set_msg(nwevm); -- break; -- -- case NSS_WIFI_EXT_VDEV_MSG_CONFIGURE_VLAN: -- nss_wifi_ext_vdev_log_vlan_msg(nwevm); -- break; -- -- default: -- nss_trace("%px: Invalid message type\n", nwevm); -- break; -- } --} -- --/* -- * nss_wifi_ext_vdev_log_tx_msg() -- * Log messages transmitted to FW. -- */ --void nss_wifi_ext_vdev_log_tx_msg(struct nss_wifi_ext_vdev_msg *nwevm) --{ -- uint32_t type_idx = 0; -- if (nwevm->cm.type >= NSS_WIFI_EXT_VDEV_MSG_MAX) { -- nss_warning("%px: Invalid message type\n", nwevm); -- return; -- } -- -- type_idx = (nwevm->cm.type > NSS_IF_MAX_MSG_TYPES) ? -- (NSS_WIFI_EXT_VDEV_LOG_MESSAGE_TYPE_INDEX(nwevm->cm.type)) : 0; -- -- nss_info("%px: type[%d]:%s\n", nwevm, nwevm->cm.type, nss_wifi_ext_vdev_log_message_types_str[type_idx]); -- nss_wifi_ext_vdev_log_verbose(nwevm); --} -- --/* -- * nss_wifi_ext_vdev_log_rx_msg() -- * Log messages received from FW. -- */ --void nss_wifi_ext_vdev_log_rx_msg(struct nss_wifi_ext_vdev_msg *nwevm) --{ -- uint32_t type_idx = 0; -- if (nwevm->cm.response >= NSS_CMN_RESPONSE_LAST) { -- nss_warning("%px: Invalid response\n", nwevm); -- return; -- } -- -- type_idx = (nwevm->cm.type > NSS_IF_MAX_MSG_TYPES) ? -- (NSS_WIFI_EXT_VDEV_LOG_MESSAGE_TYPE_INDEX(nwevm->cm.type)) : 0; -- -- if (nwevm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nwevm->cm.response == NSS_CMN_RESPONSE_ACK)) { -- nss_info("%px: type[%d]:%s, response[%d]:%s\n", nwevm, nwevm->cm.type, -- nss_wifi_ext_vdev_log_message_types_str[type_idx], -- nwevm->cm.response, nss_cmn_response_str[nwevm->cm.response]); -- goto verbose; -- } -- -- nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", -- nwevm, nwevm->cm.type, nss_wifi_ext_vdev_log_message_types_str[type_idx], -- nwevm->cm.response, nss_cmn_response_str[nwevm->cm.response]); -- --verbose: -- nss_wifi_ext_vdev_log_verbose(nwevm); --} ---- a/nss_wifi_ext_vdev_log.h -+++ /dev/null -@@ -1,34 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2020, 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. -- ************************************************************************** -- */ -- --#ifndef __NSS_WIFI_EXT_VDEV_LOG_H --#define __NSS_WIFI_EXT_VDEV_LOG_H -- --/* -- * nss_wifi_ext_vdev_log_tx_msg -- * Logs a wifi_ext_vdev message that is sent to the NSS firmware. -- */ --void nss_wifi_ext_vdev_log_tx_msg(struct nss_wifi_ext_vdev_msg *nwevm); -- --/* -- * nss_wifi_ext_vdev_log_rx_msg -- * Logs a wifi_ext_vdev message that is received from the NSS firmware. -- */ --void nss_wifi_ext_vdev_log_rx_msg(struct nss_wifi_ext_vdev_msg *nwevm); -- --#endif /* __NSS_WIFI_EXT_VDEV_LOG_H */ ---- a/nss_wifi_ext_vdev_stats.c -+++ /dev/null -@@ -1,234 +0,0 @@ --/* -- ************************************************************************** -- * Copyright (c) 2020, 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_tx_rx_common.h" --#include "nss_wifi_ext_vdev_stats.h" -- --DEFINE_SPINLOCK(nss_wifi_ext_vdev_debug_lock); --struct nss_wifi_ext_vdev_debug nss_wifi_ext_vdev_debug_stats[NSS_WIFI_EXT_VDEV_MAX]; -- --/* -- * nss_wifi_ext_vdev_debug_str -- * WiFi extended VAP statistics strings. -- */ --struct nss_stats_info nss_wifi_ext_vdev_debug_str[NSS_WIFI_EXT_VDEV_STATS_MAX] = { -- {"node_rx_pkts" , NSS_STATS_TYPE_COMMON}, -- {"node_rx_bytes" , NSS_STATS_TYPE_COMMON}, -- {"node_tx_pkts" , NSS_STATS_TYPE_COMMON}, -- {"node_tx_bytes" , NSS_STATS_TYPE_COMMON}, -- {"node_rx_dropped" , NSS_STATS_TYPE_DROP}, -- {"mc_count" , NSS_STATS_TYPE_SPECIAL}, -- {"uc_count" , NSS_STATS_TYPE_SPECIAL}, -- {"nxt_hop_drop" , NSS_STATS_TYPE_DROP}, --}; -- --/* -- * WiFi extended vdev statistics APIs -- */ -- --/* -- * nss_wifi_ext_vdev_stats_register() -- * Register debug statistic for WiFi extended VAP. -- */ --void nss_wifi_ext_vdev_stats_register(uint32_t if_num, struct net_device *netdev) --{ -- int i; -- -- spin_lock_bh(&nss_wifi_ext_vdev_debug_lock); -- for (i = 0; i < NSS_WIFI_EXT_VDEV_MAX; i++) { -- if (!nss_wifi_ext_vdev_debug_stats[i].valid) { -- nss_wifi_ext_vdev_debug_stats[i].valid = true; -- nss_wifi_ext_vdev_debug_stats[i].if_num = if_num; -- nss_wifi_ext_vdev_debug_stats[i].if_index = netdev->ifindex; -- break; -- } -- } -- -- spin_unlock_bh(&nss_wifi_ext_vdev_debug_lock); --} -- --/* -- * nss_wifi_ext_vdev_stats_unregister() -- * Register debug statistic for WiFi extended vap. -- */ --void nss_wifi_ext_vdev_stats_unregister(uint32_t if_num, struct net_device *netdev) --{ -- int i; -- -- spin_lock_bh(&nss_wifi_ext_vdev_debug_lock); -- for (i = 0; i < NSS_WIFI_EXT_VDEV_MAX; i++) { -- if (nss_wifi_ext_vdev_debug_stats[i].if_num == if_num) { -- memset(&nss_wifi_ext_vdev_debug_stats[i], 0, -- sizeof(struct nss_wifi_ext_vdev_debug)); -- break; -- } -- } -- spin_unlock_bh(&nss_wifi_ext_vdev_debug_lock); --} -- --/* -- * nss_wifi_ext_vdev_stats_sync() -- * Sync function for WiFi extendev vap statistics. -- */ --void nss_wifi_ext_vdev_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_wifi_ext_vdev_stats *stats_msg, -- uint16_t if_num) --{ -- int i; -- struct nss_wifi_ext_vdev_debug *s = NULL; -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- spin_lock_bh(&nss_wifi_ext_vdev_debug_lock); -- for (i = 0; i < NSS_WIFI_EXT_VDEV_MAX; i++) { -- if (nss_wifi_ext_vdev_debug_stats[i].if_num == if_num) { -- s = &nss_wifi_ext_vdev_debug_stats[i]; -- break; -- } -- } -- -- if (!s) { -- spin_unlock_bh(&nss_wifi_ext_vdev_debug_lock); -- nss_warning("%px: Interface:%u not found", nss_ctx, if_num); -- return; -- } -- -- s->stats[NSS_WIFI_EXT_VDEV_STATS_NODE_RX_PKTS ] += stats_msg->node_stats.rx_packets; -- s->stats[NSS_WIFI_EXT_VDEV_STATS_NODE_RX_BYTES] += stats_msg->node_stats.rx_bytes; -- s->stats[NSS_WIFI_EXT_VDEV_STATS_NODE_TX_PKTS] += stats_msg->node_stats.tx_packets; -- s->stats[NSS_WIFI_EXT_VDEV_STATS_NODE_TX_BYTES] += stats_msg->node_stats.tx_bytes; -- for (i = 0; i < NSS_MAX_NUM_PRI; i++) { -- s->stats[NSS_WIFI_EXT_VDEV_STATS_NODE_TOTAL_DROPPED] += stats_msg->node_stats.rx_dropped[i]; -- } -- s->stats[NSS_WIFI_EXT_VDEV_STATS_MULTICAST_COUNT] += stats_msg->mc_count; -- s->stats[NSS_WIFI_EXT_VDEV_STATS_UNICAST_COUNT] += stats_msg->node_stats.rx_packets - stats_msg->mc_count; -- s->stats[NSS_WIFI_EXT_VDEV_STATS_NEXT_HOP_DROP_COUNT] += stats_msg->nxt_hop_drp; -- spin_unlock_bh(&nss_wifi_ext_vdev_debug_lock); --} -- --/* -- * nss_wifi_ext_vdev_debug_get() -- * Get WiFi extendev vap debug statitics. -- */ --static void nss_wifi_ext_vdev_debug_get(struct nss_wifi_ext_vdev_debug *stats) --{ -- int i; -- -- if (!stats) { -- nss_warning("No memory to copy WiFi extended VAP stats"); -- return; -- } -- -- spin_lock_bh(&nss_wifi_ext_vdev_debug_lock); -- for (i = 0; i < NSS_WIFI_EXT_VDEV_MAX; i++) { -- if (nss_wifi_ext_vdev_debug_stats[i].valid) { -- memcpy(stats, &nss_wifi_ext_vdev_debug_stats[i], -- sizeof(struct nss_wifi_ext_vdev_debug)); -- stats++; -- } -- } -- spin_unlock_bh(&nss_wifi_ext_vdev_debug_lock); --} -- --/* -- * nss_wifi_ext_vdev_read() -- * Read WiFi extended VAP statistics -- */ --static ssize_t nss_wifi_ext_vdev_stats_read(struct file *fp, char __user *ubuf, -- size_t sz, loff_t *ppos) --{ -- uint32_t max_output_lines = 2 /* header and footer of the interface stats*/ -- + (NSS_WIFI_EXT_VDEV_STATS_MAX * (NSS_WIFI_EXT_VDEV_MAX + 2)) /* Interface stats */ -- + 2; -- -- size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; -- size_t size_wr = 0; -- size_t bytes_read = 0; -- struct net_device *dev; -- int id; -- struct nss_wifi_ext_vdev_debug *wifi_ext_vdev_stats = NULL; -- -- char *lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(lbuf == NULL)) { -- nss_warning("Could not allocate memory for local statistics buffer"); -- return 0; -- } -- -- wifi_ext_vdev_stats = kzalloc((sizeof(struct nss_wifi_ext_vdev_debug) * NSS_WIFI_EXT_VDEV_MAX), GFP_KERNEL); -- if (unlikely(wifi_ext_vdev_stats == NULL)) { -- nss_warning("Could not allocate memory for populating stats"); -- kfree(lbuf); -- return 0; -- } -- -- /* -- * Get all stats -- */ -- nss_wifi_ext_vdev_debug_get(wifi_ext_vdev_stats); -- -- /* -- * WiFi extended vap stats. -- */ -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "WiFi extended VAP stats", NSS_STATS_SINGLE_CORE); -- -- for (id = 0; id < NSS_WIFI_EXT_VDEV_MAX; id++) { -- if (!wifi_ext_vdev_stats[id].valid) { -- continue; -- } -- -- dev = dev_get_by_index(&init_net, wifi_ext_vdev_stats[id].if_index); -- if (likely(dev)) { -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -- "%d. nss interface id=%d, netdevice=%s\n", -- id, wifi_ext_vdev_stats[id].if_num, -- dev->name); -- dev_put(dev); -- } else { -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, -- "%d. nss interface id=%d\n", id, -- wifi_ext_vdev_stats[id].if_num); -- } -- -- size_wr += nss_stats_print("vdev", "debug", id -- , nss_wifi_ext_vdev_debug_str -- , wifi_ext_vdev_stats[id].stats -- , NSS_WIFI_EXT_VDEV_STATS_MAX -- , lbuf, size_wr, size_al); -- -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n"); -- } -- -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); -- -- kfree(wifi_ext_vdev_stats); -- kfree(lbuf); -- return bytes_read; --} -- --/* -- * nss_wifi_ext_vdev_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(wifi_ext_vdev); -- --/* -- * nss_wifi_ext_vdev_dentry_create() -- * Create wifi extension vap statistics debug entry. -- */ --void nss_wifi_ext_vdev_stats_dentry_create(void) --{ -- nss_stats_create_dentry("wifi_ext_vdev", &nss_wifi_ext_vdev_stats_ops); --} ---- a/nss_wifi_ext_vdev_stats.h -+++ /dev/null -@@ -1,60 +0,0 @@ --/* -- ****************************************************************************** -- * Copyright (c) 2020, 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. -- * **************************************************************************** -- */ -- --#ifndef __NSS_WIFI_EXT_VDEV_STATS_H --#define __NSS_WIFI_EXT_VDEV_STATS_H -- --/* -- * WiFi extendev vap debug statistic counters. -- */ --enum nss_wifi_ext_vdev_stats_types { -- NSS_WIFI_EXT_VDEV_STATS_NODE_RX_PKTS, -- NSS_WIFI_EXT_VDEV_STATS_NODE_RX_BYTES, -- NSS_WIFI_EXT_VDEV_STATS_NODE_TX_PKTS, -- NSS_WIFI_EXT_VDEV_STATS_NODE_TX_BYTES, -- NSS_WIFI_EXT_VDEV_STATS_NODE_TOTAL_DROPPED, -- NSS_WIFI_EXT_VDEV_STATS_MULTICAST_COUNT, -- NSS_WIFI_EXT_VDEV_STATS_UNICAST_COUNT, -- NSS_WIFI_EXT_VDEV_STATS_NEXT_HOP_DROP_COUNT, -- NSS_WIFI_EXT_VDEV_STATS_MAX, --}; -- --/* -- * WiFi extendev vap debug statistics. -- */ --struct nss_wifi_ext_vdev_debug { -- uint64_t stats[NSS_WIFI_EXT_VDEV_STATS_MAX]; -- int32_t if_index; /**< Netdevice's ifindex. */ -- uint32_t if_num; /**< NSS interface number. */ -- bool valid; /**< Is node valid ? */ --}; -- --/* -- * Data structures to store WiFi extended VAP debug stats. -- */ --extern struct nss_wifi_ext_vdev_debug nss_wifi_ext_vdev_debug_stats[NSS_WIFI_EXT_VDEV_MAX]; -- --/* -- * WiFi extendev vap statistics APIs -- */ --extern void nss_wifi_ext_vdev_stats_register(uint32_t if_num, struct net_device *netdev); --extern void nss_wifi_ext_vdev_stats_unregister(uint32_t if_num, struct net_device *netdev); --extern void nss_wifi_ext_vdev_stats_sync(struct nss_ctx_instance *nss_ctx, struct nss_wifi_ext_vdev_stats *stats_msg, uint16_t if_num); --extern void nss_wifi_ext_vdev_stats_dentry_create(void); -- --#endif /* __NSS_WIFI_EXT_VDEV_STATS_H */ ---- /dev/null -+++ b/nss_wifi_if.c -@@ -0,0 +1,516 @@ -+/* -+ ************************************************************************** -+ * Copyright (c) 2015-2020, 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. -+ ************************************************************************** -+ */ -+ -+/* -+ * nss_wifi_if.c -+ * NSS wifi/redirect handler APIs -+ */ -+ -+#include "nss_tx_rx_common.h" -+#include "nss_wifi_if_stats.h" -+#include -+ -+#define NSS_WIFI_IF_TX_TIMEOUT 3000 /* 3 Seconds */ -+#define NSS_WIFI_IF_GET_INDEX(if_num) (if_num-NSS_DYNAMIC_IF_START) -+ -+extern int nss_ctl_redirect; -+ -+/* -+ * Data structure that holds the wifi interface context. -+ */ -+struct nss_wifi_if_handle *wifi_handle[NSS_MAX_DYNAMIC_INTERFACES]; -+ -+/* -+ * Spinlock to protect the global data structure wifi_handle. -+ */ -+DEFINE_SPINLOCK(wifi_if_lock); -+ -+/* -+ * nss_wifi_if_msg_handler() -+ * Handle NSS -> HLOS messages for wifi interface -+ */ -+static void nss_wifi_if_msg_handler(struct nss_ctx_instance *nss_ctx, -+ struct nss_cmn_msg *ncm, -+ __attribute__((unused))void *app_data) -+{ -+ struct nss_wifi_if_msg *nwim = (struct nss_wifi_if_msg *)ncm; -+ int32_t if_num; -+ -+ nss_wifi_if_msg_callback_t cb; -+ struct nss_wifi_if_handle *handle = NULL; -+ -+ /* -+ * Sanity check the message type -+ */ -+ if (ncm->type >= NSS_WIFI_IF_MAX_MSG_TYPES) { -+ nss_warning("%px: message type out of range: %d", -+ nss_ctx, ncm->type); -+ return; -+ } -+ -+ if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_wifi_if_msg)) { -+ nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); -+ return; -+ } -+ -+ if (!NSS_IS_IF_TYPE(DYNAMIC, ncm->interface)) { -+ nss_warning("%px: response for another interface: %d", nss_ctx, ncm->interface); -+ return; -+ } -+ -+ /* -+ * Log failures -+ */ -+ nss_core_log_msg_failures(nss_ctx, ncm); -+ -+ if_num = NSS_WIFI_IF_GET_INDEX(ncm->interface); -+ -+ spin_lock_bh(&wifi_if_lock); -+ if (!wifi_handle[if_num]) { -+ spin_unlock_bh(&wifi_if_lock); -+ nss_warning("%px: wifi_if handle is NULL\n", nss_ctx); -+ return; -+ } -+ -+ handle = wifi_handle[if_num]; -+ spin_unlock_bh(&wifi_if_lock); -+ -+ switch (nwim->cm.type) { -+ case NSS_WIFI_IF_STATS_SYNC_MSG: -+ nss_wifi_if_stats_sync(handle, &nwim->msg.stats); -+ break; -+ } -+ -+ /* -+ * Update the callback and app_data for NOTIFY messages. -+ */ -+ if (nwim->cm.response == NSS_CMN_RESPONSE_NOTIFY) { -+ ncm->cb = (nss_ptr_t)handle->cb; -+ ncm->app_data = (nss_ptr_t)handle->app_data; -+ } -+ -+ /* -+ * Do we have a callback? -+ */ -+ if (!ncm->cb) { -+ nss_warning("cb is NULL\n"); -+ return; -+ } -+ -+ /* -+ * Callback -+ */ -+ cb = (nss_wifi_if_msg_callback_t)ncm->cb; -+ cb((void *)ncm->app_data, ncm); -+} -+ -+/* -+ * nss_wifi_if_register_handler() -+ * Register the message handler & initialize semaphore & completion for the * interface if_num -+ */ -+static uint32_t nss_wifi_if_register_handler(struct nss_wifi_if_handle *handle) -+{ -+ struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[nss_top_main.wlan_handler_id]; -+ uint32_t ret; -+ struct nss_wifi_if_pvt *nwip = NULL; -+ int32_t if_num = handle->if_num; -+ -+ ret = nss_core_register_handler(nss_ctx, if_num, nss_wifi_if_msg_handler, NULL); -+ -+ if (ret != NSS_CORE_STATUS_SUCCESS) { -+ nss_warning("%d: Message handler failed to be registered for interface ret %d\n", if_num, ret); -+ return NSS_WIFI_IF_CORE_FAILURE; -+ } -+ -+ nwip = handle->pvt; -+ if (!nwip->sem_init_done) { -+ sema_init(&nwip->sem, 1); -+ init_completion(&nwip->complete); -+ nwip->sem_init_done = 1; -+ } -+ -+ nss_wifi_if_stats_dentry_create(); -+ return NSS_WIFI_IF_SUCCESS; -+} -+ -+/* -+ * nss_wifi_if_callback -+ * Callback to handle the completion of NSS->HLOS messages. -+ */ -+static void nss_wifi_if_callback(void *app_data, struct nss_cmn_msg *ncm) -+{ -+ struct nss_wifi_if_handle *handle = (struct nss_wifi_if_handle *)app_data; -+ struct nss_wifi_if_pvt *nwip = handle->pvt; -+ -+ if (ncm->response != NSS_CMN_RESPONSE_ACK) { -+ nss_warning("%px: wifi_if Error response %d\n", -+ handle->nss_ctx, ncm->response); -+ nwip->response = NSS_TX_FAILURE; -+ complete(&nwip->complete); -+ return; -+ } -+ -+ nwip->response = NSS_TX_SUCCESS; -+ complete(&nwip->complete); -+} -+ -+/* -+ * nss_wifi_if_tx_msg() -+ * Send a message from HLOS to NSS asynchronously. -+ */ -+nss_tx_status_t nss_wifi_if_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_wifi_if_msg *nwim) -+{ -+ struct nss_cmn_msg *ncm = &nwim->cm; -+ -+ if (ncm->type > NSS_WIFI_IF_MAX_MSG_TYPES) { -+ nss_warning("%px: message type out of range: %d\n", nss_ctx, ncm->type); -+ return NSS_TX_FAILURE; -+ } -+ -+ return nss_core_send_cmd(nss_ctx, nwim, sizeof(*nwim), NSS_NBUF_PAYLOAD_SIZE); -+} -+ -+/* -+ * nss_wifi_if_tx_msg_sync -+ * Send a message from HLOS to NSS synchronously. -+ */ -+static nss_tx_status_t nss_wifi_if_tx_msg_sync(struct nss_wifi_if_handle *handle, -+ struct nss_wifi_if_msg *nwim) -+{ -+ nss_tx_status_t status; -+ int ret = 0; -+ struct nss_wifi_if_pvt *nwip = handle->pvt; -+ struct nss_ctx_instance *nss_ctx = handle->nss_ctx; -+ -+ down(&nwip->sem); -+ -+ status = nss_wifi_if_tx_msg(nss_ctx, nwim); -+ if (status != NSS_TX_SUCCESS) { -+ nss_warning("%px: nss_wifi_if_msg failed\n", nss_ctx); -+ up(&nwip->sem); -+ return status; -+ } -+ -+ ret = wait_for_completion_timeout(&nwip->complete, -+ msecs_to_jiffies(NSS_WIFI_IF_TX_TIMEOUT)); -+ if (!ret) { -+ nss_warning("%px: wifi_if tx failed due to timeout\n", nss_ctx); -+ nwip->response = NSS_TX_FAILURE; -+ } -+ -+ status = nwip->response; -+ up(&nwip->sem); -+ -+ return status; -+} -+ -+/* -+ * nss_wifi_if_handle_destroy() -+ * Destroy the wifi handle either due to request from WLAN or due to error. -+ */ -+static int nss_wifi_if_handle_destroy(struct nss_wifi_if_handle *handle) -+{ -+ int32_t if_num; -+ int32_t index; -+ struct nss_ctx_instance *nss_ctx; -+ nss_tx_status_t status; -+ -+ if (!handle) { -+ nss_warning("Destroy failed as wifi_if handle is NULL\n"); -+ return NSS_TX_FAILURE_BAD_PARAM; -+ } -+ -+ if_num = handle->if_num; -+ index = NSS_WIFI_IF_GET_INDEX(if_num); -+ nss_ctx = handle->nss_ctx; -+ -+ spin_lock_bh(&wifi_if_lock); -+ wifi_handle[index] = NULL; -+ spin_unlock_bh(&wifi_if_lock); -+ -+ status = nss_dynamic_interface_dealloc_node(if_num, NSS_DYNAMIC_INTERFACE_TYPE_WIFI); -+ if (status != NSS_TX_SUCCESS) { -+ nss_warning("%px: Dynamic interface destroy failed status %d\n", nss_ctx, status); -+ return status; -+ } -+ -+ kfree(handle->pvt); -+ kfree(handle); -+ -+ return status; -+} -+ -+/* -+ * nss_wifi_if_handle_init() -+ * Initialize wifi handle which holds the if_num and stats per interface. -+ */ -+static struct nss_wifi_if_handle *nss_wifi_if_handle_create(struct nss_ctx_instance *nss_ctx, -+ int32_t *cmd_rsp) -+{ -+ int32_t index; -+ int32_t if_num = 0; -+ struct nss_wifi_if_handle *handle; -+ -+ if_num = nss_dynamic_interface_alloc_node(NSS_DYNAMIC_INTERFACE_TYPE_WIFI); -+ if (if_num < 0) { -+ nss_warning("%px:failure allocating wifi if\n", nss_ctx); -+ *cmd_rsp = NSS_WIFI_IF_DYNAMIC_IF_FAILURE; -+ return NULL; -+ } -+ -+ index = NSS_WIFI_IF_GET_INDEX(if_num); -+ -+ handle = (struct nss_wifi_if_handle *)kzalloc(sizeof(struct nss_wifi_if_handle), -+ GFP_KERNEL); -+ if (!handle) { -+ nss_warning("%px: handle memory alloc failed\n", nss_ctx); -+ *cmd_rsp = NSS_WIFI_IF_ALLOC_FAILURE; -+ goto error1; -+ } -+ -+ handle->nss_ctx = nss_ctx; -+ handle->if_num = if_num; -+ handle->pvt = (struct nss_wifi_if_pvt *)kzalloc(sizeof(struct nss_wifi_if_pvt), -+ GFP_KERNEL); -+ if (!handle->pvt) { -+ nss_warning("%px: failure allocating memory for nss_wifi_if_pvt\n", nss_ctx); -+ *cmd_rsp = NSS_WIFI_IF_ALLOC_FAILURE; -+ goto error2; -+ } -+ -+ handle->cb = NULL; -+ handle->app_data = NULL; -+ -+ spin_lock_bh(&wifi_if_lock); -+ wifi_handle[index] = handle; -+ spin_unlock_bh(&wifi_if_lock); -+ -+ *cmd_rsp = NSS_WIFI_IF_SUCCESS; -+ -+ return handle; -+ -+error2: -+ kfree(handle); -+error1: -+ nss_dynamic_interface_dealloc_node(if_num, NSS_DYNAMIC_INTERFACE_TYPE_WIFI); -+ return NULL; -+} -+ -+/* nss_wifi_if_msg_init() -+ * Initialize wifi specific message structure. -+ */ -+static void nss_wifi_if_msg_init(struct nss_wifi_if_msg *nwim, -+ uint16_t if_num, -+ uint32_t type, -+ uint32_t len, -+ nss_wifi_if_msg_callback_t cb, -+ struct nss_wifi_if_handle *app_data) -+{ -+ nss_cmn_msg_init(&nwim->cm, if_num, type, len, (void *)cb, (void *)app_data); -+} -+ -+/* -+ * nss_wifi_if_create_sync() -+ * Create a wifi interface and associate it with the netdev -+ */ -+struct nss_wifi_if_handle *nss_wifi_if_create_sync(struct net_device *netdev) -+{ -+ struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[nss_top_main.wlan_handler_id]; -+ struct nss_wifi_if_msg nwim; -+ struct nss_wifi_if_create_msg *nwcm; -+ uint32_t ret; -+ struct nss_wifi_if_handle *handle = NULL; -+ -+ if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { -+ nss_warning("%px: Interface could not be created as core not ready\n", nss_ctx); -+ return NULL; -+ } -+ -+ handle = nss_wifi_if_handle_create(nss_ctx, &ret); -+ if (!handle) { -+ nss_warning("%px:wifi_if handle creation failed ret %d\n", nss_ctx, ret); -+ return NULL; -+ } -+ -+ /* Initializes the semaphore and also sets the msg handler for if_num */ -+ ret = nss_wifi_if_register_handler(handle); -+ if (ret != NSS_WIFI_IF_SUCCESS) { -+ nss_warning("%px: Registration handler failed reason: %d\n", nss_ctx, ret); -+ goto error; -+ } -+ -+ nss_wifi_if_msg_init(&nwim, handle->if_num, NSS_WIFI_IF_TX_CREATE_MSG, -+ sizeof(struct nss_wifi_if_create_msg), nss_wifi_if_callback, handle); -+ -+ nwcm = &nwim.msg.create; -+ nwcm->flags = 0; -+ memcpy(nwcm->mac_addr, netdev->dev_addr, ETH_ALEN); -+ -+ ret = nss_wifi_if_tx_msg_sync(handle, &nwim); -+ if (ret != NSS_TX_SUCCESS) { -+ nss_warning("%px: nss_wifi_if_tx_msg_sync failed %u\n", nss_ctx, ret); -+ goto error; -+ } -+ -+ nss_core_register_subsys_dp(nss_ctx, handle->if_num, NULL, NULL, NULL, netdev, 0); -+ -+ /* -+ * Hold a reference to the net_device -+ */ -+ dev_hold(netdev); -+ -+ /* -+ * The context returned is the interface # which is, essentially, the index into the if_ctx -+ * array that is holding the net_device pointer -+ */ -+ -+ return handle; -+ -+error: -+ nss_wifi_if_handle_destroy(handle); -+ return NULL; -+} -+EXPORT_SYMBOL(nss_wifi_if_create_sync); -+ -+/* -+ * nss_wifi_if_destroy_sync() -+ * Destroy the wifi interface associated with the interface number. -+ */ -+nss_tx_status_t nss_wifi_if_destroy_sync(struct nss_wifi_if_handle *handle) -+{ -+ nss_tx_status_t status; -+ struct net_device *dev; -+ int32_t if_num = handle->if_num; -+ struct nss_ctx_instance *nss_ctx = handle->nss_ctx; -+ -+ if (unlikely(nss_ctx->state != NSS_CORE_STATE_INITIALIZED)) { -+ nss_warning("%px: Interface could not be destroyed as core not ready\n", nss_ctx); -+ return NSS_TX_FAILURE_NOT_READY; -+ } -+ -+ spin_lock_bh(&nss_top_main.lock); -+ if (!nss_ctx->subsys_dp_register[if_num].ndev) { -+ spin_unlock_bh(&nss_top_main.lock); -+ nss_warning("%px: Unregister wifi interface %d: no context\n", nss_ctx, if_num); -+ return NSS_TX_FAILURE_BAD_PARAM; -+ } -+ -+ dev = nss_ctx->subsys_dp_register[if_num].ndev; -+ nss_core_unregister_subsys_dp(nss_ctx, if_num); -+ spin_unlock_bh(&nss_top_main.lock); -+ dev_put(dev); -+ -+ status = nss_wifi_if_handle_destroy(handle); -+ return status; -+} -+EXPORT_SYMBOL(nss_wifi_if_destroy_sync); -+ -+/* -+ * nss_wifi_if_register() -+ * Register cb, netdev associated with the if_num to the nss data plane -+ * to receive data packets. -+ */ -+void nss_wifi_if_register(struct nss_wifi_if_handle *handle, -+ nss_wifi_if_data_callback_t rx_callback, -+ struct net_device *netdev) -+{ -+ struct nss_ctx_instance *nss_ctx; -+ int32_t if_num; -+ -+ if (!handle) { -+ nss_warning("nss_wifi_if_register handle is NULL\n"); -+ return; -+ } -+ -+ nss_ctx = handle->nss_ctx; -+ if_num = handle->if_num; -+ nss_assert(NSS_IS_IF_TYPE(DYNAMIC, if_num)); -+ -+ nss_core_register_subsys_dp(nss_ctx, if_num, rx_callback, NULL, NULL, netdev, netdev->features); -+} -+EXPORT_SYMBOL(nss_wifi_if_register); -+ -+/* -+ * nss_wifi_if_unregister() -+ * Unregister the cb, netdev associated with the if_num. -+ */ -+void nss_wifi_if_unregister(struct nss_wifi_if_handle *handle) -+{ -+ struct nss_ctx_instance *nss_ctx; -+ int32_t if_num; -+ -+ if (!handle) { -+ nss_warning("nss_wifi_if_unregister handle is NULL\n"); -+ return; -+ } -+ -+ nss_ctx = handle->nss_ctx; -+ if_num = handle->if_num; -+ -+ nss_core_unregister_subsys_dp(nss_ctx, if_num); -+} -+EXPORT_SYMBOL(nss_wifi_if_unregister); -+ -+/* -+ * nss_wifi_if_tx_buf() -+ * HLOS interface has received a packet which we redirect to the NSS. -+ */ -+nss_tx_status_t nss_wifi_if_tx_buf(struct nss_wifi_if_handle *handle, -+ struct sk_buff *skb) -+{ -+ struct nss_ctx_instance *nss_ctx; -+ int32_t if_num; -+ int cpu = 0; -+ -+ if (!handle) { -+ nss_warning("nss_wifi_if_tx_buf handle is NULL\n"); -+ return NSS_TX_FAILURE; -+ } -+ -+ nss_ctx = handle->nss_ctx; -+ if_num = handle->if_num; -+ -+ /* -+ * redirect should be turned on in /proc/ -+ */ -+ if (unlikely(nss_ctl_redirect == 0)) { -+ return NSS_TX_FAILURE_NOT_ENABLED; -+ } -+ -+ if (unlikely(skb->vlan_tci)) { -+ return NSS_TX_FAILURE_NOT_SUPPORTED; -+ } -+ -+ nss_assert(NSS_IS_IF_TYPE(DYNAMIC, if_num)); -+ -+ /* -+ * Sanity check the SKB to ensure that it's suitable for us -+ */ -+ if (unlikely(skb->len <= ETH_HLEN)) { -+ nss_warning("%px: Rx packet: %px too short", nss_ctx, skb); -+ return NSS_TX_FAILURE_TOO_SHORT; -+ } -+ -+ /* -+ * set skb queue mapping -+ */ -+ cpu = get_cpu(); -+ put_cpu(); -+ skb_set_queue_mapping(skb, cpu); -+ -+ return nss_core_send_packet(nss_ctx, skb, if_num, H2N_BIT_FLAG_VIRTUAL_BUFFER); -+} -+EXPORT_SYMBOL(nss_wifi_if_tx_buf); ---- /dev/null -+++ b/nss_wifi_if_stats.c -@@ -0,0 +1,210 @@ -+/* -+ ************************************************************************** -+ * Copyright (c) 2016-2017, 2019 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_core.h" -+#include "nss_wifi_if.h" -+ -+/* -+ * Data structure that holds the wifi interface context. -+ */ -+extern struct nss_wifi_if_handle *wifi_handle[]; -+ -+/* -+ * Spinlock to protect the global data structure wifi_handle. -+ */ -+extern spinlock_t wifi_if_lock; -+ -+/* -+ * nss_wifi_if_stats_get() -+ * Get the stats from wifi handle to buffer(line) for if_num. -+ */ -+static int32_t nss_wifi_if_stats_get(int32_t if_num, int i, char *line) -+{ -+ int32_t bytes = 0; -+ struct nss_wifi_if_stats *stats; -+ int32_t ifnum; -+ uint32_t len = 80; -+ struct nss_wifi_if_handle *handle = NULL; -+ -+ ifnum = if_num - NSS_DYNAMIC_IF_START; -+ -+ spin_lock_bh(&wifi_if_lock); -+ if (!wifi_handle[ifnum]) { -+ spin_unlock_bh(&wifi_if_lock); -+ goto end; -+ } -+ -+ handle = wifi_handle[ifnum]; -+ spin_unlock_bh(&wifi_if_lock); -+ stats = &handle->stats; -+ -+ switch (i) { -+ case 0: -+ bytes = scnprintf(line, len, "rx_packets=%d\n", -+ stats->node_stats.rx_packets); -+ break; -+ -+ case 1: -+ bytes = scnprintf(line, len, "rx_bytes=%d\n", -+ stats->node_stats.rx_bytes); -+ break; -+ -+ case 2: -+ bytes = scnprintf(line, len, "rx_dropped=%d\n", -+ nss_cmn_rx_dropped_sum(&stats->node_stats)); -+ break; -+ -+ case 3: -+ bytes = scnprintf(line, len, "tx_packets=%d\n", -+ stats->node_stats.tx_packets); -+ break; -+ -+ case 4: -+ bytes = scnprintf(line, len, "tx_bytes=%d\n", -+ stats->node_stats.tx_bytes); -+ break; -+ -+ case 5: -+ bytes = scnprintf(line, len, "tx_enqueue_failed=%d\n", -+ stats->tx_enqueue_failed); -+ break; -+ -+ case 6: -+ bytes = scnprintf(line, len, "shaper_enqueue_failed=%d\n", -+ stats->shaper_enqueue_failed); -+ break; -+ } -+ -+end: -+ return bytes; -+} -+ -+/* -+ * nss_wifi_if_stats_read() -+ * Read wifi_if statistics -+ */ -+static ssize_t nss_wifi_if_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) -+{ -+ struct nss_stats_data *data = fp->private_data; -+ struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; -+ int32_t if_num = NSS_DYNAMIC_IF_START; -+ int32_t max_if_num = if_num + NSS_MAX_DYNAMIC_INTERFACES; -+ size_t bytes = 0; -+ ssize_t bytes_read = 0; -+ char line[80]; -+ int start, end; -+ -+ if (data) { -+ if_num = data->if_num; -+ } -+ -+ if (if_num > max_if_num) { -+ return 0; -+ } -+ -+ for (; if_num < max_if_num; if_num++) { -+ if (nss_dynamic_interface_get_type(nss_ctx, if_num) != NSS_DYNAMIC_INTERFACE_TYPE_WIFI) -+ continue; -+ -+ bytes = scnprintf(line, sizeof(line), "if_num %d stats start:\n\n", if_num); -+ if ((bytes_read + bytes) > sz) -+ break; -+ -+ if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { -+ bytes_read = -EFAULT; -+ goto end; -+ } -+ -+ bytes_read += bytes; -+ -+ start = 0; -+ end = 7; -+ while (bytes_read < sz && start < end) { -+ bytes = nss_wifi_if_stats_get(if_num, start, line); -+ if (!bytes) -+ break; -+ -+ if ((bytes_read + bytes) > sz) -+ break; -+ -+ if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { -+ bytes_read = -EFAULT; -+ goto end; -+ } -+ -+ bytes_read += bytes; -+ start++; -+ } -+ -+ bytes = scnprintf(line, sizeof(line), "if_num %d stats end:\n\n", if_num); -+ if (bytes_read > (sz - bytes)) -+ break; -+ -+ if (copy_to_user(ubuf + bytes_read, line, bytes) != 0) { -+ bytes_read = -EFAULT; -+ goto end; -+ } -+ -+ bytes_read += bytes; -+ } -+ -+ if (bytes_read > 0) { -+ *ppos = bytes_read; -+ } -+ -+ if (data) { -+ data->if_num = if_num; -+ } -+ -+end: -+ return bytes_read; -+} -+ -+/* -+ * nss_wifi_if_stats_ops -+ */ -+NSS_STATS_DECLARE_FILE_OPERATIONS(wifi_if) -+ -+/* -+ * nss_wifi_if_stats_dentry_create() -+ * Create wifi_if statistics debug entry. -+ */ -+void nss_wifi_if_stats_dentry_create(void) -+{ -+ nss_stats_create_dentry("wifi_if", &nss_wifi_if_stats_ops); -+} -+ -+/* -+ * nss_wifi_if_stats_sync() -+ * Sync stats from the NSS FW -+ */ -+void nss_wifi_if_stats_sync(struct nss_wifi_if_handle *handle, -+ struct nss_wifi_if_stats *nwis) -+{ -+ struct nss_wifi_if_stats *stats = &handle->stats; -+ int i; -+ -+ stats->node_stats.rx_packets += nwis->node_stats.rx_packets; -+ stats->node_stats.rx_bytes += nwis->node_stats.rx_bytes; -+ -+ for (i = 0; i < NSS_MAX_NUM_PRI; i++) { -+ stats->node_stats.rx_dropped[i] += nwis->node_stats.rx_dropped[i]; -+ } -+ stats->node_stats.tx_packets += nwis->node_stats.tx_packets; -+ stats->node_stats.tx_bytes += nwis->node_stats.tx_bytes; -+ stats->tx_enqueue_failed += nwis->tx_enqueue_failed; -+ stats->shaper_enqueue_failed += nwis->shaper_enqueue_failed; -+} ---- a/nss_tls_strings.h -+++ /dev/null -@@ -1,27 +0,0 @@ --/* -- ****************************************************************************** -- * 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. -- ****************************************************************************** -- */ -- --#ifndef __NSS_TLS_STRINGS_H --#define __NSS_TLS_STRINGS_H -- --#include "nss_tls_stats.h" -- --extern struct nss_stats_info nss_tls_strings_stats[NSS_TLS_STATS_MAX]; --extern void nss_tls_strings_dentry_create(void); -- --#endif /* __NSS_TLS_STRINGS_H */ ---- /dev/null -+++ b/nss_wifi_if_stats.h -@@ -0,0 +1,26 @@ -+/* -+ ****************************************************************************** -+ * Copyright (c) 2017, 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. -+ * **************************************************************************** -+ */ -+ -+#ifndef __NSS_WIFI_IF_STATS_H -+#define __NSS_WIFI_IF_STATS_H -+ -+/* -+ * wifi interface statistics APIs -+ */ -+extern void nss_wifi_if_stats_sync(struct nss_wifi_if_handle *handle, struct nss_wifi_if_stats *nwis); -+extern void nss_wifi_if_stats_dentry_create(void); -+ -+#endif /* __NSS_WIFI_IF_STATS_H */ ---- a/nss_wifi_mac_db.c -+++ b/nss_wifi_mac_db.c -@@ -19,21 +19,9 @@ - #include "nss_core.h" - #include "nss_wifi_mac_db_if.h" - --/* -- * Compile time assertion. -- */ --#define NSS_WIFI_MAC_DB_COMPILE_TIME_ASSERT(assertion_name, predicate) \ -- typedef char assertion_name[(predicate) ? 1 : -1] -- - #define NSS_WIFI_MAC_DB_TX_TIMEOUT 1000 /* Millisecond to jiffies*/ - - /* -- * Validate the Wi-Fi MAC database message size not exceeding buffer size. -- */ --NSS_WIFI_MAC_DB_COMPILE_TIME_ASSERT(NSS_WIFI_MAC_DB_MAX_BUF_MSG, -- (sizeof(struct nss_wifi_mac_db_msg) < NSS_NBUF_PAYLOAD_SIZE)); -- --/* - * nss_wifi_mac_db_get_context() +--- a/exports/nss_n2h.h ++++ b/exports/nss_n2h.h +@@ -73,40 +73,43 @@ struct nss_n2h_cfg_pvt { */ - struct nss_ctx_instance *nss_wifi_mac_db_get_context(void) ---- a/nss_wifi_mesh.c -+++ /dev/null -@@ -1,242 +0,0 @@ --/* -- ************************************************************************** -- * 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_tx_rx_common.h" --#include "nss_core.h" --#include "nss_cmn.h" --#include "nss_wifi_mesh.h" --#include "nss_wifi_mesh_log.h" --#include "nss_wifi_mesh_strings.h" -- --/* -- * nss_wifi_mesh_verify_if_num() -- * Verify interface number. -- */ --bool nss_wifi_mesh_verify_if_num(nss_if_num_t if_num) --{ -- enum nss_dynamic_interface_type if_type = nss_dynamic_interface_get_type(nss_wifi_mesh_get_context(), if_num); -- -- return ((if_type == NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER) || -- (if_type == NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER)); --} --EXPORT_SYMBOL(nss_wifi_mesh_verify_if_num); -- --/* nss_wifi_mesh_handler() -- * Handles Wi-Fi mesh messages from NSS to HLOS. -- */ --static void nss_wifi_mesh_handler(struct nss_ctx_instance *nss_ctx, struct nss_cmn_msg *ncm, void *app_data) --{ -- nss_wifi_mesh_msg_callback_t cb; -- struct nss_wifi_mesh_msg *nwmm = (struct nss_wifi_mesh_msg *)ncm; -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- nss_assert(nss_is_dynamic_interface(ncm->interface)); -- nss_assert(nss_wifi_mesh_verify_if_num(ncm->interface)); -- -- /* -- * Is this a valid request/response packet? -- */ -- if (ncm->type >= NSS_WIFI_MESH_MSG_MAX) { -- nss_warning("%px: Received invalid message %d for wifi_mesh interface\n", nss_ctx, ncm->type); -- return; -- } -- -- -- /* -- * For variable array the size of the common length will be greater the nss_wifi_mesh_msg -- * length. Add conditional checking for messages where length check will fail. -- */ -- if ((nss_cmn_get_msg_len(ncm) > sizeof(struct nss_wifi_mesh_msg)) && -- (ncm->type != NSS_WIFI_MESH_MSG_PATH_TABLE_DUMP) && -- (ncm->type != NSS_WIFI_MESH_MSG_PROXY_PATH_TABLE_DUMP)) { -- nss_warning("%px: Length of message is greater than expected, type: %d, len: %d", -- nss_ctx, ncm->type, ncm->len); -- return; -- } -- -- /* -- * Log failures -- */ -- nss_core_log_msg_failures(nss_ctx, ncm); -- -- /* -- * Trace Messages -- */ -- nss_wifi_mesh_log_rx_msg(nwmm); -- -- /* -- * Update the stats and send statistics notifications to the registered modules. -- */ -- if (nwmm->cm.type == NSS_WIFI_MESH_MSG_STATS_SYNC) { -- nss_wifi_mesh_update_stats(ncm->interface, &nwmm->msg.stats_sync_msg); -- nss_wifi_mesh_stats_notify(ncm->interface, nss_ctx->id); -- } -- -- if (ncm->response == NSS_CMN_RESPONSE_NOTIFY) { -- ncm->cb = (nss_ptr_t)nss_core_get_msg_handler(nss_ctx, ncm->interface); -- ncm->app_data = (nss_ptr_t)app_data; -- } -- -- if (!ncm->cb) { -- return; -- } -- -- cb = (nss_wifi_mesh_msg_callback_t)ncm->cb; -- cb((void *)ncm->app_data, ncm); --} -- --/* -- * nss_wifi_mesh_msg_init() -- * Initiliaze a Wi-Fi mesh message. -- */ --void nss_wifi_mesh_msg_init(struct nss_wifi_mesh_msg *nwm, nss_if_num_t if_num, uint32_t type, uint32_t len, -- nss_wifi_mesh_msg_callback_t cb, void *app_data) --{ -- nss_assert(nss_wifi_mesh_verify_if_num(if_num)); -- nss_cmn_msg_init(&nwm->cm, if_num, type, len, cb, app_data); --} --EXPORT_SYMBOL(nss_wifi_mesh_msg_init); -- --/* -- * nss_wifi_mesh_tx_buf -- * Send data packet for vap processing asynchronously. -- */ --nss_tx_status_t nss_wifi_mesh_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, nss_if_num_t if_num) --{ -- nss_assert(nss_is_dynamic_interface(if_num)); -- return nss_core_send_packet(nss_ctx, os_buf, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); --} --EXPORT_SYMBOL(nss_wifi_mesh_tx_buf); -- --/* -- * nss_wifi_mesh_tx_msg -- * Transmit a Wi-Fi mesh message to the NSS firmware asynchronously. -- * -- * NOTE: The caller is expected to handle synchronous waiting for message -- * response if needed. -- */ --nss_tx_status_t nss_wifi_mesh_tx_msg(struct nss_ctx_instance *nss_ctx, struct nss_wifi_mesh_msg *msg) --{ -- struct nss_cmn_msg *ncm = &msg->cm; -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- if (ncm->type >= NSS_WIFI_MESH_MSG_MAX) { -- nss_warning("%px: wifi_mesh message type out of range: %d\n", nss_ctx, ncm->type); -- return NSS_TX_FAILURE; -- } -- -- /* -- * Log messages. -- */ -- nss_wifi_mesh_log_tx_msg(msg); -- -- /* -- * The interface number shall be one of the Wi-Fi mesh socket interfaces. -- */ -- nss_assert(nss_is_dynamic_interface(ncm->interface)); -- -- return nss_core_send_cmd(nss_ctx, msg, sizeof(*msg), NSS_NBUF_PAYLOAD_SIZE); --} --EXPORT_SYMBOL(nss_wifi_mesh_tx_msg); -- --/* -- **************************************** -- * Register/Unregister/Miscellaneous APIs -- **************************************** -- */ -- --/* -- * nss_wifi_mesh_get_context() -- * Return the core ctx which the feature is on. -- */ --struct nss_ctx_instance *nss_wifi_mesh_get_context(void) --{ -- return (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; --} --EXPORT_SYMBOL(nss_wifi_mesh_get_context); -- --/* -- * nss_unregister_wifi_mesh_if() -- * Unregister Wi-Fi mesh from the NSS driver. -- */ --void nss_unregister_wifi_mesh_if(nss_if_num_t if_num) --{ -- struct nss_ctx_instance *nss_ctx = nss_wifi_mesh_get_context(); -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- -- nss_core_unregister_subsys_dp(nss_ctx, if_num); -- nss_core_unregister_msg_handler(nss_ctx, if_num); -- nss_core_unregister_handler(nss_ctx, if_num); -- nss_wifi_mesh_stats_handle_free(if_num); --} --EXPORT_SYMBOL(nss_unregister_wifi_mesh_if); -- --/* -- * nss_register_wifi_mesh_if() -- * Register wifi_mesh with nss driver. -- */ --uint32_t nss_register_wifi_mesh_if(nss_if_num_t if_num, -- nss_wifi_mesh_data_callback_t mesh_data_callback, -- nss_wifi_mesh_ext_data_callback_t mesh_ext_data_callback, -- nss_wifi_mesh_msg_callback_t mesh_event_callback, -- uint32_t dp_type, struct net_device *netdev, uint32_t features) --{ -- struct nss_ctx_instance *nss_ctx = nss_wifi_mesh_get_context(); -- uint32_t status; -- -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- nss_assert(netdev); -- nss_assert(nss_wifi_mesh_verify_if_num(if_num)); -- -- if (!nss_wifi_mesh_stats_handle_alloc(if_num, netdev->ifindex)) { -- nss_warning("%px: couldn't allocate stats handle for device name: %s, if_num: 0x%x\n", nss_ctx, netdev->name, if_num); -- return NSS_CORE_STATUS_FAILURE; -- } -- -- nss_core_register_handler(nss_ctx, if_num, nss_wifi_mesh_handler, netdev); -- -- status = nss_core_register_msg_handler(nss_ctx, if_num, mesh_event_callback); -- if (status != NSS_CORE_STATUS_SUCCESS) { -- nss_warning("%px: unable to register event handler for interface(%u)\n", nss_ctx, if_num); -- nss_core_unregister_handler(nss_ctx, if_num); -- nss_wifi_mesh_stats_handle_free(if_num); -- return status; -- } -- -- nss_core_register_subsys_dp(nss_ctx, if_num, mesh_data_callback, mesh_ext_data_callback, NULL, netdev, features); -- nss_core_set_subsys_dp_type(nss_ctx, netdev, if_num, dp_type); -- return NSS_CORE_STATUS_SUCCESS; --} --EXPORT_SYMBOL(nss_register_wifi_mesh_if); -- --/* -- * nss_wifi_mesh_init() -- * Initialize the mesh stats dentries. -- */ --void nss_wifi_mesh_init(void) --{ -- if (!nss_wifi_mesh_strings_dentry_create()) { -- nss_warning("Unable to create dentry for Wi-Fi mesh strings\n"); -- } -- -- if (!nss_wifi_mesh_stats_dentry_create()) { -- nss_warning("Unable to create dentry for Wi-Fi mesh stats\n"); -- } --} ---- a/nss_wifi_mesh_log.c -+++ /dev/null -@@ -1,387 +0,0 @@ --/* -- ************************************************************************** -- * 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. -- ************************************************************************** -- */ -- --/* -- * nss_wifi_mesh_log.c -- * NSS WiFi Mesh logger file. -- */ -- --#include "nss_core.h" --#include "nss_wifi_mesh.h" -- --#define NSS_WIFI_MESH_LOG_MESSAGE_TYPE_INDEX(type) ((type) - NSS_IF_MAX_MSG_TYPES) -- --/* -- * nss_wifi_mesh_log_message_types_str -- * NSS Wi-Fi mesh message strings. -- */ --static uint8_t *nss_wifi_mesh_log_message_types_str[NSS_WIFI_MESH_LOG_MESSAGE_TYPE_INDEX(NSS_WIFI_MESH_MSG_MAX)] __maybe_unused = { -- "WiFi Mesh configure", -- "WiFi Mesh configure Mpath Add", -- "WiFi Mesh configure Mpath Delete", -- "WiFi Mesh configure Mpath Update", -- "WiFi Mesh configure Proxy Learn", -- "WiFi Mesh configure Proxy Add", -- "WiFi Mesh configure Proxy Update", -- "WiFi Mesh configure Proxy Delete", -- "WiFi Mesh configure Mpath Not Found", -- "WiFi Mesh configure Refresh" -- "WiFi Mesh configure Mpath Table Dump", -- "WiFi Mesh configure Proxy Path Table Dump", -- "WiFi Mesh configure Assoc Link Vap", -- "WiFi Mesh configure Exception Message", -- "WiFi Mesh configure Rate limit message", -- "WiFi Mesh configure Stats Sync" --}; -- --/* -- * nss_wifi_mesh_log_configure_msg() -- * Log a NSS Wi-Fi mesh interface configure message. -- */ --static void nss_wifi_mesh_log_configure_if_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_config_msg *cmsg __maybe_unused = &nwmm->msg.mesh_config; -- nss_trace("%px: WiFi Mesh configure message\n" -- "Local Mac address: %pM\n" -- "TTL: %d\n" -- "Mesh Path Refresh Time: %d\n" -- "Mpp Learning Mode: %d\n" -- "Block Mesh Forwarding: %d\n" -- "Configs Flags: 0x%x\n", -- cmsg, cmsg->local_mac_addr, cmsg->ttl, -- cmsg->mesh_path_refresh_time, -- cmsg->mpp_learning_mode, -- cmsg->block_mesh_forwarding, -- cmsg->config_flags); --} -- --/* -- * nss_wifi_mesh_log_mpath_add_msg() -- * Log a NSS Wi-Fi mesh mpath add message. -- */ --static void nss_wifi_mesh_log_mpath_add_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_mpath_add_msg *mamsg __maybe_unused = &nwmm->msg.mpath_add; -- nss_trace("%px: NSS WiFi Mesh Mpath add message:\n" -- "Dest Mac address: %pM\n" -- "Next Hop Mac address: %pM\n" -- "Metric: %d\n" -- "Expiry Time: %d\n" -- "Hop Count: %d\n" -- "Flags: 0x%x\n" -- "Link Vap id: %d\n" -- "Is Mesh Gate: %d\n", -- mamsg, mamsg->dest_mac_addr, mamsg->next_hop_mac_addr, -- mamsg->metric, mamsg->expiry_time, mamsg->hop_count, -- mamsg->path_flags, mamsg->link_vap_id, mamsg->is_mesh_gate); --} -- --/* -- * nss_wifi_mesh_log_mpath_delete_msg() -- * Log a NSS Wi-Fi mesh mpath delete message. -- */ --static void nss_wifi_mesh_log_mpath_delete_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_mpath_del_msg *mdmsg __maybe_unused = &nwmm->msg.mpath_del; -- nss_trace("%px: NSS WiFi Mesh Mpath delete message:\n" -- "Dest Mac Address: %pM\n" -- "Link Vap id: %d\n" -- "Next Hop Mac address: %pM\n", -- mdmsg, mdmsg->mesh_dest_mac_addr, mdmsg->link_vap_id, mdmsg->next_hop_mac_addr); --} -- --/* -- * nss_wifi_mesh_log_mpath_update_msg() -- * Log a NSS Wi-Fi mesh mpath update message. -- */ --static void nss_wifi_mesh_log_mpath_update_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_mpath_update_msg *mumsg __maybe_unused = &nwmm->msg.mpath_update; -- nss_trace("%px: NSS WiFi Mesh Mpath update message:\n" -- "Dest Mac address: %pM\n" -- "Next Hop Mac address: %pM\n" -- "Metric: %d\n" -- "Expiry Time: %d\n" -- "Hop Count: %d\n" -- "Flags: 0x%x\n" -- "Link Vap id: %d\n" -- "Is Mesh Gate: %d\n" -- "Update Flags: %d\n", -- mumsg, mumsg->dest_mac_addr, mumsg->next_hop_mac_addr, -- mumsg->metric, mumsg->expiry_time, mumsg->hop_count, -- mumsg->path_flags, mumsg->link_vap_id, mumsg->is_mesh_gate, -- mumsg->update_flags); --} -- --/* -- * nss_wifi_mesh_log_proxy_path_learn_msg() -- * Log a NSS Wi-Fi mesh proxy path learn message. -- */ --static void nss_wifi_mesh_log_proxy_path_learn_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_proxy_path_learn_msg *pplm __maybe_unused = &nwmm->msg.proxy_learn_msg; -- nss_trace("%px: NSS WiFi Mesh Proxy Path Learn message:\n" -- "Mesh Dest Mac address: %pM\n" -- "Destination Mac address: %pM\n" -- "flags: 0x%x\n", -- pplm, pplm->mesh_dest_mac, pplm->dest_mac_addr, -- pplm->path_flags); --} -- --/* -- * nss_wifi_mesh_log_proxy_path_add_msg() -- * Log a NSS Wi-Fi Mesh proxy path add message. -- */ --static void nss_wifi_mesh_log_proxy_path_add_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_proxy_path_add_msg *ppam __maybe_unused = &nwmm->msg.proxy_add_msg; -- nss_trace("%px: NSS WiFi Mesh Proxy Path Add message:\n" -- "Mesh Dest Mac address: %pM\n" -- "Destination Mac address: %pM\n" -- "flags: 0x%x\n", -- ppam, ppam->mesh_dest_mac, ppam->dest_mac_addr, -- ppam->path_flags); --} -- --/* -- * nss_wifi_mesh_log_proxy_path_delete_msg() -- * Log a NSS Wi-Fi proxy path delete message. -- */ --static void nss_wifi_mesh_log_proxy_path_delete_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_proxy_path_del_msg *ppdm __maybe_unused = &nwmm->msg.proxy_del_msg; -- nss_trace("%px: NSS WiFi Mesh Proxy Path Delete message:\n" -- "Mesh Dest Mac address: %pM\n" -- "Destination Mac address: %pM\n", -- ppdm, ppdm->mesh_dest_mac_addr, ppdm->dest_mac_addr); --} -- --/* -- * nss_wifi_mesh_log_proxy_path_update_msg() -- * Log a NSS Wi-Fi mesh proxy path update message. -- */ --static void nss_wifi_mesh_log_proxy_path_update_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_proxy_path_update_msg *ppum __maybe_unused = &nwmm->msg.proxy_update_msg; -- nss_trace("%px: NSS WiFi Mesh Proxy Path Add message:\n" -- "Mesh Dest Mac address: %pM\n" -- "Destination Mac address: %pM\n" -- "flags: 0x%x\n" -- "Bitmap: %d\n", -- ppum, ppum->mesh_dest_mac, ppum->dest_mac_addr, -- ppum->path_flags, ppum->bitmap); --} -- --/* -- * nss_wifi_mesh_log_mpath_not_found_msg() -- * Log a NSS Wi-Fi mesh mpath not found message. -- */ --static void nss_wifi_mesh_log_mpath_not_found_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_mpath_not_found_msg *mnfm __maybe_unused = &nwmm->msg.mpath_not_found_msg; -- nss_trace("%px: NSS WiFi Mesh Mpath not found message:\n" -- "Destination Mac address: %pM\n" -- "Transmitter Mac address: %pM\n" -- "Link Vap Id: %d\n" -- "Is Mesh Forwarding Path: %d\n", -- mnfm, mnfm->dest_mac_addr, mnfm->transmitter_mac_addr, -- mnfm->link_vap_id, mnfm->is_mesh_forward_path); --} -- --/* -- * nss_wifi_mesh_log_mpath_refresh_msg() -- * Log a NSS Wi-Fi mesh mpath refresh message. -- */ --static void nss_wifi_mesh_log_mpath_refresh_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_path_refresh_msg *mprm __maybe_unused = &nwmm->msg.path_refresh_msg; -- nss_trace("%px: NSS WiFi Mesh Mpath refresh message:\n" -- "Destination Mac address: %pM\n" -- "Next Hop Mac address: %pM\n" -- "Flags: 0x%x\n" -- "Link Vap Id: %d\n", -- mprm, mprm->dest_mac_addr, mprm->next_hop_mac_addr, -- mprm->path_flags, mprm->link_vap_id); --} -- --/* -- * nss_wifi_mesh_log_mpath_expiry_msg() -- * Log a NSS Wi-Fi mesh mpath expiry message. -- */ --static void nss_wifi_mesh_log_mpath_expiry_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_path_expiry_msg *mpem __maybe_unused = &nwmm->msg.path_expiry_msg; -- nss_trace("%px: NSS WiFi Mesh Mpath expiry message:\n" -- "Destination Mac address: %pM\n" -- "Next Hop Mac address: %pM\n" -- "Flags: 0x%x\n" -- "Link Vap Id: %d\n", -- mpem, mpem->mesh_dest_mac_addr, mpem->next_hop_mac_addr, -- mpem->path_flags, mpem->link_vap_id); --} -- --/* -- * nss_wifi_mesh_log_exception_flag_msg() -- * Log a NSS Wi-Fi mesh exception flag message. -- */ --static void nss_wifi_mesh_log_exception_flag_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_exception_flag_msg *efm __maybe_unused = &nwmm->msg.exception_msg; -- nss_trace("%px: NSS WiFi Mesh Exception Flag message:\n" -- "Destination Mac address: %pM\n", -- efm, efm->dest_mac_addr); --} -- --/* -- * nss_wifi_mesh_log_rate_limit_config() -- * Log a NSS Wi-Fi mesh rate limit config message. -- */ --static void nss_wifi_mesh_log_rate_limit_config(struct nss_wifi_mesh_msg *nwmm) --{ -- struct nss_wifi_mesh_rate_limit_config *rlcm __maybe_unused = &nwmm->msg.exc_cfg; -- nss_trace("%px: NSS WiFi Mesh rate limit config message:\n" -- "exception_num : %d\n" -- "enable : %d\n" -- "rate_limit : %d\n", -- rlcm, rlcm->exception_num, rlcm->enable, rlcm->rate_limit); --} -- --/* -- * nss_wifi_mesh_log_verbose() -- * Log message contents. -- */ --static void nss_wifi_mesh_log_verbose(struct nss_wifi_mesh_msg *nwmm) --{ -- switch (nwmm->cm.type) { -- case NSS_WIFI_MESH_MSG_INTERFACE_CONFIGURE: -- nss_wifi_mesh_log_configure_if_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_MSG_MPATH_ADD: -- nss_wifi_mesh_log_mpath_add_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_MSG_MPATH_DELETE: -- nss_wifi_mesh_log_mpath_delete_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_MSG_MPATH_UPDATE: -- nss_wifi_mesh_log_mpath_update_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_MSG_PROXY_PATH_LEARN: -- nss_wifi_mesh_log_proxy_path_learn_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_MSG_PROXY_PATH_ADD: -- nss_wifi_mesh_log_proxy_path_add_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_MSG_PROXY_PATH_DELETE: -- nss_wifi_mesh_log_proxy_path_delete_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_MSG_PROXY_PATH_UPDATE: -- nss_wifi_mesh_log_proxy_path_update_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_MSG_PATH_NOT_FOUND: -- nss_wifi_mesh_log_mpath_not_found_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_MSG_PATH_REFRESH: -- nss_wifi_mesh_log_mpath_refresh_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_MSG_PATH_EXPIRY: -- nss_wifi_mesh_log_mpath_expiry_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_MSG_PATH_TABLE_DUMP: -- break; -- -- case NSS_WIFI_MESH_MSG_PROXY_PATH_TABLE_DUMP: -- break; -- -- case NSS_WIFI_MESH_MSG_STATS_SYNC: -- break; -- -- case NSS_WIFI_MESH_MSG_EXCEPTION_FLAG: -- nss_wifi_mesh_log_exception_flag_msg(nwmm); -- break; -- -- case NSS_WIFI_MESH_CONFIG_EXCEPTION: -- nss_wifi_mesh_log_rate_limit_config(nwmm); -- break; -- -- default: -- nss_trace("%px: Invalid message, type: %d\n", nwmm, nwmm->cm.type); -- break; -- } --} -- --/* -- * nss_wifi_mesh_log_tx_msg() -- * Log messages transmitted to firmware. -- */ --void nss_wifi_mesh_log_tx_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- uint32_t index; -- if ((nwmm->cm.type >= NSS_WIFI_MESH_MSG_MAX) || (nwmm->cm.type <= NSS_IF_MAX_MSG_TYPES)) { -- nss_warning("%px: Invalid message, type: %d\n", nwmm, nwmm->cm.type); -- return; -- } -- -- index = NSS_WIFI_MESH_LOG_MESSAGE_TYPE_INDEX(nwmm->cm.type); -- -- nss_info("%px: type[%d]:%s\n", nwmm, nwmm->cm.type, nss_wifi_mesh_log_message_types_str[index - 1]); -- nss_wifi_mesh_log_verbose(nwmm); --} -- --/* -- * nss_wifi_mesh_log_rx_msg() -- * Log messages received from firmware. -- */ --void nss_wifi_mesh_log_rx_msg(struct nss_wifi_mesh_msg *nwmm) --{ -- uint32_t index; -- if (nwmm->cm.response >= NSS_CMN_RESPONSE_LAST) { -- nss_warning("%px: Invalid response, message type: %d\n", nwmm, nwmm->cm.type); -- return; -- } -- -- if (nwmm->cm.type <= NSS_IF_MAX_MSG_TYPES) { -- return; -- } -- -- index = NSS_WIFI_MESH_LOG_MESSAGE_TYPE_INDEX(nwmm->cm.type); -- -- if (nwmm->cm.response == NSS_CMN_RESPONSE_NOTIFY || (nwmm->cm.response == NSS_CMN_RESPONSE_ACK)) { -- nss_info("%px: type[%d]:%s, response[%d]:%s\n", nwmm, nwmm->cm.type, -- nss_wifi_mesh_log_message_types_str[index - 1], -- nwmm->cm.response, nss_cmn_response_str[nwmm->cm.response]); -- goto verbose; -- } -- -- nss_info("%px: msg nack - type[%d]:%s, response[%d]:%s\n", -- nwmm, nwmm->cm.type, nss_wifi_mesh_log_message_types_str[index - 1], -- nwmm->cm.response, nss_cmn_response_str[nwmm->cm.response]); -- --verbose: -- nss_wifi_mesh_log_verbose(nwmm); --} ---- a/nss_wifi_mesh_log.h -+++ /dev/null -@@ -1,34 +0,0 @@ --/* -- ************************************************************************** -- * 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. -- ************************************************************************** -- */ -- --#ifndef __NSS_WIFI_MESH_LOG_H --#define __NSS_WIFI_MESH_LOG_H -- --/* -- * nss_wifi_mesh_log_tx_msg -- * Logs a Wi-Fi mesh message that was sent to the NSS firmware. -- */ --void nss_wifi_mesh_log_tx_msg(struct nss_wifi_mesh_msg *nwmm); -- --/* -- * nss_wifi_mesh_log_rx_msg -- * Logs a Wi-Fi mesh message that was received from the NSS firmware. -- */ --void nss_wifi_mesh_log_rx_msg(struct nss_wifi_mesh_msg *nwmm); -- --#endif /* __NSS_WIFI_MESH_LOG_H */ ---- a/nss_wifi_mesh_stats.c -+++ /dev/null -@@ -1,662 +0,0 @@ --/* -- ************************************************************************** -- * 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_core.h" --#include "nss_tx_rx_common.h" --#include "nss_wifi_mesh.h" --#include "nss_wifi_mesh_stats.h" --#include "nss_wifi_mesh_strings.h" -- --#define NSS_WIFI_MESH_OUTER_STATS 0 --#define NSS_WIFI_MESH_INNER_STATS 1 --#define NSS_WIFI_MESH_PATH_STATS 2 --#define NSS_WIFI_MESH_PROXY_PATH_STATS 3 --#define NSS_WIFI_MESH_EXCEPTION_STATS 4 -- --/* -- * Wi-Fi mesh stats dentry file size. -- */ --#define NSS_WIFI_MESH_DENTRY_FILE_SIZE 19 -- --/* -- * Spinlock for protecting tunnel operations colliding with a tunnel destroy -- */ --static DEFINE_SPINLOCK(nss_wifi_mesh_stats_lock); -- --/* -- * Declare atomic notifier data structure for statistics. -- */ --static ATOMIC_NOTIFIER_HEAD(nss_wifi_mesh_stats_notifier); -- --/* -- * Declare an array of Wi-Fi mesh stats handle. -- */ --struct nss_wifi_mesh_stats_handle *nss_wifi_mesh_stats_hdl[NSS_WIFI_MESH_MAX_DYNAMIC_INTERFACE]; -- --/* -- * nss_wifi_mesh_max_statistics() -- * Wi-Fi mesh maximum statistics. -- */ --static uint32_t nss_wifi_mesh_max_statistics(void) --{ -- uint32_t max1; -- uint32_t exception_stats_max = NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_MAX; -- uint32_t encap_stats_max = NSS_WIFI_MESH_ENCAP_STATS_TYPE_MAX; -- uint32_t decap_stats_max = NSS_WIFI_MESH_DECAP_STATS_TYPE_MAX; -- uint32_t path_stats_max = NSS_WIFI_MESH_PATH_STATS_TYPE_MAX; -- uint32_t proxy_path_stats_max = NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_MAX; -- -- max1 = max(max(encap_stats_max, decap_stats_max), max(path_stats_max, proxy_path_stats_max)); -- -- return (max(max1, exception_stats_max)); --} -- --/* -- * nss_wifi_mesh_stats_handle_alloc() -- * Allocate Wi-Fi mesh tunnel instance -- */ --bool nss_wifi_mesh_stats_handle_alloc(nss_if_num_t if_num, int32_t ifindex) --{ -- struct nss_wifi_mesh_stats_handle *h; -- uint32_t idx; -- -- /* -- * Allocate a handle -- */ -- h = kzalloc(sizeof(struct nss_wifi_mesh_stats_handle), GFP_ATOMIC); -- if (!h) { -- nss_warning("Failed to allocate memory for Wi-Fi mesh instance for interface : 0x%x\n", if_num); -- return false; -- } -- -- spin_lock(&nss_wifi_mesh_stats_lock); -- for (idx = 0; idx < NSS_WIFI_MESH_MAX_DYNAMIC_INTERFACE; idx++) { -- if (nss_wifi_mesh_stats_hdl[idx] && nss_wifi_mesh_stats_hdl[idx]->if_num == if_num) { -- spin_unlock(&nss_wifi_mesh_stats_lock); -- nss_warning("Already a handle present for this interface number: 0x%x\n", if_num); -- kfree(h); -- return false; -- } -- } -- -- for (idx = 0; idx < NSS_WIFI_MESH_MAX_DYNAMIC_INTERFACE; idx++) { -- if (nss_wifi_mesh_stats_hdl[idx]) { -- continue; -- } -- -- h->if_num = if_num; -- h->mesh_idx = idx; -- h->ifindex = ifindex; -- nss_wifi_mesh_stats_hdl[idx] = h; -- spin_unlock(&nss_wifi_mesh_stats_lock); -- return true; -- } -- spin_unlock(&nss_wifi_mesh_stats_lock); -- nss_warning("No free index available for handle with ifnum: 0x%x\n", if_num); -- kfree(h); -- return false; --} -- --/* -- * nss_wifi_mesh_stats_handle_free() -- * Free Wi-Fi mesh tunnel handle instance. -- */ --bool nss_wifi_mesh_stats_handle_free(nss_if_num_t if_num) --{ -- struct nss_wifi_mesh_stats_handle *h; -- -- spin_lock(&nss_wifi_mesh_stats_lock); -- h = nss_wifi_mesh_get_stats_handle(if_num); -- if (!h) { -- spin_unlock(&nss_wifi_mesh_stats_lock); -- nss_warning("Unable to free Wi-Fi mesh stats handle instance for interface number: 0x%x\n", if_num); -- return false; -- } -- -- nss_wifi_mesh_stats_hdl[h->mesh_idx] = NULL; -- spin_unlock(&nss_wifi_mesh_stats_lock); -- kfree(h); -- return true; --} -- --/** -- * nss_wifi_mesh_get_stats_handle() -- * Get Wi-Fi mesh stats handle from interface number. -- */ --struct nss_wifi_mesh_stats_handle *nss_wifi_mesh_get_stats_handle(nss_if_num_t if_num) --{ -- uint32_t idx; -- -- assert_spin_locked(&nss_wifi_mesh_stats_lock); -- -- for (idx = 0; idx < NSS_WIFI_MESH_MAX_DYNAMIC_INTERFACE; idx++) { -- if (nss_wifi_mesh_stats_hdl[idx]) { -- if (nss_wifi_mesh_stats_hdl[idx]->if_num == if_num) { -- struct nss_wifi_mesh_stats_handle *h = nss_wifi_mesh_stats_hdl[idx]; -- return h; -- } -- } -- } -- return NULL; --} -- --/* -- * nss_wifi_mesh_get_stats() -- * API for getting stats from a Wi-Fi mesh interface stats -- */ --static bool nss_wifi_mesh_get_stats(nss_if_num_t if_num, struct nss_wifi_mesh_hdl_stats_sync_msg *stats) --{ -- struct nss_wifi_mesh_stats_handle *h; -- -- if (!nss_wifi_mesh_verify_if_num(if_num)) { -- return false; -- } -- -- spin_lock(&nss_wifi_mesh_stats_lock); -- h = nss_wifi_mesh_get_stats_handle(if_num); -- if (!h) { -- spin_unlock(&nss_wifi_mesh_stats_lock); -- nss_warning("Invalid Wi-Fi mesh stats handle for interface number: %d\n", if_num); -- return false; -- } -- -- memcpy(stats, &h->stats, sizeof(*stats)); -- spin_unlock(&nss_wifi_mesh_stats_lock); -- return true; --} -- --/* -- * nss_wifi_mesh_get_valid_interface_count() -- * Get count of valid Wi-Fi mesh interfaces up. -- */ --static uint32_t nss_wifi_mesh_get_valid_interface_count(uint16_t type, uint32_t if_num, uint32_t max_if_num) --{ -- uint32_t interface_count = 0; -- enum nss_dynamic_interface_type dtype; -- -- for (; if_num <= max_if_num; if_num++) { -- if (!nss_is_dynamic_interface(if_num)) { -- continue; -- } -- -- dtype = nss_dynamic_interface_get_type(nss_wifi_mesh_get_context(), if_num); -- -- if ((type == NSS_WIFI_MESH_OUTER_STATS) && (dtype != NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER)) { -- continue; -- } -- -- if ((type == NSS_WIFI_MESH_INNER_STATS) && (dtype != NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER)) { -- continue; -- } -- -- if ((type == NSS_WIFI_MESH_PATH_STATS) && (dtype != NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER)) { -- continue; -- } -- -- if ((type == NSS_WIFI_MESH_PROXY_PATH_STATS) && (dtype != NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER)) { -- continue; -- } -- interface_count++; -- } -- return interface_count; --} -- --/** -- * nss_wifi_mesh_stats_read() -- * Read Wi-Fi Mesh stats. -- */ --static ssize_t nss_wifi_mesh_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos, uint16_t type) --{ -- uint32_t max_output_lines, max_stats; -- size_t size_al, size_wr = 0; -- ssize_t bytes_read = 0; -- struct nss_stats_data *data = fp->private_data; -- int ifindex; -- uint32_t if_num = NSS_DYNAMIC_IF_START; -- uint32_t interface_count = 0; -- uint32_t max_if_num = NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES; -- struct nss_wifi_mesh_hdl_stats_sync_msg *stats; -- struct net_device *ndev; -- struct nss_wifi_mesh_stats_handle *handle; -- char *lbuf; -- enum nss_dynamic_interface_type dtype; -- -- if (data) { -- if_num = data->if_num; -- } -- -- /* -- * If we are done accomodating all the Wi-Fi mesh interfaces. -- */ -- if (if_num > max_if_num) { -- return 0; -- } -- -- /* -- * Get number of Wi-Fi mesh interfaces up. -- */ -- interface_count = nss_wifi_mesh_get_valid_interface_count(type, if_num, max_if_num); -- if (!interface_count) { -- nss_warning("%px: Invalid number of valid interface for if_num: 0x%x\n", data, if_num); -- return 0; -- } -- -- /* -- * max output lines = #stats + Number of Extra outputlines for future reference to add new stats + -- * Maximum node stats + Maximum of all the stats + three blank lines. -- */ -- max_stats = nss_wifi_mesh_max_statistics(); -- max_output_lines = max_stats + NSS_STATS_NODE_MAX + NSS_STATS_EXTRA_OUTPUT_LINES; -- size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines * interface_count; -- -- lbuf = kzalloc(size_al, GFP_KERNEL); -- if (unlikely(lbuf == NULL)) { -- nss_warning("Could not allocate memory for local statistics buffer\n"); -- return 0; -- } -- -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, "wifi_mesh", NSS_STATS_SINGLE_CORE); -- -- stats = kzalloc(sizeof(struct nss_wifi_mesh_hdl_stats_sync_msg), GFP_KERNEL); -- if (!stats) { -- nss_warning("%px: Failed to allocate stats memory for if_num: 0x%x\n", data, if_num); -- kfree(lbuf); -- return 0; -- } -- -- for (; if_num <= max_if_num; if_num++) { -- bool ret; -- -- if (!nss_is_dynamic_interface(if_num)) { -- continue; -- } -- -- dtype = nss_dynamic_interface_get_type(nss_wifi_mesh_get_context(), if_num); -- -- if ((type == NSS_WIFI_MESH_OUTER_STATS) && (dtype != NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER)) { -- continue; -- } -- -- if ((type == NSS_WIFI_MESH_INNER_STATS) && (dtype != NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER)) { -- continue; -- } -- -- if ((type == NSS_WIFI_MESH_PATH_STATS) && (dtype != NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER)) { -- continue; -- } -- -- if ((type == NSS_WIFI_MESH_PROXY_PATH_STATS) && (dtype != NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER)) { -- continue; -- } -- -- /* -- * If Wi-Fi mesh stats handle does not exists, then ret will be false. -- */ -- ret = nss_wifi_mesh_get_stats(if_num, stats); -- if (!ret) { -- continue; -- } -- -- spin_lock(&nss_wifi_mesh_stats_lock); -- handle = nss_wifi_mesh_get_stats_handle(if_num); -- if (!handle) { -- spin_unlock(&nss_wifi_mesh_stats_lock); -- nss_warning("Invalid Wi-Fi mesh stats handle, if_num: %d\n", if_num); -- continue; -- } -- ifindex = handle->ifindex; -- spin_unlock(&nss_wifi_mesh_stats_lock); -- -- ndev = dev_get_by_index(&init_net, ifindex); -- if (!ndev) { -- continue; -- } -- -- size_wr += scnprintf(lbuf + size_wr, size_al - size_wr, "\n%s if_num:%03u\n", -- ndev->name, if_num); -- dev_put(ndev); -- -- /* -- * Read encap stats, path stats, proxy path stats from inner node and decap stats from outer node. -- */ -- switch (type) { -- case NSS_WIFI_MESH_INNER_STATS: -- size_wr += nss_stats_print("wifi_mesh", "encap stats", NSS_STATS_SINGLE_INSTANCE -- , nss_wifi_mesh_strings_encap_stats -- , stats->encap_stats -- , NSS_WIFI_MESH_ENCAP_STATS_TYPE_MAX -- , lbuf, size_wr, size_al); -- break; -- -- case NSS_WIFI_MESH_PATH_STATS: -- size_wr += nss_stats_print("wifi_mesh", "path stats", NSS_STATS_SINGLE_INSTANCE -- , nss_wifi_mesh_strings_path_stats -- , stats->path_stats -- , NSS_WIFI_MESH_PATH_STATS_TYPE_MAX -- , lbuf, size_wr, size_al); -- break; -- -- case NSS_WIFI_MESH_PROXY_PATH_STATS: -- size_wr += nss_stats_print("wifi_mesh", "proxy path stats", NSS_STATS_SINGLE_INSTANCE -- , nss_wifi_mesh_strings_proxy_path_stats -- , stats->proxy_path_stats -- , NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_MAX -- , lbuf, size_wr, size_al); -- break; -- -- case NSS_WIFI_MESH_OUTER_STATS: -- size_wr += nss_stats_print("wifi_mesh", "decap stats", NSS_STATS_SINGLE_INSTANCE -- , nss_wifi_mesh_strings_decap_stats -- , stats->decap_stats -- , NSS_WIFI_MESH_DECAP_STATS_TYPE_MAX -- , lbuf, size_wr, size_al); -- break; -- -- case NSS_WIFI_MESH_EXCEPTION_STATS: -- size_wr += nss_stats_print("wifi_mesh", "exception stats", NSS_STATS_SINGLE_INSTANCE -- , nss_wifi_mesh_strings_exception_stats -- , stats->except_stats -- , NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_MAX -- , lbuf, size_wr, size_al); -- break; -- -- default: -- nss_warning("%px: Invalid stats type: %d\n", stats, type); -- nss_assert(0); -- kfree(stats); -- kfree(lbuf); -- return 0; -- } -- } -- -- bytes_read = simple_read_from_buffer(ubuf, sz, ppos, lbuf, size_wr); -- kfree(stats); -- kfree(lbuf); -- return bytes_read; --} -- --/** -- * nss_wifi_mesh_decap_stats_read() -- * Read Wi-Fi Mesh decap stats. -- */ --static ssize_t nss_wifi_mesh_decap_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_wifi_mesh_stats_read(fp, ubuf, sz, ppos, NSS_WIFI_MESH_OUTER_STATS); --} -- --/** -- * nss_wifi_mesh_encap_stats_read() -- * Read Wi-Fi Mesh encap stats -- */ --static ssize_t nss_wifi_mesh_encap_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_wifi_mesh_stats_read(fp, ubuf, sz, ppos, NSS_WIFI_MESH_INNER_STATS); --} -- --/** -- * nss_wifi_mesh_path_stats_read() -- * Read Wi-Fi Mesh path stats -- */ --static ssize_t nss_wifi_mesh_path_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_wifi_mesh_stats_read(fp, ubuf, sz, ppos, NSS_WIFI_MESH_PATH_STATS); --} -- --/** -- * nss_wifi_mesh_proxy_path_stats_read() -- * Read Wi-Fi Mesh proxy path stats -- */ --static ssize_t nss_wifi_mesh_proxy_path_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_wifi_mesh_stats_read(fp, ubuf, sz, ppos, NSS_WIFI_MESH_PROXY_PATH_STATS); --} -- --/** -- * nss_wifi_mesh_exception_stats_read() -- * Read Wi-Fi Mesh exception stats -- */ --static ssize_t nss_wifi_mesh_exception_stats_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_wifi_mesh_stats_read(fp, ubuf, sz, ppos, NSS_WIFI_MESH_EXCEPTION_STATS); --} -- --/* -- * nss_wifi_mesh_stats_ops -- */ --NSS_STATS_DECLARE_FILE_OPERATIONS(wifi_mesh_encap); --NSS_STATS_DECLARE_FILE_OPERATIONS(wifi_mesh_decap); --NSS_STATS_DECLARE_FILE_OPERATIONS(wifi_mesh_path); --NSS_STATS_DECLARE_FILE_OPERATIONS(wifi_mesh_proxy_path); --NSS_STATS_DECLARE_FILE_OPERATIONS(wifi_mesh_exception); -- --/* -- * nss_wifi_mesh_get_interface_type() -- * Function to get the type of dynamic interface. -- */ --static enum nss_dynamic_interface_type nss_wifi_mesh_get_interface_type(nss_if_num_t if_num) --{ -- struct nss_ctx_instance *nss_ctx = &nss_top_main.nss[nss_top_main.wifi_handler_id]; -- NSS_VERIFY_CTX_MAGIC(nss_ctx); -- return nss_dynamic_interface_get_type(nss_ctx, if_num); --} -- --/* -- * nss_wifi_mesh_update_stats() -- * Update stats for Wi-Fi mesh interface. -- */ --void nss_wifi_mesh_update_stats(nss_if_num_t if_num, struct nss_wifi_mesh_stats_sync_msg *mstats) --{ -- struct nss_wifi_mesh_stats_handle *handle; -- struct nss_wifi_mesh_hdl_stats_sync_msg *stats; -- enum nss_dynamic_interface_type type; -- uint64_t *dst; -- uint32_t *src; -- int i; -- -- spin_lock(&nss_wifi_mesh_stats_lock); -- handle = nss_wifi_mesh_get_stats_handle(if_num); -- if (!handle) { -- spin_unlock(&nss_wifi_mesh_stats_lock); -- nss_warning("Invalid Wi-Fi mesh stats handle, if_num: %d\n", if_num); -- return; -- } -- -- type = nss_wifi_mesh_get_interface_type(handle->if_num);; -- stats = &handle->stats; -- -- switch (type) { -- case NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_INNER: -- /* -- * Update pnode Rx stats. -- */ -- stats->encap_stats[NSS_WIFI_MESH_ENCAP_STATS_TYPE_PNODE_RX_PACKETS] += mstats->pnode_stats.rx_packets; -- stats->encap_stats[NSS_WIFI_MESH_ENCAP_STATS_TYPE_PNODE_RX_BYTES] += mstats->pnode_stats.rx_bytes; -- stats->encap_stats[NSS_WIFI_MESH_ENCAP_STATS_TYPE_PNODE_RX_DROPPED] += nss_cmn_rx_dropped_sum(&mstats->pnode_stats); -- -- /* -- * Update pnode Tx stats. -- */ -- stats->encap_stats[NSS_WIFI_MESH_ENCAP_STATS_TYPE_PNODE_TX_PACKETS] += mstats->pnode_stats.tx_packets; -- stats->encap_stats[NSS_WIFI_MESH_ENCAP_STATS_TYPE_PNODE_TX_BYTES] += mstats->pnode_stats.tx_bytes; -- -- /* -- * Update encap stats. -- */ -- dst = &stats->encap_stats[NSS_WIFI_MESH_ENCAP_STATS_TYPE_EXPIRY_NOTIFY_SENT]; -- src = &mstats->mesh_encap_stats.expiry_notify_sent; -- for (i = NSS_WIFI_MESH_ENCAP_STATS_TYPE_EXPIRY_NOTIFY_SENT; i < NSS_WIFI_MESH_ENCAP_STATS_TYPE_MAX; i++) { -- *dst++ += *src++; -- } -- -- /* -- * Update mesh path stats. -- */ -- dst = &stats->path_stats[NSS_WIFI_MESH_PATH_STATS_TYPE_ALLOC_FAILURES]; -- src = &mstats->mesh_path_stats.alloc_failures; -- for (i = NSS_WIFI_MESH_PATH_STATS_TYPE_ALLOC_FAILURES; i < NSS_WIFI_MESH_PATH_STATS_TYPE_MAX; i++) { -- *dst++ += *src++; -- } -- -- /* -- * Update mesh proxy path stats. -- */ -- dst = &stats->proxy_path_stats[NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_ALLOC_FAILURES]; -- src = &mstats->mesh_proxy_path_stats.alloc_failures; -- for (i = NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_ALLOC_FAILURES; i < NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_MAX; i++) { -- *dst++ += *src++; -- } -- -- /* -- * Update exception stats. -- */ -- dst = &stats->except_stats[NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_PACKETS_SUCCESS]; -- src = &mstats->mesh_except_stats.packets_success; -- for (i = NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_PACKETS_SUCCESS; i < NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_MAX; i++) { -- *dst++ += *src++; -- } -- spin_unlock(&nss_wifi_mesh_stats_lock); -- break; -- -- case NSS_DYNAMIC_INTERFACE_TYPE_WIFI_MESH_OUTER: -- /* -- * Update pnode Rx stats. -- */ -- stats->decap_stats[NSS_WIFI_MESH_DECAP_STATS_TYPE_PNODE_RX_PACKETS] += mstats->pnode_stats.rx_packets; -- stats->decap_stats[NSS_WIFI_MESH_DECAP_STATS_TYPE_PNODE_RX_BYTES] += mstats->pnode_stats.rx_bytes; -- stats->decap_stats[NSS_WIFI_MESH_DECAP_STATS_TYPE_PNODE_RX_DROPPED] += nss_cmn_rx_dropped_sum(&mstats->pnode_stats); -- -- /* -- * Update pnode Tx stats. -- */ -- stats->decap_stats[NSS_WIFI_MESH_DECAP_STATS_TYPE_PNODE_TX_PACKETS] += mstats->pnode_stats.tx_packets; -- stats->decap_stats[NSS_WIFI_MESH_DECAP_STATS_TYPE_PNODE_TX_BYTES] += mstats->pnode_stats.tx_bytes; -- -- /* -- * Update decap stats. -- */ -- dst = &stats->decap_stats[NSS_WIFI_MESH_DECAP_STATS_TYPE_PATH_REFRESH_SENT]; -- src = &mstats->mesh_decap_stats.path_refresh_sent; -- for (i = NSS_WIFI_MESH_DECAP_STATS_TYPE_PATH_REFRESH_SENT; i < NSS_WIFI_MESH_DECAP_STATS_TYPE_MAX; i++) { -- *dst++ += *src++; -- } -- spin_unlock(&nss_wifi_mesh_stats_lock); -- break; -- -- default: -- spin_unlock(&nss_wifi_mesh_stats_lock); -- nss_warning("%px: Received invalid dynamic interface type: %d\n", handle, type); -- nss_assert(0); -- } --} -- --/* -- * nss_wifi_mesh_stats_notify() -- * Sends notifications to the registered modules. -- * -- * Leverage NSS-FW statistics timing to update Netlink. -- */ --void nss_wifi_mesh_stats_notify(nss_if_num_t if_num, uint32_t core_id) --{ -- struct nss_wifi_mesh_stats_notification wifi_mesh_stats; -- -- if (!nss_wifi_mesh_get_stats(if_num, &wifi_mesh_stats.stats)) { -- nss_warning("No handle is present with ifnum: 0x%x\n", if_num); -- return; -- } -- -- wifi_mesh_stats.core_id = core_id; -- wifi_mesh_stats.if_num = if_num; -- atomic_notifier_call_chain(&nss_wifi_mesh_stats_notifier, NSS_STATS_EVENT_NOTIFY, (void *)&wifi_mesh_stats); --} -- --/* -- * nss_wifi_mesh_stats_dentry_create() -- * Create Wi-Fi Mesh statistics debug entry -- */ --struct dentry *nss_wifi_mesh_stats_dentry_create(void) --{ -- struct dentry *stats_dentry_dir; -- struct dentry *stats_file; -- char dir_name[NSS_WIFI_MESH_DENTRY_FILE_SIZE] = {0}; -- -- if (!nss_top_main.stats_dentry) { -- nss_warning("qca-nss-drv/stats is not present\n"); -- return NULL; -- } -- -- snprintf(dir_name, sizeof(dir_name), "wifi_mesh"); -- -- stats_dentry_dir = debugfs_create_dir(dir_name, nss_top_main.stats_dentry); -- if (!stats_dentry_dir) { -- nss_warning("Failed to create qca-nss-drv/stats/wifi_mesh directory\n"); -- return NULL; -- } -- -- stats_file = debugfs_create_file("encap_stats", 0400, stats_dentry_dir, &nss_top_main, &nss_wifi_mesh_encap_stats_ops); -- if (!stats_file) { -- nss_warning("Failed to create qca-nss-drv/stats/wifi_mesh/encap_stats file\n"); -- goto fail; -- } -- -- stats_file = debugfs_create_file("decap_stats", 0400, stats_dentry_dir, &nss_top_main, &nss_wifi_mesh_decap_stats_ops); -- if (!stats_file) { -- nss_warning("Failed to create qca-nss-drv/stats/wifi_mesh/decap_stats file\n"); -- goto fail; -- } -- -- stats_file = debugfs_create_file("path_stats", 0400, stats_dentry_dir, &nss_top_main, &nss_wifi_mesh_path_stats_ops); -- if (!stats_file) { -- nss_warning("Failed to create qca-nss-drv/stats/wifi_mesh/path_stats file\n"); -- goto fail; -- } -- -- stats_file = debugfs_create_file("proxy_path_stats", 0400, stats_dentry_dir, &nss_top_main, &nss_wifi_mesh_proxy_path_stats_ops); -- if (!stats_file) { -- nss_warning("Failed to create qca-nss-drv/stats/wifi_mesh/proxy_path_stats file\n"); -- goto fail; -- } -- stats_file = debugfs_create_file("exception_stats", 0400, stats_dentry_dir, &nss_top_main, &nss_wifi_mesh_exception_stats_ops); -- if (!stats_file) { -- nss_warning("Failed to create qca-nss-drv/stats/wifi_mesh/exception_stats file\n"); -- goto fail; -- } -- return stats_dentry_dir; --fail: -- debugfs_remove_recursive(stats_dentry_dir); -- return NULL; --} -- --/** -- * nss_wifi_mesh_stats_register_notifier() -- * Registers statistics notifier. -- */ --int nss_wifi_mesh_stats_register_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_register(&nss_wifi_mesh_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_wifi_mesh_stats_register_notifier); -- --/** -- * nss_wifi_mesh_stats_unregister_notifier() -- * Deregisters statistics notifier. -- */ --int nss_wifi_mesh_stats_unregister_notifier(struct notifier_block *nb) --{ -- return atomic_notifier_chain_unregister(&nss_wifi_mesh_stats_notifier, nb); --} --EXPORT_SYMBOL(nss_wifi_mesh_stats_unregister_notifier); ---- a/nss_wifi_mesh_stats.h -+++ /dev/null -@@ -1,42 +0,0 @@ --/* -- ************************************************************************** -- * 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. -- ************************************************************************** -- */ -- --#ifndef __NSS_WIFI_MESH_STATS_H__ --#define __NSS_WIFI_MESH_STATS_H__ -- --/** -- * Array of pointer for NSS Wi-Fi mesh handles. -- * Each handle has per-tunnel statistics based on the interface number which is an index. -- */ --struct nss_wifi_mesh_stats_handle { -- nss_if_num_t if_num; /**< Interface number. */ -- uint32_t ifindex; /**< Netdev index. */ -- uint32_t mesh_idx; /**< Mesh index. */ -- struct nss_wifi_mesh_hdl_stats_sync_msg stats; /**< Stats per-interface number. */ --}; -- --/* -- * Wi-Fi Mesh statistics APIs -- */ --extern void nss_wifi_mesh_update_stats(nss_if_num_t if_num, struct nss_wifi_mesh_stats_sync_msg *mstats); --extern void nss_wifi_mesh_stats_notify(nss_if_num_t if_num, uint32_t core_id); --extern struct dentry *nss_wifi_mesh_stats_dentry_create(void); --extern struct nss_wifi_mesh_stats_handle *nss_wifi_mesh_get_stats_handle(nss_if_num_t if_num); --extern bool nss_wifi_mesh_stats_handle_alloc(nss_if_num_t if_num, int32_t ifindex); --extern bool nss_wifi_mesh_stats_handle_free(nss_if_num_t if_num); --#endif /* __NSS_WIFI_MESH_STATS_H__ */ ---- a/nss_wifi_mesh_strings.c -+++ /dev/null -@@ -1,284 +0,0 @@ --/* -- ************************************************************************** -- * 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 --#include "nss_wifi_mesh_stats.h" --#include "nss_strings.h" --#include "nss_wifi_mesh_strings.h" -- --/* -- * nss_wifi_mesh_strings_encap_stats -- * Wi-Fi mesh encap statistics string. -- */ --struct nss_stats_info nss_wifi_mesh_strings_encap_stats[NSS_WIFI_MESH_ENCAP_STATS_TYPE_MAX] = { -- {"rx_packets", NSS_STATS_TYPE_COMMON}, -- {"rx_bytes", NSS_STATS_TYPE_COMMON}, -- {"tx_packets", NSS_STATS_TYPE_COMMON}, -- {"tx_bytes", NSS_STATS_TYPE_COMMON}, -- {"rx_dropped", NSS_STATS_TYPE_COMMON}, -- {"expiry_notify_sent", NSS_STATS_TYPE_SPECIAL}, -- {"mc_count", NSS_STATS_TYPE_SPECIAL}, -- {"mp_not_found", NSS_STATS_TYPE_SPECIAL}, -- {"mp_active", NSS_STATS_TYPE_SPECIAL}, -- {"mpp_not_found", NSS_STATS_TYPE_SPECIAL}, -- {"mpp_found", NSS_STATS_TYPE_SPECIAL}, -- {"encap_hdr_fail", NSS_STATS_TYPE_SPECIAL}, -- {"mp_del_notify_fail", NSS_STATS_TYPE_SPECIAL}, -- {"link_enqueue", NSS_STATS_TYPE_SPECIAL}, -- {"link_enq_fail", NSS_STATS_TYPE_SPECIAL}, -- {"ra_lup_fail", NSS_STATS_TYPE_SPECIAL}, -- {"dummy_add_count", NSS_STATS_TYPE_SPECIAL}, -- {"encap_mp_add_notify_fail", NSS_STATS_TYPE_SPECIAL}, -- {"dummy_add_fail", NSS_STATS_TYPE_SPECIAL}, -- {"dummy_lup_fail", NSS_STATS_TYPE_SPECIAL}, -- {"send_to_host_failed", NSS_STATS_TYPE_SPECIAL}, -- {"sent_to_host", NSS_STATS_TYPE_SPECIAL}, -- {"expiry_notify_fail", NSS_STATS_TYPE_SPECIAL}, -- {"no_headroom", NSS_STATS_TYPE_SPECIAL}, -- {"path_refresh_sent", NSS_STATS_TYPE_SPECIAL}, -- {"linearise_failed", NSS_STATS_TYPE_SPECIAL}, -- {"mp_exc_event_rl_dropped", NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_wifi_mesh_encap_strings_read() -- * Read Wi-Fi mesh encap statistics names. -- */ --static ssize_t nss_wifi_mesh_encap_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_wifi_mesh_strings_encap_stats, NSS_WIFI_MESH_ENCAP_STATS_TYPE_MAX); --} -- --/* -- * nss_wifi_mesh_strings_path_stats -- * Wi-Fi mesh path statistics string. -- */ --struct nss_stats_info nss_wifi_mesh_strings_path_stats[NSS_WIFI_MESH_PATH_STATS_TYPE_MAX] = { -- {"alloc_failures", NSS_STATS_TYPE_SPECIAL}, -- {"error_max_radio_count", NSS_STATS_TYPE_SPECIAL}, -- {"invalid_interface_failures", NSS_STATS_TYPE_SPECIAL}, -- {"add_success", NSS_STATS_TYPE_SPECIAL}, -- {"table_full_errors", NSS_STATS_TYPE_SPECIAL}, -- {"insert_failures", NSS_STATS_TYPE_SPECIAL}, -- {"not_found", NSS_STATS_TYPE_SPECIAL}, -- {"delete_success", NSS_STATS_TYPE_SPECIAL}, -- {"update_success", NSS_STATS_TYPE_SPECIAL}, -- {"mesh_path_expired", NSS_STATS_TYPE_SPECIAL}, -- {"mesh_path_refresh_needed", NSS_STATS_TYPE_SPECIAL}, -- {"add_requests", NSS_STATS_TYPE_SPECIAL}, -- {"del_requests", NSS_STATS_TYPE_SPECIAL}, -- {"update_requests", NSS_STATS_TYPE_SPECIAL}, -- {"next_hop_updations", NSS_STATS_TYPE_SPECIAL}, -- {"hop_count_updations", NSS_STATS_TYPE_SPECIAL}, -- {"flag_updations", NSS_STATS_TYPE_SPECIAL}, -- {"metric_updations", NSS_STATS_TYPE_SPECIAL}, -- {"block_mesh_fwd_updations", NSS_STATS_TYPE_SPECIAL}, -- {"delete_failures", NSS_STATS_TYPE_SPECIAL}, -- {"mesh_path_dummy_add_failures",NSS_STATS_TYPE_SPECIAL}, -- {"mesh_path_dummy_add_success", NSS_STATS_TYPE_SPECIAL} -- --}; -- --/* -- * nss_wifi_mesh_path_strings_read() -- * Read Wi-Fi mesh path statistics names. -- */ --static ssize_t nss_wifi_mesh_path_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_wifi_mesh_strings_path_stats, NSS_WIFI_MESH_PATH_STATS_TYPE_MAX); --} -- --/* -- * nss_wifi_mesh_strings_proxy_path_stats -- * Wi-Fi mesh proxy path statistics string. -- */ --struct nss_stats_info nss_wifi_mesh_strings_proxy_path_stats[NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_MAX] = { -- {"alloc_failures", NSS_STATS_TYPE_SPECIAL}, -- {"entry_exist_failures", NSS_STATS_TYPE_SPECIAL}, -- {"add_success", NSS_STATS_TYPE_SPECIAL}, -- {"table_full_errors", NSS_STATS_TYPE_SPECIAL}, -- {"insert_failures", NSS_STATS_TYPE_SPECIAL}, -- {"not_found", NSS_STATS_TYPE_SPECIAL}, -- {"unhashed_errors", NSS_STATS_TYPE_SPECIAL}, -- {"delete_failures", NSS_STATS_TYPE_SPECIAL}, -- {"delete_success", NSS_STATS_TYPE_SPECIAL}, -- {"update_success", NSS_STATS_TYPE_SPECIAL}, -- {"lookup_success", NSS_STATS_TYPE_SPECIAL}, -- {"add_requests", NSS_STATS_TYPE_SPECIAL}, -- {"del_requests", NSS_STATS_TYPE_SPECIAL}, -- {"update_requests", NSS_STATS_TYPE_SPECIAL}, -- {"mda_updations", NSS_STATS_TYPE_SPECIAL}, -- {"flag_updations", NSS_STATS_TYPE_SPECIAL}, -- {"mesh_proxy_path_dummy_lookup_success", NSS_STATS_TYPE_SPECIAL}, -- {"mesh_proxy_path_dummy_lookup_failures", NSS_STATS_TYPE_SPECIAL}, -- {"mesh_proxy_path_dummy_add_failures", NSS_STATS_TYPE_SPECIAL}, -- {"mesh_proxy_path_dummy_add_success", NSS_STATS_TYPE_SPECIAL} --}; -- --/* -- * nss_wifi_mesh_proxy_path_strings_read() -- * Read Wi-Fi mesh proxy path statistics names. -- */ --static ssize_t nss_wifi_mesh_proxy_path_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_wifi_mesh_strings_proxy_path_stats, NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_MAX); --} -- --/* -- * nss_wifi_mesh_strings_decap_stats -- * Wi-Fi mesh decap statistics string. -- */ --struct nss_stats_info nss_wifi_mesh_strings_decap_stats[NSS_WIFI_MESH_DECAP_STATS_TYPE_MAX] = { -- {"rx_packets", NSS_STATS_TYPE_COMMON}, -- {"rx_bytes", NSS_STATS_TYPE_COMMON}, -- {"tx_packets", NSS_STATS_TYPE_COMMON}, -- {"tx_bytes", NSS_STATS_TYPE_COMMON}, -- {"rx_dropped", NSS_STATS_TYPE_COMMON}, -- {"path_refresh_sent", NSS_STATS_TYPE_SPECIAL}, -- {"reserved", NSS_STATS_TYPE_SPECIAL}, -- {"mc_drop", NSS_STATS_TYPE_DROP}, -- {"ttl_0", NSS_STATS_TYPE_SPECIAL}, -- {"mpp_lup_fail", NSS_STATS_TYPE_SPECIAL}, -- {"decap_hdr_fail", NSS_STATS_TYPE_SPECIAL}, -- {"rx_fwd_fail", NSS_STATS_TYPE_SPECIAL}, -- {"rx_fwd_success", NSS_STATS_TYPE_SPECIAL}, -- {"mp_fwd_lookup_fail", NSS_STATS_TYPE_SPECIAL}, -- {"mp_fwd_inactive", NSS_STATS_TYPE_SPECIAL}, -- {"nxt_mnode_fwd_success", NSS_STATS_TYPE_SPECIAL}, -- {"nxt_mnode_fwd_fail", NSS_STATS_TYPE_SPECIAL}, -- {"mpp_add_fail", NSS_STATS_TYPE_SPECIAL}, -- {"mpp_add_event2host_fail", NSS_STATS_TYPE_SPECIAL}, -- {"mpp_upate_fail", NSS_STATS_TYPE_SPECIAL}, -- {"mpp_update_even2host_fail", NSS_STATS_TYPE_SPECIAL}, -- {"mpp_learn2host_fail", NSS_STATS_TYPE_SPECIAL}, -- {"block_mesh_fwd_packets", NSS_STATS_TYPE_SPECIAL}, -- {"no_headroom", NSS_STATS_TYPE_SPECIAL}, -- {"linearise_failed", NSS_STATS_TYPE_SPECIAL}, -- {"mpp_learn_event_rl_dropped", NSS_STATS_TYPE_DROP}, -- {"mp_missging_event_rl_dropped", NSS_STATS_TYPE_DROP} --}; -- --/* -- * nss_wifi_mesh_decap_strings_read() -- * Read Wi-Fi mesh decap statistics names. -- */ --static ssize_t nss_wifi_mesh_decap_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_wifi_mesh_strings_decap_stats, NSS_WIFI_MESH_DECAP_STATS_TYPE_MAX); --} -- --/* -- * nss_wifi_mesh_strings_exception_stats -- * Wi-Fi mesh exception statistics string. -- */ --struct nss_stats_info nss_wifi_mesh_strings_exception_stats[NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_MAX] = { -- {"packets_success", NSS_STATS_TYPE_SPECIAL}, -- {"packets_failure", NSS_STATS_TYPE_DROP} --}; -- --/* -- * nss_wifi_mesh_exception_strings_read() -- * Read Wi-Fi mesh exception statistics names. -- */ --static ssize_t nss_wifi_mesh_exception_stats_strings_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos) --{ -- return nss_strings_print(ubuf, sz, ppos, nss_wifi_mesh_strings_exception_stats, NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_MAX); --} -- --/* -- * nss_wifi_mesh_decap_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifi_mesh_decap_stats); -- --/* -- * nss_wifi_mesh_encap_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifi_mesh_encap_stats); -- --/* -- * nss_wifi_mesh_path_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifi_mesh_path_stats); -- --/* -- * nss_wifi_mesh_proxy_path_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifi_mesh_proxy_path_stats); -- --/* -- * nss_wifi_mesh_exception_strings_ops -- */ --NSS_STRINGS_DECLARE_FILE_OPERATIONS(wifi_mesh_exception_stats); -- --/* -- * nss_wifi_mesh_strings_dentry_create() -- * Create Wi-Fi mesh statistics strings debug entry. -- */ --struct dentry *nss_wifi_mesh_strings_dentry_create(void) --{ -- struct dentry *str_dentry_dir; -- struct dentry *str_file; -- -- if (!nss_top_main.strings_dentry) { -- nss_warning("qca-nss-drv/strings is not present\n"); -- return NULL; -- } -- -- str_dentry_dir = debugfs_create_dir("wifi_mesh", nss_top_main.strings_dentry); -- if (!str_dentry_dir) { -- nss_warning("Failed to create qca-nss-drv/string/wifi_mesh directory\n"); -- return NULL; -- } -- -- str_file = debugfs_create_file("encap_stats", 0400, str_dentry_dir, &nss_top_main, &nss_wifi_mesh_encap_stats_strings_ops); -- if (!str_file) { -- nss_warning("Failed to create qca-nss-drv/string/wifi_mesh/encap_stats file\n"); -- goto fail; -- } -- -- str_file = debugfs_create_file("decap_stats", 0400, str_dentry_dir, &nss_top_main, &nss_wifi_mesh_decap_stats_strings_ops); -- if (!str_file) { -- nss_warning("Failed to create qca-nss-drv/string/wifi_mesh/decap_stats file\n"); -- goto fail; -- } -- -- str_file = debugfs_create_file("path_stats", 0400, str_dentry_dir, &nss_top_main, &nss_wifi_mesh_path_stats_strings_ops); -- if (!str_file) { -- nss_warning("Failed to create qca-nss-drv/string/wifi_mesh/path_stats file\n"); -- goto fail; -- } -- -- str_file = debugfs_create_file("proxy_path_stats", 0400, str_dentry_dir, &nss_top_main, &nss_wifi_mesh_proxy_path_stats_strings_ops); -- if (!str_file) { -- nss_warning("Failed to create qca-nss-drv/string/wifi_mesh/proxy_path_stats file\n"); -- goto fail; -- } -- -- str_file = debugfs_create_file("exception_stats", 0400, str_dentry_dir, &nss_top_main, &nss_wifi_mesh_exception_stats_strings_ops); -- if (!str_file) { -- nss_warning("Failed to create qca-nss-drv/string/wifi_mesh/exception_stats file\n"); -- goto fail; -- } -- -- return str_dentry_dir; --fail: -- debugfs_remove_recursive(str_dentry_dir); -- return NULL; --} ---- a/nss_wifi_mesh_strings.h -+++ /dev/null -@@ -1,32 +0,0 @@ --/* -- ************************************************************************** -- * 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. -- ************************************************************************** -- */ -- --#ifndef __NSS_WIFI_MESH_STRINGS_H --#define __NSS_WIFI_MESH_STRINGS_H -- --#include "nss_wifi_mesh_stats.h" --#include "nss_strings.h" -- --extern struct nss_stats_info nss_wifi_mesh_strings_encap_stats[NSS_WIFI_MESH_ENCAP_STATS_TYPE_MAX]; --extern struct nss_stats_info nss_wifi_mesh_strings_decap_stats[NSS_WIFI_MESH_DECAP_STATS_TYPE_MAX]; --extern struct nss_stats_info nss_wifi_mesh_strings_path_stats[NSS_WIFI_MESH_PATH_STATS_TYPE_MAX]; --extern struct nss_stats_info nss_wifi_mesh_strings_proxy_path_stats[NSS_WIFI_MESH_PROXY_PATH_STATS_TYPE_MAX]; --extern struct nss_stats_info nss_wifi_mesh_strings_exception_stats[NSS_WIFI_MESH_EXCEPTION_STATS_TYPE_MAX]; --extern struct dentry *nss_wifi_mesh_strings_dentry_create(void); -- --#endif /* __NSS_WIFI_MESH_STRINGS_H */ ---- a/nss_wifi_stats.c -+++ b/nss_wifi_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2016-2017, 2019-2021 The Linux Foundation. All rights reserved. -+ * Copyright (c) 2016-2017, 2019-2020 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. -@@ -86,8 +86,7 @@ struct nss_stats_info nss_wifi_stats_str - {"rx_htt_fetch_cnt" , NSS_STATS_TYPE_SPECIAL}, - {"total_tidq_bypass_cnt" , NSS_STATS_TYPE_SPECIAL}, - {"global_q_full_cnt" , NSS_STATS_TYPE_SPECIAL}, -- {"tidq_full_cnt" , NSS_STATS_TYPE_SPECIAL}, -- {"peer_unauth_rx_pkt_drop" , NSS_STATS_TYPE_DROP} -+ {"tidq_full_cnt" , NSS_STATS_TYPE_SPECIAL} + enum nss_n2h_stats_types { + NSS_N2H_STATS_QUEUE_DROPPED = NSS_STATS_NODE_MAX, +- /**< Number of packets dropped because the exception queue is too full. */ +- NSS_N2H_STATS_TOTAL_TICKS, /**< Total clock ticks spend inside the N2H. */ +- NSS_N2H_STATS_WORST_CASE_TICKS, /**< Worst case iteration of the exception path in ticks. */ +- NSS_N2H_STATS_ITERATIONS, /**< Number of iterations around the N2H. */ +- NSS_N2H_STATS_PBUF_OCM_TOTAL_COUNT, /**< Number of pbuf OCM total count. */ +- NSS_N2H_STATS_PBUF_OCM_FREE_COUNT, /**< Number of pbuf OCM free count. */ ++ /* Number of packets dropped because the exception queue is too full */ ++ NSS_N2H_STATS_TOTAL_TICKS, /* Total clock ticks spend inside the N2H */ ++ NSS_N2H_STATS_WORST_CASE_TICKS, /* Worst case iteration of the exception path in ticks */ ++ NSS_N2H_STATS_ITERATIONS, /* Number of iterations around the N2H */ ++ + NSS_N2H_STATS_PBUF_OCM_ALLOC_FAILS_WITH_PAYLOAD, +- /**< Number of pbuf OCM allocations that have failed with payload. */ ++ /* Number of pbuf ocm allocations that have failed with payload */ ++ NSS_N2H_STATS_PBUF_OCM_FREE_COUNT, /* Number of pbuf ocm free count */ ++ NSS_N2H_STATS_PBUF_OCM_TOTAL_COUNT, /* Number of pbuf ocm total count */ + NSS_N2H_STATS_PBUF_OCM_ALLOC_FAILS_NO_PAYLOAD, +- /**< Number of pbuf OCM allocations that have failed without payload. */ +- NSS_N2H_STATS_PBUF_DEFAULT_TOTAL_COUNT, /**< Number of pbuf default total count. */ +- NSS_N2H_STATS_PBUF_DEFAULT_FREE_COUNT, /**< Number of pbuf default free count. */ ++ /* Number of pbuf ocm allocations that have failed without payload */ ++ + NSS_N2H_STATS_PBUF_DEFAULT_ALLOC_FAILS_WITH_PAYLOAD, +- /**< Number of pbuf default allocations that have failed with payload. */ ++ /* Number of pbuf default allocations that have failed with payload */ ++ ++ NSS_N2H_STATS_PBUF_DEFAULT_FREE_COUNT, /* Number of pbuf default free count */ ++ NSS_N2H_STATS_PBUF_DEFAULT_TOTAL_COUNT, /* Number of pbuf default total count */ + NSS_N2H_STATS_PBUF_DEFAULT_ALLOC_FAILS_NO_PAYLOAD, +- /**< Number of pbuf default allocations that have failed without payload. */ ++ /* Number of pbuf default allocations that have failed without payload */ ++ ++ NSS_N2H_STATS_PAYLOAD_ALLOC_FAILS, /* Number of pbuf allocations that have failed because there were no free payloads */ ++ NSS_N2H_STATS_PAYLOAD_FREE_COUNT, /* Number of free payloads that exist */ + +- NSS_N2H_STATS_PAYLOAD_ALLOC_FAILS, /**< Number of pbuf allocations that have failed because there were no free payloads. */ +- NSS_N2H_STATS_PAYLOAD_FREE_COUNT, /**< Number of free payloads that exist. */ ++ NSS_N2H_STATS_H2N_CONTROL_PACKETS, /* Control packets received from HLOS */ ++ NSS_N2H_STATS_H2N_CONTROL_BYTES, /* Control bytes received from HLOS */ ++ NSS_N2H_STATS_N2H_CONTROL_PACKETS, /* Control packets sent to HLOS */ ++ NSS_N2H_STATS_N2H_CONTROL_BYTES, /* Control bytes sent to HLOS */ + +- NSS_N2H_STATS_H2N_CONTROL_PACKETS, /**< Control packets received from HLOS. */ +- NSS_N2H_STATS_H2N_CONTROL_BYTES, /**< Control bytes received from HLOS. */ +- NSS_N2H_STATS_N2H_CONTROL_PACKETS, /**< Control packets sent to HLOS. */ +- NSS_N2H_STATS_N2H_CONTROL_BYTES, /**< Control bytes sent to HLOS. */ +- +- NSS_N2H_STATS_H2N_DATA_PACKETS, /**< Data packets received from HLOS. */ +- NSS_N2H_STATS_H2N_DATA_BYTES, /**< Data bytes received from HLOS. */ +- NSS_N2H_STATS_N2H_DATA_PACKETS, /**< Data packets sent to HLOS. */ +- NSS_N2H_STATS_N2H_DATA_BYTES, /**< Data bytes sent to HLOS. */ +- NSS_N2H_STATS_N2H_TOT_PAYLOADS, /**< Number of payloads in NSS. */ +- NSS_N2H_STATS_N2H_INTERFACE_INVALID, /**< Number of bad interface access. */ +- NSS_N2H_STATS_ENQUEUE_RETRIES, /**< Number of enqueue retries by N2H. */ ++ NSS_N2H_STATS_H2N_DATA_PACKETS, /* Data packets received from HLOS */ ++ NSS_N2H_STATS_H2N_DATA_BYTES, /* Data bytes received from HLOS */ ++ NSS_N2H_STATS_N2H_DATA_PACKETS, /* Data packets sent to HLOS */ ++ NSS_N2H_STATS_N2H_DATA_BYTES, /* Data bytes sent to HLOS */ ++ NSS_N2H_STATS_N2H_TOT_PAYLOADS, /* No. of payloads in NSS */ ++ NSS_N2H_STATS_N2H_INTERFACE_INVALID, /* No. of bad interface access */ ++ NSS_N2H_STATS_ENQUEUE_RETRIES, /* No. of enqueue retries by N2H */ + +- NSS_N2H_STATS_MAX, /**< Maximum message type. */ ++ NSS_N2H_STATS_MAX, }; - uint64_t nss_wifi_stats[NSS_MAX_WIFI_RADIO_INTERFACES][NSS_WIFI_STATS_MAX]; /* WIFI statistics */ -@@ -209,7 +208,6 @@ void nss_wifi_stats_sync(struct nss_ctx_ - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TOTAL_TIDQ_BYPASS_CNT] += stats->total_tidq_bypass_cnt; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_GLOBAL_Q_FULL_CNT] += stats->global_q_full_cnt; - nss_wifi_stats[radio_id][NSS_WIFI_STATS_TIDQ_FULL_CNT] += stats->tidq_full_cnt; -- nss_wifi_stats[radio_id][NSS_WIFI_STATS_UNATH_RX_PKT_DROP] += stats->peer_unauth_rx_pkt_drop; - - spin_unlock_bh(&nss_top->stats_lock); - } ---- a/nss_wifi_stats.h -+++ b/nss_wifi_stats.h -@@ -50,7 +50,6 @@ enum nss_wifi_stats_types { - NSS_WIFI_STATS_TOTAL_TIDQ_BYPASS_CNT, - NSS_WIFI_STATS_GLOBAL_Q_FULL_CNT, - NSS_WIFI_STATS_TIDQ_FULL_CNT, -- NSS_WIFI_STATS_UNATH_RX_PKT_DROP, - NSS_WIFI_STATS_MAX, - }; - ---- a/nss_wifi_vdev.c -+++ b/nss_wifi_vdev.c -@@ -199,16 +199,8 @@ EXPORT_SYMBOL(nss_wifi_vdev_tx_msg_ext); - */ - nss_tx_status_t nss_wifi_vdev_tx_buf(struct nss_ctx_instance *nss_ctx, struct sk_buff *os_buf, uint32_t if_num) - { -- enum nss_dynamic_interface_type if_type; -- - BUG_ON(((if_num < NSS_DYNAMIC_IF_START) || (if_num >= (NSS_DYNAMIC_IF_START + NSS_MAX_DYNAMIC_INTERFACES)))); - -- if_type = nss_dynamic_interface_get_type(nss_ctx, if_num); -- if (if_type != NSS_DYNAMIC_INTERFACE_TYPE_VAP) { -- nss_warning("%px: non vap %d packet tx not allowed", nss_ctx, if_num); -- return NSS_TX_FAILURE_NOT_SUPPORTED; -- } -- - return nss_core_send_packet(nss_ctx, os_buf, if_num, H2N_BIT_FLAG_BUFFER_REUSABLE); - } - EXPORT_SYMBOL(nss_wifi_vdev_tx_buf); ---- a/nss_wifili.c -+++ b/nss_wifili.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2020, 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. -@@ -20,56 +20,6 @@ - #include "nss_wifili_strings.h" - - #define NSS_WIFILI_TX_TIMEOUT 1000 /* Millisecond to jiffies*/ --#define NSS_WIFILI_INVALID_SCHEME_ID -1 --#define NSS_WIFILI_THREAD_SCHEME_ENTRY_MAX 4 /* Maximum number of thread scheme entries. */ --#define NSS_WIFILI_EXTERNAL_INTERFACE_MAX 2 /* Maximum external I/F supported */ -- --/* -- * NSS external interface number table -- */ --nss_if_num_t nss_wifili_external_tbl[NSS_WIFILI_EXTERNAL_INTERFACE_MAX] = -- {NSS_WIFILI_EXTERNAL_INTERFACE0, NSS_WIFILI_EXTERNAL_INTERFACE1}; -- --/* -- * nss_wifili_thread_scheme_entry -- * Details of thread scheme. -- */ --struct nss_wifili_thread_scheme_entry { -- int32_t radio_ifnum; /* Radio interface number. */ -- uint32_t radio_priority; /* Priority of radio. */ -- uint32_t scheme_priority; /* Priority of scheme. */ -- uint8_t scheme_index; /* Scheme index allocated to radio. */ -- bool allocated; /* Flag to check if scheme is allocated. */ --}; -- --/* -- * nss_wifili_thread_scheme_db -- * Wifili thread scheme database. -- */ --struct nss_wifili_thread_scheme_db { -- spinlock_t lock; /* Lock to protect from simultaneous access. */ -- uint32_t radio_count; /* Radio counter. */ -- struct nss_wifili_thread_scheme_entry nwtse[NSS_WIFILI_THREAD_SCHEME_ENTRY_MAX]; -- /* Metadata for each of scheme. */ --}; -- --/* -- * nss_wifili_external_if_state_tbl -- * External interface state table -- */ --struct nss_wifili_external_if_state_tbl { -- nss_if_num_t ifnum; -- bool in_use; --}; -- --/* -- * nss_wifili_external_if_info -- * Wifili external interface info -- */ --struct nss_wifili_external_if_info { -- spinlock_t lock; -- struct nss_wifili_external_if_state_tbl state_tbl[NSS_WIFILI_EXTERNAL_INTERFACE_MAX]; --} nss_wifi_eif_info; - - /* - * nss_wifili_pvt -@@ -84,11 +34,6 @@ static struct nss_wifili_pvt { - } wifili_pvt; - - /* -- * Scheme to radio mapping database -- */ --static struct nss_wifili_thread_scheme_db ts_db[NSS_MAX_CORES]; -- --/* - * nss_wifili_handler() - * Handle NSS -> HLOS messages for wifi - */ -@@ -105,8 +50,11 @@ static void nss_wifili_handler(struct ns - */ - BUG_ON((nss_is_dynamic_interface(ncm->interface)) - || ((ncm->interface != NSS_WIFILI_INTERNAL_INTERFACE) + /** +--- a/nss_ipv4_strings.c ++++ b/nss_ipv4_strings.c +@@ -106,8 +106,10 @@ struct nss_stats_info nss_ipv4_strings_e + {"mc_pbuf_alloc_failure" , NSS_STATS_TYPE_EXCEPTION}, + {"pppoe_bridge_no_icme" , NSS_STATS_TYPE_EXCEPTION}, + {"pppoe_no_session" , NSS_STATS_TYPE_DROP}, +#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE0) -- && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE1))); -+ && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE1) + {"icmp_ipv4_gre_hdr_incomplete" , NSS_STATS_TYPE_EXCEPTION}, + {"icmp_ipv4_esp_hdr_incomplete" , NSS_STATS_TYPE_EXCEPTION}, +#endif -+ )); + }; - /* - * Trace messages. -@@ -122,9 +70,7 @@ static void nss_wifili_handler(struct ns - } - - if ((nss_cmn_get_msg_len(ncm) > sizeof(struct nss_wifili_msg)) && -- ntm->cm.type != NSS_WIFILI_PEER_EXT_STATS_MSG && -- ntm->cm.type != NSS_WIFILI_ASTENTRY_SYNC_MSG && -- ntm->cm.type != NSS_WIFILI_MECENTRY_SYNC_MSG) { -+ ntm->cm.type != NSS_WIFILI_PEER_EXT_STATS_MSG) { - nss_warning("%px: Length of message is greater than required: %d", nss_ctx, nss_cmn_get_msg_len(ncm)); - return; - } -@@ -229,8 +175,13 @@ nss_tx_status_t nss_wifili_tx_msg(struct - * The interface number shall be one of the wifili soc interfaces + /* +--- a/nss_n2h_stats.c ++++ b/nss_n2h_stats.c +@@ -38,7 +38,7 @@ static ssize_t nss_n2h_stats_read(struct + * Max output lines = #stats + few blank lines for banner printing + + * Number of Extra outputlines for future reference to add new stats */ - if ((ncm->interface != NSS_WIFILI_INTERNAL_INTERFACE) +- uint32_t max_output_lines = (NSS_N2H_STATS_MAX + 3) * NSS_MAX_CORES + NSS_STATS_EXTRA_OUTPUT_LINES; ++ uint32_t max_output_lines = (NSS_N2H_STATS_MAX + 3) * 2 + 5; + size_t size_al = NSS_STATS_MAX_STR_LENGTH * max_output_lines; + size_t size_wr = 0; + ssize_t bytes_read = 0; +--- a/exports/nss_ipv6.h ++++ b/exports/nss_ipv6.h +@@ -276,10 +276,14 @@ enum nss_ipv6_exception_events { + NSS_IPV6_EXCEPTION_EVENT_TUNIPIP6_NEEDS_FRAGMENTATION, + NSS_IPV6_EXCEPTION_EVENT_PPPOE_BRIDGE_NO_ICME, + NSS_IPV6_EXCEPTION_EVENT_DONT_FRAG_SET, +#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE0) -- && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE1)) { -+ && (ncm->interface != NSS_WIFILI_EXTERNAL_INTERFACE1)) + NSS_IPV6_EXCEPTION_EVENT_REASSEMBLY_NOT_SUPPORTED, ++#endif + NSS_IPV6_EXCEPTION_EVENT_PPPOE_NO_SESSION, ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + NSS_IPV6_EXCEPTION_EVENT_ICMP_IPV6_GRE_HEADER_INCOMPLETE, + NSS_IPV6_EXCEPTION_EVENT_ICMP_IPV6_ESP_HEADER_INCOMPLETE, ++#endif + NSS_IPV6_EXCEPTION_EVENT_MAX + }; + +@@ -469,20 +473,24 @@ enum nss_ipv6_error_response_types { + /**< Invalid interface for updating multicast. */ + NSS_IPV6_CR_ACCEL_MODE_CONFIG_INVALID, + /**< Invalid config value for acceleration mode. */ ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + NSS_IPV6_CR_INVALID_MSG_ERROR, + /**< Invalid message size error. */ + NSS_IPV6_CR_DSCP2PRI_PRI_INVALID, + /**< Priority value out of range error. */ + NSS_IPV6_CR_DSCP2PRI_CONFIG_INVALID, + /**< Invalid DSCP value. */ ++#endif + NSS_IPV6_CR_INVALID_RPS, + /**< Invalid RPS Value. */ + NSS_IPV6_HASH_BITMAP_INVALID, + /**< Invalid hash bitmap. */ ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + NSS_IPV6_DR_HW_DECEL_FAIL_ERROR, + /**< Hardware deceleration fail error. */ + NSS_IPV6_CR_RETURN_EXIST_ERROR, + /**< Rule creation failed because a 5-tuple return already exists. */ ++#endif + NSS_IPV6_LAST + /**< Maximum number of error responses. */ + }; +--- a/nss_ipv6_strings.c ++++ b/nss_ipv6_strings.c +@@ -81,10 +81,14 @@ struct nss_stats_info nss_ipv6_strings_e + {"tunipip6_needs_fragmentation" , NSS_STATS_TYPE_EXCEPTION}, + {"pppoe_bridge_no_icme" , NSS_STATS_TYPE_EXCEPTION}, + {"dont_frag_set" , NSS_STATS_TYPE_EXCEPTION}, ++#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) + {"reassembly_not_supported" , NSS_STATS_TYPE_EXCEPTION}, + {"pppoe_no_session" , NSS_STATS_TYPE_DROP}, + {"icmp_gre_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, + {"icmp_esp_header_incomplete" , NSS_STATS_TYPE_EXCEPTION}, +#else -+ ) ++ {"pppoe_no_session" , NSS_STATS_TYPE_DROP}, +#endif -+ { - nss_warning("%px: tx request for interface that is not a wifili: %d", nss_ctx, ncm->interface); - return NSS_TX_FAILURE; - } -@@ -284,261 +235,31 @@ struct nss_ctx_instance *nss_wifili_get_ - EXPORT_SYMBOL(nss_wifili_get_context); - - /* -- * nss_wifili_release_external_if() -- * Release the external interface. -- */ --void nss_wifili_release_external_if(nss_if_num_t ifnum) --{ -- uint32_t idx; -- -- spin_lock_bh(&nss_wifi_eif_info.lock); -- for (idx = 0; idx < NSS_WIFILI_EXTERNAL_INTERFACE_MAX; idx++) { -- if (nss_wifi_eif_info.state_tbl[idx].ifnum != ifnum) { -- continue; -- } -- -- if (!nss_wifi_eif_info.state_tbl[idx].in_use) { -- spin_unlock_bh(&nss_wifi_eif_info.lock); -- nss_warning("%px: I/F num:%d is not in use\n", &nss_wifi_eif_info, ifnum); -- return; -- } -- -- nss_wifi_eif_info.state_tbl[idx].in_use = false; -- break; -- } -- -- spin_unlock_bh(&nss_wifi_eif_info.lock); -- -- if (idx == NSS_WIFILI_EXTERNAL_INTERFACE_MAX) { -- nss_warning("%px: Trying to release invalid ifnum:%d\n", &nss_wifi_eif_info, ifnum); -- } --} --EXPORT_SYMBOL(nss_wifili_release_external_if); -- --/* - * nss_get_available_wifili_external_if() - * Check and return the available external interface - */ --nss_if_num_t nss_get_available_wifili_external_if(void) -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) -+uint32_t nss_get_available_wifili_external_if(void) - { -- nss_if_num_t ifnum = -1; -- uint32_t idx; -- -+ struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; - /* - * Check if the external interface is registered. - * Return the interface number if not registered. - */ -- spin_lock_bh(&nss_wifi_eif_info.lock); -- for (idx = 0; idx < NSS_WIFILI_EXTERNAL_INTERFACE_MAX; idx++) { -- if (nss_wifi_eif_info.state_tbl[idx].in_use) { -- continue; -- } -- -- nss_wifi_eif_info.state_tbl[idx].in_use = true; -- ifnum = nss_wifi_eif_info.state_tbl[idx].ifnum; -- break; -+ if (!(nss_ctx->subsys_dp_register[NSS_WIFILI_EXTERNAL_INTERFACE0].ndev)) { -+ return NSS_WIFILI_EXTERNAL_INTERFACE0; - } - -- spin_unlock_bh(&nss_wifi_eif_info.lock); -- -- BUG_ON(idx == NSS_WIFILI_EXTERNAL_INTERFACE_MAX); -- return ifnum; --} --EXPORT_SYMBOL(nss_get_available_wifili_external_if); -- --/* -- * nss_wifili_get_radio_num() -- * Get NSS wifili radio count. -- * -- * Wi-Fi host driver needs to know the current radio count -- * to extract the radio priority from ini file. -- */ --uint32_t nss_wifili_get_radio_num(struct nss_ctx_instance *nss_ctx) --{ -- uint8_t core_id; -- uint32_t radio_count; -- -- nss_assert(nss_ctx); -- nss_assert(nss_ctx->id < nss_top_main.num_nss); -- -- core_id = nss_ctx->id; -- -- spin_lock_bh(&ts_db[core_id].lock); -- radio_count = ts_db[core_id].radio_count; -- spin_unlock_bh(&ts_db[core_id].lock); -- -- return radio_count; --} --EXPORT_SYMBOL(nss_wifili_get_radio_num); -- --/* -- * nss_wifili_thread_scheme_alloc() -- * Allocate NSS worker thread scheme index. -- * -- * API does search on scheme database and returns scheme index based on -- * priority of radio and free entry available. -- * Wi-Fi driver fetches radio priority from ini file and calls this API -- * to get the scheme index based on radio priority. -- * -- */ --uint8_t nss_wifili_thread_scheme_alloc(struct nss_ctx_instance *nss_ctx, -- int32_t radio_ifnum, -- enum nss_wifili_thread_scheme_priority radio_priority) --{ -- uint8_t i; -- uint8_t scheme_idx; -- uint8_t core_id; -- uint8_t next_avail_entry_idx = NSS_WIFILI_THREAD_SCHEME_ENTRY_MAX; -- -- nss_assert(nss_ctx); -- nss_assert(nss_ctx->id < nss_top_main.num_nss); -- -- core_id = nss_ctx->id; -- -- /* -- * Iterate through scheme database and allocate -- * scheme_id matching the priority requested. -- */ -- spin_lock_bh(&ts_db[core_id].lock); -- for (i = 0; i < NSS_WIFILI_THREAD_SCHEME_ENTRY_MAX; i++) { -- if (ts_db[core_id].nwtse[i].allocated) { -- continue; -- } -- -- if (radio_priority == -- ts_db[core_id].nwtse[i].scheme_priority) { -- ts_db[core_id].nwtse[i].radio_ifnum = radio_ifnum; -- ts_db[core_id].nwtse[i].radio_priority = radio_priority; -- ts_db[core_id].nwtse[i].allocated = true; -- ts_db[core_id].radio_count++; -- scheme_idx = ts_db[core_id].nwtse[i].scheme_index; -- spin_unlock_bh(&ts_db[core_id].lock); -- -- nss_info("%px: Allocated scheme index:%d radio_ifnum:%d", -- nss_ctx, -- scheme_idx, -- radio_ifnum); -- -- return scheme_idx; -- } -- -- next_avail_entry_idx = i; -- } -- -- /* -- * When radio priority does not match any of scheme entry priority -- * and database has unallocated entries, provide available unallocated entry. -- * This prevents any catastrophic failure during attach of Wi-Fi radio. -- */ -- if (next_avail_entry_idx != NSS_WIFILI_THREAD_SCHEME_ENTRY_MAX) { -- -- ts_db[core_id].nwtse[next_avail_entry_idx].radio_ifnum = radio_ifnum; -- ts_db[core_id].nwtse[next_avail_entry_idx].radio_priority = radio_priority; -- ts_db[core_id].nwtse[next_avail_entry_idx].allocated = true; -- ts_db[core_id].radio_count++; -- scheme_idx = ts_db[core_id].nwtse[next_avail_entry_idx].scheme_index; -- spin_unlock_bh(&ts_db[core_id].lock); -- -- nss_info("%px: Priority did not match for radio_ifnum:%d, allocated a next available scheme:%d", -- nss_ctx, -- radio_ifnum, -- scheme_idx); -- -- return scheme_idx; -+ if (!(nss_ctx->subsys_dp_register[NSS_WIFILI_EXTERNAL_INTERFACE1].ndev)) { -+ return NSS_WIFILI_EXTERNAL_INTERFACE1; - } -- spin_unlock_bh(&ts_db[core_id].lock); - -- nss_warning("%px: Could not find scheme - radio_ifnum:%d radio_map:%d\n", -- nss_ctx, -- radio_ifnum, -- radio_priority); -+ nss_warning("%px: No available external intefaces\n", nss_ctx); - -- return NSS_WIFILI_INVALID_SCHEME_ID; -+ return NSS_MAX_NET_INTERFACES; - } --EXPORT_SYMBOL(nss_wifili_thread_scheme_alloc); -- --/* -- * nss_wifili_thread_scheme_dealloc() -- * Reset thread scheme metadata. -- */ --void nss_wifili_thread_scheme_dealloc(struct nss_ctx_instance *nss_ctx, -- int32_t radio_ifnum) --{ -- uint32_t id; -- uint8_t core_id; -- -- nss_assert(nss_ctx); -- nss_assert(nss_ctx->id < nss_top_main.num_nss); -- -- core_id = nss_ctx->id; -- -- /* -- * Radio count cannot be zero here. -- */ -- nss_assert(ts_db[core_id].radio_count); -- -- spin_lock_bh(&ts_db[core_id].lock); -- for (id = 0; id < NSS_WIFILI_THREAD_SCHEME_ENTRY_MAX; id++) { -- if (ts_db[core_id].nwtse[id].radio_ifnum != radio_ifnum) { -- continue; -- } -- -- ts_db[core_id].nwtse[id].radio_priority = 0; -- ts_db[core_id].nwtse[id].allocated = false; -- ts_db[core_id].nwtse[id].radio_ifnum = 0; -- ts_db[core_id].radio_count--; -- break; -- } -- spin_unlock_bh(&ts_db[core_id].lock); -- -- if (id == NSS_WIFILI_THREAD_SCHEME_ENTRY_MAX) { -- nss_warning("%px: Could not find scheme database with radio_ifnum:%d", -- nss_ctx, -- radio_ifnum); -- } --} --EXPORT_SYMBOL(nss_wifili_thread_scheme_dealloc); -- --/* -- * nss_wifili_thread_scheme_db_init() -- * Initialize thread scheme database. -- */ --void nss_wifili_thread_scheme_db_init(uint8_t core_id) --{ -- uint32_t id; -- -- spin_lock_init(&ts_db[core_id].lock); -- -- /* -- * Iterate through scheme database and assign -- * scheme_id and priority for each entry -- */ -- ts_db[core_id].radio_count = 0; -- for (id = 0; id < NSS_WIFILI_THREAD_SCHEME_ENTRY_MAX; id++) { -- ts_db[core_id].nwtse[id].radio_priority = 0; -- ts_db[core_id].nwtse[id].radio_ifnum = 0; -- ts_db[core_id].nwtse[id].allocated = false; -- -- switch (id) { -- case 0: -- ts_db[core_id].nwtse[id].scheme_priority = NSS_WIFILI_HIGH_PRIORITY_SCHEME; -- ts_db[core_id].nwtse[id].scheme_index = NSS_WIFILI_THREAD_SCHEME_ID_0; -- break; -- case 1: -- ts_db[core_id].nwtse[id].scheme_priority = NSS_WIFILI_LOW_PRIORITY_SCHEME; -- ts_db[core_id].nwtse[id].scheme_index = NSS_WIFILI_THREAD_SCHEME_ID_1; -- break; -- case 2: -- case 3: -- ts_db[core_id].nwtse[id].scheme_priority = NSS_WIFILI_HIGH_PRIORITY_SCHEME; -- ts_db[core_id].nwtse[id].scheme_index = NSS_WIFILI_THREAD_SCHEME_ID_2; -- break; -- default: -- nss_warning("Invalid scheme index:%d", id); -- } -- } --} -- -+EXPORT_SYMBOL(nss_get_available_wifili_external_if); -+#endif - /* - * nss_wifili_msg_init() - * Initialize nss_wifili_msg. -@@ -598,7 +319,6 @@ void nss_unregister_wifili_if(uint32_t i - || (if_num == NSS_WIFILI_EXTERNAL_INTERFACE1)); - - nss_core_unregister_subsys_dp(nss_ctx, if_num); -- nss_wifili_release_external_if(if_num); - } - EXPORT_SYMBOL(nss_unregister_wifili_if); - -@@ -648,25 +368,16 @@ EXPORT_SYMBOL(nss_unregister_wifili_radi - void nss_wifili_register_handler(void) - { - struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[nss_top_main.wifi_handler_id]; -- uint32_t idx; - - nss_info("nss_wifili_register_handler"); - nss_core_register_handler(nss_ctx, NSS_WIFILI_INTERNAL_INTERFACE, nss_wifili_handler, NULL); -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - nss_core_register_handler(nss_ctx, NSS_WIFILI_EXTERNAL_INTERFACE0, nss_wifili_handler, NULL); - nss_core_register_handler(nss_ctx, NSS_WIFILI_EXTERNAL_INTERFACE1, nss_wifili_handler, NULL); -- -+#endif - nss_wifili_stats_dentry_create(); - nss_wifili_strings_dentry_create(); - - sema_init(&wifili_pvt.sem, 1); - init_completion(&wifili_pvt.complete); -- -- /* -- * Intialize the external interfaces info. -- */ -- spin_lock_init(&nss_wifi_eif_info.lock); -- for (idx = 0; idx < NSS_WIFILI_EXTERNAL_INTERFACE_MAX; idx++) { -- nss_wifi_eif_info.state_tbl[idx].ifnum = nss_wifili_external_tbl[idx]; -- nss_wifi_eif_info.state_tbl[idx].in_use = false; -- } - } ---- a/nss_wifili_stats.c -+++ b/nss_wifili_stats.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2017-2020, 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. -@@ -37,37 +37,6 @@ ATOMIC_NOTIFIER_HEAD(nss_wifili_stats_no - struct nss_wifili_soc_stats soc_stats[NSS_WIFILI_MAX_SOC_NUM]; - - /* -- * nss_wifili_target_type_string() -- * Convert Target Type Integer to String -- */ --void nss_wifili_target_type_to_string(uint32_t target_type, char *target_type_str) --{ -- switch (target_type) { -- -- case NSS_WIFILI_TARGET_TYPE_QCA8074: -- snprintf(target_type_str, NSS_WIFILI_SOC_STRING_SIZE_MAX, "IPQ8074 V1"); -- break; -- case NSS_WIFILI_TARGET_TYPE_QCA8074V2: -- snprintf(target_type_str, NSS_WIFILI_SOC_STRING_SIZE_MAX, "IPQ8074 V2"); -- break; -- case NSS_WIFILI_TARGET_TYPE_QCA6018: -- snprintf(target_type_str, NSS_WIFILI_SOC_STRING_SIZE_MAX, "IPQ6018"); -- break; -- case NSS_WIFILI_TARGET_TYPE_QCN9000: -- snprintf(target_type_str, NSS_WIFILI_SOC_STRING_SIZE_MAX, "QCN9000"); -- break; -- case NSS_WIFILI_TARGET_TYPE_QCA5018: -- snprintf(target_type_str, NSS_WIFILI_SOC_STRING_SIZE_MAX, "IPQ5018"); -- break; -- case NSS_WIFILI_TARGET_TYPE_QCN6122: -- snprintf(target_type_str, NSS_WIFILI_SOC_STRING_SIZE_MAX, "QCN6122"); -- break; -- default : -- snprintf(target_type_str, NSS_WIFILI_SOC_STRING_SIZE_MAX, "Unknown"); -- } --} -- --/* - * nss_wifili_stats_read() - * Read wifili statistics - */ -@@ -87,7 +56,6 @@ static ssize_t nss_wifili_stats_read(str - char *lbuf = NULL; - uint32_t soc_idx; - struct nss_wifili_stats *stats_wifili = NULL; -- char pdev_tag[NSS_WIFILI_SOC_STRING_SIZE_MAX]; - - /* - * Max number of pdev depends on type of soc (Internal/Attached). -@@ -115,17 +83,12 @@ static ssize_t nss_wifili_stats_read(str - return 0; - } - -+ size_wr += nss_stats_banner(lbuf, size_wr, size_al, "wifili", NSS_STATS_SINGLE_CORE); - - for (soc_idx = 0; soc_idx < NSS_WIFILI_MAX_SOC_NUM; soc_idx++) { -- if (soc_stats[soc_idx].soc_maxpdev == 0) { -- continue; -- } -- -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, soc_stats[soc_idx].soc_type, NSS_STATS_SINGLE_CORE); - stats_wifili = &(soc_stats[soc_idx].stats_wifili); - for (i = 0; i < soc_stats[soc_idx].soc_maxpdev; i++) { -- snprintf(pdev_tag, NSS_WIFILI_SOC_STRING_SIZE_MAX, "PDEV %d", i); -- size_wr += nss_stats_banner(lbuf, size_wr, size_al, pdev_tag, NSS_STATS_SINGLE_CORE); -+ - spin_lock_bh(&nss_top_main.stats_lock); - size_wr += nss_stats_print("wifili", "txrx", i - , nss_wifili_strings_stats_txrx -@@ -275,9 +238,6 @@ void nss_wifili_stats_sync(struct nss_ct - struct nss_wifili_stats *stats = NULL; - struct nss_wifili_device_stats *devstats = &wlsoc_stats->stats; - uint32_t index; -- char target_type_str[NSS_WIFILI_SOC_STRING_SIZE_MAX]; -- -- nss_wifili_target_type_to_string(wlsoc_stats->target_type, target_type_str); - - /* - * Max number of pdev depends on type of soc (Internal/Attached). -@@ -286,20 +246,19 @@ void nss_wifili_stats_sync(struct nss_ct - case NSS_WIFILI_INTERNAL_INTERFACE: - nwss = &soc_stats[0]; - nwss->soc_maxpdev = NSS_WIFILI_MAX_PDEV_NUM_MSG; -- snprintf(nwss->soc_type, NSS_WIFILI_SOC_STRING_SIZE_MAX, "INTERNAL: %s", target_type_str); - break; - -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - case NSS_WIFILI_EXTERNAL_INTERFACE0: - nwss = &soc_stats[1]; - nwss->soc_maxpdev = NSS_WIFILI_SOC_ATTACHED_MAX_PDEV_NUM; -- snprintf(nwss->soc_type, NSS_WIFILI_SOC_STRING_SIZE_MAX, "ATTACH 0: %s", target_type_str); - break; - - case NSS_WIFILI_EXTERNAL_INTERFACE1: - nwss = &soc_stats[2]; - nwss->soc_maxpdev = NSS_WIFILI_SOC_ATTACHED_MAX_PDEV_NUM; -- snprintf(nwss->soc_type, NSS_WIFILI_SOC_STRING_SIZE_MAX, "ATTACH 1: %s", target_type_str); - break; -+#endif - - default: - nss_warning("%px: Invalid wifili interface\n", nss_ctx); -@@ -402,10 +361,6 @@ void nss_wifili_stats_sync(struct nss_ct - devstats->txcomp_stats[index].hw_ring_empty; - stats->stats_tx_comp[index][NSS_WIFILI_STATS_TX_DESC_FREE_REAPED] += - devstats->txcomp_stats[index].ring_reaped; -- stats->stats_tx_comp[index][NSS_WIFILI_STATS_TX_CAPTURE_ENQUEUE] += -- devstats->txcomp_stats[index].tx_cap_enqueue_count; -- stats->stats_tx_comp[index][NSS_WIFILI_STATS_TX_CAPTURE_ENQUEUE_FAIL] += -- devstats->txcomp_stats[index].tx_cap_enqueue_fail_count; - } - - /* -@@ -505,7 +460,7 @@ void nss_wifili_stats_notify(struct nss_ - struct nss_wifili_stats_notification *wifili_stats; - uint32_t index = 0; - -- wifili_stats = kzalloc(sizeof(struct nss_wifili_stats_notification), in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); -+ wifili_stats = kzalloc(sizeof(struct nss_wifili_stats_notification), GFP_KERNEL); - if (!wifili_stats) { - nss_warning("%px: Failed to allocate memory for wifili stats\n", nss_ctx); - return; -@@ -517,6 +472,7 @@ void nss_wifili_stats_notify(struct nss_ - index = 0; - break; - -+#if (NSS_FW_VERSION_CODE > NSS_FW_VERSION(11,0)) - case NSS_WIFILI_EXTERNAL_INTERFACE0: - index = 1; - break; -@@ -524,6 +480,7 @@ void nss_wifili_stats_notify(struct nss_ - case NSS_WIFILI_EXTERNAL_INTERFACE1: - index = 2; - break; -+#endif - - default: - nss_warning("%px: Invalid wifili interface\n", nss_ctx); ---- a/nss_wifili_stats.h -+++ b/nss_wifili_stats.h -@@ -22,13 +22,6 @@ - #ifndef __NSS_WIFILI_STATS_H - #define __NSS_WIFILI_STATS_H - --#define NSS_WIFILI_TARGET_TYPE_QCA8074 20 --#define NSS_WIFILI_TARGET_TYPE_QCA8074V2 24 --#define NSS_WIFILI_TARGET_TYPE_QCA6018 25 --#define NSS_WIFILI_TARGET_TYPE_QCN9000 26 --#define NSS_WIFILI_TARGET_TYPE_QCA5018 29 --#define NSS_WIFILI_TARGET_TYPE_QCN6122 30 -- - #include "nss_core.h" - #include "nss_wifili_if.h" - ---- a/nss_wifili_strings.c -+++ b/nss_wifili_strings.c -@@ -1,6 +1,6 @@ - /* - ************************************************************************** -- * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2019-2020, 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 -@@ -71,12 +71,10 @@ struct nss_stats_info nss_wifili_strings - * wifili tx comp stats - */ - struct nss_stats_info nss_wifili_strings_stats_tx_comp[NSS_WIFILI_STATS_TX_DESC_FREE_MAX] = { -- {"tx_desc_free_inv_bufsrc" , NSS_STATS_TYPE_ERROR}, -- {"tx_desc_free_inv_cookie" , NSS_STATS_TYPE_SPECIAL}, -- {"tx_desc_free_hw_ring_empty" , NSS_STATS_TYPE_SPECIAL}, -- {"tx_desc_free_reaped" , NSS_STATS_TYPE_SPECIAL}, -- {"tx_capture_enqueue_count" , NSS_STATS_TYPE_SPECIAL}, -- {"tx_capture_enqueue_fail_count" , NSS_STATS_TYPE_ERROR} -+ {"tx_desc_free_inv_bufsrc" , NSS_STATS_TYPE_ERROR}, -+ {"tx_desc_free_inv_cookie" , NSS_STATS_TYPE_SPECIAL}, -+ {"tx_desc_free_hw_ring_empty" , NSS_STATS_TYPE_SPECIAL}, -+ {"tx_desc_free_reaped" , NSS_STATS_TYPE_SPECIAL} }; /* diff --git a/package/qca-nss/qca-nss-drv/patches/110-kernel-6.x-support.patch b/package/qca-nss/qca-nss-drv/patches/110-kernel-6.x-support.patch index 6d869e05de..e3e44591cd 100644 --- a/package/qca-nss/qca-nss-drv/patches/110-kernel-6.x-support.patch +++ b/package/qca-nss/qca-nss-drv/patches/110-kernel-6.x-support.patch @@ -1,6 +1,6 @@ --- a/nss_c2c_tx.c +++ b/nss_c2c_tx.c -@@ -334,6 +334,7 @@ static struct ctl_table nss_c2c_tx_table +@@ -331,6 +331,7 @@ static struct ctl_table nss_c2c_tx_table { } }; @@ -8,7 +8,7 @@ static struct ctl_table nss_c2c_tx_dir[] = { { .procname = "c2c_tx", -@@ -360,6 +361,7 @@ static struct ctl_table nss_c2c_tx_root[ +@@ -357,6 +358,7 @@ static struct ctl_table nss_c2c_tx_root[ }, { } }; @@ -16,7 +16,7 @@ static struct ctl_table_header *nss_c2c_tx_header; -@@ -378,7 +380,11 @@ void nss_c2c_tx_register_sysctl(void) +@@ -375,7 +377,11 @@ void nss_c2c_tx_register_sysctl(void) /* * Register sysctl table. */ @@ -94,20 +94,6 @@ return 0; } ---- a/nss_hal/ipq50xx/nss_hal_pvt.c -+++ b/nss_hal/ipq50xx/nss_hal_pvt.c -@@ -598,7 +598,11 @@ static int __nss_hal_request_irq(struct - return err; - } - -+#if (LINUX_VERSION_CODE > KERNEL_VERSION(6, 1, 0)) -+ netif_napi_add_weight(&nss_ctx->napi_ndev, &int_ctx->napi, napi_poll_cb, napi_wgt); -+#else - netif_napi_add(&nss_ctx->napi_ndev, &int_ctx->napi, napi_poll_cb, napi_wgt); -+#endif - int_ctx->cause = cause; - err = request_irq(irq, nss_hal_handle_irq, 0, irq_name, int_ctx); - if (err) { --- a/nss_hal/ipq60xx/nss_hal_pvt.c +++ b/nss_hal/ipq60xx/nss_hal_pvt.c @@ -614,62 +614,102 @@ static int __nss_hal_request_irq(struct @@ -460,7 +446,7 @@ /* --- a/nss_n2h.c +++ b/nss_n2h.c -@@ -1862,6 +1862,7 @@ static struct ctl_table nss_n2h_table_mu +@@ -1859,6 +1859,7 @@ static struct ctl_table nss_n2h_table_mu { } }; @@ -468,7 +454,7 @@ /* * This table will be overwritten during single-core registration */ -@@ -1891,6 +1892,7 @@ static struct ctl_table nss_n2h_root[] = +@@ -1888,6 +1889,7 @@ static struct ctl_table nss_n2h_root[] = }, { } }; @@ -476,7 +462,7 @@ static struct ctl_table_header *nss_n2h_header; -@@ -2133,8 +2135,12 @@ void nss_n2h_single_core_register_sysctl +@@ -2131,8 +2133,12 @@ void nss_n2h_single_core_register_sysctl /* * Register sysctl table. */ @@ -489,7 +475,7 @@ } /* -@@ -2232,7 +2238,11 @@ void nss_n2h_multi_core_register_sysctl( +@@ -2230,7 +2236,11 @@ void nss_n2h_multi_core_register_sysctl( /* * Register sysctl table. */ diff --git a/package/qca-nss/qca-nss-drv/patches/120-fix-conversion.patch b/package/qca-nss/qca-nss-drv/patches/120-fix-conversion.patch index 459121fc38..731a19f01c 100644 --- a/package/qca-nss/qca-nss-drv/patches/120-fix-conversion.patch +++ b/package/qca-nss/qca-nss-drv/patches/120-fix-conversion.patch @@ -1,6 +1,6 @@ --- a/nss_dynamic_interface.c +++ b/nss_dynamic_interface.c -@@ -226,7 +226,7 @@ int nss_dynamic_interface_alloc_node(enu +@@ -223,7 +223,7 @@ int nss_dynamic_interface_alloc_node(enu core_id = nss_top_main.dynamic_interface_table[type]; nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[core_id]; di_data.if_num = -1; @@ -9,7 +9,7 @@ init_completion(&di_data.complete); nss_dynamic_interface_msg_init(&ndim, NSS_DYNAMIC_INTERFACE, NSS_DYNAMIC_INTERFACE_ALLOC_NODE, -@@ -285,7 +285,7 @@ nss_tx_status_t nss_dynamic_interface_de +@@ -282,7 +282,7 @@ nss_tx_status_t nss_dynamic_interface_de core_id = nss_top_main.dynamic_interface_table[type]; nss_ctx = (struct nss_ctx_instance *)&nss_top_main.nss[core_id]; @@ -50,7 +50,7 @@ EXPORT_SYMBOL(nss_lag_tx_slave_state); --- a/nss_n2h.c +++ b/nss_n2h.c -@@ -1153,16 +1153,16 @@ static nss_tx_status_t nss_n2h_mitigatio +@@ -1150,16 +1150,16 @@ static nss_tx_status_t nss_n2h_mitigatio /* * ACK/NACK received from NSS FW */ @@ -70,7 +70,7 @@ } static inline void nss_n2h_buf_pool_free(struct nss_n2h_buf_pool *buf_pool) -@@ -1234,7 +1234,7 @@ static nss_tx_status_t nss_n2h_buf_pool_ +@@ -1231,7 +1231,7 @@ static nss_tx_status_t nss_n2h_buf_pool_ /* * ACK/NACK received from NSS FW */ @@ -79,7 +79,7 @@ nss_n2h_buf_pool_free(buf_pool); goto failure; -@@ -1243,10 +1243,10 @@ static nss_tx_status_t nss_n2h_buf_pool_ +@@ -1240,10 +1240,10 @@ static nss_tx_status_t nss_n2h_buf_pool_ up(&nss_n2h_bufcp[core_num].sem); } while(num_pages); @@ -92,7 +92,7 @@ } /* -@@ -1545,7 +1545,7 @@ static nss_tx_status_t nss_n2h_host_bp_c +@@ -1542,7 +1542,7 @@ static nss_tx_status_t nss_n2h_host_bp_c if (nss_tx_status != NSS_TX_SUCCESS) { nss_warning("%px: nss_tx error setting back pressure\n", nss_ctx); up(&nss_n2h_host_bp_cfg_pvt.sem); @@ -101,7 +101,7 @@ } /* -@@ -1555,7 +1555,7 @@ static nss_tx_status_t nss_n2h_host_bp_c +@@ -1552,7 +1552,7 @@ static nss_tx_status_t nss_n2h_host_bp_c if (ret == 0) { nss_warning("%px: Waiting for ack timed out\n", nss_ctx); up(&nss_n2h_host_bp_cfg_pvt.sem); @@ -110,7 +110,7 @@ } /* -@@ -1563,11 +1563,11 @@ static nss_tx_status_t nss_n2h_host_bp_c +@@ -1560,11 +1560,11 @@ static nss_tx_status_t nss_n2h_host_bp_c */ if (nss_n2h_host_bp_cfg_pvt.response == NSS_FAILURE) { up(&nss_n2h_host_bp_cfg_pvt.sem); diff --git a/package/qca-nss/qca-nss-ecm/Makefile b/package/qca-nss/qca-nss-ecm/Makefile index 55c1174abd..84ac984616 100644 --- a/package/qca-nss/qca-nss-ecm/Makefile +++ b/package/qca-nss/qca-nss-ecm/Makefile @@ -1,4 +1,4 @@ -# NHSS.QSDK.12.4.5.r2 +# NHSS.QSDK.11.2 - 12.4.5.r2 # by SqTER include $(TOPDIR)/rules.mk @@ -317,9 +317,7 @@ define Build/InstallDev endef define Build/Compile - +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" $(strip $(ECM_MAKE_OPTS)) \ - $(KERNEL_MAKE_FLAGS) \ - $(PKG_MAKE_FLAGS) \ + $(KERNEL_MAKE) $(strip $(ECM_MAKE_OPTS)) \ M="$(PKG_BUILD_DIR)" \ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" SoC="$(subtarget)" \ EXAMPLES_BUILD_PCC="$(CONFIG_QCA_NSS_ECM_EXAMPLES_PCC)" \ diff --git a/package/qca-nss/qca-nss-gmac/Makefile b/package/qca-nss/qca-nss-gmac/Makefile index 29526c07b2..0cb95799c0 100644 --- a/package/qca-nss/qca-nss-gmac/Makefile +++ b/package/qca-nss/qca-nss-gmac/Makefile @@ -11,7 +11,7 @@ PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/nss-gmac.git PKG_SOURCE_PROTO:=git PKG_SOURCE_DATE:=2023-06-01 PKG_SOURCE_VERSION:=171767947467662f2407d0cfff26dfb136c3fb4a -PKG_MIRROR_HASH:=3c59139b20bc607f71e8a20e14ea63e6520b2f321347cfa7b3532c15120c9947 +PKG_MIRROR_HASH:=21f8a0ce6672f9dfae9eca6490b19e49cfc51f6fdc5ba48db28c20a92af81822 include $(INCLUDE_DIR)/package.mk @@ -40,9 +40,8 @@ EXTRA_CFLAGS+= \ -I$(PKG_BUILD_DIR)/nss_hal/$(BOARD) define Build/Compile - $(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \ - $(KERNEL_MAKE_FLAGS) \ - $(PKG_MAKE_FLAGS) \ + $(KERNEL_MAKE) \ + SUBDIRS="$(PKG_BUILD_DIR)" \ M="$(PKG_BUILD_DIR)" \ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ modules